|
|
(13 intermediate revisions not shown) |
Line 1: |
Line 1: |
| <html> | | <html> |
| | | |
| + | <!-- MathJax (LaTeX for the web) --> |
| + | <script type="text/javascript" src="http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML"></script> |
| | | |
| | | |
| <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js" type="text/javascript"></script> | | <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js" type="text/javascript"></script> |
- | | + | </script> |
| | | |
| <script src="http://lokeshdhakar.com/projects/lightbox2/js/jquery-1.11.0.min.js"></script> | | <script src="http://lokeshdhakar.com/projects/lightbox2/js/jquery-1.11.0.min.js"></script> |
| <script src="http://lokeshdhakar.com/projects/lightbox2/js/lightbox.js"></script> | | <script src="http://lokeshdhakar.com/projects/lightbox2/js/lightbox.js"></script> |
- |
| |
- |
| |
- |
| |
- |
| |
- | <script language="javascript" type="text/javascript">
| |
- | (function() {
| |
- | var supports = (function() {
| |
- | var supports = {};
| |
- |
| |
- | var html;
| |
- | var work = this.document.createElement('div');
| |
- |
| |
- | html = "<P><I></P></I>";
| |
- | work.innerHTML = html;
| |
- | supports.tagSoup = work.innerHTML !== html;
| |
- |
| |
- | work.innerHTML = "<P><i><P></P></i></P>";
| |
- | supports.selfClose = work.childNodes.length === 2;
| |
- |
| |
- | return supports;
| |
- | })();
| |
- |
| |
- |
| |
- |
| |
- | // Regular Expressions for parsing tags and attributes
| |
- | var startTag = /^<([\-A-Za-z0-9_]+)((?:\s+[\w\-]+(?:\s*=\s*(?:(?:"[^"]*")|(?:'[^']*')|[^>\s]+))?)*)\s*(\/?)>/;
| |
- | var endTag = /^<\/([\-A-Za-z0-9_]+)[^>]*>/;
| |
- | var attr = /([\-A-Za-z0-9_]+)(?:\s*=\s*(?:(?:"((?:\\.|[^"])*)")|(?:'((?:\\.|[^'])*)')|([^>\s]+)))?/g;
| |
- | var fillAttr = /^(checked|compact|declare|defer|disabled|ismap|multiple|nohref|noresize|noshade|nowrap|readonly|selected)$/i;
| |
- |
| |
- | var DEBUG = false;
| |
- |
| |
- | function htmlParser(stream, options) {
| |
- | stream = stream || '';
| |
- |
| |
- | // Options
| |
- | options = options || {};
| |
- |
| |
- | for(var key in supports) {
| |
- | if(supports.hasOwnProperty(key)) {
| |
- | if(options.autoFix) {
| |
- | options['fix_'+key] = true;//!supports[key];
| |
- | }
| |
- | options.fix = options.fix || options['fix_'+key];
| |
- | }
| |
- | }
| |
- |
| |
- | var stack = [];
| |
- |
| |
- | var append = function(str) {
| |
- | stream += str;
| |
- | };
| |
- |
| |
- | var prepend = function(str) {
| |
- | stream = str + stream;
| |
- | };
| |
- |
| |
- | // Order of detection matters: detection of one can only
| |
- | // succeed if detection of previous didn't
| |
- | var detect = {
| |
- | comment: /^<!--/,
| |
- | endTag: /^<\//,
| |
- | atomicTag: /^<\s*(script|style|noscript|iframe|textarea)[\s>]/i,
| |
- | startTag: /^</,
| |
- | chars: /^[^<]/
| |
- | };
| |
- |
| |
- | // Detection has already happened when a reader is called.
| |
- | var reader = {
| |
- |
| |
- | comment: function() {
| |
- | var index = stream.indexOf("-->");
| |
- | if ( index >= 0 ) {
| |
- | return {
| |
- | content: stream.substr(4, index),
| |
- | length: index + 3
| |
- | };
| |
- | }
| |
- | },
| |
- |
| |
- | endTag: function() {
| |
- | var match = stream.match( endTag );
| |
- |
| |
- | if ( match ) {
| |
- | return {
| |
- | tagName: match[1],
| |
- | length: match[0].length
| |
- | };
| |
- | }
| |
- | },
| |
- |
| |
- | atomicTag: function() {
| |
- | var start = reader.startTag();
| |
- | if(start) {
| |
- | var rest = stream.slice(start.length);
| |
- | // for optimization, we check first just for the end tag
| |
- | if(rest.match(new RegExp("<\/\\s*" + start.tagName + "\\s*>", "i"))) {
| |
- | // capturing the content is inefficient, so we do it inside the if
| |
- | var match = rest.match(new RegExp("([\\s\\S]*?)<\/\\s*" + start.tagName + "\\s*>", "i"));
| |
- | if(match) {
| |
- | // good to go
| |
- | return {
| |
- | tagName: start.tagName,
| |
- | attrs: start.attrs,
| |
- | content: match[1],
| |
- | length: match[0].length + start.length
| |
- | };
| |
- | }
| |
- | }
| |
- | }
| |
- | },
| |
- |
| |
- | startTag: function() {
| |
- | var match = stream.match( startTag );
| |
- |
| |
- | if ( match ) {
| |
- | var attrs = {};
| |
- |
| |
- | match[2].replace(attr, function(match, name) {
| |
- | var value = arguments[2] || arguments[3] || arguments[4] ||
| |
- | fillAttr.test(name) && name || null;
| |
- |
| |
- | attrs[name] = value;
| |
- | });
| |
- |
| |
- | return {
| |
- | tagName: match[1],
| |
- | attrs: attrs,
| |
- | unary: !!match[3],
| |
- | length: match[0].length
| |
- | };
| |
- | }
| |
- | },
| |
- |
| |
- | chars: function() {
| |
- | var index = stream.indexOf("<");
| |
- | return {
| |
- | length: index >= 0 ? index : stream.length
| |
- | };
| |
- | }
| |
- | };
| |
- |
| |
- | var readToken = function() {
| |
- |
| |
- | // Enumerate detects in order
| |
- | for (var type in detect) {
| |
- |
| |
- | if(detect[type].test(stream)) {
| |
- | if(DEBUG) { console.log('suspected ' + type); }
| |
- |
| |
- | var token = reader[type]();
| |
- | if(token) {
| |
- | if(DEBUG) { console.log('parsed ' + type, token); }
| |
- | // Type
| |
- | token.type = token.type || type;
| |
- | // Entire text
| |
- | token.text = stream.substr(0, token.length);
| |
- | // Update the stream
| |
- | stream = stream.slice(token.length);
| |
- |
| |
- | return token;
| |
- | }
| |
- | return null;
| |
- | }
| |
- | }
| |
- | };
| |
- |
| |
- | var readTokens = function(handlers) {
| |
- | var tok;
| |
- | while(tok = readToken()) {
| |
- | // continue until we get an explicit "false" return
| |
- | if(handlers[tok.type] && handlers[tok.type](tok) === false) {
| |
- | return;
| |
- | }
| |
- | }
| |
- | };
| |
- |
| |
- | var clear = function() {
| |
- | var rest = stream;
| |
- | stream = '';
| |
- | return rest;
| |
- | };
| |
- |
| |
- | var rest = function() {
| |
- | return stream;
| |
- | };
| |
- |
| |
- | if(options.fix) {
| |
- | (function() {
| |
- | // Empty Elements - HTML 4.01
| |
- | var EMPTY = /^(AREA|BASE|BASEFONT|BR|COL|FRAME|HR|IMG|INPUT|ISINDEX|LINK|META|PARAM|EMBED)$/i;
| |
- |
| |
- | // Elements that you can| intentionally| leave open
| |
- | // (and which close themselves)
| |
- | var CLOSESELF = /^(COLGROUP|DD|DT|LI|OPTIONS|P|TD|TFOOT|TH|THEAD|TR)$/i;
| |
- |
| |
- |
| |
- | var stack = [];
| |
- | stack.last = function() {
| |
- | return this[this.length - 1];
| |
- | };
| |
- | stack.lastTagNameEq = function(tagName) {
| |
- | var last = this.last();
| |
- | return last && last.tagName &&
| |
- | last.tagName.toUpperCase() === tagName.toUpperCase();
| |
- | };
| |
- |
| |
- | stack.containsTagName = function(tagName) {
| |
- | for(var i = 0, tok; tok = this[i]; i++) {
| |
- | if(tok.tagName === tagName) {
| |
- | return true;
| |
- | }
| |
- | }
| |
- | return false;
| |
- | };
| |
- |
| |
- | var correct = function(tok) {
| |
- | if(tok && tok.type === 'startTag') {
| |
- | // unary
| |
- | tok.unary = EMPTY.test(tok.tagName) || tok.unary;
| |
- | }
| |
- | return tok;
| |
- | };
| |
- |
| |
- | var readTokenImpl = readToken;
| |
- |
| |
- | var peekToken = function() {
| |
- | var tmp = stream;
| |
- | var tok = correct(readTokenImpl());
| |
- | stream = tmp;
| |
- | return tok;
| |
- | };
| |
- |
| |
- | var closeLast = function() {
| |
- | var tok = stack.pop();
| |
- |
| |
- | // prepend close tag to stream.
| |
- | prepend('</'+tok.tagName+'>');
| |
- | };
| |
- |
| |
- | var handlers = {
| |
- | startTag: function(tok) {
| |
- | var tagName = tok.tagName;
| |
- | // Fix tbody
| |
- | if(tagName.toUpperCase() === 'TR' && stack.lastTagNameEq('TABLE')) {
| |
- | prepend('<TBODY>');
| |
- | prepareNextToken();
| |
- | } else if(options.fix_selfClose &&
| |
- | CLOSESELF.test(tagName) &&
| |
- | stack.containsTagName(tagName)) {
| |
- | if(stack.lastTagNameEq(tagName)) {
| |
- | closeLast();
| |
- | } else {
| |
- | prepend('</'+tok.tagName+'>');
| |
- | prepareNextToken();
| |
- | }
| |
- | } else if (!tok.unary) {
| |
- | stack.push(tok);
| |
- | }
| |
- | },
| |
- |
| |
- | endTag: function(tok) {
| |
- | var last = stack.last();
| |
- | if(last) {
| |
- | if(options.fix_tagSoup && !stack.lastTagNameEq(tok.tagName)) {
| |
- | // cleanup tag soup
| |
- | closeLast();
| |
- | } else {
| |
- | stack.pop();
| |
- | }
| |
- | } else if (options.fix_tagSoup) {
| |
- | // cleanup tag soup part 2: skip this token
| |
- | skipToken();
| |
- | }
| |
- | }
| |
- | };
| |
- |
| |
- | var skipToken = function() {
| |
- | // shift the next token
| |
- | readTokenImpl();
| |
- |
| |
- | prepareNextToken();
| |
- | };
| |
- |
| |
- | var prepareNextToken = function() {
| |
- | var tok = peekToken();
| |
- | if(tok && handlers[tok.type]) {
| |
- | handlers[tok.type](tok);
| |
- | }
| |
- | };
| |
- |
| |
- | // redefine readToken
| |
- | readToken = function() {
| |
- | prepareNextToken();
| |
- | return correct(readTokenImpl());
| |
- | };
| |
- | })();
| |
- | }
| |
- |
| |
- | return {
| |
- | append: append,
| |
- | readToken: readToken,
| |
- | readTokens: readTokens,
| |
- | clear: clear,
| |
- | rest: rest,
| |
- | stack: stack
| |
- | };
| |
- |
| |
- | }
| |
- |
| |
- | htmlParser.supports = supports;
| |
- |
| |
- | htmlParser.tokenToString = function(tok) {
| |
- | var handler = {
| |
- | comment: function(tok) {
| |
- | return '<--' + tok.content + '-->';
| |
- | },
| |
- | endTag: function(tok) {
| |
- | return '</'+tok.tagName+'>';
| |
- | },
| |
- | atomicTag: function(tok) {
| |
- | console.log(tok);
| |
- | return handler.startTag(tok) +
| |
- | tok.content +
| |
- | handler.endTag(tok);
| |
- | },
| |
- | startTag: function(tok) {
| |
- | var str = '<'+tok.tagName;
| |
- | for (var key in tok.attrs) {
| |
- | var val = tok.attrs[key];
| |
- | // escape quotes
| |
- | str += ' '+key+'="'+(val ? val.replace(/(^|[^\\])"/g, '$1\\\"') : '')+'"';
| |
- | }
| |
- | return str + (tok.unary ? '/>' : '>');
| |
- | },
| |
- | chars: function(tok) {
| |
- | return tok.text;
| |
- | }
| |
- | };
| |
- | return handler[tok.type](tok);
| |
- | };
| |
- |
| |
- | htmlParser.escapeAttributes = function(attrs) {
| |
- | var escapedAttrs = {};
| |
- | // escape double-quotes for writing html as a string
| |
- |
| |
- | for(var name in attrs) {
| |
- | var value = attrs[name];
| |
- | escapedAttrs[name] = value && value.replace(/(^|[^\\])"/g, '$1\\\"');
| |
- | }
| |
- | return escapedAttrs;
| |
- | };
| |
- |
| |
- | for(var key in supports) {
| |
- | htmlParser.browserHasFlaw = htmlParser.browserHasFlaw || (!supports[key]) && key;
| |
- | }
| |
- |
| |
- | this.htmlParser = htmlParser;
| |
- | })();
| |
- | </script>
| |
- |
| |
- |
| |
- |
| |
- | <script>
| |
- |
| |
- | // postscribe.js 1.1.2
| |
- | // (c) Copyright 2012 to the present, Krux
| |
- | // postscribe is freely distributable under the MIT license.
| |
- | // For all details and documentation:
| |
- | // http://krux.github.com/postscribe
| |
- |
| |
- |
| |
- | (function() {
| |
- |
| |
- | var global = this;
| |
- |
| |
- | if(global.postscribe) {
| |
- | return;
| |
- | }
| |
- |
| |
- | // Debug write tasks.
| |
- | var DEBUG = true;
| |
- |
| |
- | // Turn on to debug how each chunk affected the DOM.
| |
- | var DEBUG_CHUNK = false;
| |
- |
| |
- | // # Helper Functions
| |
- |
| |
- | var slice = Array.prototype.slice;
| |
- |
| |
- | // A function that intentionally does nothing.
| |
- | function doNothing() {}
| |
- |
| |
- |
| |
- | // Is this a function?
| |
- | function isFunction(x) {
| |
- | return "function" === typeof x;
| |
- | }
| |
- |
| |
- | // Loop over each item in an array-like value.
| |
- | function each(arr, fn, _this) {
| |
- | var i, len = (arr && arr.length) || 0;
| |
- | for(i = 0; i < len; i++) {
| |
- | fn.call(_this, arr[i], i);
| |
- | }
| |
- | }
| |
- |
| |
- | // Loop over each key/value pair in a hash.
| |
- | function eachKey(obj, fn, _this) {
| |
- | var key;
| |
- | for(key in obj) {
| |
- | if(obj.hasOwnProperty(key)) {
| |
- | fn.call(_this, key, obj[key]);
| |
- | }
| |
- | }
| |
- | }
| |
- |
| |
- | // Set properties on an object.
| |
- | function set(obj, props) {
| |
- | eachKey(props, function(key, value) {
| |
- | obj[key] = value;
| |
- | });
| |
- | return obj;
| |
- | }
| |
- |
| |
- | // Set default options where some option was not specified.
| |
- | function defaults(options, _defaults) {
| |
- | options = options || {};
| |
- | eachKey(_defaults, function(key, val) {
| |
- | if(options[key] == null) {
| |
- | options[key] = val;
| |
- | }
| |
- | });
| |
- | return options;
| |
- | }
| |
- |
| |
- | // Convert value (e.g., a NodeList) to an array.
| |
- | function toArray(obj) {
| |
- | try {
| |
- | return slice.call(obj);
| |
- | } catch(e) {
| |
- | var ret = [];
| |
- | each(obj, function(val) {
| |
- | ret.push(val);
| |
- | });
| |
- | return ret;
| |
- | }
| |
- | }
| |
- |
| |
- | // Test if token is a script tag.
| |
- | function isScript(tok) {
| |
- | return (/^script$/i).test(tok.tagName);
| |
- | }
| |
- |
| |
- | // # Class WriteStream
| |
- |
| |
- | // Stream static html to an element, where "static html" denotes "html without scripts".
| |
- |
| |
- | // This class maintains a *history of writes devoid of any attributes* or "proxy history".
| |
- | // Injecting the proxy history into a temporary div has no side-effects,
| |
- | // other than to create proxy elements for previously written elements.
| |
- |
| |
- | // Given the `staticHtml` of a new write, a `tempDiv`'s innerHTML is set to `proxy_history + staticHtml`.
| |
- | // The *structure* of `tempDiv`'s contents, (i.e., the placement of new nodes beside or inside of proxy elements),
| |
- | // reflects the DOM structure that would have resulted if all writes had been squashed into a single write.
| |
- |
| |
- | // For each descendent `node` of `tempDiv` whose parentNode is a *proxy*, `node` is appended to the corresponding *real* element within the DOM.
| |
- |
| |
- | // Proxy elements are mapped to *actual* elements in the DOM by injecting a data-id attribute into each start tag in `staticHtml`.
| |
- | var WriteStream = (function(){
| |
- |
| |
- | // Prefix for data attributes on DOM elements.
| |
- | var BASEATTR = 'data-ps-';
| |
- |
| |
- | // get / set data attributes
| |
- | function data(el, name, value) {
| |
- | var attr = BASEATTR + name;
| |
- |
| |
- | if(arguments.length === 2) {
| |
- | // Get
| |
- | var val = el.getAttribute(attr);
| |
- |
| |
- | // IE 8 returns a number if it's a number
| |
- | return val == null ? val : String(val);
| |
- |
| |
- | } else if( value != null && value !== '') {
| |
- | // Set
| |
- | el.setAttribute(attr, value);
| |
- |
| |
- | } else {
| |
- | // Remove
| |
- | el.removeAttribute(attr);
| |
- | }
| |
- | }
| |
- |
| |
- | function WriteStream(root, options) {
| |
- | var doc = root.ownerDocument;
| |
- |
| |
- | set(this, {
| |
- | root: root,
| |
- |
| |
- | options: options,
| |
- |
| |
- | win: doc.defaultView || doc.parentWindow,
| |
- |
| |
- | doc: doc,
| |
- |
| |
- | parser: global.htmlParser('', { autoFix: true }),
| |
- |
| |
- | // Actual elements by id.
| |
- | actuals: [root],
| |
- |
| |
- | // Embodies the "structure" of what's been written so far, devoid of attributes.
| |
- | proxyHistory: '',
| |
- |
| |
- | // Create a proxy of the root element.
| |
- | proxyRoot: doc.createElement(root.nodeName),
| |
- |
| |
- | scriptStack: [],
| |
- |
| |
- | writeQueue: []
| |
- | });
| |
- |
| |
- | data(this.proxyRoot, 'proxyof', 0);
| |
- |
| |
- | }
| |
- |
| |
- |
| |
- | WriteStream.prototype.write = function() {
| |
- | [].push.apply(this.writeQueue, arguments);
| |
- | // Process writes
| |
- | // When new script gets pushed or pending this will stop
| |
- | // because new writeQueue gets pushed
| |
- | var arg;
| |
- | while(!this.deferredRemote &&
| |
- | this.writeQueue.length) {
| |
- | arg = this.writeQueue.shift();
| |
- |
| |
- | if(isFunction(arg)) {
| |
- | this.callFunction(arg);
| |
- | } else {
| |
- | this.writeImpl(arg);
| |
- | }
| |
- | }
| |
- | };
| |
- |
| |
- | WriteStream.prototype.callFunction = function(fn) {
| |
- | var tok = { type: "function", value: fn.name || fn.toString() };
| |
- | this.onScriptStart(tok);
| |
- | fn.call(this.win, this.doc);
| |
- | this.onScriptDone(tok);
| |
- | };
| |
- |
| |
- | WriteStream.prototype.writeImpl = function(html) {
| |
- | this.parser.append(html);
| |
- |
| |
- | var tok, tokens = [];
| |
- |
| |
- | // stop if we see a script token
| |
- | while((tok = this.parser.readToken()) && !isScript(tok)) {
| |
- | tokens.push(tok);
| |
- | }
| |
- |
| |
- | this.writeStaticTokens(tokens);
| |
- |
| |
- | if(tok) {
| |
- | this.handleScriptToken(tok);
| |
- | }
| |
- | };
| |
- |
| |
- |
| |
- | // ## Contiguous non-script tokens (a chunk)
| |
- | WriteStream.prototype.writeStaticTokens = function(tokens) {
| |
- |
| |
- | var chunk = this.buildChunk(tokens);
| |
- |
| |
- | if(!chunk.actual) {
| |
- | // e.g., no tokens, or a noscript that got ignored
| |
- | return;
| |
- | }
| |
- | chunk.html = this.proxyHistory + chunk.actual;
| |
- | this.proxyHistory += chunk.proxy;
| |
- |
| |
- | this.proxyRoot.innerHTML = chunk.html;
| |
- |
| |
- | if(DEBUG_CHUNK) {
| |
- | chunk.proxyInnerHTML = this.proxyRoot.innerHTML;
| |
- | }
| |
- |
| |
- | this.walkChunk();
| |
- |
| |
- | if(DEBUG_CHUNK) {
| |
- | chunk.actualInnerHTML = this.root.innerHTML; //root
| |
- | }
| |
- |
| |
- | return chunk;
| |
- | };
| |
- |
| |
- |
| |
- | WriteStream.prototype.buildChunk = function (tokens) {
| |
- | var nextId = this.actuals.length,
| |
- |
| |
- | // The raw html of this chunk.
| |
- | raw = [],
| |
- |
| |
- | // The html to create the nodes in the tokens (with id's injected).
| |
- | actual = [],
| |
- |
| |
- | // Html that can later be used to proxy the nodes in the tokens.
| |
- | proxy = [];
| |
- |
| |
- | each(tokens, function(tok) {
| |
- |
| |
- | raw.push(tok.text);
| |
- |
| |
- | if(tok.attrs) { // tok.attrs <==> startTag or atomicTag or cursor
| |
- | // Ignore noscript tags. They are atomic, so we don't have to worry about children.
| |
- | if(!(/^noscript$/i).test(tok.tagName)) {
| |
- | var id = nextId++;
| |
- |
| |
- | // Actual: inject id attribute: replace '>' at end of start tag with id attribute + '>'
| |
- | actual.push(
| |
- | tok.text.replace(/(\/?>)/, ' '+BASEATTR+'id='+id+' $1')
| |
- | );
| |
- |
| |
- | // Don't proxy scripts: they have no bearing on DOM structure.
| |
- | if(tok.attrs.id !== "ps-script") {
| |
- | // Proxy: strip all attributes and inject proxyof attribute
| |
- | proxy.push(
| |
- | // ignore atomic tags (e.g., style): they have no "structural" effect
| |
- | tok.type === 'atomicTag' ? '' :
| |
- | '<'+tok.tagName+' '+BASEATTR+'proxyof='+id+(tok.unary ? '/>' : '>')
| |
- | );
| |
- | }
| |
- | }
| |
- |
| |
- | } else {
| |
- | // Visit any other type of token
| |
- | // Actual: append.
| |
- | actual.push(tok.text);
| |
- | // Proxy: append endTags. Ignore everything else.
| |
- | proxy.push(tok.type === 'endTag' ? tok.text : '');
| |
- | }
| |
- | });
| |
- |
| |
- | return {
| |
- | tokens: tokens,
| |
- | raw: raw.join(''),
| |
- | actual: actual.join(''),
| |
- | proxy: proxy.join('')
| |
- | };
| |
- | };
| |
- |
| |
- | WriteStream.prototype.walkChunk = function() {
| |
- | var node, stack = [this.proxyRoot];
| |
- |
| |
- | // use shift/unshift so that children are walked in document order
| |
- |
| |
- | while((node = stack.shift()) != null) {
| |
- |
| |
- | var isElement = node.nodeType === 1;
| |
- | var isProxy = isElement && data(node, 'proxyof');
| |
- |
| |
- | // Ignore proxies
| |
- | if(!isProxy) {
| |
- |
| |
- | if(isElement) {
| |
- | // New actual element: register it and remove the the id attr.
| |
- | this.actuals[data(node, 'id')] = node;
| |
- | data(node, 'id', null);
| |
- | }
| |
- |
| |
- | // Is node's parent a proxy?
| |
- | var parentIsProxyOf = node.parentNode && data(node.parentNode, 'proxyof');
| |
- | if(parentIsProxyOf) {
| |
- | // Move node under actual parent.
| |
- | this.actuals[parentIsProxyOf].appendChild(node);
| |
- | }
| |
- | }
| |
- | // prepend childNodes to stack
| |
- | stack.unshift.apply(stack, toArray(node.childNodes));
| |
- | }
| |
- | };
| |
- |
| |
- | // ### Script tokens
| |
- |
| |
- | WriteStream.prototype.handleScriptToken = function(tok) {
| |
- | var remainder = this.parser.clear();
| |
- |
| |
- | if(remainder) {
| |
- | // Write remainder immediately behind this script.
| |
- | this.writeQueue.unshift(remainder);
| |
- | }
| |
- |
| |
- | tok.src = tok.attrs.src || tok.attrs.SRC;
| |
- |
| |
- | if(tok.src && this.scriptStack.length) {
| |
- | // Defer this script until scriptStack is empty.
| |
- | // Assumption 1: This script will not start executing until
| |
- | // scriptStack is empty.
| |
- | this.deferredRemote = tok;
| |
- | } else {
| |
- | this.onScriptStart(tok);
| |
- | }
| |
- |
| |
- | // Put the script node in the DOM.
| |
- | var _this = this;
| |
- | this.writeScriptToken(tok, function() {
| |
- | _this.onScriptDone(tok);
| |
- | });
| |
- |
| |
- | };
| |
- |
| |
- | WriteStream.prototype.onScriptStart = function(tok) {
| |
- | tok.outerWrites = this.writeQueue;
| |
- | this.writeQueue = [];
| |
- | this.scriptStack.unshift(tok);
| |
- | };
| |
- |
| |
- | WriteStream.prototype.onScriptDone = function(tok) {
| |
- | // Pop script and check nesting.
| |
- | if(tok !== this.scriptStack[0]) {
| |
- | this.options.error({ message: "Bad script nesting or script finished twice" });
| |
- | return;
| |
- | }
| |
- | this.scriptStack.shift();
| |
- |
| |
- | // Append outer writes to queue and process them.
| |
- | this.write.apply(this, tok.outerWrites);
| |
- |
| |
- | // Check for pending remote
| |
- |
| |
- | // Assumption 2: if remote_script1 writes remote_script2 then
| |
- | // the we notice remote_script1 finishes before remote_script2 starts.
| |
- | // I think this is equivalent to assumption 1
| |
- | if(!this.scriptStack.length && this.deferredRemote) {
| |
- | this.onScriptStart(this.deferredRemote);
| |
- | this.deferredRemote = null;
| |
- | }
| |
- | };
| |
- |
| |
- | // Build a script and insert it into the DOM.
| |
- | // Done is called once script has executed.
| |
- | WriteStream.prototype.writeScriptToken = function(tok, done) {
| |
- | var el = this.buildScript(tok);
| |
- |
| |
- | if(tok.src) {
| |
- | // Fix for attribute "SRC" (capitalized). IE does not recognize it.
| |
- | el.src = tok.src;
| |
- | this.scriptLoadHandler(el, done);
| |
- | }
| |
- |
| |
- | try {
| |
- | this.insertScript(el);
| |
- | if(!tok.src) {
| |
- | done();
| |
- | }
| |
- | } catch(e) {
| |
- | this.options.error(e);
| |
- | done();
| |
- | }
| |
- | };
| |
- |
| |
- | // Build a script element from an atomic script token.
| |
- | WriteStream.prototype.buildScript = function(tok) {
| |
- | var el = this.doc.createElement(tok.tagName);
| |
- |
| |
- | // Set attributes
| |
- | eachKey(tok.attrs, function(name, value) {
| |
- | el.setAttribute(name, value);
| |
- | });
| |
- |
| |
- | // Set content
| |
- | if(tok.content) {
| |
- | el.text = tok.content;
| |
- | }
| |
- |
| |
- | return el;
| |
- | };
| |
- |
| |
- |
| |
- | // Insert script into DOM where it would naturally be written.
| |
- | WriteStream.prototype.insertScript = function(el) {
| |
- | // Append a span to the stream. That span will act as a cursor
| |
- | // (i.e. insertion point) for the script.
| |
- | this.writeImpl('<span id="ps-script"/>');
| |
- |
| |
- | // Grab that span from the DOM.
| |
- | var cursor = this.doc.getElementById("ps-script");
| |
- |
| |
- | // Replace cursor with script.
| |
- | cursor.parentNode.replaceChild(el, cursor);
| |
- | };
| |
- |
| |
- |
| |
- | WriteStream.prototype.scriptLoadHandler = function(el, done) {
| |
- | function cleanup() {
| |
- | el = el.onload = el.onreadystatechange = el.onerror = null;
| |
- | done();
| |
- | }
| |
- |
| |
- | // Error handler
| |
- | var error = this.options.error;
| |
- |
| |
- | // Set handlers
| |
- | set(el, {
| |
- | onload: function() { cleanup(); },
| |
- |
| |
- | onreadystatechange: function() {
| |
- | if(/^(loaded|complete)$/.test( el.readyState )) {
| |
- | cleanup();
| |
- | }
| |
- | },
| |
- |
| |
- | onerror: function() {
| |
- | error({ message: 'remote script failed ' + el.src });
| |
- | cleanup();
| |
- | }
| |
- | });
| |
- | };
| |
- |
| |
- | return WriteStream;
| |
- |
| |
- | }());
| |
- |
| |
- |
| |
- |
| |
- |
| |
- |
| |
- |
| |
- | // Public-facing interface and queuing
| |
- | var postscribe = (function() {
| |
- | var nextId = 0;
| |
- |
| |
- | var queue = [];
| |
- |
| |
- | var active = null;
| |
- |
| |
- | function nextStream() {
| |
- | var args = queue.shift();
| |
- | if(args) {
| |
- | args.stream = runStream.apply(null, args);
| |
- | }
| |
- | }
| |
- |
| |
- |
| |
- | function runStream(el, html, options) {
| |
- | active = new WriteStream(el, options);
| |
- |
| |
- | // Identify this stream.
| |
- | active.id = nextId++;
| |
- | active.name = options.name || active.id;
| |
- | postscribe.streams[active.name] = active;
| |
- |
| |
- | // Override document.write.
| |
- | var doc = el.ownerDocument;
| |
- |
| |
- | var stash = { write: doc.write, writeln: doc.writeln };
| |
- |
| |
- | function write(str) {
| |
- | str = options.beforeWrite(str);
| |
- | active.write(str);
| |
- | options.afterWrite(str);
| |
- | }
| |
- |
| |
- | set(doc, { write: write, writeln: function(str) { write(str + '\n'); } });
| |
- |
| |
- | // Override window.onerror
| |
- | var oldOnError = active.win.onerror || doNothing;
| |
- |
| |
- | // This works together with the try/catch around WriteStream::insertScript
| |
- | // In modern browsers, exceptions in tag scripts go directly to top level
| |
- | active.win.onerror = function(msg, url, line) {
| |
- | options.error({ msg: msg + ' - ' + url + ':' + line });
| |
- | oldOnError.apply(active.win, arguments);
| |
- | };
| |
- |
| |
- | // Write to the stream
| |
- | active.write(html, function streamDone() {
| |
- | // restore document.write
| |
- | set(doc, stash);
| |
- |
| |
- | // restore window.onerror
| |
- | active.win.onerror = oldOnError;
| |
- |
| |
- | options.done();
| |
- | active = null;
| |
- | nextStream();
| |
- | });
| |
- |
| |
- | return active;
| |
- | }
| |
- |
| |
- |
| |
- | function postscribe(el, html, options) {
| |
- | if(isFunction(options)) {
| |
- | options = { done: options };
| |
- | }
| |
- | options = defaults(options, {
| |
- | done: doNothing,
| |
- | error: function(e) { throw e; },
| |
- | beforeWrite: function(str) { return str; },
| |
- | afterWrite: doNothing
| |
- | });
| |
- |
| |
- | el =
| |
- | // id selector
| |
- | (/^#/).test(el) ? global.document.getElementById(el.substr(1)) :
| |
- | // jquery object. TODO: loop over all elements.
| |
- | el.jquery ? el[0] : el;
| |
- |
| |
- |
| |
- | var args = [el, html, options];
| |
- |
| |
- | el.postscribe = {
| |
- | cancel: function() {
| |
- | if(args.stream) {
| |
- | // TODO: implement this
| |
- | args.stream.abort();
| |
- | } else {
| |
- | args[1] = doNothing;
| |
- | }
| |
- | }
| |
- | };
| |
- |
| |
- | queue.push(args);
| |
- | if(!active) {
| |
- | nextStream();
| |
- | }
| |
- |
| |
- | return el.postscribe;
| |
- | }
| |
- |
| |
- | return set(postscribe, {
| |
- | // Streams by name.
| |
- | streams: {},
| |
- | // Queue of streams.
| |
- | queue: queue,
| |
- | // Expose internal classes.
| |
- | WriteStream: WriteStream
| |
- | });
| |
- |
| |
- | }());
| |
- |
| |
- | // export postscribe
| |
- | global.postscribe = postscribe;
| |
- |
| |
- | }());
| |
- |
| |
- | </script>
| |
- |
| |
- | <script>
| |
- |
| |
- | /**
| |
- | * AJAX Banner placement
| |
- | *
| |
- | * @param {int} uid
| |
- | * @param {int} lang
| |
- | * @param {int} typeNum
| |
- | * @param {string} startingPoint
| |
- | * @param {string} categories
| |
- | * @param {string} displayMode
| |
- | * @param {string} position
| |
- | * @param {string} hmac
| |
- | * @constructor
| |
- | */
| |
- | var BannerPlacement = function (uid, lang, typeNum, startingPoint, categories, displayMode, position, hmac) {
| |
- | var url = 'index.php?id=' + uid;
| |
- | url += '&L=' + lang;
| |
- | url += '&type=' + typeNum;
| |
- | url += '&tx_sfbanners_pi1[action]=getBanners';
| |
- | url += '&tx_sfbanners_pi1[currentPageUid]=' + uid;
| |
- | url += '&tx_sfbanners_pi1[hmac]=' + hmac;
| |
- |
| |
- | if (typeof startingPoint !== 'undefined' && startingPoint !== '') {
| |
- | url += '&tx_sfbanners_pi1[startingPoint]=' + startingPoint;
| |
- | }
| |
- |
| |
- | if (typeof categories !== 'undefined' && categories !== '') {
| |
- | url += '&tx_sfbanners_pi1[categories]=' + categories;
| |
- | }
| |
- |
| |
- | if (typeof displayMode !== 'undefined' && displayMode !== '') {
| |
- | url += '&tx_sfbanners_pi1[displayMode]=' + displayMode;
| |
- | }
| |
- |
| |
- | $.get(url, function(data) {
| |
- | postscribe('#' + position, data);
| |
- | });
| |
- | }
| |
- |
| |
- | </script>
| |
- |
| |
- | <script>
| |
- | /*
| |
- | * jQuery FlexSlider v2.1
| |
- | * Copyright 2012 WooThemes
| |
- | * Contributing Author: Tyler Smith
| |
- | */
| |
- | ; (function(d){d.flexslider=function(i,k){var a=d(i),c=d.extend({},d.flexslider.defaults,k),e=c.namespace,r="ontouchstart"in window||window.DocumentTouch&&document instanceof DocumentTouch,s=r?"touchend":"click",l="vertical"===c.direction,m=c.reverse,h=0<c.itemWidth,q="fade"===c.animation,p=""!==c.asNavFor,f={};d.data(i,"flexslider",a);f={init:function(){a.animating=!1;a.currentSlide=c.startAt;a.animatingTo=a.currentSlide;a.atEnd=0===a.currentSlide||a.currentSlide===a.last;a.containerSelector=c.selector.substr(0,
| |
- | c.selector.search(" "));a.slides=d(c.selector,a);a.container=d(a.containerSelector,a);a.count=a.slides.length;a.syncExists=0<d(c.sync).length;"slide"===c.animation&&(c.animation="swing");a.prop=l?"top":"marginLeft";a.args={};a.manualPause=!1;var b=a,g;if(g=!c.video)if(g=!q)if(g=c.useCSS)a:{g=document.createElement("div");var n=["perspectiveProperty","WebkitPerspective","MozPerspective","OPerspective","msPerspective"],e;for(e in n)if(void 0!==g.style[n[e]]){a.pfx=n[e].replace("Perspective","").toLowerCase();
| |
- | a.prop="-"+a.pfx+"-transform";g=!0;break a}g=!1}b.transitions=g;""!==c.controlsContainer&&(a.controlsContainer=0<d(c.controlsContainer).length&&d(c.controlsContainer));""!==c.manualControls&&(a.manualControls=0<d(c.manualControls).length&&d(c.manualControls));c.randomize&&(a.slides.sort(function(){return Math.round(Math.random())-0.5}),a.container.empty().append(a.slides));a.doMath();p&&f.asNav.setup();a.setup("init");c.controlNav&&f.controlNav.setup();c.directionNav&&f.directionNav.setup();c.keyboard&&
| |
- | (1===d(a.containerSelector).length||c.multipleKeyboard)&&d(document).bind("keyup",function(b){b=b.keyCode;if(!a.animating&&(b===39||b===37)){b=b===39?a.getTarget("next"):b===37?a.getTarget("prev"):false;a.flexAnimate(b,c.pauseOnAction)}});c.mousewheel&&a.bind("mousewheel",function(b,g){b.preventDefault();var d=g<0?a.getTarget("next"):a.getTarget("prev");a.flexAnimate(d,c.pauseOnAction)});c.pausePlay&&f.pausePlay.setup();c.slideshow&&(c.pauseOnHover&&a.hover(function(){!a.manualPlay&&!a.manualPause&&
| |
- | a.pause()},function(){!a.manualPause&&!a.manualPlay&&a.play()}),0<c.initDelay?setTimeout(a.play,c.initDelay):a.play());r&&c.touch&&f.touch();(!q||q&&c.smoothHeight)&&d(window).bind("resize focus",f.resize);setTimeout(function(){c.start(a)},200)},asNav:{setup:function(){a.asNav=!0;a.animatingTo=Math.floor(a.currentSlide/a.move);a.currentItem=a.currentSlide;a.slides.removeClass(e+"active-slide").eq(a.currentItem).addClass(e+"active-slide");a.slides.click(function(b){b.preventDefault();var b=d(this),
| |
- | g=b.index();!d(c.asNavFor).data("flexslider").animating&&!b.hasClass("active")&&(a.direction=a.currentItem<g?"next":"prev",a.flexAnimate(g,c.pauseOnAction,!1,!0,!0))})}},controlNav:{setup:function(){a.manualControls?f.controlNav.setupManual():f.controlNav.setupPaging()},setupPaging:function(){var b=1,g;a.controlNavScaffold=d('<ol class="'+e+"control-nav "+e+("thumbnails"===c.controlNav?"control-thumbs":"control-paging")+'"></ol>');if(1<a.pagingCount)for(var n=0;n<a.pagingCount;n++)g="thumbnails"===
| |
- | c.controlNav?'<img src="'+a.slides.eq(n).attr("data-thumb")+'"/>':"<a>"+b+"</a>",a.controlNavScaffold.append("<li>"+g+"</li>"),b++;a.controlsContainer?d(a.controlsContainer).append(a.controlNavScaffold):a.append(a.controlNavScaffold);f.controlNav.set();f.controlNav.active();a.controlNavScaffold.delegate("a, img",s,function(b){b.preventDefault();var b=d(this),g=a.controlNav.index(b);b.hasClass(e+"active")||(a.direction=g>a.currentSlide?"next":"prev",a.flexAnimate(g,c.pauseOnAction))});r&&a.controlNavScaffold.delegate("a",
| |
- | "click touchstart",function(a){a.preventDefault()})},setupManual:function(){a.controlNav=a.manualControls;f.controlNav.active();a.controlNav.live(s,function(b){b.preventDefault();var b=d(this),g=a.controlNav.index(b);b.hasClass(e+"active")||(g>a.currentSlide?a.direction="next":a.direction="prev",a.flexAnimate(g,c.pauseOnAction))});r&&a.controlNav.live("click touchstart",function(a){a.preventDefault()})},set:function(){a.controlNav=d("."+e+"control-nav li "+("thumbnails"===c.controlNav?"img":"a"),
| |
- | a.controlsContainer?a.controlsContainer:a)},active:function(){a.controlNav.removeClass(e+"active").eq(a.animatingTo).addClass(e+"active")},update:function(b,c){1<a.pagingCount&&"add"===b?a.controlNavScaffold.append(d("<li><a>"+a.count+"</a></li>")):1===a.pagingCount?a.controlNavScaffold.find("li").remove():a.controlNav.eq(c).closest("li").remove();f.controlNav.set();1<a.pagingCount&&a.pagingCount!==a.controlNav.length?a.update(c,b):f.controlNav.active()}},directionNav:{setup:function(){var b=d('<ul class="'+
| |
- | e+'direction-nav"><li><a class="'+e+'prev" href="#">'+c.prevText+'</a></li><li><a class="'+e+'next" href="#">'+c.nextText+"</a></li></ul>");a.controlsContainer?(d(a.controlsContainer).append(b),a.directionNav=d("."+e+"direction-nav li a",a.controlsContainer)):(a.append(b),a.directionNav=d("."+e+"direction-nav li a",a));f.directionNav.update();a.directionNav.bind(s,function(b){b.preventDefault();b=d(this).hasClass(e+"next")?a.getTarget("next"):a.getTarget("prev");a.flexAnimate(b,c.pauseOnAction)});
| |
- | r&&a.directionNav.bind("click touchstart",function(a){a.preventDefault()})},update:function(){var b=e+"disabled";1===a.pagingCount?a.directionNav.addClass(b):c.animationLoop?a.directionNav.removeClass(b):0===a.animatingTo?a.directionNav.removeClass(b).filter("."+e+"prev").addClass(b):a.animatingTo===a.last?a.directionNav.removeClass(b).filter("."+e+"next").addClass(b):a.directionNav.removeClass(b)}},pausePlay:{setup:function(){var b=d('<div class="'+e+'pauseplay"><a></a></div>');a.controlsContainer?
| |
- | (a.controlsContainer.append(b),a.pausePlay=d("."+e+"pauseplay a",a.controlsContainer)):(a.append(b),a.pausePlay=d("."+e+"pauseplay a",a));f.pausePlay.update(c.slideshow?e+"pause":e+"play");a.pausePlay.bind(s,function(b){b.preventDefault();if(d(this).hasClass(e+"pause")){a.manualPause=true;a.manualPlay=false;a.pause()}else{a.manualPause=false;a.manualPlay=true;a.play()}});r&&a.pausePlay.bind("click touchstart",function(a){a.preventDefault()})},update:function(b){"play"===b?a.pausePlay.removeClass(e+
| |
- | "pause").addClass(e+"play").text(c.playText):a.pausePlay.removeClass(e+"play").addClass(e+"pause").text(c.pauseText)}},touch:function(){function b(b){j=l?d-b.touches[0].pageY:d-b.touches[0].pageX;p=l?Math.abs(j)<Math.abs(b.touches[0].pageX-e):Math.abs(j)<Math.abs(b.touches[0].pageY-e);if(!p||500<Number(new Date)-k)b.preventDefault(),!q&&a.transitions&&(c.animationLoop||(j/=0===a.currentSlide&&0>j||a.currentSlide===a.last&&0<j?Math.abs(j)/o+2:1),a.setProps(f+j,"setTouch"))}function g(){if(a.animatingTo===
| |
- | a.currentSlide&&!p&&null!==j){var h=m?-j:j,l=0<h?a.getTarget("next"):a.getTarget("prev");a.canAdvance(l)&&(550>Number(new Date)-k&&50<Math.abs(h)||Math.abs(h)>o/2)?a.flexAnimate(l,c.pauseOnAction):a.flexAnimate(a.currentSlide,c.pauseOnAction,!0)}i.removeEventListener("touchmove",b,!1);i.removeEventListener("touchend",g,!1);f=j=e=d=null}var d,e,f,o,j,k,p=!1;i.addEventListener("touchstart",function(j){a.animating?j.preventDefault():1===j.touches.length&&(a.pause(),o=l?a.h:a.w,k=Number(new Date),f=h&&
| |
- | m&&a.animatingTo===a.last?0:h&&m?a.limit-(a.itemW+c.itemMargin)*a.move*a.animatingTo:h&&a.currentSlide===a.last?a.limit:h?(a.itemW+c.itemMargin)*a.move*a.currentSlide:m?(a.last-a.currentSlide+a.cloneOffset)*o:(a.currentSlide+a.cloneOffset)*o,d=l?j.touches[0].pageY:j.touches[0].pageX,e=l?j.touches[0].pageX:j.touches[0].pageY,i.addEventListener("touchmove",b,!1),i.addEventListener("touchend",g,!1))},!1)},resize:function(){!a.animating&&a.is(":visible")&&(h||a.doMath(),q?f.smoothHeight():h?(a.slides.width(a.computedW),
| |
- | a.update(a.pagingCount),a.setProps()):l?(a.viewport.height(a.h),a.setProps(a.h,"setTotal")):(c.smoothHeight&&f.smoothHeight(),a.newSlides.width(a.computedW),a.setProps(a.computedW,"setTotal")))},smoothHeight:function(b){if(!l||q){var c=q?a:a.viewport;b?c.animate({height:a.slides.eq(a.animatingTo).height()},b):c.height(a.slides.eq(a.animatingTo).height())}},sync:function(b){var g=d(c.sync).data("flexslider"),e=a.animatingTo;switch(b){case "animate":g.flexAnimate(e,c.pauseOnAction,!1,!0);break;case "play":!g.playing&&
| |
- | !g.asNav&&g.play();break;case "pause":g.pause()}}};a.flexAnimate=function(b,g,n,i,k){p&&1===a.pagingCount&&(a.direction=a.currentItem<b?"next":"prev");if(!a.animating&&(a.canAdvance(b,k)||n)&&a.is(":visible")){if(p&&i)if(n=d(c.asNavFor).data("flexslider"),a.atEnd=0===b||b===a.count-1,n.flexAnimate(b,!0,!1,!0,k),a.direction=a.currentItem<b?"next":"prev",n.direction=a.direction,Math.ceil((b+1)/a.visible)-1!==a.currentSlide&&0!==b)a.currentItem=b,a.slides.removeClass(e+"active-slide").eq(b).addClass(e+
| |
- | "active-slide"),b=Math.floor(b/a.visible);else return a.currentItem=b,a.slides.removeClass(e+"active-slide").eq(b).addClass(e+"active-slide"),!1;a.animating=!0;a.animatingTo=b;c.before(a);g&&a.pause();a.syncExists&&!k&&f.sync("animate");c.controlNav&&f.controlNav.active();h||a.slides.removeClass(e+"active-slide").eq(b).addClass(e+"active-slide");a.atEnd=0===b||b===a.last;c.directionNav&&f.directionNav.update();b===a.last&&(c.end(a),c.animationLoop||a.pause());if(q)a.slides.eq(a.currentSlide).fadeOut(c.animationSpeed,
| |
- | c.easing),a.slides.eq(b).fadeIn(c.animationSpeed,c.easing,a.wrapup);else{var o=l?a.slides.filter(":first").height():a.computedW;h?(b=c.itemWidth>a.w?2*c.itemMargin:c.itemMargin,b=(a.itemW+b)*a.move*a.animatingTo,b=b>a.limit&&1!==a.visible?a.limit:b):b=0===a.currentSlide&&b===a.count-1&&c.animationLoop&&"next"!==a.direction?m?(a.count+a.cloneOffset)*o:0:a.currentSlide===a.last&&0===b&&c.animationLoop&&"prev"!==a.direction?m?0:(a.count+1)*o:m?(a.count-1-b+a.cloneOffset)*o:(b+a.cloneOffset)*o;a.setProps(b,
| |
- | "",c.animationSpeed);if(a.transitions){if(!c.animationLoop||!a.atEnd)a.animating=!1,a.currentSlide=a.animatingTo;a.container.unbind("webkitTransitionEnd transitionend");a.container.bind("webkitTransitionEnd transitionend",function(){a.wrapup(o)})}else a.container.animate(a.args,c.animationSpeed,c.easing,function(){a.wrapup(o)})}c.smoothHeight&&f.smoothHeight(c.animationSpeed)}};a.wrapup=function(b){!q&&!h&&(0===a.currentSlide&&a.animatingTo===a.last&&c.animationLoop?a.setProps(b,"jumpEnd"):a.currentSlide===
| |
- | a.last&&(0===a.animatingTo&&c.animationLoop)&&a.setProps(b,"jumpStart"));a.animating=!1;a.currentSlide=a.animatingTo;c.after(a)};a.animateSlides=function(){a.animating||a.flexAnimate(a.getTarget("next"))};a.pause=function(){clearInterval(a.animatedSlides);a.playing=!1;c.pausePlay&&f.pausePlay.update("play");a.syncExists&&f.sync("pause")};a.play=function(){a.animatedSlides=setInterval(a.animateSlides,c.slideshowSpeed);a.playing=!0;c.pausePlay&&f.pausePlay.update("pause");a.syncExists&&f.sync("play")};
| |
- | a.canAdvance=function(b,g){var d=p?a.pagingCount-1:a.last;return g?!0:p&&a.currentItem===a.count-1&&0===b&&"prev"===a.direction?!0:p&&0===a.currentItem&&b===a.pagingCount-1&&"next"!==a.direction?!1:b===a.currentSlide&&!p?!1:c.animationLoop?!0:a.atEnd&&0===a.currentSlide&&b===d&&"next"!==a.direction?!1:a.atEnd&&a.currentSlide===d&&0===b&&"next"===a.direction?!1:!0};a.getTarget=function(b){a.direction=b;return"next"===b?a.currentSlide===a.last?0:a.currentSlide+1:0===a.currentSlide?a.last:a.currentSlide-
| |
- | 1};a.setProps=function(b,g,d){var e,f=b?b:(a.itemW+c.itemMargin)*a.move*a.animatingTo;e=-1*function(){if(h)return"setTouch"===g?b:m&&a.animatingTo===a.last?0:m?a.limit-(a.itemW+c.itemMargin)*a.move*a.animatingTo:a.animatingTo===a.last?a.limit:f;switch(g){case "setTotal":return m?(a.count-1-a.currentSlide+a.cloneOffset)*b:(a.currentSlide+a.cloneOffset)*b;case "setTouch":return b;case "jumpEnd":return m?b:a.count*b;case "jumpStart":return m?a.count*b:b;default:return b}}()+"px";a.transitions&&(e=l?
| |
- | "translate3d(0,"+e+",0)":"translate3d("+e+",0,0)",d=void 0!==d?d/1E3+"s":"0s",a.container.css("-"+a.pfx+"-transition-duration",d));a.args[a.prop]=e;(a.transitions||void 0===d)&&a.container.css(a.args)};a.setup=function(b){if(q)a.slides.css({width:"100%","float":"left",marginRight:"-100%",position:"relative"}),"init"===b&&a.slides.eq(a.currentSlide).fadeIn(c.animationSpeed,c.easing),c.smoothHeight&&f.smoothHeight();else{var g,n;"init"===b&&(a.viewport=d('<div class="'+e+'viewport"></div>').css({overflow:"hidden",
| |
- | position:"relative"}).appendTo(a).append(a.container),a.cloneCount=0,a.cloneOffset=0,m&&(n=d.makeArray(a.slides).reverse(),a.slides=d(n),a.container.empty().append(a.slides)));c.animationLoop&&!h&&(a.cloneCount=2,a.cloneOffset=1,"init"!==b&&a.container.find(".clone").remove(),a.container.append(a.slides.first().clone().addClass("clone")).prepend(a.slides.last().clone().addClass("clone")));a.newSlides=d(c.selector,a);g=m?a.count-1-a.currentSlide+a.cloneOffset:a.currentSlide+a.cloneOffset;l&&!h?(a.container.height(200*
| |
- | (a.count+a.cloneCount)+"%").css("position","absolute").width("100%"),setTimeout(function(){a.newSlides.css({display:"block"});a.doMath();a.viewport.height(a.h);a.setProps(g*a.h,"init")},"init"===b?100:0)):(a.container.width(200*(a.count+a.cloneCount)+"%"),a.setProps(g*a.computedW,"init"),setTimeout(function(){a.doMath();a.newSlides.css({width:a.computedW,"float":"left",display:"block"});c.smoothHeight&&f.smoothHeight()},"init"===b?100:0))}h||a.slides.removeClass(e+"active-slide").eq(a.currentSlide).addClass(e+
| |
- | "active-slide")};a.doMath=function(){var b=a.slides.first(),d=c.itemMargin,e=c.minItems,f=c.maxItems;a.w=a.width();a.h=b.height();a.boxPadding=b.outerWidth()-b.width();h?(a.itemT=c.itemWidth+d,a.minW=e?e*a.itemT:a.w,a.maxW=f?f*a.itemT:a.w,a.itemW=a.minW>a.w?(a.w-d*e)/e:a.maxW<a.w?(a.w-d*f)/f:c.itemWidth>a.w?a.w:c.itemWidth,a.visible=Math.floor(a.w/(a.itemW+d)),a.move=0<c.move&&c.move<a.visible?c.move:a.visible,a.pagingCount=Math.ceil((a.count-a.visible)/a.move+1),a.last=a.pagingCount-1,a.limit=1===
| |
- | a.pagingCount?0:c.itemWidth>a.w?(a.itemW+2*d)*a.count-a.w-d:(a.itemW+d)*a.count-a.w-d):(a.itemW=a.w,a.pagingCount=a.count,a.last=a.count-1);a.computedW=a.itemW-a.boxPadding};a.update=function(b,d){a.doMath();h||(b<a.currentSlide?a.currentSlide+=1:b<=a.currentSlide&&0!==b&&(a.currentSlide-=1),a.animatingTo=a.currentSlide);if(c.controlNav&&!a.manualControls)if("add"===d&&!h||a.pagingCount>a.controlNav.length)f.controlNav.update("add");else if("remove"===d&&!h||a.pagingCount<a.controlNav.length)h&&a.currentSlide>
| |
- | a.last&&(a.currentSlide-=1,a.animatingTo-=1),f.controlNav.update("remove",a.last);c.directionNav&&f.directionNav.update()};a.addSlide=function(b,e){var f=d(b);a.count+=1;a.last=a.count-1;l&&m?void 0!==e?a.slides.eq(a.count-e).after(f):a.container.prepend(f):void 0!==e?a.slides.eq(e).before(f):a.container.append(f);a.update(e,"add");a.slides=d(c.selector+":not(.clone)",a);a.setup();c.added(a)};a.removeSlide=function(b){var e=isNaN(b)?a.slides.index(d(b)):b;a.count-=1;a.last=a.count-1;isNaN(b)?d(b,
| |
- | a.slides).remove():l&&m?a.slides.eq(a.last).remove():a.slides.eq(b).remove();a.doMath();a.update(e,"remove");a.slides=d(c.selector+":not(.clone)",a);a.setup();c.removed(a)};f.init()};d.flexslider.defaults={namespace:"flex-",selector:".slides > li",animation:"fade",easing:"swing",direction:"horizontal",reverse:!1,animationLoop:!0,smoothHeight:!1,startAt:0,slideshow:!0,slideshowSpeed:7E3,animationSpeed:600,initDelay:0,randomize:!1,pauseOnAction:!0,pauseOnHover:!1,useCSS:!0,touch:!0,video:!1,controlNav:!0,
| |
- | directionNav:!0,prevText:"Previous",nextText:"Next",keyboard:!0,multipleKeyboard:!1,mousewheel:!1,pausePlay:!1,pauseText:"Pause",playText:"Play",controlsContainer:"",manualControls:"",sync:"",asNavFor:"",itemWidth:0,itemMargin:0,minItems:0,maxItems:0,move:0,start:function(){},before:function(){},after:function(){},end:function(){},added:function(){},removed:function(){}};d.fn.flexslider=function(i){void 0===i&&(i={});if("object"===typeof i)return this.each(function(){var a=d(this),c=a.find(i.selector?
| |
- | i.selector:".slides > li");1===c.length?(c.fadeIn(400),i.start&&i.start(a)):void 0===a.data("flexslider")&&new d.flexslider(this,i)});var k=d(this).data("flexslider");switch(i){case "play":k.play();break;case "pause":k.pause();break;case "next":k.flexAnimate(k.getTarget("next"),!0);break;case "prev":case "previous":k.flexAnimate(k.getTarget("prev"),!0);break;default:"number"===typeof i&&k.flexAnimate(i,!0)}}})(jQuery);
| |
- |
| |
- | </script>
| |
- |
| |
- |
| |
- | <script>
| |
- | // Can also be used with $(document).ready()
| |
- | jQuery(window).load(function() {
| |
- | jQuery('#slider').flexslider({
| |
- | animation: "slide"
| |
- | });
| |
- | jQuery('#slider img').removeAttr('width').removeAttr('height');
| |
- | });
| |
- | </script>
| |
- |
| |
- | <script src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML" type="text/javascript"></script>
| |
- |
| |
- | <script>
| |
- |
| |
- | // decrypt helper function
| |
- | function decryptCharcode(n,start,end,offset) {
| |
- | n = n + offset;
| |
- | if (offset > 0 && n > end) {
| |
- | n = start + (n - end - 1);
| |
- | } else if (offset < 0 && n < start) {
| |
- | n = end - (start - n - 1);
| |
- | }
| |
- | return String.fromCharCode(n);
| |
- | }
| |
- | // decrypt string
| |
- | function decryptString(enc,offset) {
| |
- | var dec = "";
| |
- | var len = enc.length;
| |
- | for(var i=0; i < len; i++) {
| |
- | var n = enc.charCodeAt(i);
| |
- | if (n >= 0x2B && n <= 0x3A) {
| |
- | dec += decryptCharcode(n,0x2B,0x3A,offset); // 0-9 . , - + / :
| |
- | } else if (n >= 0x40 && n <= 0x5A) {
| |
- | dec += decryptCharcode(n,0x40,0x5A,offset); // A-Z @
| |
- | } else if (n >= 0x61 && n <= 0x7A) {
| |
- | dec += decryptCharcode(n,0x61,0x7A,offset); // a-z
| |
- | } else {
| |
- | dec += enc.charAt(i);
| |
- | }
| |
- | }
| |
- | return dec;
| |
- | }
| |
- | // decrypt spam-protected emails
| |
- | function linkTo_UnCryptMailto(s) {
| |
- | location.href = decryptString(s,-2);
| |
- | }
| |
- |
| |
- | </script>
| |
- | <script>
| |
- | /**
| |
- | * Baseurl
| |
- | *
| |
- | * @type {string}
| |
- | */
| |
- | var baseurl;
| |
- |
| |
- | /**
| |
- | * Powermail main JavaScript for form validation
| |
- | */
| |
- | jQuery(document).ready(function($) {
| |
- |
| |
- | // Read baseURL
| |
- | baseurl = getBaseUrl();
| |
- |
| |
- | // Tabs
| |
- | if ($.fn.powermailTabs) {
| |
- | $('.powermail_morestep').powermailTabs();
| |
- | }
| |
- |
| |
- | // Location field
| |
- | if ($('.powermail_fieldwrap_location input').length) {
| |
- | getLocationAndWrite();
| |
- | }
| |
- |
| |
- | // AJAX Form submit
| |
- | if ($('form[data-powermail-ajax]').length) {
| |
- | ajaxFormSubmit();
| |
- | }
| |
- |
| |
- | // Datepicker field
| |
- | if ($.fn.datetimepicker) {
| |
- | $('.powermail_date').each(function() {
| |
- | var $this = $(this);
| |
- | // stop javascript datepicker, if browser supports type="date" or "datetime-local" or "time"
| |
- | if ($this.prop('type') === 'date' || $this.prop('type') === 'datetime-local' || $this.prop('type') === 'time') {
| |
- | if ($this.data('datepicker-force')) {
| |
- | // rewrite input type
| |
- | $this.prop('type', 'text');
| |
- | } else {
| |
- | // get date in format Y-m-d H:i for html5 date fields
| |
- | if ($(this).data('date-value')) {
| |
- | $(this).val(
| |
- | getDatetimeForDateFields($(this).data('date-value'), $(this).data('datepicker-format'), $this.prop('type'))
| |
- | );
| |
- | }
| |
- |
| |
- | // stop js datepicker
| |
- | return;
| |
- | }
| |
- | }
| |
- |
| |
- | var datepickerStatus = true;
| |
- | var timepickerStatus = true;
| |
- | if ($this.data('datepicker-settings') === 'date') {
| |
- | timepickerStatus = false;
| |
- | } else if ($this.data('datepicker-settings') === 'time') {
| |
- | datepickerStatus = false;
| |
- | }
| |
- |
| |
- | // create datepicker
| |
- | $this.datetimepicker({
| |
- | format: $this.data('datepicker-format'),
| |
- | timepicker: timepickerStatus,
| |
- | datepicker: datepickerStatus,
| |
- | lang: 'en',
| |
- | i18n:{
| |
- | en:{
| |
- | months: $this.data('datepicker-months').split(','),
| |
- | dayOfWeek: $this.data('datepicker-days').split(',')
| |
- | }
| |
- | }
| |
- | });
| |
- | });
| |
- | }
| |
- |
| |
- | // File Upload Delete
| |
- | $('.powermail_fieldwrap_file_inner').find('.deleteAllFiles').each(function() {
| |
- | // initially hide upload fields
| |
- | disableUploadField($(this).closest('.powermail_fieldwrap_file_inner').find('input[type="file"]'));
| |
- | });
| |
- | $('.deleteAllFiles').click(function() {
| |
- | enableUploadField($(this).closest('.powermail_fieldwrap_file_inner').find('input[type="file"]'));
| |
- | $(this).closest('ul').fadeOut(function() {
| |
- | $(this).remove();
| |
- | });
| |
- | });
| |
- | function disableUploadField(element) {
| |
- | element.prop('disabled', 'disabled').addClass('hide');
| |
- | }
| |
- | function enableUploadField(element) {
| |
- | element.removeProp('disabled').removeClass('hide');
| |
- | }
| |
- |
| |
- | // Password Field Output
| |
- | $('.powermail_all_type_password.powermail_all_value').html('********');
| |
- | });
| |
- |
| |
- | /**
| |
- | * Allow AJAX Submit for powermail
| |
- | *
| |
- | * @return void
| |
- | */
| |
- | function ajaxFormSubmit() {
| |
- | // submit is called after parsley and html5 validation - so we don't have to check for errors
| |
- | $(document).on('submit', 'form[data-powermail-ajax]', function (e) {
| |
- | var $this = $(this);
| |
- | var formUid = $this.data('powermail-form');
| |
- |
| |
- | $.ajax({
| |
- | type: 'POST',
| |
- | url: $this.prop('action'),
| |
- | data: $this.serialize(),
| |
- | beforeSend: function() {
| |
- | // add progressbar <div class="powermail_progressbar"><div class="powermail_progress"><div class="powermail_progess_inner"></div></div></div>
| |
- | var progressBar = $('<div />').addClass('powermail_progressbar').html(
| |
- | $('<div />').addClass('powermail_progress').html(
| |
- | $('<div />').addClass('powermail_progess_inner')
| |
- | )
| |
- | );
| |
- | $('.powermail_submit', $this).parent().append(progressBar);
| |
- | $('.powermail_confirmation_submit, .powermail_confirmation_form', $this).closest('.powermail_confirmation').append(progressBar);
| |
- | },
| |
- | complete: function() {
| |
- | // remove progressbar
| |
- | $('.powermail_fieldwrap_submit', $this).find('.powermail_progressbar').remove();
| |
- | },
| |
- | success: function(data) {
| |
- | var html = $('*[data-powermail-form="' + formUid + '"]:first', data);
| |
- | $('.tx-powermail').html(html);
| |
- | // fire tabs and parsley again
| |
- | if ($.fn.powermailTabs) {
| |
- | $('.powermail_morestep').powermailTabs();
| |
- | }
| |
- | if ($.fn.parsley) {
| |
- | $('form[data-parsley-validate="data-parsley-validate"]').parsley();
| |
- | }
| |
- | }
| |
- | });
| |
- |
| |
- | e.preventDefault();
| |
- | });
| |
- | }
| |
- |
| |
- | /**
| |
- | * Convert date format for html5 date fields
| |
- | * 31.08.2014 => 2014-08-31
| |
- | *
| |
- | * @param value
| |
- | * @param format
| |
- | * @param type
| |
- | * @returns {string}
| |
- | */
| |
- | function getDatetimeForDateFields(value, format, type) {
| |
- | var date = new Date(Date.parseDate(value, format));
| |
- | var valueDate = date.getFullYear() + '-';
| |
- | valueDate += ('0' + (date.getMonth() + 1)).slice(-2) + '-';
| |
- | valueDate += ('0' + date.getDate()).slice(-2);
| |
- | var valueTime = ('0' + date.getHours()).slice(-2) + ':' + ('0' + date.getMinutes()).slice(-2);
| |
- | var valueDateTime = valueDate + 'T' + valueTime;
| |
- |
| |
- | if (type === 'date') {
| |
- | return valueDate;
| |
- | }
| |
- | if (type === 'datetime-local') {
| |
- | return valueDateTime;
| |
- | }
| |
- | if (type === 'time') {
| |
- | return valueTime;
| |
- | }
| |
- | return 'error';
| |
- | }
| |
- |
| |
- | /**
| |
- | * Getting the Location by the browser and write to inputform as address
| |
- | *
| |
- | * @return void
| |
- | */
| |
- | function getLocationAndWrite() {
| |
- | if (navigator.geolocation) { // Read location from Browser
| |
- | navigator.geolocation.getCurrentPosition(function(position) {
| |
- | var lat = position.coords.latitude;
| |
- | var lng = position.coords.longitude;
| |
- | var url = baseurl + '/index.php' + '?eID=' + 'powermailEidGetLocation';
| |
- | jQuery.ajax({
| |
- | url: url,
| |
- | data: 'lat=' + lat + '&lng=' + lng,
| |
- | cache: false,
| |
- | beforeSend: function(jqXHR, settings) {
| |
- | jQuery('body').css('cursor', 'wait');
| |
- | },
| |
- | complete: function(jqXHR, textStatus) {
| |
- | jQuery('body').css('cursor', 'default');
| |
- | },
| |
- | success: function(data) { // return values
| |
- | if (data) {
| |
- | jQuery('.powermail_fieldwrap_location input').val(data);
| |
- | }
| |
- | }
| |
- | });
| |
- | });
| |
- | }
| |
- | }
| |
- |
| |
- | /**
| |
- | * Return BaseUrl as prefix
| |
- | *
| |
- | * @return string Base Url
| |
- | */
| |
- | function getBaseUrl() {
| |
- | var baseurl;
| |
- | if (jQuery('base').length > 0) {
| |
- | baseurl = jQuery('base').prop('href');
| |
- | } else {
| |
- | if (window.location.protocol != "https:") {
| |
- | baseurl = 'http://' + window.location.hostname;
| |
- | } else {
| |
- | baseurl = 'https://' + window.location.hostname;
| |
- | }
| |
- | }
| |
- | return baseurl;
| |
- | }
| |
- |
| |
- |
| |
- | </script>
| |
- | <script>
| |
- | /*!
| |
- | * Parsleyjs
| |
- | * Guillaume Potier - <guillaume@wisembly.com>
| |
- | * Version 2.0.5 - built Thu Aug 28 2014 11:33:36
| |
- | * MIT Licensed
| |
- | *
| |
- | */
| |
- | !function(a){"function"==typeof define&&define.amd?define(["jquery"],a):a(jQuery)}(function(a){"undefined"==typeof a&&"undefined"!=typeof window.jQuery&&(a=window.jQuery);var b={attr:function(a,b,c){var d,e={},f=this.msieversion(),g=new RegExp("^"+b,"i");if("undefined"==typeof a||"undefined"==typeof a[0])return{};for(var h in a[0].attributes)if(d=a[0].attributes[h],"undefined"!=typeof d&&null!==d&&(!f||f>=8||d.specified)&&g.test(d.name)){if("undefined"!=typeof c&&new RegExp(c+"$","i").test(d.name))return!0;e[this.camelize(d.name.replace(b,""))]=this.deserializeValue(d.value)}return"undefined"==typeof c?e:!1},setAttr:function(a,b,c,d){a[0].setAttribute(this.dasherize(b+c),String(d))},get:function(a,b){for(var c=0,d=(b||"").split(".");this.isObject(a)||this.isArray(a);)if(a=a[d[c++]],c===d.length)return a;return void 0},hash:function(a){return String(Math.random()).substring(2,a?a+2:9)},isArray:function(a){return"[object Array]"===Object.prototype.toString.call(a)},isObject:function(a){return a===Object(a)},deserializeValue:function(b){var c;try{return b?"true"==b||("false"==b?!1:"null"==b?null:isNaN(c=Number(b))?/^[\[\{]/.test(b)?a.parseJSON(b):b:c):b}catch(d){return b}},camelize:function(a){return a.replace(/-+(.)?/g,function(a,b){return b?b.toUpperCase():""})},dasherize:function(a){return a.replace(/::/g,"/").replace(/([A-Z]+)([A-Z][a-z])/g,"$1_$2").replace(/([a-z\d])([A-Z])/g,"$1_$2").replace(/_/g,"-").toLowerCase()},msieversion:function(){var a=window.navigator.userAgent,b=a.indexOf("MSIE ");return b>0||navigator.userAgent.match(/Trident.*rv\:11\./)?parseInt(a.substring(b+5,a.indexOf(".",b)),10):0}},c={namespace:"data-parsley-",inputs:"input, textarea, select",excluded:"input[type=button], input[type=submit], input[type=reset], input[type=hidden]",priorityEnabled:!0,uiEnabled:!0,validationThreshold:3,focus:"first",trigger:!1,errorClass:"parsley-error",successClass:"parsley-success",classHandler:function(){},errorsContainer:function(){},errorsWrapper:'<ul class="parsley-errors-list"></ul>',errorTemplate:"<li></li>"},d=function(){};d.prototype={asyncSupport:!1,actualizeOptions:function(){return this.options=this.OptionsFactory.get(this),this},validateThroughValidator:function(a,b,c){return window.ParsleyValidator.validate.apply(window.ParsleyValidator,[a,b,c])},subscribe:function(b,c){return a.listenTo(this,b.toLowerCase(),c),this},unsubscribe:function(b){return a.unsubscribeTo(this,b.toLowerCase()),this},reset:function(){if("ParsleyForm"!==this.__class__)return a.emit("parsley:field:reset",this);for(var b=0;b<this.fields.length;b++)a.emit("parsley:field:reset",this.fields[b]);a.emit("parsley:form:reset",this)},destroy:function(){if("ParsleyForm"!==this.__class__)return this.$element.removeData("Parsley"),this.$element.removeData("ParsleyFieldMultiple"),void a.emit("parsley:field:destroy",this);for(var b=0;b<this.fields.length;b++)this.fields[b].destroy();this.$element.removeData("Parsley"),a.emit("parsley:form:destroy",this)}};var e=function(){var a={},b=function(a){this.__class__="Validator",this.__version__="1.0.0",this.options=a||{},this.bindingKey=this.options.bindingKey||"_validatorjsConstraint"};b.prototype={constructor:b,validate:function(a,b,c){if("string"!=typeof a&&"object"!=typeof a)throw new Error("You must validate an object or a string");return"string"==typeof a||g(a)?this._validateString(a,b,c):this.isBinded(a)?this._validateBindedObject(a,b):this._validateObject(a,b,c)},bind:function(a,b){if("object"!=typeof a)throw new Error("Must bind a Constraint to an object");return a[this.bindingKey]=new c(b),this},unbind:function(a){return"undefined"==typeof a._validatorjsConstraint?this:(delete a[this.bindingKey],this)},isBinded:function(a){return"undefined"!=typeof a[this.bindingKey]},getBinded:function(a){return this.isBinded(a)?a[this.bindingKey]:null},_validateString:function(a,b,c){var f,h=[];g(b)||(b=[b]);for(var i=0;i<b.length;i++){if(!(b[i]instanceof e))throw new Error("You must give an Assert or an Asserts array to validate a string");f=b[i].check(a,c),f instanceof d&&h.push(f)}return h.length?h:!0},_validateObject:function(a,b,d){if("object"!=typeof b)throw new Error("You must give a constraint to validate an object");return b instanceof c?b.check(a,d):new c(b).check(a,d)},_validateBindedObject:function(a,b){return a[this.bindingKey].check(a,b)}},b.errorCode={must_be_a_string:"must_be_a_string",must_be_an_array:"must_be_an_array",must_be_a_number:"must_be_a_number",must_be_a_string_or_array:"must_be_a_string_or_array"};var c=function(a,b){if(this.__class__="Constraint",this.options=b||{},this.nodes={},a)try{this._bootstrap(a)}catch(c){throw new Error("Should give a valid mapping object to Constraint",c,a)}};c.prototype={constructor:c,check:function(a,b){var c,d={};for(var h in this.nodes){for(var i=!1,j=this.get(h),k=g(j)?j:[j],l=k.length-1;l>=0;l--)"Required"!==k[l].__class__||(i=k[l].requiresValidation(b));if(this.has(h,a)||this.options.strict||i)try{this.has(h,this.options.strict||i?a:void 0)||(new e).HaveProperty(h).validate(a),c=this._check(h,a[h],b),(g(c)&&c.length>0||!g(c)&&!f(c))&&(d[h]=c)}catch(m){d[h]=m}}return f(d)?!0:d},add:function(a,b){if(b instanceof e||g(b)&&b[0]instanceof e)return this.nodes[a]=b,this;if("object"==typeof b&&!g(b))return this.nodes[a]=b instanceof c?b:new c(b),this;throw new Error("Should give an Assert, an Asserts array, a Constraint",b)},has:function(a,b){return b="undefined"!=typeof b?b:this.nodes,"undefined"!=typeof b[a]},get:function(a,b){return this.has(a)?this.nodes[a]:b||null},remove:function(a){var b=[];for(var c in this.nodes)c!==a&&(b[c]=this.nodes[c]);return this.nodes=b,this},_bootstrap:function(a){if(a instanceof c)return this.nodes=a.nodes;for(var b in a)this.add(b,a[b])},_check:function(a,b,d){if(this.nodes[a]instanceof e)return this._checkAsserts(b,[this.nodes[a]],d);if(g(this.nodes[a]))return this._checkAsserts(b,this.nodes[a],d);if(this.nodes[a]instanceof c)return this.nodes[a].check(b,d);throw new Error("Invalid node",this.nodes[a])},_checkAsserts:function(a,b,c){for(var d,e=[],f=0;f<b.length;f++)d=b[f].check(a,c),"undefined"!=typeof d&&!0!==d&&e.push(d);return e}};var d=function(a,b,c){if(this.__class__="Violation",!(a instanceof e))throw new Error("Should give an assertion implementing the Assert interface");this.assert=a,this.value=b,"undefined"!=typeof c&&(this.violation=c)};d.prototype={show:function(){var a={assert:this.assert.__class__,value:this.value};return this.violation&&(a.violation=this.violation),a},__toString:function(){return"undefined"!=typeof this.violation&&(this.violation='", '+this.getViolation().constraint+" expected was "+this.getViolation().expected),this.assert.__class__+' assert failed for "'+this.value+this.violation||""},getViolation:function(){var a,b;for(a in this.violation)b=this.violation[a];return{constraint:a,expected:b}}};var e=function(a){this.__class__="Assert",this.__parentClass__=this.__class__,this.groups=[],"undefined"!=typeof a&&this.addGroup(a)};e.prototype={construct:e,requiresValidation:function(a){return a&&!this.hasGroup(a)?!1:!a&&this.hasGroups()?!1:!0},check:function(a,b){if(this.requiresValidation(b))try{return this.validate(a,b)}catch(c){return c}},hasGroup:function(a){return g(a)?this.hasOneOf(a):"Any"===a?!0:this.hasGroups()?-1!==this.groups.indexOf(a):"Default"===a},hasOneOf:function(a){for(var b=0;b<a.length;b++)if(this.hasGroup(a[b]))return!0;return!1},hasGroups:function(){return this.groups.length>0},addGroup:function(a){return g(a)?this.addGroups(a):(this.hasGroup(a)||this.groups.push(a),this)},removeGroup:function(a){for(var b=[],c=0;c<this.groups.length;c++)a!==this.groups[c]&&b.push(this.groups[c]);return this.groups=b,this},addGroups:function(a){for(var b=0;b<a.length;b++)this.addGroup(a[b]);return this},HaveProperty:function(a){return this.__class__="HaveProperty",this.node=a,this.validate=function(a){if("undefined"==typeof a[this.node])throw new d(this,a,{value:this.node});return!0},this},Blank:function(){return this.__class__="Blank",this.validate=function(a){if("string"!=typeof a)throw new d(this,a,{value:b.errorCode.must_be_a_string});if(""!==a.replace(/^\s+/g,"").replace(/\s+$/g,""))throw new d(this,a);return!0},this},Callback:function(a){if(this.__class__="Callback",this.arguments=Array.prototype.slice.call(arguments),1===this.arguments.length?this.arguments=[]:this.arguments.splice(0,1),"function"!=typeof a)throw new Error("Callback must be instanciated with a function");return this.fn=a,this.validate=function(a){var b=this.fn.apply(this,[a].concat(this.arguments));if(!0!==b)throw new d(this,a,{result:b});return!0},this},Choice:function(a){if(this.__class__="Choice",!g(a)&&"function"!=typeof a)throw new Error("Choice must be instanciated with an array or a function");return this.list=a,this.validate=function(a){for(var b="function"==typeof this.list?this.list():this.list,c=0;c<b.length;c++)if(a===b[c])return!0;throw new d(this,a,{choices:b})},this},Collection:function(a){return this.__class__="Collection",this.constraint="undefined"!=typeof a?a instanceof e?a:new c(a):!1,this.validate=function(a,c){var e,h=new b,i=0,j={},k=this.groups.length?this.groups:c;if(!g(a))throw new d(this,array,{value:b.errorCode.must_be_an_array});for(var l=0;l<a.length;l++)e=this.constraint?h.validate(a[l],this.constraint,k):h.validate(a[l],k),f(e)||(j[i]=e),i++;return f(j)?!0:j},this},Count:function(a){return this.__class__="Count",this.count=a,this.validate=function(a){if(!g(a))throw new d(this,a,{value:b.errorCode.must_be_an_array});var c="function"==typeof this.count?this.count(a):this.count;if(isNaN(Number(c)))throw new Error("Count must be a valid interger",c);if(c!==a.length)throw new d(this,a,{count:c});return!0},this},Email:function(){return this.__class__="Email",this.validate=function(a){var c=/^((([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+(\.([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+)*)|((\x22)((((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(([\x01-\x08\x0b\x0c\x0e-\x1f\x7f]|\x21|[\x23-\x5b]|[\x5d-\x7e]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(\\([\x01-\x09\x0b\x0c\x0d-\x7f]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]))))*(((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(\x22)))@((([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.)+(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))$/i;if("string"!=typeof a)throw new d(this,a,{value:b.errorCode.must_be_a_string});if(!c.test(a))throw new d(this,a);return!0},this},EqualTo:function(a){if(this.__class__="EqualTo","undefined"==typeof a)throw new Error("EqualTo must be instanciated with a value or a function");return this.reference=a,this.validate=function(a){var b="function"==typeof this.reference?this.reference(a):this.reference;if(b!==a)throw new d(this,a,{value:b});return!0},this},GreaterThan:function(a){if(this.__class__="GreaterThan","undefined"==typeof a)throw new Error("Should give a threshold value");return this.threshold=a,this.validate=function(a){if(""===a||isNaN(Number(a)))throw new d(this,a,{value:b.errorCode.must_be_a_number});if(this.threshold>=a)throw new d(this,a,{threshold:this.threshold});return!0},this},GreaterThanOrEqual:function(a){if(this.__class__="GreaterThanOrEqual","undefined"==typeof a)throw new Error("Should give a threshold value");return this.threshold=a,this.validate=function(a){if(""===a||isNaN(Number(a)))throw new d(this,a,{value:b.errorCode.must_be_a_number});if(this.threshold>a)throw new d(this,a,{threshold:this.threshold});return!0},this},InstanceOf:function(a){if(this.__class__="InstanceOf","undefined"==typeof a)throw new Error("InstanceOf must be instanciated with a value");return this.classRef=a,this.validate=function(a){if(!0!=a instanceof this.classRef)throw new d(this,a,{classRef:this.classRef});return!0},this},Length:function(a){if(this.__class__="Length",!a.min&&!a.max)throw new Error("Lenth assert must be instanciated with a { min: x, max: y } object");return this.min=a.min,this.max=a.max,this.validate=function(a){if("string"!=typeof a&&!g(a))throw new d(this,a,{value:b.errorCode.must_be_a_string_or_array});if("undefined"!=typeof this.min&&this.min===this.max&&a.length!==this.min)throw new d(this,a,{min:this.min,max:this.max});if("undefined"!=typeof this.max&&a.length>this.max)throw new d(this,a,{max:this.max});if("undefined"!=typeof this.min&&a.length<this.min)throw new d(this,a,{min:this.min});return!0},this},LessThan:function(a){if(this.__class__="LessThan","undefined"==typeof a)throw new Error("Should give a threshold value");return this.threshold=a,this.validate=function(a){if(""===a||isNaN(Number(a)))throw new d(this,a,{value:b.errorCode.must_be_a_number});if(this.threshold<=a)throw new d(this,a,{threshold:this.threshold});return!0},this},LessThanOrEqual:function(a){if(this.__class__="LessThanOrEqual","undefined"==typeof a)throw new Error("Should give a threshold value");return this.threshold=a,this.validate=function(a){if(""===a||isNaN(Number(a)))throw new d(this,a,{value:b.errorCode.must_be_a_number});if(this.threshold<a)throw new d(this,a,{threshold:this.threshold});return!0},this},NotNull:function(){return this.__class__="NotNull",this.validate=function(a){if(null===a||"undefined"==typeof a)throw new d(this,a);return!0},this},NotBlank:function(){return this.__class__="NotBlank",this.validate=function(a){if("string"!=typeof a)throw new d(this,a,{value:b.errorCode.must_be_a_string});if(""===a.replace(/^\s+/g,"").replace(/\s+$/g,""))throw new d(this,a);return!0},this},Null:function(){return this.__class__="Null",this.validate=function(a){if(null!==a)throw new d(this,a);return!0},this},Range:function(a,b){if(this.__class__="Range","undefined"==typeof a||"undefined"==typeof b)throw new Error("Range assert expects min and max values");return this.min=a,this.max=b,this.validate=function(a){try{return"string"==typeof a&&isNaN(Number(a))||g(a)?(new e).Length({min:this.min,max:this.max}).validate(a):(new e).GreaterThanOrEqual(this.min).validate(a)&&(new e).LessThanOrEqual(this.max).validate(a),!0}catch(b){throw new d(this,a,b.violation)}return!0},this},Regexp:function(a,c){if(this.__class__="Regexp","undefined"==typeof a)throw new Error("You must give a regexp");return this.regexp=a,this.flag=c||"",this.validate=function(a){if("string"!=typeof a)throw new d(this,a,{value:b.errorCode.must_be_a_string});if(!new RegExp(this.regexp,this.flag).test(a))throw new d(this,a,{regexp:this.regexp,flag:this.flag});return!0},this},Required:function(){return this.__class__="Required",this.validate=function(a){if("undefined"==typeof a)throw new d(this,a);try{"string"==typeof a?(new e).NotNull().validate(a)&&(new e).NotBlank().validate(a):!0===g(a)&&(new e).Length({min:1}).validate(a)}catch(b){throw new d(this,a)}return!0},this},Unique:function(a){return this.__class__="Unique","object"==typeof a&&(this.key=a.key),this.validate=function(a){var c,e=[];if(!g(a))throw new d(this,a,{value:b.errorCode.must_be_an_array});for(var f=0;f<a.length;f++)if(c="object"==typeof a[f]?a[f][this.key]:a[f],"undefined"!=typeof c){if(-1!==e.indexOf(c))throw new d(this,a,{value:c});e.push(c)}return!0},this}},a.Assert=e,a.Validator=b,a.Violation=d,a.Constraint=c,Array.prototype.indexOf||(Array.prototype.indexOf=function(a){if(null===this)throw new TypeError;var b=Object(this),c=b.length>>>0;if(0===c)return-1;var d=0;if(arguments.length>1&&(d=Number(arguments[1]),d!=d?d=0:0!==d&&1/0!=d&&d!=-1/0&&(d=(d>0||-1)*Math.floor(Math.abs(d)))),d>=c)return-1;for(var e=d>=0?d:Math.max(c-Math.abs(d),0);c>e;e++)if(e in b&&b[e]===a)return e;return-1});var f=function(a){for(var b in a)return!1;return!0},g=function(a){return"[object Array]"===Object.prototype.toString.call(a)};return"function"==typeof define&&define.amd?define("vendors/validator.js/dist/validator",[],function(){return a}):"undefined"!=typeof module&&module.exports?module.exports=a:window["undefined"!=typeof validatorjs_ns?validatorjs_ns:"Validator"]=a,a}();e="undefined"!=typeof e?e:"undefined"!=typeof module?module.exports:null;var f=function(a,b){this.__class__="ParsleyValidator",this.Validator=e,this.locale="en",this.init(a||{},b||{})};f.prototype={init:function(b,c){this.catalog=c;for(var d in b)this.addValidator(d,b[d].fn,b[d].priority,b[d].requirementsTransformer);a.emit("parsley:validator:init")},setLocale:function(a){if("undefined"==typeof this.catalog[a])throw new Error(a+" is not available in the catalog");return this.locale=a,this},addCatalog:function(a,b,c){return"object"==typeof b&&(this.catalog[a]=b),!0===c?this.setLocale(a):this},addMessage:function(a,b,c){return"undefined"==typeof this.catalog[a]&&(this.catalog[a]={}),this.catalog[a][b.toLowerCase()]=c,this},validate:function(){return(new this.Validator.Validator).validate.apply(new e.Validator,arguments)},addValidator:function(b,c,d,f){return this.validators[b.toLowerCase()]=function(b){return a.extend((new e.Assert).Callback(c,b),{priority:d,requirementsTransformer:f})},this},updateValidator:function(a,b,c,d){return this.addValidator(a,b,c,d)},removeValidator:function(a){return delete this.validators[a],this},getErrorMessage:function(a){var b;return b="type"===a.name?this.catalog[this.locale][a.name][a.requirements]:this.formatMessage(this.catalog[this.locale][a.name],a.requirements),""!==b?b:this.catalog[this.locale].defaultMessage},formatMessage:function(a,b){if("object"==typeof b){for(var c in b)a=this.formatMessage(a,b[c]);return a}return"string"==typeof a?a.replace(new RegExp("%s","i"),b):""},validators:{notblank:function(){return a.extend((new e.Assert).NotBlank(),{priority:2})},required:function(){return a.extend((new e.Assert).Required(),{priority:512})},type:function(b){var c;switch(b){case"email":c=(new e.Assert).Email();break;case"range":case"number":c=(new e.Assert).Regexp("^-?(?:\\d+|\\d{1,3}(?:,\\d{3})+)?(?:\\.\\d+)?$");break;case"integer":c=(new e.Assert).Regexp("^-?\\d+$");break;case"digits":c=(new e.Assert).Regexp("^\\d+$");break;case"alphanum":c=(new e.Assert).Regexp("^\\w+$","i");break;case"url":c=(new e.Assert).Regexp("(https?:\\/\\/)?(www\\.)?[-a-zA-Z0-9@:%._\\+~#=]{2,256}\\.[a-z]{2,4}\\b([-a-zA-Z0-9@:%_\\+.~#?&//=]*)","i");break;default:throw new Error("validator type `"+b+"` is not supported")}return a.extend(c,{priority:256})},pattern:function(b){var c="";return/^\/.*\/(?:[gimy]*)$/.test(b)&&(c=b.replace(/.*\/([gimy]*)$/,"$1"),b=b.replace(new RegExp("^/(.*?)/"+c+"$"),"$1")),a.extend((new e.Assert).Regexp(b,c),{priority:64})},minlength:function(b){return a.extend((new e.Assert).Length({min:b}),{priority:30,requirementsTransformer:function(){return"string"!=typeof b||isNaN(b)?b:parseInt(b,10)}})},maxlength:function(b){return a.extend((new e.Assert).Length({max:b}),{priority:30,requirementsTransformer:function(){return"string"!=typeof b||isNaN(b)?b:parseInt(b,10)}})},length:function(b){return a.extend((new e.Assert).Length({min:b[0],max:b[1]}),{priority:32})},mincheck:function(a){return this.minlength(a)},maxcheck:function(a){return this.maxlength(a)},check:function(a){return this.length(a)},min:function(b){return a.extend((new e.Assert).GreaterThanOrEqual(b),{priority:30,requirementsTransformer:function(){return"string"!=typeof b||isNaN(b)?b:parseInt(b,10)}})},max:function(b){return a.extend((new e.Assert).LessThanOrEqual(b),{priority:30,requirementsTransformer:function(){return"string"!=typeof b||isNaN(b)?b:parseInt(b,10)}})},range:function(b){return a.extend((new e.Assert).Range(b[0],b[1]),{priority:32,requirementsTransformer:function(){for(var a=0;a<b.length;a++)b[a]="string"!=typeof b[a]||isNaN(b[a])?b[a]:parseInt(b[a],10);return b}})},equalto:function(b){return a.extend((new e.Assert).EqualTo(b),{priority:256,requirementsTransformer:function(){return a(b).length?a(b).val():b}})}}};var g=function(){this.__class__="ParsleyUI"};g.prototype={listen:function(){return a.listen("parsley:form:init",this,this.setupForm),a.listen("parsley:field:init",this,this.setupField),a.listen("parsley:field:validated",this,this.reflow),a.listen("parsley:form:validated",this,this.focus),a.listen("parsley:field:reset",this,this.reset),a.listen("parsley:form:destroy",this,this.destroy),a.listen("parsley:field:destroy",this,this.destroy),this},reflow:function(a){if("undefined"!=typeof a._ui&&!1!==a._ui.active){var b=this._diff(a.validationResult,a._ui.lastValidationResult);a._ui.lastValidationResult=a.validationResult,a._ui.validatedOnce=!0,this.manageStatusClass(a),this.manageErrorsMessages(a,b),this.actualizeTriggers(a),(b.kept.length||b.added.length)&&"undefined"==typeof a._ui.failedOnce&&this.manageFailingFieldTrigger(a)}},getErrorsMessages:function(a){if(!0===a.validationResult)return[];for(var b=[],c=0;c<a.validationResult.length;c++)b.push(this._getErrorMessage(a,a.validationResult[c].assert));return b},manageStatusClass:function(a){!0===a.validationResult?this._successClass(a):a.validationResult.length>0?this._errorClass(a):this._resetClass(a)},manageErrorsMessages:function(b,c){if("undefined"==typeof b.options.errorsMessagesDisabled){if("undefined"!=typeof b.options.errorMessage)return c.added.length||c.kept.length?(0===b._ui.$errorsWrapper.find(".parsley-custom-error-message").length&&b._ui.$errorsWrapper.append(a(b.options.errorTemplate).addClass("parsley-custom-error-message")),b._ui.$errorsWrapper.addClass("filled").find(".parsley-custom-error-message").html(b.options.errorMessage)):b._ui.$errorsWrapper.removeClass("filled").find(".parsley-custom-error-message").remove();for(var d=0;d<c.removed.length;d++)this.removeError(b,c.removed[d].assert.name,!0);for(d=0;d<c.added.length;d++)this.addError(b,c.added[d].assert.name,void 0,c.added[d].assert,!0);for(d=0;d<c.kept.length;d++)this.updateError(b,c.kept[d].assert.name,void 0,c.kept[d].assert,!0)}},addError:function(b,c,d,e,f){b._ui.$errorsWrapper.addClass("filled").append(a(b.options.errorTemplate).addClass("parsley-"+c).html(d||this._getErrorMessage(b,e))),!0!==f&&this._errorClass(b)},updateError:function(a,b,c,d,e){a._ui.$errorsWrapper.addClass("filled").find(".parsley-"+b).html(c||this._getErrorMessage(a,d)),!0!==e&&this._errorClass(a)},removeError:function(a,b,c){a._ui.$errorsWrapper.removeClass("filled").find(".parsley-"+b).remove(),!0!==c&&this.manageStatusClass(a)},focus:function(a){if(!0===a.validationResult||"none"===a.options.focus)return a._focusedField=null;a._focusedField=null;for(var b=0;b<a.fields.length;b++)if(!0!==a.fields[b].validationResult&&a.fields[b].validationResult.length>0&&"undefined"==typeof a.fields[b].options.noFocus){if("first"===a.options.focus)return a._focusedField=a.fields[b].$element,a._focusedField.focus();a._focusedField=a.fields[b].$element}return null===a._focusedField?null:a._focusedField.focus()},_getErrorMessage:function(a,b){var c=b.name+"Message";return"undefined"!=typeof a.options[c]?window.ParsleyValidator.formatMessage(a.options[c],b.requirements):window.ParsleyValidator.getErrorMessage(b)},_diff:function(a,b,c){for(var d=[],e=[],f=0;f<a.length;f++){for(var g=!1,h=0;h<b.length;h++)if(a[f].assert.name===b[h].assert.name){g=!0;break}g?e.push(a[f]):d.push(a[f])}return{kept:e,added:d,removed:c?[]:this._diff(b,a,!0).added}},setupForm:function(b){b.$element.on("submit.Parsley",!1,a.proxy(b.onSubmitValidate,b)),!1!==b.options.uiEnabled&&b.$element.attr("novalidate","")},setupField:function(b){var c={active:!1};!1!==b.options.uiEnabled&&(c.active=!0,b.$element.attr(b.options.namespace+"id",b.__id__),c.$errorClassHandler=this._manageClassHandler(b),c.errorsWrapperId="parsley-id-"+("undefined"!=typeof b.options.multiple?"multiple-"+b.options.multiple:b.__id__),c.$errorsWrapper=a(b.options.errorsWrapper).attr("id",c.errorsWrapperId),c.lastValidationResult=[],c.validatedOnce=!1,c.validationInformationVisible=!1,b._ui=c,b.$element.is(b.options.excluded)||this._insertErrorWrapper(b),this.actualizeTriggers(b))},_manageClassHandler:function(b){if("string"==typeof b.options.classHandler&&a(b.options.classHandler).length)return a(b.options.classHandler);var c=b.options.classHandler(b);return"undefined"!=typeof c&&c.length?c:"undefined"==typeof b.options.multiple||b.$element.is("select")?b.$element:b.$element.parent()},_insertErrorWrapper:function(b){var c;if("string"==typeof b.options.errorsContainer){if(a(b.options.errorsContainer).length)return a(b.options.errorsContainer).append(b._ui.$errorsWrapper);window.console&&window.console.warn&&window.console.warn("The errors container `"+b.options.errorsContainer+"` does not exist in DOM")}else"function"==typeof b.options.errorsContainer&&(c=b.options.errorsContainer(b));return"undefined"!=typeof c&&c.length?c.append(b._ui.$errorsWrapper):"undefined"==typeof b.options.multiple?b.$element.after(b._ui.$errorsWrapper):b.$element.parent().after(b._ui.$errorsWrapper)},actualizeTriggers:function(b){var c=this;if(b.options.multiple?a("["+b.options.namespace+'multiple="'+b.options.multiple+'"]').each(function(){a(this).off(".Parsley")}):b.$element.off(".Parsley"),!1!==b.options.trigger){var d=b.options.trigger.replace(/^\s+/g,"").replace(/\s+$/g,"");""!==d&&(b.options.multiple?a("["+b.options.namespace+'multiple="'+b.options.multiple+'"]').each(function(){a(this).on(d.split(" ").join(".Parsley ")+".Parsley",!1,a.proxy("function"==typeof b.eventValidate?b.eventValidate:c.eventValidate,b))}):b.$element.on(d.split(" ").join(".Parsley ")+".Parsley",!1,a.proxy("function"==typeof b.eventValidate?b.eventValidate:this.eventValidate,b)))}},eventValidate:function(a){new RegExp("key").test(a.type)&&!this._ui.validationInformationVisible&&this.getValue().length<=this.options.validationThreshold||(this._ui.validatedOnce=!0,this.validate())},manageFailingFieldTrigger:function(b){return b._ui.failedOnce=!0,b.options.multiple&&a("["+b.options.namespace+'multiple="'+b.options.multiple+'"]').each(function(){return new RegExp("change","i").test(a(this).parsley().options.trigger||"")?void 0:a(this).on("change.ParsleyFailedOnce",!1,a.proxy(b.validate,b))}),b.$element.is("select")&&!new RegExp("change","i").test(b.options.trigger||"")?b.$element.on("change.ParsleyFailedOnce",!1,a.proxy(b.validate,b)):new RegExp("keyup","i").test(b.options.trigger||"")?void 0:b.$element.on("keyup.ParsleyFailedOnce",!1,a.proxy(b.validate,b))},reset:function(b){b.$element.off(".Parsley"),b.$element.off(".ParsleyFailedOnce"),"undefined"!=typeof b._ui&&"ParsleyForm"!==b.__class__&&(b._ui.$errorsWrapper.children().each(function(){a(this).remove()}),this._resetClass(b),b._ui.validatedOnce=!1,b._ui.lastValidationResult=[],b._ui.validationInformationVisible=!1)},destroy:function(a){this.reset(a),"ParsleyForm"!==a.__class__&&("undefined"!=typeof a._ui&&a._ui.$errorsWrapper.remove(),delete a._ui)},_successClass:function(a){a._ui.validationInformationVisible=!0,a._ui.$errorClassHandler.removeClass(a.options.errorClass).addClass(a.options.successClass)},_errorClass:function(a){a._ui.validationInformationVisible=!0,a._ui.$errorClassHandler.removeClass(a.options.successClass).addClass(a.options.errorClass)},_resetClass:function(a){a._ui.$errorClassHandler.removeClass(a.options.successClass).removeClass(a.options.errorClass)}};var h=function(c,d,e,f){this.__class__="OptionsFactory",this.__id__=b.hash(4),this.formOptions=null,this.fieldOptions=null,this.staticOptions=a.extend(!0,{},c,d,e,{namespace:f})};h.prototype={get:function(a){if("undefined"==typeof a.__class__)throw new Error("Parsley Instance expected");switch(a.__class__){case"Parsley":return this.staticOptions;case"ParsleyForm":return this.getFormOptions(a);case"ParsleyField":case"ParsleyFieldMultiple":return this.getFieldOptions(a);default:throw new Error("Instance "+a.__class__+" is not supported")}},getFormOptions:function(c){return this.formOptions=b.attr(c.$element,this.staticOptions.namespace),a.extend({},this.staticOptions,this.formOptions)},getFieldOptions:function(c){return this.fieldOptions=b.attr(c.$element,this.staticOptions.namespace),null===this.formOptions&&"undefined"!=typeof c.parent&&(this.formOptions=this.getFormOptions(c.parent)),a.extend({},this.staticOptions,this.formOptions,this.fieldOptions)}};var i=function(c,d){if(this.__class__="ParsleyForm",this.__id__=b.hash(4),"OptionsFactory"!==b.get(d,"__class__"))throw new Error("You must give an OptionsFactory instance");this.OptionsFactory=d,this.$element=a(c),this.validationResult=null,this.options=this.OptionsFactory.get(this)};i.prototype={onSubmitValidate:function(b){return this.validate(void 0,void 0,b),!1===this.validationResult&&b instanceof a.Event&&(b.stopImmediatePropagation(),b.preventDefault()),this},validate:function(b,c,d){this.submitEvent=d,this.validationResult=!0;var e=[];this._refreshFields(),a.emit("parsley:form:validate",this);for(var f=0;f<this.fields.length;f++)(!b||this._isFieldInGroup(this.fields[f],b))&&(e=this.fields[f].validate(c),!0!==e&&e.length>0&&this.validationResult&&(this.validationResult=!1));return a.emit("parsley:form:validated",this),this.validationResult},isValid:function(a,b){this._refreshFields();for(var c=0;c<this.fields.length;c++)if((!a||this._isFieldInGroup(this.fields[c],a))&&!1===this.fields[c].isValid(b))return!1;return!0},_isFieldInGroup:function(c,d){return b.isArray(c.options.group)?-1!==a.inArray(c.options.group,d):c.options.group===d},_refreshFields:function(){return this.actualizeOptions()._bindFields()},_bindFields:function(){var a=this;return this.fields=[],this.fieldsMappedById={},this.$element.find(this.options.inputs).each(function(){var b=new window.Parsley(this,{},a);"ParsleyField"!==b.__class__&&"ParsleyFieldMultiple"!==b.__class__||b.$element.is(b.options.excluded)||"undefined"==typeof a.fieldsMappedById[b.__class__+"-"+b.__id__]&&(a.fieldsMappedById[b.__class__+"-"+b.__id__]=b,a.fields.push(b))}),this}};var j=function(c,d,e,f,g){if(!new RegExp("ParsleyField").test(b.get(c,"__class__")))throw new Error("ParsleyField or ParsleyFieldMultiple instance expected");if("function"!=typeof window.ParsleyValidator.validators[d]&&"Assert"!==window.ParsleyValidator.validators[d](e).__parentClass__)throw new Error("Valid validator expected");var h=function(a,c){return"undefined"!=typeof a.options[c+"Priority"]?a.options[c+"Priority"]:b.get(window.ParsleyValidator.validators[c](e),"priority")||2};return f=f||h(c,d),"function"==typeof window.ParsleyValidator.validators[d](e).requirementsTransformer&&(e=window.ParsleyValidator.validators[d](e).requirementsTransformer()),a.extend(window.ParsleyValidator.validators[d](e),{name:d,requirements:e,priority:f,groups:[f],isDomConstraint:g||b.attr(c.$element,c.options.namespace,d)})},k=function(c,d,e){this.__class__="ParsleyField",this.__id__=b.hash(4),this.$element=a(c),"undefined"!=typeof e?(this.parent=e,this.OptionsFactory=this.parent.OptionsFactory,this.options=this.OptionsFactory.get(this)):(this.OptionsFactory=d,this.options=this.OptionsFactory.get(this)),this.constraints=[],this.constraintsByName={},this.validationResult=[],this._bindConstraints()};k.prototype={validate:function(b){return this.value=this.getValue(),a.emit("parsley:field:validate",this),a.emit("parsley:field:"+(this.isValid(b,this.value)?"success":"error"),this),a.emit("parsley:field:validated",this),this.validationResult},isValid:function(a,b){this.refreshConstraints();var c=this._getConstraintsSortedPriorities();if(b=b||this.getValue(),0===b.length&&!this._isRequired()&&"undefined"==typeof this.options.validateIfEmpty&&!0!==a)return this.validationResult=[];if(!1===this.options.priorityEnabled)return!0===(this.validationResult=this.validateThroughValidator(b,this.constraints,"Any"));for(var d=0;d<c.length;d++)if(!0!==(this.validationResult=this.validateThroughValidator(b,this.constraints,c[d])))return!1;return!0},getValue:function(){var a;
| |
- | return a="undefined"!=typeof this.options.value?this.options.value:this.$element.val(),"undefined"==typeof a||null===a?"":!0===this.options.trimValue?a.replace(/^\s+|\s+$/g,""):a},refreshConstraints:function(){return this.actualizeOptions()._bindConstraints()},addConstraint:function(a,b,c,d){if(a=a.toLowerCase(),"function"==typeof window.ParsleyValidator.validators[a]){var e=new j(this,a,b,c,d);"undefined"!==this.constraintsByName[e.name]&&this.removeConstraint(e.name),this.constraints.push(e),this.constraintsByName[e.name]=e}return this},removeConstraint:function(a){for(var b=0;b<this.constraints.length;b++)if(a===this.constraints[b].name){this.constraints.splice(b,1);break}return this},updateConstraint:function(a,b,c){return this.removeConstraint(a).addConstraint(a,b,c)},_bindConstraints:function(){for(var a=[],b=0;b<this.constraints.length;b++)!1===this.constraints[b].isDomConstraint&&a.push(this.constraints[b]);this.constraints=a;for(var c in this.options)this.addConstraint(c,this.options[c]);return this._bindHtml5Constraints()},_bindHtml5Constraints:function(){(this.$element.hasClass("required")||this.$element.attr("required"))&&this.addConstraint("required",!0,void 0,!0),"string"==typeof this.$element.attr("pattern")&&this.addConstraint("pattern",this.$element.attr("pattern"),void 0,!0),"undefined"!=typeof this.$element.attr("min")&&"undefined"!=typeof this.$element.attr("max")?this.addConstraint("range",[this.$element.attr("min"),this.$element.attr("max")],void 0,!0):"undefined"!=typeof this.$element.attr("min")?this.addConstraint("min",this.$element.attr("min"),void 0,!0):"undefined"!=typeof this.$element.attr("max")&&this.addConstraint("max",this.$element.attr("max"),void 0,!0);var a=this.$element.attr("type");return"undefined"==typeof a?this:"number"===a?this.addConstraint("type","integer",void 0,!0):new RegExp(a,"i").test("email url range")?this.addConstraint("type",a,void 0,!0):this},_isRequired:function(){return"undefined"==typeof this.constraintsByName.required?!1:!1!==this.constraintsByName.required.requirements},_getConstraintsSortedPriorities:function(){for(var a=[],b=0;b<this.constraints.length;b++)-1===a.indexOf(this.constraints[b].priority)&&a.push(this.constraints[b].priority);return a.sort(function(a,b){return b-a}),a}};var l=function(){this.__class__="ParsleyFieldMultiple"};l.prototype={addElement:function(a){return this.$elements.push(a),this},refreshConstraints:function(){var b;if(this.constraints=[],this.$element.is("select"))return this.actualizeOptions()._bindConstraints(),this;for(var c=0;c<this.$elements.length;c++)if(a("html").has(this.$elements[c]).length){b=this.$elements[c].data("ParsleyFieldMultiple").refreshConstraints().constraints;for(var d=0;d<b.length;d++)this.addConstraint(b[d].name,b[d].requirements,b[d].priority,b[d].isDomConstraint)}else this.$elements.splice(c,1);return this},getValue:function(){if("undefined"!=typeof this.options.value)return this.options.value;if(this.$element.is("input[type=radio]"))return a("["+this.options.namespace+'multiple="'+this.options.multiple+'"]:checked').val()||"";if(this.$element.is("input[type=checkbox]")){var b=[];return a("["+this.options.namespace+'multiple="'+this.options.multiple+'"]:checked').each(function(){b.push(a(this).val())}),b.length?b:[]}return this.$element.is("select")&&null===this.$element.val()?[]:this.$element.val()},_init:function(a){return this.$elements=[this.$element],this.options.multiple=a,this}};var m=a({}),n={};a.listen=function(a){if("undefined"==typeof n[a]&&(n[a]=[]),"function"==typeof arguments[1])return n[a].push({fn:arguments[1]});if("object"==typeof arguments[1]&&"function"==typeof arguments[2])return n[a].push({fn:arguments[2],ctxt:arguments[1]});throw new Error("Wrong parameters")},a.listenTo=function(a,b,c){if("undefined"==typeof n[b]&&(n[b]=[]),!(a instanceof k||a instanceof i))throw new Error("Must give Parsley instance");if("string"!=typeof b||"function"!=typeof c)throw new Error("Wrong parameters");n[b].push({instance:a,fn:c})},a.unsubscribe=function(a,b){if("undefined"!=typeof n[a]){if("string"!=typeof a||"function"!=typeof b)throw new Error("Wrong arguments");for(var c=0;c<n[a].length;c++)if(n[a][c].fn===b)return n[a].splice(c,1)}},a.unsubscribeTo=function(a,b){if("undefined"!=typeof n[b]){if(!(a instanceof k||a instanceof i))throw new Error("Must give Parsley instance");for(var c=0;c<n[b].length;c++)if("undefined"!=typeof n[b][c].instance&&n[b][c].instance.__id__===a.__id__)return n[b].splice(c,1)}},a.unsubscribeAll=function(a){"undefined"!=typeof n[a]&&delete n[a]},a.emit=function(a,b){if("undefined"!=typeof n[a])for(var c=0;c<n[a].length;c++)if("undefined"!=typeof n[a][c].instance){if(b instanceof k||b instanceof i)if(n[a][c].instance.__id__!==b.__id__){if(n[a][c].instance instanceof i&&b instanceof k)for(var d=0;d<n[a][c].instance.fields.length;d++)if(n[a][c].instance.fields[d].__id__===b.__id__){n[a][c].fn.apply(m,Array.prototype.slice.call(arguments,1));continue}}else n[a][c].fn.apply(m,Array.prototype.slice.call(arguments,1))}else n[a][c].fn.apply("undefined"!=typeof n[a][c].ctxt?n[a][c].ctxt:m,Array.prototype.slice.call(arguments,1))},a.subscribed=function(){return n},window.ParsleyConfig=window.ParsleyConfig||{},window.ParsleyConfig.i18n=window.ParsleyConfig.i18n||{},window.ParsleyConfig.i18n.en=a.extend(window.ParsleyConfig.i18n.en||{},{defaultMessage:"This value seems to be invalid.",type:{email:"This value should be a valid email.",url:"This value should be a valid url.",number:"This value should be a valid number.",integer:"This value should be a valid integer.",digits:"This value should be digits.",alphanum:"This value should be alphanumeric."},notblank:"This value should not be blank.",required:"This value is required.",pattern:"This value seems to be invalid.",min:"This value should be greater than or equal to %s.",max:"This value should be lower than or equal to %s.",range:"This value should be between %s and %s.",minlength:"This value is too short. It should have %s characters or more.",maxlength:"This value is too long. It should have %s characters or fewer.",length:"This value length is invalid. It should be between %s and %s characters long.",mincheck:"You must select at least %s choices.",maxcheck:"You must select %s choices or fewer.",check:"You must select between %s and %s choices.",equalto:"This value should be the same."}),"undefined"!=typeof window.ParsleyValidator&&window.ParsleyValidator.addCatalog("en",window.ParsleyConfig.i18n.en,!0);var o=function(c,d,e){if(this.__class__="Parsley",this.__version__="2.0.5",this.__id__=b.hash(4),"undefined"==typeof c)throw new Error("You must give an element");if("undefined"!=typeof e&&"ParsleyForm"!==e.__class__)throw new Error("Parent instance must be a ParsleyForm instance");return this.init(a(c),d,e)};o.prototype={init:function(a,d,e){if(!a.length)throw new Error("You must bind Parsley on an existing element.");if(this.$element=a,this.$element.data("Parsley")){var f=this.$element.data("Parsley");return"undefined"!=typeof e&&(f.parent=e),f}return this.OptionsFactory=new h(c,b.get(window,"ParsleyConfig")||{},d,this.getNamespace(d)),this.options=this.OptionsFactory.get(this),this.$element.is("form")||b.attr(this.$element,this.options.namespace,"validate")&&!this.$element.is(this.options.inputs)?this.bind("parsleyForm"):this.$element.is(this.options.inputs)&&!this.$element.is(this.options.excluded)?this.isMultiple()?this.handleMultiple(e):this.bind("parsleyField",e):this},isMultiple:function(){return this.$element.is("input[type=radio], input[type=checkbox]")&&"undefined"==typeof this.options.multiple||this.$element.is("select")&&"undefined"!=typeof this.$element.attr("multiple")},handleMultiple:function(c){var d,e,f,g=this;if(this.options=a.extend(this.options,c?c.OptionsFactory.get(c):{},b.attr(this.$element,this.options.namespace)),this.options.multiple?e=this.options.multiple:"undefined"!=typeof this.$element.attr("name")&&this.$element.attr("name").length?e=d=this.$element.attr("name"):"undefined"!=typeof this.$element.attr("id")&&this.$element.attr("id").length&&(e=this.$element.attr("id")),this.$element.is("select")&&"undefined"!=typeof this.$element.attr("multiple"))return this.bind("parsleyFieldMultiple",c,e||this.__id__);if("undefined"==typeof e)return window.console&&window.console.warn&&window.console.warn("To be binded by Parsley, a radio, a checkbox and a multiple select input must have either a name or a multiple option.",this.$element),this;if(e=e.replace(/(:|\.|\[|\]|\$)/g,""),"undefined"!=typeof d&&a('input[name="'+d+'"]').each(function(){a(this).is("input[type=radio], input[type=checkbox]")&&a(this).attr(g.options.namespace+"multiple",e)}),a("["+this.options.namespace+"multiple="+e+"]").length)for(var h=0;h<a("["+this.options.namespace+"multiple="+e+"]").length;h++)if("undefined"!=typeof a(a("["+this.options.namespace+"multiple="+e+"]").get(h)).data("Parsley")){f=a(a("["+this.options.namespace+"multiple="+e+"]").get(h)).data("Parsley"),this.$element.data("ParsleyFieldMultiple")||(f.addElement(this.$element),this.$element.attr(this.options.namespace+"id",f.__id__));break}return this.bind("parsleyField",c,e,!0),f||this.bind("parsleyFieldMultiple",c,e)},getNamespace:function(a){return"undefined"!=typeof this.$element.data("parsleyNamespace")?this.$element.data("parsleyNamespace"):"undefined"!=typeof b.get(a,"namespace")?a.namespace:"undefined"!=typeof b.get(window,"ParsleyConfig.namespace")?window.ParsleyConfig.namespace:c.namespace},bind:function(c,e,f,g){var h;switch(c){case"parsleyForm":h=a.extend(new i(this.$element,this.OptionsFactory),new d,window.ParsleyExtend)._bindFields();break;case"parsleyField":h=a.extend(new k(this.$element,this.OptionsFactory,e),new d,window.ParsleyExtend);break;case"parsleyFieldMultiple":h=a.extend(new k(this.$element,this.OptionsFactory,e),new d,new l,window.ParsleyExtend)._init(f);break;default:throw new Error(c+"is not a supported Parsley type")}return"undefined"!=typeof f&&b.setAttr(this.$element,this.options.namespace,"multiple",f),"undefined"!=typeof g?(this.$element.data("ParsleyFieldMultiple",h),h):(new RegExp("ParsleyF","i").test(h.__class__)&&(this.$element.data("Parsley",h),a.emit("parsley:"+("parsleyForm"===c?"form":"field")+":init",h)),h)}},a.fn.parsley=a.fn.psly=function(b){if(this.length>1){var c=[];return this.each(function(){c.push(a(this).parsley(b))}),c}return a(this).length?new o(this,b):void(window.console&&window.console.warn&&window.console.warn("You must bind Parsley on an existing element."))},window.ParsleyUI="function"==typeof b.get(window,"ParsleyConfig.ParsleyUI")?(new window.ParsleyConfig.ParsleyUI).listen():(new g).listen(),"undefined"==typeof window.ParsleyExtend&&(window.ParsleyExtend={}),"undefined"==typeof window.ParsleyConfig&&(window.ParsleyConfig={}),window.Parsley=window.psly=o,window.ParsleyUtils=b,window.ParsleyValidator=new f(window.ParsleyConfig.validators,window.ParsleyConfig.i18n),!1!==b.get(window,"ParsleyConfig.autoBind")&&a(document).ready(function(){a("[data-parsley-validate]").length&&a("[data-parsley-validate]").parsley()})});
| |
- | </script>
| |
- |
| |
- | <script>
| |
- | /***************************************************************
| |
- | * Copyright notice
| |
- | *
| |
- | * (c) 2012 Alexander Kellner <alexander.kellner@in2code.de>, in2code
| |
- | *
| |
- | * All rights reserved
| |
- | *
| |
- | * This script is part of the TYPO3 project. The TYPO3 project is
| |
- | * free software; you can redistribute it and/or modify
| |
- | * it under the terms of the GNU General Public License as published by
| |
- | * the Free Software Foundation; either version 3 of the License, or
| |
- | * (at your option) any later version.
| |
- | *
| |
- | * The GNU General Public License can be found at
| |
- | * http://www.gnu.org/copyleft/gpl.html.
| |
- | *
| |
- | * This script is distributed in the hope that it will be useful,
| |
- | * but WITHOUT ANY WARRANTY; without even the implied warranty of
| |
- | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
| |
- | * GNU General Public License for more details.
| |
- | *
| |
- | * This copyright notice MUST APPEAR in all copies of the script!
| |
- | ***************************************************************/
| |
- |
| |
- | jQuery(document).ready(function() {
| |
- | $.fn.powermailTabs = function(options) {
| |
- | 'use strict';
| |
- | var $this = jQuery(this);
| |
- | options = jQuery.extend({
| |
- | container: 'fieldset',
| |
- | header: 'legend',
| |
- | tabs: true,
| |
- | navigation: true,
| |
- | openTabOnError: true,
| |
- | tabIndex: true
| |
- | }, options);
| |
- |
| |
- | // initial show first fieldset
| |
- | hideAllFieldsets($this, options);
| |
- | $this.find(options.container).first().show();
| |
- |
| |
- | generateTabNavigation($this, options);
| |
- | generateButtonNavigation($this, options);
| |
- |
| |
- | if ($.fn.parsley && $('form[data-parsley-validate="data-parsley-validate"]').length && $('.powermail_morestep').length) {
| |
- | $('form[data-parsley-validate="data-parsley-validate"]').parsley().subscribe('parsley:field:validated', function() {
| |
- | $('#powermail_tabmenu > li').removeClass('parsley-error');
| |
- |
| |
- | // if error occurs
| |
- | if (!$('form[data-parsley-validate="data-parsley-validate"]').parsley().isValid()) {
| |
- |
| |
- | // for each field with an error
| |
- | $('.parsley-error').each(function() {
| |
- | var errorIndex = $('.powermail_fieldset').index($(this).closest('.powermail_fieldset'));
| |
- | var tabWithError = $('#powermail_tabmenu > li').slice(errorIndex, errorIndex + 1);
| |
- | tabWithError.addClass('parsley-error');
| |
- | });
| |
- | }
| |
- | });
| |
- | }
| |
- |
| |
- | // open tab with error
| |
- | if (options.openTabOnError) {
| |
- | $.listen('parsley:field:error', function() {
| |
- | setTimeout(function() {
| |
- | $('.powermail_tabmenu > .parsley-error:first').click();
| |
- | }, 50);
| |
- | });
| |
- | }
| |
- | };
| |
- |
| |
- | /**
| |
- | * Show Tab
| |
- | *
| |
- | * @param tab
| |
- | * @param form
| |
- | * @param options
| |
- | * @param clickedIndex
| |
- | * @return void
| |
- | */
| |
- | function showTab(tab, form, options, clickedIndex) {
| |
- | $('.powermail_tabmenu li', form).removeClass('act');
| |
- | tab.addClass('act');
| |
- | hideAllFieldsets(form, options)
| |
- | $('.powermail_fieldset', form).slice(clickedIndex, clickedIndex + 1).show();
| |
- | }
| |
- |
| |
- | /**
| |
- | * Hide all fieldsets
| |
- | *
| |
- | * @param element
| |
- | * @param options
| |
- | * @return void
| |
- | */
| |
- | function hideAllFieldsets(element, options) {
| |
- | element.children(options.container).hide();
| |
- | }
| |
- |
| |
- | /**
| |
- | * Generate Button Navigation
| |
- | *
| |
- | * @param object element
| |
- | * @param array options
| |
- | * @return void
| |
- | */
| |
- | function generateButtonNavigation(element, options) {
| |
- | if (!options.navigation) {
| |
- | return;
| |
- | }
| |
- |
| |
- | // buttons
| |
- | element.children(options.container).each(function(i) {
| |
- | var navigationContainer = $('<div />')
| |
- | .addClass('powermail_fieldwrap')
| |
- | .addClass('powermail_tab_navigation')
| |
- | .appendTo($(this));
| |
- | ;
| |
- | if (i > 0) {
| |
- | navigationContainer.append(createPreviousButton(element, options));
| |
- | }
| |
- | if (i < (element.children(options.container).length - 1)) {
| |
- | navigationContainer.append(createNextButton(element, options));
| |
- | }
| |
- | });
| |
- | }
| |
- |
| |
- | /**
| |
- | * Create next button
| |
- | *
| |
- | * @param object element
| |
- | * @param array options
| |
- | * @return object
| |
- | */
| |
- | function createPreviousButton(element, options) {
| |
- | return $('<a />')
| |
- | .prop('href', '#')
| |
- | .addClass('powermail_tab_navigation_previous')
| |
- | .html('<')
| |
- | .click(function(e) {
| |
- | e.preventDefault();
| |
- | showPreviousTab(element, options);
| |
- | });
| |
- | }
| |
- |
| |
- | /**
| |
- | * Create next button
| |
- | *
| |
- | * @param object element
| |
- | * @param array options
| |
- | * @return object
| |
- | */
| |
- | function createNextButton(element, options) {
| |
- | return $('<a />')
| |
- | .prop('href', '#')
| |
- | .addClass('powermail_tab_navigation_next')
| |
- | .html('>')
| |
- | .click(function(e) {
| |
- | e.preventDefault();
| |
- | showNextTab(element, options);
| |
- | });
| |
- | }
| |
- |
| |
- | /**
| |
- | * Show next Tab
| |
- | *
| |
- | * @param object element
| |
- | * @param array options
| |
- | * @return void
| |
- | */
| |
- | function showNextTab(element, options) {
| |
- | var currentActiveTab = element.find('#powermail_tabmenu > li').index($('.act'));
| |
- | element.find('#powermail_tabmenu > li.act').removeClass('act').next().addClass('act');
| |
- | hideAllFieldsets(element, options);
| |
- | element.find('.powermail_fieldset').slice(currentActiveTab + 1, currentActiveTab + 2).show();
| |
- | }
| |
- |
| |
- | /**
| |
- | * Show previous Tab
| |
- | *
| |
- | * @param object element
| |
- | * @param array options
| |
- | * @return void
| |
- | */
| |
- | function showPreviousTab(element, options) {
| |
- | var currentActiveTab = element.find('#powermail_tabmenu > li').index($('.act'));
| |
- | element.find('#powermail_tabmenu > li.act').removeClass('act').prev().addClass('act');
| |
- | hideAllFieldsets(element, options);
| |
- | element.find('.powermail_fieldset').slice(currentActiveTab - 1, currentActiveTab).show();
| |
- | }
| |
- |
| |
- | /**
| |
- | * Generate Tabs
| |
- | *
| |
- | * @param object element
| |
- | * @param array options
| |
- | * @return void
| |
- | */
| |
- | function generateTabNavigation(element, options) {
| |
- | if (!options.tabs) {
| |
- | return;
| |
- | }
| |
- |
| |
- | // generate menu
| |
- | var $ul = $('<ul />', {
| |
- | 'id': 'powermail_tabmenu',
| |
- | 'class': 'powermail_tabmenu'
| |
- | }).insertBefore(
| |
- | element.children(options.container).filter(':first')
| |
- | );
| |
- |
| |
- | // all containers
| |
- | element.children(options.container).each(function(i, $fieldset){
| |
- | //tab_menu
| |
- | var li = $('<li/>')
| |
- | .html($(this).children(options.header).html())
| |
- | .addClass((i==0) ? 'act' : '')
| |
- | .addClass('item' + i)
| |
- | .on('click keypress', {
| |
- | container: element.children(options.container),
| |
- | fieldset: $($fieldset)
| |
- | }, function() {
| |
- | var indexTab = $('.powermail_tabmenu li', element).index($(this));
| |
- | showTab($(this), element, options, indexTab);
| |
- | });
| |
- | if (options.tabIndex) {
| |
- | li.prop('tabindex', i);
| |
- | }
| |
- | $ul.append(li);
| |
- | });
| |
- | }
| |
- | });
| |
- |
| |
- | </script>
| |
- | <script>
| |
- | /**
| |
- | * Baseurl
| |
- | *
| |
- | * @type {string}
| |
- | */
| |
- | var baseurl;
| |
- |
| |
- | /**
| |
- | * Powermail main JavaScript for form validation
| |
- | */
| |
- | jQuery(document).ready(function($) {
| |
- |
| |
- | // Read baseURL
| |
- | baseurl = getBaseUrl();
| |
- |
| |
- | // Tabs
| |
- | if ($.fn.powermailTabs) {
| |
- | $('.powermail_morestep').powermailTabs();
| |
- | }
| |
- |
| |
- | // Location field
| |
- | if ($('.powermail_fieldwrap_location input').length) {
| |
- | getLocationAndWrite();
| |
- | }
| |
- |
| |
- | // AJAX Form submit
| |
- | if ($('form[data-powermail-ajax]').length) {
| |
- | ajaxFormSubmit();
| |
- | }
| |
- |
| |
- | // Datepicker field
| |
- | if ($.fn.datetimepicker) {
| |
- | $('.powermail_date').each(function() {
| |
- | var $this = $(this);
| |
- | // stop javascript datepicker, if browser supports type="date" or "datetime-local" or "time"
| |
- | if ($this.prop('type') === 'date' || $this.prop('type') === 'datetime-local' || $this.prop('type') === 'time') {
| |
- | if ($this.data('datepicker-force')) {
| |
- | // rewrite input type
| |
- | $this.prop('type', 'text');
| |
- | } else {
| |
- | // get date in format Y-m-d H:i for html5 date fields
| |
- | if ($(this).data('date-value')) {
| |
- | $(this).val(
| |
- | getDatetimeForDateFields($(this).data('date-value'), $(this).data('datepicker-format'), $this.prop('type'))
| |
- | );
| |
- | }
| |
- |
| |
- | // stop js datepicker
| |
- | return;
| |
- | }
| |
- | }
| |
- |
| |
- | var datepickerStatus = true;
| |
- | var timepickerStatus = true;
| |
- | if ($this.data('datepicker-settings') === 'date') {
| |
- | timepickerStatus = false;
| |
- | } else if ($this.data('datepicker-settings') === 'time') {
| |
- | datepickerStatus = false;
| |
- | }
| |
- |
| |
- | // create datepicker
| |
- | $this.datetimepicker({
| |
- | format: $this.data('datepicker-format'),
| |
- | timepicker: timepickerStatus,
| |
- | datepicker: datepickerStatus,
| |
- | lang: 'en',
| |
- | i18n:{
| |
- | en:{
| |
- | months: $this.data('datepicker-months').split(','),
| |
- | dayOfWeek: $this.data('datepicker-days').split(',')
| |
- | }
| |
- | }
| |
- | });
| |
- | });
| |
- | }
| |
- |
| |
- | // File Upload Delete
| |
- | $('.powermail_fieldwrap_file_inner').find('.deleteAllFiles').each(function() {
| |
- | // initially hide upload fields
| |
- | disableUploadField($(this).closest('.powermail_fieldwrap_file_inner').find('input[type="file"]'));
| |
- | });
| |
- | $('.deleteAllFiles').click(function() {
| |
- | enableUploadField($(this).closest('.powermail_fieldwrap_file_inner').find('input[type="file"]'));
| |
- | $(this).closest('ul').fadeOut(function() {
| |
- | $(this).remove();
| |
- | });
| |
- | });
| |
- | function disableUploadField(element) {
| |
- | element.prop('disabled', 'disabled').addClass('hide');
| |
- | }
| |
- | function enableUploadField(element) {
| |
- | element.removeProp('disabled').removeClass('hide');
| |
- | }
| |
- |
| |
- | // Password Field Output
| |
- | $('.powermail_all_type_password.powermail_all_value').html('********');
| |
- | });
| |
- |
| |
- | /**
| |
- | * Allow AJAX Submit for powermail
| |
- | *
| |
- | * @return void
| |
- | */
| |
- | function ajaxFormSubmit() {
| |
- | // submit is called after parsley and html5 validation - so we don't have to check for errors
| |
- | $(document).on('submit', 'form[data-powermail-ajax]', function (e) {
| |
- | var $this = $(this);
| |
- | var formUid = $this.data('powermail-form');
| |
- |
| |
- | $.ajax({
| |
- | type: 'POST',
| |
- | url: $this.prop('action'),
| |
- | data: $this.serialize(),
| |
- | beforeSend: function() {
| |
- | // add progressbar <div class="powermail_progressbar"><div class="powermail_progress"><div class="powermail_progess_inner"></div></div></div>
| |
- | var progressBar = $('<div />').addClass('powermail_progressbar').html(
| |
- | $('<div />').addClass('powermail_progress').html(
| |
- | $('<div />').addClass('powermail_progess_inner')
| |
- | )
| |
- | );
| |
- | $('.powermail_submit', $this).parent().append(progressBar);
| |
- | $('.powermail_confirmation_submit, .powermail_confirmation_form', $this).closest('.powermail_confirmation').append(progressBar);
| |
- | },
| |
- | complete: function() {
| |
- | // remove progressbar
| |
- | $('.powermail_fieldwrap_submit', $this).find('.powermail_progressbar').remove();
| |
- | },
| |
- | success: function(data) {
| |
- | var html = $('*[data-powermail-form="' + formUid + '"]:first', data);
| |
- | $('.tx-powermail').html(html);
| |
- | // fire tabs and parsley again
| |
- | if ($.fn.powermailTabs) {
| |
- | $('.powermail_morestep').powermailTabs();
| |
- | }
| |
- | if ($.fn.parsley) {
| |
- | $('form[data-parsley-validate="data-parsley-validate"]').parsley();
| |
- | }
| |
- | }
| |
- | });
| |
- |
| |
- | e.preventDefault();
| |
- | });
| |
- | }
| |
- |
| |
- | /**
| |
- | * Convert date format for html5 date fields
| |
- | * 31.08.2014 => 2014-08-31
| |
- | *
| |
- | * @param value
| |
- | * @param format
| |
- | * @param type
| |
- | * @returns {string}
| |
- | */
| |
- | function getDatetimeForDateFields(value, format, type) {
| |
- | var date = new Date(Date.parseDate(value, format));
| |
- | var valueDate = date.getFullYear() + '-';
| |
- | valueDate += ('0' + (date.getMonth() + 1)).slice(-2) + '-';
| |
- | valueDate += ('0' + date.getDate()).slice(-2);
| |
- | var valueTime = ('0' + date.getHours()).slice(-2) + ':' + ('0' + date.getMinutes()).slice(-2);
| |
- | var valueDateTime = valueDate + 'T' + valueTime;
| |
- |
| |
- | if (type === 'date') {
| |
- | return valueDate;
| |
- | }
| |
- | if (type === 'datetime-local') {
| |
- | return valueDateTime;
| |
- | }
| |
- | if (type === 'time') {
| |
- | return valueTime;
| |
- | }
| |
- | return 'error';
| |
- | }
| |
- |
| |
- | /**
| |
- | * Getting the Location by the browser and write to inputform as address
| |
- | *
| |
- | * @return void
| |
- | */
| |
- | function getLocationAndWrite() {
| |
- | if (navigator.geolocation) { // Read location from Browser
| |
- | navigator.geolocation.getCurrentPosition(function(position) {
| |
- | var lat = position.coords.latitude;
| |
- | var lng = position.coords.longitude;
| |
- | var url = baseurl + '/index.php' + '?eID=' + 'powermailEidGetLocation';
| |
- | jQuery.ajax({
| |
- | url: url,
| |
- | data: 'lat=' + lat + '&lng=' + lng,
| |
- | cache: false,
| |
- | beforeSend: function(jqXHR, settings) {
| |
- | jQuery('body').css('cursor', 'wait');
| |
- | },
| |
- | complete: function(jqXHR, textStatus) {
| |
- | jQuery('body').css('cursor', 'default');
| |
- | },
| |
- | success: function(data) { // return values
| |
- | if (data) {
| |
- | jQuery('.powermail_fieldwrap_location input').val(data);
| |
- | }
| |
- | }
| |
- | });
| |
- | });
| |
- | }
| |
- | }
| |
- |
| |
- | /**
| |
- | * Return BaseUrl as prefix
| |
- | *
| |
- | * @return string Base Url
| |
- | */
| |
- | function getBaseUrl() {
| |
- | var baseurl;
| |
- | if (jQuery('base').length > 0) {
| |
- | baseurl = jQuery('base').prop('href');
| |
- | } else {
| |
- | if (window.location.protocol != "https:") {
| |
- | baseurl = 'http://' + window.location.hostname;
| |
- | } else {
| |
- | baseurl = 'https://' + window.location.hostname;
| |
- | }
| |
- | }
| |
- | return baseurl;
| |
- | }
| |
- | </script>
| |
- | <script>
| |
- | /**
| |
- | * Powermail_Frontend main JavaScript
| |
- | */
| |
- | jQuery(document).ready(function($) {
| |
- | });
| |
- | </script>
| |
- | <script>
| |
- | jQuery(document).ready(function() {
| |
- | var data = '';
| |
- | data += 'tx_powermail_pi1[language]=' + $('#powermail_marketing_information').data('language');
| |
- | data += '&tx_powermail_pi1[pid]=' + $('#powermail_marketing_information').data('pid');
| |
- | data += '&tx_powermail_pi1[mobileDevice]=' + (isMobile() ? 1 : 0);
| |
- | data += '&tx_powermail_pi1[referer]=' + encodeURIComponent(document.referrer);
| |
- | jQuery.ajax({
| |
- | url: getBaseUrl() + '/index.php?&eID=powermailEidMarketing',
| |
- | data: data,
| |
- | cache: false
| |
- | });
| |
- | });
| |
- |
| |
- | /**
| |
- | * Check if user device is mobile or not
| |
- | *
| |
- | * @return bool
| |
- | */
| |
- | function isMobile() {
| |
- | var ua = navigator.userAgent;
| |
- | var checker = {
| |
- | iphone:ua.match(/(iPhone|iPod|iPad)/),
| |
- | blackberry:ua.match(/BlackBerry/),
| |
- | android:ua.match(/Android/)
| |
- | }
| |
- |
| |
- | if (checker.iphone || checker.blackberry || checker.android) {
| |
- | return true;
| |
- | }
| |
- | return false;
| |
- | }
| |
- |
| |
- | /**
| |
- | * Return BaseUrl as prefix
| |
- | *
| |
- | * @return string Base Url
| |
- | */
| |
- | function getBaseUrl() {
| |
- | var baseurl;
| |
- | if (jQuery('base').length > 0) {
| |
- | baseurl = jQuery('base').prop('href');
| |
- | } else {
| |
- | if (window.location.protocol != "https:") {
| |
- | baseurl = 'http://' + window.location.hostname;
| |
- | } else {
| |
- | baseurl = 'https://' + window.location.hostname;
| |
- | }
| |
- | }
| |
- | return baseurl;
| |
- | }
| |
- |
| |
- |
| |
- | </script>
| |
- |
| |
- |
| |
| | | |
| </html> | | </html> |