(function(global, factory){
"use strict";
if(typeof module==="object"&&typeof module.exports==="object"){
module.exports=global.document ?
factory(global, true) :
function(w){
if(!w.document){
throw new Error("jQuery requires a window with a document");
}
return factory(w);
};}else{
factory(global);
}})(typeof window!=="undefined" ? window:this, function(window, noGlobal){
"use strict";
var arr=[];
var getProto=Object.getPrototypeOf;
var slice=arr.slice;
var flat=arr.flat ? function(array){
return arr.flat.call(array);
}:function(array){
return arr.concat.apply([], array);
};
var push=arr.push;
var indexOf=arr.indexOf;
var class2type={};
var toString=class2type.toString;
var hasOwn=class2type.hasOwnProperty;
var fnToString=hasOwn.toString;
var ObjectFunctionString=fnToString.call(Object);
var support={};
var isFunction=function isFunction(obj){
return typeof obj==="function"&&typeof obj.nodeType!=="number" &&
typeof obj.item!=="function";
};
var isWindow=function isWindow(obj){
return obj!=null&&obj===obj.window;
};
var document=window.document;
var preservedScriptAttributes={
type: true,
src: true,
nonce: true,
noModule: true
};
function DOMEval(code, node, doc){
doc=doc||document;
var i, val,
script=doc.createElement("script");
script.text=code;
if(node){
for(i in preservedScriptAttributes){
val=node[ i ]||node.getAttribute&&node.getAttribute(i);
if(val){
script.setAttribute(i, val);
}}
}
doc.head.appendChild(script).parentNode.removeChild(script);
}
function toType(obj){
if(obj==null){
return obj + "";
}
return typeof obj==="object"||typeof obj==="function" ?
class2type[ toString.call(obj) ]||"object" :
typeof obj;
}
var version="3.7.1",
rhtmlSuffix=/HTML$/i,
jQuery=function(selector, context){
return new jQuery.fn.init(selector, context);
};
jQuery.fn=jQuery.prototype={
jquery: version,
constructor: jQuery,
length: 0,
toArray: function(){
return slice.call(this);
},
get: function(num){
if(num==null){
return slice.call(this);
}
return num < 0 ? this[ num + this.length ]:this[ num ];
},
pushStack: function(elems){
var ret=jQuery.merge(this.constructor(), elems);
ret.prevObject=this;
return ret;
},
each: function(callback){
return jQuery.each(this, callback);
},
map: function(callback){
return this.pushStack(jQuery.map(this, function(elem, i){
return callback.call(elem, i, elem);
}));
},
slice: function(){
return this.pushStack(slice.apply(this, arguments));
},
first: function(){
return this.eq(0);
},
last: function(){
return this.eq(-1);
},
even: function(){
return this.pushStack(jQuery.grep(this, function(_elem, i){
return(i + 1) % 2;
}));
},
odd: function(){
return this.pushStack(jQuery.grep(this, function(_elem, i){
return i % 2;
}));
},
eq: function(i){
var len=this.length,
j=+i +(i < 0 ? len:0);
return this.pushStack(j >=0&&j < len ? [ this[ j ] ]:[]);
},
end: function(){
return this.prevObject||this.constructor();
},
push: push,
sort: arr.sort,
splice: arr.splice
};
jQuery.extend=jQuery.fn.extend=function(){
var options, name, src, copy, copyIsArray, clone,
target=arguments[ 0 ]||{},
i=1,
length=arguments.length,
deep=false;
if(typeof target==="boolean"){
deep=target;
target=arguments[ i ]||{};
i++;
}
if(typeof target!=="object"&&!isFunction(target)){
target={};}
if(i===length){
target=this;
i--;
}
for(; i < length; i++){
if(( options=arguments[ i ])!=null){
for(name in options){
copy=options[ name ];
if(name==="__proto__"||target===copy){
continue;
}
if(deep&&copy&&(jQuery.isPlainObject(copy) ||
(copyIsArray=Array.isArray(copy)))){
src=target[ name ];
if(copyIsArray&&!Array.isArray(src)){
clone=[];
}else if(!copyIsArray&&!jQuery.isPlainObject(src)){
clone={};}else{
clone=src;
}
copyIsArray=false;
target[ name ]=jQuery.extend(deep, clone, copy);
}else if(copy!==undefined){
target[ name ]=copy;
}}
}}
return target;
};
jQuery.extend({
expando: "jQuery" +(version + Math.random()).replace(/\D/g, ""),
isReady: true,
error: function(msg){
throw new Error(msg);
},
noop: function(){},
isPlainObject: function(obj){
var proto, Ctor;
if(!obj||toString.call(obj)!=="[object Object]"){
return false;
}
proto=getProto(obj);
if(!proto){
return true;
}
Ctor=hasOwn.call(proto, "constructor")&&proto.constructor;
return typeof Ctor==="function"&&fnToString.call(Ctor)===ObjectFunctionString;
},
isEmptyObject: function(obj){
var name;
for(name in obj){
return false;
}
return true;
},
globalEval: function(code, options, doc){
DOMEval(code, { nonce: options&&options.nonce }, doc);
},
each: function(obj, callback){
var length, i=0;
if(isArrayLike(obj)){
length=obj.length;
for(; i < length; i++){
if(callback.call(obj[ i ], i, obj[ i ])===false){
break;
}}
}else{
for(i in obj){
if(callback.call(obj[ i ], i, obj[ i ])===false){
break;
}}
}
return obj;
},
text: function(elem){
var node,
ret="",
i=0,
nodeType=elem.nodeType;
if(!nodeType){
while(( node=elem[ i++ ])){
ret +=jQuery.text(node);
}}
if(nodeType===1||nodeType===11){
return elem.textContent;
}
if(nodeType===9){
return elem.documentElement.textContent;
}
if(nodeType===3||nodeType===4){
return elem.nodeValue;
}
return ret;
},
makeArray: function(arr, results){
var ret=results||[];
if(arr!=null){
if(isArrayLike(Object(arr))){
jQuery.merge(ret,
typeof arr==="string" ?
[ arr ]:arr
);
}else{
push.call(ret, arr);
}}
return ret;
},
inArray: function(elem, arr, i){
return arr==null ? -1:indexOf.call(arr, elem, i);
},
isXMLDoc: function(elem){
var namespace=elem&&elem.namespaceURI,
docElem=elem&&(elem.ownerDocument||elem).documentElement;
return !rhtmlSuffix.test(namespace||docElem&&docElem.nodeName||"HTML");
},
merge: function(first, second){
var len=+second.length,
j=0,
i=first.length;
for(; j < len; j++){
first[ i++ ]=second[ j ];
}
first.length=i;
return first;
},
grep: function(elems, callback, invert){
var callbackInverse,
matches=[],
i=0,
length=elems.length,
callbackExpect = !invert;
for(; i < length; i++){
callbackInverse = !callback(elems[ i ], i);
if(callbackInverse!==callbackExpect){
matches.push(elems[ i ]);
}}
return matches;
},
map: function(elems, callback, arg){
var length, value,
i=0,
ret=[];
if(isArrayLike(elems)){
length=elems.length;
for(; i < length; i++){
value=callback(elems[ i ], i, arg);
if(value!=null){
ret.push(value);
}}
}else{
for(i in elems){
value=callback(elems[ i ], i, arg);
if(value!=null){
ret.push(value);
}}
}
return flat(ret);
},
guid: 1,
support: support
});
if(typeof Symbol==="function"){
jQuery.fn[ Symbol.iterator ]=arr[ Symbol.iterator ];
}
jQuery.each("Boolean Number String Function Array Date RegExp Object Error Symbol".split(" "),
function(_i, name){
class2type[ "[object " + name + "]" ]=name.toLowerCase();
});
function isArrayLike(obj){
var length = !!obj&&"length" in obj&&obj.length,
type=toType(obj);
if(isFunction(obj)||isWindow(obj)){
return false;
}
return type==="array"||length===0 ||
typeof length==="number"&&length > 0&&(length - 1) in obj;
}
function nodeName(elem, name){
return elem.nodeName&&elem.nodeName.toLowerCase()===name.toLowerCase();
}
var pop=arr.pop;
var sort=arr.sort;
var splice=arr.splice;
var whitespace="[\\x20\\t\\r\\n\\f]";
var rtrimCSS=new RegExp(
"^" + whitespace + "+|((?:^|[^\\\\])(?:\\\\.)*)" + whitespace + "+$",
"g"
);
jQuery.contains=function(a, b){
var bup=b&&b.parentNode;
return a===bup||!!(bup&&bup.nodeType===1&&(
a.contains ?
a.contains(bup) :
a.compareDocumentPosition&&a.compareDocumentPosition(bup) & 16
));
};
var rcssescape=/([\0-\x1f\x7f]|^-?\d)|^-$|[^\x80-\uFFFF\w-]/g;
function fcssescape(ch, asCodePoint){
if(asCodePoint){
if(ch==="\0"){
return "\uFFFD";
}
return ch.slice(0, -1) + "\\" + ch.charCodeAt(ch.length - 1).toString(16) + " ";
}
return "\\" + ch;
}
jQuery.escapeSelector=function(sel){
return(sel + "").replace(rcssescape, fcssescape);
};
var preferredDoc=document,
pushNative=push;
(function(){
var i,
Expr,
outermostContext,
sortInput,
hasDuplicate,
push=pushNative,
document,
documentElement,
documentIsHTML,
rbuggyQSA,
matches,
expando=jQuery.expando,
dirruns=0,
done=0,
classCache=createCache(),
tokenCache=createCache(),
compilerCache=createCache(),
nonnativeSelectorCache=createCache(),
sortOrder=function(a, b){
if(a===b){
hasDuplicate=true;
}
return 0;
},
booleans="checked|selected|async|autofocus|autoplay|controls|defer|disabled|hidden|ismap|" +
"loop|multiple|open|readonly|required|scoped",
identifier="(?:\\\\[\\da-fA-F]{1,6}" + whitespace +
"?|\\\\[^\\r\\n\\f]|[\\w-]|[^\0-\\x7f])+",
attributes="\\[" + whitespace + "*(" + identifier + ")(?:" + whitespace +
"*([*^$|!~]?=)" + whitespace +
"*(?:'((?:\\\\.|[^\\\\'])*)'|\"((?:\\\\.|[^\\\\\"])*)\"|(" + identifier + "))|)" +
whitespace + "*\\]",
pseudos=":(" + identifier + ")(?:\\((" +
"('((?:\\\\.|[^\\\\'])*)'|\"((?:\\\\.|[^\\\\\"])*)\")|" +
"((?:\\\\.|[^\\\\()[\\]]|" + attributes + ")*)|" +
".*" +
")\\)|)",
rwhitespace=new RegExp(whitespace + "+", "g"),
rcomma=new RegExp("^" + whitespace + "*," + whitespace + "*"),
rleadingCombinator=new RegExp("^" + whitespace + "*([>+~]|" + whitespace + ")" +
whitespace + "*"),
rdescend=new RegExp(whitespace + "|>"),
rpseudo=new RegExp(pseudos),
ridentifier=new RegExp("^" + identifier + "$"),
matchExpr={
ID: new RegExp("^#(" + identifier + ")"),
CLASS: new RegExp("^\\.(" + identifier + ")"),
TAG: new RegExp("^(" + identifier + "|[*])"),
ATTR: new RegExp("^" + attributes),
PSEUDO: new RegExp("^" + pseudos),
CHILD: new RegExp(
"^:(only|first|last|nth|nth-last)-(child|of-type)(?:\\(" +
whitespace + "*(even|odd|(([+-]|)(\\d*)n|)" + whitespace + "*(?:([+-]|)" +
whitespace + "*(\\d+)|))" + whitespace + "*\\)|)", "i"),
bool: new RegExp("^(?:" + booleans + ")$", "i"),
needsContext: new RegExp("^" + whitespace +
"*[>+~]|:(even|odd|eq|gt|lt|nth|first|last)(?:\\(" + whitespace +
"*((?:-\\d)?\\d*)" + whitespace + "*\\)|)(?=[^-]|$)", "i")
},
rinputs=/^(?:input|select|textarea|button)$/i,
rheader=/^h\d$/i,
rquickExpr=/^(?:#([\w-]+)|(\w+)|\.([\w-]+))$/,
rsibling=/[+~]/,
runescape=new RegExp("\\\\[\\da-fA-F]{1,6}" + whitespace +
"?|\\\\([^\\r\\n\\f])", "g"),
funescape=function(escape, nonHex){
var high="0x" + escape.slice(1) - 0x10000;
if(nonHex){
return nonHex;
}
return high < 0 ?
String.fromCharCode(high + 0x10000) :
String.fromCharCode(high >> 10 | 0xD800, high & 0x3FF | 0xDC00);
},
unloadHandler=function(){
setDocument();
},
inDisabledFieldset=addCombinator(
function(elem){
return elem.disabled===true&&nodeName(elem, "fieldset");
},
{ dir: "parentNode", next: "legend" }
);
function safeActiveElement(){
try {
return document.activeElement;
} catch(err){ }}
try {
push.apply((arr=slice.call(preferredDoc.childNodes)),
preferredDoc.childNodes
);
arr[ preferredDoc.childNodes.length ].nodeType;
} catch(e){
push={
apply: function(target, els){
pushNative.apply(target, slice.call(els));
},
call: function(target){
pushNative.apply(target, slice.call(arguments, 1));
}};}
function find(selector, context, results, seed){
var m, i, elem, nid, match, groups, newSelector,
newContext=context&&context.ownerDocument,
nodeType=context ? context.nodeType:9;
results=results||[];
if(typeof selector!=="string"||!selector ||
nodeType!==1&&nodeType!==9&&nodeType!==11){
return results;
}
if(!seed){
setDocument(context);
context=context||document;
if(documentIsHTML){
if(nodeType!==11&&(match=rquickExpr.exec(selector))){
if(( m=match[ 1 ])){
if(nodeType===9){
if(( elem=context.getElementById(m))){
if(elem.id===m){
push.call(results, elem);
return results;
}}else{
return results;
}}else{
if(newContext&&(elem=newContext.getElementById(m)) &&
find.contains(context, elem) &&
elem.id===m){
push.call(results, elem);
return results;
}}
}else if(match[ 2 ]){
push.apply(results, context.getElementsByTagName(selector));
return results;
}else if(( m=match[ 3 ])&&context.getElementsByClassName){
push.apply(results, context.getElementsByClassName(m));
return results;
}}
if(!nonnativeSelectorCache[ selector + " " ] &&
(!rbuggyQSA||!rbuggyQSA.test(selector))){
newSelector=selector;
newContext=context;
if(nodeType===1 &&
(rdescend.test(selector)||rleadingCombinator.test(selector))){
newContext=rsibling.test(selector)&&testContext(context.parentNode) ||
context;
if(newContext!=context||!support.scope){
if(( nid=context.getAttribute("id"))){
nid=jQuery.escapeSelector(nid);
}else{
context.setAttribute("id",(nid=expando));
}}
groups=tokenize(selector);
i=groups.length;
while(i--){
groups[ i ]=(nid ? "#" + nid:":scope") + " " +
toSelector(groups[ i ]);
}
newSelector=groups.join(",");
}
try {
push.apply(results,
newContext.querySelectorAll(newSelector)
);
return results;
} catch(qsaError){
nonnativeSelectorCache(selector, true);
} finally {
if(nid===expando){
context.removeAttribute("id");
}}
}}
}
return select(selector.replace(rtrimCSS, "$1"), context, results, seed);
}
/**
* Create key-value caches of limited size
* @returns {function(string, object)} Returns the Object data after storing it on itself with
*	property name the (space-suffixed) string and (if the cache is larger than Expr.cacheLength)
*	deleting the oldest entry
*/
function createCache(){
var keys=[];
function cache(key, value){
if(keys.push(key + " ") > Expr.cacheLength){
delete cache[ keys.shift() ];
}
return(cache[ key + " " ]=value);
}
return cache;
}
function markFunction(fn){
fn[ expando ]=true;
return fn;
}
function assert(fn){
var el=document.createElement("fieldset");
try {
return !!fn(el);
} catch(e){
return false;
} finally {
if(el.parentNode){
el.parentNode.removeChild(el);
}
el=null;
}}
function createInputPseudo(type){
return function(elem){
return nodeName(elem, "input")&&elem.type===type;
};}
function createButtonPseudo(type){
return function(elem){
return(nodeName(elem, "input")||nodeName(elem, "button")) &&
elem.type===type;
};}
function createDisabledPseudo(disabled){
return function(elem){
if("form" in elem){
if(elem.parentNode&&elem.disabled===false){
if("label" in elem){
if("label" in elem.parentNode){
return elem.parentNode.disabled===disabled;
}else{
return elem.disabled===disabled;
}}
return elem.isDisabled===disabled ||
elem.isDisabled!==!disabled &&
inDisabledFieldset(elem)===disabled;
}
return elem.disabled===disabled;
}else if("label" in elem){
return elem.disabled===disabled;
}
return false;
};}
function createPositionalPseudo(fn){
return markFunction(function(argument){
argument=+argument;
return markFunction(function(seed, matches){
var j,
matchIndexes=fn([], seed.length, argument),
i=matchIndexes.length;
while(i--){
if(seed[(j=matchIndexes[ i ]) ]){
seed[ j ] = !(matches[ j ]=seed[ j ]);
}}
});
});
}
function testContext(context){
return context&&typeof context.getElementsByTagName!=="undefined"&&context;
}
function setDocument(node){
var subWindow,
doc=node ? node.ownerDocument||node:preferredDoc;
if(doc==document||doc.nodeType!==9||!doc.documentElement){
return document;
}
document=doc;
documentElement=document.documentElement;
documentIsHTML = !jQuery.isXMLDoc(document);
matches=documentElement.matches ||
documentElement.webkitMatchesSelector ||
documentElement.msMatchesSelector;
if(documentElement.msMatchesSelector &&
preferredDoc!=document &&
(subWindow=document.defaultView)&&subWindow.top!==subWindow){
subWindow.addEventListener("unload", unloadHandler);
}
support.getById=assert(function(el){
documentElement.appendChild(el).id=jQuery.expando;
return !document.getElementsByName ||
!document.getElementsByName(jQuery.expando).length;
});
support.disconnectedMatch=assert(function(el){
return matches.call(el, "*");
});
support.scope=assert(function(){
return document.querySelectorAll(":scope");
});
support.cssHas=assert(function(){
try {
document.querySelector(":has(*,:jqfake)");
return false;
} catch(e){
return true;
}});
if(support.getById){
Expr.filter.ID=function(id){
var attrId=id.replace(runescape, funescape);
return function(elem){
return elem.getAttribute("id")===attrId;
};};
Expr.find.ID=function(id, context){
if(typeof context.getElementById!=="undefined"&&documentIsHTML){
var elem=context.getElementById(id);
return elem ? [ elem ]:[];
}};}else{
Expr.filter.ID=function(id){
var attrId=id.replace(runescape, funescape);
return function(elem){
var node=typeof elem.getAttributeNode!=="undefined" &&
elem.getAttributeNode("id");
return node&&node.value===attrId;
};};
Expr.find.ID=function(id, context){
if(typeof context.getElementById!=="undefined"&&documentIsHTML){
var node, i, elems,
elem=context.getElementById(id);
if(elem){
node=elem.getAttributeNode("id");
if(node&&node.value===id){
return [ elem ];
}
elems=context.getElementsByName(id);
i=0;
while(( elem=elems[ i++ ])){
node=elem.getAttributeNode("id");
if(node&&node.value===id){
return [ elem ];
}}
}
return [];
}};}
Expr.find.TAG=function(tag, context){
if(typeof context.getElementsByTagName!=="undefined"){
return context.getElementsByTagName(tag);
}else{
return context.querySelectorAll(tag);
}};
Expr.find.CLASS=function(className, context){
if(typeof context.getElementsByClassName!=="undefined"&&documentIsHTML){
return context.getElementsByClassName(className);
}};
rbuggyQSA=[];
assert(function(el){
var input;
documentElement.appendChild(el).innerHTML =
"<a id='" + expando + "' href='' disabled='disabled'></a>" +
"<select id='" + expando + "-\r\\' disabled='disabled'>" +
"<option selected=''></option></select>";
if(!el.querySelectorAll("[selected]").length){
rbuggyQSA.push("\\[" + whitespace + "*(?:value|" + booleans + ")");
}
if(!el.querySelectorAll("[id~=" + expando + "-]").length){
rbuggyQSA.push("~=");
}
if(!el.querySelectorAll("a#" + expando + "+*").length){
rbuggyQSA.push(".#.+[+~]");
}
if(!el.querySelectorAll(":checked").length){
rbuggyQSA.push(":checked");
}
input=document.createElement("input");
input.setAttribute("type", "hidden");
el.appendChild(input).setAttribute("name", "D");
documentElement.appendChild(el).disabled=true;
if(el.querySelectorAll(":disabled").length!==2){
rbuggyQSA.push(":enabled", ":disabled");
}
input=document.createElement("input");
input.setAttribute("name", "");
el.appendChild(input);
if(!el.querySelectorAll("[name='']").length){
rbuggyQSA.push("\\[" + whitespace + "*name" + whitespace + "*=" +
whitespace + "*(?:''|\"\")");
}});
if(!support.cssHas){
rbuggyQSA.push(":has");
}
rbuggyQSA=rbuggyQSA.length&&new RegExp(rbuggyQSA.join("|"));
sortOrder=function(a, b){
if(a===b){
hasDuplicate=true;
return 0;
}
var compare = !a.compareDocumentPosition - !b.compareDocumentPosition;
if(compare){
return compare;
}
compare=(a.ownerDocument||a)==(b.ownerDocument||b) ?
a.compareDocumentPosition(b) :
1;
if(compare & 1 ||
(!support.sortDetached&&b.compareDocumentPosition(a)===compare)){
if(a===document||a.ownerDocument==preferredDoc &&
find.contains(preferredDoc, a)){
return -1;
}
if(b===document||b.ownerDocument==preferredDoc &&
find.contains(preferredDoc, b)){
return 1;
}
return sortInput ?
(indexOf.call(sortInput, a) - indexOf.call(sortInput, b)) :
0;
}
return compare & 4 ? -1:1;
};
return document;
}
find.matches=function(expr, elements){
return find(expr, null, null, elements);
};
find.matchesSelector=function(elem, expr){
setDocument(elem);
if(documentIsHTML &&
!nonnativeSelectorCache[ expr + " " ] &&
(!rbuggyQSA||!rbuggyQSA.test(expr))){
try {
var ret=matches.call(elem, expr);
if(ret||support.disconnectedMatch ||
elem.document&&elem.document.nodeType!==11){
return ret;
}} catch(e){
nonnativeSelectorCache(expr, true);
}}
return find(expr, document, null, [ elem ]).length > 0;
};
find.contains=function(context, elem){
if(( context.ownerDocument||context)!=document){
setDocument(context);
}
return jQuery.contains(context, elem);
};
find.attr=function(elem, name){
if(( elem.ownerDocument||elem)!=document){
setDocument(elem);
}
var fn=Expr.attrHandle[ name.toLowerCase() ],
val=fn&&hasOwn.call(Expr.attrHandle, name.toLowerCase()) ?
fn(elem, name, !documentIsHTML) :
undefined;
if(val!==undefined){
return val;
}
return elem.getAttribute(name);
};
find.error=function(msg){
throw new Error("Syntax error, unrecognized expression: " + msg);
};
jQuery.uniqueSort=function(results){
var elem,
duplicates=[],
j=0,
i=0;
hasDuplicate = !support.sortStable;
sortInput = !support.sortStable&&slice.call(results, 0);
sort.call(results, sortOrder);
if(hasDuplicate){
while(( elem=results[ i++ ])){
if(elem===results[ i ]){
j=duplicates.push(i);
}}
while(j--){
splice.call(results, duplicates[ j ], 1);
}}
sortInput=null;
return results;
};
jQuery.fn.uniqueSort=function(){
return this.pushStack(jQuery.uniqueSort(slice.apply(this)));
};
Expr=jQuery.expr={
cacheLength: 50,
createPseudo: markFunction,
match: matchExpr,
attrHandle: {},
find: {},
relative: {
">": { dir: "parentNode", first: true },
" ": { dir: "parentNode" },
"+": { dir: "previousSibling", first: true },
"~": { dir: "previousSibling" }},
preFilter: {
ATTR: function(match){
match[ 1 ]=match[ 1 ].replace(runescape, funescape);
match[ 3 ]=(match[ 3 ]||match[ 4 ]||match[ 5 ]||"")
.replace(runescape, funescape);
if(match[ 2 ]==="~="){
match[ 3 ]=" " + match[ 3 ] + " ";
}
return match.slice(0, 4);
},
CHILD: function(match){
match[ 1 ]=match[ 1 ].toLowerCase();
if(match[ 1 ].slice(0, 3)==="nth"){
if(!match[ 3 ]){
find.error(match[ 0 ]);
}
match[ 4 ]=+(match[ 4 ] ?
match[ 5 ] +(match[ 6 ]||1) :
2 *(match[ 3 ]==="even"||match[ 3 ]==="odd")
);
match[ 5 ]=+(( match[ 7 ] + match[ 8 ])||match[ 3 ]==="odd");
}else if(match[ 3 ]){
find.error(match[ 0 ]);
}
return match;
},
PSEUDO: function(match){
var excess,
unquoted = !match[ 6 ]&&match[ 2 ];
if(matchExpr.CHILD.test(match[ 0 ])){
return null;
}
if(match[ 3 ]){
match[ 2 ]=match[ 4 ]||match[ 5 ]||"";
}else if(unquoted&&rpseudo.test(unquoted) &&
(excess=tokenize(unquoted, true)) &&
(excess=unquoted.indexOf(")", unquoted.length - excess) - unquoted.length)){
match[ 0 ]=match[ 0 ].slice(0, excess);
match[ 2 ]=unquoted.slice(0, excess);
}
return match.slice(0, 3);
}},
filter: {
TAG: function(nodeNameSelector){
var expectedNodeName=nodeNameSelector.replace(runescape, funescape).toLowerCase();
return nodeNameSelector==="*" ?
function(){
return true;
} :
function(elem){
return nodeName(elem, expectedNodeName);
};},
CLASS: function(className){
var pattern=classCache[ className + " " ];
return pattern ||
(pattern=new RegExp("(^|" + whitespace + ")" + className +
"(" + whitespace + "|$)")) &&
classCache(className, function(elem){
return pattern.test(typeof elem.className==="string"&&elem.className ||
typeof elem.getAttribute!=="undefined" &&
elem.getAttribute("class") ||
""
);
});
},
ATTR: function(name, operator, check){
return function(elem){
var result=find.attr(elem, name);
if(result==null){
return operator==="!=";
}
if(!operator){
return true;
}
result +="";
if(operator==="="){
return result===check;
}
if(operator==="!="){
return result!==check;
}
if(operator==="^="){
return check&&result.indexOf(check)===0;
}
if(operator==="*="){
return check&&result.indexOf(check) > -1;
}
if(operator==="$="){
return check&&result.slice(-check.length)===check;
}
if(operator==="~="){
return(" " + result.replace(rwhitespace, " ") + " ")
.indexOf(check) > -1;
}
if(operator==="|="){
return result===check||result.slice(0, check.length + 1)===check + "-";
}
return false;
};},
CHILD: function(type, what, _argument, first, last){
var simple=type.slice(0, 3)!=="nth",
forward=type.slice(-4)!=="last",
ofType=what==="of-type";
return first===1&&last===0 ?
function(elem){
return !!elem.parentNode;
} :
function(elem, _context, xml){
var cache, outerCache, node, nodeIndex, start,
dir=simple!==forward ? "nextSibling":"previousSibling",
parent=elem.parentNode,
name=ofType&&elem.nodeName.toLowerCase(),
useCache = !xml&&!ofType,
diff=false;
if(parent){
if(simple){
while(dir){
node=elem;
while(( node=node[ dir ])){
if(ofType ?
nodeName(node, name) :
node.nodeType===1){
return false;
}}
start=dir=type==="only"&&!start&&"nextSibling";
}
return true;
}
start=[ forward ? parent.firstChild:parent.lastChild ];
if(forward&&useCache){
outerCache=parent[ expando ]||(parent[ expando ]={});
cache=outerCache[ type ]||[];
nodeIndex=cache[ 0 ]===dirruns&&cache[ 1 ];
diff=nodeIndex&&cache[ 2 ];
node=nodeIndex&&parent.childNodes[ nodeIndex ];
while(( node=++nodeIndex&&node&&node[ dir ] ||
(diff=nodeIndex=0)||start.pop())){
if(node.nodeType===1&&++diff&&node===elem){
outerCache[ type ]=[ dirruns, nodeIndex, diff ];
break;
}}
}else{
if(useCache){
outerCache=elem[ expando ]||(elem[ expando ]={});
cache=outerCache[ type ]||[];
nodeIndex=cache[ 0 ]===dirruns&&cache[ 1 ];
diff=nodeIndex;
}
if(diff===false){
while(( node=++nodeIndex&&node&&node[ dir ] ||
(diff=nodeIndex=0)||start.pop())){
if(( ofType ?
nodeName(node, name) :
node.nodeType===1) &&
++diff){
if(useCache){
outerCache=node[ expando ] ||
(node[ expando ]={});
outerCache[ type ]=[ dirruns, diff ];
}
if(node===elem){
break;
}}
}}
}
diff -=last;
return diff===first||(diff % first===0&&diff / first >=0);
}};},
PSEUDO: function(pseudo, argument){
var args,
fn=Expr.pseudos[ pseudo ]||Expr.setFilters[ pseudo.toLowerCase() ] ||
find.error("unsupported pseudo: " + pseudo);
if(fn[ expando ]){
return fn(argument);
}
if(fn.length > 1){
args=[ pseudo, pseudo, "", argument ];
return Expr.setFilters.hasOwnProperty(pseudo.toLowerCase()) ?
markFunction(function(seed, matches){
var idx,
matched=fn(seed, argument),
i=matched.length;
while(i--){
idx=indexOf.call(seed, matched[ i ]);
seed[ idx ] = !(matches[ idx ]=matched[ i ]);
}}) :
function(elem){
return fn(elem, 0, args);
};}
return fn;
}},
pseudos: {
not: markFunction(function(selector){
var input=[],
results=[],
matcher=compile(selector.replace(rtrimCSS, "$1"));
return matcher[ expando ] ?
markFunction(function(seed, matches, _context, xml){
var elem,
unmatched=matcher(seed, null, xml, []),
i=seed.length;
while(i--){
if(( elem=unmatched[ i ])){
seed[ i ] = !(matches[ i ]=elem);
}}
}) :
function(elem, _context, xml){
input[ 0 ]=elem;
matcher(input, null, xml, results);
input[ 0 ]=null;
return !results.pop();
};}),
has: markFunction(function(selector){
return function(elem){
return find(selector, elem).length > 0;
};}),
contains: markFunction(function(text){
text=text.replace(runescape, funescape);
return function(elem){
return(elem.textContent||jQuery.text(elem)).indexOf(text) > -1;
};}),
lang: markFunction(function(lang){
if(!ridentifier.test(lang||"")){
find.error("unsupported lang: " + lang);
}
lang=lang.replace(runescape, funescape).toLowerCase();
return function(elem){
var elemLang;
do {
if(( elemLang=documentIsHTML ?
elem.lang :
elem.getAttribute("xml:lang")||elem.getAttribute("lang"))){
elemLang=elemLang.toLowerCase();
return elemLang===lang||elemLang.indexOf(lang + "-")===0;
}} while(( elem=elem.parentNode)&&elem.nodeType===1);
return false;
};}),
target: function(elem){
var hash=window.location&&window.location.hash;
return hash&&hash.slice(1)===elem.id;
},
root: function(elem){
return elem===documentElement;
},
focus: function(elem){
return elem===safeActiveElement() &&
document.hasFocus() &&
!!(elem.type||elem.href||~elem.tabIndex);
},
enabled: createDisabledPseudo(false),
disabled: createDisabledPseudo(true),
checked: function(elem){
return(nodeName(elem, "input")&&!!elem.checked) ||
(nodeName(elem, "option")&&!!elem.selected);
},
selected: function(elem){
if(elem.parentNode){
elem.parentNode.selectedIndex;
}
return elem.selected===true;
},
empty: function(elem){
for(elem=elem.firstChild; elem; elem=elem.nextSibling){
if(elem.nodeType < 6){
return false;
}}
return true;
},
parent: function(elem){
return !Expr.pseudos.empty(elem);
},
header: function(elem){
return rheader.test(elem.nodeName);
},
input: function(elem){
return rinputs.test(elem.nodeName);
},
button: function(elem){
return nodeName(elem, "input")&&elem.type==="button" ||
nodeName(elem, "button");
},
text: function(elem){
var attr;
return nodeName(elem, "input")&&elem.type==="text" &&
(( attr=elem.getAttribute("type"))==null ||
attr.toLowerCase()==="text");
},
first: createPositionalPseudo(function(){
return [ 0 ];
}),
last: createPositionalPseudo(function(_matchIndexes, length){
return [ length - 1 ];
}),
eq: createPositionalPseudo(function(_matchIndexes, length, argument){
return [ argument < 0 ? argument + length:argument ];
}),
even: createPositionalPseudo(function(matchIndexes, length){
var i=0;
for(; i < length; i +=2){
matchIndexes.push(i);
}
return matchIndexes;
}),
odd: createPositionalPseudo(function(matchIndexes, length){
var i=1;
for(; i < length; i +=2){
matchIndexes.push(i);
}
return matchIndexes;
}),
lt: createPositionalPseudo(function(matchIndexes, length, argument){
var i;
if(argument < 0){
i=argument + length;
}else if(argument > length){
i=length;
}else{
i=argument;
}
for(; --i >=0;){
matchIndexes.push(i);
}
return matchIndexes;
}),
gt: createPositionalPseudo(function(matchIndexes, length, argument){
var i=argument < 0 ? argument + length:argument;
for(; ++i < length;){
matchIndexes.push(i);
}
return matchIndexes;
})
}};
Expr.pseudos.nth=Expr.pseudos.eq;
for(i in { radio: true, checkbox: true, file: true, password: true, image: true }){
Expr.pseudos[ i ]=createInputPseudo(i);
}
for(i in { submit: true, reset: true }){
Expr.pseudos[ i ]=createButtonPseudo(i);
}
function setFilters(){}
setFilters.prototype=Expr.filters=Expr.pseudos;
Expr.setFilters=new setFilters();
function tokenize(selector, parseOnly){
var matched, match, tokens, type,
soFar, groups, preFilters,
cached=tokenCache[ selector + " " ];
if(cached){
return parseOnly ? 0:cached.slice(0);
}
soFar=selector;
groups=[];
preFilters=Expr.preFilter;
while(soFar){
if(!matched||(match=rcomma.exec(soFar))){
if(match){
soFar=soFar.slice(match[ 0 ].length)||soFar;
}
groups.push(( tokens=[]));
}
matched=false;
if(( match=rleadingCombinator.exec(soFar))){
matched=match.shift();
tokens.push({
value: matched,
type: match[ 0 ].replace(rtrimCSS, " ")
});
soFar=soFar.slice(matched.length);
}
for(type in Expr.filter){
if(( match=matchExpr[ type ].exec(soFar))&&(!preFilters[ type ] ||
(match=preFilters[ type ](match)))){
matched=match.shift();
tokens.push({
value: matched,
type: type,
matches: match
});
soFar=soFar.slice(matched.length);
}}
if(!matched){
break;
}}
if(parseOnly){
return soFar.length;
}
return soFar ?
find.error(selector) :
tokenCache(selector, groups).slice(0);
}
function toSelector(tokens){
var i=0,
len=tokens.length,
selector="";
for(; i < len; i++){
selector +=tokens[ i ].value;
}
return selector;
}
function addCombinator(matcher, combinator, base){
var dir=combinator.dir,
skip=combinator.next,
key=skip||dir,
checkNonElements=base&&key==="parentNode",
doneName=done++;
return combinator.first ?
function(elem, context, xml){
while(( elem=elem[ dir ])){
if(elem.nodeType===1||checkNonElements){
return matcher(elem, context, xml);
}}
return false;
} :
function(elem, context, xml){
var oldCache, outerCache,
newCache=[ dirruns, doneName ];
if(xml){
while(( elem=elem[ dir ])){
if(elem.nodeType===1||checkNonElements){
if(matcher(elem, context, xml)){
return true;
}}
}}else{
while(( elem=elem[ dir ])){
if(elem.nodeType===1||checkNonElements){
outerCache=elem[ expando ]||(elem[ expando ]={});
if(skip&&nodeName(elem, skip)){
elem=elem[ dir ]||elem;
}else if(( oldCache=outerCache[ key ]) &&
oldCache[ 0 ]===dirruns&&oldCache[ 1 ]===doneName){
return(newCache[ 2 ]=oldCache[ 2 ]);
}else{
outerCache[ key ]=newCache;
if(( newCache[ 2 ]=matcher(elem, context, xml))){
return true;
}}
}}
}
return false;
};}
function elementMatcher(matchers){
return matchers.length > 1 ?
function(elem, context, xml){
var i=matchers.length;
while(i--){
if(!matchers[ i ](elem, context, xml)){
return false;
}}
return true;
} :
matchers[ 0 ];
}
function multipleContexts(selector, contexts, results){
var i=0,
len=contexts.length;
for(; i < len; i++){
find(selector, contexts[ i ], results);
}
return results;
}
function condense(unmatched, map, filter, context, xml){
var elem,
newUnmatched=[],
i=0,
len=unmatched.length,
mapped=map!=null;
for(; i < len; i++){
if(( elem=unmatched[ i ])){
if(!filter||filter(elem, context, xml)){
newUnmatched.push(elem);
if(mapped){
map.push(i);
}}
}}
return newUnmatched;
}
function setMatcher(preFilter, selector, matcher, postFilter, postFinder, postSelector){
if(postFilter&&!postFilter[ expando ]){
postFilter=setMatcher(postFilter);
}
if(postFinder&&!postFinder[ expando ]){
postFinder=setMatcher(postFinder, postSelector);
}
return markFunction(function(seed, results, context, xml){
var temp, i, elem, matcherOut,
preMap=[],
postMap=[],
preexisting=results.length,
elems=seed ||
multipleContexts(selector||"*",
context.nodeType ? [ context ]:context, []),
matcherIn=preFilter&&(seed||!selector) ?
condense(elems, preMap, preFilter, context, xml) :
elems;
if(matcher){
matcherOut=postFinder||(seed ? preFilter:preexisting||postFilter) ?
[] :
results;
matcher(matcherIn, matcherOut, context, xml);
}else{
matcherOut=matcherIn;
}
if(postFilter){
temp=condense(matcherOut, postMap);
postFilter(temp, [], context, xml);
i=temp.length;
while(i--){
if(( elem=temp[ i ])){
matcherOut[ postMap[ i ] ] = !(matcherIn[ postMap[ i ] ]=elem);
}}
}
if(seed){
if(postFinder||preFilter){
if(postFinder){
temp=[];
i=matcherOut.length;
while(i--){
if(( elem=matcherOut[ i ])){
temp.push(( matcherIn[ i ]=elem));
}}
postFinder(null,(matcherOut=[]), temp, xml);
}
i=matcherOut.length;
while(i--){
if(( elem=matcherOut[ i ]) &&
(temp=postFinder ? indexOf.call(seed, elem):preMap[ i ]) > -1){
seed[ temp ] = !(results[ temp ]=elem);
}}
}}else{
matcherOut=condense(
matcherOut===results ?
matcherOut.splice(preexisting, matcherOut.length) :
matcherOut
);
if(postFinder){
postFinder(null, results, matcherOut, xml);
}else{
push.apply(results, matcherOut);
}}
});
}
function matcherFromTokens(tokens){
var checkContext, matcher, j,
len=tokens.length,
leadingRelative=Expr.relative[ tokens[ 0 ].type ],
implicitRelative=leadingRelative||Expr.relative[ " " ],
i=leadingRelative ? 1:0,
matchContext=addCombinator(function(elem){
return elem===checkContext;
}, implicitRelative, true),
matchAnyContext=addCombinator(function(elem){
return indexOf.call(checkContext, elem) > -1;
}, implicitRelative, true),
matchers=[ function(elem, context, xml){
var ret=(!leadingRelative&&(xml||context!=outermostContext))||(
(checkContext=context).nodeType ?
matchContext(elem, context, xml) :
matchAnyContext(elem, context, xml));
checkContext=null;
return ret;
} ];
for(; i < len; i++){
if(( matcher=Expr.relative[ tokens[ i ].type ])){
matchers=[ addCombinator(elementMatcher(matchers), matcher) ];
}else{
matcher=Expr.filter[ tokens[ i ].type ].apply(null, tokens[ i ].matches);
if(matcher[ expando ]){
j=++i;
for(; j < len; j++){
if(Expr.relative[ tokens[ j ].type ]){
break;
}}
return setMatcher(
i > 1&&elementMatcher(matchers),
i > 1&&toSelector(
tokens.slice(0, i - 1)
.concat({ value: tokens[ i - 2 ].type===" " ? "*":"" })
).replace(rtrimCSS, "$1"),
matcher,
i < j&&matcherFromTokens(tokens.slice(i, j)),
j < len&&matcherFromTokens(( tokens=tokens.slice(j))),
j < len&&toSelector(tokens)
);
}
matchers.push(matcher);
}}
return elementMatcher(matchers);
}
function matcherFromGroupMatchers(elementMatchers, setMatchers){
var bySet=setMatchers.length > 0,
byElement=elementMatchers.length > 0,
superMatcher=function(seed, context, xml, results, outermost){
var elem, j, matcher,
matchedCount=0,
i="0",
unmatched=seed&&[],
setMatched=[],
contextBackup=outermostContext,
elems=seed||byElement&&Expr.find.TAG("*", outermost),
dirrunsUnique=(dirruns +=contextBackup==null ? 1:Math.random()||0.1),
len=elems.length;
if(outermost){
outermostContext=context==document||context||outermost;
}
for(; i!==len&&(elem=elems[ i ])!=null; i++){
if(byElement&&elem){
j=0;
if(!context&&elem.ownerDocument!=document){
setDocument(elem);
xml = !documentIsHTML;
}
while(( matcher=elementMatchers[ j++ ])){
if(matcher(elem, context||document, xml)){
push.call(results, elem);
break;
}}
if(outermost){
dirruns=dirrunsUnique;
}}
if(bySet){
if(( elem = !matcher&&elem)){
matchedCount--;
}
if(seed){
unmatched.push(elem);
}}
}
matchedCount +=i;
if(bySet&&i!==matchedCount){
j=0;
while(( matcher=setMatchers[ j++ ])){
matcher(unmatched, setMatched, context, xml);
}
if(seed){
if(matchedCount > 0){
while(i--){
if(!(unmatched[ i ]||setMatched[ i ])){
setMatched[ i ]=pop.call(results);
}}
}
setMatched=condense(setMatched);
}
push.apply(results, setMatched);
if(outermost&&!seed&&setMatched.length > 0 &&
(matchedCount + setMatchers.length) > 1){
jQuery.uniqueSort(results);
}}
if(outermost){
dirruns=dirrunsUnique;
outermostContext=contextBackup;
}
return unmatched;
};
return bySet ?
markFunction(superMatcher) :
superMatcher;
}
function compile(selector, match ){
var i,
setMatchers=[],
elementMatchers=[],
cached=compilerCache[ selector + " " ];
if(!cached){
if(!match){
match=tokenize(selector);
}
i=match.length;
while(i--){
cached=matcherFromTokens(match[ i ]);
if(cached[ expando ]){
setMatchers.push(cached);
}else{
elementMatchers.push(cached);
}}
cached=compilerCache(selector,
matcherFromGroupMatchers(elementMatchers, setMatchers));
cached.selector=selector;
}
return cached;
}
function select(selector, context, results, seed){
var i, tokens, token, type, find,
compiled=typeof selector==="function"&&selector,
match = !seed&&tokenize(( selector=compiled.selector||selector));
results=results||[];
if(match.length===1){
tokens=match[ 0 ]=match[ 0 ].slice(0);
if(tokens.length > 2&&(token=tokens[ 0 ]).type==="ID" &&
context.nodeType===9&&documentIsHTML&&Expr.relative[ tokens[ 1 ].type ]){
context=(Expr.find.ID(token.matches[ 0 ].replace(runescape, funescape),
context
)||[])[ 0 ];
if(!context){
return results;
}else if(compiled){
context=context.parentNode;
}
selector=selector.slice(tokens.shift().value.length);
}
i=matchExpr.needsContext.test(selector) ? 0:tokens.length;
while(i--){
token=tokens[ i ];
if(Expr.relative[(type=token.type) ]){
break;
}
if(( find=Expr.find[ type ])){
if(( seed=find(
token.matches[ 0 ].replace(runescape, funescape),
rsibling.test(tokens[ 0 ].type) &&
testContext(context.parentNode)||context
))){
tokens.splice(i, 1);
selector=seed.length&&toSelector(tokens);
if(!selector){
push.apply(results, seed);
return results;
}
break;
}}
}}
(compiled||compile(selector, match))(
seed,
context,
!documentIsHTML,
results,
!context||rsibling.test(selector)&&testContext(context.parentNode)||context
);
return results;
}
support.sortStable=expando.split("").sort(sortOrder).join("")===expando;
setDocument();
support.sortDetached=assert(function(el){
return el.compareDocumentPosition(document.createElement("fieldset")) & 1;
});
jQuery.find=find;
jQuery.expr[ ":" ]=jQuery.expr.pseudos;
jQuery.unique=jQuery.uniqueSort;
find.compile=compile;
find.select=select;
find.setDocument=setDocument;
find.tokenize=tokenize;
find.escape=jQuery.escapeSelector;
find.getText=jQuery.text;
find.isXML=jQuery.isXMLDoc;
find.selectors=jQuery.expr;
find.support=jQuery.support;
find.uniqueSort=jQuery.uniqueSort;
})();
var dir=function(elem, dir, until){
var matched=[],
truncate=until!==undefined;
while(( elem=elem[ dir ])&&elem.nodeType!==9){
if(elem.nodeType===1){
if(truncate&&jQuery(elem).is(until)){
break;
}
matched.push(elem);
}}
return matched;
};
var siblings=function(n, elem){
var matched=[];
for(; n; n=n.nextSibling){
if(n.nodeType===1&&n!==elem){
matched.push(n);
}}
return matched;
};
var rneedsContext=jQuery.expr.match.needsContext;
var rsingleTag=(/^<([a-z][^\/\0>:\x20\t\r\n\f]*)[\x20\t\r\n\f]*\/?>(?:<\/\1>|)$/i);
function winnow(elements, qualifier, not){
if(isFunction(qualifier)){
return jQuery.grep(elements, function(elem, i){
return !!qualifier.call(elem, i, elem)!==not;
});
}
if(qualifier.nodeType){
return jQuery.grep(elements, function(elem){
return(elem===qualifier)!==not;
});
}
if(typeof qualifier!=="string"){
return jQuery.grep(elements, function(elem){
return(indexOf.call(qualifier, elem) > -1)!==not;
});
}
return jQuery.filter(qualifier, elements, not);
}
jQuery.filter=function(expr, elems, not){
var elem=elems[ 0 ];
if(not){
expr=":not(" + expr + ")";
}
if(elems.length===1&&elem.nodeType===1){
return jQuery.find.matchesSelector(elem, expr) ? [ elem ]:[];
}
return jQuery.find.matches(expr, jQuery.grep(elems, function(elem){
return elem.nodeType===1;
}));
};
jQuery.fn.extend({
find: function(selector){
var i, ret,
len=this.length,
self=this;
if(typeof selector!=="string"){
return this.pushStack(jQuery(selector).filter(function(){
for(i=0; i < len; i++){
if(jQuery.contains(self[ i ], this)){
return true;
}}
}));
}
ret=this.pushStack([]);
for(i=0; i < len; i++){
jQuery.find(selector, self[ i ], ret);
}
return len > 1 ? jQuery.uniqueSort(ret):ret;
},
filter: function(selector){
return this.pushStack(winnow(this, selector||[], false));
},
not: function(selector){
return this.pushStack(winnow(this, selector||[], true));
},
is: function(selector){
return !!winnow(
this,
typeof selector==="string"&&rneedsContext.test(selector) ?
jQuery(selector) :
selector||[],
false
).length;
}});
var rootjQuery,
rquickExpr=/^(?:\s*(<[\w\W]+>)[^>]*|#([\w-]+))$/,
init=jQuery.fn.init=function(selector, context, root){
var match, elem;
if(!selector){
return this;
}
root=root||rootjQuery;
if(typeof selector==="string"){
if(selector[ 0 ]==="<" &&
selector[ selector.length - 1 ]===">" &&
selector.length >=3){
match=[ null, selector, null ];
}else{
match=rquickExpr.exec(selector);
}
if(match&&(match[ 1 ]||!context)){
if(match[ 1 ]){
context=context instanceof jQuery ? context[ 0 ]:context;
jQuery.merge(this, jQuery.parseHTML(match[ 1 ],
context&&context.nodeType ? context.ownerDocument||context:document,
true
));
if(rsingleTag.test(match[ 1 ])&&jQuery.isPlainObject(context)){
for(match in context){
if(isFunction(this[ match ])){
this[ match ](context[ match ]);
}else{
this.attr(match, context[ match ]);
}}
}
return this;
}else{
elem=document.getElementById(match[ 2 ]);
if(elem){
this[ 0 ]=elem;
this.length=1;
}
return this;
}}else if(!context||context.jquery){
return(context||root).find(selector);
}else{
return this.constructor(context).find(selector);
}}else if(selector.nodeType){
this[ 0 ]=selector;
this.length=1;
return this;
}else if(isFunction(selector)){
return root.ready!==undefined ?
root.ready(selector) :
selector(jQuery);
}
return jQuery.makeArray(selector, this);
};
init.prototype=jQuery.fn;
rootjQuery=jQuery(document);
var rparentsprev=/^(?:parents|prev(?:Until|All))/,
guaranteedUnique={
children: true,
contents: true,
next: true,
prev: true
};
jQuery.fn.extend({
has: function(target){
var targets=jQuery(target, this),
l=targets.length;
return this.filter(function(){
var i=0;
for(; i < l; i++){
if(jQuery.contains(this, targets[ i ])){
return true;
}}
});
},
closest: function(selectors, context){
var cur,
i=0,
l=this.length,
matched=[],
targets=typeof selectors!=="string"&&jQuery(selectors);
if(!rneedsContext.test(selectors)){
for(; i < l; i++){
for(cur=this[ i ]; cur&&cur!==context; cur=cur.parentNode){
if(cur.nodeType < 11&&(targets ?
targets.index(cur) > -1 :
cur.nodeType===1 &&
jQuery.find.matchesSelector(cur, selectors))){
matched.push(cur);
break;
}}
}}
return this.pushStack(matched.length > 1 ? jQuery.uniqueSort(matched):matched);
},
index: function(elem){
if(!elem){
return(this[ 0 ]&&this[ 0 ].parentNode) ? this.first().prevAll().length:-1;
}
if(typeof elem==="string"){
return indexOf.call(jQuery(elem), this[ 0 ]);
}
return indexOf.call(this,
elem.jquery ? elem[ 0 ]:elem
);
},
add: function(selector, context){
return this.pushStack(jQuery.uniqueSort(jQuery.merge(this.get(), jQuery(selector, context))
)
);
},
addBack: function(selector){
return this.add(selector==null ?
this.prevObject:this.prevObject.filter(selector)
);
}});
function sibling(cur, dir){
while(( cur=cur[ dir ])&&cur.nodeType!==1){}
return cur;
}
jQuery.each({
parent: function(elem){
var parent=elem.parentNode;
return parent&&parent.nodeType!==11 ? parent:null;
},
parents: function(elem){
return dir(elem, "parentNode");
},
parentsUntil: function(elem, _i, until){
return dir(elem, "parentNode", until);
},
next: function(elem){
return sibling(elem, "nextSibling");
},
prev: function(elem){
return sibling(elem, "previousSibling");
},
nextAll: function(elem){
return dir(elem, "nextSibling");
},
prevAll: function(elem){
return dir(elem, "previousSibling");
},
nextUntil: function(elem, _i, until){
return dir(elem, "nextSibling", until);
},
prevUntil: function(elem, _i, until){
return dir(elem, "previousSibling", until);
},
siblings: function(elem){
return siblings(( elem.parentNode||{}).firstChild, elem);
},
children: function(elem){
return siblings(elem.firstChild);
},
contents: function(elem){
if(elem.contentDocument!=null &&
getProto(elem.contentDocument)){
return elem.contentDocument;
}
if(nodeName(elem, "template")){
elem=elem.content||elem;
}
return jQuery.merge([], elem.childNodes);
}}, function(name, fn){
jQuery.fn[ name ]=function(until, selector){
var matched=jQuery.map(this, fn, until);
if(name.slice(-5)!=="Until"){
selector=until;
}
if(selector&&typeof selector==="string"){
matched=jQuery.filter(selector, matched);
}
if(this.length > 1){
if(!guaranteedUnique[ name ]){
jQuery.uniqueSort(matched);
}
if(rparentsprev.test(name)){
matched.reverse();
}}
return this.pushStack(matched);
};});
var rnothtmlwhite=(/[^\x20\t\r\n\f]+/g);
function createOptions(options){
var object={};
jQuery.each(options.match(rnothtmlwhite)||[], function(_, flag){
object[ flag ]=true;
});
return object;
}
jQuery.Callbacks=function(options){
options=typeof options==="string" ?
createOptions(options) :
jQuery.extend({}, options);
var
firing,
memory,
fired,
locked,
list=[],
queue=[],
firingIndex=-1,
fire=function(){
locked=locked||options.once;
fired=firing=true;
for(; queue.length; firingIndex=-1){
memory=queue.shift();
while ( ++firingIndex < list.length){
if(list[ firingIndex ].apply(memory[ 0 ], memory[ 1 ])===false &&
options.stopOnFalse){
firingIndex=list.length;
memory=false;
}}
}
if(!options.memory){
memory=false;
}
firing=false;
if(locked){
if(memory){
list=[];
}else{
list="";
}}
},
self={
add: function(){
if(list){
if(memory&&!firing){
firingIndex=list.length - 1;
queue.push(memory);
}
(function add(args){
jQuery.each(args, function(_, arg){
if(isFunction(arg)){
if(!options.unique||!self.has(arg)){
list.push(arg);
}}else if(arg&&arg.length&&toType(arg)!=="string"){
add(arg);
}});
})(arguments);
if(memory&&!firing){
fire();
}}
return this;
},
remove: function(){
jQuery.each(arguments, function(_, arg){
var index;
while(( index=jQuery.inArray(arg, list, index)) > -1){
list.splice(index, 1);
if(index <=firingIndex){
firingIndex--;
}}
});
return this;
},
has: function(fn){
return fn ?
jQuery.inArray(fn, list) > -1 :
list.length > 0;
},
empty: function(){
if(list){
list=[];
}
return this;
},
disable: function(){
locked=queue=[];
list=memory="";
return this;
},
disabled: function(){
return !list;
},
lock: function(){
locked=queue=[];
if(!memory&&!firing){
list=memory="";
}
return this;
},
locked: function(){
return !!locked;
},
fireWith: function(context, args){
if(!locked){
args=args||[];
args=[ context, args.slice ? args.slice():args ];
queue.push(args);
if(!firing){
fire();
}}
return this;
},
fire: function(){
self.fireWith(this, arguments);
return this;
},
fired: function(){
return !!fired;
}};
return self;
};
function Identity(v){
return v;
}
function Thrower(ex){
throw ex;
}
function adoptValue(value, resolve, reject, noValue){
var method;
try {
if(value&&isFunction(( method=value.promise))){
method.call(value).done(resolve).fail(reject);
}else if(value&&isFunction(( method=value.then))){
method.call(value, resolve, reject);
}else{
resolve.apply(undefined, [ value ].slice(noValue));
}} catch(value){
reject.apply(undefined, [ value ]);
}}
jQuery.extend({
Deferred: function(func){
var tuples=[
[ "notify", "progress", jQuery.Callbacks("memory"),
jQuery.Callbacks("memory"), 2 ],
[ "resolve", "done", jQuery.Callbacks("once memory"),
jQuery.Callbacks("once memory"), 0, "resolved" ],
[ "reject", "fail", jQuery.Callbacks("once memory"),
jQuery.Callbacks("once memory"), 1, "rejected" ]
],
state="pending",
promise={
state: function(){
return state;
},
always: function(){
deferred.done(arguments).fail(arguments);
return this;
},
"catch": function(fn){
return promise.then(null, fn);
},
pipe: function(){
var fns=arguments;
return jQuery.Deferred(function(newDefer){
jQuery.each(tuples, function(_i, tuple){
var fn=isFunction(fns[ tuple[ 4 ] ])&&fns[ tuple[ 4 ] ];
deferred[ tuple[ 1 ] ](function(){
var returned=fn&&fn.apply(this, arguments);
if(returned&&isFunction(returned.promise)){
returned.promise()
.progress(newDefer.notify)
.done(newDefer.resolve)
.fail(newDefer.reject);
}else{
newDefer[ tuple[ 0 ] + "With" ](
this,
fn ? [ returned ]:arguments
);
}});
});
fns=null;
}).promise();
},
then: function(onFulfilled, onRejected, onProgress){
var maxDepth=0;
function resolve(depth, deferred, handler, special){
return function(){
var that=this,
args=arguments,
mightThrow=function(){
var returned, then;
if(depth < maxDepth){
return;
}
returned=handler.apply(that, args);
if(returned===deferred.promise()){
throw new TypeError("Thenable self-resolution");
}
then=returned &&
(typeof returned==="object" ||
typeof returned==="function") &&
returned.then;
if(isFunction(then)){
if(special){
then.call(returned,
resolve(maxDepth, deferred, Identity, special),
resolve(maxDepth, deferred, Thrower, special)
);
}else{
maxDepth++;
then.call(returned,
resolve(maxDepth, deferred, Identity, special),
resolve(maxDepth, deferred, Thrower, special),
resolve(maxDepth, deferred, Identity,
deferred.notifyWith)
);
}}else{
if(handler!==Identity){
that=undefined;
args=[ returned ];
}
(special||deferred.resolveWith)(that, args);
}},
process=special ?
mightThrow :
function(){
try {
mightThrow();
} catch(e){
if(jQuery.Deferred.exceptionHook){
jQuery.Deferred.exceptionHook(e,
process.error);
}
if(depth + 1 >=maxDepth){
if(handler!==Thrower){
that=undefined;
args=[ e ];
}
deferred.rejectWith(that, args);
}}
};
if(depth){
process();
}else{
if(jQuery.Deferred.getErrorHook){
process.error=jQuery.Deferred.getErrorHook();
}else if(jQuery.Deferred.getStackHook){
process.error=jQuery.Deferred.getStackHook();
}
window.setTimeout(process);
}};}
return jQuery.Deferred(function(newDefer){
tuples[ 0 ][ 3 ].add(resolve(
0,
newDefer,
isFunction(onProgress) ?
onProgress :
Identity,
newDefer.notifyWith
)
);
tuples[ 1 ][ 3 ].add(resolve(
0,
newDefer,
isFunction(onFulfilled) ?
onFulfilled :
Identity
)
);
tuples[ 2 ][ 3 ].add(resolve(
0,
newDefer,
isFunction(onRejected) ?
onRejected :
Thrower
)
);
}).promise();
},
promise: function(obj){
return obj!=null ? jQuery.extend(obj, promise):promise;
}},
deferred={};
jQuery.each(tuples, function(i, tuple){
var list=tuple[ 2 ],
stateString=tuple[ 5 ];
promise[ tuple[ 1 ] ]=list.add;
if(stateString){
list.add(function(){
state=stateString;
},
tuples[ 3 - i ][ 2 ].disable,
tuples[ 3 - i ][ 3 ].disable,
tuples[ 0 ][ 2 ].lock,
tuples[ 0 ][ 3 ].lock
);
}
list.add(tuple[ 3 ].fire);
deferred[ tuple[ 0 ] ]=function(){
deferred[ tuple[ 0 ] + "With" ](this===deferred ? undefined:this, arguments);
return this;
};
deferred[ tuple[ 0 ] + "With" ]=list.fireWith;
});
promise.promise(deferred);
if(func){
func.call(deferred, deferred);
}
return deferred;
},
when: function(singleValue){
var
remaining=arguments.length,
i=remaining,
resolveContexts=Array(i),
resolveValues=slice.call(arguments),
primary=jQuery.Deferred(),
updateFunc=function(i){
return function(value){
resolveContexts[ i ]=this;
resolveValues[ i ]=arguments.length > 1 ? slice.call(arguments):value;
if(!(--remaining)){
primary.resolveWith(resolveContexts, resolveValues);
}};};
if(remaining <=1){
adoptValue(singleValue, primary.done(updateFunc(i)).resolve, primary.reject,
!remaining);
if(primary.state()==="pending" ||
isFunction(resolveValues[ i ]&&resolveValues[ i ].then)){
return primary.then();
}}
while(i--){
adoptValue(resolveValues[ i ], updateFunc(i), primary.reject);
}
return primary.promise();
}});
var rerrorNames=/^(Eval|Internal|Range|Reference|Syntax|Type|URI)Error$/;
jQuery.Deferred.exceptionHook=function(error, asyncError){
if(window.console&&window.console.warn&&error&&rerrorNames.test(error.name)){
window.console.warn("jQuery.Deferred exception: " + error.message,
error.stack, asyncError);
}};
jQuery.readyException=function(error){
window.setTimeout(function(){
throw error;
});
};
var readyList=jQuery.Deferred();
jQuery.fn.ready=function(fn){
readyList
.then(fn)
.catch(function(error){
jQuery.readyException(error);
});
return this;
};
jQuery.extend({
isReady: false,
readyWait: 1,
ready: function(wait){
if(wait===true ? --jQuery.readyWait:jQuery.isReady){
return;
}
jQuery.isReady=true;
if(wait!==true&&--jQuery.readyWait > 0){
return;
}
readyList.resolveWith(document, [ jQuery ]);
}});
jQuery.ready.then=readyList.then;
function completed(){
document.removeEventListener("DOMContentLoaded", completed);
window.removeEventListener("load", completed);
jQuery.ready();
}
if(document.readyState==="complete" ||
(document.readyState!=="loading"&&!document.documentElement.doScroll)){
window.setTimeout(jQuery.ready);
}else{
document.addEventListener("DOMContentLoaded", completed);
window.addEventListener("load", completed);
}
var access=function(elems, fn, key, value, chainable, emptyGet, raw){
var i=0,
len=elems.length,
bulk=key==null;
if(toType(key)==="object"){
chainable=true;
for(i in key){
access(elems, fn, i, key[ i ], true, emptyGet, raw);
}}else if(value!==undefined){
chainable=true;
if(!isFunction(value)){
raw=true;
}
if(bulk){
if(raw){
fn.call(elems, value);
fn=null;
}else{
bulk=fn;
fn=function(elem, _key, value){
return bulk.call(jQuery(elem), value);
};}}
if(fn){
for(; i < len; i++){
fn(
elems[ i ], key, raw ?
value :
value.call(elems[ i ], i, fn(elems[ i ], key))
);
}}
}
if(chainable){
return elems;
}
if(bulk){
return fn.call(elems);
}
return len ? fn(elems[ 0 ], key):emptyGet;
};
var rmsPrefix=/^-ms-/,
rdashAlpha=/-([a-z])/g;
function fcamelCase(_all, letter){
return letter.toUpperCase();
}
function camelCase(string){
return string.replace(rmsPrefix, "ms-").replace(rdashAlpha, fcamelCase);
}
var acceptData=function(owner){
return owner.nodeType===1||owner.nodeType===9||!( +owner.nodeType);
};
function Data(){
this.expando=jQuery.expando + Data.uid++;
}
Data.uid=1;
Data.prototype={
cache: function(owner){
var value=owner[ this.expando ];
if(!value){
value={};
if(acceptData(owner)){
if(owner.nodeType){
owner[ this.expando ]=value;
}else{
Object.defineProperty(owner, this.expando, {
value: value,
configurable: true
});
}}
}
return value;
},
set: function(owner, data, value){
var prop,
cache=this.cache(owner);
if(typeof data==="string"){
cache[ camelCase(data) ]=value;
}else{
for(prop in data){
cache[ camelCase(prop) ]=data[ prop ];
}}
return cache;
},
get: function(owner, key){
return key===undefined ?
this.cache(owner) :
owner[ this.expando ]&&owner[ this.expando ][ camelCase(key) ];
},
access: function(owner, key, value){
if(key===undefined ||
(( key&&typeof key==="string")&&value===undefined)){
return this.get(owner, key);
}
this.set(owner, key, value);
return value!==undefined ? value:key;
},
remove: function(owner, key){
var i,
cache=owner[ this.expando ];
if(cache===undefined){
return;
}
if(key!==undefined){
if(Array.isArray(key)){
key=key.map(camelCase);
}else{
key=camelCase(key);
key=key in cache ?
[ key ] :
(key.match(rnothtmlwhite)||[]);
}
i=key.length;
while(i--){
delete cache[ key[ i ] ];
}}
if(key===undefined||jQuery.isEmptyObject(cache)){
if(owner.nodeType){
owner[ this.expando ]=undefined;
}else{
delete owner[ this.expando ];
}}
},
hasData: function(owner){
var cache=owner[ this.expando ];
return cache!==undefined&&!jQuery.isEmptyObject(cache);
}};
var dataPriv=new Data();
var dataUser=new Data();
var rbrace=/^(?:\{[\w\W]*\}|\[[\w\W]*\])$/,
rmultiDash=/[A-Z]/g;
function getData(data){
if(data==="true"){
return true;
}
if(data==="false"){
return false;
}
if(data==="null"){
return null;
}
if(data===+data + ""){
return +data;
}
if(rbrace.test(data)){
return JSON.parse(data);
}
return data;
}
function dataAttr(elem, key, data){
var name;
if(data===undefined&&elem.nodeType===1){
name="data-" + key.replace(rmultiDash, "-$&").toLowerCase();
data=elem.getAttribute(name);
if(typeof data==="string"){
try {
data=getData(data);
} catch(e){}
dataUser.set(elem, key, data);
}else{
data=undefined;
}}
return data;
}
jQuery.extend({
hasData: function(elem){
return dataUser.hasData(elem)||dataPriv.hasData(elem);
},
data: function(elem, name, data){
return dataUser.access(elem, name, data);
},
removeData: function(elem, name){
dataUser.remove(elem, name);
},
_data: function(elem, name, data){
return dataPriv.access(elem, name, data);
},
_removeData: function(elem, name){
dataPriv.remove(elem, name);
}});
jQuery.fn.extend({
data: function(key, value){
var i, name, data,
elem=this[ 0 ],
attrs=elem&&elem.attributes;
if(key===undefined){
if(this.length){
data=dataUser.get(elem);
if(elem.nodeType===1&&!dataPriv.get(elem, "hasDataAttrs")){
i=attrs.length;
while(i--){
if(attrs[ i ]){
name=attrs[ i ].name;
if(name.indexOf("data-")===0){
name=camelCase(name.slice(5));
dataAttr(elem, name, data[ name ]);
}}
}
dataPriv.set(elem, "hasDataAttrs", true);
}}
return data;
}
if(typeof key==="object"){
return this.each(function(){
dataUser.set(this, key);
});
}
return access(this, function(value){
var data;
if(elem&&value===undefined){
data=dataUser.get(elem, key);
if(data!==undefined){
return data;
}
data=dataAttr(elem, key);
if(data!==undefined){
return data;
}
return;
}
this.each(function(){
dataUser.set(this, key, value);
});
}, null, value, arguments.length > 1, null, true);
},
removeData: function(key){
return this.each(function(){
dataUser.remove(this, key);
});
}});
jQuery.extend({
queue: function(elem, type, data){
var queue;
if(elem){
type=(type||"fx") + "queue";
queue=dataPriv.get(elem, type);
if(data){
if(!queue||Array.isArray(data)){
queue=dataPriv.access(elem, type, jQuery.makeArray(data));
}else{
queue.push(data);
}}
return queue||[];
}},
dequeue: function(elem, type){
type=type||"fx";
var queue=jQuery.queue(elem, type),
startLength=queue.length,
fn=queue.shift(),
hooks=jQuery._queueHooks(elem, type),
next=function(){
jQuery.dequeue(elem, type);
};
if(fn==="inprogress"){
fn=queue.shift();
startLength--;
}
if(fn){
if(type==="fx"){
queue.unshift("inprogress");
}
delete hooks.stop;
fn.call(elem, next, hooks);
}
if(!startLength&&hooks){
hooks.empty.fire();
}},
_queueHooks: function(elem, type){
var key=type + "queueHooks";
return dataPriv.get(elem, key)||dataPriv.access(elem, key, {
empty: jQuery.Callbacks("once memory").add(function(){
dataPriv.remove(elem, [ type + "queue", key ]);
})
});
}});
jQuery.fn.extend({
queue: function(type, data){
var setter=2;
if(typeof type!=="string"){
data=type;
type="fx";
setter--;
}
if(arguments.length < setter){
return jQuery.queue(this[ 0 ], type);
}
return data===undefined ?
this :
this.each(function(){
var queue=jQuery.queue(this, type, data);
jQuery._queueHooks(this, type);
if(type==="fx"&&queue[ 0 ]!=="inprogress"){
jQuery.dequeue(this, type);
}});
},
dequeue: function(type){
return this.each(function(){
jQuery.dequeue(this, type);
});
},
clearQueue: function(type){
return this.queue(type||"fx", []);
},
promise: function(type, obj){
var tmp,
count=1,
defer=jQuery.Deferred(),
elements=this,
i=this.length,
resolve=function(){
if(!(--count)){
defer.resolveWith(elements, [ elements ]);
}};
if(typeof type!=="string"){
obj=type;
type=undefined;
}
type=type||"fx";
while(i--){
tmp=dataPriv.get(elements[ i ], type + "queueHooks");
if(tmp&&tmp.empty){
count++;
tmp.empty.add(resolve);
}}
resolve();
return defer.promise(obj);
}});
var pnum=(/[+-]?(?:\d*\.|)\d+(?:[eE][+-]?\d+|)/).source;
var rcssNum=new RegExp("^(?:([+-])=|)(" + pnum + ")([a-z%]*)$", "i");
var cssExpand=[ "Top", "Right", "Bottom", "Left" ];
var documentElement=document.documentElement;
var isAttached=function(elem){
return jQuery.contains(elem.ownerDocument, elem);
},
composed={ composed: true };
if(documentElement.getRootNode){
isAttached=function(elem){
return jQuery.contains(elem.ownerDocument, elem) ||
elem.getRootNode(composed)===elem.ownerDocument;
};}
var isHiddenWithinTree=function(elem, el){
elem=el||elem;
return elem.style.display==="none" ||
elem.style.display==="" &&
isAttached(elem) &&
jQuery.css(elem, "display")==="none";
};
function adjustCSS(elem, prop, valueParts, tween){
var adjusted, scale,
maxIterations=20,
currentValue=tween ?
function(){
return tween.cur();
} :
function(){
return jQuery.css(elem, prop, "");
},
initial=currentValue(),
unit=valueParts&&valueParts[ 3 ]||(jQuery.cssNumber[ prop ] ? "":"px"),
initialInUnit=elem.nodeType &&
(jQuery.cssNumber[ prop ]||unit!=="px"&&+initial) &&
rcssNum.exec(jQuery.css(elem, prop));
if(initialInUnit&&initialInUnit[ 3 ]!==unit){
initial=initial / 2;
unit=unit||initialInUnit[ 3 ];
initialInUnit=+initial||1;
while(maxIterations--){
jQuery.style(elem, prop, initialInUnit + unit);
if(( 1 - scale) *(1 -(scale=currentValue() / initial||0.5)) <=0){
maxIterations=0;
}
initialInUnit=initialInUnit / scale;
}
initialInUnit=initialInUnit * 2;
jQuery.style(elem, prop, initialInUnit + unit);
valueParts=valueParts||[];
}
if(valueParts){
initialInUnit=+initialInUnit||+initial||0;
adjusted=valueParts[ 1 ] ?
initialInUnit +(valueParts[ 1 ] + 1) * valueParts[ 2 ] :
+valueParts[ 2 ];
if(tween){
tween.unit=unit;
tween.start=initialInUnit;
tween.end=adjusted;
}}
return adjusted;
}
var defaultDisplayMap={};
function getDefaultDisplay(elem){
var temp,
doc=elem.ownerDocument,
nodeName=elem.nodeName,
display=defaultDisplayMap[ nodeName ];
if(display){
return display;
}
temp=doc.body.appendChild(doc.createElement(nodeName));
display=jQuery.css(temp, "display");
temp.parentNode.removeChild(temp);
if(display==="none"){
display="block";
}
defaultDisplayMap[ nodeName ]=display;
return display;
}
function showHide(elements, show){
var display, elem,
values=[],
index=0,
length=elements.length;
for(; index < length; index++){
elem=elements[ index ];
if(!elem.style){
continue;
}
display=elem.style.display;
if(show){
if(display==="none"){
values[ index ]=dataPriv.get(elem, "display")||null;
if(!values[ index ]){
elem.style.display="";
}}
if(elem.style.display===""&&isHiddenWithinTree(elem)){
values[ index ]=getDefaultDisplay(elem);
}}else{
if(display!=="none"){
values[ index ]="none";
dataPriv.set(elem, "display", display);
}}
}
for(index=0; index < length; index++){
if(values[ index ]!=null){
elements[ index ].style.display=values[ index ];
}}
return elements;
}
jQuery.fn.extend({
show: function(){
return showHide(this, true);
},
hide: function(){
return showHide(this);
},
toggle: function(state){
if(typeof state==="boolean"){
return state ? this.show():this.hide();
}
return this.each(function(){
if(isHiddenWithinTree(this)){
jQuery(this).show();
}else{
jQuery(this).hide();
}});
}});
var rcheckableType=(/^(?:checkbox|radio)$/i);
var rtagName=(/<([a-z][^\/\0>\x20\t\r\n\f]*)/i);
var rscriptType=(/^$|^module$|\/(?:java|ecma)script/i);
(function(){
var fragment=document.createDocumentFragment(),
div=fragment.appendChild(document.createElement("div")),
input=document.createElement("input");
input.setAttribute("type", "radio");
input.setAttribute("checked", "checked");
input.setAttribute("name", "t");
div.appendChild(input);
support.checkClone=div.cloneNode(true).cloneNode(true).lastChild.checked;
div.innerHTML="<textarea>x</textarea>";
support.noCloneChecked = !!div.cloneNode(true).lastChild.defaultValue;
div.innerHTML="<option></option>";
support.option = !!div.lastChild;
})();
var wrapMap={
thead: [ 1, "<table>", "</table>" ],
col: [ 2, "<table><colgroup>", "</colgroup></table>" ],
tr: [ 2, "<table><tbody>", "</tbody></table>" ],
td: [ 3, "<table><tbody><tr>", "</tr></tbody></table>" ],
_default: [ 0, "", "" ]
};
wrapMap.tbody=wrapMap.tfoot=wrapMap.colgroup=wrapMap.caption=wrapMap.thead;
wrapMap.th=wrapMap.td;
if(!support.option){
wrapMap.optgroup=wrapMap.option=[ 1, "<select multiple='multiple'>", "</select>" ];
}
function getAll(context, tag){
var ret;
if(typeof context.getElementsByTagName!=="undefined"){
ret=context.getElementsByTagName(tag||"*");
}else if(typeof context.querySelectorAll!=="undefined"){
ret=context.querySelectorAll(tag||"*");
}else{
ret=[];
}
if(tag===undefined||tag&&nodeName(context, tag)){
return jQuery.merge([ context ], ret);
}
return ret;
}
function setGlobalEval(elems, refElements){
var i=0,
l=elems.length;
for(; i < l; i++){
dataPriv.set(elems[ i ],
"globalEval",
!refElements||dataPriv.get(refElements[ i ], "globalEval")
);
}}
var rhtml=/<|&#?\w+;/;
function buildFragment(elems, context, scripts, selection, ignored){
var elem, tmp, tag, wrap, attached, j,
fragment=context.createDocumentFragment(),
nodes=[],
i=0,
l=elems.length;
for(; i < l; i++){
elem=elems[ i ];
if(elem||elem===0){
if(toType(elem)==="object"){
jQuery.merge(nodes, elem.nodeType ? [ elem ]:elem);
}else if(!rhtml.test(elem)){
nodes.push(context.createTextNode(elem));
}else{
tmp=tmp||fragment.appendChild(context.createElement("div"));
tag=(rtagName.exec(elem)||[ "", "" ])[ 1 ].toLowerCase();
wrap=wrapMap[ tag ]||wrapMap._default;
tmp.innerHTML=wrap[ 1 ] + jQuery.htmlPrefilter(elem) + wrap[ 2 ];
j=wrap[ 0 ];
while(j--){
tmp=tmp.lastChild;
}
jQuery.merge(nodes, tmp.childNodes);
tmp=fragment.firstChild;
tmp.textContent="";
}}
}
fragment.textContent="";
i=0;
while(( elem=nodes[ i++ ])){
if(selection&&jQuery.inArray(elem, selection) > -1){
if(ignored){
ignored.push(elem);
}
continue;
}
attached=isAttached(elem);
tmp=getAll(fragment.appendChild(elem), "script");
if(attached){
setGlobalEval(tmp);
}
if(scripts){
j=0;
while(( elem=tmp[ j++ ])){
if(rscriptType.test(elem.type||"")){
scripts.push(elem);
}}
}}
return fragment;
}
var rtypenamespace=/^([^.]*)(?:\.(.+)|)/;
function returnTrue(){
return true;
}
function returnFalse(){
return false;
}
function on(elem, types, selector, data, fn, one){
var origFn, type;
if(typeof types==="object"){
if(typeof selector!=="string"){
data=data||selector;
selector=undefined;
}
for(type in types){
on(elem, type, selector, data, types[ type ], one);
}
return elem;
}
if(data==null&&fn==null){
fn=selector;
data=selector=undefined;
}else if(fn==null){
if(typeof selector==="string"){
fn=data;
data=undefined;
}else{
fn=data;
data=selector;
selector=undefined;
}}
if(fn===false){
fn=returnFalse;
}else if(!fn){
return elem;
}
if(one===1){
origFn=fn;
fn=function(event){
jQuery().off(event);
return origFn.apply(this, arguments);
};
fn.guid=origFn.guid||(origFn.guid=jQuery.guid++);
}
return elem.each(function(){
jQuery.event.add(this, types, fn, data, selector);
});
}
jQuery.event={
global: {},
add: function(elem, types, handler, data, selector){
var handleObjIn, eventHandle, tmp,
events, t, handleObj,
special, handlers, type, namespaces, origType,
elemData=dataPriv.get(elem);
if(!acceptData(elem)){
return;
}
if(handler.handler){
handleObjIn=handler;
handler=handleObjIn.handler;
selector=handleObjIn.selector;
}
if(selector){
jQuery.find.matchesSelector(documentElement, selector);
}
if(!handler.guid){
handler.guid=jQuery.guid++;
}
if(!(events=elemData.events)){
events=elemData.events=Object.create(null);
}
if(!(eventHandle=elemData.handle)){
eventHandle=elemData.handle=function(e){
return typeof jQuery!=="undefined"&&jQuery.event.triggered!==e.type ?
jQuery.event.dispatch.apply(elem, arguments):undefined;
};}
types=(types||"").match(rnothtmlwhite)||[ "" ];
t=types.length;
while(t--){
tmp=rtypenamespace.exec(types[ t ])||[];
type=origType=tmp[ 1 ];
namespaces=(tmp[ 2 ]||"").split(".").sort();
if(!type){
continue;
}
special=jQuery.event.special[ type ]||{};
type=(selector ? special.delegateType:special.bindType)||type;
special=jQuery.event.special[ type ]||{};
handleObj=jQuery.extend({
type: type,
origType: origType,
data: data,
handler: handler,
guid: handler.guid,
selector: selector,
needsContext: selector&&jQuery.expr.match.needsContext.test(selector),
namespace: namespaces.join(".")
}, handleObjIn);
if(!(handlers=events[ type ])){
handlers=events[ type ]=[];
handlers.delegateCount=0;
if(!special.setup ||
special.setup.call(elem, data, namespaces, eventHandle)===false){
if(elem.addEventListener){
elem.addEventListener(type, eventHandle);
}}
}
if(special.add){
special.add.call(elem, handleObj);
if(!handleObj.handler.guid){
handleObj.handler.guid=handler.guid;
}}
if(selector){
handlers.splice(handlers.delegateCount++, 0, handleObj);
}else{
handlers.push(handleObj);
}
jQuery.event.global[ type ]=true;
}},
remove: function(elem, types, handler, selector, mappedTypes){
var j, origCount, tmp,
events, t, handleObj,
special, handlers, type, namespaces, origType,
elemData=dataPriv.hasData(elem)&&dataPriv.get(elem);
if(!elemData||!(events=elemData.events)){
return;
}
types=(types||"").match(rnothtmlwhite)||[ "" ];
t=types.length;
while(t--){
tmp=rtypenamespace.exec(types[ t ])||[];
type=origType=tmp[ 1 ];
namespaces=(tmp[ 2 ]||"").split(".").sort();
if(!type){
for(type in events){
jQuery.event.remove(elem, type + types[ t ], handler, selector, true);
}
continue;
}
special=jQuery.event.special[ type ]||{};
type=(selector ? special.delegateType:special.bindType)||type;
handlers=events[ type ]||[];
tmp=tmp[ 2 ] &&
new RegExp("(^|\\.)" + namespaces.join("\\.(?:.*\\.|)") + "(\\.|$)");
origCount=j = handlers.length;
while(j--){
handleObj=handlers[ j ];
if(( mappedTypes||origType===handleObj.origType) &&
(!handler||handler.guid===handleObj.guid) &&
(!tmp||tmp.test(handleObj.namespace)) &&
(!selector||selector===handleObj.selector ||
selector==="**"&&handleObj.selector)){
handlers.splice(j, 1);
if(handleObj.selector){
handlers.delegateCount--;
}
if(special.remove){
special.remove.call(elem, handleObj);
}}
}
if(origCount&&!handlers.length){
if(!special.teardown ||
special.teardown.call(elem, namespaces, elemData.handle)===false){
jQuery.removeEvent(elem, type, elemData.handle);
}
delete events[ type ];
}}
if(jQuery.isEmptyObject(events)){
dataPriv.remove(elem, "handle events");
}},
dispatch: function(nativeEvent){
var i, j, ret, matched, handleObj, handlerQueue,
args=new Array(arguments.length),
event=jQuery.event.fix(nativeEvent),
handlers=(
dataPriv.get(this, "events")||Object.create(null)
)[ event.type ]||[],
special=jQuery.event.special[ event.type ]||{};
args[ 0 ]=event;
for(i=1; i < arguments.length; i++){
args[ i ]=arguments[ i ];
}
event.delegateTarget=this;
if(special.preDispatch&&special.preDispatch.call(this, event)===false){
return;
}
handlerQueue=jQuery.event.handlers.call(this, event, handlers);
i=0;
while(( matched=handlerQueue[ i++ ])&&!event.isPropagationStopped()){
event.currentTarget=matched.elem;
j=0;
while(( handleObj=matched.handlers[ j++ ]) &&
!event.isImmediatePropagationStopped()){
if(!event.rnamespace||handleObj.namespace===false ||
event.rnamespace.test(handleObj.namespace)){
event.handleObj=handleObj;
event.data=handleObj.data;
ret=(( jQuery.event.special[ handleObj.origType ]||{}).handle ||
handleObj.handler).apply(matched.elem, args);
if(ret!==undefined){
if(( event.result=ret)===false){
event.preventDefault();
event.stopPropagation();
}}
}}
}
if(special.postDispatch){
special.postDispatch.call(this, event);
}
return event.result;
},
handlers: function(event, handlers){
var i, handleObj, sel, matchedHandlers, matchedSelectors,
handlerQueue=[],
delegateCount=handlers.delegateCount,
cur=event.target;
if(delegateCount &&
cur.nodeType &&
!(event.type==="click"&&event.button >=1)){
for(; cur!==this; cur=cur.parentNode||this){
if(cur.nodeType===1&&!(event.type==="click"&&cur.disabled===true)){
matchedHandlers=[];
matchedSelectors={};
for(i=0; i < delegateCount; i++){
handleObj=handlers[ i ];
sel=handleObj.selector + " ";
if(matchedSelectors[ sel ]===undefined){
matchedSelectors[ sel ]=handleObj.needsContext ?
jQuery(sel, this).index(cur) > -1 :
jQuery.find(sel, this, null, [ cur ]).length;
}
if(matchedSelectors[ sel ]){
matchedHandlers.push(handleObj);
}}
if(matchedHandlers.length){
handlerQueue.push({ elem: cur, handlers: matchedHandlers });
}}
}}
cur=this;
if(delegateCount < handlers.length){
handlerQueue.push({ elem: cur, handlers: handlers.slice(delegateCount) });
}
return handlerQueue;
},
addProp: function(name, hook){
Object.defineProperty(jQuery.Event.prototype, name, {
enumerable: true,
configurable: true,
get: isFunction(hook) ?
function(){
if(this.originalEvent){
return hook(this.originalEvent);
}} :
function(){
if(this.originalEvent){
return this.originalEvent[ name ];
}},
set: function(value){
Object.defineProperty(this, name, {
enumerable: true,
configurable: true,
writable: true,
value: value
});
}});
},
fix: function(originalEvent){
return originalEvent[ jQuery.expando ] ?
originalEvent :
new jQuery.Event(originalEvent);
},
special: {
load: {
noBubble: true
},
click: {
setup: function(data){
var el=this||data;
if(rcheckableType.test(el.type) &&
el.click&&nodeName(el, "input")){
leverageNative(el, "click", true);
}
return false;
},
trigger: function(data){
var el=this||data;
if(rcheckableType.test(el.type) &&
el.click&&nodeName(el, "input")){
leverageNative(el, "click");
}
return true;
},
_default: function(event){
var target=event.target;
return rcheckableType.test(target.type) &&
target.click&&nodeName(target, "input") &&
dataPriv.get(target, "click") ||
nodeName(target, "a");
}},
beforeunload: {
postDispatch: function(event){
if(event.result!==undefined&&event.originalEvent){
event.originalEvent.returnValue=event.result;
}}
}}
};
function leverageNative(el, type, isSetup){
if(!isSetup){
if(dataPriv.get(el, type)===undefined){
jQuery.event.add(el, type, returnTrue);
}
return;
}
dataPriv.set(el, type, false);
jQuery.event.add(el, type, {
namespace: false,
handler: function(event){
var result,
saved=dataPriv.get(this, type);
if(( event.isTrigger & 1)&&this[ type ]){
if(!saved){
saved=slice.call(arguments);
dataPriv.set(this, type, saved);
this[ type ]();
result=dataPriv.get(this, type);
dataPriv.set(this, type, false);
if(saved!==result){
event.stopImmediatePropagation();
event.preventDefault();
return result;
}}else if(( jQuery.event.special[ type ]||{}).delegateType){
event.stopPropagation();
}}else if(saved){
dataPriv.set(this, type, jQuery.event.trigger(saved[ 0 ],
saved.slice(1),
this
));
event.stopPropagation();
event.isImmediatePropagationStopped=returnTrue;
}}
});
}
jQuery.removeEvent=function(elem, type, handle){
if(elem.removeEventListener){
elem.removeEventListener(type, handle);
}};
jQuery.Event=function(src, props){
if(!(this instanceof jQuery.Event)){
return new jQuery.Event(src, props);
}
if(src&&src.type){
this.originalEvent=src;
this.type=src.type;
this.isDefaultPrevented=src.defaultPrevented ||
src.defaultPrevented===undefined &&
src.returnValue===false ?
returnTrue :
returnFalse;
this.target=(src.target&&src.target.nodeType===3) ?
src.target.parentNode :
src.target;
this.currentTarget=src.currentTarget;
this.relatedTarget=src.relatedTarget;
}else{
this.type=src;
}
if(props){
jQuery.extend(this, props);
}
this.timeStamp=src&&src.timeStamp||Date.now();
this[ jQuery.expando ]=true;
};
jQuery.Event.prototype={
constructor: jQuery.Event,
isDefaultPrevented: returnFalse,
isPropagationStopped: returnFalse,
isImmediatePropagationStopped: returnFalse,
isSimulated: false,
preventDefault: function(){
var e=this.originalEvent;
this.isDefaultPrevented=returnTrue;
if(e&&!this.isSimulated){
e.preventDefault();
}},
stopPropagation: function(){
var e=this.originalEvent;
this.isPropagationStopped=returnTrue;
if(e&&!this.isSimulated){
e.stopPropagation();
}},
stopImmediatePropagation: function(){
var e=this.originalEvent;
this.isImmediatePropagationStopped=returnTrue;
if(e&&!this.isSimulated){
e.stopImmediatePropagation();
}
this.stopPropagation();
}};
jQuery.each({
altKey: true,
bubbles: true,
cancelable: true,
changedTouches: true,
ctrlKey: true,
detail: true,
eventPhase: true,
metaKey: true,
pageX: true,
pageY: true,
shiftKey: true,
view: true,
"char": true,
code: true,
charCode: true,
key: true,
keyCode: true,
button: true,
buttons: true,
clientX: true,
clientY: true,
offsetX: true,
offsetY: true,
pointerId: true,
pointerType: true,
screenX: true,
screenY: true,
targetTouches: true,
toElement: true,
touches: true,
which: true
}, jQuery.event.addProp);
jQuery.each({ focus: "focusin", blur: "focusout" }, function(type, delegateType){
function focusMappedHandler(nativeEvent){
if(document.documentMode){
var handle=dataPriv.get(this, "handle"),
event=jQuery.event.fix(nativeEvent);
event.type=nativeEvent.type==="focusin" ? "focus":"blur";
event.isSimulated=true;
handle(nativeEvent);
if(event.target===event.currentTarget){
handle(event);
}}else{
jQuery.event.simulate(delegateType, nativeEvent.target,
jQuery.event.fix(nativeEvent));
}}
jQuery.event.special[ type ]={
setup: function(){
var attaches;
leverageNative(this, type, true);
if(document.documentMode){
attaches=dataPriv.get(this, delegateType);
if(!attaches){
this.addEventListener(delegateType, focusMappedHandler);
}
dataPriv.set(this, delegateType,(attaches||0) + 1);
}else{
return false;
}},
trigger: function(){
leverageNative(this, type);
return true;
},
teardown: function(){
var attaches;
if(document.documentMode){
attaches=dataPriv.get(this, delegateType) - 1;
if(!attaches){
this.removeEventListener(delegateType, focusMappedHandler);
dataPriv.remove(this, delegateType);
}else{
dataPriv.set(this, delegateType, attaches);
}}else{
return false;
}},
_default: function(event){
return dataPriv.get(event.target, type);
},
delegateType: delegateType
};
jQuery.event.special[ delegateType ]={
setup: function(){
var doc=this.ownerDocument||this.document||this,
dataHolder=document.documentMode ? this:doc,
attaches=dataPriv.get(dataHolder, delegateType);
if(!attaches){
if(document.documentMode){
this.addEventListener(delegateType, focusMappedHandler);
}else{
doc.addEventListener(type, focusMappedHandler, true);
}}
dataPriv.set(dataHolder, delegateType,(attaches||0) + 1);
},
teardown: function(){
var doc=this.ownerDocument||this.document||this,
dataHolder=document.documentMode ? this:doc,
attaches=dataPriv.get(dataHolder, delegateType) - 1;
if(!attaches){
if(document.documentMode){
this.removeEventListener(delegateType, focusMappedHandler);
}else{
doc.removeEventListener(type, focusMappedHandler, true);
}
dataPriv.remove(dataHolder, delegateType);
}else{
dataPriv.set(dataHolder, delegateType, attaches);
}}
};});
jQuery.each({
mouseenter: "mouseover",
mouseleave: "mouseout",
pointerenter: "pointerover",
pointerleave: "pointerout"
}, function(orig, fix){
jQuery.event.special[ orig ]={
delegateType: fix,
bindType: fix,
handle: function(event){
var ret,
target=this,
related=event.relatedTarget,
handleObj=event.handleObj;
if(!related||(related!==target&&!jQuery.contains(target, related))){
event.type=handleObj.origType;
ret=handleObj.handler.apply(this, arguments);
event.type=fix;
}
return ret;
}};});
jQuery.fn.extend({
on: function(types, selector, data, fn){
return on(this, types, selector, data, fn);
},
one: function(types, selector, data, fn){
return on(this, types, selector, data, fn, 1);
},
off: function(types, selector, fn){
var handleObj, type;
if(types&&types.preventDefault&&types.handleObj){
handleObj=types.handleObj;
jQuery(types.delegateTarget).off(handleObj.namespace ?
handleObj.origType + "." + handleObj.namespace :
handleObj.origType,
handleObj.selector,
handleObj.handler
);
return this;
}
if(typeof types==="object"){
for(type in types){
this.off(type, selector, types[ type ]);
}
return this;
}
if(selector===false||typeof selector==="function"){
fn=selector;
selector=undefined;
}
if(fn===false){
fn=returnFalse;
}
return this.each(function(){
jQuery.event.remove(this, types, fn, selector);
});
}});
var
rnoInnerhtml=/<script|<style|<link/i,
rchecked=/checked\s*(?:[^=]|=\s*.checked.)/i,
rcleanScript=/^\s*<!\[CDATA\[|\]\]>\s*$/g;
function manipulationTarget(elem, content){
if(nodeName(elem, "table") &&
nodeName(content.nodeType!==11 ? content:content.firstChild, "tr")){
return jQuery(elem).children("tbody")[ 0 ]||elem;
}
return elem;
}
function disableScript(elem){
elem.type=(elem.getAttribute("type")!==null) + "/" + elem.type;
return elem;
}
function restoreScript(elem){
if(( elem.type||"").slice(0, 5)==="true/"){
elem.type=elem.type.slice(5);
}else{
elem.removeAttribute("type");
}
return elem;
}
function cloneCopyEvent(src, dest){
var i, l, type, pdataOld, udataOld, udataCur, events;
if(dest.nodeType!==1){
return;
}
if(dataPriv.hasData(src)){
pdataOld=dataPriv.get(src);
events=pdataOld.events;
if(events){
dataPriv.remove(dest, "handle events");
for(type in events){
for(i=0, l=events[ type ].length; i < l; i++){
jQuery.event.add(dest, type, events[ type ][ i ]);
}}
}}
if(dataUser.hasData(src)){
udataOld=dataUser.access(src);
udataCur=jQuery.extend({}, udataOld);
dataUser.set(dest, udataCur);
}}
function fixInput(src, dest){
var nodeName=dest.nodeName.toLowerCase();
if(nodeName==="input"&&rcheckableType.test(src.type)){
dest.checked=src.checked;
}else if(nodeName==="input"||nodeName==="textarea"){
dest.defaultValue=src.defaultValue;
}}
function domManip(collection, args, callback, ignored){
args=flat(args);
var fragment, first, scripts, hasScripts, node, doc,
i=0,
l=collection.length,
iNoClone=l - 1,
value=args[ 0 ],
valueIsFunction=isFunction(value);
if(valueIsFunction ||
(l > 1&&typeof value==="string" &&
!support.checkClone&&rchecked.test(value))){
return collection.each(function(index){
var self=collection.eq(index);
if(valueIsFunction){
args[ 0 ]=value.call(this, index, self.html());
}
domManip(self, args, callback, ignored);
});
}
if(l){
fragment=buildFragment(args, collection[ 0 ].ownerDocument, false, collection, ignored);
first=fragment.firstChild;
if(fragment.childNodes.length===1){
fragment=first;
}
if(first||ignored){
scripts=jQuery.map(getAll(fragment, "script"), disableScript);
hasScripts=scripts.length;
for(; i < l; i++){
node=fragment;
if(i!==iNoClone){
node=jQuery.clone(node, true, true);
if(hasScripts){
jQuery.merge(scripts, getAll(node, "script"));
}}
callback.call(collection[ i ], node, i);
}
if(hasScripts){
doc=scripts[ scripts.length - 1 ].ownerDocument;
jQuery.map(scripts, restoreScript);
for(i=0; i < hasScripts; i++){
node=scripts[ i ];
if(rscriptType.test(node.type||"") &&
!dataPriv.access(node, "globalEval") &&
jQuery.contains(doc, node)){
if(node.src&&(node.type||"").toLowerCase()!=="module"){
if(jQuery._evalUrl&&!node.noModule){
jQuery._evalUrl(node.src, {
nonce: node.nonce||node.getAttribute("nonce")
}, doc);
}}else{
DOMEval(node.textContent.replace(rcleanScript, ""), node, doc);
}}
}}
}}
return collection;
}
function remove(elem, selector, keepData){
var node,
nodes=selector ? jQuery.filter(selector, elem):elem,
i=0;
for(;(node=nodes[ i ])!=null; i++){
if(!keepData&&node.nodeType===1){
jQuery.cleanData(getAll(node));
}
if(node.parentNode){
if(keepData&&isAttached(node)){
setGlobalEval(getAll(node, "script"));
}
node.parentNode.removeChild(node);
}}
return elem;
}
jQuery.extend({
htmlPrefilter: function(html){
return html;
},
clone: function(elem, dataAndEvents, deepDataAndEvents){
var i, l, srcElements, destElements,
clone=elem.cloneNode(true),
inPage=isAttached(elem);
if(!support.noCloneChecked&&(elem.nodeType===1||elem.nodeType===11) &&
!jQuery.isXMLDoc(elem)){
destElements=getAll(clone);
srcElements=getAll(elem);
for(i=0, l=srcElements.length; i < l; i++){
fixInput(srcElements[ i ], destElements[ i ]);
}}
if(dataAndEvents){
if(deepDataAndEvents){
srcElements=srcElements||getAll(elem);
destElements=destElements||getAll(clone);
for(i=0, l=srcElements.length; i < l; i++){
cloneCopyEvent(srcElements[ i ], destElements[ i ]);
}}else{
cloneCopyEvent(elem, clone);
}}
destElements=getAll(clone, "script");
if(destElements.length > 0){
setGlobalEval(destElements, !inPage&&getAll(elem, "script"));
}
return clone;
},
cleanData: function(elems){
var data, elem, type,
special=jQuery.event.special,
i=0;
for(;(elem=elems[ i ])!==undefined; i++){
if(acceptData(elem)){
if(( data=elem[ dataPriv.expando ])){
if(data.events){
for(type in data.events){
if(special[ type ]){
jQuery.event.remove(elem, type);
}else{
jQuery.removeEvent(elem, type, data.handle);
}}
}
elem[ dataPriv.expando ]=undefined;
}
if(elem[ dataUser.expando ]){
elem[ dataUser.expando ]=undefined;
}}
}}
});
jQuery.fn.extend({
detach: function(selector){
return remove(this, selector, true);
},
remove: function(selector){
return remove(this, selector);
},
text: function(value){
return access(this, function(value){
return value===undefined ?
jQuery.text(this) :
this.empty().each(function(){
if(this.nodeType===1||this.nodeType===11||this.nodeType===9){
this.textContent=value;
}});
}, null, value, arguments.length);
},
append: function(){
return domManip(this, arguments, function(elem){
if(this.nodeType===1||this.nodeType===11||this.nodeType===9){
var target=manipulationTarget(this, elem);
target.appendChild(elem);
}});
},
prepend: function(){
return domManip(this, arguments, function(elem){
if(this.nodeType===1||this.nodeType===11||this.nodeType===9){
var target=manipulationTarget(this, elem);
target.insertBefore(elem, target.firstChild);
}});
},
before: function(){
return domManip(this, arguments, function(elem){
if(this.parentNode){
this.parentNode.insertBefore(elem, this);
}});
},
after: function(){
return domManip(this, arguments, function(elem){
if(this.parentNode){
this.parentNode.insertBefore(elem, this.nextSibling);
}});
},
empty: function(){
var elem,
i=0;
for(;(elem=this[ i ])!=null; i++){
if(elem.nodeType===1){
jQuery.cleanData(getAll(elem, false));
elem.textContent="";
}}
return this;
},
clone: function(dataAndEvents, deepDataAndEvents){
dataAndEvents=dataAndEvents==null ? false:dataAndEvents;
deepDataAndEvents=deepDataAndEvents==null ? dataAndEvents:deepDataAndEvents;
return this.map(function(){
return jQuery.clone(this, dataAndEvents, deepDataAndEvents);
});
},
html: function(value){
return access(this, function(value){
var elem=this[ 0 ]||{},
i=0,
l=this.length;
if(value===undefined&&elem.nodeType===1){
return elem.innerHTML;
}
if(typeof value==="string"&&!rnoInnerhtml.test(value) &&
!wrapMap[(rtagName.exec(value)||[ "", "" ])[ 1 ].toLowerCase() ]){
value=jQuery.htmlPrefilter(value);
try {
for(; i < l; i++){
elem=this[ i ]||{};
if(elem.nodeType===1){
jQuery.cleanData(getAll(elem, false));
elem.innerHTML=value;
}}
elem=0;
} catch(e){}}
if(elem){
this.empty().append(value);
}}, null, value, arguments.length);
},
replaceWith: function(){
var ignored=[];
return domManip(this, arguments, function(elem){
var parent=this.parentNode;
if(jQuery.inArray(this, ignored) < 0){
jQuery.cleanData(getAll(this));
if(parent){
parent.replaceChild(elem, this);
}}
}, ignored);
}});
jQuery.each({
appendTo: "append",
prependTo: "prepend",
insertBefore: "before",
insertAfter: "after",
replaceAll: "replaceWith"
}, function(name, original){
jQuery.fn[ name ]=function(selector){
var elems,
ret=[],
insert=jQuery(selector),
last=insert.length - 1,
i=0;
for(; i <=last; i++){
elems=i===last ? this:this.clone(true);
jQuery(insert[ i ])[ original ](elems);
push.apply(ret, elems.get());
}
return this.pushStack(ret);
};});
var rnumnonpx=new RegExp("^(" + pnum + ")(?!px)[a-z%]+$", "i");
var rcustomProp=/^--/;
var getStyles=function(elem){
var view=elem.ownerDocument.defaultView;
if(!view||!view.opener){
view=window;
}
return view.getComputedStyle(elem);
};
var swap=function(elem, options, callback){
var ret, name,
old={};
for(name in options){
old[ name ]=elem.style[ name ];
elem.style[ name ]=options[ name ];
}
ret=callback.call(elem);
for(name in options){
elem.style[ name ]=old[ name ];
}
return ret;
};
var rboxStyle=new RegExp(cssExpand.join("|"), "i");
(function(){
function computeStyleTests(){
if(!div){
return;
}
container.style.cssText="position:absolute;left:-11111px;width:60px;" +
"margin-top:1px;padding:0;border:0";
div.style.cssText =
"position:relative;display:block;box-sizing:border-box;overflow:scroll;" +
"margin:auto;border:1px;padding:1px;" +
"width:60%;top:1%";
documentElement.appendChild(container).appendChild(div);
var divStyle=window.getComputedStyle(div);
pixelPositionVal=divStyle.top!=="1%";
reliableMarginLeftVal=roundPixelMeasures(divStyle.marginLeft)===12;
div.style.right="60%";
pixelBoxStylesVal=roundPixelMeasures(divStyle.right)===36;
boxSizingReliableVal=roundPixelMeasures(divStyle.width)===36;
div.style.position="absolute";
scrollboxSizeVal=roundPixelMeasures(div.offsetWidth / 3)===12;
documentElement.removeChild(container);
div=null;
}
function roundPixelMeasures(measure){
return Math.round(parseFloat(measure));
}
var pixelPositionVal, boxSizingReliableVal, scrollboxSizeVal, pixelBoxStylesVal,
reliableTrDimensionsVal, reliableMarginLeftVal,
container=document.createElement("div"),
div=document.createElement("div");
if(!div.style){
return;
}
div.style.backgroundClip="content-box";
div.cloneNode(true).style.backgroundClip="";
support.clearCloneStyle=div.style.backgroundClip==="content-box";
jQuery.extend(support, {
boxSizingReliable: function(){
computeStyleTests();
return boxSizingReliableVal;
},
pixelBoxStyles: function(){
computeStyleTests();
return pixelBoxStylesVal;
},
pixelPosition: function(){
computeStyleTests();
return pixelPositionVal;
},
reliableMarginLeft: function(){
computeStyleTests();
return reliableMarginLeftVal;
},
scrollboxSize: function(){
computeStyleTests();
return scrollboxSizeVal;
},
reliableTrDimensions: function(){
var table, tr, trChild, trStyle;
if(reliableTrDimensionsVal==null){
table=document.createElement("table");
tr=document.createElement("tr");
trChild=document.createElement("div");
table.style.cssText="position:absolute;left:-11111px;border-collapse:separate";
tr.style.cssText="box-sizing:content-box;border:1px solid";
tr.style.height="1px";
trChild.style.height="9px";
trChild.style.display="block";
documentElement
.appendChild(table)
.appendChild(tr)
.appendChild(trChild);
trStyle=window.getComputedStyle(tr);
reliableTrDimensionsVal=(parseInt(trStyle.height, 10) +
parseInt(trStyle.borderTopWidth, 10) +
parseInt(trStyle.borderBottomWidth, 10))===tr.offsetHeight;
documentElement.removeChild(table);
}
return reliableTrDimensionsVal;
}});
})();
function curCSS(elem, name, computed){
var width, minWidth, maxWidth, ret,
isCustomProp=rcustomProp.test(name),
style=elem.style;
computed=computed||getStyles(elem);
if(computed){
ret=computed.getPropertyValue(name)||computed[ name ];
if(isCustomProp&&ret){
ret=ret.replace(rtrimCSS, "$1")||undefined;
}
if(ret===""&&!isAttached(elem)){
ret=jQuery.style(elem, name);
}
if(!support.pixelBoxStyles()&&rnumnonpx.test(ret)&&rboxStyle.test(name)){
width=style.width;
minWidth=style.minWidth;
maxWidth=style.maxWidth;
style.minWidth=style.maxWidth=style.width=ret;
ret=computed.width;
style.width=width;
style.minWidth=minWidth;
style.maxWidth=maxWidth;
}}
return ret!==undefined ?
ret + "" :
ret;
}
function addGetHookIf(conditionFn, hookFn){
return {
get: function(){
if(conditionFn()){
delete this.get;
return;
}
return(this.get=hookFn).apply(this, arguments);
}};}
var cssPrefixes=[ "Webkit", "Moz", "ms" ],
emptyStyle=document.createElement("div").style,
vendorProps={};
function vendorPropName(name){
var capName=name[ 0 ].toUpperCase() + name.slice(1),
i=cssPrefixes.length;
while(i--){
name=cssPrefixes[ i ] + capName;
if(name in emptyStyle){
return name;
}}
}
function finalPropName(name){
var final=jQuery.cssProps[ name ]||vendorProps[ name ];
if(final){
return final;
}
if(name in emptyStyle){
return name;
}
return vendorProps[ name ]=vendorPropName(name)||name;
}
var
rdisplayswap=/^(none|table(?!-c[ea]).+)/,
cssShow={ position: "absolute", visibility: "hidden", display: "block" },
cssNormalTransform={
letterSpacing: "0",
fontWeight: "400"
};
function setPositiveNumber(_elem, value, subtract){
var matches=rcssNum.exec(value);
return matches ?
Math.max(0, matches[ 2 ] -(subtract||0)) +(matches[ 3 ]||"px") :
value;
}
function boxModelAdjustment(elem, dimension, box, isBorderBox, styles, computedVal){
var i=dimension==="width" ? 1:0,
extra=0,
delta=0,
marginDelta=0;
if(box===(isBorderBox ? "border":"content")){
return 0;
}
for(; i < 4; i +=2){
if(box==="margin"){
marginDelta +=jQuery.css(elem, box + cssExpand[ i ], true, styles);
}
if(!isBorderBox){
delta +=jQuery.css(elem, "padding" + cssExpand[ i ], true, styles);
if(box!=="padding"){
delta +=jQuery.css(elem, "border" + cssExpand[ i ] + "Width", true, styles);
}else{
extra +=jQuery.css(elem, "border" + cssExpand[ i ] + "Width", true, styles);
}}else{
if(box==="content"){
delta -=jQuery.css(elem, "padding" + cssExpand[ i ], true, styles);
}
if(box!=="margin"){
delta -=jQuery.css(elem, "border" + cssExpand[ i ] + "Width", true, styles);
}}
}
if(!isBorderBox&&computedVal >=0){
delta +=Math.max(0, Math.ceil(elem[ "offset" + dimension[ 0 ].toUpperCase() + dimension.slice(1) ] -
computedVal -
delta -
extra -
0.5
))||0;
}
return delta + marginDelta;
}
function getWidthOrHeight(elem, dimension, extra){
var styles=getStyles(elem),
boxSizingNeeded = !support.boxSizingReliable()||extra,
isBorderBox=boxSizingNeeded &&
jQuery.css(elem, "boxSizing", false, styles)==="border-box",
valueIsBorderBox=isBorderBox,
val=curCSS(elem, dimension, styles),
offsetProp="offset" + dimension[ 0 ].toUpperCase() + dimension.slice(1);
if(rnumnonpx.test(val)){
if(!extra){
return val;
}
val="auto";
}
if(( !support.boxSizingReliable()&&isBorderBox ||
!support.reliableTrDimensions()&&nodeName(elem, "tr") ||
val==="auto" ||
!parseFloat(val)&&jQuery.css(elem, "display", false, styles)==="inline") &&
elem.getClientRects().length){
isBorderBox=jQuery.css(elem, "boxSizing", false, styles)==="border-box";
valueIsBorderBox=offsetProp in elem;
if(valueIsBorderBox){
val=elem[ offsetProp ];
}}
val=parseFloat(val)||0;
return(val +
boxModelAdjustment(
elem,
dimension,
extra||(isBorderBox ? "border":"content"),
valueIsBorderBox,
styles,
val
)
) + "px";
}
jQuery.extend({
cssHooks: {
opacity: {
get: function(elem, computed){
if(computed){
var ret=curCSS(elem, "opacity");
return ret==="" ? "1":ret;
}}
}},
cssNumber: {
animationIterationCount: true,
aspectRatio: true,
borderImageSlice: true,
columnCount: true,
flexGrow: true,
flexShrink: true,
fontWeight: true,
gridArea: true,
gridColumn: true,
gridColumnEnd: true,
gridColumnStart: true,
gridRow: true,
gridRowEnd: true,
gridRowStart: true,
lineHeight: true,
opacity: true,
order: true,
orphans: true,
scale: true,
widows: true,
zIndex: true,
zoom: true,
fillOpacity: true,
floodOpacity: true,
stopOpacity: true,
strokeMiterlimit: true,
strokeOpacity: true
},
cssProps: {},
style: function(elem, name, value, extra){
if(!elem||elem.nodeType===3||elem.nodeType===8||!elem.style){
return;
}
var ret, type, hooks,
origName=camelCase(name),
isCustomProp=rcustomProp.test(name),
style=elem.style;
if(!isCustomProp){
name=finalPropName(origName);
}
hooks=jQuery.cssHooks[ name ]||jQuery.cssHooks[ origName ];
if(value!==undefined){
type=typeof value;
if(type==="string"&&(ret=rcssNum.exec(value))&&ret[ 1 ]){
value=adjustCSS(elem, name, ret);
type="number";
}
if(value==null||value!==value){
return;
}
if(type==="number"&&!isCustomProp){
value +=ret&&ret[ 3 ]||(jQuery.cssNumber[ origName ] ? "":"px");
}
if(!support.clearCloneStyle&&value===""&&name.indexOf("background")===0){
style[ name ]="inherit";
}
if(!hooks||!("set" in hooks) ||
(value=hooks.set(elem, value, extra))!==undefined){
if(isCustomProp){
style.setProperty(name, value);
}else{
style[ name ]=value;
}}
}else{
if(hooks&&"get" in hooks &&
(ret=hooks.get(elem, false, extra))!==undefined){
return ret;
}
return style[ name ];
}},
css: function(elem, name, extra, styles){
var val, num, hooks,
origName=camelCase(name),
isCustomProp=rcustomProp.test(name);
if(!isCustomProp){
name=finalPropName(origName);
}
hooks=jQuery.cssHooks[ name ]||jQuery.cssHooks[ origName ];
if(hooks&&"get" in hooks){
val=hooks.get(elem, true, extra);
}
if(val===undefined){
val=curCSS(elem, name, styles);
}
if(val==="normal"&&name in cssNormalTransform){
val=cssNormalTransform[ name ];
}
if(extra===""||extra){
num=parseFloat(val);
return extra===true||isFinite(num) ? num||0:val;
}
return val;
}});
jQuery.each([ "height", "width" ], function(_i, dimension){
jQuery.cssHooks[ dimension ]={
get: function(elem, computed, extra){
if(computed){
return rdisplayswap.test(jQuery.css(elem, "display")) &&
(!elem.getClientRects().length||!elem.getBoundingClientRect().width) ?
swap(elem, cssShow, function(){
return getWidthOrHeight(elem, dimension, extra);
}) :
getWidthOrHeight(elem, dimension, extra);
}},
set: function(elem, value, extra){
var matches,
styles=getStyles(elem),
scrollboxSizeBuggy = !support.scrollboxSize() &&
styles.position==="absolute",
boxSizingNeeded=scrollboxSizeBuggy||extra,
isBorderBox=boxSizingNeeded &&
jQuery.css(elem, "boxSizing", false, styles)==="border-box",
subtract=extra ?
boxModelAdjustment(
elem,
dimension,
extra,
isBorderBox,
styles
) :
0;
if(isBorderBox&&scrollboxSizeBuggy){
subtract -=Math.ceil(elem[ "offset" + dimension[ 0 ].toUpperCase() + dimension.slice(1) ] -
parseFloat(styles[ dimension ]) -
boxModelAdjustment(elem, dimension, "border", false, styles) -
0.5
);
}
if(subtract&&(matches=rcssNum.exec(value)) &&
(matches[ 3 ]||"px")!=="px"){
elem.style[ dimension ]=value;
value=jQuery.css(elem, dimension);
}
return setPositiveNumber(elem, value, subtract);
}};});
jQuery.cssHooks.marginLeft=addGetHookIf(support.reliableMarginLeft,
function(elem, computed){
if(computed){
return(parseFloat(curCSS(elem, "marginLeft")) ||
elem.getBoundingClientRect().left -
swap(elem, { marginLeft: 0 }, function(){
return elem.getBoundingClientRect().left;
})
) + "px";
}}
);
jQuery.each({
margin: "",
padding: "",
border: "Width"
}, function(prefix, suffix){
jQuery.cssHooks[ prefix + suffix ]={
expand: function(value){
var i=0,
expanded={},
parts=typeof value==="string" ? value.split(" "):[ value ];
for(; i < 4; i++){
expanded[ prefix + cssExpand[ i ] + suffix ] =
parts[ i ]||parts[ i - 2 ]||parts[ 0 ];
}
return expanded;
}};
if(prefix!=="margin"){
jQuery.cssHooks[ prefix + suffix ].set=setPositiveNumber;
}});
jQuery.fn.extend({
css: function(name, value){
return access(this, function(elem, name, value){
var styles, len,
map={},
i=0;
if(Array.isArray(name)){
styles=getStyles(elem);
len=name.length;
for(; i < len; i++){
map[ name[ i ] ]=jQuery.css(elem, name[ i ], false, styles);
}
return map;
}
return value!==undefined ?
jQuery.style(elem, name, value) :
jQuery.css(elem, name);
}, name, value, arguments.length > 1);
}});
function Tween(elem, options, prop, end, easing){
return new Tween.prototype.init(elem, options, prop, end, easing);
}
jQuery.Tween=Tween;
Tween.prototype={
constructor: Tween,
init: function(elem, options, prop, end, easing, unit){
this.elem=elem;
this.prop=prop;
this.easing=easing||jQuery.easing._default;
this.options=options;
this.start=this.now=this.cur();
this.end=end;
this.unit=unit||(jQuery.cssNumber[ prop ] ? "":"px");
},
cur: function(){
var hooks=Tween.propHooks[ this.prop ];
return hooks&&hooks.get ?
hooks.get(this) :
Tween.propHooks._default.get(this);
},
run: function(percent){
var eased,
hooks=Tween.propHooks[ this.prop ];
if(this.options.duration){
this.pos=eased=jQuery.easing[ this.easing ](
percent, this.options.duration * percent, 0, 1, this.options.duration
);
}else{
this.pos=eased=percent;
}
this.now=(this.end - this.start) * eased + this.start;
if(this.options.step){
this.options.step.call(this.elem, this.now, this);
}
if(hooks&&hooks.set){
hooks.set(this);
}else{
Tween.propHooks._default.set(this);
}
return this;
}};
Tween.prototype.init.prototype=Tween.prototype;
Tween.propHooks={
_default: {
get: function(tween){
var result;
if(tween.elem.nodeType!==1 ||
tween.elem[ tween.prop ]!=null&&tween.elem.style[ tween.prop ]==null){
return tween.elem[ tween.prop ];
}
result=jQuery.css(tween.elem, tween.prop, "");
return !result||result==="auto" ? 0:result;
},
set: function(tween){
if(jQuery.fx.step[ tween.prop ]){
jQuery.fx.step[ tween.prop ](tween);
}else if(tween.elem.nodeType===1&&(
jQuery.cssHooks[ tween.prop ] ||
tween.elem.style[ finalPropName(tween.prop) ]!=null)){
jQuery.style(tween.elem, tween.prop, tween.now + tween.unit);
}else{
tween.elem[ tween.prop ]=tween.now;
}}
}};
Tween.propHooks.scrollTop=Tween.propHooks.scrollLeft={
set: function(tween){
if(tween.elem.nodeType&&tween.elem.parentNode){
tween.elem[ tween.prop ]=tween.now;
}}
};
jQuery.easing={
linear: function(p){
return p;
},
swing: function(p){
return 0.5 - Math.cos(p * Math.PI) / 2;
},
_default: "swing"
};
jQuery.fx=Tween.prototype.init;
jQuery.fx.step={};
var
fxNow, inProgress,
rfxtypes=/^(?:toggle|show|hide)$/,
rrun=/queueHooks$/;
function schedule(){
if(inProgress){
if(document.hidden===false&&window.requestAnimationFrame){
window.requestAnimationFrame(schedule);
}else{
window.setTimeout(schedule, jQuery.fx.interval);
}
jQuery.fx.tick();
}}
function createFxNow(){
window.setTimeout(function(){
fxNow=undefined;
});
return(fxNow=Date.now());
}
function genFx(type, includeWidth){
var which,
i=0,
attrs={ height: type };
includeWidth=includeWidth ? 1:0;
for(; i < 4; i +=2 - includeWidth){
which=cssExpand[ i ];
attrs[ "margin" + which ]=attrs[ "padding" + which ]=type;
}
if(includeWidth){
attrs.opacity=attrs.width=type;
}
return attrs;
}
function createTween(value, prop, animation){
var tween,
collection=(Animation.tweeners[ prop ]||[]).concat(Animation.tweeners[ "*" ]),
index=0,
length=collection.length;
for(; index < length; index++){
if(( tween=collection[ index ].call(animation, prop, value))){
return tween;
}}
}
function defaultPrefilter(elem, props, opts){
var prop, value, toggle, hooks, oldfire, propTween, restoreDisplay, display,
isBox="width" in props||"height" in props,
anim=this,
orig={},
style=elem.style,
hidden=elem.nodeType&&isHiddenWithinTree(elem),
dataShow=dataPriv.get(elem, "fxshow");
if(!opts.queue){
hooks=jQuery._queueHooks(elem, "fx");
if(hooks.unqueued==null){
hooks.unqueued=0;
oldfire=hooks.empty.fire;
hooks.empty.fire=function(){
if(!hooks.unqueued){
oldfire();
}};}
hooks.unqueued++;
anim.always(function(){
anim.always(function(){
hooks.unqueued--;
if(!jQuery.queue(elem, "fx").length){
hooks.empty.fire();
}});
});
}
for(prop in props){
value=props[ prop ];
if(rfxtypes.test(value)){
delete props[ prop ];
toggle=toggle||value==="toggle";
if(value===(hidden ? "hide":"show")){
if(value==="show"&&dataShow&&dataShow[ prop ]!==undefined){
hidden=true;
}else{
continue;
}}
orig[ prop ]=dataShow&&dataShow[ prop ]||jQuery.style(elem, prop);
}}
propTween = !jQuery.isEmptyObject(props);
if(!propTween&&jQuery.isEmptyObject(orig)){
return;
}
if(isBox&&elem.nodeType===1){
opts.overflow=[ style.overflow, style.overflowX, style.overflowY ];
restoreDisplay=dataShow&&dataShow.display;
if(restoreDisplay==null){
restoreDisplay=dataPriv.get(elem, "display");
}
display=jQuery.css(elem, "display");
if(display==="none"){
if(restoreDisplay){
display=restoreDisplay;
}else{
showHide([ elem ], true);
restoreDisplay=elem.style.display||restoreDisplay;
display=jQuery.css(elem, "display");
showHide([ elem ]);
}}
if(display==="inline"||display==="inline-block"&&restoreDisplay!=null){
if(jQuery.css(elem, "float")==="none"){
if(!propTween){
anim.done(function(){
style.display=restoreDisplay;
});
if(restoreDisplay==null){
display=style.display;
restoreDisplay=display==="none" ? "":display;
}}
style.display="inline-block";
}}
}
if(opts.overflow){
style.overflow="hidden";
anim.always(function(){
style.overflow=opts.overflow[ 0 ];
style.overflowX=opts.overflow[ 1 ];
style.overflowY=opts.overflow[ 2 ];
});
}
propTween=false;
for(prop in orig){
if(!propTween){
if(dataShow){
if("hidden" in dataShow){
hidden=dataShow.hidden;
}}else{
dataShow=dataPriv.access(elem, "fxshow", { display: restoreDisplay });
}
if(toggle){
dataShow.hidden = !hidden;
}
if(hidden){
showHide([ elem ], true);
}
anim.done(function(){
if(!hidden){
showHide([ elem ]);
}
dataPriv.remove(elem, "fxshow");
for(prop in orig){
jQuery.style(elem, prop, orig[ prop ]);
}});
}
propTween=createTween(hidden ? dataShow[ prop ]:0, prop, anim);
if(!(prop in dataShow)){
dataShow[ prop ]=propTween.start;
if(hidden){
propTween.end=propTween.start;
propTween.start=0;
}}
}}
function propFilter(props, specialEasing){
var index, name, easing, value, hooks;
for(index in props){
name=camelCase(index);
easing=specialEasing[ name ];
value=props[ index ];
if(Array.isArray(value)){
easing=value[ 1 ];
value=props[ index ]=value[ 0 ];
}
if(index!==name){
props[ name ]=value;
delete props[ index ];
}
hooks=jQuery.cssHooks[ name ];
if(hooks&&"expand" in hooks){
value=hooks.expand (value);
delete props[ name ];
for(index in value){
if(!(index in props)){
props[ index ]=value[ index ];
specialEasing[ index ]=easing;
}}
}else{
specialEasing[ name ]=easing;
}}
}
function Animation(elem, properties, options){
var result,
stopped,
index=0,
length=Animation.prefilters.length,
deferred=jQuery.Deferred().always(function(){
delete tick.elem;
}),
tick=function(){
if(stopped){
return false;
}
var currentTime=fxNow||createFxNow(),
remaining=Math.max(0, animation.startTime + animation.duration - currentTime),
temp=remaining / animation.duration||0,
percent=1 - temp,
index=0,
length=animation.tweens.length;
for(; index < length; index++){
animation.tweens[ index ].run(percent);
}
deferred.notifyWith(elem, [ animation, percent, remaining ]);
if(percent < 1&&length){
return remaining;
}
if(!length){
deferred.notifyWith(elem, [ animation, 1, 0 ]);
}
deferred.resolveWith(elem, [ animation ]);
return false;
},
animation=deferred.promise({
elem: elem,
props: jQuery.extend({}, properties),
opts: jQuery.extend(true, {
specialEasing: {},
easing: jQuery.easing._default
}, options),
originalProperties: properties,
originalOptions: options,
startTime: fxNow||createFxNow(),
duration: options.duration,
tweens: [],
createTween: function(prop, end){
var tween=jQuery.Tween(elem, animation.opts, prop, end,
animation.opts.specialEasing[ prop ]||animation.opts.easing);
animation.tweens.push(tween);
return tween;
},
stop: function(gotoEnd){
var index=0,
length=gotoEnd ? animation.tweens.length:0;
if(stopped){
return this;
}
stopped=true;
for(; index < length; index++){
animation.tweens[ index ].run(1);
}
if(gotoEnd){
deferred.notifyWith(elem, [ animation, 1, 0 ]);
deferred.resolveWith(elem, [ animation, gotoEnd ]);
}else{
deferred.rejectWith(elem, [ animation, gotoEnd ]);
}
return this;
}}),
props=animation.props;
propFilter(props, animation.opts.specialEasing);
for(; index < length; index++){
result=Animation.prefilters[ index ].call(animation, elem, props, animation.opts);
if(result){
if(isFunction(result.stop)){
jQuery._queueHooks(animation.elem, animation.opts.queue).stop =
result.stop.bind(result);
}
return result;
}}
jQuery.map(props, createTween, animation);
if(isFunction(animation.opts.start)){
animation.opts.start.call(elem, animation);
}
animation
.progress(animation.opts.progress)
.done(animation.opts.done, animation.opts.complete)
.fail(animation.opts.fail)
.always(animation.opts.always);
jQuery.fx.timer(jQuery.extend(tick, {
elem: elem,
anim: animation,
queue: animation.opts.queue
})
);
return animation;
}
jQuery.Animation=jQuery.extend(Animation, {
tweeners: {
"*": [ function(prop, value){
var tween=this.createTween(prop, value);
adjustCSS(tween.elem, prop, rcssNum.exec(value), tween);
return tween;
} ]
},
tweener: function(props, callback){
if(isFunction(props)){
callback=props;
props=[ "*" ];
}else{
props=props.match(rnothtmlwhite);
}
var prop,
index=0,
length=props.length;
for(; index < length; index++){
prop=props[ index ];
Animation.tweeners[ prop ]=Animation.tweeners[ prop ]||[];
Animation.tweeners[ prop ].unshift(callback);
}},
prefilters: [ defaultPrefilter ],
prefilter: function(callback, prepend){
if(prepend){
Animation.prefilters.unshift(callback);
}else{
Animation.prefilters.push(callback);
}}
});
jQuery.speed=function(speed, easing, fn){
var opt=speed&&typeof speed==="object" ? jQuery.extend({}, speed):{
complete: fn||!fn&&easing ||
isFunction(speed)&&speed,
duration: speed,
easing: fn&&easing||easing&&!isFunction(easing)&&easing
};
if(jQuery.fx.off){
opt.duration=0;
}else{
if(typeof opt.duration!=="number"){
if(opt.duration in jQuery.fx.speeds){
opt.duration=jQuery.fx.speeds[ opt.duration ];
}else{
opt.duration=jQuery.fx.speeds._default;
}}
}
if(opt.queue==null||opt.queue===true){
opt.queue="fx";
}
opt.old=opt.complete;
opt.complete=function(){
if(isFunction(opt.old)){
opt.old.call(this);
}
if(opt.queue){
jQuery.dequeue(this, opt.queue);
}};
return opt;
};
jQuery.fn.extend({
fadeTo: function(speed, to, easing, callback){
return this.filter(isHiddenWithinTree).css("opacity", 0).show()
.end().animate({ opacity: to }, speed, easing, callback);
},
animate: function(prop, speed, easing, callback){
var empty=jQuery.isEmptyObject(prop),
optall=jQuery.speed(speed, easing, callback),
doAnimation=function(){
var anim=Animation(this, jQuery.extend({}, prop), optall);
if(empty||dataPriv.get(this, "finish")){
anim.stop(true);
}};
doAnimation.finish=doAnimation;
return empty||optall.queue===false ?
this.each(doAnimation) :
this.queue(optall.queue, doAnimation);
},
stop: function(type, clearQueue, gotoEnd){
var stopQueue=function(hooks){
var stop=hooks.stop;
delete hooks.stop;
stop(gotoEnd);
};
if(typeof type!=="string"){
gotoEnd=clearQueue;
clearQueue=type;
type=undefined;
}
if(clearQueue){
this.queue(type||"fx", []);
}
return this.each(function(){
var dequeue=true,
index=type!=null&&type + "queueHooks",
timers=jQuery.timers,
data=dataPriv.get(this);
if(index){
if(data[ index ]&&data[ index ].stop){
stopQueue(data[ index ]);
}}else{
for(index in data){
if(data[ index ]&&data[ index ].stop&&rrun.test(index)){
stopQueue(data[ index ]);
}}
}
for(index=timers.length; index--;){
if(timers[ index ].elem===this &&
(type==null||timers[ index ].queue===type)){
timers[ index ].anim.stop(gotoEnd);
dequeue=false;
timers.splice(index, 1);
}}
if(dequeue||!gotoEnd){
jQuery.dequeue(this, type);
}});
},
finish: function(type){
if(type!==false){
type=type||"fx";
}
return this.each(function(){
var index,
data=dataPriv.get(this),
queue=data[ type + "queue" ],
hooks=data[ type + "queueHooks" ],
timers=jQuery.timers,
length=queue ? queue.length:0;
data.finish=true;
jQuery.queue(this, type, []);
if(hooks&&hooks.stop){
hooks.stop.call(this, true);
}
for(index=timers.length; index--;){
if(timers[ index ].elem===this&&timers[ index ].queue===type){
timers[ index ].anim.stop(true);
timers.splice(index, 1);
}}
for(index=0; index < length; index++){
if(queue[ index ]&&queue[ index ].finish){
queue[ index ].finish.call(this);
}}
delete data.finish;
});
}});
jQuery.each([ "toggle", "show", "hide" ], function(_i, name){
var cssFn=jQuery.fn[ name ];
jQuery.fn[ name ]=function(speed, easing, callback){
return speed==null||typeof speed==="boolean" ?
cssFn.apply(this, arguments) :
this.animate(genFx(name, true), speed, easing, callback);
};});
jQuery.each({
slideDown: genFx("show"),
slideUp: genFx("hide"),
slideToggle: genFx("toggle"),
fadeIn: { opacity: "show" },
fadeOut: { opacity: "hide" },
fadeToggle: { opacity: "toggle" }}, function(name, props){
jQuery.fn[ name ]=function(speed, easing, callback){
return this.animate(props, speed, easing, callback);
};});
jQuery.timers=[];
jQuery.fx.tick=function(){
var timer,
i=0,
timers=jQuery.timers;
fxNow=Date.now();
for(; i < timers.length; i++){
timer=timers[ i ];
if(!timer()&&timers[ i ]===timer){
timers.splice(i--, 1);
}}
if(!timers.length){
jQuery.fx.stop();
}
fxNow=undefined;
};
jQuery.fx.timer=function(timer){
jQuery.timers.push(timer);
jQuery.fx.start();
};
jQuery.fx.interval=13;
jQuery.fx.start=function(){
if(inProgress){
return;
}
inProgress=true;
schedule();
};
jQuery.fx.stop=function(){
inProgress=null;
};
jQuery.fx.speeds={
slow: 600,
fast: 200,
_default: 400
};
jQuery.fn.delay=function(time, type){
time=jQuery.fx ? jQuery.fx.speeds[ time ]||time:time;
type=type||"fx";
return this.queue(type, function(next, hooks){
var timeout=window.setTimeout(next, time);
hooks.stop=function(){
window.clearTimeout(timeout);
};});
};
(function(){
var input=document.createElement("input"),
select=document.createElement("select"),
opt=select.appendChild(document.createElement("option"));
input.type="checkbox";
support.checkOn=input.value!=="";
support.optSelected=opt.selected;
input=document.createElement("input");
input.value="t";
input.type="radio";
support.radioValue=input.value==="t";
})();
var boolHook,
attrHandle=jQuery.expr.attrHandle;
jQuery.fn.extend({
attr: function(name, value){
return access(this, jQuery.attr, name, value, arguments.length > 1);
},
removeAttr: function(name){
return this.each(function(){
jQuery.removeAttr(this, name);
});
}});
jQuery.extend({
attr: function(elem, name, value){
var ret, hooks,
nType=elem.nodeType;
if(nType===3||nType===8||nType===2){
return;
}
if(typeof elem.getAttribute==="undefined"){
return jQuery.prop(elem, name, value);
}
if(nType!==1||!jQuery.isXMLDoc(elem)){
hooks=jQuery.attrHooks[ name.toLowerCase() ] ||
(jQuery.expr.match.bool.test(name) ? boolHook:undefined);
}
if(value!==undefined){
if(value===null){
jQuery.removeAttr(elem, name);
return;
}
if(hooks&&"set" in hooks &&
(ret=hooks.set(elem, value, name))!==undefined){
return ret;
}
elem.setAttribute(name, value + "");
return value;
}
if(hooks&&"get" in hooks&&(ret=hooks.get(elem, name))!==null){
return ret;
}
ret=jQuery.find.attr(elem, name);
return ret==null ? undefined:ret;
},
attrHooks: {
type: {
set: function(elem, value){
if(!support.radioValue&&value==="radio" &&
nodeName(elem, "input")){
var val=elem.value;
elem.setAttribute("type", value);
if(val){
elem.value=val;
}
return value;
}}
}},
removeAttr: function(elem, value){
var name,
i=0,
attrNames=value&&value.match(rnothtmlwhite);
if(attrNames&&elem.nodeType===1){
while(( name=attrNames[ i++ ])){
elem.removeAttribute(name);
}}
}});
boolHook={
set: function(elem, value, name){
if(value===false){
jQuery.removeAttr(elem, name);
}else{
elem.setAttribute(name, name);
}
return name;
}};
jQuery.each(jQuery.expr.match.bool.source.match(/\w+/g), function(_i, name){
var getter=attrHandle[ name ]||jQuery.find.attr;
attrHandle[ name ]=function(elem, name, isXML){
var ret, handle,
lowercaseName=name.toLowerCase();
if(!isXML){
handle=attrHandle[ lowercaseName ];
attrHandle[ lowercaseName ]=ret;
ret=getter(elem, name, isXML)!=null ?
lowercaseName :
null;
attrHandle[ lowercaseName ]=handle;
}
return ret;
};});
var rfocusable=/^(?:input|select|textarea|button)$/i,
rclickable=/^(?:a|area)$/i;
jQuery.fn.extend({
prop: function(name, value){
return access(this, jQuery.prop, name, value, arguments.length > 1);
},
removeProp: function(name){
return this.each(function(){
delete this[ jQuery.propFix[ name ]||name ];
});
}});
jQuery.extend({
prop: function(elem, name, value){
var ret, hooks,
nType=elem.nodeType;
if(nType===3||nType===8||nType===2){
return;
}
if(nType!==1||!jQuery.isXMLDoc(elem)){
name=jQuery.propFix[ name ]||name;
hooks=jQuery.propHooks[ name ];
}
if(value!==undefined){
if(hooks&&"set" in hooks &&
(ret=hooks.set(elem, value, name))!==undefined){
return ret;
}
return(elem[ name ]=value);
}
if(hooks&&"get" in hooks&&(ret=hooks.get(elem, name))!==null){
return ret;
}
return elem[ name ];
},
propHooks: {
tabIndex: {
get: function(elem){
var tabindex=jQuery.find.attr(elem, "tabindex");
if(tabindex){
return parseInt(tabindex, 10);
}
if(rfocusable.test(elem.nodeName) ||
rclickable.test(elem.nodeName) &&
elem.href
){
return 0;
}
return -1;
}}
},
propFix: {
"for": "htmlFor",
"class": "className"
}});
if(!support.optSelected){
jQuery.propHooks.selected={
get: function(elem){
var parent=elem.parentNode;
if(parent&&parent.parentNode){
parent.parentNode.selectedIndex;
}
return null;
},
set: function(elem){
var parent=elem.parentNode;
if(parent){
parent.selectedIndex;
if(parent.parentNode){
parent.parentNode.selectedIndex;
}}
}};}
jQuery.each([
"tabIndex",
"readOnly",
"maxLength",
"cellSpacing",
"cellPadding",
"rowSpan",
"colSpan",
"useMap",
"frameBorder",
"contentEditable"
], function(){
jQuery.propFix[ this.toLowerCase() ]=this;
});
function stripAndCollapse(value){
var tokens=value.match(rnothtmlwhite)||[];
return tokens.join(" ");
}
function getClass(elem){
return elem.getAttribute&&elem.getAttribute("class")||"";
}
function classesToArray(value){
if(Array.isArray(value)){
return value;
}
if(typeof value==="string"){
return value.match(rnothtmlwhite)||[];
}
return [];
}
jQuery.fn.extend({
addClass: function(value){
var classNames, cur, curValue, className, i, finalValue;
if(isFunction(value)){
return this.each(function(j){
jQuery(this).addClass(value.call(this, j, getClass(this)));
});
}
classNames=classesToArray(value);
if(classNames.length){
return this.each(function(){
curValue=getClass(this);
cur=this.nodeType===1&&(" " + stripAndCollapse(curValue) + " ");
if(cur){
for(i=0; i < classNames.length; i++){
className=classNames[ i ];
if(cur.indexOf(" " + className + " ") < 0){
cur +=className + " ";
}}
finalValue=stripAndCollapse(cur);
if(curValue!==finalValue){
this.setAttribute("class", finalValue);
}}
});
}
return this;
},
removeClass: function(value){
var classNames, cur, curValue, className, i, finalValue;
if(isFunction(value)){
return this.each(function(j){
jQuery(this).removeClass(value.call(this, j, getClass(this)));
});
}
if(!arguments.length){
return this.attr("class", "");
}
classNames=classesToArray(value);
if(classNames.length){
return this.each(function(){
curValue=getClass(this);
cur=this.nodeType===1&&(" " + stripAndCollapse(curValue) + " ");
if(cur){
for(i=0; i < classNames.length; i++){
className=classNames[ i ];
while(cur.indexOf(" " + className + " ") > -1){
cur=cur.replace(" " + className + " ", " ");
}}
finalValue=stripAndCollapse(cur);
if(curValue!==finalValue){
this.setAttribute("class", finalValue);
}}
});
}
return this;
},
toggleClass: function(value, stateVal){
var classNames, className, i, self,
type=typeof value,
isValidValue=type==="string"||Array.isArray(value);
if(isFunction(value)){
return this.each(function(i){
jQuery(this).toggleClass(value.call(this, i, getClass(this), stateVal),
stateVal
);
});
}
if(typeof stateVal==="boolean"&&isValidValue){
return stateVal ? this.addClass(value):this.removeClass(value);
}
classNames=classesToArray(value);
return this.each(function(){
if(isValidValue){
self=jQuery(this);
for(i=0; i < classNames.length; i++){
className=classNames[ i ];
if(self.hasClass(className)){
self.removeClass(className);
}else{
self.addClass(className);
}}
}else if(value===undefined||type==="boolean"){
className=getClass(this);
if(className){
dataPriv.set(this, "__className__", className);
}
if(this.setAttribute){
this.setAttribute("class",
className||value===false ?
"" :
dataPriv.get(this, "__className__")||""
);
}}
});
},
hasClass: function(selector){
var className, elem,
i=0;
className=" " + selector + " ";
while(( elem=this[ i++ ])){
if(elem.nodeType===1 &&
(" " + stripAndCollapse(getClass(elem)) + " ").indexOf(className) > -1){
return true;
}}
return false;
}});
var rreturn=/\r/g;
jQuery.fn.extend({
val: function(value){
var hooks, ret, valueIsFunction,
elem=this[ 0 ];
if(!arguments.length){
if(elem){
hooks=jQuery.valHooks[ elem.type ] ||
jQuery.valHooks[ elem.nodeName.toLowerCase() ];
if(hooks &&
"get" in hooks &&
(ret=hooks.get(elem, "value"))!==undefined
){
return ret;
}
ret=elem.value;
if(typeof ret==="string"){
return ret.replace(rreturn, "");
}
return ret==null ? "":ret;
}
return;
}
valueIsFunction=isFunction(value);
return this.each(function(i){
var val;
if(this.nodeType!==1){
return;
}
if(valueIsFunction){
val=value.call(this, i, jQuery(this).val());
}else{
val=value;
}
if(val==null){
val="";
}else if(typeof val==="number"){
val +="";
}else if(Array.isArray(val)){
val=jQuery.map(val, function(value){
return value==null ? "":value + "";
});
}
hooks=jQuery.valHooks[ this.type ]||jQuery.valHooks[ this.nodeName.toLowerCase() ];
if(!hooks||!("set" in hooks)||hooks.set(this, val, "value")===undefined){
this.value=val;
}});
}});
jQuery.extend({
valHooks: {
option: {
get: function(elem){
var val=jQuery.find.attr(elem, "value");
return val!=null ?
val :
stripAndCollapse(jQuery.text(elem));
}},
select: {
get: function(elem){
var value, option, i,
options=elem.options,
index=elem.selectedIndex,
one=elem.type==="select-one",
values=one ? null:[],
max=one ? index + 1:options.length;
if(index < 0){
i=max;
}else{
i=one ? index:0;
}
for(; i < max; i++){
option=options[ i ];
if(( option.selected||i===index) &&
!option.disabled &&
(!option.parentNode.disabled ||
!nodeName(option.parentNode, "optgroup"))){
value=jQuery(option).val();
if(one){
return value;
}
values.push(value);
}}
return values;
},
set: function(elem, value){
var optionSet, option,
options=elem.options,
values=jQuery.makeArray(value),
i=options.length;
while(i--){
option=options[ i ];
if(option.selected =
jQuery.inArray(jQuery.valHooks.option.get(option), values) > -1
){
optionSet=true;
}
}
if(!optionSet){
elem.selectedIndex=-1;
}
return values;
}}
}});
jQuery.each([ "radio", "checkbox" ], function(){
jQuery.valHooks[ this ]={
set: function(elem, value){
if(Array.isArray(value)){
return(elem.checked=jQuery.inArray(jQuery(elem).val(), value) > -1);
}}
};
if(!support.checkOn){
jQuery.valHooks[ this ].get=function(elem){
return elem.getAttribute("value")===null ? "on":elem.value;
};}});
var location=window.location;
var nonce={ guid: Date.now() };
var rquery=(/\?/);
jQuery.parseXML=function(data){
var xml, parserErrorElem;
if(!data||typeof data!=="string"){
return null;
}
try {
xml=(new window.DOMParser()).parseFromString(data, "text/xml");
} catch(e){}
parserErrorElem=xml&&xml.getElementsByTagName("parsererror")[ 0 ];
if(!xml||parserErrorElem){
jQuery.error("Invalid XML: " + (
parserErrorElem ?
jQuery.map(parserErrorElem.childNodes, function(el){
return el.textContent;
}).join("\n") :
data
));
}
return xml;
};
var rfocusMorph=/^(?:focusinfocus|focusoutblur)$/,
stopPropagationCallback=function(e){
e.stopPropagation();
};
jQuery.extend(jQuery.event, {
trigger: function(event, data, elem, onlyHandlers){
var i, cur, tmp, bubbleType, ontype, handle, special, lastElement,
eventPath=[ elem||document ],
type=hasOwn.call(event, "type") ? event.type:event,
namespaces=hasOwn.call(event, "namespace") ? event.namespace.split("."):[];
cur=lastElement=tmp=elem=elem||document;
if(elem.nodeType===3||elem.nodeType===8){
return;
}
if(rfocusMorph.test(type + jQuery.event.triggered)){
return;
}
if(type.indexOf(".") > -1){
namespaces=type.split(".");
type=namespaces.shift();
namespaces.sort();
}
ontype=type.indexOf(":") < 0&&"on" + type;
event=event[ jQuery.expando ] ?
event :
new jQuery.Event(type, typeof event==="object"&&event);
event.isTrigger=onlyHandlers ? 2:3;
event.namespace=namespaces.join(".");
event.rnamespace=event.namespace ?
new RegExp("(^|\\.)" + namespaces.join("\\.(?:.*\\.|)") + "(\\.|$)") :
null;
event.result=undefined;
if(!event.target){
event.target=elem;
}
data=data==null ?
[ event ] :
jQuery.makeArray(data, [ event ]);
special=jQuery.event.special[ type ]||{};
if(!onlyHandlers&&special.trigger&&special.trigger.apply(elem, data)===false){
return;
}
if(!onlyHandlers&&!special.noBubble&&!isWindow(elem)){
bubbleType=special.delegateType||type;
if(!rfocusMorph.test(bubbleType + type)){
cur=cur.parentNode;
}
for(; cur; cur=cur.parentNode){
eventPath.push(cur);
tmp=cur;
}
if(tmp===(elem.ownerDocument||document)){
eventPath.push(tmp.defaultView||tmp.parentWindow||window);
}}
i=0;
while(( cur=eventPath[ i++ ])&&!event.isPropagationStopped()){
lastElement=cur;
event.type=i > 1 ?
bubbleType :
special.bindType||type;
handle=(dataPriv.get(cur, "events")||Object.create(null))[ event.type ] &&
dataPriv.get(cur, "handle");
if(handle){
handle.apply(cur, data);
}
handle=ontype&&cur[ ontype ];
if(handle&&handle.apply&&acceptData(cur)){
event.result=handle.apply(cur, data);
if(event.result===false){
event.preventDefault();
}}
}
event.type=type;
if(!onlyHandlers&&!event.isDefaultPrevented()){
if(( !special._default ||
special._default.apply(eventPath.pop(), data)===false) &&
acceptData(elem)){
if(ontype&&isFunction(elem[ type ])&&!isWindow(elem)){
tmp=elem[ ontype ];
if(tmp){
elem[ ontype ]=null;
}
jQuery.event.triggered=type;
if(event.isPropagationStopped()){
lastElement.addEventListener(type, stopPropagationCallback);
}
elem[ type ]();
if(event.isPropagationStopped()){
lastElement.removeEventListener(type, stopPropagationCallback);
}
jQuery.event.triggered=undefined;
if(tmp){
elem[ ontype ]=tmp;
}}
}}
return event.result;
},
simulate: function(type, elem, event){
var e=jQuery.extend(new jQuery.Event(),
event,
{
type: type,
isSimulated: true
}
);
jQuery.event.trigger(e, null, elem);
}});
jQuery.fn.extend({
trigger: function(type, data){
return this.each(function(){
jQuery.event.trigger(type, data, this);
});
},
triggerHandler: function(type, data){
var elem=this[ 0 ];
if(elem){
return jQuery.event.trigger(type, data, elem, true);
}}
});
var
rbracket=/\[\]$/,
rCRLF=/\r?\n/g,
rsubmitterTypes=/^(?:submit|button|image|reset|file)$/i,
rsubmittable=/^(?:input|select|textarea|keygen)/i;
function buildParams(prefix, obj, traditional, add){
var name;
if(Array.isArray(obj)){
jQuery.each(obj, function(i, v){
if(traditional||rbracket.test(prefix)){
add(prefix, v);
}else{
buildParams(
prefix + "[" +(typeof v==="object"&&v!=null ? i:"") + "]",
v,
traditional,
add
);
}});
}else if(!traditional&&toType(obj)==="object"){
for(name in obj){
buildParams(prefix + "[" + name + "]", obj[ name ], traditional, add);
}}else{
add(prefix, obj);
}}
jQuery.param=function(a, traditional){
var prefix,
s=[],
add=function(key, valueOrFunction){
var value=isFunction(valueOrFunction) ?
valueOrFunction() :
valueOrFunction;
s[ s.length ]=encodeURIComponent(key) + "=" +
encodeURIComponent(value==null ? "":value);
};
if(a==null){
return "";
}
if(Array.isArray(a)||(a.jquery&&!jQuery.isPlainObject(a))){
jQuery.each(a, function(){
add(this.name, this.value);
});
}else{
for(prefix in a){
buildParams(prefix, a[ prefix ], traditional, add);
}}
return s.join("&");
};
jQuery.fn.extend({
serialize: function(){
return jQuery.param(this.serializeArray());
},
serializeArray: function(){
return this.map(function(){
var elements=jQuery.prop(this, "elements");
return elements ? jQuery.makeArray(elements):this;
}).filter(function(){
var type=this.type;
return this.name&&!jQuery(this).is(":disabled") &&
rsubmittable.test(this.nodeName)&&!rsubmitterTypes.test(type) &&
(this.checked||!rcheckableType.test(type));
}).map(function(_i, elem){
var val=jQuery(this).val();
if(val==null){
return null;
}
if(Array.isArray(val)){
return jQuery.map(val, function(val){
return { name: elem.name, value: val.replace(rCRLF, "\r\n") };});
}
return { name: elem.name, value: val.replace(rCRLF, "\r\n") };}).get();
}});
var
r20=/%20/g,
rhash=/#.*$/,
rantiCache=/([?&])_=[^&]*/,
rheaders=/^(.*?):[ \t]*([^\r\n]*)$/mg,
rlocalProtocol=/^(?:about|app|app-storage|.+-extension|file|res|widget):$/,
rnoContent=/^(?:GET|HEAD)$/,
rprotocol=/^\/\//,
prefilters={},
transports={},
allTypes="*/".concat("*"),
originAnchor=document.createElement("a");
originAnchor.href=location.href;
function addToPrefiltersOrTransports(structure){
return function(dataTypeExpression, func){
if(typeof dataTypeExpression!=="string"){
func=dataTypeExpression;
dataTypeExpression="*";
}
var dataType,
i=0,
dataTypes=dataTypeExpression.toLowerCase().match(rnothtmlwhite)||[];
if(isFunction(func)){
while(( dataType=dataTypes[ i++ ])){
if(dataType[ 0 ]==="+"){
dataType=dataType.slice(1)||"*";
(structure[ dataType ]=structure[ dataType ]||[]).unshift(func);
}else{
(structure[ dataType ]=structure[ dataType ]||[]).push(func);
}}
}};}
function inspectPrefiltersOrTransports(structure, options, originalOptions, jqXHR){
var inspected={},
seekingTransport=(structure===transports);
function inspect(dataType){
var selected;
inspected[ dataType ]=true;
jQuery.each(structure[ dataType ]||[], function(_, prefilterOrFactory){
var dataTypeOrTransport=prefilterOrFactory(options, originalOptions, jqXHR);
if(typeof dataTypeOrTransport==="string" &&
!seekingTransport&&!inspected[ dataTypeOrTransport ]){
options.dataTypes.unshift(dataTypeOrTransport);
inspect(dataTypeOrTransport);
return false;
}else if(seekingTransport){
return !(selected=dataTypeOrTransport);
}});
return selected;
}
return inspect(options.dataTypes[ 0 ])||!inspected[ "*" ]&&inspect("*");
}
function ajaxExtend(target, src){
var key, deep,
flatOptions=jQuery.ajaxSettings.flatOptions||{};
for(key in src){
if(src[ key ]!==undefined){
(flatOptions[ key ] ? target:(deep||(deep={})))[ key ]=src[ key ];
}}
if(deep){
jQuery.extend(true, target, deep);
}
return target;
}
function ajaxHandleResponses(s, jqXHR, responses){
var ct, type, finalDataType, firstDataType,
contents=s.contents,
dataTypes=s.dataTypes;
while(dataTypes[ 0 ]==="*"){
dataTypes.shift();
if(ct===undefined){
ct=s.mimeType||jqXHR.getResponseHeader("Content-Type");
}}
if(ct){
for(type in contents){
if(contents[ type ]&&contents[ type ].test(ct)){
dataTypes.unshift(type);
break;
}}
}
if(dataTypes[ 0 ] in responses){
finalDataType=dataTypes[ 0 ];
}else{
for(type in responses){
if(!dataTypes[ 0 ]||s.converters[ type + " " + dataTypes[ 0 ] ]){
finalDataType=type;
break;
}
if(!firstDataType){
firstDataType=type;
}}
finalDataType=finalDataType||firstDataType;
}
if(finalDataType){
if(finalDataType!==dataTypes[ 0 ]){
dataTypes.unshift(finalDataType);
}
return responses[ finalDataType ];
}}
function ajaxConvert(s, response, jqXHR, isSuccess){
var conv2, current, conv, tmp, prev,
converters={},
dataTypes=s.dataTypes.slice();
if(dataTypes[ 1 ]){
for(conv in s.converters){
converters[ conv.toLowerCase() ]=s.converters[ conv ];
}}
current=dataTypes.shift();
while(current){
if(s.responseFields[ current ]){
jqXHR[ s.responseFields[ current ] ]=response;
}
if(!prev&&isSuccess&&s.dataFilter){
response=s.dataFilter(response, s.dataType);
}
prev=current;
current=dataTypes.shift();
if(current){
if(current==="*"){
current=prev;
}else if(prev!=="*"&&prev!==current){
conv=converters[ prev + " " + current ]||converters[ "* " + current ];
if(!conv){
for(conv2 in converters){
tmp=conv2.split(" ");
if(tmp[ 1 ]===current){
conv=converters[ prev + " " + tmp[ 0 ] ] ||
converters[ "* " + tmp[ 0 ] ];
if(conv){
if(conv===true){
conv=converters[ conv2 ];
}else if(converters[ conv2 ]!==true){
current=tmp[ 0 ];
dataTypes.unshift(tmp[ 1 ]);
}
break;
}}
}}
if(conv!==true){
if(conv&&s.throws){
response=conv(response);
}else{
try {
response=conv(response);
} catch(e){
return {
state: "parsererror",
error: conv ? e:"No conversion from " + prev + " to " + current
};}}
}}
}}
return { state: "success", data: response };}
jQuery.extend({
active: 0,
lastModified: {},
etag: {},
ajaxSettings: {
url: location.href,
type: "GET",
isLocal: rlocalProtocol.test(location.protocol),
global: true,
processData: true,
async: true,
contentType: "application/x-www-form-urlencoded; charset=UTF-8",
accepts: {
"*": allTypes,
text: "text/plain",
html: "text/html",
xml: "application/xml, text/xml",
json: "application/json, text/javascript"
},
contents: {
xml: /\bxml\b/,
html: /\bhtml/,
json: /\bjson\b/
},
responseFields: {
xml: "responseXML",
text: "responseText",
json: "responseJSON"
},
converters: {
"* text": String,
"text html": true,
"text json": JSON.parse,
"text xml": jQuery.parseXML
},
flatOptions: {
url: true,
context: true
}},
ajaxSetup: function(target, settings){
return settings ?
ajaxExtend(ajaxExtend(target, jQuery.ajaxSettings), settings) :
ajaxExtend(jQuery.ajaxSettings, target);
},
ajaxPrefilter: addToPrefiltersOrTransports(prefilters),
ajaxTransport: addToPrefiltersOrTransports(transports),
ajax: function(url, options){
if(typeof url==="object"){
options=url;
url=undefined;
}
options=options||{};
var transport,
cacheURL,
responseHeadersString,
responseHeaders,
timeoutTimer,
urlAnchor,
completed,
fireGlobals,
i,
uncached,
s=jQuery.ajaxSetup({}, options),
callbackContext=s.context||s,
globalEventContext=s.context &&
(callbackContext.nodeType||callbackContext.jquery) ?
jQuery(callbackContext) :
jQuery.event,
deferred=jQuery.Deferred(),
completeDeferred=jQuery.Callbacks("once memory"),
statusCode=s.statusCode||{},
requestHeaders={},
requestHeadersNames={},
strAbort="canceled",
jqXHR={
readyState: 0,
getResponseHeader: function(key){
var match;
if(completed){
if(!responseHeaders){
responseHeaders={};
while(( match=rheaders.exec(responseHeadersString))){
responseHeaders[ match[ 1 ].toLowerCase() + " " ] =
(responseHeaders[ match[ 1 ].toLowerCase() + " " ]||[])
.concat(match[ 2 ]);
}}
match=responseHeaders[ key.toLowerCase() + " " ];
}
return match==null ? null:match.join(", ");
},
getAllResponseHeaders: function(){
return completed ? responseHeadersString:null;
},
setRequestHeader: function(name, value){
if(completed==null){
name=requestHeadersNames[ name.toLowerCase() ] =
requestHeadersNames[ name.toLowerCase() ]||name;
requestHeaders[ name ]=value;
}
return this;
},
overrideMimeType: function(type){
if(completed==null){
s.mimeType=type;
}
return this;
},
statusCode: function(map){
var code;
if(map){
if(completed){
jqXHR.always(map[ jqXHR.status ]);
}else{
for(code in map){
statusCode[ code ]=[ statusCode[ code ], map[ code ] ];
}}
}
return this;
},
abort: function(statusText){
var finalText=statusText||strAbort;
if(transport){
transport.abort(finalText);
}
done(0, finalText);
return this;
}};
deferred.promise(jqXHR);
s.url=(( url||s.url||location.href) + "")
.replace(rprotocol, location.protocol + "//");
s.type=options.method||options.type||s.method||s.type;
s.dataTypes=(s.dataType||"*").toLowerCase().match(rnothtmlwhite)||[ "" ];
if(s.crossDomain==null){
urlAnchor=document.createElement("a");
try {
urlAnchor.href=s.url;
urlAnchor.href=urlAnchor.href;
s.crossDomain=originAnchor.protocol + "//" + originAnchor.host!==urlAnchor.protocol + "//" + urlAnchor.host;
} catch(e){
s.crossDomain=true;
}}
if(s.data&&s.processData&&typeof s.data!=="string"){
s.data=jQuery.param(s.data, s.traditional);
}
inspectPrefiltersOrTransports(prefilters, s, options, jqXHR);
if(completed){
return jqXHR;
}
fireGlobals=jQuery.event&&s.global;
if(fireGlobals&&jQuery.active++===0){
jQuery.event.trigger("ajaxStart");
}
s.type=s.type.toUpperCase();
s.hasContent = !rnoContent.test(s.type);
cacheURL=s.url.replace(rhash, "");
if(!s.hasContent){
uncached=s.url.slice(cacheURL.length);
if(s.data&&(s.processData||typeof s.data==="string")){
cacheURL +=(rquery.test(cacheURL) ? "&":"?") + s.data;
delete s.data;
}
if(s.cache===false){
cacheURL=cacheURL.replace(rantiCache, "$1");
uncached=(rquery.test(cacheURL) ? "&":"?") + "_=" +(nonce.guid++) +
uncached;
}
s.url=cacheURL + uncached;
}else if(s.data&&s.processData &&
(s.contentType||"").indexOf("application/x-www-form-urlencoded")===0){
s.data=s.data.replace(r20, "+");
}
if(s.ifModified){
if(jQuery.lastModified[ cacheURL ]){
jqXHR.setRequestHeader("If-Modified-Since", jQuery.lastModified[ cacheURL ]);
}
if(jQuery.etag[ cacheURL ]){
jqXHR.setRequestHeader("If-None-Match", jQuery.etag[ cacheURL ]);
}}
if(s.data&&s.hasContent&&s.contentType!==false||options.contentType){
jqXHR.setRequestHeader("Content-Type", s.contentType);
}
jqXHR.setRequestHeader("Accept",
s.dataTypes[ 0 ]&&s.accepts[ s.dataTypes[ 0 ] ] ?
s.accepts[ s.dataTypes[ 0 ] ] +
(s.dataTypes[ 0 ]!=="*" ? ", " + allTypes + "; q=0.01":"") :
s.accepts[ "*" ]
);
for(i in s.headers){
jqXHR.setRequestHeader(i, s.headers[ i ]);
}
if(s.beforeSend &&
(s.beforeSend.call(callbackContext, jqXHR, s)===false||completed)){
return jqXHR.abort();
}
strAbort="abort";
completeDeferred.add(s.complete);
jqXHR.done(s.success);
jqXHR.fail(s.error);
transport=inspectPrefiltersOrTransports(transports, s, options, jqXHR);
if(!transport){
done(-1, "No Transport");
}else{
jqXHR.readyState=1;
if(fireGlobals){
globalEventContext.trigger("ajaxSend", [ jqXHR, s ]);
}
if(completed){
return jqXHR;
}
if(s.async&&s.timeout > 0){
timeoutTimer=window.setTimeout(function(){
jqXHR.abort("timeout");
}, s.timeout);
}
try {
completed=false;
transport.send(requestHeaders, done);
} catch(e){
if(completed){
throw e;
}
done(-1, e);
}}
function done(status, nativeStatusText, responses, headers){
var isSuccess, success, error, response, modified,
statusText=nativeStatusText;
if(completed){
return;
}
completed=true;
if(timeoutTimer){
window.clearTimeout(timeoutTimer);
}
transport=undefined;
responseHeadersString=headers||"";
jqXHR.readyState=status > 0 ? 4:0;
isSuccess=status >=200&&status < 300||status===304;
if(responses){
response=ajaxHandleResponses(s, jqXHR, responses);
}
if(!isSuccess &&
jQuery.inArray("script", s.dataTypes) > -1 &&
jQuery.inArray("json", s.dataTypes) < 0){
s.converters[ "text script" ]=function(){};}
response=ajaxConvert(s, response, jqXHR, isSuccess);
if(isSuccess){
if(s.ifModified){
modified=jqXHR.getResponseHeader("Last-Modified");
if(modified){
jQuery.lastModified[ cacheURL ]=modified;
}
modified=jqXHR.getResponseHeader("etag");
if(modified){
jQuery.etag[ cacheURL ]=modified;
}}
if(status===204||s.type==="HEAD"){
statusText="nocontent";
}else if(status===304){
statusText="notmodified";
}else{
statusText=response.state;
success=response.data;
error=response.error;
isSuccess = !error;
}}else{
error=statusText;
if(status||!statusText){
statusText="error";
if(status < 0){
status=0;
}}
}
jqXHR.status=status;
jqXHR.statusText=(nativeStatusText||statusText) + "";
if(isSuccess){
deferred.resolveWith(callbackContext, [ success, statusText, jqXHR ]);
}else{
deferred.rejectWith(callbackContext, [ jqXHR, statusText, error ]);
}
jqXHR.statusCode(statusCode);
statusCode=undefined;
if(fireGlobals){
globalEventContext.trigger(isSuccess ? "ajaxSuccess":"ajaxError",
[ jqXHR, s, isSuccess ? success:error ]);
}
completeDeferred.fireWith(callbackContext, [ jqXHR, statusText ]);
if(fireGlobals){
globalEventContext.trigger("ajaxComplete", [ jqXHR, s ]);
if(!(--jQuery.active)){
jQuery.event.trigger("ajaxStop");
}}
}
return jqXHR;
},
getJSON: function(url, data, callback){
return jQuery.get(url, data, callback, "json");
},
getScript: function(url, callback){
return jQuery.get(url, undefined, callback, "script");
}});
jQuery.each([ "get", "post" ], function(_i, method){
jQuery[ method ]=function(url, data, callback, type){
if(isFunction(data)){
type=type||callback;
callback=data;
data=undefined;
}
return jQuery.ajax(jQuery.extend({
url: url,
type: method,
dataType: type,
data: data,
success: callback
}, jQuery.isPlainObject(url)&&url));
};});
jQuery.ajaxPrefilter(function(s){
var i;
for(i in s.headers){
if(i.toLowerCase()==="content-type"){
s.contentType=s.headers[ i ]||"";
}}
});
jQuery._evalUrl=function(url, options, doc){
return jQuery.ajax({
url: url,
type: "GET",
dataType: "script",
cache: true,
async: false,
global: false,
converters: {
"text script": function(){}},
dataFilter: function(response){
jQuery.globalEval(response, options, doc);
}});
};
jQuery.fn.extend({
wrapAll: function(html){
var wrap;
if(this[ 0 ]){
if(isFunction(html)){
html=html.call(this[ 0 ]);
}
wrap=jQuery(html, this[ 0 ].ownerDocument).eq(0).clone(true);
if(this[ 0 ].parentNode){
wrap.insertBefore(this[ 0 ]);
}
wrap.map(function(){
var elem=this;
while(elem.firstElementChild){
elem=elem.firstElementChild;
}
return elem;
}).append(this);
}
return this;
},
wrapInner: function(html){
if(isFunction(html)){
return this.each(function(i){
jQuery(this).wrapInner(html.call(this, i));
});
}
return this.each(function(){
var self=jQuery(this),
contents=self.contents();
if(contents.length){
contents.wrapAll(html);
}else{
self.append(html);
}});
},
wrap: function(html){
var htmlIsFunction=isFunction(html);
return this.each(function(i){
jQuery(this).wrapAll(htmlIsFunction ? html.call(this, i):html);
});
},
unwrap: function(selector){
this.parent(selector).not("body").each(function(){
jQuery(this).replaceWith(this.childNodes);
});
return this;
}});
jQuery.expr.pseudos.hidden=function(elem){
return !jQuery.expr.pseudos.visible(elem);
};
jQuery.expr.pseudos.visible=function(elem){
return !!(elem.offsetWidth||elem.offsetHeight||elem.getClientRects().length);
};
jQuery.ajaxSettings.xhr=function(){
try {
return new window.XMLHttpRequest();
} catch(e){}};
var xhrSuccessStatus={
0: 200,
1223: 204
},
xhrSupported=jQuery.ajaxSettings.xhr();
support.cors = !!xhrSupported&&("withCredentials" in xhrSupported);
support.ajax=xhrSupported = !!xhrSupported;
jQuery.ajaxTransport(function(options){
var callback, errorCallback;
if(support.cors||xhrSupported&&!options.crossDomain){
return {
send: function(headers, complete){
var i,
xhr=options.xhr();
xhr.open(options.type,
options.url,
options.async,
options.username,
options.password
);
if(options.xhrFields){
for(i in options.xhrFields){
xhr[ i ]=options.xhrFields[ i ];
}}
if(options.mimeType&&xhr.overrideMimeType){
xhr.overrideMimeType(options.mimeType);
}
if(!options.crossDomain&&!headers[ "X-Requested-With" ]){
headers[ "X-Requested-With" ]="XMLHttpRequest";
}
for(i in headers){
xhr.setRequestHeader(i, headers[ i ]);
}
callback=function(type){
return function(){
if(callback){
callback=errorCallback=xhr.onload =
xhr.onerror=xhr.onabort=xhr.ontimeout =
xhr.onreadystatechange=null;
if(type==="abort"){
xhr.abort();
}else if(type==="error"){
if(typeof xhr.status!=="number"){
complete(0, "error");
}else{
complete(
xhr.status,
xhr.statusText
);
}}else{
complete(
xhrSuccessStatus[ xhr.status ]||xhr.status,
xhr.statusText,
(xhr.responseType||"text")!=="text"  ||
typeof xhr.responseText!=="string" ?
{ binary: xhr.response } :
{ text: xhr.responseText },
xhr.getAllResponseHeaders()
);
}}
};};
xhr.onload=callback();
errorCallback=xhr.onerror=xhr.ontimeout=callback("error");
if(xhr.onabort!==undefined){
xhr.onabort=errorCallback;
}else{
xhr.onreadystatechange=function(){
if(xhr.readyState===4){
window.setTimeout(function(){
if(callback){
errorCallback();
}});
}};}
callback=callback("abort");
try {
xhr.send(options.hasContent&&options.data||null);
} catch(e){
if(callback){
throw e;
}}
},
abort: function(){
if(callback){
callback();
}}
};}});
jQuery.ajaxPrefilter(function(s){
if(s.crossDomain){
s.contents.script=false;
}});
jQuery.ajaxSetup({
accepts: {
script: "text/javascript, application/javascript, " +
"application/ecmascript, application/x-ecmascript"
},
contents: {
script: /\b(?:java|ecma)script\b/
},
converters: {
"text script": function(text){
jQuery.globalEval(text);
return text;
}}
});
jQuery.ajaxPrefilter("script", function(s){
if(s.cache===undefined){
s.cache=false;
}
if(s.crossDomain){
s.type="GET";
}});
jQuery.ajaxTransport("script", function(s){
if(s.crossDomain||s.scriptAttrs){
var script, callback;
return {
send: function(_, complete){
script=jQuery("<script>")
.attr(s.scriptAttrs||{})
.prop({ charset: s.scriptCharset, src: s.url })
.on("load error", callback=function(evt){
script.remove();
callback=null;
if(evt){
complete(evt.type==="error" ? 404:200, evt.type);
}});
document.head.appendChild(script[ 0 ]);
},
abort: function(){
if(callback){
callback();
}}
};}});
var oldCallbacks=[],
rjsonp=/(=)\?(?=&|$)|\?\?/;
jQuery.ajaxSetup({
jsonp: "callback",
jsonpCallback: function(){
var callback=oldCallbacks.pop()||(jQuery.expando + "_" +(nonce.guid++));
this[ callback ]=true;
return callback;
}});
jQuery.ajaxPrefilter("json jsonp", function(s, originalSettings, jqXHR){
var callbackName, overwritten, responseContainer,
jsonProp=s.jsonp!==false&&(rjsonp.test(s.url) ?
"url" :
typeof s.data==="string" &&
(s.contentType||"")
.indexOf("application/x-www-form-urlencoded")===0 &&
rjsonp.test(s.data)&&"data"
);
if(jsonProp||s.dataTypes[ 0 ]==="jsonp"){
callbackName=s.jsonpCallback=isFunction(s.jsonpCallback) ?
s.jsonpCallback() :
s.jsonpCallback;
if(jsonProp){
s[ jsonProp ]=s[ jsonProp ].replace(rjsonp, "$1" + callbackName);
}else if(s.jsonp!==false){
s.url +=(rquery.test(s.url) ? "&":"?") + s.jsonp + "=" + callbackName;
}
s.converters[ "script json" ]=function(){
if(!responseContainer){
jQuery.error(callbackName + " was not called");
}
return responseContainer[ 0 ];
};
s.dataTypes[ 0 ]="json";
overwritten=window[ callbackName ];
window[ callbackName ]=function(){
responseContainer=arguments;
};
jqXHR.always(function(){
if(overwritten===undefined){
jQuery(window).removeProp(callbackName);
}else{
window[ callbackName ]=overwritten;
}
if(s[ callbackName ]){
s.jsonpCallback=originalSettings.jsonpCallback;
oldCallbacks.push(callbackName);
}
if(responseContainer&&isFunction(overwritten)){
overwritten(responseContainer[ 0 ]);
}
responseContainer=overwritten=undefined;
});
return "script";
}});
support.createHTMLDocument=(function(){
var body=document.implementation.createHTMLDocument("").body;
body.innerHTML="<form></form><form></form>";
return body.childNodes.length===2;
})();
jQuery.parseHTML=function(data, context, keepScripts){
if(typeof data!=="string"){
return [];
}
if(typeof context==="boolean"){
keepScripts=context;
context=false;
}
var base, parsed, scripts;
if(!context){
if(support.createHTMLDocument){
context=document.implementation.createHTMLDocument("");
base=context.createElement("base");
base.href=document.location.href;
context.head.appendChild(base);
}else{
context=document;
}}
parsed=rsingleTag.exec(data);
scripts = !keepScripts&&[];
if(parsed){
return [ context.createElement(parsed[ 1 ]) ];
}
parsed=buildFragment([ data ], context, scripts);
if(scripts&&scripts.length){
jQuery(scripts).remove();
}
return jQuery.merge([], parsed.childNodes);
};
jQuery.fn.load=function(url, params, callback){
var selector, type, response,
self=this,
off=url.indexOf(" ");
if(off > -1){
selector=stripAndCollapse(url.slice(off));
url=url.slice(0, off);
}
if(isFunction(params)){
callback=params;
params=undefined;
}else if(params&&typeof params==="object"){
type="POST";
}
if(self.length > 0){
jQuery.ajax({
url: url,
type: type||"GET",
dataType: "html",
data: params
}).done(function(responseText){
response=arguments;
self.html(selector ?
jQuery("<div>").append(jQuery.parseHTML(responseText)).find(selector) :
responseText);
}).always(callback&&function(jqXHR, status){
self.each(function(){
callback.apply(this, response||[ jqXHR.responseText, status, jqXHR ]);
});
});
}
return this;
};
jQuery.expr.pseudos.animated=function(elem){
return jQuery.grep(jQuery.timers, function(fn){
return elem===fn.elem;
}).length;
};
jQuery.offset={
setOffset: function(elem, options, i){
var curPosition, curLeft, curCSSTop, curTop, curOffset, curCSSLeft, calculatePosition,
position=jQuery.css(elem, "position"),
curElem=jQuery(elem),
props={};
if(position==="static"){
elem.style.position="relative";
}
curOffset=curElem.offset();
curCSSTop=jQuery.css(elem, "top");
curCSSLeft=jQuery.css(elem, "left");
calculatePosition=(position==="absolute"||position==="fixed") &&
(curCSSTop + curCSSLeft).indexOf("auto") > -1;
if(calculatePosition){
curPosition=curElem.position();
curTop=curPosition.top;
curLeft=curPosition.left;
}else{
curTop=parseFloat(curCSSTop)||0;
curLeft=parseFloat(curCSSLeft)||0;
}
if(isFunction(options)){
options=options.call(elem, i, jQuery.extend({}, curOffset));
}
if(options.top!=null){
props.top=(options.top - curOffset.top) + curTop;
}
if(options.left!=null){
props.left=(options.left - curOffset.left) + curLeft;
}
if("using" in options){
options.using.call(elem, props);
}else{
curElem.css(props);
}}
};
jQuery.fn.extend({
offset: function(options){
if(arguments.length){
return options===undefined ?
this :
this.each(function(i){
jQuery.offset.setOffset(this, options, i);
});
}
var rect, win,
elem=this[ 0 ];
if(!elem){
return;
}
if(!elem.getClientRects().length){
return { top: 0, left: 0 };}
rect=elem.getBoundingClientRect();
win=elem.ownerDocument.defaultView;
return {
top: rect.top + win.pageYOffset,
left: rect.left + win.pageXOffset
};},
position: function(){
if(!this[ 0 ]){
return;
}
var offsetParent, offset, doc,
elem=this[ 0 ],
parentOffset={ top: 0, left: 0 };
if(jQuery.css(elem, "position")==="fixed"){
offset=elem.getBoundingClientRect();
}else{
offset=this.offset();
doc=elem.ownerDocument;
offsetParent=elem.offsetParent||doc.documentElement;
while(offsetParent &&
(offsetParent===doc.body||offsetParent===doc.documentElement) &&
jQuery.css(offsetParent, "position")==="static"){
offsetParent=offsetParent.parentNode;
}
if(offsetParent&&offsetParent!==elem&&offsetParent.nodeType===1){
parentOffset=jQuery(offsetParent).offset();
parentOffset.top +=jQuery.css(offsetParent, "borderTopWidth", true);
parentOffset.left +=jQuery.css(offsetParent, "borderLeftWidth", true);
}}
return {
top: offset.top - parentOffset.top - jQuery.css(elem, "marginTop", true),
left: offset.left - parentOffset.left - jQuery.css(elem, "marginLeft", true)
};},
offsetParent: function(){
return this.map(function(){
var offsetParent=this.offsetParent;
while(offsetParent&&jQuery.css(offsetParent, "position")==="static"){
offsetParent=offsetParent.offsetParent;
}
return offsetParent||documentElement;
});
}});
jQuery.each({ scrollLeft: "pageXOffset", scrollTop: "pageYOffset" }, function(method, prop){
var top="pageYOffset"===prop;
jQuery.fn[ method ]=function(val){
return access(this, function(elem, method, val){
var win;
if(isWindow(elem)){
win=elem;
}else if(elem.nodeType===9){
win=elem.defaultView;
}
if(val===undefined){
return win ? win[ prop ]:elem[ method ];
}
if(win){
win.scrollTo(!top ? val:win.pageXOffset,
top ? val:win.pageYOffset
);
}else{
elem[ method ]=val;
}}, method, val, arguments.length);
};});
jQuery.each([ "top", "left" ], function(_i, prop){
jQuery.cssHooks[ prop ]=addGetHookIf(support.pixelPosition,
function(elem, computed){
if(computed){
computed=curCSS(elem, prop);
return rnumnonpx.test(computed) ?
jQuery(elem).position()[ prop ] + "px" :
computed;
}}
);
});
jQuery.each({ Height: "height", Width: "width" }, function(name, type){
jQuery.each({
padding: "inner" + name,
content: type,
"": "outer" + name
}, function(defaultExtra, funcName){
jQuery.fn[ funcName ]=function(margin, value){
var chainable=arguments.length&&(defaultExtra||typeof margin!=="boolean"),
extra=defaultExtra||(margin===true||value===true ? "margin":"border");
return access(this, function(elem, type, value){
var doc;
if(isWindow(elem)){
return funcName.indexOf("outer")===0 ?
elem[ "inner" + name ] :
elem.document.documentElement[ "client" + name ];
}
if(elem.nodeType===9){
doc=elem.documentElement;
return Math.max(elem.body[ "scroll" + name ], doc[ "scroll" + name ],
elem.body[ "offset" + name ], doc[ "offset" + name ],
doc[ "client" + name ]
);
}
return value===undefined ?
jQuery.css(elem, type, extra) :
jQuery.style(elem, type, value, extra);
}, type, chainable ? margin:undefined, chainable);
};});
});
jQuery.each([
"ajaxStart",
"ajaxStop",
"ajaxComplete",
"ajaxError",
"ajaxSuccess",
"ajaxSend"
], function(_i, type){
jQuery.fn[ type ]=function(fn){
return this.on(type, fn);
};});
jQuery.fn.extend({
bind: function(types, data, fn){
return this.on(types, null, data, fn);
},
unbind: function(types, fn){
return this.off(types, null, fn);
},
delegate: function(selector, types, data, fn){
return this.on(types, selector, data, fn);
},
undelegate: function(selector, types, fn){
return arguments.length===1 ?
this.off(selector, "**") :
this.off(types, selector||"**", fn);
},
hover: function(fnOver, fnOut){
return this
.on("mouseenter", fnOver)
.on("mouseleave", fnOut||fnOver);
}});
jQuery.each(("blur focus focusin focusout resize scroll click dblclick " +
"mousedown mouseup mousemove mouseover mouseout mouseenter mouseleave " +
"change select submit keydown keypress keyup contextmenu").split(" "),
function(_i, name){
jQuery.fn[ name ]=function(data, fn){
return arguments.length > 0 ?
this.on(name, null, data, fn) :
this.trigger(name);
};}
);
var rtrim=/^[\s\uFEFF\xA0]+|([^\s\uFEFF\xA0])[\s\uFEFF\xA0]+$/g;
jQuery.proxy=function(fn, context){
var tmp, args, proxy;
if(typeof context==="string"){
tmp=fn[ context ];
context=fn;
fn=tmp;
}
if(!isFunction(fn)){
return undefined;
}
args=slice.call(arguments, 2);
proxy=function(){
return fn.apply(context||this, args.concat(slice.call(arguments)));
};
proxy.guid=fn.guid=fn.guid||jQuery.guid++;
return proxy;
};
jQuery.holdReady=function(hold){
if(hold){
jQuery.readyWait++;
}else{
jQuery.ready(true);
}};
jQuery.isArray=Array.isArray;
jQuery.parseJSON=JSON.parse;
jQuery.nodeName=nodeName;
jQuery.isFunction=isFunction;
jQuery.isWindow=isWindow;
jQuery.camelCase=camelCase;
jQuery.type=toType;
jQuery.now=Date.now;
jQuery.isNumeric=function(obj){
var type=jQuery.type(obj);
return(type==="number"||type==="string") &&
!isNaN(obj - parseFloat(obj));
};
jQuery.trim=function(text){
return text==null ?
"" :
(text + "").replace(rtrim, "$1");
};
if(typeof define==="function"&&define.amd){
define("jquery", [], function(){
return jQuery;
});
}
var
_jQuery=window.jQuery,
_$=window.$;
jQuery.noConflict=function(deep){
if(window.$===jQuery){
window.$=_$;
}
if(deep&&window.jQuery===jQuery){
window.jQuery=_jQuery;
}
return jQuery;
};
if(typeof noGlobal==="undefined"){
window.jQuery=window.$=jQuery;
}
return jQuery;
});
jQuery.noConflict();
(function(factory){
"use strict";
if(typeof define==="function"&&define.amd){
define([ "jquery" ], function(jQuery){
return factory(jQuery, window);
});
}else if(typeof module==="object"&&module.exports){
module.exports=factory(require("jquery"), window);
}else{
factory(jQuery, window);
}})(function(jQuery, window){
"use strict";
jQuery.migrateVersion="3.4.1";
function compareVersions(v1, v2){
var i,
rVersionParts=/^(\d+)\.(\d+)\.(\d+)/,
v1p=rVersionParts.exec(v1)||[ ],
v2p=rVersionParts.exec(v2)||[ ];
for(i=1; i <=3; i++){
if(+v1p[ i ] > +v2p[ i ]){
return 1;
}
if(+v1p[ i ] < +v2p[ i ]){
return -1;
}}
return 0;
}
function jQueryVersionSince(version){
return compareVersions(jQuery.fn.jquery, version) >=0;
}
var disabledPatches=Object.create(null);
jQuery.migrateDisablePatches=function(){
var i;
for(i=0; i < arguments.length; i++){
disabledPatches[ arguments[ i ] ]=true;
}};
jQuery.migrateEnablePatches=function(){
var i;
for(i=0; i < arguments.length; i++){
delete disabledPatches[ arguments[ i ] ];
}};
jQuery.migrateIsPatchEnabled=function(patchCode){
return !disabledPatches[ patchCode ];
};
(function(){
if(!window.console||!window.console.log){
return;
}
if(!jQuery||!jQueryVersionSince("3.0.0") ||
jQueryVersionSince("5.0.0")){
window.console.log("JQMIGRATE: jQuery 3.x-4.x REQUIRED");
}
if(jQuery.migrateWarnings){
window.console.log("JQMIGRATE: Migrate plugin loaded multiple times");
}
window.console.log("JQMIGRATE: Migrate is installed" +
(jQuery.migrateMute ? "":" with logging active") +
", version " + jQuery.migrateVersion);
})();
var warnedAbout={};
jQuery.migrateDeduplicateWarnings=true;
jQuery.migrateWarnings=[];
if(jQuery.migrateTrace===undefined){
jQuery.migrateTrace=true;
}
jQuery.migrateReset=function(){
warnedAbout={};
jQuery.migrateWarnings.length=0;
};
function migrateWarn(code, msg){
var console=window.console;
if(jQuery.migrateIsPatchEnabled(code) &&
(!jQuery.migrateDeduplicateWarnings||!warnedAbout[ msg ])){
warnedAbout[ msg ]=true;
jQuery.migrateWarnings.push(msg + " [" + code + "]");
if(console&&console.warn&&!jQuery.migrateMute){
console.warn("JQMIGRATE: " + msg);
if(jQuery.migrateTrace&&console.trace){
console.trace();
}}
}}
function migrateWarnProp(obj, prop, value, code, msg){
Object.defineProperty(obj, prop, {
configurable: true,
enumerable: true,
get: function(){
migrateWarn(code, msg);
return value;
},
set: function(newValue){
migrateWarn(code, msg);
value=newValue;
}});
}
function migrateWarnFuncInternal(obj, prop, newFunc, code, msg){
var finalFunc,
origFunc=obj[ prop ];
obj[ prop ]=function(){
if(msg){
migrateWarn(code, msg);
}
finalFunc=jQuery.migrateIsPatchEnabled(code) ?
newFunc :
(origFunc||jQuery.noop);
return finalFunc.apply(this, arguments);
};}
function migratePatchAndWarnFunc(obj, prop, newFunc, code, msg){
if(!msg){
throw new Error("No warning message provided");
}
return migrateWarnFuncInternal(obj, prop, newFunc, code, msg);
}
function migratePatchFunc(obj, prop, newFunc, code){
return migrateWarnFuncInternal(obj, prop, newFunc, code);
}
if(window.document.compatMode==="BackCompat"){
migrateWarn("quirks", "jQuery is not compatible with Quirks Mode");
}
var findProp,
class2type={},
oldInit=jQuery.fn.init,
oldFind=jQuery.find,
rattrHashTest=/\[(\s*[-\w]+\s*)([~|^$*]?=)\s*([-\w#]*?#[-\w#]*)\s*\]/,
rattrHashGlob=/\[(\s*[-\w]+\s*)([~|^$*]?=)\s*([-\w#]*?#[-\w#]*)\s*\]/g,
rtrim=/^[\s\uFEFF\xA0]+|([^\s\uFEFF\xA0])[\s\uFEFF\xA0]+$/g;
migratePatchFunc(jQuery.fn, "init", function(arg1){
var args=Array.prototype.slice.call(arguments);
if(jQuery.migrateIsPatchEnabled("selector-empty-id") &&
typeof arg1==="string"&&arg1==="#"){
migrateWarn("selector-empty-id", "jQuery('#') is not a valid selector");
args[ 0 ]=[];
}
return oldInit.apply(this, args);
}, "selector-empty-id");
jQuery.fn.init.prototype=jQuery.fn;
migratePatchFunc(jQuery, "find", function(selector){
var args=Array.prototype.slice.call(arguments);
if(typeof selector==="string"&&rattrHashTest.test(selector)){
try {
window.document.querySelector(selector);
} catch(err1){
selector=selector.replace(rattrHashGlob, function(_, attr, op, value){
return "[" + attr + op + "\"" + value + "\"]";
});
try {
window.document.querySelector(selector);
migrateWarn("selector-hash",
"Attribute selector with '#' must be quoted: " + args[ 0 ]);
args[ 0 ]=selector;
} catch(err2){
migrateWarn("selector-hash",
"Attribute selector with '#' was not fixed: " + args[ 0 ]);
}}
}
return oldFind.apply(this, args);
}, "selector-hash");
for(findProp in oldFind){
if(Object.prototype.hasOwnProperty.call(oldFind, findProp)){
jQuery.find[ findProp ]=oldFind[ findProp ];
}}
migratePatchAndWarnFunc(jQuery.fn, "size", function(){
return this.length;
}, "size",
"jQuery.fn.size() is deprecated and removed; use the .length property");
migratePatchAndWarnFunc(jQuery, "parseJSON", function(){
return JSON.parse.apply(null, arguments);
}, "parseJSON",
"jQuery.parseJSON is deprecated; use JSON.parse");
migratePatchAndWarnFunc(jQuery, "holdReady", jQuery.holdReady,
"holdReady", "jQuery.holdReady is deprecated");
migratePatchAndWarnFunc(jQuery, "unique", jQuery.uniqueSort,
"unique", "jQuery.unique is deprecated; use jQuery.uniqueSort");
migrateWarnProp(jQuery.expr, "filters", jQuery.expr.pseudos, "expr-pre-pseudos",
"jQuery.expr.filters is deprecated; use jQuery.expr.pseudos");
migrateWarnProp(jQuery.expr, ":", jQuery.expr.pseudos, "expr-pre-pseudos",
"jQuery.expr[':'] is deprecated; use jQuery.expr.pseudos");
if(jQueryVersionSince("3.1.1")){
migratePatchAndWarnFunc(jQuery, "trim", function(text){
return text==null ?
"" :
(text + "").replace(rtrim, "$1");
}, "trim",
"jQuery.trim is deprecated; use String.prototype.trim");
}
if(jQueryVersionSince("3.2.0")){
migratePatchAndWarnFunc(jQuery, "nodeName", function(elem, name){
return elem.nodeName&&elem.nodeName.toLowerCase()===name.toLowerCase();
}, "nodeName",
"jQuery.nodeName is deprecated");
migratePatchAndWarnFunc(jQuery, "isArray", Array.isArray, "isArray",
"jQuery.isArray is deprecated; use Array.isArray"
);
}
if(jQueryVersionSince("3.3.0")){
migratePatchAndWarnFunc(jQuery, "isNumeric", function(obj){
var type=typeof obj;
return(type==="number"||type==="string") &&
!isNaN(obj - parseFloat(obj));
}, "isNumeric",
"jQuery.isNumeric() is deprecated"
);
jQuery.each("Boolean Number String Function Array Date RegExp Object Error Symbol".
split(" "),
function(_, name){
class2type[ "[object " + name + "]" ]=name.toLowerCase();
});
migratePatchAndWarnFunc(jQuery, "type", function(obj){
if(obj==null){
return obj + "";
}
return typeof obj==="object"||typeof obj==="function" ?
class2type[ Object.prototype.toString.call(obj) ]||"object" :
typeof obj;
}, "type",
"jQuery.type is deprecated");
migratePatchAndWarnFunc(jQuery, "isFunction",
function(obj){
return typeof obj==="function";
}, "isFunction",
"jQuery.isFunction() is deprecated");
migratePatchAndWarnFunc(jQuery, "isWindow",
function(obj){
return obj!=null&&obj===obj.window;
}, "isWindow",
"jQuery.isWindow() is deprecated"
);
}
if(jQuery.ajax){
var oldAjax=jQuery.ajax,
rjsonp=/(=)\?(?=&|$)|\?\?/;
migratePatchFunc(jQuery, "ajax", function(){
var jQXHR=oldAjax.apply(this, arguments);
if(jQXHR.promise){
migratePatchAndWarnFunc(jQXHR, "success", jQXHR.done, "jqXHR-methods",
"jQXHR.success is deprecated and removed");
migratePatchAndWarnFunc(jQXHR, "error", jQXHR.fail, "jqXHR-methods",
"jQXHR.error is deprecated and removed");
migratePatchAndWarnFunc(jQXHR, "complete", jQXHR.always, "jqXHR-methods",
"jQXHR.complete is deprecated and removed");
}
return jQXHR;
}, "jqXHR-methods");
if(!jQueryVersionSince("4.0.0")){
jQuery.ajaxPrefilter("+json", function(s){
if(s.jsonp!==false&&(rjsonp.test(s.url) ||
typeof s.data==="string" &&
(s.contentType||"")
.indexOf("application/x-www-form-urlencoded")===0 &&
rjsonp.test(s.data)
)){
migrateWarn("jsonp-promotion", "JSON-to-JSONP auto-promotion is deprecated");
}});
}}
var oldRemoveAttr=jQuery.fn.removeAttr,
oldToggleClass=jQuery.fn.toggleClass,
rmatchNonSpace=/\S+/g;
migratePatchFunc(jQuery.fn, "removeAttr", function(name){
var self=this,
patchNeeded=false;
jQuery.each(name.match(rmatchNonSpace), function(_i, attr){
if(jQuery.expr.match.bool.test(attr)){
self.each(function(){
if(jQuery(this).prop(attr)!==false){
patchNeeded=true;
return false;
}});
}
if(patchNeeded){
migrateWarn("removeAttr-bool",
"jQuery.fn.removeAttr no longer sets boolean properties: " + attr);
self.prop(attr, false);
}});
return oldRemoveAttr.apply(this, arguments);
}, "removeAttr-bool");
migratePatchFunc(jQuery.fn, "toggleClass", function(state){
if(state!==undefined&&typeof state!=="boolean"){
return oldToggleClass.apply(this, arguments);
}
migrateWarn("toggleClass-bool", "jQuery.fn.toggleClass(boolean) is deprecated");
return this.each(function(){
var className=this.getAttribute&&this.getAttribute("class")||"";
if(className){
jQuery.data(this, "__className__", className);
}
if(this.setAttribute){
this.setAttribute("class",
className||state===false ?
"" :
jQuery.data(this, "__className__")||""
);
}});
}, "toggleClass-bool");
function camelCase(string){
return string.replace(/-([a-z])/g, function(_, letter){
return letter.toUpperCase();
});
}
var origFnCss, internalCssNumber,
internalSwapCall=false,
ralphaStart=/^[a-z]/,
rautoPx=/^(?:Border(?:Top|Right|Bottom|Left)?(?:Width|)|(?:Margin|Padding)?(?:Top|Right|Bottom|Left)?|(?:Min|Max)?(?:Width|Height))$/;
if(jQuery.swap){
jQuery.each([ "height", "width", "reliableMarginRight" ], function(_, name){
var oldHook=jQuery.cssHooks[ name ]&&jQuery.cssHooks[ name ].get;
if(oldHook){
jQuery.cssHooks[ name ].get=function(){
var ret;
internalSwapCall=true;
ret=oldHook.apply(this, arguments);
internalSwapCall=false;
return ret;
};}});
}
migratePatchFunc(jQuery, "swap", function(elem, options, callback, args){
var ret, name,
old={};
if(!internalSwapCall){
migrateWarn("swap", "jQuery.swap() is undocumented and deprecated");
}
for(name in options){
old[ name ]=elem.style[ name ];
elem.style[ name ]=options[ name ];
}
ret=callback.apply(elem, args||[]);
for(name in options){
elem.style[ name ]=old[ name ];
}
return ret;
}, "swap");
if(jQueryVersionSince("3.4.0")&&typeof Proxy!=="undefined"){
jQuery.cssProps=new Proxy(jQuery.cssProps||{}, {
set: function(){
migrateWarn("cssProps", "jQuery.cssProps is deprecated");
return Reflect.set.apply(this, arguments);
}});
}
if(jQueryVersionSince("4.0.0")){
internalCssNumber={
animationIterationCount: true,
columnCount: true,
fillOpacity: true,
flexGrow: true,
flexShrink: true,
fontWeight: true,
gridArea: true,
gridColumn: true,
gridColumnEnd: true,
gridColumnStart: true,
gridRow: true,
gridRowEnd: true,
gridRowStart: true,
lineHeight: true,
opacity: true,
order: true,
orphans: true,
widows: true,
zIndex: true,
zoom: true
};
if(typeof Proxy!=="undefined"){
jQuery.cssNumber=new Proxy(internalCssNumber, {
get: function(){
migrateWarn("css-number", "jQuery.cssNumber is deprecated");
return Reflect.get.apply(this, arguments);
},
set: function(){
migrateWarn("css-number", "jQuery.cssNumber is deprecated");
return Reflect.set.apply(this, arguments);
}});
}else{
jQuery.cssNumber=internalCssNumber;
}}else{
internalCssNumber=jQuery.cssNumber;
}
function isAutoPx(prop){
return ralphaStart.test(prop) &&
rautoPx.test(prop[ 0 ].toUpperCase() + prop.slice(1));
}
origFnCss=jQuery.fn.css;
migratePatchFunc(jQuery.fn, "css", function(name, value){
var camelName,
origThis=this;
if(name&&typeof name==="object"&&!Array.isArray(name)){
jQuery.each(name, function(n, v){
jQuery.fn.css.call(origThis, n, v);
});
return this;
}
if(typeof value==="number"){
camelName=camelCase(name);
if(!isAutoPx(camelName)&&!internalCssNumber[ camelName ]){
migrateWarn("css-number",
"Number-typed values are deprecated for jQuery.fn.css(\"" +
name + "\", value)");
}}
return origFnCss.apply(this, arguments);
}, "css-number");
var origData=jQuery.data;
migratePatchFunc(jQuery, "data", function(elem, name, value){
var curData, sameKeys, key;
if(name&&typeof name==="object"&&arguments.length===2){
curData=jQuery.hasData(elem)&&origData.call(this, elem);
sameKeys={};
for(key in name){
if(key!==camelCase(key)){
migrateWarn("data-camelCase",
"jQuery.data() always sets/gets camelCased names: " + key);
curData[ key ]=name[ key ];
}else{
sameKeys[ key ]=name[ key ];
}}
origData.call(this, elem, sameKeys);
return name;
}
if(name&&typeof name==="string"&&name!==camelCase(name)){
curData=jQuery.hasData(elem)&&origData.call(this, elem);
if(curData&&name in curData){
migrateWarn("data-camelCase",
"jQuery.data() always sets/gets camelCased names: " + name);
if(arguments.length > 2){
curData[ name ]=value;
}
return curData[ name ];
}}
return origData.apply(this, arguments);
}, "data-camelCase");
if(jQuery.fx){
var intervalValue, intervalMsg,
oldTweenRun=jQuery.Tween.prototype.run,
linearEasing=function(pct){
return pct;
};
migratePatchFunc(jQuery.Tween.prototype, "run", function(){
if(jQuery.easing[ this.easing ].length > 1){
migrateWarn(
"easing-one-arg",
"'jQuery.easing." + this.easing.toString() + "' should use only one argument"
);
jQuery.easing[ this.easing ]=linearEasing;
}
oldTweenRun.apply(this, arguments);
}, "easing-one-arg");
intervalValue=jQuery.fx.interval;
intervalMsg="jQuery.fx.interval is deprecated";
if(window.requestAnimationFrame){
Object.defineProperty(jQuery.fx, "interval", {
configurable: true,
enumerable: true,
get: function(){
if(!window.document.hidden){
migrateWarn("fx-interval", intervalMsg);
}
if(!jQuery.migrateIsPatchEnabled("fx-interval")){
return intervalValue;
}
return intervalValue===undefined ? 13:intervalValue;
},
set: function(newValue){
migrateWarn("fx-interval", intervalMsg);
intervalValue=newValue;
}});
}}
var oldLoad=jQuery.fn.load,
oldEventAdd=jQuery.event.add,
originalFix=jQuery.event.fix;
jQuery.event.props=[];
jQuery.event.fixHooks={};
migrateWarnProp(jQuery.event.props, "concat", jQuery.event.props.concat,
"event-old-patch",
"jQuery.event.props.concat() is deprecated and removed");
migratePatchFunc(jQuery.event, "fix", function(originalEvent){
var event,
type=originalEvent.type,
fixHook=this.fixHooks[ type ],
props=jQuery.event.props;
if(props.length){
migrateWarn("event-old-patch",
"jQuery.event.props are deprecated and removed: " + props.join());
while(props.length){
jQuery.event.addProp(props.pop());
}}
if(fixHook&&!fixHook._migrated_){
fixHook._migrated_=true;
migrateWarn("event-old-patch",
"jQuery.event.fixHooks are deprecated and removed: " + type);
if(( props=fixHook.props)&&props.length){
while(props.length){
jQuery.event.addProp(props.pop());
}}
}
event=originalFix.call(this, originalEvent);
return fixHook&&fixHook.filter ?
fixHook.filter(event, originalEvent) :
event;
}, "event-old-patch");
migratePatchFunc(jQuery.event, "add", function(elem, types){
if(elem===window&&types==="load"&&window.document.readyState==="complete"){
migrateWarn("load-after-event",
"jQuery(window).on('load'...) called after load event occurred");
}
return oldEventAdd.apply(this, arguments);
}, "load-after-event");
jQuery.each([ "load", "unload", "error" ], function(_, name){
migratePatchFunc(jQuery.fn, name, function(){
var args=Array.prototype.slice.call(arguments, 0);
if(name==="load"&&typeof args[ 0 ]==="string"){
return oldLoad.apply(this, args);
}
migrateWarn("shorthand-removed-v3",
"jQuery.fn." + name + "() is deprecated");
args.splice(0, 0, name);
if(arguments.length){
return this.on.apply(this, args);
}
this.triggerHandler.apply(this, args);
return this;
}, "shorthand-removed-v3");
});
jQuery.each(( "blur focus focusin focusout resize scroll click dblclick " +
"mousedown mouseup mousemove mouseover mouseout mouseenter mouseleave " +
"change select submit keydown keypress keyup contextmenu").split(" "),
function(_i, name){
migratePatchAndWarnFunc(jQuery.fn, name, function(data, fn){
return arguments.length > 0 ?
this.on(name, null, data, fn) :
this.trigger(name);
},
"shorthand-deprecated-v3",
"jQuery.fn." + name + "() event shorthand is deprecated");
});
jQuery(function(){
jQuery(window.document).triggerHandler("ready");
});
jQuery.event.special.ready={
setup: function(){
if(this===window.document){
migrateWarn("ready-event", "'ready' event is deprecated");
}}
};
migratePatchAndWarnFunc(jQuery.fn, "bind", function(types, data, fn){
return this.on(types, null, data, fn);
}, "pre-on-methods", "jQuery.fn.bind() is deprecated");
migratePatchAndWarnFunc(jQuery.fn, "unbind", function(types, fn){
return this.off(types, null, fn);
}, "pre-on-methods", "jQuery.fn.unbind() is deprecated");
migratePatchAndWarnFunc(jQuery.fn, "delegate", function(selector, types, data, fn){
return this.on(types, selector, data, fn);
}, "pre-on-methods", "jQuery.fn.delegate() is deprecated");
migratePatchAndWarnFunc(jQuery.fn, "undelegate", function(selector, types, fn){
return arguments.length===1 ?
this.off(selector, "**") :
this.off(types, selector||"**", fn);
}, "pre-on-methods", "jQuery.fn.undelegate() is deprecated");
migratePatchAndWarnFunc(jQuery.fn, "hover", function(fnOver, fnOut){
return this.on("mouseenter", fnOver).on("mouseleave", fnOut||fnOver);
}, "pre-on-methods", "jQuery.fn.hover() is deprecated");
var rxhtmlTag=/<(?!area|br|col|embed|hr|img|input|link|meta|param)(([a-z][^\/\0>\x20\t\r\n\f]*)[^>]*)\/>/gi,
makeMarkup=function(html){
var doc=window.document.implementation.createHTMLDocument("");
doc.body.innerHTML=html;
return doc.body&&doc.body.innerHTML;
},
warnIfChanged=function(html){
var changed=html.replace(rxhtmlTag, "<$1></$2>");
if(changed!==html&&makeMarkup(html)!==makeMarkup(changed)){
migrateWarn("self-closed-tags",
"HTML tags must be properly nested and closed: " + html);
}};
jQuery.UNSAFE_restoreLegacyHtmlPrefilter=function(){
jQuery.migrateEnablePatches("self-closed-tags");
};
migratePatchFunc(jQuery, "htmlPrefilter", function(html){
warnIfChanged(html);
return html.replace(rxhtmlTag, "<$1></$2>");
}, "self-closed-tags");
jQuery.migrateDisablePatches("self-closed-tags");
var origOffset=jQuery.fn.offset;
migratePatchFunc(jQuery.fn, "offset", function(){
var elem=this[ 0 ];
if(elem&&(!elem.nodeType||!elem.getBoundingClientRect)){
migrateWarn("offset-valid-elem", "jQuery.fn.offset() requires a valid DOM element");
return arguments.length ? this:undefined;
}
return origOffset.apply(this, arguments);
}, "offset-valid-elem");
if(jQuery.ajax){
var origParam=jQuery.param;
migratePatchFunc(jQuery, "param", function(data, traditional){
var ajaxTraditional=jQuery.ajaxSettings&&jQuery.ajaxSettings.traditional;
if(traditional===undefined&&ajaxTraditional){
migrateWarn("param-ajax-traditional",
"jQuery.param() no longer uses jQuery.ajaxSettings.traditional");
traditional=ajaxTraditional;
}
return origParam.call(this, data, traditional);
}, "param-ajax-traditional");
}
migratePatchAndWarnFunc(jQuery.fn, "andSelf", jQuery.fn.addBack, "andSelf",
"jQuery.fn.andSelf() is deprecated and removed, use jQuery.fn.addBack()");
if(jQuery.Deferred){
var oldDeferred=jQuery.Deferred,
tuples=[
[ "resolve", "done", jQuery.Callbacks("once memory"),
jQuery.Callbacks("once memory"), "resolved" ],
[ "reject", "fail", jQuery.Callbacks("once memory"),
jQuery.Callbacks("once memory"), "rejected" ],
[ "notify", "progress", jQuery.Callbacks("memory"),
jQuery.Callbacks("memory") ]
];
migratePatchFunc(jQuery, "Deferred", function(func){
var deferred=oldDeferred(),
promise=deferred.promise();
function newDeferredPipe(){
var fns=arguments;
return jQuery.Deferred(function(newDefer){
jQuery.each(tuples, function(i, tuple){
var fn=typeof fns[ i ]==="function"&&fns[ i ];
deferred[ tuple[ 1 ] ](function(){
var returned=fn&&fn.apply(this, arguments);
if(returned&&typeof returned.promise==="function"){
returned.promise()
.done(newDefer.resolve)
.fail(newDefer.reject)
.progress(newDefer.notify);
}else{
newDefer[ tuple[ 0 ] + "With" ](
this===promise ? newDefer.promise():this,
fn ? [ returned ]:arguments
);
}});
});
fns=null;
}).promise();
}
migratePatchAndWarnFunc(deferred, "pipe", newDeferredPipe, "deferred-pipe",
"deferred.pipe() is deprecated");
migratePatchAndWarnFunc(promise, "pipe", newDeferredPipe, "deferred-pipe",
"deferred.pipe() is deprecated");
if(func){
func.call(deferred, deferred);
}
return deferred;
}, "deferred-pipe");
jQuery.Deferred.exceptionHook=oldDeferred.exceptionHook;
}
return jQuery;
});
;(function(){
"use strict";
function setup($){
$.fn._fadeIn=$.fn.fadeIn;
var noOp=$.noop||function(){};
var msie=/MSIE/.test(navigator.userAgent);
var ie6=/MSIE 6.0/.test(navigator.userAgent)&&! /MSIE 8.0/.test(navigator.userAgent);
var mode=document.documentMode||0;
var setExpr='function'===typeof document.createElement('div').style.setExpression ? document.createElement('div').style.setExpression:false;
$.blockUI=function(opts){ install(window, opts); };
$.unblockUI=function(opts){ remove(window, opts); };
$.growlUI=function(title, message, timeout, onClose){
var $m=$('<div class="growlUI"></div>');
if(title) $m.append('<h1>'+title+'</h1>');
if(message) $m.append('<h2>'+message+'</h2>');
if(timeout===undefined) timeout=3000;
var callBlock=function(opts){
opts=opts||{};
$.blockUI({
message: $m,
fadeIn:typeof opts.fadeIn!=='undefined' ? opts.fadeIn:700,
fadeOut: typeof opts.fadeOut!=='undefined' ? opts.fadeOut:1000,
timeout: typeof opts.timeout!=='undefined' ? opts.timeout:timeout,
centerY: false,
showOverlay: false,
onUnblock: onClose,
css: $.blockUI.defaults.growlCSS
});
};
callBlock();
var nonmousedOpacity=$m.css('opacity');
$m.on('mouseover', function(){
callBlock({
fadeIn: 0,
timeout: 30000
});
var displayBlock=$('.blockMsg');
displayBlock.stop();
displayBlock.fadeTo(300, 1);
}).on('mouseout', function(){
$('.blockMsg').fadeOut(1000);
});
};
$.fn.block=function(opts){
if(this[0]===window){
$.blockUI(opts);
return this;
}
var fullOpts=$.extend({}, $.blockUI.defaults, opts||{});
this.each(function(){
var $el=$(this);
if(fullOpts.ignoreIfBlocked&&$el.data('blockUI.isBlocked'))
return;
$el.unblock({ fadeOut: 0 });
});
return this.each(function(){
if($.css(this,'position')=='static'){
this.style.position='relative';
$(this).data('blockUI.static', true);
}
this.style.zoom=1;
install(this, opts);
});
};
$.fn.unblock=function(opts){
if(this[0]===window){
$.unblockUI(opts);
return this;
}
return this.each(function(){
remove(this, opts);
});
};
$.blockUI.version=2.70;
$.blockUI.defaults={
message:  '<h1>Please wait...</h1>',
title: null,
draggable: true,
theme: false,
css: {
padding:	0,
margin:		0,
width:		'30%',
top:		'40%',
left:		'35%',
textAlign:	'center',
color:		'#000',
border:		'3px solid #aaa',
backgroundColor:'#fff',
cursor:		'wait'
},
themedCSS: {
width:	'30%',
top:	'40%',
left:	'35%'
},
overlayCSS:  {
backgroundColor:	'#000',
opacity:			0.6,
cursor:				'wait'
},
cursorReset: 'default',
growlCSS: {
width:		'350px',
top:		'10px',
left:		'',
right:		'10px',
border:		'none',
padding:	'5px',
opacity:	0.6,
cursor:		'default',
color:		'#fff',
backgroundColor: '#000',
'-webkit-border-radius':'10px',
'-moz-border-radius':	'10px',
'border-radius':		'10px'
},
iframeSrc: /^https/i.test(window.location.href||'') ? 'javascript:false':'about:blank',
forceIframe: false,
baseZ: 1000,
centerX: true,
centerY: true,
allowBodyStretch: true,
bindEvents: true,
constrainTabKey: true,
fadeIn:  200,
fadeOut:  400,
timeout: 0,
showOverlay: true,
focusInput: true,
focusableElements: ':input:enabled:visible',
onBlock: null,
onUnblock: null,
onOverlayClick: null,
quirksmodeOffsetHack: 4,
blockMsgClass: 'blockMsg',
ignoreIfBlocked: false
};
var pageBlock=null;
var pageBlockEls=[];
function install(el, opts){
var css, themedCSS;
var full=(el==window);
var msg=(opts&&opts.message!==undefined ? opts.message:undefined);
opts=$.extend({}, $.blockUI.defaults, opts||{});
if(opts.ignoreIfBlocked&&$(el).data('blockUI.isBlocked'))
return;
opts.overlayCSS=$.extend({}, $.blockUI.defaults.overlayCSS, opts.overlayCSS||{});
css=$.extend({}, $.blockUI.defaults.css, opts.css||{});
if(opts.onOverlayClick)
opts.overlayCSS.cursor='pointer';
themedCSS=$.extend({}, $.blockUI.defaults.themedCSS, opts.themedCSS||{});
msg=msg===undefined ? opts.message:msg;
if(full&&pageBlock)
remove(window, {fadeOut:0});
if(msg&&typeof msg!='string'&&(msg.parentNode||msg.jquery)){
var node=msg.jquery ? msg[0]:msg;
var data={};
$(el).data('blockUI.history', data);
data.el=node;
data.parent=node.parentNode;
data.display=node.style.display;
data.position=node.style.position;
if(data.parent)
data.parent.removeChild(node);
}
$(el).data('blockUI.onUnblock', opts.onUnblock);
var z=opts.baseZ;
var lyr1, lyr2, lyr3, s;
if(msie||opts.forceIframe)
lyr1=$('<iframe class="blockUI" style="z-index:'+ (z++) +';display:none;border:none;margin:0;padding:0;position:absolute;width:100%;height:100%;top:0;left:0" src="'+opts.iframeSrc+'"></iframe>');
else
lyr1=$('<div class="blockUI" style="display:none"></div>');
if(opts.theme)
lyr2=$('<div class="blockUI blockOverlay ui-widget-overlay" style="z-index:'+ (z++) +';display:none"></div>');
else
lyr2=$('<div class="blockUI blockOverlay" style="z-index:'+ (z++) +';display:none;border:none;margin:0;padding:0;width:100%;height:100%;top:0;left:0"></div>');
if(opts.theme&&full){
s='<div class="blockUI ' + opts.blockMsgClass + ' blockPage ui-dialog ui-widget ui-corner-all" style="z-index:'+(z+10)+';display:none;position:fixed">';
if(opts.title){
s +='<div class="ui-widget-header ui-dialog-titlebar ui-corner-all blockTitle">'+(opts.title||'&nbsp;')+'</div>';
}
s +='<div class="ui-widget-content ui-dialog-content"></div>';
s +='</div>';
}
else if(opts.theme){
s='<div class="blockUI ' + opts.blockMsgClass + ' blockElement ui-dialog ui-widget ui-corner-all" style="z-index:'+(z+10)+';display:none;position:absolute">';
if(opts.title){
s +='<div class="ui-widget-header ui-dialog-titlebar ui-corner-all blockTitle">'+(opts.title||'&nbsp;')+'</div>';
}
s +='<div class="ui-widget-content ui-dialog-content"></div>';
s +='</div>';
}
else if(full){
s='<div class="blockUI ' + opts.blockMsgClass + ' blockPage" style="z-index:'+(z+10)+';display:none;position:fixed"></div>';
}else{
s='<div class="blockUI ' + opts.blockMsgClass + ' blockElement" style="z-index:'+(z+10)+';display:none;position:absolute"></div>';
}
lyr3=$(s);
if(msg){
if(opts.theme){
lyr3.css(themedCSS);
lyr3.addClass('ui-widget-content');
}
else
lyr3.css(css);
}
if(!opts.theme )
lyr2.css(opts.overlayCSS);
lyr2.css('position', full ? 'fixed':'absolute');
if(msie||opts.forceIframe)
lyr1.css('opacity',0.0);
var layers=[lyr1,lyr2,lyr3], $par=full ? $('body'):$(el);
$.each(layers, function(){
this.appendTo($par);
});
if(opts.theme&&opts.draggable&&$.fn.draggable){
lyr3.draggable({
handle: '.ui-dialog-titlebar',
cancel: 'li'
});
}
var expr=setExpr&&(!$.support.boxModel||$('object,embed', full ? null:el).length > 0);
if(ie6||expr){
if(full&&opts.allowBodyStretch&&$.support.boxModel)
$('html,body').css('height','100%');
if((ie6||!$.support.boxModel)&&!full){
var t=sz(el,'borderTopWidth'), l=sz(el,'borderLeftWidth');
var fixT=t ? '(0 - '+t+')':0;
var fixL=l ? '(0 - '+l+')':0;
}
$.each(layers, function(i,o){
var s=o[0].style;
s.position='absolute';
if(i < 2){
if(full)
s.setExpression('height','Math.max(document.body.scrollHeight, document.body.offsetHeight) - (jQuery.support.boxModel?0:'+opts.quirksmodeOffsetHack+') + "px"');
else
s.setExpression('height','this.parentNode.offsetHeight + "px"');
if(full)
s.setExpression('width','jQuery.support.boxModel&&document.documentElement.clientWidth||document.body.clientWidth + "px"');
else
s.setExpression('width','this.parentNode.offsetWidth + "px"');
if(fixL) s.setExpression('left', fixL);
if(fixT) s.setExpression('top', fixT);
}
else if(opts.centerY){
if(full) s.setExpression('top','(document.documentElement.clientHeight||document.body.clientHeight) / 2 - (this.offsetHeight / 2) + (blah=document.documentElement.scrollTop ? document.documentElement.scrollTop:document.body.scrollTop) + "px"');
s.marginTop=0;
}
else if(!opts.centerY&&full){
var top=(opts.css&&opts.css.top) ? parseInt(opts.css.top, 10):0;
var expression='((document.documentElement.scrollTop ? document.documentElement.scrollTop:document.body.scrollTop) + '+top+') + "px"';
s.setExpression('top',expression);
}});
}
if(msg){
if(opts.theme)
lyr3.find('.ui-widget-content').append(msg);
else
lyr3.append(msg);
if(msg.jquery||msg.nodeType)
$(msg).show();
}
if((msie||opts.forceIframe)&&opts.showOverlay)
lyr1.show();
if(opts.fadeIn){
var cb=opts.onBlock ? opts.onBlock:noOp;
var cb1=(opts.showOverlay&&!msg) ? cb:noOp;
var cb2=msg ? cb:noOp;
if(opts.showOverlay)
lyr2._fadeIn(opts.fadeIn, cb1);
if(msg)
lyr3._fadeIn(opts.fadeIn, cb2);
}else{
if(opts.showOverlay)
lyr2.show();
if(msg)
lyr3.show();
if(opts.onBlock)
opts.onBlock.bind(lyr3)();
}
bind(1, el, opts);
if(full){
pageBlock=lyr3[0];
pageBlockEls=$(opts.focusableElements,pageBlock);
if(opts.focusInput)
setTimeout(focus, 20);
}
else
center(lyr3[0], opts.centerX, opts.centerY);
if(opts.timeout){
var to=setTimeout(function(){
if(full)
$.unblockUI(opts);
else
$(el).unblock(opts);
}, opts.timeout);
$(el).data('blockUI.timeout', to);
}}
function remove(el, opts){
var count;
var full=(el==window);
var $el=$(el);
var data=$el.data('blockUI.history');
var to=$el.data('blockUI.timeout');
if(to){
clearTimeout(to);
$el.removeData('blockUI.timeout');
}
opts=$.extend({}, $.blockUI.defaults, opts||{});
bind(0, el, opts);
if(opts.onUnblock===null){
opts.onUnblock=$el.data('blockUI.onUnblock');
$el.removeData('blockUI.onUnblock');
}
var els;
if(full)
els=$(document.body).children().filter('.blockUI').add('body > .blockUI');
else
els=$el.find('>.blockUI');
if(opts.cursorReset){
if(els.length > 1)
els[1].style.cursor=opts.cursorReset;
if(els.length > 2)
els[2].style.cursor=opts.cursorReset;
}
if(full)
pageBlock=pageBlockEls=null;
if(opts.fadeOut){
count=els.length;
els.stop().fadeOut(opts.fadeOut, function(){
if(--count===0)
reset(els,data,opts,el);
});
}
else
reset(els, data, opts, el);
}
function reset(els,data,opts,el){
var $el=$(el);
if($el.data('blockUI.isBlocked'))
return;
els.each(function(i,o){
if(this.parentNode)
this.parentNode.removeChild(this);
});
if(data&&data.el){
data.el.style.display=data.display;
data.el.style.position=data.position;
data.el.style.cursor='default';
if(data.parent)
data.parent.appendChild(data.el);
$el.removeData('blockUI.history');
}
if($el.data('blockUI.static')){
$el.css('position', 'static');
}
if(typeof opts.onUnblock=='function')
opts.onUnblock(el,opts);
var body=$(document.body), w=body.width(), cssW=body[0].style.width;
body.width(w-1).width(w);
body[0].style.width=cssW;
}
function bind(b, el, opts){
var full=el==window, $el=$(el);
if(!b&&(full&&!pageBlock||!full&&!$el.data('blockUI.isBlocked')))
return;
$el.data('blockUI.isBlocked', b);
if(!full||!opts.bindEvents||(b&&!opts.showOverlay))
return;
var events='mousedown mouseup keydown keypress keyup touchstart touchend touchmove';
if(b)
$(document).on(events, opts, handler);
else
$(document).off(events, handler);
}
function handler(e){
if(e.type==='keydown'&&e.keyCode&&e.keyCode==9){
if(pageBlock&&e.data.constrainTabKey){
var els=pageBlockEls;
var fwd = !e.shiftKey&&e.target===els[els.length-1];
var back=e.shiftKey&&e.target===els[0];
if(fwd||back){
setTimeout(function(){focus(back);},10);
return false;
}}
}
var opts=e.data;
var target=$(e.target);
if(target.hasClass('blockOverlay')&&opts.onOverlayClick)
opts.onOverlayClick(e);
if(target.parents('div.' + opts.blockMsgClass).length > 0)
return true;
return target.parents().children().filter('div.blockUI').length===0;
}
function focus(back){
if(!pageBlockEls)
return;
var e=pageBlockEls[back===true ? pageBlockEls.length-1:0];
if(e)
e.trigger('focus');
}
function center(el, x, y){
var p=el.parentNode, s=el.style;
var l=((p.offsetWidth - el.offsetWidth)/2) - sz(p,'borderLeftWidth');
var t=((p.offsetHeight - el.offsetHeight)/2) - sz(p,'borderTopWidth');
if(x) s.left=l > 0 ? (l+'px'):'0';
if(y) s.top=t > 0 ? (t+'px'):'0';
}
function sz(el, p){
return parseInt($.css(el,p),10)||0;
}}
if(typeof define==='function'&&define.amd&&define.amd.jQuery){
define(['jquery'], setup);
}else{
setup(jQuery);
}})();
jQuery(function($){
if(typeof wc_add_to_cart_params==='undefined'){
return false;
}
var AddToCartHandler=function(){
this.requests=[];
this.addRequest=this.addRequest.bind(this);
this.run=this.run.bind(this);
this.$liveRegion=this.createLiveRegion();
$(document.body)
.on('click', '.add_to_cart_button:not(.wc-interactive)', { addToCartHandler: this }, this.onAddToCart)
.on('keydown', '.add_to_cart_button:not(.wc-interactive)', { addToCartHandler: this },
(e)=> { if(e.key===' '){ e.preventDefault(); e.target.click(); }}
)
.on('click', '.remove_from_cart_button', { addToCartHandler: this }, this.onRemoveFromCart)
.on('keydown', '.remove_from_cart_button', this.onKeydownRemoveFromCart)
.on('added_to_cart', { addToCartHandler: this }, this.onAddedToCart)
.on('removed_from_cart', { addToCartHandler: this }, this.onRemovedFromCart)
.on('ajax_request_not_sent.adding_to_cart', this.updateButton);
};
AddToCartHandler.prototype.addRequest=function(request){
this.requests.push(request);
if(1===this.requests.length){
this.run();
}};
AddToCartHandler.prototype.run=function(){
var requestManager=this,
originalCallback=requestManager.requests[0].complete;
requestManager.requests[0].complete=function(){
if(typeof originalCallback==='function'){
originalCallback();
}
requestManager.requests.shift();
if(requestManager.requests.length > 0){
requestManager.run();
}};
$.ajax(this.requests[0]);
};
AddToCartHandler.prototype.onAddToCart=function(e){
var $thisbutton=$(this);
if($thisbutton.is('.ajax_add_to_cart')){
if(! $thisbutton.attr('data-product_id')){
return true;
}
e.data.addToCartHandler.$liveRegion
.text('')
.removeAttr('aria-relevant');
e.preventDefault();
$thisbutton.removeClass('added');
$thisbutton.addClass('loading');
if(false===$(document.body).triggerHandler('should_send_ajax_request.adding_to_cart', [ $thisbutton ])){
$(document.body).trigger('ajax_request_not_sent.adding_to_cart', [ false, false, $thisbutton ]);
return true;
}
var data={};
$.each($thisbutton.data(), function(key, value){
data[ key ]=value;
});
$.each($thisbutton[0].dataset, function(key, value){
data[ key ]=value;
});
$(document.body).trigger('adding_to_cart', [ $thisbutton, data ]);
e.data.addToCartHandler.addRequest({
type: 'POST',
url: wc_add_to_cart_params.wc_ajax_url.toString().replace('%%endpoint%%', 'add_to_cart'),
data: data,
success: function(response){
if(! response){
return;
}
if(response.error&&response.product_url){
window.location=response.product_url;
return;
}
if(wc_add_to_cart_params.cart_redirect_after_add==='yes'){
window.location=wc_add_to_cart_params.cart_url;
return;
}
$(document.body).trigger('added_to_cart', [ response.fragments, response.cart_hash, $thisbutton ]);
},
dataType: 'json'
});
}};
AddToCartHandler.prototype.onRemoveFromCart=function(e){
var $thisbutton=$(this),
$row=$thisbutton.closest('.woocommerce-mini-cart-item');
e.data.addToCartHandler.$liveRegion
.text('')
.removeAttr('aria-relevant');
e.preventDefault();
$row.block({
message: null,
overlayCSS: {
opacity: 0.6
}});
e.data.addToCartHandler.addRequest({
type: 'POST',
url: wc_add_to_cart_params.wc_ajax_url.toString().replace('%%endpoint%%', 'remove_from_cart'),
data: {
cart_item_key:$thisbutton.data('cart_item_key')
},
success: function(response){
if(! response||! response.fragments){
window.location=$thisbutton.attr('href');
return;
}
$(document.body).trigger('removed_from_cart', [ response.fragments, response.cart_hash, $thisbutton ]);
},
error: function(){
window.location=$thisbutton.attr('href');
return;
},
dataType: 'json'
});
};
AddToCartHandler.prototype.onKeydownRemoveFromCart=function(event){
if(event.key===' '){
event.preventDefault();
$(this).trigger('click');
}};
AddToCartHandler.prototype.updateButton=function(e, fragments, cart_hash, $button){
$button=typeof $button==='undefined' ? false:$button;
if($button){
$button.removeClass('loading');
if(fragments){
$button.addClass('added');
}
if(fragments&&! wc_add_to_cart_params.is_cart&&$button.parent().find('.added_to_cart').length===0){
var anchor=document.createElement('a');
anchor.href=wc_add_to_cart_params.cart_url;
anchor.className='added_to_cart wc-forward';
anchor.title=wc_add_to_cart_params.i18n_view_cart;
anchor.textContent=wc_add_to_cart_params.i18n_view_cart;
$button.after(anchor);
}
$(document.body).trigger('wc_cart_button_updated', [ $button ]);
}};
AddToCartHandler.prototype.updateFragments=function(e, fragments){
if(fragments){
$.each(fragments, function(key){
$(key)
.addClass('updating')
.fadeTo('400', '0.6')
.block({
message: null,
overlayCSS: {
opacity: 0.6
}});
});
$.each(fragments, function(key, value){
$(key).replaceWith(value);
$(key).stop(true).css('opacity', '1').unblock();
});
$(document.body).trigger('wc_fragments_loaded');
}};
AddToCartHandler.prototype.alertCartUpdated=function(e, fragments, cart_hash, $button){
$button=typeof $button==='undefined' ? false:$button;
if($button){
var message=$button.data('success_message');
if(!message){
return;
}
e.data.addToCartHandler.$liveRegion
.delay(1000)
.text(message)
.attr('aria-relevant', 'all');
}};
AddToCartHandler.prototype.createLiveRegion=function(){
var existingLiveRegion=$('.widget_shopping_cart_live_region');
if(existingLiveRegion.length){
return existingLiveRegion;
}
return $('<div class="widget_shopping_cart_live_region screen-reader-text" role="status"></div>').appendTo('body');
};
AddToCartHandler.prototype.onAddedToCart=function(e, fragments, cart_hash, $button){
e.data.addToCartHandler.updateButton(e, fragments, cart_hash, $button);
e.data.addToCartHandler.updateFragments(e, fragments);
e.data.addToCartHandler.alertCartUpdated(e, fragments, cart_hash, $button);
};
AddToCartHandler.prototype.onRemovedFromCart=function(e, fragments, cart_hash, $button){
e.data.addToCartHandler.updateFragments(e, fragments);
e.data.addToCartHandler.alertCartUpdated(e, fragments, cart_hash, $button);
};
new AddToCartHandler();
});
(function ($){
var defaults={
url: false,
callback: false,
target: false,
duration: 120,
on: 'mouseover',
touch: true,
onZoomIn: false,
onZoomOut: false,
magnify: 1
};
$.zoom=function(target, source, img, magnify){
var targetHeight,
targetWidth,
sourceHeight,
sourceWidth,
xRatio,
yRatio,
offset,
$target=$(target),
position=$target.css('position'),
$source=$(source);
target.style.position=/(absolute|fixed)/.test(position) ? position:'relative';
target.style.overflow='hidden';
img.style.width=img.style.height='';
$(img)
.addClass('zoomImg')
.css({
position: 'absolute',
top: 0,
left: 0,
opacity: 0,
width: img.width * magnify,
height: img.height * magnify,
border: 'none',
maxWidth: 'none',
maxHeight: 'none'
})
.appendTo(target);
return {
init: function(){
targetWidth=$target.outerWidth();
targetHeight=$target.outerHeight();
if(source===target){
sourceWidth=targetWidth;
sourceHeight=targetHeight;
}else{
sourceWidth=$source.outerWidth();
sourceHeight=$source.outerHeight();
}
xRatio=(img.width - targetWidth) / sourceWidth;
yRatio=(img.height - targetHeight) / sourceHeight;
offset=$source.offset();
},
move: function (e){
var left=(e.pageX - offset.left),
top=(e.pageY - offset.top);
top=Math.max(Math.min(top, sourceHeight), 0);
left=Math.max(Math.min(left, sourceWidth), 0);
img.style.left=(left * -xRatio) + 'px';
img.style.top=(top * -yRatio) + 'px';
}};};
$.fn.zoom=function (options){
return this.each(function (){
var
settings=$.extend({}, defaults, options||{}),
target=settings.target&&$(settings.target)[0]||this,
source=this,
$source=$(source),
img=document.createElement('img'),
$img=$(img),
mousemove='mousemove.zoom',
clicked=false,
touched=false;
if(!settings.url){
var srcElement=source.querySelector('img');
if(srcElement){
settings.url=srcElement.getAttribute('data-src')||srcElement.currentSrc||srcElement.src;
settings.alt=srcElement.getAttribute('data-alt')||srcElement.alt;
}
if(!settings.url){
return;
}}
$source.one('zoom.destroy', function(position, overflow){
$source.off(".zoom");
target.style.position=position;
target.style.overflow=overflow;
img.onload=null;
$img.remove();
}.bind(this, target.style.position, target.style.overflow));
img.onload=function (){
var zoom=$.zoom(target, source, img, settings.magnify);
function start(e){
zoom.init();
zoom.move(e);
$img.stop()
.fadeTo($.support.opacity ? settings.duration:0, 1, 'function'===typeof settings.onZoomIn ? settings.onZoomIn.call(img):false);
}
function stop(){
$img.stop()
.fadeTo(settings.duration, 0, 'function'===typeof settings.onZoomOut ? settings.onZoomOut.call(img):false);
}
if(settings.on==='grab'){
$source
.on('mousedown.zoom',
function (e){
if(e.which===1){
$(document).one('mouseup.zoom',
function (){
stop();
$(document).off(mousemove, zoom.move);
}
);
start(e);
$(document).on(mousemove, zoom.move);
e.preventDefault();
}}
);
}else if(settings.on==='click'){
$source.on('click.zoom',
function (e){
if(clicked){
return;
}else{
clicked=true;
start(e);
$(document).on(mousemove, zoom.move);
$(document).one('click.zoom',
function (){
stop();
clicked=false;
$(document).off(mousemove, zoom.move);
}
);
return false;
}}
);
}else if(settings.on==='toggle'){
$source.on('click.zoom',
function (e){
if(clicked){
stop();
}else{
start(e);
}
clicked = !clicked;
}
);
}else if(settings.on==='mouseover'){
zoom.init();
$source
.on('mouseenter.zoom', start)
.on('mouseleave.zoom', stop)
.on(mousemove, zoom.move);
}
if(settings.touch){
$source
.on('touchstart.zoom', function (e){
e.preventDefault();
if(touched){
touched=false;
stop();
}else{
touched=true;
start(e.originalEvent.touches[0]||e.originalEvent.changedTouches[0]);
}})
.on('touchmove.zoom', function (e){
e.preventDefault();
zoom.move(e.originalEvent.touches[0]||e.originalEvent.changedTouches[0]);
})
.on('touchend.zoom', function (e){
e.preventDefault();
if(touched){
touched=false;
stop();
}});
}
if('function'===typeof settings.callback){
settings.callback.call(img);
}};
img.setAttribute('role', 'presentation');
img.alt=settings.alt||'';
img.src=settings.url;
});
};
$.fn.zoom.defaults=defaults;
}(window.jQuery));
;
(function ($){
var focused=true;
var easings={
swing:  'cubic-bezier(.02, .01, .47, 1)', // https://stackoverflow.com/a/9245729
linear: 'linear',
easeInQuad:     'cubic-bezier(0.11, 0, 0.5, 0)',  // https://easings.net/#easeInQuad
easeOutQuad:    'cubic-bezier(0.5, 1, 0.89, 1)',  // https://easings.net/#easeOutQuad
easeInOutQuad:  'cubic-bezier(0.45, 0, 0.55, 1)', // https://easings.net/#easeInOutQuad
easeInCubic:    'cubic-bezier(0.32, 0, 0.67, 0)', // https://easings.net/#easeInCubic
easeOutCubic:   'cubic-bezier(0.33, 1, 0.68, 1)', // https://easings.net/#easeOutCubic
easeInOutCubic: 'cubic-bezier(0.65, 0, 0.35, 1)', // https://easings.net/#easeInOutCubic
easeInQuart:    'cubic-bezier(0.5, 0, 0.75, 0)',  // https://easings.net/#easeInQuart
easeOutQuart:   'cubic-bezier(0.25, 1, 0.5, 1)',  // https://easings.net/#easeOutQuart
easeInOutQuart: 'cubic-bezier(0.76, 0, 0.24, 1)', // https://easings.net/#easeInOutQuart
easeInQuint:    'cubic-bezier(0.64, 0, 0.78, 0)', // https://easings.net/#easeInQuint
easeOutQuint:   'cubic-bezier(0.22, 1, 0.36, 1)', // https://easings.net/#easeOutQuint
easeInOutQuint: 'cubic-bezier(0.83, 0, 0.17, 1)', // https://easings.net/#easeInOutQuint
easeInSine:     'cubic-bezier(0.12, 0, 0.39, 0)', // https://easings.net/#easeInSine
easeOutSine:    'cubic-bezier(0.61, 1, 0.88, 1)', // https://easings.net/#easeOutSine
easeInOutSine:  'cubic-bezier(0.37, 0, 0.63, 1)', // https://easings.net/#easeInOutSine
easeInExpo:     'cubic-bezier(0.7, 0, 0.84, 0)',  // https://easings.net/#easeInExpo
easeOutExpo:    'cubic-bezier(0.16, 1, 0.3, 1)',  // https://easings.net/#easeOutExpo
easeInOutExpo:  'cubic-bezier(0.87, 0, 0.13, 1)', // https://easings.net/#easeInOutExpo
easeInCirc:     'cubic-bezier(0.55, 0, 1, 0.45)', // https://easings.net/#easeInCirc
easeOutCirc:    'cubic-bezier(0, 0.55, 0.45, 1)', // https://easings.net/#easeOutCirc
easeInOutCirc:  'cubic-bezier(0.85, 0, 0.15, 1)', // https://easings.net/#easeInOutCirc
easeInBack:     'cubic-bezier(0.36, 0, 0.66, -0.56)', // https://easings.net/#easeInBack
easeOutBack:    'cubic-bezier(0.34, 1.56, 0.64, 1)',  // https://easings.net/#easeOutBack
easeInOutBack:  'cubic-bezier(0.68, -0.6, 0.32, 1.6)' // https://easings.net/#easeInOutBack
};
easings['jswing']=easings['swing'];
$.flexslider=function(el, options){
var slider=$(el);
if(typeof options.rtl=='undefined'&&$('html').attr('dir')=='rtl'){
options.rtl=true;
}
slider.vars=$.extend({}, $.flexslider.defaults, options);
var namespace=slider.vars.namespace,
touch=(("ontouchstart" in window)||window.DocumentTouch&&document instanceof DocumentTouch)&&slider.vars.touch,
eventType="click touchend keyup flexslider-click",
watchedEvent="",
watchedEventClearTimer,
easing=easings[slider.vars.easing]||"ease",
vertical=slider.vars.direction==="vertical",
reverse=slider.vars.reverse,
carousel=(slider.vars.itemWidth > 0),
fade=slider.vars.animation==="fade",
asNav=slider.vars.asNavFor!=="",
methods={};
$.data(el, "flexslider", slider);
methods={
init: function(){
slider.animating=false;
slider.currentSlide=parseInt(( slider.vars.startAt ? slider.vars.startAt:0), 10);
if(isNaN(slider.currentSlide)){ slider.currentSlide=0; }
slider.animatingTo=slider.currentSlide;
slider.atEnd=(slider.currentSlide===0||slider.currentSlide===slider.last);
slider.containerSelector=slider.vars.selector.substr(0,slider.vars.selector.search(' '));
slider.slides=$(slider.vars.selector, slider);
slider.container=$(slider.containerSelector, slider);
slider.count=slider.slides.length;
slider.syncExists=$(slider.vars.sync).length > 0;
if(slider.vars.animation==="slide"){ slider.vars.animation="swing"; }
slider.prop=(vertical) ? "top":(slider.vars.rtl ? "marginRight":"marginLeft");
slider.args={};
slider.manualPause=false;
slider.stopped=false;
slider.started=false;
slider.startTimeout=null;
slider.transforms=slider.transitions = !slider.vars.video&&!fade&&slider.vars.useCSS;
if(slider.transforms) slider.prop="transform";
slider.isFirefox=navigator.userAgent.toLowerCase().indexOf('firefox') > -1;
slider.ensureAnimationEnd='';
if(slider.vars.controlsContainer!=="") slider.controlsContainer=$(slider.vars.controlsContainer).length > 0&&$(slider.vars.controlsContainer);
if(slider.vars.manualControls!=="") slider.manualControls=$(slider.vars.manualControls).length > 0&&$(slider.vars.manualControls);
if(slider.vars.customDirectionNav!=="") slider.customDirectionNav=$(slider.vars.customDirectionNav).length===2&&$(slider.vars.customDirectionNav);
if(slider.vars.randomize){
slider.slides.sort(function(){ return (Math.round(Math.random())-0.5); });
slider.container.empty().append(slider.slides);
}
slider.doMath();
slider.setup("init");
if(slider.vars.controlNav){ methods.controlNav.setup(); }
if(slider.vars.directionNav){ methods.directionNav.setup(); }
if(slider.vars.keyboard&&($(slider.containerSelector).length===1||slider.vars.multipleKeyboard)){
$(document).on('keyup', function(event){
var keycode=event.keyCode;
if(!slider.animating&&(keycode===39||keycode===37)){
var target=(slider.vars.rtl?
((keycode===37) ? slider.getTarget('next') :
(keycode===39) ? slider.getTarget('prev'):false)
:
((keycode===39) ? slider.getTarget('next') :
(keycode===37) ? slider.getTarget('prev'):false)
)
;
slider.flexAnimate(target, slider.vars.pauseOnAction);
}});
}
if(slider.vars.mousewheel){
slider.on('mousewheel', function(event, delta, deltaX, deltaY){
event.preventDefault();
var target=(delta < 0) ? slider.getTarget('next'):slider.getTarget('prev');
slider.flexAnimate(target, slider.vars.pauseOnAction);
});
}
if(slider.vars.pausePlay){ methods.pausePlay.setup(); }
if(slider.vars.slideshow&&slider.vars.pauseInvisible){ methods.pauseInvisible(); }
if(slider.vars.slideshow){
if(slider.vars.pauseOnHover){
slider.on('mouseenter', function(){
if(!slider.manualPlay&&!slider.manualPause){ slider.pause(); }}).on('mouseleave', function(){
if(!slider.manualPause&&!slider.manualPlay&&!slider.stopped){ slider.play(); }});
}
if(!slider.vars.pauseInvisible||document.visibilityState==='visible'){
(slider.vars.initDelay > 0) ? slider.startTimeout=setTimeout(slider.play, slider.vars.initDelay):slider.play();
}}
if(asNav){ methods.asNav.setup(); }
if(touch&&slider.vars.touch){ methods.touch(); }
if(!fade||(fade&&slider.vars.smoothHeight)){ $(window).on("resize orientationchange focus", methods.resize); }
slider.find("img").attr("draggable", "false");
setTimeout(function(){
slider.vars.start(slider);
}, 200);
},
asNav: {
setup: function(){
slider.asNav=true;
slider.animatingTo=Math.floor(slider.currentSlide/slider.move);
slider.currentItem=slider.currentSlide;
slider.slides.removeClass(namespace + "active-slide").eq(slider.currentItem).addClass(namespace + "active-slide");
slider.slides.on(eventType, function(e){
e.preventDefault();
var $slide=$(this),
target=$slide.index();
var posFromX;
if(slider.vars.rtl){
posFromX=-1*($slide.offset().right - $(slider).scrollLeft());
}else{
posFromX=$slide.offset().left - $(slider).scrollLeft();
}
if(posFromX <=0&&$slide.hasClass(namespace + 'active-slide')){
slider.flexAnimate(slider.getTarget("prev"), true);
}else if(!$(slider.vars.asNavFor).data('flexslider').animating&&!$slide.hasClass(namespace + "active-slide")){
slider.direction=(slider.currentItem < target) ? "next":"prev";
slider.flexAnimate(target, slider.vars.pauseOnAction, false, true, true);
}});
}},
controlNav: {
setup: function(){
if(!slider.manualControls){
methods.controlNav.setupPaging();
}else{
methods.controlNav.setupManual();
}},
setupPaging: function(){
var type=(slider.vars.controlNav==="thumbnails") ? 'control-thumbs':'control-paging',
j=1,
item,
slide;
slider.controlNavScaffold=$('<ol class="'+ namespace + 'control-nav ' + namespace + type + '"></ol>');
if(slider.pagingCount > 1){
for (var i=0; i < slider.pagingCount; i++){
slide=slider.slides.eq(i);
if(undefined===slide.attr('data-thumb-alt')){
slide.attr('data-thumb-alt', '');
}
item=$('<a></a>').attr('href', '#').text(j);
if(slider.vars.controlNav==="thumbnails"){
item=$('<img/>', {
onload: 'this.width=this.naturalWidth; this.height=this.naturalHeight',
src: slide.attr('data-thumb'),
srcset: slide.attr('data-thumb-srcset'),
sizes: slide.attr('data-thumb-sizes'),
alt: slide.attr('alt')
})
}
if(''!==slide.attr('data-thumb-alt')){
item.attr('alt', slide.attr('data-thumb-alt'));
}
if('thumbnails'===slider.vars.controlNav&&true===slider.vars.thumbCaptions){
var captn=slide.attr('data-thumbcaption');
if(''!==captn&&undefined!==captn){
var caption=$('<span></span>').addClass(namespace + 'caption').text(captn);
item.append(caption);
}}
var liElement=$('<li>');
item.appendTo(liElement);
liElement.append('</li>');
slider.controlNavScaffold.append(liElement);
j++;
}}
(slider.controlsContainer) ? $(slider.controlsContainer).append(slider.controlNavScaffold):slider.append(slider.controlNavScaffold);
methods.controlNav.set();
methods.controlNav.active();
slider.controlNavScaffold.on(eventType, 'a, img', function(event){
event.preventDefault();
if(watchedEvent===""||watchedEvent===event.type||event.type==="flexslider-click"){
var $this=$(this),
target=slider.controlNav.index($this);
if(!$this.hasClass(namespace + 'active')){
slider.direction=(target > slider.currentSlide) ? "next":"prev";
slider.flexAnimate(target, slider.vars.pauseOnAction);
}}
if(watchedEvent===""&&event.type!=="flexslider-click"){
watchedEvent=event.type;
}
methods.setToClearWatchedEvent();
});
},
setupManual: function(){
slider.controlNav=slider.manualControls;
methods.controlNav.active();
slider.controlNav.on(eventType, function(event){
event.preventDefault();
if(watchedEvent===""||watchedEvent===event.type||event.type==="flexslider-click"){
var $this=$(this),
target=slider.controlNav.index($this);
if(!$this.hasClass(namespace + 'active')){
(target > slider.currentSlide) ? slider.direction="next":slider.direction="prev";
slider.flexAnimate(target, slider.vars.pauseOnAction);
}}
if(watchedEvent===""&&event.type!=="flexslider-click"){
watchedEvent=event.type;
}
methods.setToClearWatchedEvent();
});
},
set: function(){
var selector=(slider.vars.controlNav==="thumbnails") ? 'img':'a';
slider.controlNav=$('.' + namespace + 'control-nav li ' + selector, (slider.controlsContainer) ? slider.controlsContainer:slider);
},
active: function(){
slider.controlNav.removeClass(namespace + "active").eq(slider.animatingTo).addClass(namespace + "active");
},
update: function(action, pos){
if(slider.pagingCount > 1&&action==="add"){
slider.controlNavScaffold.append($('<li><a href="#">' + slider.count + '</a></li>'));
}else if(slider.pagingCount===1){
slider.controlNavScaffold.find('li').remove();
}else{
slider.controlNav.eq(pos).closest('li').remove();
}
methods.controlNav.set();
(slider.pagingCount > 1&&slider.pagingCount!==slider.controlNav.length) ? slider.update(pos, action):methods.controlNav.active();
}},
directionNav: {
setup: function(){
var directionNavScaffold=$('<ul class="' + namespace + 'direction-nav"><li class="' + namespace + 'nav-prev"><a class="' + namespace + 'prev" href="#">' + slider.vars.prevText + '</a></li><li class="' + namespace + 'nav-next"><a class="' + namespace + 'next" href="#">' + slider.vars.nextText + '</a></li></ul>');
if(slider.customDirectionNav){
slider.directionNav=slider.customDirectionNav;
}else if(slider.controlsContainer){
$(slider.controlsContainer).append(directionNavScaffold);
slider.directionNav=$('.' + namespace + 'direction-nav li a', slider.controlsContainer);
}else{
slider.append(directionNavScaffold);
slider.directionNav=$('.' + namespace + 'direction-nav li a', slider);
}
methods.directionNav.update();
slider.directionNav.on(eventType, function(event){
event.preventDefault();
var target;
if(watchedEvent===""||watchedEvent===event.type||event.type==="flexslider-click"){
target=($(this).hasClass(namespace + 'next')) ? slider.getTarget('next'):slider.getTarget('prev');
slider.flexAnimate(target, slider.vars.pauseOnAction);
}
if(watchedEvent===""&&event.type!=="flexslider-click"){
watchedEvent=event.type;
}
methods.setToClearWatchedEvent();
});
},
update: function(){
var disabledClass=namespace + 'disabled';
if(slider.pagingCount===1){
slider.directionNav.addClass(disabledClass).attr('tabindex', '-1');
}else if(!slider.vars.animationLoop){
if(slider.animatingTo===0){
slider.directionNav.removeClass(disabledClass).filter('.' + namespace + "prev").addClass(disabledClass).attr('tabindex', '-1');
}else if(slider.animatingTo===slider.last){
slider.directionNav.removeClass(disabledClass).filter('.' + namespace + "next").addClass(disabledClass).attr('tabindex', '-1');
}else{
slider.directionNav.removeClass(disabledClass).prop('tabindex', '-1');
}}else{
slider.directionNav.removeClass(disabledClass).prop('tabindex', '-1');
}}
},
pausePlay: {
setup: function(){
var pausePlayScaffold=$('<div class="' + namespace + 'pauseplay"><a href="#"></a></div>');
if(slider.controlsContainer){
slider.controlsContainer.append(pausePlayScaffold);
slider.pausePlay=$('.' + namespace + 'pauseplay a', slider.controlsContainer);
}else{
slider.append(pausePlayScaffold);
slider.pausePlay=$('.' + namespace + 'pauseplay a', slider);
}
methods.pausePlay.update((slider.vars.slideshow) ? namespace + 'pause':namespace + 'play');
slider.pausePlay.on(eventType, function(event){
event.preventDefault();
if(watchedEvent===""||watchedEvent===event.type||event.type==="flexslider-click"){
if($(this).hasClass(namespace + 'pause')){
slider.manualPause=true;
slider.manualPlay=false;
slider.pause();
}else{
slider.manualPause=false;
slider.manualPlay=true;
slider.play();
}}
if(watchedEvent===""&&event.type!=="flexslider-click"){
watchedEvent=event.type;
}
methods.setToClearWatchedEvent();
});
},
update: function(state){
(state==="play") ? slider.pausePlay.removeClass(namespace + 'pause').addClass(namespace + 'play').html(slider.vars.playText):slider.pausePlay.removeClass(namespace + 'play').addClass(namespace + 'pause').html(slider.vars.pauseText);
}},
touch: function(){
var startX,
startY,
offset,
cwidth,
dx,
startT,
onTouchStart,
onTouchMove,
onTouchEnd,
scrolling=false,
localX=0,
localY=0,
accDx=0;
onTouchStart=function(e){
if(slider.animating){
e.preventDefault();
}else if(e.touches.length===1){
slider.pause();
cwidth=(vertical) ? slider.h:slider. w;
startT=Number(new Date());
localX=e.touches[0].pageX;
localY=e.touches[0].pageY;
offset=(carousel&&reverse&&slider.animatingTo===slider.last) ? 0 :
(carousel&&reverse) ? slider.limit - (((slider.itemW + slider.vars.itemMargin) * slider.move) * slider.animatingTo) :
(carousel&&slider.currentSlide===slider.last) ? slider.limit :
(carousel) ? ((slider.itemW + slider.vars.itemMargin) * slider.move) * slider.currentSlide :
(reverse) ? (slider.last - slider.currentSlide + slider.cloneOffset) * cwidth:(slider.currentSlide + slider.cloneOffset) * cwidth;
startX=(vertical) ? localY:localX;
startY=(vertical) ? localX:localY;
el.addEventListener('touchmove', onTouchMove, false);
el.addEventListener('touchend', onTouchEnd, false);
}};
onTouchMove=function(e){
localX=e.touches[0].pageX;
localY=e.touches[0].pageY;
dx=(vertical) ? startX - localY:(slider.vars.rtl?-1:1)*(startX - localX);
scrolling=(vertical) ? (Math.abs(dx) < Math.abs(localX - startY)):(Math.abs(dx) < Math.abs(localY - startY));
var fxms=500;
if(! scrolling||Number(new Date()) - startT > fxms){
e.preventDefault();
if(!fade){
if(!slider.vars.animationLoop){
dx=dx/((slider.currentSlide===0&&dx < 0||slider.currentSlide===slider.last&&dx > 0) ? (Math.abs(dx)/cwidth+2):1);
}
slider.setProps(offset + dx, "setTouch");
}}
};
onTouchEnd=function(e){
el.removeEventListener('touchmove', onTouchMove, false);
if(slider.animatingTo===slider.currentSlide&&!scrolling&&!(dx===null)){
var updateDx=(reverse) ? -dx:dx,
target=(updateDx > 0) ? slider.getTarget('next'):slider.getTarget('prev');
if(slider.canAdvance(target)&&(Number(new Date()) - startT < 550&&Math.abs(updateDx) > 50||Math.abs(updateDx) > cwidth/2)){
slider.flexAnimate(target, slider.vars.pauseOnAction);
}else{
if(!fade){ slider.flexAnimate(slider.currentSlide, slider.vars.pauseOnAction, true); }}
}
el.removeEventListener('touchend', onTouchEnd, false);
startX=null;
startY=null;
dx=null;
offset=null;
};
el.addEventListener('touchstart', onTouchStart, false);
},
resize: function(){
if(!slider.animating&&slider.is(':visible')){
if(!carousel){ slider.doMath(); }
if(fade){
methods.smoothHeight();
}else if(carousel){
slider.slides.width(slider.computedW);
slider.update(slider.pagingCount);
slider.setProps();
}
else if(vertical){
slider.viewport.height(slider.h);
slider.setProps(slider.h, "setTotal");
}else{
slider.setProps(slider.computedW, "setTotal");
slider.newSlides.width(slider.computedW);
if(slider.vars.smoothHeight){ methods.smoothHeight(); }}
}},
smoothHeight: function(dur){
if(!vertical||fade){
var $obj=(fade) ? slider:slider.viewport;
$obj.css({"height": slider.slides.eq(slider.animatingTo).innerHeight(), "transition": dur ? ("height " + dur + "ms"):"none"});
}},
sync: function(action){
var $obj=$(slider.vars.sync).data("flexslider"),
target=slider.animatingTo;
switch (action){
case "animate": $obj.flexAnimate(target, slider.vars.pauseOnAction, false, true); break;
case "play": if(!$obj.playing&&!$obj.asNav){ $obj.play(); } break;
case "pause": $obj.pause(); break;
}},
uniqueID: function($clone){
$clone.filter('[id]').add($clone.find('[id]')).each(function(){
var $this=$(this);
$this.attr('id', $this.attr('id') + '_clone');
});
return $clone;
},
pauseInvisible: function(){
document.addEventListener('visibilitychange', function(){
if(document.visibilityState==='hidden'){
if(slider.startTimeout){
clearTimeout(slider.startTimeout);
}else{
slider.pause();
}}else{
if(slider.started){
slider.play();
}else{
if(slider.vars.initDelay > 0){
setTimeout(slider.play, slider.vars.initDelay);
}else{
slider.play();
}}
}});
},
setToClearWatchedEvent: function(){
clearTimeout(watchedEventClearTimer);
watchedEventClearTimer=setTimeout(function(){
watchedEvent="";
}, 3000);
}};
slider.flexAnimate=function(target, pause, override, withSync, fromNav){
if(!slider.vars.animationLoop&&target!==slider.currentSlide){
slider.direction=(target > slider.currentSlide) ? "next":"prev";
}
if(asNav&&slider.pagingCount===1) slider.direction=(slider.currentItem < target) ? "next":"prev";
if(!slider.animating&&(slider.canAdvance(target, fromNav)||override)&&slider.is(":visible")){
if(asNav&&withSync){
var master=$(slider.vars.asNavFor).data('flexslider');
slider.atEnd=target===0||target===slider.count - 1;
master.flexAnimate(target, true, false, true, fromNav);
slider.direction=(slider.currentItem < target) ? "next":"prev";
master.direction=slider.direction;
if(Math.ceil((target + 1)/slider.visible) - 1!==slider.currentSlide&&target!==0){
slider.currentItem=target;
slider.slides.removeClass(namespace + "active-slide").eq(target).addClass(namespace + "active-slide");
target=Math.floor(target/slider.visible);
}else{
slider.currentItem=target;
slider.slides.removeClass(namespace + "active-slide").eq(target).addClass(namespace + "active-slide");
return false;
}}
slider.animating=true;
slider.animatingTo=target;
if(pause){ slider.pause(); }
slider.vars.before(slider);
if(slider.syncExists&&!fromNav){ methods.sync("animate"); }
if(slider.vars.controlNav){ methods.controlNav.active(); }
if(!carousel){ slider.slides.removeClass(namespace + 'active-slide').eq(target).addClass(namespace + 'active-slide'); }
slider.atEnd=target===0||target===slider.last;
if(slider.vars.directionNav){ methods.directionNav.update(); }
if(target===slider.last){
slider.vars.end(slider);
if(!slider.vars.animationLoop){ slider.pause(); }}
if(!fade){
var dimension=(vertical) ? slider.slides.filter(':first').height():slider.computedW,
margin, slideString, calcNext;
if(carousel){
margin=slider.vars.itemMargin;
calcNext=((slider.itemW + margin) * slider.move) * slider.animatingTo;
slideString=(calcNext > slider.limit&&slider.visible!==1) ? slider.limit:calcNext;
}else if(slider.currentSlide===0&&target===slider.count - 1&&slider.vars.animationLoop&&slider.direction!=="next"){
slideString=(reverse) ? (slider.count + slider.cloneOffset) * dimension:0;
}else if(slider.currentSlide===slider.last&&target===0&&slider.vars.animationLoop&&slider.direction!=="prev"){
slideString=(reverse) ? 0:(slider.count + 1) * dimension;
}else{
slideString=(reverse) ? ((slider.count - 1) - target + slider.cloneOffset) * dimension:(target + slider.cloneOffset) * dimension;
}
slider.setProps(slideString, "", slider.vars.animationSpeed);
if(!slider.vars.animationLoop||!slider.atEnd){
slider.animating=false;
slider.currentSlide=slider.animatingTo;
}
slider.container.off("transitionend");
slider.container.on("transitionend", function(){
clearTimeout(slider.ensureAnimationEnd);
slider.wrapup(dimension);
});
clearTimeout(slider.ensureAnimationEnd);
slider.ensureAnimationEnd=setTimeout(function(){
slider.wrapup(dimension);
}, slider.vars.animationSpeed + 100);
}else{
if(!touch){
slider.slides.eq(slider.currentSlide).off("transitionend");
slider.slides.eq(target).off("transitionend").on("transitionend", slider.wrapup);
}
slider.slides.eq(slider.currentSlide).css({ "opacity": 0, "zIndex": 1 });
slider.slides.eq(target).css({ "opacity": 1, "zIndex": 2 });
if(touch){
slider.wrapup(dimension);
}}
if(slider.vars.smoothHeight){ methods.smoothHeight(slider.vars.animationSpeed); }}
};
slider.wrapup=function(dimension){
if(!fade&&!carousel){
if(slider.currentSlide===0&&slider.animatingTo===slider.last&&slider.vars.animationLoop){
slider.setProps(dimension, "jumpEnd");
}else if(slider.currentSlide===slider.last&&slider.animatingTo===0&&slider.vars.animationLoop){
slider.setProps(dimension, "jumpStart");
}}
slider.animating=false;
slider.currentSlide=slider.animatingTo;
slider.vars.after(slider);
};
slider.animateSlides=function(){
if(!slider.animating&&focused){ slider.flexAnimate(slider.getTarget("next")); }};
slider.pause=function(){
clearInterval(slider.animatedSlides);
slider.animatedSlides=null;
slider.playing=false;
if(slider.vars.pausePlay){ methods.pausePlay.update("play"); }
if(slider.syncExists){ methods.sync("pause"); }};
slider.play=function(){
if(slider.playing){ clearInterval(slider.animatedSlides); }
slider.animatedSlides=slider.animatedSlides||setInterval(slider.animateSlides, slider.vars.slideshowSpeed);
slider.started=slider.playing=true;
if(slider.vars.pausePlay){ methods.pausePlay.update("pause"); }
if(slider.syncExists){ methods.sync("play"); }};
slider.stop=function (){
slider.pause();
slider.stopped=true;
};
slider.canAdvance=function(target, fromNav){
var last=(asNav) ? slider.pagingCount - 1:slider.last;
return (fromNav) ? true :
(asNav&&slider.currentItem===slider.count - 1&&target===0&&slider.direction==="prev") ? true :
(asNav&&slider.currentItem===0&&target===slider.pagingCount - 1&&slider.direction!=="next") ? false :
(target===slider.currentSlide&&!asNav) ? false :
(slider.vars.animationLoop) ? true :
(slider.atEnd&&slider.currentSlide===0&&target===last&&slider.direction!=="next") ? false :
(slider.atEnd&&slider.currentSlide===last&&target===0&&slider.direction==="next") ? false :
true;
};
slider.getTarget=function(dir){
slider.direction=dir;
if(dir==="next"){
return (slider.currentSlide===slider.last) ? 0:slider.currentSlide + 1;
}else{
return (slider.currentSlide===0) ? slider.last:slider.currentSlide - 1;
}};
slider.setProps=function(pos, special, dur){
var target=(function(){
var posCheck=(pos) ? pos:((slider.itemW + slider.vars.itemMargin) * slider.move) * slider.animatingTo,
posCalc=(function(){
if(carousel){
return (special==="setTouch") ? pos :
(reverse&&slider.animatingTo===slider.last) ? 0 :
(reverse) ? slider.limit - (((slider.itemW + slider.vars.itemMargin) * slider.move) * slider.animatingTo) :
(slider.animatingTo===slider.last) ? slider.limit:posCheck;
}else{
switch (special){
case "setTotal": return (reverse) ? ((slider.count - 1) - slider.currentSlide + slider.cloneOffset) * pos:(slider.currentSlide + slider.cloneOffset) * pos;
case "setTouch": return (reverse) ? pos:pos;
case "jumpEnd": return (reverse) ? pos:slider.count * pos;
case "jumpStart": return (reverse) ? slider.count * pos:pos;
default: return pos;
}}
}());
return (posCalc * ((slider.vars.rtl)?1:-1)) + "px";
}());
dur=(dur!==undefined) ? (dur/1000) + "s":"0s";
slider.container.css("transition-duration", dur);
if(slider.transforms){
target=(vertical) ? "translate3d(0," + target + ",0)":"translate3d(" + (parseInt(target)+'px') + ",0,0)";
}else{
slider.container.css("transition-timing-function", easing);
}
slider.args[slider.prop]=target;
slider.container.css(slider.args);
};
slider.setup=function(type){
if(!fade){
var sliderOffset, arr;
if(type==="init"){
slider.viewport=$('<div class="' + namespace + 'viewport"></div>').css({"overflow": "hidden", "position": "relative"}).appendTo(slider).append(slider.container);
slider.cloneCount=0;
slider.cloneOffset=0;
if(reverse){
arr=$.makeArray(slider.slides).reverse();
slider.slides=$(arr);
slider.container.empty().append(slider.slides);
}}
if(slider.vars.animationLoop&&!carousel){
slider.cloneCount=2;
slider.cloneOffset=1;
if(type!=="init"){ slider.container.find('.clone').remove(); }
slider.container.append(methods.uniqueID(slider.slides.first().clone().addClass('clone')).attr('aria-hidden', 'true'))
.prepend(methods.uniqueID(slider.slides.last().clone().addClass('clone')).attr('aria-hidden', 'true'));
}
slider.newSlides=$(slider.vars.selector, slider);
sliderOffset=(reverse) ? slider.count - 1 - slider.currentSlide + slider.cloneOffset:slider.currentSlide + slider.cloneOffset;
if(vertical&&!carousel){
slider.container.height((slider.count + slider.cloneCount) * 200 + "%").css("position", "absolute").width("100%");
setTimeout(function(){
slider.newSlides.css({"display": "block"});
slider.doMath();
slider.viewport.height(slider.h);
slider.setProps(sliderOffset * slider.h, "init");
}, (type==="init") ? 100:0);
}else{
slider.container.width((slider.count + slider.cloneCount) * 200 + "%");
slider.setProps(sliderOffset * slider.computedW, "init");
setTimeout(function(){
slider.doMath();
if(slider.vars.rtl){
slider.newSlides.css({"width": slider.computedW, "marginRight":slider.computedM, "float": "right", "display": "block"});
}else{
slider.newSlides.css({"width": slider.computedW, "marginRight":slider.computedM, "float": "left", "display": "block"});
}
if(slider.vars.smoothHeight){ methods.smoothHeight(); }}, (type==="init") ? 100:0);
}}else{
if(slider.vars.rtl){
slider.slides.css({"width": "100%", "float": 'right', "marginLeft": "-100%", "position": "relative"});
}else{
slider.slides.css({"width": "100%", "float": 'left', "marginRight": "-100%", "position": "relative"});
}
if(type==="init"){
if(!touch){
if(slider.vars.fadeFirstSlide==false){
slider.slides.css({ "opacity": 0, "display": "block", "zIndex": 1 }).eq(slider.currentSlide).css({ "opacity": 1, "zIndex": 2 });
slider.slides.outerWidth();
}else{
slider.slides.css({ "opacity": 0, "display": "block", "zIndex": 1 }).outerWidth();
slider.slides.eq(slider.currentSlide).css({ "opacity": 1, "zIndex": 2 });
}
slider.slides.css({ "transition": "opacity " + slider.vars.animationSpeed / 1000 + "s " + easing });
}else{
slider.slides.css({ "opacity": 0, "display": "block", "transition": "opacity " + slider.vars.animationSpeed / 1000 + "s ease", "zIndex": 1 }).eq(slider.currentSlide).css({ "opacity": 1, "zIndex": 2 });
}}
if(slider.vars.smoothHeight){ methods.smoothHeight(); }}
if(!carousel){ slider.slides.removeClass(namespace + "active-slide").eq(slider.currentSlide).addClass(namespace + "active-slide"); }
slider.vars.init(slider);
};
slider.doMath=function(){
var slide=slider.slides.first(),
slideMargin=slider.vars.itemMargin,
minItems=slider.vars.minItems,
maxItems=slider.vars.maxItems;
slider.w=(slider.viewport===undefined) ? slider.width():slider.viewport.width();
if(slider.isFirefox){ slider.w=slider.width(); }
slider.h=slide.height();
slider.boxPadding=slide.outerWidth() - slide.width();
if(carousel){
slider.itemT=slider.vars.itemWidth + slideMargin;
slider.itemM=slideMargin;
slider.minW=(minItems) ? minItems * slider.itemT:slider.w;
slider.maxW=(maxItems) ? (maxItems * slider.itemT) - slideMargin:slider.w;
slider.itemW=(slider.minW > slider.w) ? (slider.w - (slideMargin * (minItems - 1)))/minItems :
(slider.maxW < slider.w) ? (slider.w - (slideMargin * (maxItems - 1)))/maxItems :
(slider.vars.itemWidth > slider.w) ? slider.w:slider.vars.itemWidth;
slider.visible=Math.floor(slider.w/(slider.itemW));
slider.move=(slider.vars.move > 0&&slider.vars.move < slider.visible) ? slider.vars.move:slider.visible;
slider.pagingCount=Math.ceil(((slider.count - slider.visible)/slider.move) + 1);
slider.last=slider.pagingCount - 1;
slider.limit=(slider.pagingCount===1) ? 0 :
(slider.vars.itemWidth > slider.w) ? (slider.itemW * (slider.count - 1)) + (slideMargin * (slider.count - 1)):((slider.itemW + slideMargin) * slider.count) - slider.w - slideMargin;
}else{
slider.itemW=slider.w;
slider.itemM=slideMargin;
slider.pagingCount=slider.count;
slider.last=slider.count - 1;
}
slider.computedW=slider.itemW - slider.boxPadding;
slider.computedM=slider.itemM;
};
slider.update=function(pos, action){
slider.doMath();
if(!carousel){
if(pos < slider.currentSlide){
slider.currentSlide +=1;
}else if(pos <=slider.currentSlide&&pos!==0){
slider.currentSlide -=1;
}
slider.animatingTo=slider.currentSlide;
}
if(slider.vars.controlNav&&!slider.manualControls){
if((action==="add"&&!carousel)||slider.pagingCount > slider.controlNav.length){
methods.controlNav.update("add");
}else if((action==="remove"&&!carousel)||slider.pagingCount < slider.controlNav.length){
if(carousel&&slider.currentSlide > slider.last){
slider.currentSlide -=1;
slider.animatingTo -=1;
}
methods.controlNav.update("remove", slider.last);
}}
if(slider.vars.directionNav){ methods.directionNav.update(); }};
slider.addSlide=function(obj, pos){
var $obj=$(obj);
slider.count +=1;
slider.last=slider.count - 1;
if(vertical&&reverse){
(pos!==undefined) ? slider.slides.eq(slider.count - pos).after($obj):slider.container.prepend($obj);
}else{
(pos!==undefined) ? slider.slides.eq(pos).before($obj):slider.container.append($obj);
}
slider.update(pos, "add");
slider.slides=$(slider.vars.selector + ':not(.clone)', slider);
slider.setup();
slider.vars.added(slider);
};
slider.removeSlide=function(obj){
var pos=(isNaN(obj)) ? slider.slides.index($(obj)):obj;
slider.count -=1;
slider.last=slider.count - 1;
if(isNaN(obj)){
$(obj, slider.slides).remove();
}else{
(vertical&&reverse) ? slider.slides.eq(slider.last).remove():slider.slides.eq(obj).remove();
}
slider.doMath();
slider.update(pos, "remove");
slider.slides=$(slider.vars.selector + ':not(.clone)', slider);
slider.setup();
slider.vars.removed(slider);
};
methods.init();
};
$(window).on('blur', function(e){
focused=false;
}).on('focus', function(e){
focused=true;
});
$.flexslider.defaults={
namespace: "flex-",
selector: ".slides > li",
animation: "fade",
easing: "swing",
direction: "horizontal",
reverse: false,
animationLoop: true,
smoothHeight: false,
startAt: 0,
slideshow: true,
slideshowSpeed: 7000,
animationSpeed: 600,
initDelay: 0,
randomize: false,
fadeFirstSlide: true,
thumbCaptions: false,
pauseOnAction: true,
pauseOnHover: false,
pauseInvisible: true,
useCSS: true,
touch: true,
video: false,
controlNav: true,
directionNav: true,
prevText: "Previous",
nextText: "Next",
keyboard: true,
multipleKeyboard: false,
mousewheel: false,              //{UPDATED} Boolean: Requires jquery.mousewheel.js (https://github.com/brandonaaron/jquery-mousewheel) - Allows slider navigating via mousewheel
pausePlay: false,
pauseText: "Pause",
playText: "Play",
controlsContainer: "",
manualControls: "",
customDirectionNav: "",
sync: "",
asNavFor: "",
itemWidth: 0,
itemMargin: 0,
minItems: 1,
maxItems: 0,
move: 0,
allowOneSlide: true,
isFirefox: false,
start: function(){},
before: function(){},
after: function(){},
end: function(){},
added: function(){},
removed: function(){},
init: function(){},
rtl: false
};
$.fn.flexslider=function(options){
if(options===undefined){ options={};}
if(typeof options==="object"){
return this.each(function(){
var $this=$(this),
selector=(options.selector) ? options.selector:".slides > li",
$slides=$this.find(selector);
if(( $slides.length===1&&options.allowOneSlide===false)||$slides.length===0){
var fadeIn=[{ opacity: 0 }, { opacity: 1 }];
if($slides.length){ $slides[0].animate(fadeIn, 400); }
if(options.start){ options.start($this); }}else if($this.data('flexslider')===undefined){
new $.flexslider(this, options);
}});
}else{
var $slider=$(this).data('flexslider');
switch (options){
case "play": $slider.play(); break;
case "pause": $slider.pause(); break;
case "stop": $slider.stop(); break;
case "next": $slider.flexAnimate($slider.getTarget("next"), true); break;
case "prev":
case "previous": $slider.flexAnimate($slider.getTarget("prev"), true); break;
default: if(typeof options==="number"){ $slider.flexAnimate(options, true); }}
}};})(jQuery);
(function (root, factory){
if(typeof define==='function'&&define.amd){
define(factory);
}else if(typeof exports==='object'){
module.exports=factory();
}else{
root.PhotoSwipe=factory();
}})(this, function (){
'use strict';
var PhotoSwipe=function(template, UiClass, items, options){
var framework={
features: null,
bind: function(target, type, listener, unbind){
var methodName=(unbind ? 'remove':'add') + 'EventListener';
type=type.split(' ');
for(var i=0; i < type.length; i++){
if(type[i]){
target[methodName](type[i], listener, false);
}}
},
isArray: function(obj){
return (obj instanceof Array);
},
createEl: function(classes, tag){
var el=document.createElement(tag||'div');
if(classes){
el.className=classes;
}
return el;
},
getScrollY: function(){
var yOffset=window.pageYOffset;
return yOffset!==undefined ? yOffset:document.documentElement.scrollTop;
},
unbind: function(target, type, listener){
framework.bind(target,type,listener,true);
},
removeClass: function(el, className){
var reg=new RegExp('(\\s|^)' + className + '(\\s|$)');
el.className=el.className.replace(reg, ' ').replace(/^\s\s*/, '').replace(/\s\s*$/, '');
},
addClass: function(el, className){
if(!framework.hasClass(el,className)){
el.className +=(el.className ? ' ':'') + className;
}},
hasClass: function(el, className){
return el.className&&new RegExp('(^|\\s)' + className + '(\\s|$)').test(el.className);
},
getChildByClass: function(parentEl, childClassName){
var node=parentEl.firstChild;
while(node){
if(framework.hasClass(node, childClassName)){
return node;
}
node=node.nextSibling;
}},
arraySearch: function(array, value, key){
var i=array.length;
while(i--){
if(array[i][key]===value){
return i;
}}
return -1;
},
extend: function(o1, o2, preventOverwrite){
for (var prop in o2){
if(o2.hasOwnProperty(prop)){
if(preventOverwrite&&o1.hasOwnProperty(prop)){
continue;
}
o1[prop]=o2[prop];
}}
},
easing: {
sine: {
out: function(k){
return Math.sin(k * (Math.PI / 2));
},
inOut: function(k){
return - (Math.cos(Math.PI * k) - 1) / 2;
}},
cubic: {
out: function(k){
return --k * k * k + 1;
}}
/*
elastic: {
out: function(k){
var s, a=0.1, p=0.4;
if(k===0) return 0;
if(k===1) return 1;
if(!a||a < 1){ a=1; s=p / 4; }
else s=p * Math.asin(1 / a) /(2 * Math.PI);
return(a * Math.pow(2, - 10 * k) * Math.sin(( k - s) *(2 * Math.PI) / p) + 1);
},
},
back: {
out: function(k){
var s=1.70158;
return --k * k *(( s + 1) * k + s) + 1;
}}
*/
},
detectFeatures: function(){
if(framework.features){
return framework.features;
}
var helperEl=framework.createEl(),
helperStyle=helperEl.style,
vendor='',
features={};
features.oldIE=document.all&&!document.addEventListener;
features.touch='ontouchstart' in window;
if(window.requestAnimationFrame){
features.raf=window.requestAnimationFrame;
features.caf=window.cancelAnimationFrame;
}
features.pointerEvent = !!(window.PointerEvent)||navigator.msPointerEnabled;
if(!features.pointerEvent){
var ua=navigator.userAgent;
if(/iP(hone|od)/.test(navigator.platform)){
var v=(navigator.appVersion).match(/OS (\d+)_(\d+)_?(\d+)?/);
if(v&&v.length > 0){
v=parseInt(v[1], 10);
if(v >=1&&v < 8){
features.isOldIOSPhone=true;
}}
}
var match=ua.match(/Android\s([0-9\.]*)/);
var androidversion=match ? match[1]:0;
androidversion=parseFloat(androidversion);
if(androidversion >=1){
if(androidversion < 4.4){
features.isOldAndroid=true;
}
features.androidVersion=androidversion;
}
features.isMobileOpera=/opera mini|opera mobi/i.test(ua);
}
var styleChecks=['transform', 'perspective', 'animationName'],
vendors=['', 'webkit','Moz','ms','O'],
styleCheckItem,
styleName;
for(var i=0; i < 4; i++){
vendor=vendors[i];
for(var a=0; a < 3; a++){
styleCheckItem=styleChecks[a];
styleName=vendor + (vendor ?
styleCheckItem.charAt(0).toUpperCase() + styleCheckItem.slice(1) :
styleCheckItem);
if(!features[styleCheckItem]&&styleName in helperStyle){
features[styleCheckItem]=styleName;
}}
if(vendor&&!features.raf){
vendor=vendor.toLowerCase();
features.raf=window[vendor+'RequestAnimationFrame'];
if(features.raf){
features.caf=window[vendor+'CancelAnimationFrame'] ||
window[vendor+'CancelRequestAnimationFrame'];
}}
}
if(!features.raf){
var lastTime=0;
features.raf=function(fn){
var currTime=new Date().getTime();
var timeToCall=Math.max(0, 16 - (currTime - lastTime));
var id=window.setTimeout(function(){ fn(currTime + timeToCall); }, timeToCall);
lastTime=currTime + timeToCall;
return id;
};
features.caf=function(id){ clearTimeout(id); };}
features.svg = !!document.createElementNS &&
!!document.createElementNS('http://www.w3.org/2000/svg', 'svg').createSVGRect;
framework.features=features;
return features;
}};
framework.detectFeatures();
if(framework.features.oldIE){
framework.bind=function(target, type, listener, unbind){
type=type.split(' ');
var methodName=(unbind ? 'detach':'attach') + 'Event',
evName,
_handleEv=function(){
listener.handleEvent.call(listener);
};
for(var i=0; i < type.length; i++){
evName=type[i];
if(evName){
if(typeof listener==='object'&&listener.handleEvent){
if(!unbind){
listener['oldIE' + evName]=_handleEv;
}else{
if(!listener['oldIE' + evName]){
return false;
}}
target[methodName]('on' + evName, listener['oldIE' + evName]);
}else{
target[methodName]('on' + evName, listener);
}}
}};}
var self=this;
var DOUBLE_TAP_RADIUS=25,
NUM_HOLDERS=3;
var _options={
allowPanToNext:true,
spacing: 0.12,
bgOpacity: 1,
mouseUsed: false,
loop: true,
pinchToClose: true,
closeOnScroll: true,
closeOnVerticalDrag: true,
verticalDragRange: 0.75,
hideAnimationDuration: 333,
showAnimationDuration: 333,
showHideOpacity: false,
focus: true,
escKey: true,
arrowKeys: true,
mainScrollEndFriction: 0.35,
panEndFriction: 0.35,
isClickableElement: function(el){
return el.tagName==='A';
},
getDoubleTapZoom: function(isMouseClick, item){
if(isMouseClick){
return 1;
}else{
return item.initialZoomLevel < 0.7 ? 1:1.33;
}},
maxSpreadZoom: 1.33,
modal: true,
scaleMode: 'fit'
};
framework.extend(_options, options);
var _getEmptyPoint=function(){
return {x:0,y:0};};
var _isOpen,
_isDestroying,
_closedByScroll,
_currentItemIndex,
_containerStyle,
_containerShiftIndex,
_currPanDist=_getEmptyPoint(),
_startPanOffset=_getEmptyPoint(),
_panOffset=_getEmptyPoint(),
_upMoveEvents,
_downEvents,
_globalEventHandlers,
_viewportSize={},
_currZoomLevel,
_startZoomLevel,
_translatePrefix,
_translateSufix,
_updateSizeInterval,
_itemsNeedUpdate,
_currPositionIndex=0,
_offset={},
_slideSize=_getEmptyPoint(),
_itemHolders,
_prevItemIndex,
_indexDiff=0,
_dragStartEvent,
_dragMoveEvent,
_dragEndEvent,
_dragCancelEvent,
_transformKey,
_pointerEventEnabled,
_isFixedPosition=true,
_likelyTouchDevice,
_modules=[],
_requestAF,
_cancelAF,
_initalClassName,
_initalWindowScrollY,
_oldIE,
_currentWindowScrollY,
_features,
_windowVisibleSize={},
_renderMaxResolution=false,
_orientationChangeTimeout,
_registerModule=function(name, module){
framework.extend(self, module.publicMethods);
_modules.push(name);
},
_getLoopedId=function(index){
var numSlides=_getNumItems();
if(index > numSlides - 1){
return index - numSlides;
}else if(index < 0){
return numSlides + index;
}
return index;
},
_listeners={},
_listen=function(name, fn){
if(!_listeners[name]){
_listeners[name]=[];
}
return _listeners[name].push(fn);
},
_shout=function(name){
var listeners=_listeners[name];
if(listeners){
var args=Array.prototype.slice.call(arguments);
args.shift();
for(var i=0; i < listeners.length; i++){
listeners[i].apply(self, args);
}}
},
_getCurrentTime=function(){
return new Date().getTime();
},
_applyBgOpacity=function(opacity){
_bgOpacity=opacity;
self.bg.style.opacity=opacity * _options.bgOpacity;
},
_applyZoomTransform=function(styleObj,x,y,zoom,item){
if(!_renderMaxResolution||(item&&item!==self.currItem)){
zoom=zoom / (item ? item.fitRatio:self.currItem.fitRatio);
}
styleObj[_transformKey]=_translatePrefix + x + 'px, ' + y + 'px' + _translateSufix + ' scale(' + zoom + ')';
},
_applyCurrentZoomPan=function(allowRenderResolution){
if(_currZoomElementStyle){
if(allowRenderResolution){
if(_currZoomLevel > self.currItem.fitRatio){
if(!_renderMaxResolution){
_setImageSize(self.currItem, false, true);
_renderMaxResolution=true;
}}else{
if(_renderMaxResolution){
_setImageSize(self.currItem);
_renderMaxResolution=false;
}}
}
_applyZoomTransform(_currZoomElementStyle, _panOffset.x, _panOffset.y, _currZoomLevel);
}},
_applyZoomPanToItem=function(item){
if(item.container){
_applyZoomTransform(item.container.style,
item.initialPosition.x,
item.initialPosition.y,
item.initialZoomLevel,
item);
}},
_setTranslateX=function(x, elStyle){
elStyle[_transformKey]=_translatePrefix + x + 'px, 0px' + _translateSufix;
},
_moveMainScroll=function(x, dragging){
if(!_options.loop&&dragging){
var newSlideIndexOffset=_currentItemIndex + (_slideSize.x * _currPositionIndex - x) / _slideSize.x,
delta=Math.round(x - _mainScrollPos.x);
if((newSlideIndexOffset < 0&&delta > 0) ||
(newSlideIndexOffset >=_getNumItems() - 1&&delta < 0)){
x=_mainScrollPos.x + delta * _options.mainScrollEndFriction;
}}
_mainScrollPos.x=x;
_setTranslateX(x, _containerStyle);
},
_calculatePanOffset=function(axis, zoomLevel){
var m=_midZoomPoint[axis] - _offset[axis];
return _startPanOffset[axis] + _currPanDist[axis] + m - m *(zoomLevel / _startZoomLevel);
},
_equalizePoints=function(p1, p2){
p1.x=p2.x;
p1.y=p2.y;
if(p2.id){
p1.id=p2.id;
}},
_roundPoint=function(p){
p.x=Math.round(p.x);
p.y=Math.round(p.y);
},
_mouseMoveTimeout=null,
_onFirstMouseMove=function(){
if(_mouseMoveTimeout){
framework.unbind(document, 'mousemove', _onFirstMouseMove);
framework.addClass(template, 'pswp--has_mouse');
_options.mouseUsed=true;
_shout('mouseUsed');
}
_mouseMoveTimeout=setTimeout(function(){
_mouseMoveTimeout=null;
}, 100);
},
_bindEvents=function(){
framework.bind(document, 'keydown', self);
if(_features.transform){
framework.bind(self.scrollWrap, 'click', self);
}
if(!_options.mouseUsed){
framework.bind(document, 'mousemove', _onFirstMouseMove);
}
framework.bind(window, 'resize scroll orientationchange', self);
_shout('bindEvents');
},
_unbindEvents=function(){
framework.unbind(window, 'resize scroll orientationchange', self);
framework.unbind(window, 'scroll', _globalEventHandlers.scroll);
framework.unbind(document, 'keydown', self);
framework.unbind(document, 'mousemove', _onFirstMouseMove);
if(_features.transform){
framework.unbind(self.scrollWrap, 'click', self);
}
if(_isDragging){
framework.unbind(window, _upMoveEvents, self);
}
clearTimeout(_orientationChangeTimeout);
_shout('unbindEvents');
},
_calculatePanBounds=function(zoomLevel, update){
var bounds=_calculateItemSize(self.currItem, _viewportSize, zoomLevel);
if(update){
_currPanBounds=bounds;
}
return bounds;
},
_getMinZoomLevel=function(item){
if(!item){
item=self.currItem;
}
return item.initialZoomLevel;
},
_getMaxZoomLevel=function(item){
if(!item){
item=self.currItem;
}
return item.w > 0 ? _options.maxSpreadZoom:1;
},
_modifyDestPanOffset=function(axis, destPanBounds, destPanOffset, destZoomLevel){
if(destZoomLevel===self.currItem.initialZoomLevel){
destPanOffset[axis]=self.currItem.initialPosition[axis];
return true;
}else{
destPanOffset[axis]=_calculatePanOffset(axis, destZoomLevel);
if(destPanOffset[axis] > destPanBounds.min[axis]){
destPanOffset[axis]=destPanBounds.min[axis];
return true;
}else if(destPanOffset[axis] < destPanBounds.max[axis]){
destPanOffset[axis]=destPanBounds.max[axis];
return true;
}}
return false;
},
_setupTransforms=function(){
if(_transformKey){
var allow3dTransform=_features.perspective&&!_likelyTouchDevice;
_translatePrefix='translate' + (allow3dTransform ? '3d(':'(');
_translateSufix=_features.perspective ? ', 0px)':')';
return;
}
_transformKey='left';
framework.addClass(template, 'pswp--ie');
_setTranslateX=function(x, elStyle){
elStyle.left=x + 'px';
};
_applyZoomPanToItem=function(item){
var zoomRatio=item.fitRatio > 1 ? 1:item.fitRatio,
s=item.container.style,
w=zoomRatio * item.w,
h=zoomRatio * item.h;
s.width=w + 'px';
s.height=h + 'px';
s.left=item.initialPosition.x + 'px';
s.top=item.initialPosition.y + 'px';
};
_applyCurrentZoomPan=function(){
if(_currZoomElementStyle){
var s=_currZoomElementStyle,
item=self.currItem,
zoomRatio=item.fitRatio > 1 ? 1:item.fitRatio,
w=zoomRatio * item.w,
h=zoomRatio * item.h;
s.width=w + 'px';
s.height=h + 'px';
s.left=_panOffset.x + 'px';
s.top=_panOffset.y + 'px';
}};},
_onKeyDown=function(e){
var keydownAction='';
if(_options.escKey&&e.keyCode===27){
keydownAction='close';
}else if(_options.arrowKeys){
if(e.keyCode===37){
keydownAction='prev';
}else if(e.keyCode===39){
keydownAction='next';
}}
if(keydownAction){
if(!e.ctrlKey&&!e.altKey&&!e.shiftKey&&!e.metaKey){
if(e.preventDefault){
e.preventDefault();
}else{
e.returnValue=false;
}
self[keydownAction]();
}}
},
_onGlobalClick=function(e){
if(!e){
return;
}
if(_moved||_zoomStarted||_mainScrollAnimating||_verticalDragInitiated){
e.preventDefault();
e.stopPropagation();
}},
_updatePageScrollOffset=function(){
self.setScrollOffset(0, framework.getScrollY());
};
var _animations={},
_numAnimations=0,
_stopAnimation=function(name){
if(_animations[name]){
if(_animations[name].raf){
_cancelAF(_animations[name].raf);
}
_numAnimations--;
delete _animations[name];
}},
_registerStartAnimation=function(name){
if(_animations[name]){
_stopAnimation(name);
}
if(!_animations[name]){
_numAnimations++;
_animations[name]={};}},
_stopAllAnimations=function(){
for (var prop in _animations){
if(_animations.hasOwnProperty(prop)){
_stopAnimation(prop);
}}
},
_animateProp=function(name, b, endProp, d, easingFn, onUpdate, onComplete){
var startAnimTime=_getCurrentTime(), t;
_registerStartAnimation(name);
var animloop=function(){
if(_animations[name]){
t=_getCurrentTime() - startAnimTime;
if(t >=d){
_stopAnimation(name);
onUpdate(endProp);
if(onComplete){
onComplete();
}
return;
}
onUpdate((endProp - b) * easingFn(t/d) + b);
_animations[name].raf=_requestAF(animloop);
}};
animloop();
};
var publicMethods={
shout: _shout,
listen: _listen,
viewportSize: _viewportSize,
options: _options,
isMainScrollAnimating: function(){
return _mainScrollAnimating;
},
getZoomLevel: function(){
return _currZoomLevel;
},
getCurrentIndex: function(){
return _currentItemIndex;
},
isDragging: function(){
return _isDragging;
},
isZooming: function(){
return _isZooming;
},
setScrollOffset: function(x,y){
_offset.x=x;
_currentWindowScrollY=_offset.y=y;
_shout('updateScrollOffset', _offset);
},
applyZoomPan: function(zoomLevel,panX,panY,allowRenderResolution){
_panOffset.x=panX;
_panOffset.y=panY;
_currZoomLevel=zoomLevel;
_applyCurrentZoomPan(allowRenderResolution);
},
init: function(){
if(_isOpen||_isDestroying){
return;
}
var i;
self.framework=framework;
self.template=template;
self.bg=framework.getChildByClass(template, 'pswp__bg');
_initalClassName=template.className;
_isOpen=true;
_features=framework.detectFeatures();
_requestAF=_features.raf;
_cancelAF=_features.caf;
_transformKey=_features.transform;
_oldIE=_features.oldIE;
self.scrollWrap=framework.getChildByClass(template, 'pswp__scroll-wrap');
self.container=framework.getChildByClass(self.scrollWrap, 'pswp__container');
_containerStyle=self.container.style;
self.itemHolders=_itemHolders=[
{el:self.container.children[0] , wrap:0, index: -1},
{el:self.container.children[1] , wrap:0, index: -1},
{el:self.container.children[2] , wrap:0, index: -1}
];
_itemHolders[0].el.style.display=_itemHolders[2].el.style.display='none';
_setupTransforms();
_globalEventHandlers={
resize: self.updateSize,
orientationchange: function(){
clearTimeout(_orientationChangeTimeout);
_orientationChangeTimeout=setTimeout(function(){
if(_viewportSize.x!==self.scrollWrap.clientWidth){
self.updateSize();
}}, 500);
},
scroll: _updatePageScrollOffset,
keydown: _onKeyDown,
click: _onGlobalClick
};
var oldPhone=_features.isOldIOSPhone||_features.isOldAndroid||_features.isMobileOpera;
if(!_features.animationName||!_features.transform||oldPhone){
_options.showAnimationDuration=_options.hideAnimationDuration=0;
}
for(i=0; i < _modules.length; i++){
self['init' + _modules[i]]();
}
if(UiClass){
var ui=self.ui=new UiClass(self, framework);
ui.init();
}
_shout('firstUpdate');
_currentItemIndex=_currentItemIndex||_options.index||0;
if(isNaN(_currentItemIndex)||_currentItemIndex < 0||_currentItemIndex >=_getNumItems()){
_currentItemIndex=0;
}
self.currItem=_getItemAt(_currentItemIndex);
if(_features.isOldIOSPhone||_features.isOldAndroid){
_isFixedPosition=false;
}
template.setAttribute('aria-hidden', 'false');
if(_options.modal){
if(!_isFixedPosition){
template.style.position='absolute';
template.style.top=framework.getScrollY() + 'px';
}else{
template.style.position='fixed';
}}
if(_currentWindowScrollY===undefined){
_shout('initialLayout');
_currentWindowScrollY=_initalWindowScrollY=framework.getScrollY();
}
var rootClasses='pswp--open ';
if(_options.mainClass){
rootClasses +=_options.mainClass + ' ';
}
if(_options.showHideOpacity){
rootClasses +='pswp--animate_opacity ';
}
rootClasses +=_likelyTouchDevice ? 'pswp--touch':'pswp--notouch';
rootClasses +=_features.animationName ? ' pswp--css_animation':'';
rootClasses +=_features.svg ? ' pswp--svg':'';
framework.addClass(template, rootClasses);
self.updateSize();
_containerShiftIndex=-1;
_indexDiff=null;
for(i=0; i < NUM_HOLDERS; i++){
_setTranslateX((i+_containerShiftIndex) * _slideSize.x, _itemHolders[i].el.style);
}
if(!_oldIE){
framework.bind(self.scrollWrap, _downEvents, self);
}
_listen('initialZoomInEnd', function(){
self.setContent(_itemHolders[0], _currentItemIndex-1);
self.setContent(_itemHolders[2], _currentItemIndex+1);
_itemHolders[0].el.style.display=_itemHolders[2].el.style.display='block';
if(_options.focus){
template.focus();
}
_bindEvents();
});
self.setContent(_itemHolders[1], _currentItemIndex);
self.updateCurrItem();
_shout('afterInit');
if(!_isFixedPosition){
_updateSizeInterval=setInterval(function(){
if(!_numAnimations&&!_isDragging&&!_isZooming&&(_currZoomLevel===self.currItem.initialZoomLevel)){
self.updateSize();
}}, 1000);
}
framework.addClass(template, 'pswp--visible');
},
close: function(){
if(!_isOpen){
return;
}
_isOpen=false;
_isDestroying=true;
_shout('close');
_unbindEvents();
_showOrHide(self.currItem, null, true, self.destroy);
},
destroy: function(){
_shout('destroy');
if(_showOrHideTimeout){
clearTimeout(_showOrHideTimeout);
}
template.setAttribute('aria-hidden', 'true');
template.className=_initalClassName;
if(_updateSizeInterval){
clearInterval(_updateSizeInterval);
}
framework.unbind(self.scrollWrap, _downEvents, self);
framework.unbind(window, 'scroll', self);
_stopDragUpdateLoop();
_stopAllAnimations();
_listeners=null;
},
panTo: function(x,y,force){
if(!force){
if(x > _currPanBounds.min.x){
x=_currPanBounds.min.x;
}else if(x < _currPanBounds.max.x){
x=_currPanBounds.max.x;
}
if(y > _currPanBounds.min.y){
y=_currPanBounds.min.y;
}else if(y < _currPanBounds.max.y){
y=_currPanBounds.max.y;
}}
_panOffset.x=x;
_panOffset.y=y;
_applyCurrentZoomPan();
},
handleEvent: function (e){
e=e||window.event;
if(_globalEventHandlers[e.type]){
_globalEventHandlers[e.type](e);
}},
goTo: function(index){
index=_getLoopedId(index);
var diff=index - _currentItemIndex;
_indexDiff=diff;
_currentItemIndex=index;
self.currItem=_getItemAt(_currentItemIndex);
_currPositionIndex -=diff;
_moveMainScroll(_slideSize.x * _currPositionIndex);
_stopAllAnimations();
_mainScrollAnimating=false;
self.updateCurrItem();
},
next: function(){
self.goTo(_currentItemIndex + 1);
},
prev: function(){
self.goTo(_currentItemIndex - 1);
},
updateCurrZoomItem: function(emulateSetContent){
if(emulateSetContent){
_shout('beforeChange', 0);
}
if(_itemHolders[1].el.children.length){
var zoomElement=_itemHolders[1].el.children[0];
if(framework.hasClass(zoomElement, 'pswp__zoom-wrap')){
_currZoomElementStyle=zoomElement.style;
}else{
_currZoomElementStyle=null;
}}else{
_currZoomElementStyle=null;
}
_currPanBounds=self.currItem.bounds;
_startZoomLevel=_currZoomLevel=self.currItem.initialZoomLevel;
_panOffset.x=_currPanBounds.center.x;
_panOffset.y=_currPanBounds.center.y;
if(emulateSetContent){
_shout('afterChange');
}},
invalidateCurrItems: function(){
_itemsNeedUpdate=true;
for(var i=0; i < NUM_HOLDERS; i++){
if(_itemHolders[i].item){
_itemHolders[i].item.needsUpdate=true;
}}
},
updateCurrItem: function(beforeAnimation){
if(_indexDiff===0){
return;
}
var diffAbs=Math.abs(_indexDiff),
tempHolder;
if(beforeAnimation&&diffAbs < 2){
return;
}
self.currItem=_getItemAt(_currentItemIndex);
_renderMaxResolution=false;
_shout('beforeChange', _indexDiff);
if(diffAbs >=NUM_HOLDERS){
_containerShiftIndex +=_indexDiff + (_indexDiff > 0 ? -NUM_HOLDERS:NUM_HOLDERS);
diffAbs=NUM_HOLDERS;
}
for(var i=0; i < diffAbs; i++){
if(_indexDiff > 0){
tempHolder=_itemHolders.shift();
_itemHolders[NUM_HOLDERS-1]=tempHolder;
_containerShiftIndex++;
_setTranslateX((_containerShiftIndex+2) * _slideSize.x, tempHolder.el.style);
self.setContent(tempHolder, _currentItemIndex - diffAbs + i + 1 + 1);
}else{
tempHolder=_itemHolders.pop();
_itemHolders.unshift(tempHolder);
_containerShiftIndex--;
_setTranslateX(_containerShiftIndex * _slideSize.x, tempHolder.el.style);
self.setContent(tempHolder, _currentItemIndex + diffAbs - i - 1 - 1);
}}
if(_currZoomElementStyle&&Math.abs(_indexDiff)===1){
var prevItem=_getItemAt(_prevItemIndex);
if(prevItem.initialZoomLevel!==_currZoomLevel){
_calculateItemSize(prevItem , _viewportSize);
_setImageSize(prevItem);
_applyZoomPanToItem(prevItem);
}}
_indexDiff=0;
self.updateCurrZoomItem();
_prevItemIndex=_currentItemIndex;
_shout('afterChange');
},
updateSize: function(force){
if(!_isFixedPosition&&_options.modal){
var windowScrollY=framework.getScrollY();
if(_currentWindowScrollY!==windowScrollY){
template.style.top=windowScrollY + 'px';
_currentWindowScrollY=windowScrollY;
}
if(!force&&_windowVisibleSize.x===window.innerWidth&&_windowVisibleSize.y===window.innerHeight){
return;
}
_windowVisibleSize.x=window.innerWidth;
_windowVisibleSize.y=window.innerHeight;
template.style.height=_windowVisibleSize.y + 'px';
}
_viewportSize.x=self.scrollWrap.clientWidth;
_viewportSize.y=self.scrollWrap.clientHeight;
_updatePageScrollOffset();
_slideSize.x=_viewportSize.x + Math.round(_viewportSize.x * _options.spacing);
_slideSize.y=_viewportSize.y;
_moveMainScroll(_slideSize.x * _currPositionIndex);
_shout('beforeResize');
if(_containerShiftIndex!==undefined){
var holder,
item,
hIndex;
for(var i=0; i < NUM_HOLDERS; i++){
holder=_itemHolders[i];
_setTranslateX((i+_containerShiftIndex) * _slideSize.x, holder.el.style);
hIndex=_currentItemIndex+i-1;
if(_options.loop&&_getNumItems() > 2){
hIndex=_getLoopedId(hIndex);
}
item=_getItemAt(hIndex);
if(item&&(_itemsNeedUpdate||item.needsUpdate||!item.bounds)){
self.cleanSlide(item);
self.setContent(holder, hIndex);
if(i===1){
self.currItem=item;
self.updateCurrZoomItem(true);
}
item.needsUpdate=false;
}else if(holder.index===-1&&hIndex >=0){
self.setContent(holder, hIndex);
}
if(item&&item.container){
_calculateItemSize(item, _viewportSize);
_setImageSize(item);
_applyZoomPanToItem(item);
}}
_itemsNeedUpdate=false;
}
_startZoomLevel=_currZoomLevel=self.currItem.initialZoomLevel;
_currPanBounds=self.currItem.bounds;
if(_currPanBounds){
_panOffset.x=_currPanBounds.center.x;
_panOffset.y=_currPanBounds.center.y;
_applyCurrentZoomPan(true);
}
_shout('resize');
},
zoomTo: function(destZoomLevel, centerPoint, speed, easingFn, updateFn){
if(centerPoint){
_startZoomLevel=_currZoomLevel;
_midZoomPoint.x=Math.abs(centerPoint.x) - _panOffset.x ;
_midZoomPoint.y=Math.abs(centerPoint.y) - _panOffset.y ;
_equalizePoints(_startPanOffset, _panOffset);
}
var destPanBounds=_calculatePanBounds(destZoomLevel, false),
destPanOffset={};
_modifyDestPanOffset('x', destPanBounds, destPanOffset, destZoomLevel);
_modifyDestPanOffset('y', destPanBounds, destPanOffset, destZoomLevel);
var initialZoomLevel=_currZoomLevel;
var initialPanOffset={
x: _panOffset.x,
y: _panOffset.y
};
_roundPoint(destPanOffset);
var onUpdate=function(now){
if(now===1){
_currZoomLevel=destZoomLevel;
_panOffset.x=destPanOffset.x;
_panOffset.y=destPanOffset.y;
}else{
_currZoomLevel=(destZoomLevel - initialZoomLevel) * now + initialZoomLevel;
_panOffset.x=(destPanOffset.x - initialPanOffset.x) * now + initialPanOffset.x;
_panOffset.y=(destPanOffset.y - initialPanOffset.y) * now + initialPanOffset.y;
}
if(updateFn){
updateFn(now);
}
_applyCurrentZoomPan(now===1);
};
if(speed){
_animateProp('customZoomTo', 0, 1, speed, easingFn||framework.easing.sine.inOut, onUpdate);
}else{
onUpdate(1);
}}
};
var MIN_SWIPE_DISTANCE=30,
DIRECTION_CHECK_OFFSET=10;
var _gestureStartTime,
_gestureCheckSpeedTime,
p={},
p2={},
delta={},
_currPoint={},
_startPoint={},
_currPointers=[],
_startMainScrollPos={},
_releaseAnimData,
_posPoints=[],
_tempPoint={},
_isZoomingIn,
_verticalDragInitiated,
_oldAndroidTouchEndTimeout,
_currZoomedItemIndex=0,
_centerPoint=_getEmptyPoint(),
_lastReleaseTime=0,
_isDragging,
_isMultitouch,
_zoomStarted,
_moved,
_dragAnimFrame,
_mainScrollShifted,
_currentPoints,
_isZooming,
_currPointsDistance,
_startPointsDistance,
_currPanBounds,
_mainScrollPos=_getEmptyPoint(),
_currZoomElementStyle,
_mainScrollAnimating,
_midZoomPoint=_getEmptyPoint(),
_currCenterPoint=_getEmptyPoint(),
_direction,
_isFirstMove,
_opacityChanged,
_bgOpacity,
_wasOverInitialZoom,
_isEqualPoints=function(p1, p2){
return p1.x===p2.x&&p1.y===p2.y;
},
_isNearbyPoints=function(touch0, touch1){
return Math.abs(touch0.x - touch1.x) < DOUBLE_TAP_RADIUS&&Math.abs(touch0.y - touch1.y) < DOUBLE_TAP_RADIUS;
},
_calculatePointsDistance=function(p1, p2){
_tempPoint.x=Math.abs(p1.x - p2.x);
_tempPoint.y=Math.abs(p1.y - p2.y);
return Math.sqrt(_tempPoint.x * _tempPoint.x + _tempPoint.y * _tempPoint.y);
},
_stopDragUpdateLoop=function(){
if(_dragAnimFrame){
_cancelAF(_dragAnimFrame);
_dragAnimFrame=null;
}},
_dragUpdateLoop=function(){
if(_isDragging){
_dragAnimFrame=_requestAF(_dragUpdateLoop);
_renderMovement();
}},
_canPan=function(){
return !(_options.scaleMode==='fit'&&_currZoomLevel===self.currItem.initialZoomLevel);
},
_closestElement=function(el, fn){
if(!el||el===document){
return false;
}
if(el.getAttribute('class')&&el.getAttribute('class').indexOf('pswp__scroll-wrap') > -1){
return false;
}
if(fn(el)){
return el;
}
return _closestElement(el.parentNode, fn);
},
_preventObj={},
_preventDefaultEventBehaviour=function(e, isDown){
_preventObj.prevent = !_closestElement(e.target, _options.isClickableElement);
_shout('preventDragEvent', e, isDown, _preventObj);
return _preventObj.prevent;
},
_convertTouchToPoint=function(touch, p){
p.x=touch.pageX;
p.y=touch.pageY;
p.id=touch.identifier;
return p;
},
_findCenterOfPoints=function(p1, p2, pCenter){
pCenter.x=(p1.x + p2.x) * 0.5;
pCenter.y=(p1.y + p2.y) * 0.5;
},
_pushPosPoint=function(time, x, y){
if(time - _gestureCheckSpeedTime > 50){
var o=_posPoints.length > 2 ? _posPoints.shift():{};
o.x=x;
o.y=y;
_posPoints.push(o);
_gestureCheckSpeedTime=time;
}},
_calculateVerticalDragOpacityRatio=function(){
var yOffset=_panOffset.y - self.currItem.initialPosition.y;
return 1 -  Math.abs(yOffset / (_viewportSize.y / 2));
},
_ePoint1={},
_ePoint2={},
_tempPointsArr=[],
_tempCounter,
_getTouchPoints=function(e){
while(_tempPointsArr.length > 0){
_tempPointsArr.pop();
}
if(!_pointerEventEnabled){
if(e.type.indexOf('touch') > -1){
if(e.touches&&e.touches.length > 0){
_tempPointsArr[0]=_convertTouchToPoint(e.touches[0], _ePoint1);
if(e.touches.length > 1){
_tempPointsArr[1]=_convertTouchToPoint(e.touches[1], _ePoint2);
}}
}else{
_ePoint1.x=e.pageX;
_ePoint1.y=e.pageY;
_ePoint1.id='';
_tempPointsArr[0]=_ePoint1;
}}else{
_tempCounter=0;
_currPointers.forEach(function(p){
if(_tempCounter===0){
_tempPointsArr[0]=p;
}else if(_tempCounter===1){
_tempPointsArr[1]=p;
}
_tempCounter++;
});
}
return _tempPointsArr;
},
_panOrMoveMainScroll=function(axis, delta){
var panFriction,
overDiff=0,
newOffset=_panOffset[axis] + delta[axis],
startOverDiff,
dir=delta[axis] > 0,
newMainScrollPosition=_mainScrollPos.x + delta.x,
mainScrollDiff=_mainScrollPos.x - _startMainScrollPos.x,
newPanPos,
newMainScrollPos;
if(newOffset > _currPanBounds.min[axis]||newOffset < _currPanBounds.max[axis]){
panFriction=_options.panEndFriction;
}else{
panFriction=1;
}
newOffset=_panOffset[axis] + delta[axis] * panFriction;
if(_options.allowPanToNext||_currZoomLevel===self.currItem.initialZoomLevel){
if(!_currZoomElementStyle){
newMainScrollPos=newMainScrollPosition;
}else if(_direction==='h'&&axis==='x'&&!_zoomStarted){
if(dir){
if(newOffset > _currPanBounds.min[axis]){
panFriction=_options.panEndFriction;
overDiff=_currPanBounds.min[axis] - newOffset;
startOverDiff=_currPanBounds.min[axis] - _startPanOffset[axis];
}
if((startOverDiff <=0||mainScrollDiff < 0)&&_getNumItems() > 1){
newMainScrollPos=newMainScrollPosition;
if(mainScrollDiff < 0&&newMainScrollPosition > _startMainScrollPos.x){
newMainScrollPos=_startMainScrollPos.x;
}}else{
if(_currPanBounds.min.x!==_currPanBounds.max.x){
newPanPos=newOffset;
}}
}else{
if(newOffset < _currPanBounds.max[axis]){
panFriction=_options.panEndFriction;
overDiff=newOffset - _currPanBounds.max[axis];
startOverDiff=_startPanOffset[axis] - _currPanBounds.max[axis];
}
if((startOverDiff <=0||mainScrollDiff > 0)&&_getNumItems() > 1){
newMainScrollPos=newMainScrollPosition;
if(mainScrollDiff > 0&&newMainScrollPosition < _startMainScrollPos.x){
newMainScrollPos=_startMainScrollPos.x;
}}else{
if(_currPanBounds.min.x!==_currPanBounds.max.x){
newPanPos=newOffset;
}}
}}
if(axis==='x'){
if(newMainScrollPos!==undefined){
_moveMainScroll(newMainScrollPos, true);
if(newMainScrollPos===_startMainScrollPos.x){
_mainScrollShifted=false;
}else{
_mainScrollShifted=true;
}}
if(_currPanBounds.min.x!==_currPanBounds.max.x){
if(newPanPos!==undefined){
_panOffset.x=newPanPos;
}else if(!_mainScrollShifted){
_panOffset.x +=delta.x * panFriction;
}}
return newMainScrollPos!==undefined;
}}
if(!_mainScrollAnimating){
if(!_mainScrollShifted){
if(_currZoomLevel > self.currItem.fitRatio){
_panOffset[axis] +=delta[axis] * panFriction;
}}
}},
_onDragStart=function(e){
if(e.type==='mousedown'&&e.button > 0){
return;
}
if(_initialZoomRunning){
e.preventDefault();
return;
}
if(_oldAndroidTouchEndTimeout&&e.type==='mousedown'){
return;
}
if(_preventDefaultEventBehaviour(e, true)){
e.preventDefault();
}
_shout('pointerDown');
if(_pointerEventEnabled){
var pointerIndex=framework.arraySearch(_currPointers, e.pointerId, 'id');
if(pointerIndex < 0){
pointerIndex=_currPointers.length;
}
_currPointers[pointerIndex]={x:e.pageX, y:e.pageY, id: e.pointerId};}
var startPointsList=_getTouchPoints(e),
numPoints=startPointsList.length;
_currentPoints=null;
_stopAllAnimations();
if(!_isDragging||numPoints===1){
_isDragging=_isFirstMove=true;
framework.bind(window, _upMoveEvents, self);
_isZoomingIn =
_wasOverInitialZoom =
_opacityChanged =
_verticalDragInitiated =
_mainScrollShifted =
_moved =
_isMultitouch =
_zoomStarted=false;
_direction=null;
_shout('firstTouchStart', startPointsList);
_equalizePoints(_startPanOffset, _panOffset);
_currPanDist.x=_currPanDist.y=0;
_equalizePoints(_currPoint, startPointsList[0]);
_equalizePoints(_startPoint, _currPoint);
_startMainScrollPos.x=_slideSize.x * _currPositionIndex;
_posPoints=[{
x: _currPoint.x,
y: _currPoint.y
}];
_gestureCheckSpeedTime=_gestureStartTime=_getCurrentTime();
_calculatePanBounds(_currZoomLevel, true);
_stopDragUpdateLoop();
_dragUpdateLoop();
}
if(!_isZooming&&numPoints > 1&&!_mainScrollAnimating&&!_mainScrollShifted){
_startZoomLevel=_currZoomLevel;
_zoomStarted=false;
_isZooming=_isMultitouch=true;
_currPanDist.y=_currPanDist.x=0;
_equalizePoints(_startPanOffset, _panOffset);
_equalizePoints(p, startPointsList[0]);
_equalizePoints(p2, startPointsList[1]);
_findCenterOfPoints(p, p2, _currCenterPoint);
_midZoomPoint.x=Math.abs(_currCenterPoint.x) - _panOffset.x;
_midZoomPoint.y=Math.abs(_currCenterPoint.y) - _panOffset.y;
_currPointsDistance=_startPointsDistance=_calculatePointsDistance(p, p2);
}},
_onDragMove=function(e){
e.preventDefault();
if(_pointerEventEnabled){
var pointerIndex=framework.arraySearch(_currPointers, e.pointerId, 'id');
if(pointerIndex > -1){
var p=_currPointers[pointerIndex];
p.x=e.pageX;
p.y=e.pageY;
}}
if(_isDragging){
var touchesList=_getTouchPoints(e);
if(!_direction&&!_moved&&!_isZooming){
if(_mainScrollPos.x!==_slideSize.x * _currPositionIndex){
_direction='h';
}else{
var diff=Math.abs(touchesList[0].x - _currPoint.x) - Math.abs(touchesList[0].y - _currPoint.y);
if(Math.abs(diff) >=DIRECTION_CHECK_OFFSET){
_direction=diff > 0 ? 'h':'v';
_currentPoints=touchesList;
}}
}else{
_currentPoints=touchesList;
}}
},
_renderMovement=function(){
if(!_currentPoints){
return;
}
var numPoints=_currentPoints.length;
if(numPoints===0){
return;
}
_equalizePoints(p, _currentPoints[0]);
delta.x=p.x - _currPoint.x;
delta.y=p.y - _currPoint.y;
if(_isZooming&&numPoints > 1){
_currPoint.x=p.x;
_currPoint.y=p.y;
if(!delta.x&&!delta.y&&_isEqualPoints(_currentPoints[1], p2)){
return;
}
_equalizePoints(p2, _currentPoints[1]);
if(!_zoomStarted){
_zoomStarted=true;
_shout('zoomGestureStarted');
}
var pointsDistance=_calculatePointsDistance(p,p2);
var zoomLevel=_calculateZoomLevel(pointsDistance);
if(zoomLevel > self.currItem.initialZoomLevel + self.currItem.initialZoomLevel / 15){
_wasOverInitialZoom=true;
}
var zoomFriction=1,
minZoomLevel=_getMinZoomLevel(),
maxZoomLevel=_getMaxZoomLevel();
if(zoomLevel < minZoomLevel){
if(_options.pinchToClose&&!_wasOverInitialZoom&&_startZoomLevel <=self.currItem.initialZoomLevel){
var minusDiff=minZoomLevel - zoomLevel;
var percent=1 - minusDiff / (minZoomLevel / 1.2);
_applyBgOpacity(percent);
_shout('onPinchClose', percent);
_opacityChanged=true;
}else{
zoomFriction=(minZoomLevel - zoomLevel) / minZoomLevel;
if(zoomFriction > 1){
zoomFriction=1;
}
zoomLevel=minZoomLevel - zoomFriction * (minZoomLevel / 3);
}}else if(zoomLevel > maxZoomLevel){
zoomFriction=(zoomLevel - maxZoomLevel) /(minZoomLevel * 6);
if(zoomFriction > 1){
zoomFriction=1;
}
zoomLevel=maxZoomLevel + zoomFriction * minZoomLevel;
}
if(zoomFriction < 0){
zoomFriction=0;
}
_currPointsDistance=pointsDistance;
_findCenterOfPoints(p, p2, _centerPoint);
_currPanDist.x +=_centerPoint.x - _currCenterPoint.x;
_currPanDist.y +=_centerPoint.y - _currCenterPoint.y;
_equalizePoints(_currCenterPoint, _centerPoint);
_panOffset.x=_calculatePanOffset('x', zoomLevel);
_panOffset.y=_calculatePanOffset('y', zoomLevel);
_isZoomingIn=zoomLevel > _currZoomLevel;
_currZoomLevel=zoomLevel;
_applyCurrentZoomPan();
}else{
if(!_direction){
return;
}
if(_isFirstMove){
_isFirstMove=false;
if(Math.abs(delta.x) >=DIRECTION_CHECK_OFFSET){
delta.x -=_currentPoints[0].x - _startPoint.x;
}
if(Math.abs(delta.y) >=DIRECTION_CHECK_OFFSET){
delta.y -=_currentPoints[0].y - _startPoint.y;
}}
_currPoint.x=p.x;
_currPoint.y=p.y;
if(delta.x===0&&delta.y===0){
return;
}
if(_direction==='v'&&_options.closeOnVerticalDrag){
if(!_canPan()){
_currPanDist.y +=delta.y;
_panOffset.y +=delta.y;
var opacityRatio=_calculateVerticalDragOpacityRatio();
_verticalDragInitiated=true;
_shout('onVerticalDrag', opacityRatio);
_applyBgOpacity(opacityRatio);
_applyCurrentZoomPan();
return ;
}}
_pushPosPoint(_getCurrentTime(), p.x, p.y);
_moved=true;
_currPanBounds=self.currItem.bounds;
var mainScrollChanged=_panOrMoveMainScroll('x', delta);
if(!mainScrollChanged){
_panOrMoveMainScroll('y', delta);
_roundPoint(_panOffset);
_applyCurrentZoomPan();
}}
},
_onDragRelease=function(e){
if(_features.isOldAndroid){
if(_oldAndroidTouchEndTimeout&&e.type==='mouseup'){
return;
}
if(e.type.indexOf('touch') > -1){
clearTimeout(_oldAndroidTouchEndTimeout);
_oldAndroidTouchEndTimeout=setTimeout(function(){
_oldAndroidTouchEndTimeout=0;
}, 600);
}}
_shout('pointerUp');
if(_preventDefaultEventBehaviour(e, false)){
e.preventDefault();
}
var releasePoint;
if(_pointerEventEnabled){
var pointerIndex=framework.arraySearch(_currPointers, e.pointerId, 'id');
if(pointerIndex > -1){
releasePoint=_currPointers.splice(pointerIndex, 1)[0];
if(navigator.msPointerEnabled){
var MSPOINTER_TYPES={
4: 'mouse',
2: 'touch',
3: 'pen'
};
releasePoint.type=MSPOINTER_TYPES[e.pointerType];
if(!releasePoint.type){
releasePoint.type=e.pointerType||'mouse';
}}else{
releasePoint.type=e.pointerType||'mouse';
}}
}
var touchList=_getTouchPoints(e),
gestureType,
numPoints=touchList.length;
if(e.type==='mouseup'){
numPoints=0;
}
if(numPoints===2){
_currentPoints=null;
return true;
}
if(numPoints===1){
_equalizePoints(_startPoint, touchList[0]);
}
if(numPoints===0&&!_direction&&!_mainScrollAnimating){
if(!releasePoint){
if(e.type==='mouseup'){
releasePoint={x: e.pageX, y: e.pageY, type:'mouse'};}else if(e.changedTouches&&e.changedTouches[0]){
releasePoint={x: e.changedTouches[0].pageX, y: e.changedTouches[0].pageY, type:'touch'};}}
_shout('touchRelease', e, releasePoint);
}
var releaseTimeDiff=-1;
if(numPoints===0){
_isDragging=false;
framework.unbind(window, _upMoveEvents, self);
_stopDragUpdateLoop();
if(_isZooming){
releaseTimeDiff=0;
}else if(_lastReleaseTime!==-1){
releaseTimeDiff=_getCurrentTime() - _lastReleaseTime;
}}
_lastReleaseTime=numPoints===1 ? _getCurrentTime():-1;
if(releaseTimeDiff!==-1&&releaseTimeDiff < 150){
gestureType='zoom';
}else{
gestureType='swipe';
}
if(_isZooming&&numPoints < 2){
_isZooming=false;
if(numPoints===1){
gestureType='zoomPointerUp';
}
_shout('zoomGestureEnded');
}
_currentPoints=null;
if(!_moved&&!_zoomStarted&&!_mainScrollAnimating&&!_verticalDragInitiated){
return;
}
_stopAllAnimations();
if(!_releaseAnimData){
_releaseAnimData=_initDragReleaseAnimationData();
}
_releaseAnimData.calculateSwipeSpeed('x');
if(_verticalDragInitiated){
var opacityRatio=_calculateVerticalDragOpacityRatio();
if(opacityRatio < _options.verticalDragRange){
self.close();
}else{
var initalPanY=_panOffset.y,
initialBgOpacity=_bgOpacity;
_animateProp('verticalDrag', 0, 1, 300, framework.easing.cubic.out, function(now){
_panOffset.y=(self.currItem.initialPosition.y - initalPanY) * now + initalPanY;
_applyBgOpacity((1 - initialBgOpacity) * now + initialBgOpacity);
_applyCurrentZoomPan();
});
_shout('onVerticalDrag', 1);
}
return;
}
if((_mainScrollShifted||_mainScrollAnimating)&&numPoints===0){
var itemChanged=_finishSwipeMainScrollGesture(gestureType, _releaseAnimData);
if(itemChanged){
return;
}
gestureType='zoomPointerUp';
}
if(_mainScrollAnimating){
return;
}
if(gestureType!=='swipe'){
_completeZoomGesture();
return;
}
if(!_mainScrollShifted&&_currZoomLevel > self.currItem.fitRatio){
_completePanGesture(_releaseAnimData);
}},
_initDragReleaseAnimationData=function(){
var lastFlickDuration,
tempReleasePos;
var s={
lastFlickOffset: {},
lastFlickDist: {},
lastFlickSpeed: {},
slowDownRatio:  {},
slowDownRatioReverse:  {},
speedDecelerationRatio:  {},
speedDecelerationRatioAbs:  {},
distanceOffset:  {},
backAnimDestination: {},
backAnimStarted: {},
calculateSwipeSpeed: function(axis){
if(_posPoints.length > 1){
lastFlickDuration=_getCurrentTime() - _gestureCheckSpeedTime + 50;
tempReleasePos=_posPoints[_posPoints.length-2][axis];
}else{
lastFlickDuration=_getCurrentTime() - _gestureStartTime;
tempReleasePos=_startPoint[axis];
}
s.lastFlickOffset[axis]=_currPoint[axis] - tempReleasePos;
s.lastFlickDist[axis]=Math.abs(s.lastFlickOffset[axis]);
if(s.lastFlickDist[axis] > 20){
s.lastFlickSpeed[axis]=s.lastFlickOffset[axis] / lastFlickDuration;
}else{
s.lastFlickSpeed[axis]=0;
}
if(Math.abs(s.lastFlickSpeed[axis]) < 0.1){
s.lastFlickSpeed[axis]=0;
}
s.slowDownRatio[axis]=0.95;
s.slowDownRatioReverse[axis]=1 - s.slowDownRatio[axis];
s.speedDecelerationRatio[axis]=1;
},
calculateOverBoundsAnimOffset: function(axis, speed){
if(!s.backAnimStarted[axis]){
if(_panOffset[axis] > _currPanBounds.min[axis]){
s.backAnimDestination[axis]=_currPanBounds.min[axis];
}else if(_panOffset[axis] < _currPanBounds.max[axis]){
s.backAnimDestination[axis]=_currPanBounds.max[axis];
}
if(s.backAnimDestination[axis]!==undefined){
s.slowDownRatio[axis]=0.7;
s.slowDownRatioReverse[axis]=1 - s.slowDownRatio[axis];
if(s.speedDecelerationRatioAbs[axis] < 0.05){
s.lastFlickSpeed[axis]=0;
s.backAnimStarted[axis]=true;
_animateProp('bounceZoomPan'+axis,_panOffset[axis],
s.backAnimDestination[axis],
speed||300,
framework.easing.sine.out,
function(pos){
_panOffset[axis]=pos;
_applyCurrentZoomPan();
}
);
}}
}},
calculateAnimOffset: function(axis){
if(!s.backAnimStarted[axis]){
s.speedDecelerationRatio[axis]=s.speedDecelerationRatio[axis] * (s.slowDownRatio[axis] +
s.slowDownRatioReverse[axis] -
s.slowDownRatioReverse[axis] * s.timeDiff / 10);
s.speedDecelerationRatioAbs[axis]=Math.abs(s.lastFlickSpeed[axis] * s.speedDecelerationRatio[axis]);
s.distanceOffset[axis]=s.lastFlickSpeed[axis] * s.speedDecelerationRatio[axis] * s.timeDiff;
_panOffset[axis] +=s.distanceOffset[axis];
}},
panAnimLoop: function(){
if(_animations.zoomPan){
_animations.zoomPan.raf=_requestAF(s.panAnimLoop);
s.now=_getCurrentTime();
s.timeDiff=s.now - s.lastNow;
s.lastNow=s.now;
s.calculateAnimOffset('x');
s.calculateAnimOffset('y');
_applyCurrentZoomPan();
s.calculateOverBoundsAnimOffset('x');
s.calculateOverBoundsAnimOffset('y');
if(s.speedDecelerationRatioAbs.x < 0.05&&s.speedDecelerationRatioAbs.y < 0.05){
_panOffset.x=Math.round(_panOffset.x);
_panOffset.y=Math.round(_panOffset.y);
_applyCurrentZoomPan();
_stopAnimation('zoomPan');
return;
}}
}};
return s;
},
_completePanGesture=function(animData){
animData.calculateSwipeSpeed('y');
_currPanBounds=self.currItem.bounds;
animData.backAnimDestination={};
animData.backAnimStarted={};
if(Math.abs(animData.lastFlickSpeed.x) <=0.05&&Math.abs(animData.lastFlickSpeed.y) <=0.05){
animData.speedDecelerationRatioAbs.x=animData.speedDecelerationRatioAbs.y=0;
animData.calculateOverBoundsAnimOffset('x');
animData.calculateOverBoundsAnimOffset('y');
return true;
}
_registerStartAnimation('zoomPan');
animData.lastNow=_getCurrentTime();
animData.panAnimLoop();
},
_finishSwipeMainScrollGesture=function(gestureType, _releaseAnimData){
var itemChanged;
if(!_mainScrollAnimating){
_currZoomedItemIndex=_currentItemIndex;
}
var itemsDiff;
if(gestureType==='swipe'){
var totalShiftDist=_currPoint.x - _startPoint.x,
isFastLastFlick=_releaseAnimData.lastFlickDist.x < 10;
if(totalShiftDist > MIN_SWIPE_DISTANCE &&
(isFastLastFlick||_releaseAnimData.lastFlickOffset.x > 20)){
itemsDiff=-1;
}else if(totalShiftDist < -MIN_SWIPE_DISTANCE &&
(isFastLastFlick||_releaseAnimData.lastFlickOffset.x < -20)){
itemsDiff=1;
}}
var nextCircle;
if(itemsDiff){
_currentItemIndex +=itemsDiff;
if(_currentItemIndex < 0){
_currentItemIndex=_options.loop ? _getNumItems()-1:0;
nextCircle=true;
}else if(_currentItemIndex >=_getNumItems()){
_currentItemIndex=_options.loop ? 0:_getNumItems()-1;
nextCircle=true;
}
if(!nextCircle||_options.loop){
_indexDiff +=itemsDiff;
_currPositionIndex -=itemsDiff;
itemChanged=true;
}}
var animateToX=_slideSize.x * _currPositionIndex;
var animateToDist=Math.abs(animateToX - _mainScrollPos.x);
var finishAnimDuration;
if(!itemChanged&&animateToX > _mainScrollPos.x!==_releaseAnimData.lastFlickSpeed.x > 0){
finishAnimDuration=333;
}else{
finishAnimDuration=Math.abs(_releaseAnimData.lastFlickSpeed.x) > 0 ?
animateToDist / Math.abs(_releaseAnimData.lastFlickSpeed.x) :
333;
finishAnimDuration=Math.min(finishAnimDuration, 400);
finishAnimDuration=Math.max(finishAnimDuration, 250);
}
if(_currZoomedItemIndex===_currentItemIndex){
itemChanged=false;
}
_mainScrollAnimating=true;
_shout('mainScrollAnimStart');
_animateProp('mainScroll', _mainScrollPos.x, animateToX, finishAnimDuration, framework.easing.cubic.out,
_moveMainScroll,
function(){
_stopAllAnimations();
_mainScrollAnimating=false;
_currZoomedItemIndex=-1;
if(itemChanged||_currZoomedItemIndex!==_currentItemIndex){
self.updateCurrItem();
}
_shout('mainScrollAnimComplete');
}
);
if(itemChanged){
self.updateCurrItem(true);
}
return itemChanged;
},
_calculateZoomLevel=function(touchesDistance){
return  1 / _startPointsDistance * touchesDistance * _startZoomLevel;
},
_completeZoomGesture=function(){
var destZoomLevel=_currZoomLevel,
minZoomLevel=_getMinZoomLevel(),
maxZoomLevel=_getMaxZoomLevel();
if(_currZoomLevel < minZoomLevel){
destZoomLevel=minZoomLevel;
}else if(_currZoomLevel > maxZoomLevel){
destZoomLevel=maxZoomLevel;
}
var destOpacity=1,
onUpdate,
initialOpacity=_bgOpacity;
if(_opacityChanged&&!_isZoomingIn&&!_wasOverInitialZoom&&_currZoomLevel < minZoomLevel){
self.close();
return true;
}
if(_opacityChanged){
onUpdate=function(now){
_applyBgOpacity((destOpacity - initialOpacity) * now + initialOpacity);
};}
self.zoomTo(destZoomLevel, 0, 200,  framework.easing.cubic.out, onUpdate);
return true;
};
_registerModule('Gestures', {
publicMethods: {
initGestures: function(){
var addEventNames=function(pref, down, move, up, cancel){
_dragStartEvent=pref + down;
_dragMoveEvent=pref + move;
_dragEndEvent=pref + up;
if(cancel){
_dragCancelEvent=pref + cancel;
}else{
_dragCancelEvent='';
}};
_pointerEventEnabled=_features.pointerEvent;
if(_pointerEventEnabled&&_features.touch){
_features.touch=false;
}
if(_pointerEventEnabled){
if(navigator.msPointerEnabled){
addEventNames('MSPointer', 'Down', 'Move', 'Up', 'Cancel');
}else{
addEventNames('pointer', 'down', 'move', 'up', 'cancel');
}}else if(_features.touch){
addEventNames('touch', 'start', 'move', 'end', 'cancel');
_likelyTouchDevice=true;
}else{
addEventNames('mouse', 'down', 'move', 'up');
}
_upMoveEvents=_dragMoveEvent + ' ' + _dragEndEvent  + ' ' +  _dragCancelEvent;
_downEvents=_dragStartEvent;
if(_pointerEventEnabled&&!_likelyTouchDevice){
_likelyTouchDevice=(navigator.maxTouchPoints > 1)||(navigator.msMaxTouchPoints > 1);
}
self.likelyTouchDevice=_likelyTouchDevice;
_globalEventHandlers[_dragStartEvent]=_onDragStart;
_globalEventHandlers[_dragMoveEvent]=_onDragMove;
_globalEventHandlers[_dragEndEvent]=_onDragRelease;
if(_dragCancelEvent){
_globalEventHandlers[_dragCancelEvent]=_globalEventHandlers[_dragEndEvent];
}
if(_features.touch){
_downEvents +=' mousedown';
_upMoveEvents +=' mousemove mouseup';
_globalEventHandlers.mousedown=_globalEventHandlers[_dragStartEvent];
_globalEventHandlers.mousemove=_globalEventHandlers[_dragMoveEvent];
_globalEventHandlers.mouseup=_globalEventHandlers[_dragEndEvent];
}
if(!_likelyTouchDevice){
_options.allowPanToNext=false;
}}
}});
var _showOrHideTimeout,
_showOrHide=function(item, img, out, completeFn){
if(_showOrHideTimeout){
clearTimeout(_showOrHideTimeout);
}
_initialZoomRunning=true;
_initialContentSet=true;
var thumbBounds;
if(item.initialLayout){
thumbBounds=item.initialLayout;
item.initialLayout=null;
}else{
thumbBounds=_options.getThumbBoundsFn&&_options.getThumbBoundsFn(_currentItemIndex);
}
var duration=out ? _options.hideAnimationDuration:_options.showAnimationDuration;
var onComplete=function(){
_stopAnimation('initialZoom');
if(!out){
_applyBgOpacity(1);
if(img){
img.style.display='block';
}
framework.addClass(template, 'pswp--animated-in');
_shout('initialZoom' + (out ? 'OutEnd':'InEnd'));
}else{
self.template.removeAttribute('style');
self.bg.removeAttribute('style');
}
if(completeFn){
completeFn();
}
_initialZoomRunning=false;
};
if(!duration||!thumbBounds||thumbBounds.x===undefined){
_shout('initialZoom' + (out ? 'Out':'In'));
_currZoomLevel=item.initialZoomLevel;
_equalizePoints(_panOffset,  item.initialPosition);
_applyCurrentZoomPan();
template.style.opacity=out ? 0:1;
_applyBgOpacity(1);
if(duration){
setTimeout(function(){
onComplete();
}, duration);
}else{
onComplete();
}
return;
}
var startAnimation=function(){
var closeWithRaf=_closedByScroll,
fadeEverything = !self.currItem.src||self.currItem.loadError||_options.showHideOpacity;
if(item.miniImg){
item.miniImg.style.webkitBackfaceVisibility='hidden';
}
if(!out){
_currZoomLevel=thumbBounds.w / item.w;
_panOffset.x=thumbBounds.x;
_panOffset.y=thumbBounds.y - _initalWindowScrollY;
self[fadeEverything ? 'template':'bg'].style.opacity=0.001;
_applyCurrentZoomPan();
}
_registerStartAnimation('initialZoom');
if(out&&!closeWithRaf){
framework.removeClass(template, 'pswp--animated-in');
}
if(fadeEverything){
if(out){
framework[ (closeWithRaf ? 'remove':'add') + 'Class' ](template, 'pswp--animate_opacity');
}else{
setTimeout(function(){
framework.addClass(template, 'pswp--animate_opacity');
}, 30);
}}
_showOrHideTimeout=setTimeout(function(){
_shout('initialZoom' + (out ? 'Out':'In'));
if(!out){
_currZoomLevel=item.initialZoomLevel;
_equalizePoints(_panOffset,  item.initialPosition);
_applyCurrentZoomPan();
_applyBgOpacity(1);
if(fadeEverything){
template.style.opacity=1;
}else{
_applyBgOpacity(1);
}
_showOrHideTimeout=setTimeout(onComplete, duration + 20);
}else{
var destZoomLevel=thumbBounds.w / item.w,
initialPanOffset={
x: _panOffset.x,
y: _panOffset.y
},
initialZoomLevel=_currZoomLevel,
initalBgOpacity=_bgOpacity,
onUpdate=function(now){
if(now===1){
_currZoomLevel=destZoomLevel;
_panOffset.x=thumbBounds.x;
_panOffset.y=thumbBounds.y  - _currentWindowScrollY;
}else{
_currZoomLevel=(destZoomLevel - initialZoomLevel) * now + initialZoomLevel;
_panOffset.x=(thumbBounds.x - initialPanOffset.x) * now + initialPanOffset.x;
_panOffset.y=(thumbBounds.y - _currentWindowScrollY - initialPanOffset.y) * now + initialPanOffset.y;
}
_applyCurrentZoomPan();
if(fadeEverything){
template.style.opacity=1 - now;
}else{
_applyBgOpacity(initalBgOpacity - now * initalBgOpacity);
}};
if(closeWithRaf){
_animateProp('initialZoom', 0, 1, duration, framework.easing.cubic.out, onUpdate, onComplete);
}else{
onUpdate(1);
_showOrHideTimeout=setTimeout(onComplete, duration + 20);
}}
}, out ? 25:90);
};
startAnimation();
};
var _items,
_tempPanAreaSize={},
_imagesToAppendPool=[],
_initialContentSet,
_initialZoomRunning,
_controllerDefaultOptions={
index: 0,
errorMsg: '<div class="pswp__error-msg"><a href="%url%" target="_blank">The image</a> could not be loaded.</div>',
forceProgressiveLoading: false,
preload: [1,1],
getNumItemsFn: function(){
return _items.length;
}};
var _getItemAt,
_getNumItems,
_initialIsLoop,
_getZeroBounds=function(){
return {
center:{x:0,y:0},
max:{x:0,y:0},
min:{x:0,y:0}};},
_calculateSingleItemPanBounds=function(item, realPanElementW, realPanElementH){
var bounds=item.bounds;
bounds.center.x=Math.round((_tempPanAreaSize.x - realPanElementW) / 2);
bounds.center.y=Math.round((_tempPanAreaSize.y - realPanElementH) / 2) + item.vGap.top;
bounds.max.x=(realPanElementW > _tempPanAreaSize.x) ?
Math.round(_tempPanAreaSize.x - realPanElementW) :
bounds.center.x;
bounds.max.y=(realPanElementH > _tempPanAreaSize.y) ?
Math.round(_tempPanAreaSize.y - realPanElementH) + item.vGap.top :
bounds.center.y;
bounds.min.x=(realPanElementW > _tempPanAreaSize.x) ? 0:bounds.center.x;
bounds.min.y=(realPanElementH > _tempPanAreaSize.y) ? item.vGap.top:bounds.center.y;
},
_calculateItemSize=function(item, viewportSize, zoomLevel){
if(item.src&&!item.loadError){
var isInitial = !zoomLevel;
if(isInitial){
if(!item.vGap){
item.vGap={top:0,bottom:0};}
_shout('parseVerticalMargin', item);
}
_tempPanAreaSize.x=viewportSize.x;
_tempPanAreaSize.y=viewportSize.y - item.vGap.top - item.vGap.bottom;
if(isInitial){
var hRatio=_tempPanAreaSize.x / item.w;
var vRatio=_tempPanAreaSize.y / item.h;
item.fitRatio=hRatio < vRatio ? hRatio:vRatio;
var scaleMode=_options.scaleMode;
if(scaleMode==='orig'){
zoomLevel=1;
}else if(scaleMode==='fit'){
zoomLevel=item.fitRatio;
}
if(zoomLevel > 1){
zoomLevel=1;
}
item.initialZoomLevel=zoomLevel;
if(!item.bounds){
item.bounds=_getZeroBounds();
}}
if(!zoomLevel){
return;
}
_calculateSingleItemPanBounds(item, item.w * zoomLevel, item.h * zoomLevel);
if(isInitial&&zoomLevel===item.initialZoomLevel){
item.initialPosition=item.bounds.center;
}
return item.bounds;
}else{
item.w=item.h=0;
item.initialZoomLevel=item.fitRatio=1;
item.bounds=_getZeroBounds();
item.initialPosition=item.bounds.center;
return item.bounds;
}},
_appendImage=function(index, item, baseDiv, img, preventAnimation, keepPlaceholder){
if(item.loadError){
return;
}
if(img){
item.imageAppended=true;
_setImageSize(item, img, (item===self.currItem&&_renderMaxResolution));
baseDiv.appendChild(img);
if(keepPlaceholder){
setTimeout(function(){
if(item&&item.loaded&&item.placeholder){
item.placeholder.style.display='none';
item.placeholder=null;
}}, 500);
}}
},
_preloadImage=function(item){
item.loading=true;
item.loaded=false;
var img=item.img=framework.createEl('pswp__img', 'img');
var onComplete=function(){
item.loading=false;
item.loaded=true;
if(item.loadComplete){
item.loadComplete(item);
}else{
item.img=null;
}
img.onload=img.onerror=null;
img=null;
};
img.onload=onComplete;
img.onerror=function(){
item.loadError=true;
onComplete();
};
img.src=item.src;
img.alt=item.alt||'';
return img;
},
_checkForError=function(item, cleanUp){
if(item.src&&item.loadError&&item.container){
if(cleanUp){
item.container.innerHTML='';
}
item.container.innerHTML=_options.errorMsg.replace('%url%',  item.src);
return true;
}},
_setImageSize=function(item, img, maxRes){
if(!item.src){
return;
}
if(!img){
img=item.container.lastChild;
}
var w=maxRes ? item.w:Math.round(item.w * item.fitRatio),
h=maxRes ? item.h:Math.round(item.h * item.fitRatio);
if(item.placeholder&&!item.loaded){
item.placeholder.style.width=w + 'px';
item.placeholder.style.height=h + 'px';
}
img.style.width=w + 'px';
img.style.height=h + 'px';
},
_appendImagesPool=function(){
if(_imagesToAppendPool.length){
var poolItem;
for(var i=0; i < _imagesToAppendPool.length; i++){
poolItem=_imagesToAppendPool[i];
if(poolItem.holder.index===poolItem.index){
_appendImage(poolItem.index, poolItem.item, poolItem.baseDiv, poolItem.img, false, poolItem.clearPlaceholder);
}}
_imagesToAppendPool=[];
}};
_registerModule('Controller', {
publicMethods: {
lazyLoadItem: function(index){
index=_getLoopedId(index);
var item=_getItemAt(index);
if(!item||((item.loaded||item.loading)&&!_itemsNeedUpdate)){
return;
}
_shout('gettingData', index, item);
if(!item.src){
return;
}
_preloadImage(item);
},
initController: function(){
framework.extend(_options, _controllerDefaultOptions, true);
self.items=_items=items;
_getItemAt=self.getItemAt;
_getNumItems=_options.getNumItemsFn; //self.getNumItems;
_initialIsLoop=_options.loop;
if(_getNumItems() < 3){
_options.loop=false;
}
_listen('beforeChange', function(diff){
var p=_options.preload,
isNext=diff===null ? true:(diff >=0),
preloadBefore=Math.min(p[0], _getNumItems()),
preloadAfter=Math.min(p[1], _getNumItems()),
i;
for(i=1; i <=(isNext ? preloadAfter:preloadBefore); i++){
self.lazyLoadItem(_currentItemIndex+i);
}
for(i=1; i <=(isNext ? preloadBefore:preloadAfter); i++){
self.lazyLoadItem(_currentItemIndex-i);
}});
_listen('initialLayout', function(){
self.currItem.initialLayout=_options.getThumbBoundsFn&&_options.getThumbBoundsFn(_currentItemIndex);
});
_listen('mainScrollAnimComplete', _appendImagesPool);
_listen('initialZoomInEnd', _appendImagesPool);
_listen('destroy', function(){
var item;
for(var i=0; i < _items.length; i++){
item=_items[i];
if(item.container){
item.container=null;
}
if(item.placeholder){
item.placeholder=null;
}
if(item.img){
item.img=null;
}
if(item.preloader){
item.preloader=null;
}
if(item.loadError){
item.loaded=item.loadError=false;
}}
_imagesToAppendPool=null;
});
},
getItemAt: function(index){
if(index >=0){
return _items[index]!==undefined ? _items[index]:false;
}
return false;
},
allowProgressiveImg: function(){
return _options.forceProgressiveLoading||!_likelyTouchDevice||_options.mouseUsed||screen.width > 1200;
},
setContent: function(holder, index){
if(_options.loop){
index=_getLoopedId(index);
}
var prevItem=self.getItemAt(holder.index);
if(prevItem){
prevItem.container=null;
}
var item=self.getItemAt(index),
img;
if(!item){
holder.el.innerHTML='';
return;
}
_shout('gettingData', index, item);
holder.index=index;
holder.item=item;
var baseDiv=item.container=framework.createEl('pswp__zoom-wrap');
if(!item.src&&item.html){
if(item.html.tagName){
baseDiv.appendChild(item.html);
}else{
baseDiv.innerHTML=item.html;
}}
_checkForError(item);
_calculateItemSize(item, _viewportSize);
if(item.src&&!item.loadError&&!item.loaded){
item.loadComplete=function(item){
if(!_isOpen){
return;
}
if(holder&&holder.index===index){
if(_checkForError(item, true)){
item.loadComplete=item.img=null;
_calculateItemSize(item, _viewportSize);
_applyZoomPanToItem(item);
if(holder.index===_currentItemIndex){
self.updateCurrZoomItem();
}
return;
}
if(!item.imageAppended){
if(_features.transform&&(_mainScrollAnimating||_initialZoomRunning)){
_imagesToAppendPool.push({
item:item,
baseDiv:baseDiv,
img:item.img,
index:index,
holder:holder,
clearPlaceholder:true
});
}else{
_appendImage(index, item, baseDiv, item.img, _mainScrollAnimating||_initialZoomRunning, true);
}}else{
if(!_initialZoomRunning&&item.placeholder){
item.placeholder.style.display='none';
item.placeholder=null;
}}
}
item.loadComplete=null;
item.img=null;
_shout('imageLoadComplete', index, item);
};
if(framework.features.transform){
var placeholderClassName='pswp__img pswp__img--placeholder';
placeholderClassName +=(item.msrc ? '':' pswp__img--placeholder--blank');
var placeholder=framework.createEl(placeholderClassName, item.msrc ? 'img':'');
if(item.msrc){
placeholder.src=item.msrc;
}
_setImageSize(item, placeholder);
baseDiv.appendChild(placeholder);
item.placeholder=placeholder;
}
if(!item.loading){
_preloadImage(item);
}
if(self.allowProgressiveImg()){
if(!_initialContentSet&&_features.transform){
_imagesToAppendPool.push({
item:item,
baseDiv:baseDiv,
img:item.img,
index:index,
holder:holder
});
}else{
_appendImage(index, item, baseDiv, item.img, true, true);
}}
}else if(item.src&&!item.loadError){
img=framework.createEl('pswp__img', 'img');
img.style.opacity=1;
img.src=item.src;
_setImageSize(item, img);
_appendImage(index, item, baseDiv, img, true);
}
if(!_initialContentSet&&index===_currentItemIndex){
_currZoomElementStyle=baseDiv.style;
_showOrHide(item, (img||item.img));
}else{
_applyZoomPanToItem(item);
}
holder.el.innerHTML='';
holder.el.appendChild(baseDiv);
},
cleanSlide: function(item){
if(item.img){
item.img.onload=item.img.onerror=null;
}
item.loaded=item.loading=item.img=item.imageAppended=false;
}}
});
var tapTimer,
tapReleasePoint={},
_dispatchTapEvent=function(origEvent, releasePoint, pointerType){
var e=document.createEvent('CustomEvent'),
eDetail={
origEvent:origEvent,
target:origEvent.target,
releasePoint: releasePoint,
pointerType:pointerType||'touch'
};
e.initCustomEvent('pswpTap', true, true, eDetail);
origEvent.target.dispatchEvent(e);
};
_registerModule('Tap', {
publicMethods: {
initTap: function(){
_listen('firstTouchStart', self.onTapStart);
_listen('touchRelease', self.onTapRelease);
_listen('destroy', function(){
tapReleasePoint={};
tapTimer=null;
});
},
onTapStart: function(touchList){
if(touchList.length > 1){
clearTimeout(tapTimer);
tapTimer=null;
}},
onTapRelease: function(e, releasePoint){
if(!releasePoint){
return;
}
if(!_moved&&!_isMultitouch&&!_numAnimations&&self.container.contains(e.target)){
var p0=releasePoint;
if(tapTimer){
clearTimeout(tapTimer);
tapTimer=null;
if(_isNearbyPoints(p0, tapReleasePoint)){
_shout('doubleTap', p0);
return;
}}
if(releasePoint.type==='mouse'){
_dispatchTapEvent(e, releasePoint, 'mouse');
return;
}
var clickedTagName=e.target.tagName.toUpperCase();
if(clickedTagName==='BUTTON'||framework.hasClass(e.target, 'pswp__single-tap')){
_dispatchTapEvent(e, releasePoint);
return;
}
_equalizePoints(tapReleasePoint, p0);
tapTimer=setTimeout(function(){
_dispatchTapEvent(e, releasePoint);
tapTimer=null;
}, 300);
}}
}});
var _wheelDelta;
_registerModule('DesktopZoom', {
publicMethods: {
initDesktopZoom: function(){
if(_oldIE){
return;
}
if(_likelyTouchDevice){
_listen('mouseUsed', function(){
self.setupDesktopZoom();
});
}else{
self.setupDesktopZoom(true);
}},
setupDesktopZoom: function(onInit){
_wheelDelta={};
var events='wheel mousewheel DOMMouseScroll';
_listen('bindEvents', function(){
framework.bind(template, events,  self.handleMouseWheel);
});
_listen('unbindEvents', function(){
if(_wheelDelta){
framework.unbind(template, events, self.handleMouseWheel);
}});
self.mouseZoomedIn=false;
var hasDraggingClass,
updateZoomable=function(){
if(self.mouseZoomedIn){
framework.removeClass(template, 'pswp--zoomed-in');
self.mouseZoomedIn=false;
}
if(_currZoomLevel < 1){
framework.addClass(template, 'pswp--zoom-allowed');
}else{
framework.removeClass(template, 'pswp--zoom-allowed');
}
removeDraggingClass();
},
removeDraggingClass=function(){
if(hasDraggingClass){
framework.removeClass(template, 'pswp--dragging');
hasDraggingClass=false;
}};
_listen('resize' , updateZoomable);
_listen('afterChange' , updateZoomable);
_listen('pointerDown', function(){
if(self.mouseZoomedIn){
hasDraggingClass=true;
framework.addClass(template, 'pswp--dragging');
}});
_listen('pointerUp', removeDraggingClass);
if(!onInit){
updateZoomable();
}},
handleMouseWheel: function(e){
if(_currZoomLevel <=self.currItem.fitRatio){
if(_options.modal){
if(!_options.closeOnScroll||_numAnimations||_isDragging){
e.preventDefault();
}else if(_transformKey&&Math.abs(e.deltaY) > 2){
_closedByScroll=true;
self.close();
}}
return true;
}
e.stopPropagation();
_wheelDelta.x=0;
if('deltaX' in e){
if(e.deltaMode===1 ){
_wheelDelta.x=e.deltaX * 18;
_wheelDelta.y=e.deltaY * 18;
}else{
_wheelDelta.x=e.deltaX;
_wheelDelta.y=e.deltaY;
}}else if('wheelDelta' in e){
if(e.wheelDeltaX){
_wheelDelta.x=-0.16 * e.wheelDeltaX;
}
if(e.wheelDeltaY){
_wheelDelta.y=-0.16 * e.wheelDeltaY;
}else{
_wheelDelta.y=-0.16 * e.wheelDelta;
}}else if('detail' in e){
_wheelDelta.y=e.detail;
}else{
return;
}
_calculatePanBounds(_currZoomLevel, true);
var newPanX=_panOffset.x - _wheelDelta.x,
newPanY=_panOffset.y - _wheelDelta.y;
if(_options.modal ||
(
newPanX <=_currPanBounds.min.x&&newPanX >=_currPanBounds.max.x &&
newPanY <=_currPanBounds.min.y&&newPanY >=_currPanBounds.max.y
)){
e.preventDefault();
}
self.panTo(newPanX, newPanY);
},
toggleDesktopZoom: function(centerPoint){
centerPoint=centerPoint||{x:_viewportSize.x/2 + _offset.x, y:_viewportSize.y/2 + _offset.y };
var doubleTapZoomLevel=_options.getDoubleTapZoom(true, self.currItem);
var zoomOut=_currZoomLevel===doubleTapZoomLevel;
self.mouseZoomedIn = !zoomOut;
self.zoomTo(zoomOut ? self.currItem.initialZoomLevel:doubleTapZoomLevel, centerPoint, 333);
framework[ (!zoomOut ? 'add':'remove') + 'Class'](template, 'pswp--zoomed-in');
}}
});
var _historyDefaultOptions={
history: true,
galleryUID: 1
};
var _historyUpdateTimeout,
_hashChangeTimeout,
_hashAnimCheckTimeout,
_hashChangedByScript,
_hashChangedByHistory,
_hashReseted,
_initialHash,
_historyChanged,
_closedFromURL,
_urlChangedOnce,
_windowLoc,
_supportsPushState,
_getHash=function(){
return _windowLoc.hash.substring(1);
},
_cleanHistoryTimeouts=function(){
if(_historyUpdateTimeout){
clearTimeout(_historyUpdateTimeout);
}
if(_hashAnimCheckTimeout){
clearTimeout(_hashAnimCheckTimeout);
}},
_parseItemIndexFromURL=function(){
var hash=_getHash(),
params={};
if(hash.length < 5){
return params;
}
var i, vars=hash.split('&');
for (i=0; i < vars.length; i++){
if(!vars[i]){
continue;
}
var pair=vars[i].split('=');
if(pair.length < 2){
continue;
}
params[pair[0]]=pair[1];
}
if(_options.galleryPIDs){
var searchfor=params.pid;
params.pid=0;
for(i=0; i < _items.length; i++){
if(_items[i].pid===searchfor){
params.pid=i;
break;
}}
}else{
params.pid=parseInt(params.pid,10)-1;
}
if(params.pid < 0){
params.pid=0;
}
return params;
},
_updateHash=function(){
if(_hashAnimCheckTimeout){
clearTimeout(_hashAnimCheckTimeout);
}
if(_numAnimations||_isDragging){
_hashAnimCheckTimeout=setTimeout(_updateHash, 500);
return;
}
if(_hashChangedByScript){
clearTimeout(_hashChangeTimeout);
}else{
_hashChangedByScript=true;
}
var pid=(_currentItemIndex + 1);
var item=_getItemAt(_currentItemIndex);
if(item.hasOwnProperty('pid')){
pid=item.pid;
}
var newHash=_initialHash + '&'  +  'gid=' + _options.galleryUID + '&' + 'pid=' + pid;
if(!_historyChanged){
if(_windowLoc.hash.indexOf(newHash)===-1){
_urlChangedOnce=true;
}}
var newURL=_windowLoc.href.split('#')[0] + '#' +  newHash;
if(_supportsPushState){
if('#' + newHash!==window.location.hash){
history[_historyChanged ? 'replaceState':'pushState']('', document.title, newURL);
}}else{
if(_historyChanged){
_windowLoc.replace(newURL);
}else{
_windowLoc.hash=newHash;
}}
_historyChanged=true;
_hashChangeTimeout=setTimeout(function(){
_hashChangedByScript=false;
}, 60);
};
_registerModule('History', {
publicMethods: {
initHistory: function(){
framework.extend(_options, _historyDefaultOptions, true);
if(!_options.history){
return;
}
_windowLoc=window.location;
_urlChangedOnce=false;
_closedFromURL=false;
_historyChanged=false;
_initialHash=_getHash();
_supportsPushState=('pushState' in history);
if(_initialHash.indexOf('gid=') > -1){
_initialHash=_initialHash.split('&gid=')[0];
_initialHash=_initialHash.split('?gid=')[0];
}
_listen('afterChange', self.updateURL);
_listen('unbindEvents', function(){
framework.unbind(window, 'hashchange', self.onHashChange);
});
var returnToOriginal=function(){
_hashReseted=true;
if(!_closedFromURL){
if(_urlChangedOnce){
history.back();
}else{
if(_initialHash){
_windowLoc.hash=_initialHash;
}else{
if(_supportsPushState){
history.pushState('', document.title,  _windowLoc.pathname + _windowLoc.search);
}else{
_windowLoc.hash='';
}}
}}
_cleanHistoryTimeouts();
};
_listen('unbindEvents', function(){
if(_closedByScroll){
returnToOriginal();
}});
_listen('destroy', function(){
if(!_hashReseted){
returnToOriginal();
}});
_listen('firstUpdate', function(){
_currentItemIndex=_parseItemIndexFromURL().pid;
});
var index=_initialHash.indexOf('pid=');
if(index > -1){
_initialHash=_initialHash.substring(0, index);
if(_initialHash.slice(-1)==='&'){
_initialHash=_initialHash.slice(0, -1);
}}
setTimeout(function(){
if(_isOpen){
framework.bind(window, 'hashchange', self.onHashChange);
}}, 40);
},
onHashChange: function(){
if(_getHash()===_initialHash){
_closedFromURL=true;
self.close();
return;
}
if(!_hashChangedByScript){
_hashChangedByHistory=true;
self.goTo(_parseItemIndexFromURL().pid);
_hashChangedByHistory=false;
}},
updateURL: function(){
_cleanHistoryTimeouts();
if(_hashChangedByHistory){
return;
}
if(!_historyChanged){
_updateHash();
}else{
_historyUpdateTimeout=setTimeout(_updateHash, 800);
}}
}});
framework.extend(self, publicMethods); };
return PhotoSwipe;
});
(function (root, factory){
if(typeof define==='function'&&define.amd){
define(factory);
}else if(typeof exports==='object'){
module.exports=factory();
}else{
root.PhotoSwipeUI_Default=factory();
}})(this, function (){
'use strict';
var PhotoSwipeUI_Default =
function(pswp, framework){
var ui=this;
var _overlayUIUpdated=false,
_controlsVisible=true,
_fullscrenAPI,
_controls,
_captionContainer,
_fakeCaptionContainer,
_indexIndicator,
_shareButton,
_shareModal,
_shareModalHidden=true,
_initalCloseOnScrollValue,
_isIdle,
_listen,
_loadingIndicator,
_loadingIndicatorHidden,
_loadingIndicatorTimeout,
_galleryHasOneSlide,
_options,
_defaultUIOptions={
barsSize: {top:44, bottom:'auto'},
closeElClasses: ['item', 'caption', 'zoom-wrap', 'ui', 'top-bar'],
timeToIdle: 4000,
timeToIdleOutside: 1000,
loadingIndicatorDelay: 1000,
addCaptionHTMLFn: function(item, captionEl ){
if(!item.title){
captionEl.children[0].innerHTML='';
return false;
}
captionEl.children[0].innerHTML=item.title;
return true;
},
closeEl:true,
captionEl: true,
fullscreenEl: true,
zoomEl: true,
shareEl: true,
counterEl: true,
arrowEl: true,
preloaderEl: true,
tapToClose: false,
tapToToggleControls: true,
clickToCloseNonZoomable: true,
shareButtons: [
{id:'facebook', label:'Share on Facebook', url:'https://www.facebook.com/sharer/sharer.php?u={{url}}'},
{id:'twitter', label:'Tweet', url:'https://twitter.com/intent/tweet?text={{text}}&url={{url}}'},
{id:'pinterest', label:'Pin it', url:'http://www.pinterest.com/pin/create/button/'+
'?url={{url}}&media={{image_url}}&description={{text}}'},
{id:'download', label:'Download image', url:'{{raw_image_url}}', download:true}
],
getImageURLForShare: function(){
return pswp.currItem.src||'';
},
getPageURLForShare: function(){
return window.location.href;
},
getTextForShare: function(){
return pswp.currItem.title||'';
},
indexIndicatorSep: ' / ',
fitControlsWidth: 1200
},
_blockControlsTap,
_blockControlsTapTimeout;
var _onControlsTap=function(e){
if(_blockControlsTap){
return true;
}
e=e||window.event;
if(_options.timeToIdle&&_options.mouseUsed&&!_isIdle){
_onIdleMouseMove();
}
var target=e.target||e.srcElement,
uiElement,
clickedClass=target.getAttribute('class')||'',
found;
for(var i=0; i < _uiElements.length; i++){
uiElement=_uiElements[i];
if(uiElement.onTap&&clickedClass.indexOf('pswp__' + uiElement.name) > -1){
uiElement.onTap();
found=true;
}}
if(found){
if(e.stopPropagation){
e.stopPropagation();
}
_blockControlsTap=true;
var tapDelay=framework.features.isOldAndroid ? 600:30;
_blockControlsTapTimeout=setTimeout(function(){
_blockControlsTap=false;
}, tapDelay);
}},
_fitControlsInViewport=function(){
return !pswp.likelyTouchDevice||_options.mouseUsed||screen.width > _options.fitControlsWidth;
},
_togglePswpClass=function(el, cName, add){
framework[ (add ? 'add':'remove') + 'Class' ](el, 'pswp__' + cName);
},
_countNumItems=function(){
var hasOneSlide=(_options.getNumItemsFn()===1);
if(hasOneSlide!==_galleryHasOneSlide){
_togglePswpClass(_controls, 'ui--one-slide', hasOneSlide);
_galleryHasOneSlide=hasOneSlide;
}},
_toggleShareModalClass=function(){
_togglePswpClass(_shareModal, 'share-modal--hidden', _shareModalHidden);
},
_toggleShareModal=function(){
_shareModalHidden = !_shareModalHidden;
if(!_shareModalHidden){
_toggleShareModalClass();
setTimeout(function(){
if(!_shareModalHidden){
framework.addClass(_shareModal, 'pswp__share-modal--fade-in');
}}, 30);
}else{
framework.removeClass(_shareModal, 'pswp__share-modal--fade-in');
setTimeout(function(){
if(_shareModalHidden){
_toggleShareModalClass();
}}, 300);
}
if(!_shareModalHidden){
_updateShareURLs();
}
return false;
},
_openWindowPopup=function(e){
e=e||window.event;
var target=e.target||e.srcElement;
pswp.shout('shareLinkClick', e, target);
if(!target.href){
return false;
}
if(target.hasAttribute('download')){
return true;
}
window.open(target.href, 'pswp_share', 'scrollbars=yes,resizable=yes,toolbar=no,'+
'location=yes,width=550,height=420,top=100,left=' +
(window.screen ? Math.round(screen.width / 2 - 275):100));
if(!_shareModalHidden){
_toggleShareModal();
}
return false;
},
_updateShareURLs=function(){
var shareButtonOut='',
shareButtonData,
shareURL,
image_url,
page_url,
share_text;
for(var i=0; i < _options.shareButtons.length; i++){
shareButtonData=_options.shareButtons[i];
image_url=_options.getImageURLForShare(shareButtonData);
page_url=_options.getPageURLForShare(shareButtonData);
share_text=_options.getTextForShare(shareButtonData);
shareURL=shareButtonData.url.replace('{{url}}', encodeURIComponent(page_url))
.replace('{{image_url}}', encodeURIComponent(image_url))
.replace('{{raw_image_url}}', image_url)
.replace('{{text}}', encodeURIComponent(share_text));
shareButtonOut +='<a href="' + shareURL + '" target="_blank" '+
'class="pswp__share--' + shareButtonData.id + '"' +
(shareButtonData.download ? 'download':'') + '>' +
shareButtonData.label + '</a>';
if(_options.parseShareButtonOut){
shareButtonOut=_options.parseShareButtonOut(shareButtonData, shareButtonOut);
}}
_shareModal.children[0].innerHTML=shareButtonOut;
_shareModal.children[0].onclick=_openWindowPopup;
},
_hasCloseClass=function(target){
for(var  i=0; i < _options.closeElClasses.length; i++){
if(framework.hasClass(target, 'pswp__' + _options.closeElClasses[i])){
return true;
}}
},
_idleInterval,
_idleTimer,
_idleIncrement=0,
_onIdleMouseMove=function(){
clearTimeout(_idleTimer);
_idleIncrement=0;
if(_isIdle){
ui.setIdle(false);
}},
_onMouseLeaveWindow=function(e){
e=e ? e:window.event;
var from=e.relatedTarget||e.toElement;
if(!from||from.nodeName==='HTML'){
clearTimeout(_idleTimer);
_idleTimer=setTimeout(function(){
ui.setIdle(true);
}, _options.timeToIdleOutside);
}},
_setupFullscreenAPI=function(){
if(_options.fullscreenEl&&!framework.features.isOldAndroid){
if(!_fullscrenAPI){
_fullscrenAPI=ui.getFullscreenAPI();
}
if(_fullscrenAPI){
framework.bind(document, _fullscrenAPI.eventK, ui.updateFullscreen);
ui.updateFullscreen();
framework.addClass(pswp.template, 'pswp--supports-fs');
}else{
framework.removeClass(pswp.template, 'pswp--supports-fs');
}}
},
_setupLoadingIndicator=function(){
if(_options.preloaderEl){
_toggleLoadingIndicator(true);
_listen('beforeChange', function(){
clearTimeout(_loadingIndicatorTimeout);
_loadingIndicatorTimeout=setTimeout(function(){
if(pswp.currItem&&pswp.currItem.loading){
if(!pswp.allowProgressiveImg()||(pswp.currItem.img&&!pswp.currItem.img.naturalWidth)){
_toggleLoadingIndicator(false);
}}else{
_toggleLoadingIndicator(true);
}}, _options.loadingIndicatorDelay);
});
_listen('imageLoadComplete', function(index, item){
if(pswp.currItem===item){
_toggleLoadingIndicator(true);
}});
}},
_toggleLoadingIndicator=function(hide){
if(_loadingIndicatorHidden!==hide){
_togglePswpClass(_loadingIndicator, 'preloader--active', !hide);
_loadingIndicatorHidden=hide;
}},
_applyNavBarGaps=function(item){
var gap=item.vGap;
if(_fitControlsInViewport()){
var bars=_options.barsSize;
if(_options.captionEl&&bars.bottom==='auto'){
if(!_fakeCaptionContainer){
_fakeCaptionContainer=framework.createEl('pswp__caption pswp__caption--fake');
_fakeCaptionContainer.appendChild(framework.createEl('pswp__caption__center'));
_controls.insertBefore(_fakeCaptionContainer, _captionContainer);
framework.addClass(_controls, 'pswp__ui--fit');
}
if(_options.addCaptionHTMLFn(item, _fakeCaptionContainer, true)){
var captionSize=_fakeCaptionContainer.clientHeight;
gap.bottom=parseInt(captionSize,10)||44;
}else{
gap.bottom=bars.top;
}}else{
gap.bottom=bars.bottom==='auto' ? 0:bars.bottom;
}
gap.top=bars.top;
}else{
gap.top=gap.bottom=0;
}},
_setupIdle=function(){
if(_options.timeToIdle){
_listen('mouseUsed', function(){
framework.bind(document, 'mousemove', _onIdleMouseMove);
framework.bind(document, 'mouseout', _onMouseLeaveWindow);
_idleInterval=setInterval(function(){
_idleIncrement++;
if(_idleIncrement===2){
ui.setIdle(true);
}}, _options.timeToIdle / 2);
});
}},
_setupHidingControlsDuringGestures=function(){
_listen('onVerticalDrag', function(now){
if(_controlsVisible&&now < 0.95){
ui.hideControls();
}else if(!_controlsVisible&&now >=0.95){
ui.showControls();
}});
var pinchControlsHidden;
_listen('onPinchClose' , function(now){
if(_controlsVisible&&now < 0.9){
ui.hideControls();
pinchControlsHidden=true;
}else if(pinchControlsHidden&&!_controlsVisible&&now > 0.9){
ui.showControls();
}});
_listen('zoomGestureEnded', function(){
pinchControlsHidden=false;
if(pinchControlsHidden&&!_controlsVisible){
ui.showControls();
}});
};
var _uiElements=[
{
name: 'caption',
option: 'captionEl',
onInit: function(el){
_captionContainer=el;
}},
{
name: 'share-modal',
option: 'shareEl',
onInit: function(el){
_shareModal=el;
},
onTap: function(){
_toggleShareModal();
}},
{
name: 'button--share',
option: 'shareEl',
onInit: function(el){
_shareButton=el;
},
onTap: function(){
_toggleShareModal();
}},
{
name: 'button--zoom',
option: 'zoomEl',
onTap: pswp.toggleDesktopZoom
},
{
name: 'counter',
option: 'counterEl',
onInit: function(el){
_indexIndicator=el;
}},
{
name: 'button--close',
option: 'closeEl',
onTap: pswp.close
},
{
name: 'button--arrow--left',
option: 'arrowEl',
onTap: pswp.prev
},
{
name: 'button--arrow--right',
option: 'arrowEl',
onTap: pswp.next
},
{
name: 'button--fs',
option: 'fullscreenEl',
onTap: function(){
if(_fullscrenAPI.isFullscreen()){
_fullscrenAPI.exit();
}else{
_fullscrenAPI.enter();
}}
},
{
name: 'preloader',
option: 'preloaderEl',
onInit: function(el){
_loadingIndicator=el;
}}
];
var _setupUIElements=function(){
var item,
classAttr,
uiElement;
var loopThroughChildElements=function(sChildren){
if(!sChildren){
return;
}
var l=sChildren.length;
for(var i=0; i < l; i++){
item=sChildren[i];
classAttr=item.className;
for(var a=0; a < _uiElements.length; a++){
uiElement=_uiElements[a];
if(classAttr.indexOf('pswp__' + uiElement.name) > -1){
if(_options[uiElement.option]){
framework.removeClass(item, 'pswp__element--disabled');
if(uiElement.onInit){
uiElement.onInit(item);
}}else{
framework.addClass(item, 'pswp__element--disabled');
}}
}}
};
loopThroughChildElements(_controls.children);
var topBar=framework.getChildByClass(_controls, 'pswp__top-bar');
if(topBar){
loopThroughChildElements(topBar.children);
}};
ui.init=function(){
framework.extend(pswp.options, _defaultUIOptions, true);
_options=pswp.options;
_controls=framework.getChildByClass(pswp.scrollWrap, 'pswp__ui');
_listen=pswp.listen;
_setupHidingControlsDuringGestures();
_listen('beforeChange', ui.update);
_listen('doubleTap', function(point){
var initialZoomLevel=pswp.currItem.initialZoomLevel;
if(pswp.getZoomLevel()!==initialZoomLevel){
pswp.zoomTo(initialZoomLevel, point, 333);
}else{
pswp.zoomTo(_options.getDoubleTapZoom(false, pswp.currItem), point, 333);
}});
_listen('preventDragEvent', function(e, isDown, preventObj){
var t=e.target||e.srcElement;
if(t &&
t.getAttribute('class')&&e.type.indexOf('mouse') > -1 &&
(t.getAttribute('class').indexOf('__caption') > 0||(/(SMALL|STRONG|EM)/i).test(t.tagName))
){
preventObj.prevent=false;
}});
_listen('bindEvents', function(){
framework.bind(_controls, 'pswpTap click', _onControlsTap);
framework.bind(pswp.scrollWrap, 'pswpTap', ui.onGlobalTap);
if(!pswp.likelyTouchDevice){
framework.bind(pswp.scrollWrap, 'mouseover', ui.onMouseOver);
}});
_listen('unbindEvents', function(){
if(!_shareModalHidden){
_toggleShareModal();
}
if(_idleInterval){
clearInterval(_idleInterval);
}
framework.unbind(document, 'mouseout', _onMouseLeaveWindow);
framework.unbind(document, 'mousemove', _onIdleMouseMove);
framework.unbind(_controls, 'pswpTap click', _onControlsTap);
framework.unbind(pswp.scrollWrap, 'pswpTap', ui.onGlobalTap);
framework.unbind(pswp.scrollWrap, 'mouseover', ui.onMouseOver);
if(_fullscrenAPI){
framework.unbind(document, _fullscrenAPI.eventK, ui.updateFullscreen);
if(_fullscrenAPI.isFullscreen()){
_options.hideAnimationDuration=0;
_fullscrenAPI.exit();
}
_fullscrenAPI=null;
}});
_listen('destroy', function(){
if(_options.captionEl){
if(_fakeCaptionContainer){
_controls.removeChild(_fakeCaptionContainer);
}
framework.removeClass(_captionContainer, 'pswp__caption--empty');
}
if(_shareModal){
_shareModal.children[0].onclick=null;
}
framework.removeClass(_controls, 'pswp__ui--over-close');
framework.addClass(_controls, 'pswp__ui--hidden');
ui.setIdle(false);
});
if(!_options.showAnimationDuration){
framework.removeClass(_controls, 'pswp__ui--hidden');
}
_listen('initialZoomIn', function(){
if(_options.showAnimationDuration){
framework.removeClass(_controls, 'pswp__ui--hidden');
}});
_listen('initialZoomOut', function(){
framework.addClass(_controls, 'pswp__ui--hidden');
});
_listen('parseVerticalMargin', _applyNavBarGaps);
_setupUIElements();
if(_options.shareEl&&_shareButton&&_shareModal){
_shareModalHidden=true;
}
_countNumItems();
_setupIdle();
_setupFullscreenAPI();
_setupLoadingIndicator();
};
ui.setIdle=function(isIdle){
_isIdle=isIdle;
_togglePswpClass(_controls, 'ui--idle', isIdle);
};
ui.update=function(){
if(_controlsVisible&&pswp.currItem){
ui.updateIndexIndicator();
if(_options.captionEl){
_options.addCaptionHTMLFn(pswp.currItem, _captionContainer);
_togglePswpClass(_captionContainer, 'caption--empty', !pswp.currItem.title);
}
_overlayUIUpdated=true;
}else{
_overlayUIUpdated=false;
}
if(!_shareModalHidden){
_toggleShareModal();
}
_countNumItems();
};
ui.updateFullscreen=function(e){
if(e){
setTimeout(function(){
pswp.setScrollOffset(0, framework.getScrollY());
}, 50);
}
framework[ (_fullscrenAPI.isFullscreen() ? 'add':'remove') + 'Class' ](pswp.template, 'pswp--fs');
};
ui.updateIndexIndicator=function(){
if(_options.counterEl){
_indexIndicator.innerHTML=(pswp.getCurrentIndex()+1) +
_options.indexIndicatorSep +
_options.getNumItemsFn();
}};
ui.onGlobalTap=function(e){
e=e||window.event;
var target=e.target||e.srcElement;
if(_blockControlsTap){
return;
}
if(e.detail&&e.detail.pointerType==='mouse'){
if(_hasCloseClass(target)){
pswp.close();
return;
}
if(framework.hasClass(target, 'pswp__img')){
if(pswp.getZoomLevel()===1&&pswp.getZoomLevel() <=pswp.currItem.fitRatio){
if(_options.clickToCloseNonZoomable){
pswp.close();
}}else{
pswp.toggleDesktopZoom(e.detail.releasePoint);
}}
}else{
if(_options.tapToToggleControls){
if(_controlsVisible){
ui.hideControls();
}else{
ui.showControls();
}}
if(_options.tapToClose&&(framework.hasClass(target, 'pswp__img')||_hasCloseClass(target))){
pswp.close();
return;
}}
};
ui.onMouseOver=function(e){
e=e||window.event;
var target=e.target||e.srcElement;
_togglePswpClass(_controls, 'ui--over-close', _hasCloseClass(target));
};
ui.hideControls=function(){
framework.addClass(_controls,'pswp__ui--hidden');
_controlsVisible=false;
};
ui.showControls=function(){
_controlsVisible=true;
if(!_overlayUIUpdated){
ui.update();
}
framework.removeClass(_controls,'pswp__ui--hidden');
};
ui.supportsFullscreen=function(){
var d=document;
return !!(d.exitFullscreen||d.mozCancelFullScreen||d.webkitExitFullscreen||d.msExitFullscreen);
};
ui.getFullscreenAPI=function(){
var dE=document.documentElement,
api,
tF='fullscreenchange';
if(dE.requestFullscreen){
api={
enterK: 'requestFullscreen',
exitK: 'exitFullscreen',
elementK: 'fullscreenElement',
eventK: tF
};}else if(dE.mozRequestFullScreen){
api={
enterK: 'mozRequestFullScreen',
exitK: 'mozCancelFullScreen',
elementK: 'mozFullScreenElement',
eventK: 'moz' + tF
};}else if(dE.webkitRequestFullscreen){
api={
enterK: 'webkitRequestFullscreen',
exitK: 'webkitExitFullscreen',
elementK: 'webkitFullscreenElement',
eventK: 'webkit' + tF
};}else if(dE.msRequestFullscreen){
api={
enterK: 'msRequestFullscreen',
exitK: 'msExitFullscreen',
elementK: 'msFullscreenElement',
eventK: 'MSFullscreenChange'
};}
if(api){
api.enter=function(){
_initalCloseOnScrollValue=_options.closeOnScroll;
_options.closeOnScroll=false;
if(this.enterK==='webkitRequestFullscreen'){
pswp.template[this.enterK](Element.ALLOW_KEYBOARD_INPUT);
}else{
return pswp.template[this.enterK]();
}};
api.exit=function(){
_options.closeOnScroll=_initalCloseOnScrollValue;
return document[this.exitK]();
};
api.isFullscreen=function(){ return document[this.elementK]; };}
return api;
};};
return PhotoSwipeUI_Default;
});
jQuery(function($){
if(typeof wc_single_product_params==='undefined'){
return false;
}
$('body')
.on('init', '.wc-tabs-wrapper, .woocommerce-tabs', function(){
$(this).find('.wc-tab, .woocommerce-tabs .panel:not(.panel .panel)').hide();
var hash=window.location.hash;
var url=window.location.href;
var $tabs=$(this).find('.wc-tabs, ul.tabs').first();
if(hash.toLowerCase().indexOf('comment-') >=0||hash==='#reviews'||hash==='#tab-reviews'){
$tabs.find('li.reviews_tab a').trigger('click');
}else if(url.indexOf('comment-page-') > 0||url.indexOf('cpage=') > 0){
$tabs.find('li.reviews_tab a').trigger('click');
}else if(hash==='#tab-additional_information'){
$tabs.find('li.additional_information_tab a').trigger('click');
}else{
$tabs.find('li:first a').trigger('click');
}})
.on('click', '.wc-tabs li a, ul.tabs li a', function(e){
e.preventDefault();
var $tab=$(this);
var $tabs_wrapper=$tab.closest('.wc-tabs-wrapper, .woocommerce-tabs');
var $tabs=$tabs_wrapper.find('.wc-tabs, ul.tabs');
$tabs.find('li').removeClass('active');
$tabs
.find('a[role="tab"]')
.attr('aria-selected', 'false')
.attr('tabindex', '-1');
$tabs_wrapper.find('.wc-tab, .panel:not(.panel .panel)').hide();
$tab.closest('li').addClass('active');
$tab
.attr('aria-selected', 'true')
.attr('tabindex', '0');
$tabs_wrapper.find('#' + $tab.attr('href').split('#')[1]).show();
})
.on('keydown', '.wc-tabs li a, ul.tabs li a', function(e){
var isRTL=document.documentElement.dir==='rtl';
var direction=e.key;
var next=isRTL ? 'ArrowLeft':'ArrowRight';
var prev=isRTL ? 'ArrowRight':'ArrowLeft';
var down='ArrowDown';
var up='ArrowUp';
var home='Home';
var end='End';
if(! [ next, prev, down, up, end, home ].includes(direction)){
return;
}
var $tab=$(this);
var $tabs_wrapper=$tab.closest('.wc-tabs-wrapper, .woocommerce-tabs');
var $tabsList=$tabs_wrapper.find('.wc-tabs, ul.tabs');
var $tabs=$tabsList.find('a[role="tab"]');
var endIndex=$tabs.length - 1;
var tabIndex=$tabs.index($tab);
var targetIndex=direction===prev||direction===up ? tabIndex - 1:tabIndex + 1;
var orientation='horizontal';
if($tabs.length >=2){
var firstTab=$tabs[0].getBoundingClientRect();
var secondTab=$tabs[1].getBoundingClientRect();
var orientation=Math.abs(secondTab.top - firstTab.top) > Math.abs(secondTab.left - firstTab.left)
? 'vertical'
: 'horizontal';
}
if((orientation==='vertical'&&(direction===prev||direction===next)) ||
(orientation==='horizontal'&&(direction===up||direction===down))
){
return;
}
e.preventDefault();
if((direction===prev&&tabIndex===0&&orientation==='horizontal') ||
(direction===up&&tabIndex===0&&orientation==='vertical') ||
direction===end
){
targetIndex=endIndex;
}else if((next===direction&&tabIndex===endIndex&&orientation==='horizontal') ||
(down===direction&&tabIndex===endIndex&&orientation==='vertical') ||
direction===home
){
targetIndex=0;
}
$tabs.eq(targetIndex).focus();
})
.on('click', 'a.woocommerce-review-link', function(){
$('.reviews_tab a').trigger('click');
return true;
})
.on('init', '#rating', function(){
$(this)
.hide()
.before('<p class="stars">\
<span role="group" aria-labelledby="comment-form-rating-label">\
<a role="radio" tabindex="0" aria-checked="false" class="star-1" href="#">' +
wc_single_product_params.i18n_rating_options[0] +
'</a>\
<a role="radio" tabindex="-1" aria-checked="false" class="star-2" href="#">' +
wc_single_product_params.i18n_rating_options[1] +
'</a>\
<a role="radio" tabindex="-1" aria-checked="false" class="star-3" href="#">' +
wc_single_product_params.i18n_rating_options[2] +
'</a>\
<a role="radio" tabindex="-1" aria-checked="false" class="star-4" href="#">' +
wc_single_product_params.i18n_rating_options[3] +
'</a>\
<a role="radio" tabindex="-1" aria-checked="false" class="star-5" href="#">' +
wc_single_product_params.i18n_rating_options[4] +
'</a>\
</span>\
</p>'
);
})
.on('click', '#respond p.stars a', function(){
var $star=$(this),
starPos=$star.closest('p.stars').find('a').index($star) + 1,
$rating=$(this).closest('#respond').find('#rating'),
$container=$(this).closest('.stars');
$rating.val(starPos);
$star.siblings('a')
.removeClass('active')
.attr('aria-checked', 'false')
.attr('tabindex', '-1');
$star
.addClass('active')
.attr('aria-checked', 'true')
.attr('tabindex', '0');
$container.addClass('selected');
return false;
})
.on('click', '#respond #submit', function(){
var $rating=$(this).closest('#respond').find('#rating'),
rating=$rating.val();
if($rating.length > 0&&! rating&&wc_single_product_params.review_rating_required==='yes'){
window.alert(wc_single_product_params.i18n_required_rating_text);
return false;
}})
.on('keyup', '.wc-tabs li a, ul.tabs li a, #respond p.stars a', function(e){
var direction=e.key;
var next=[ 'ArrowRight', 'ArrowDown' ];
var prev=[ 'ArrowLeft', 'ArrowUp' ];
var allDirections=next.concat(prev);
if(! allDirections.includes(direction)){
return;
}
e.preventDefault();
e.stopPropagation();
if(next.includes(direction)){
$(this).next().focus().click();
return;
}
$(this).prev().focus().click();
});
$('.wc-tabs-wrapper, .woocommerce-tabs, #rating').trigger('init');
var productGalleryElement;
var ProductGallery=function($target, args){
this.$target=$target;
this.$images=$('.woocommerce-product-gallery__image', $target);
if(0===this.$images.length){
this.$target.css('opacity', 1);
return;
}
$target.data('product_gallery', this);
this.flexslider_enabled='function'===typeof $.fn.flexslider&&wc_single_product_params.flexslider_enabled;
this.zoom_enabled='function'===typeof $.fn.zoom&&wc_single_product_params.zoom_enabled;
this.photoswipe_enabled=typeof PhotoSwipe!=='undefined'&&wc_single_product_params.photoswipe_enabled;
if(args){
this.flexslider_enabled=false===args.flexslider_enabled ? false:this.flexslider_enabled;
this.zoom_enabled=false===args.zoom_enabled ? false:this.zoom_enabled;
this.photoswipe_enabled=false===args.photoswipe_enabled ? false:this.photoswipe_enabled;
}
if(1===this.$images.length){
this.flexslider_enabled=false;
}
this.initFlexslider=this.initFlexslider.bind(this);
this.initZoom=this.initZoom.bind(this);
this.initZoomForTarget=this.initZoomForTarget.bind(this);
this.initPhotoswipe=this.initPhotoswipe.bind(this);
this.onResetSlidePosition=this.onResetSlidePosition.bind(this);
this.getGalleryItems=this.getGalleryItems.bind(this);
this.openPhotoswipe=this.openPhotoswipe.bind(this);
this.trapFocusPhotoswipe=this.trapFocusPhotoswipe.bind(this);
this.handlePswpTrapFocus=this.handlePswpTrapFocus.bind(this);
if(this.flexslider_enabled){
this.initFlexslider(args.flexslider);
$target.on('woocommerce_gallery_reset_slide_position', this.onResetSlidePosition);
}else{
this.$target.css('opacity', 1);
}
if(this.zoom_enabled){
this.initZoom();
$target.on('woocommerce_gallery_init_zoom', this.initZoom);
}
if(this.photoswipe_enabled){
this.initPhotoswipe();
}};
ProductGallery.prototype.initFlexslider=function(args){
var $target=this.$target,
gallery=this;
var options=$.extend({
selector: '.woocommerce-product-gallery__wrapper > .woocommerce-product-gallery__image',
start: function(){
$target.css('opacity', 1);
},
after: function(slider){
gallery.initZoomForTarget(gallery.$images.eq(slider.currentSlide));
}}, args);
$target.flexslider(options);
$('.woocommerce-product-gallery__wrapper .woocommerce-product-gallery__image:eq(0) .wp-post-image').one('load', function(){
var $image=$(this);
if($image){
setTimeout(function(){
var setHeight=$image.closest('.woocommerce-product-gallery__image').height();
var $viewport=$image.closest('.flex-viewport');
if(setHeight&&$viewport){
$viewport.height(setHeight);
}}, 100);
}}).each(function(){
if(this.complete){
$(this).trigger('load');
}});
};
ProductGallery.prototype.initZoom=function(){
if(document.readyState==='complete'){
this.initZoomForTarget(this.$images.first());
}else{
$(window).on('load', ()=> {
this.initZoomForTarget(this.$images.first());
});
}};
ProductGallery.prototype.initZoomForTarget=function(zoomTarget){
if(! this.zoom_enabled){
return false;
}
var galleryWidth=this.$target.width(),
zoomEnabled=false;
$(zoomTarget).each(function(index, target){
var image=$(target).find('img');
if(image.data('large_image_width') > galleryWidth){
zoomEnabled=true;
return false;
}});
if(zoomEnabled){
var zoom_options=$.extend({
touch: false,
callback: function(){
var zoomImg=this;
setTimeout(function(){
zoomImg.removeAttribute('role');
zoomImg.setAttribute('alt', '');
zoomImg.setAttribute('aria-hidden', 'true');
}, 100);
}}, wc_single_product_params.zoom_options);
if('ontouchstart' in document.documentElement){
zoom_options.on='click';
}
zoomTarget.trigger('zoom.destroy');
zoomTarget.zoom(zoom_options);
setTimeout(function(){
if(zoomTarget.find(':hover').length){
zoomTarget.trigger('mouseover');
}}, 100);
}};
ProductGallery.prototype.initPhotoswipe=function(){
if(this.zoom_enabled&&this.$images.length > 0){
this.$target.prepend('<a href="#" role="button" class="woocommerce-product-gallery__trigger" aria-haspopup="dialog" ' +
'aria-controls="photoswipe-fullscreen-dialog" aria-label="' +
wc_single_product_params.i18n_product_gallery_trigger_text + '">' +
'<span aria-hidden="true">🔍</span>' +
'</a>'
);
this.$target.on('click', '.woocommerce-product-gallery__trigger', this.openPhotoswipe);
this.$target.on('keydown', '.woocommerce-product-gallery__trigger',(e)=> {
if(e.key===' '){
this.openPhotoswipe(e);
}});
this.$target.on('click', '.woocommerce-product-gallery__image a', function(e){
e.preventDefault();
});
if(! this.flexslider_enabled){
this.$target.on('click', '.woocommerce-product-gallery__image a', this.openPhotoswipe);
}}else{
this.$target.on('click', '.woocommerce-product-gallery__image a', this.openPhotoswipe);
}};
ProductGallery.prototype.onResetSlidePosition=function(){
this.$target.flexslider(0);
};
ProductGallery.prototype.getGalleryItems=function(){
var $slides=this.$images,
items=[];
if($slides.length > 0){
$slides.each(function(i, el){
var img=$(el).find('img');
if(img.length){
var large_image_src=img.attr('data-large_image'),
large_image_w=img.attr('data-large_image_width'),
large_image_h=img.attr('data-large_image_height'),
alt=img.attr('alt'),
item={
alt:alt,
src:large_image_src,
w:large_image_w,
h:large_image_h,
title: img.attr('data-caption') ? img.attr('data-caption'):img.attr('title')
};
items.push(item);
}});
}
return items;
};
ProductGallery.prototype.openPhotoswipe=function(e){
e.preventDefault();
var pswpElement=$('.pswp')[0],
items=this.getGalleryItems(),
eventTarget=$(e.target),
currentTarget=e.currentTarget,
self=this,
clicked;
if(0 < eventTarget.closest('.woocommerce-product-gallery__trigger').length){
clicked=this.$target.find('.flex-active-slide');
}else{
clicked=eventTarget.closest('.woocommerce-product-gallery__image');
}
var options=$.extend({
index: $(clicked).index(),
addCaptionHTMLFn: function(item, captionEl){
if(! item.title){
captionEl.children[0].textContent='';
return false;
}
captionEl.children[0].textContent=item.title;
return true;
},
timeToIdle: 0,
}, wc_single_product_params.photoswipe_options);
var photoswipe=new PhotoSwipe(pswpElement, PhotoSwipeUI_Default, items, options);
photoswipe.listen('afterInit', function(){
self.trapFocusPhotoswipe(true);
});
photoswipe.listen('close', function(){
self.trapFocusPhotoswipe(false);
currentTarget.focus();
});
photoswipe.init();
};
ProductGallery.prototype.trapFocusPhotoswipe=function(trapFocus){
var pswp=document.querySelector('.pswp');
if(! pswp){
return;
}
if(trapFocus){
pswp.addEventListener('keydown', this.handlePswpTrapFocus);
}else{
pswp.removeEventListener('keydown', this.handlePswpTrapFocus);
}};
ProductGallery.prototype.handlePswpTrapFocus=function(e){
var allFocusablesEls=e.currentTarget.querySelectorAll('button:not([disabled])');
var filteredFocusablesEls=Array.from(allFocusablesEls).filter(function(btn){
return btn.style.display!=='none'&&window.getComputedStyle(btn).display!=='none';
});
if(1 >=filteredFocusablesEls.length){
return;
}
var firstTabStop=filteredFocusablesEls[0];
var lastTabStop=filteredFocusablesEls[filteredFocusablesEls.length - 1];
if(e.key==='Tab'){
if(e.shiftKey){
if(document.activeElement===firstTabStop){
e.preventDefault();
lastTabStop.focus();
}}else if(document.activeElement===lastTabStop){
e.preventDefault();
firstTabStop.focus();
}}
};
$.fn.wc_product_gallery=function(args){
new ProductGallery(this, args||wc_single_product_params);
return this;
};
$('.woocommerce-product-gallery').each(function(){
$(this).trigger('wc-product-gallery-before-init', [ this, wc_single_product_params ]);
productGalleryElement=$(this).wc_product_gallery(wc_single_product_params);
$(this).trigger('wc-product-gallery-after-init', [ this, wc_single_product_params ]);
});
});
;
(function (global, factory){
typeof exports==='object'&&typeof module!=='undefined' ? module.exports=factory() :
typeof define==='function'&&define.amd ? define(factory) :
(global=typeof globalThis!=='undefined' ? globalThis:global||self, (function (){
var current=global.Cookies;
var exports=global.Cookies=factory();
exports.noConflict=function (){ global.Cookies=current; return exports; };})());
})(this, (function (){ 'use strict';
function assign (target){
for (var i=1; i < arguments.length; i++){
var source=arguments[i];
for (var key in source){
target[key]=source[key];
}}
return target
}
var defaultConverter={
read: function (value){
if(value[0]==='"'){
value=value.slice(1, -1);
}
return value.replace(/(%[\dA-F]{2})+/gi, decodeURIComponent)
},
write: function (value){
return encodeURIComponent(value).replace(/%(2[346BF]|3[AC-F]|40|5[BDE]|60|7[BCD])/g,
decodeURIComponent
)
}};
function init (converter, defaultAttributes){
function set (name, value, attributes){
if(typeof document==='undefined'){
return
}
attributes=assign({}, defaultAttributes, attributes);
if(typeof attributes.expires==='number'){
attributes.expires=new Date(Date.now() + attributes.expires * 864e5);
}
if(attributes.expires){
attributes.expires=attributes.expires.toUTCString();
}
name=encodeURIComponent(name)
.replace(/%(2[346B]|5E|60|7C)/g, decodeURIComponent)
.replace(/[()]/g, escape);
var stringifiedAttributes='';
for (var attributeName in attributes){
if(!attributes[attributeName]){
continue
}
stringifiedAttributes +='; ' + attributeName;
if(attributes[attributeName]===true){
continue
}
stringifiedAttributes +='=' + attributes[attributeName].split(';')[0];
}
return (document.cookie =
name + '=' + converter.write(value, name) + stringifiedAttributes)
}
function get (name){
if(typeof document==='undefined'||(arguments.length&&!name)){
return
}
var cookies=document.cookie ? document.cookie.split('; '):[];
var jar={};
for (var i=0; i < cookies.length; i++){
var parts=cookies[i].split('=');
var value=parts.slice(1).join('=');
try {
var found=decodeURIComponent(parts[0]);
jar[found]=converter.read(value, found);
if(name===found){
break
}} catch (e){}}
return name ? jar[name]:jar
}
return Object.create({
set,
get,
remove: function (name, attributes){
set(
name,
'',
assign({}, attributes, {
expires: -1
})
);
},
withAttributes: function (attributes){
return init(this.converter, assign({}, this.attributes, attributes))
},
withConverter: function (converter){
return init(assign({}, this.converter, converter), this.attributes)
}},
{
attributes: { value: Object.freeze(defaultAttributes) },
converter: { value: Object.freeze(converter) }}
)
}
var api=init(defaultConverter, { path: '/' });
return api;
}));
jQuery(function($){
$('.woocommerce-ordering').on('change', 'select.orderby', function (){
$(this).closest('form').trigger('submit');
});
$('input.qty:not(.product-quantity input.qty)').each(function (){
var min=parseFloat($(this).attr('min'));
if(min >=0&&parseFloat($(this).val()) < min){
$(this).val(min);
}});
var noticeID=$('.woocommerce-store-notice').data('noticeId')||'',
cookieName='store_notice' + noticeID;
if('hidden'===Cookies.get(cookieName)){
$('.woocommerce-store-notice').hide();
}else{
$('.woocommerce-store-notice').show();
function store_notice_keydown_handler(event){
if(['Enter', ' '].includes(event.key)){
event.preventDefault();
$('.woocommerce-store-notice__dismiss-link').click();
}}
function store_notice_click_handler(event){
Cookies.set(cookieName, 'hidden', { path: '/' });
$('.woocommerce-store-notice').hide();
event.preventDefault();
$('.woocommerce-store-notice__dismiss-link')
.off('click', store_notice_click_handler)
.off('keydown', store_notice_keydown_handler);
}
$('.woocommerce-store-notice__dismiss-link')
.on('click', store_notice_click_handler)
.on('keydown', store_notice_keydown_handler);
}
if($('.woocommerce-input-wrapper span.description').length){
$(document.body).on('click', function (){
$('.woocommerce-input-wrapper span.description:visible')
.prop('aria-hidden', true)
.slideUp(250);
});
}
$('.woocommerce-input-wrapper').on('click', function(event){
event.stopPropagation();
});
$('.woocommerce-input-wrapper :input')
.on('keydown', function(event){
var input=$(this),
parent=input.parent(),
description=parent.find('span.description');
if(27===event.which &&
description.length &&
description.is(':visible')
){
description.prop('aria-hidden', true).slideUp(250);
event.preventDefault();
return false;
}})
.on('click focus', function (){
var input=$(this),
parent=input.parent(),
description=parent.find('span.description');
parent.addClass('currentTarget');
$(
'.woocommerce-input-wrapper:not(.currentTarget) span.description:visible'
)
.prop('aria-hidden', true)
.slideUp(250);
if(description.length&&description.is(':hidden')){
description.prop('aria-hidden', false).slideDown(250);
}
parent.removeClass('currentTarget');
});
$.scroll_to_notices=function(scrollElement){
if(scrollElement.length){
$('html, body').animate({
scrollTop: scrollElement.offset().top - 100,
},
1000
);
}};
$('.woocommerce form .woocommerce-Input[type="password"]').wrap('<span class="password-input"></span>'
);
$('.woocommerce form input')
.filter(':password')
.parent('span')
.addClass('password-input');
$('.password-input').each(function (){
const describedBy=$(this).find('input').attr('id');
$(this).append('<button type="button" class="show-password-input" aria-label="' +
woocommerce_params.i18n_password_show +
'" aria-describedBy="' +
describedBy +
'"></button>'
);
});
$('.show-password-input').on('click', function(event){
event.preventDefault();
if($(this).hasClass('display-password')){
$(this).removeClass('display-password');
$(this).attr('aria-label',
woocommerce_params.i18n_password_show
);
}else{
$(this).addClass('display-password');
$(this).attr('aria-label',
woocommerce_params.i18n_password_hide
);
}
if($(this).hasClass('display-password')){
$(this)
.siblings([ 'input[type="password"]' ])
.prop('type', 'text');
}else{
$(this)
.siblings('input[type="text"]')
.prop('type', 'password');
}
$(this).siblings('input').focus();
});
$('a.coming-soon-footer-banner-dismiss').on('click', function(e){
var target=$(e.target);
$.ajax({
type: 'post',
url: target.data('rest-url'),
data: {
woocommerce_meta: {
coming_soon_banner_dismissed: 'yes',
},
},
beforeSend: function(xhr){
xhr.setRequestHeader('X-WP-Nonce',
target.data('rest-nonce')
);
},
complete: function (){
$('#coming-soon-footer-banner').hide();
},
});
});
if(typeof wc_add_to_cart_params==='undefined'){
$(document.body).on('keydown', '.remove_from_cart_button', on_keydown_remove_from_cart);
}
$(document.body).on('item_removed_from_classic_cart updated_wc_div', focus_populate_live_region);
});
function on_keydown_remove_from_cart(event){
if(event.key===' '){
event.preventDefault();
event.currentTarget.click();
}}
function focus_populate_live_region(){
var noticeClasses=[
'woocommerce-message',
'woocommerce-error',
'wc-block-components-notice-banner',
];
var noticeSelectors=noticeClasses
.map(function(className){
return '.' + className + '[role="alert"]';
})
.join(', ');
var noticeElements=document.querySelectorAll(noticeSelectors);
if(noticeElements.length===0){
return;
}
var firstNotice=noticeElements[ 0 ];
firstNotice.setAttribute('tabindex', '-1');
var delayFocusNoticeId=setTimeout(function (){
firstNotice.focus();
clearTimeout(delayFocusNoticeId);
}, 500);
}
function refresh_sorted_by_live_region(){
var sorted_by_live_region=document.querySelector('.woocommerce-result-count'
);
if(sorted_by_live_region){
var text=sorted_by_live_region.innerHTML;
sorted_by_live_region.setAttribute('aria-hidden', 'true');
var sorted_by_live_region_id=setTimeout(function (){
sorted_by_live_region.setAttribute('aria-hidden', 'false');
sorted_by_live_region.innerHTML='';
sorted_by_live_region.innerHTML=text;
clearTimeout(sorted_by_live_region_id);
}, 2000);
}}
function on_document_ready(){
focus_populate_live_region();
refresh_sorted_by_live_region();
}
document.addEventListener('DOMContentLoaded', on_document_ready);
(function (factory){
if(typeof define==='function'&&define.amd){
define(['jquery'], factory);
}else if(typeof module==='object'&&module.exports){
module.exports=function (root, jQuery){
if(jQuery===undefined){
if(typeof window!=='undefined'){
jQuery=require('jquery');
}else{
jQuery=require('jquery')(root);
}}
factory(jQuery);
return jQuery;
};}else{
factory(jQuery);
}} (function (jQuery){
var S2=(function (){
if(jQuery&&jQuery.fn&&jQuery.fn.select2&&jQuery.fn.select2.amd){
var S2=jQuery.fn.select2.amd;
}
var S2;(function (){ if(!S2||!S2.requirejs){
if(!S2){ S2={};}else{ require=S2; }
var requirejs, require, define;
(function (undef){
var main, req, makeMap, handlers,
defined={},
waiting={},
config={},
defining={},
hasOwn=Object.prototype.hasOwnProperty,
aps=[].slice,
jsSuffixRegExp=/\.js$/;
function hasProp(obj, prop){
return hasOwn.call(obj, prop);
}
function normalize(name, baseName){
var nameParts, nameSegment, mapValue, foundMap, lastIndex,
foundI, foundStarMap, starI, i, j, part, normalizedBaseParts,
baseParts=baseName&&baseName.split("/"),
map=config.map,
starMap=(map&&map['*'])||{};
if(name){
name=name.split('/');
lastIndex=name.length - 1;
if(config.nodeIdCompat&&jsSuffixRegExp.test(name[lastIndex])){
name[lastIndex]=name[lastIndex].replace(jsSuffixRegExp, '');
}
if(name[0].charAt(0)==='.'&&baseParts){
normalizedBaseParts=baseParts.slice(0, baseParts.length - 1);
name=normalizedBaseParts.concat(name);
}
for (i=0; i < name.length; i++){
part=name[i];
if(part==='.'){
name.splice(i, 1);
i -=1;
}else if(part==='..'){
if(i===0||(i===1&&name[2]==='..')||name[i - 1]==='..'){
continue;
}else if(i > 0){
name.splice(i - 1, 2);
i -=2;
}}
}
name=name.join('/');
}
if((baseParts||starMap)&&map){
nameParts=name.split('/');
for (i=nameParts.length; i > 0; i -=1){
nameSegment=nameParts.slice(0, i).join("/");
if(baseParts){
for (j=baseParts.length; j > 0; j -=1){
mapValue=map[baseParts.slice(0, j).join('/')];
if(mapValue){
mapValue=mapValue[nameSegment];
if(mapValue){
foundMap=mapValue;
foundI=i;
break;
}}
}}
if(foundMap){
break;
}
if(!foundStarMap&&starMap&&starMap[nameSegment]){
foundStarMap=starMap[nameSegment];
starI=i;
}}
if(!foundMap&&foundStarMap){
foundMap=foundStarMap;
foundI=starI;
}
if(foundMap){
nameParts.splice(0, foundI, foundMap);
name=nameParts.join('/');
}}
return name;
}
function makeRequire(relName, forceSync){
return function (){
var args=aps.call(arguments, 0);
if(typeof args[0]!=='string'&&args.length===1){
args.push(null);
}
return req.apply(undef, args.concat([relName, forceSync]));
};}
function makeNormalize(relName){
return function (name){
return normalize(name, relName);
};}
function makeLoad(depName){
return function (value){
defined[depName]=value;
};}
function callDep(name){
if(hasProp(waiting, name)){
var args=waiting[name];
delete waiting[name];
defining[name]=true;
main.apply(undef, args);
}
if(!hasProp(defined, name)&&!hasProp(defining, name)){
throw new Error('No ' + name);
}
return defined[name];
}
function splitPrefix(name){
var prefix,
index=name ? name.indexOf('!'):-1;
if(index > -1){
prefix=name.substring(0, index);
name=name.substring(index + 1, name.length);
}
return [prefix, name];
}
function makeRelParts(relName){
return relName ? splitPrefix(relName):[];
}
makeMap=function (name, relParts){
var plugin,
parts=splitPrefix(name),
prefix=parts[0],
relResourceName=relParts[1];
name=parts[1];
if(prefix){
prefix=normalize(prefix, relResourceName);
plugin=callDep(prefix);
}
if(prefix){
if(plugin&&plugin.normalize){
name=plugin.normalize(name, makeNormalize(relResourceName));
}else{
name=normalize(name, relResourceName);
}}else{
name=normalize(name, relResourceName);
parts=splitPrefix(name);
prefix=parts[0];
name=parts[1];
if(prefix){
plugin=callDep(prefix);
}}
return {
f: prefix ? prefix + '!' + name:name,
n: name,
pr: prefix,
p: plugin
};};
function makeConfig(name){
return function (){
return (config&&config.config&&config.config[name])||{};};
}
handlers={
require: function (name){
return makeRequire(name);
},
exports: function (name){
var e=defined[name];
if(typeof e!=='undefined'){
return e;
}else{
return (defined[name]={});
}},
module: function (name){
return {
id: name,
uri: '',
exports: defined[name],
config: makeConfig(name)
};}};
main=function (name, deps, callback, relName){
var cjsModule, depName, ret, map, i, relParts,
args=[],
callbackType=typeof callback,
usingExports;
relName=relName||name;
relParts=makeRelParts(relName);
if(callbackType==='undefined'||callbackType==='function'){
deps = !deps.length&&callback.length ? ['require', 'exports', 'module']:deps;
for (i=0; i < deps.length; i +=1){
map=makeMap(deps[i], relParts);
depName=map.f;
if(depName==="require"){
args[i]=handlers.require(name);
}else if(depName==="exports"){
args[i]=handlers.exports(name);
usingExports=true;
}else if(depName==="module"){
cjsModule=args[i]=handlers.module(name);
}else if(hasProp(defined, depName) ||
hasProp(waiting, depName) ||
hasProp(defining, depName)){
args[i]=callDep(depName);
}else if(map.p){
map.p.load(map.n, makeRequire(relName, true), makeLoad(depName), {});
args[i]=defined[depName];
}else{
throw new Error(name + ' missing ' + depName);
}}
ret=callback ? callback.apply(defined[name], args):undefined;
if(name){
if(cjsModule&&cjsModule.exports!==undef &&
cjsModule.exports!==defined[name]){
defined[name]=cjsModule.exports;
}else if(ret!==undef||!usingExports){
defined[name]=ret;
}}
}else if(name){
defined[name]=callback;
}};
requirejs=require=req=function (deps, callback, relName, forceSync, alt){
if(typeof deps==="string"){
if(handlers[deps]){
return handlers[deps](callback);
}
return callDep(makeMap(deps, makeRelParts(callback)).f);
}else if(!deps.splice){
config=deps;
if(config.deps){
req(config.deps, config.callback);
}
if(!callback){
return;
}
if(callback.splice){
deps=callback;
callback=relName;
relName=null;
}else{
deps=undef;
}}
callback=callback||function (){};
if(typeof relName==='function'){
relName=forceSync;
forceSync=alt;
}
if(forceSync){
main(undef, deps, callback, relName);
}else{
setTimeout(function (){
main(undef, deps, callback, relName);
}, 4);
}
return req;
};
req.config=function (cfg){
return req(cfg);
};
requirejs._defined=defined;
define=function (name, deps, callback){
if(typeof name!=='string'){
throw new Error('See almond README: incorrect module build, no module name');
}
if(!deps.splice){
callback=deps;
deps=[];
}
if(!hasProp(defined, name)&&!hasProp(waiting, name)){
waiting[name]=[name, deps, callback];
}};
define.amd={
jQuery: true
};}());
S2.requirejs=requirejs;S2.require=require;S2.define=define;
}}());
S2.define("almond", function(){});
S2.define('jquery',[],function (){
var _$=jQuery||$;
if(_$==null&&console&&console.error){
console.error('Select2: An instance of jQuery or a jQuery-compatible library was not ' +
'found. Make sure that you are including jQuery before Select2 on your ' +
'web page.'
);
}
return _$;
});
S2.define('select2/utils',[
'jquery'
], function ($){
var Utils={};
Utils.Extend=function (ChildClass, SuperClass){
var __hasProp={}.hasOwnProperty;
function BaseConstructor (){
this.constructor=ChildClass;
}
for (var key in SuperClass){
if(__hasProp.call(SuperClass, key)){
ChildClass[key]=SuperClass[key];
}}
BaseConstructor.prototype=SuperClass.prototype;
ChildClass.prototype=new BaseConstructor();
ChildClass.__super__=SuperClass.prototype;
return ChildClass;
};
function getMethods (theClass){
var proto=theClass.prototype;
var methods=[];
for (var methodName in proto){
var m=proto[methodName];
if(typeof m!=='function'){
continue;
}
if(methodName==='constructor'){
continue;
}
methods.push(methodName);
}
return methods;
}
Utils.Decorate=function (SuperClass, DecoratorClass){
var decoratedMethods=getMethods(DecoratorClass);
var superMethods=getMethods(SuperClass);
function DecoratedClass (){
var unshift=Array.prototype.unshift;
var argCount=DecoratorClass.prototype.constructor.length;
var calledConstructor=SuperClass.prototype.constructor;
if(argCount > 0){
unshift.call(arguments, SuperClass.prototype.constructor);
calledConstructor=DecoratorClass.prototype.constructor;
}
calledConstructor.apply(this, arguments);
}
DecoratorClass.displayName=SuperClass.displayName;
function ctr (){
this.constructor=DecoratedClass;
}
DecoratedClass.prototype=new ctr();
for (var m=0; m < superMethods.length; m++){
var superMethod=superMethods[m];
DecoratedClass.prototype[superMethod] =
SuperClass.prototype[superMethod];
}
var calledMethod=function (methodName){
var originalMethod=function (){};
if(methodName in DecoratedClass.prototype){
originalMethod=DecoratedClass.prototype[methodName];
}
var decoratedMethod=DecoratorClass.prototype[methodName];
return function (){
var unshift=Array.prototype.unshift;
unshift.call(arguments, originalMethod);
return decoratedMethod.apply(this, arguments);
};};
for (var d=0; d < decoratedMethods.length; d++){
var decoratedMethod=decoratedMethods[d];
DecoratedClass.prototype[decoratedMethod]=calledMethod(decoratedMethod);
}
return DecoratedClass;
};
var Observable=function (){
this.listeners={};};
Observable.prototype.on=function (event, callback){
this.listeners=this.listeners||{};
if(event in this.listeners){
this.listeners[event].push(callback);
}else{
this.listeners[event]=[callback];
}};
Observable.prototype.trigger=function (event){
var slice=Array.prototype.slice;
var params=slice.call(arguments, 1);
this.listeners=this.listeners||{};
if(params==null){
params=[];
}
if(params.length===0){
params.push({});
}
params[0]._type=event;
if(event in this.listeners){
this.invoke(this.listeners[event], slice.call(arguments, 1));
}
if('*' in this.listeners){
this.invoke(this.listeners['*'], arguments);
}};
Observable.prototype.invoke=function (listeners, params){
for (var i=0, len=listeners.length; i < len; i++){
listeners[i].apply(this, params);
}};
Utils.Observable=Observable;
Utils.generateChars=function (length){
var chars='';
for (var i=0; i < length; i++){
var randomChar=Math.floor(Math.random() * 36);
chars +=randomChar.toString(36);
}
return chars;
};
Utils.bind=function (func, context){
return function (){
func.apply(context, arguments);
};};
Utils._convertData=function (data){
for (var originalKey in data){
var keys=originalKey.split('-');
var dataLevel=data;
if(keys.length===1){
continue;
}
for (var k=0; k < keys.length; k++){
var key=keys[k];
key=key.substring(0, 1).toLowerCase() + key.substring(1);
if(!(key in dataLevel)){
dataLevel[key]={};}
if(k==keys.length - 1){
dataLevel[key]=data[originalKey];
}
dataLevel=dataLevel[key];
}
delete data[originalKey];
}
return data;
};
Utils.hasScroll=function (index, el){
var $el=$(el);
var overflowX=el.style.overflowX;
var overflowY=el.style.overflowY;
if(overflowX===overflowY &&
(overflowY==='hidden'||overflowY==='visible')){
return false;
}
if(overflowX==='scroll'||overflowY==='scroll'){
return true;
}
return ($el.innerHeight() < el.scrollHeight ||
$el.innerWidth() < el.scrollWidth);
};
Utils.escapeMarkup=function (markup){
var replaceMap={
'\\': '&#92;',
'&': '&amp;',
'<': '&lt;',
'>': '&gt;',
'"': '&quot;',
'\'': '&#39;',
'/': '&#47;'
};
if(typeof markup!=='string'){
return markup;
}
return String(markup).replace(/[&<>"'\/\\]/g, function (match){
return replaceMap[match];
});
};
Utils.entityDecode=function (html){
var txt=document.createElement('textarea');
txt.innerHTML=html;
return txt.value;
}
Utils.appendMany=function ($element, $nodes){
if($.fn.jquery.substr(0, 3)==='1.7'){
var $jqNodes=$();
$.map($nodes, function (node){
$jqNodes=$jqNodes.add(node);
});
$nodes=$jqNodes;
}
$element.append($nodes);
};
Utils.isTouchscreen=function(){
if('undefined'===typeof Utils._isTouchscreenCache){
Utils._isTouchscreenCache='ontouchstart' in document.documentElement;
}
return Utils._isTouchscreenCache;
}
return Utils;
});
S2.define('select2/results',[
'jquery',
'./utils'
], function ($, Utils){
function Results ($element, options, dataAdapter){
this.$element=$element;
this.data=dataAdapter;
this.options=options;
Results.__super__.constructor.call(this);
}
Utils.Extend(Results, Utils.Observable);
Results.prototype.render=function (){
var $results=$(
'<ul class="select2-results__options" role="listbox" tabindex="-1"></ul>'
);
if(this.options.get('multiple')){
$results.attr('aria-multiselectable', 'true');
}
this.$results=$results;
return $results;
};
Results.prototype.clear=function (){
this.$results.empty();
};
Results.prototype.displayMessage=function (params){
var escapeMarkup=this.options.get('escapeMarkup');
this.clear();
this.hideLoading();
var $message=$(
'<li role="alert" aria-live="assertive"' +
' class="select2-results__option"></li>'
);
var message=this.options.get('translations').get(params.message);
$message.append(escapeMarkup(
message(params.args)
)
);
$message[0].className +=' select2-results__message';
this.$results.append($message);
};
Results.prototype.hideMessages=function (){
this.$results.find('.select2-results__message').remove();
};
Results.prototype.append=function (data){
this.hideLoading();
var $options=[];
if(data.results==null||data.results.length===0){
if(this.$results.children().length===0){
this.trigger('results:message', {
message: 'noResults'
});
}
return;
}
data.results=this.sort(data.results);
for (var d=0; d < data.results.length; d++){
var item=data.results[d];
var $option=this.option(item);
$options.push($option);
}
this.$results.append($options);
};
Results.prototype.position=function ($results, $dropdown){
var $resultsContainer=$dropdown.find('.select2-results');
$resultsContainer.append($results);
};
Results.prototype.sort=function (data){
var sorter=this.options.get('sorter');
return sorter(data);
};
Results.prototype.highlightFirstItem=function (){
var $options=this.$results
.find('.select2-results__option[data-selected]');
var $selected=$options.filter('[data-selected=true]');
if($selected.length > 0){
$selected.first().trigger('mouseenter');
}else{
$options.first().trigger('mouseenter');
}
this.ensureHighlightVisible();
};
Results.prototype.setClasses=function (){
var self=this;
this.data.current(function (selected){
var selectedIds=$.map(selected, function (s){
return s.id.toString();
});
var $options=self.$results
.find('.select2-results__option[data-selected]');
$options.each(function (){
var $option=$(this);
var item=$.data(this, 'data');
var id='' + item.id;
if((item.element!=null&&item.element.selected) ||
(item.element==null&&$.inArray(id, selectedIds) > -1)){
$option.attr('data-selected', 'true');
}else{
$option.attr('data-selected', 'false');
}});
});
};
Results.prototype.showLoading=function (params){
this.hideLoading();
var loadingMore=this.options.get('translations').get('searching');
var loading={
disabled: true,
loading: true,
text: loadingMore(params)
};
var $loading=this.option(loading);
$loading.className +=' loading-results';
this.$results.prepend($loading);
};
Results.prototype.hideLoading=function (){
this.$results.find('.loading-results').remove();
};
Results.prototype.option=function (data){
var option=document.createElement('li');
option.className='select2-results__option';
var attrs={
'role': 'option',
'data-selected': 'false',
'tabindex': -1
};
if(data.disabled){
delete attrs['data-selected'];
attrs['aria-disabled']='true';
}
if(data.id==null){
delete attrs['data-selected'];
}
if(data._resultId!=null){
option.id=data._resultId;
}
if(data.title){
option.title=data.title;
}
if(data.children){
attrs['aria-label']=data.text;
delete attrs['data-selected'];
}
for (var attr in attrs){
var val=attrs[attr];
option.setAttribute(attr, val);
}
if(data.children){
var $option=$(option);
var label=document.createElement('strong');
label.className='select2-results__group';
var $label=$(label);
this.template(data, label);
$label.attr('role', 'presentation');
var $children=[];
for (var c=0; c < data.children.length; c++){
var child=data.children[c];
var $child=this.option(child);
$children.push($child);
}
var $childrenContainer=$('<ul></ul>', {
'class': 'select2-results__options select2-results__options--nested',
'role': 'listbox'
});
$childrenContainer.append($children);
$option.attr('role', 'list');
$option.append(label);
$option.append($childrenContainer);
}else{
this.template(data, option);
}
$.data(option, 'data', data);
return option;
};
Results.prototype.bind=function (container, $container){
var self=this;
var id=container.id + '-results';
this.$results.attr('id', id);
container.on('results:all', function (params){
self.clear();
self.append(params.data);
if(container.isOpen()){
self.setClasses();
self.highlightFirstItem();
}});
container.on('results:append', function (params){
self.append(params.data);
if(container.isOpen()){
self.setClasses();
}});
container.on('query', function (params){
self.hideMessages();
self.showLoading(params);
});
container.on('select', function (){
if(!container.isOpen()){
return;
}
self.setClasses();
self.highlightFirstItem();
});
container.on('unselect', function (){
if(!container.isOpen()){
return;
}
self.setClasses();
self.highlightFirstItem();
});
container.on('open', function (){
self.$results.attr('aria-expanded', 'true');
self.$results.attr('aria-hidden', 'false');
self.setClasses();
self.ensureHighlightVisible();
var searchField=self.$results.parents('.select2-container').find('input.select2-search__field')[0];
if('undefined'!==typeof searchField){
searchField.focus();
}});
container.on('close', function (){
self.$results.attr('aria-expanded', 'false');
self.$results.attr('aria-hidden', 'true');
self.$results.removeAttr('aria-activedescendant');
});
container.on('results:toggle', function (){
var $highlighted=self.getHighlightedResults();
if($highlighted.length===0){
return;
}
$highlighted.trigger('mouseup');
});
container.on('results:select', function (){
var $highlighted=self.getHighlightedResults();
if($highlighted.length===0){
return;
}
var data=$highlighted.data('data');
if($highlighted.attr('data-selected')=='true'){
self.trigger('close', {});
}else{
self.trigger('select', {
data: data
});
}});
container.on('results:previous', function (){
var $highlighted=self.getHighlightedResults();
var $options=self.$results.find('[data-selected]');
var currentIndex=$options.index($highlighted);
if(currentIndex===0){
return;
}
var nextIndex=currentIndex - 1;
if($highlighted.length===0){
nextIndex=0;
}
var $next=$options.eq(nextIndex);
$next.trigger('mouseenter');
var currentOffset=self.$results.offset().top;
var nextTop=$next.offset().top;
var nextOffset=self.$results.scrollTop() + (nextTop - currentOffset);
if(nextIndex===0){
self.$results.scrollTop(0);
}else if(nextTop - currentOffset < 0){
self.$results.scrollTop(nextOffset);
}});
container.on('results:next', function (){
var $highlighted=self.getHighlightedResults();
var $options=self.$results.find('[data-selected]');
var currentIndex=$options.index($highlighted);
var nextIndex=currentIndex + 1;
if(nextIndex >=$options.length){
return;
}
var $next=$options.eq(nextIndex);
$next.trigger('mouseenter');
var currentOffset=self.$results.offset().top +
self.$results.outerHeight(false);
var nextBottom=$next.offset().top + $next.outerHeight(false);
var nextOffset=self.$results.scrollTop() + nextBottom - currentOffset;
if(nextIndex===0){
self.$results.scrollTop(0);
}else if(nextBottom > currentOffset){
self.$results.scrollTop(nextOffset);
}});
container.on('results:focus', function (params){
params.element.addClass('select2-results__option--highlighted').attr('aria-selected', 'true');
self.$results.attr('aria-activedescendant', params.element.attr('id'));
});
container.on('results:message', function (params){
self.displayMessage(params);
});
if($.fn.mousewheel){
this.$results.on('mousewheel', function (e){
var top=self.$results.scrollTop();
var bottom=self.$results.get(0).scrollHeight - top + e.deltaY;
var isAtTop=e.deltaY > 0&&top - e.deltaY <=0;
var isAtBottom=e.deltaY < 0&&bottom <=self.$results.height();
if(isAtTop){
self.$results.scrollTop(0);
e.preventDefault();
e.stopPropagation();
}else if(isAtBottom){
self.$results.scrollTop(self.$results.get(0).scrollHeight - self.$results.height()
);
e.preventDefault();
e.stopPropagation();
}});
}
this.$results.on('mouseup', '.select2-results__option[data-selected]',
function (evt){
var $this=$(this);
var data=$this.data('data');
if($this.attr('data-selected')==='true'){
if(self.options.get('multiple')){
self.trigger('unselect', {
originalEvent: evt,
data: data
});
}else{
self.trigger('close', {});
}
return;
}
self.trigger('select', {
originalEvent: evt,
data: data
});
});
this.$results.on('mouseenter', '.select2-results__option[data-selected]',
function (evt){
var data=$(this).data('data');
self.getHighlightedResults()
.removeClass('select2-results__option--highlighted')
.attr('aria-selected', 'false');
self.trigger('results:focus', {
data: data,
element: $(this)
});
});
};
Results.prototype.getHighlightedResults=function (){
var $highlighted=this.$results
.find('.select2-results__option--highlighted');
return $highlighted;
};
Results.prototype.destroy=function (){
this.$results.remove();
};
Results.prototype.ensureHighlightVisible=function (){
var $highlighted=this.getHighlightedResults();
if($highlighted.length===0){
return;
}
var $options=this.$results.find('[data-selected]');
var currentIndex=$options.index($highlighted);
var currentOffset=this.$results.offset().top;
var nextTop=$highlighted.offset().top;
var nextOffset=this.$results.scrollTop() + (nextTop - currentOffset);
var offsetDelta=nextTop - currentOffset;
nextOffset -=$highlighted.outerHeight(false) * 2;
if(currentIndex <=2){
this.$results.scrollTop(0);
}else if(offsetDelta > this.$results.outerHeight()||offsetDelta < 0){
this.$results.scrollTop(nextOffset);
}};
Results.prototype.template=function (result, container){
var template=this.options.get('templateResult');
var escapeMarkup=this.options.get('escapeMarkup');
var content=template(result, container);
if(content==null){
container.style.display='none';
}else if(typeof content==='string'){
container.innerHTML=escapeMarkup(content);
}else{
$(container).append(content);
}};
return Results;
});
S2.define('select2/keys',[
], function (){
var KEYS={
BACKSPACE: 8,
TAB: 9,
ENTER: 13,
SHIFT: 16,
CTRL: 17,
ALT: 18,
ESC: 27,
SPACE: 32,
PAGE_UP: 33,
PAGE_DOWN: 34,
END: 35,
HOME: 36,
LEFT: 37,
UP: 38,
RIGHT: 39,
DOWN: 40,
DELETE: 46
};
return KEYS;
});
S2.define('select2/selection/base',[
'jquery',
'../utils',
'../keys'
], function ($, Utils, KEYS){
function BaseSelection ($element, options){
this.$element=$element;
this.options=options;
BaseSelection.__super__.constructor.call(this);
}
Utils.Extend(BaseSelection, Utils.Observable);
BaseSelection.prototype.render=function (){
var $selection=$(
'<span class="select2-selection" ' +
' aria-haspopup="true" aria-expanded="false">' +
'</span>'
);
this._tabindex=0;
if(this.$element.data('old-tabindex')!=null){
this._tabindex=this.$element.data('old-tabindex');
}else if(this.$element.attr('tabindex')!=null){
this._tabindex=this.$element.attr('tabindex');
}
$selection.attr('title', this.$element.attr('title'));
$selection.attr('tabindex', this._tabindex);
this.$selection=$selection;
return $selection;
};
BaseSelection.prototype.bind=function (container, $container){
var self=this;
var id=container.id + '-container';
var resultsId=container.id + '-results';
var searchHidden=this.options.get('minimumResultsForSearch')===Infinity;
var isRequired=this.options.get('required')===true;
this.container=container;
if(isRequired){
this.$selection.attr('aria-required', 'true')
}
this.$selection.on('focus', function (evt){
self.trigger('focus', evt);
});
this.$selection.on('blur', function (evt){
self._handleBlur(evt);
});
this.$selection.on('keydown', function (evt){
self.trigger('keypress', evt);
if(evt.which===KEYS.SPACE){
evt.preventDefault();
}});
container.on('results:focus', function (params){
self.$selection.attr('aria-activedescendant', params.data._resultId);
});
container.on('selection:update', function (params){
self.update(params.data);
});
container.on('open', function (){
self.$selection.attr('aria-expanded', 'true');
self.$selection.attr('aria-owns', resultsId);
self._attachCloseHandler(container);
});
container.on('close', function (){
self.$selection.attr('aria-expanded', 'false');
self.$selection.removeAttr('aria-activedescendant');
self.$selection.removeAttr('aria-owns');
window.setTimeout(function (){
self.$selection.trigger('focus');
}, 1);
self._detachCloseHandler(container);
});
container.on('enable', function (){
self.$selection.attr('tabindex', self._tabindex);
});
container.on('disable', function (){
self.$selection.attr('tabindex', '-1');
});
};
BaseSelection.prototype._handleBlur=function (evt){
var self=this;
window.setTimeout(function (){
if((document.activeElement==self.$selection[0]) ||
($.contains(self.$selection[0], document.activeElement))
){
return;
}
self.trigger('blur', evt);
}, 1);
};
BaseSelection.prototype._attachCloseHandler=function (container){
var self=this;
$(document.body).on('mousedown.select2.' + container.id, function (e){
var $target=$(e.target);
var $select=$target.closest('.select2');
var $all=$('.select2.select2-container--open');
$all.each(function (){
var $this=$(this);
if(this==$select[0]){
return;
}
var $element=$this.data('element');
$element.select2('close');
setTimeout(function(){
$this.find('*:focus').trigger('blur');
$target.trigger('focus');
}, 1);
});
});
};
BaseSelection.prototype._detachCloseHandler=function (container){
$(document.body).off('mousedown.select2.' + container.id);
};
BaseSelection.prototype.position=function ($selection, $container){
var $selectionContainer=$container.find('.selection');
$selectionContainer.append($selection);
};
BaseSelection.prototype.destroy=function (){
this._detachCloseHandler(this.container);
};
BaseSelection.prototype.update=function (data){
throw new Error('The `update` method must be defined in child classes.');
};
return BaseSelection;
});
S2.define('select2/selection/single',[
'jquery',
'./base',
'../utils',
'../keys'
], function ($, BaseSelection, Utils, KEYS){
function SingleSelection (){
SingleSelection.__super__.constructor.apply(this, arguments);
}
Utils.Extend(SingleSelection, BaseSelection);
SingleSelection.prototype.render=function (){
var $selection=SingleSelection.__super__.render.call(this);
$selection.addClass('select2-selection--single');
$selection.html('<span class="select2-selection__rendered"></span>' +
'<span class="select2-selection__arrow" role="presentation">' +
'<b role="presentation"></b>' +
'</span>'
);
return $selection;
};
SingleSelection.prototype.bind=function (container, $container){
var self=this;
SingleSelection.__super__.bind.apply(this, arguments);
var id=container.id + '-container';
var isRequired=this.options.get('required')===true;
if(isRequired){
this.$selection.find('.select2-selection__rendered').attr('aria-required', 'true')
}
this.$selection.find('.select2-selection__rendered')
.attr('id', id)
.attr('role', 'textbox')
.attr('aria-readonly', 'true');
var label=this.options.get('label');
if(typeof(label)==='string'){
this.$selection.attr('aria-label', label);
}else{
this.$selection.attr('aria-labelledby', id);
}
this.$selection.attr('role', 'combobox');
this.$selection.on('mousedown', function (evt){
if(evt.which!==1){
return;
}
self.trigger('toggle', {
originalEvent: evt
});
});
this.$selection.on('focus', function (evt){
});
this.$selection.on('keydown', function (evt){
if(!container.isOpen()&&evt.which >=48&&evt.which <=90){
container.open();
}});
this.$selection.on('blur', function (evt){
});
container.on('focus', function (evt){
if(!container.isOpen()){
self.$selection.trigger('focus');
}});
container.on('selection:update', function (params){
self.update(params.data);
});
};
SingleSelection.prototype.clear=function (){
this.$selection.find('.select2-selection__rendered').empty();
};
SingleSelection.prototype.display=function (data, container){
var template=this.options.get('templateSelection');
var escapeMarkup=this.options.get('escapeMarkup');
return escapeMarkup(template(data, container));
};
SingleSelection.prototype.selectionContainer=function (){
return $('<span></span>');
};
SingleSelection.prototype.update=function (data){
if(data.length===0){
this.clear();
return;
}
var selection=data[0];
var $rendered=this.$selection.find('.select2-selection__rendered');
var formatted=Utils.entityDecode(this.display(selection, $rendered));
$rendered.empty().text(formatted);
$rendered.prop('title', selection.title||selection.text);
};
return SingleSelection;
});
S2.define('select2/selection/multiple',[
'jquery',
'./base',
'../utils'
], function ($, BaseSelection, Utils){
function MultipleSelection ($element, options){
MultipleSelection.__super__.constructor.apply(this, arguments);
}
Utils.Extend(MultipleSelection, BaseSelection);
MultipleSelection.prototype.render=function (){
var $selection=MultipleSelection.__super__.render.call(this);
$selection.addClass('select2-selection--multiple');
$selection.html('<ul class="select2-selection__rendered" aria-live="polite" aria-relevant="additions removals" aria-atomic="true"></ul>'
);
return $selection;
};
MultipleSelection.prototype.bind=function (container, $container){
var self=this;
MultipleSelection.__super__.bind.apply(this, arguments);
this.$selection.on('click', function (evt){
self.trigger('toggle', {
originalEvent: evt
});
});
this.$selection.on('click',
'.select2-selection__choice__remove',
function (evt){
if(self.options.get('disabled')){
return;
}
var $remove=$(this);
var $selection=$remove.parent();
var data=$selection.data('data');
self.trigger('unselect', {
originalEvent: evt,
data: data
});
}
);
this.$selection.on('keydown', function (evt){
if(!container.isOpen()&&evt.which >=48&&evt.which <=90){
container.open();
}});
container.on('focus', function(){
self.focusOnSearch();
});
};
MultipleSelection.prototype.clear=function (){
this.$selection.find('.select2-selection__rendered').empty();
};
MultipleSelection.prototype.display=function (data, container){
var template=this.options.get('templateSelection');
var escapeMarkup=this.options.get('escapeMarkup');
return escapeMarkup(template(data, container));
};
MultipleSelection.prototype.selectionContainer=function (){
var $container=$(
'<li class="select2-selection__choice">' +
'<span class="select2-selection__choice__remove" role="presentation" aria-hidden="true">' +
'&times;' +
'</span>' +
'</li>'
);
return $container;
};
MultipleSelection.prototype.focusOnSearch=function(){
var self=this;
if('undefined'!==typeof self.$search){
setTimeout(function(){
self._keyUpPrevented=true;
self.$search.trigger('focus');
}, 1);
}}
MultipleSelection.prototype.update=function (data){
this.clear();
if(data.length===0){
return;
}
var $selections=[];
for (var d=0; d < data.length; d++){
var selection=data[d];
var $selection=this.selectionContainer();
var removeItemTag=$selection.html();
var formatted=this.display(selection, $selection);
if('string'===typeof formatted){
formatted=Utils.entityDecode(formatted.trim());
}
$selection.text(formatted);
$selection.prepend(removeItemTag);
$selection.prop('title', selection.title||selection.text);
$selection.data('data', selection);
$selections.push($selection);
}
var $rendered=this.$selection.find('.select2-selection__rendered');
Utils.appendMany($rendered, $selections);
};
return MultipleSelection;
});
S2.define('select2/selection/placeholder',[
'../utils'
], function (Utils){
function Placeholder (decorated, $element, options){
this.placeholder=this.normalizePlaceholder(options.get('placeholder'));
decorated.call(this, $element, options);
}
Placeholder.prototype.normalizePlaceholder=function (_, placeholder){
if(typeof placeholder==='string'){
placeholder={
id: '',
text: placeholder
};}
return placeholder;
};
Placeholder.prototype.createPlaceholder=function (decorated, placeholder){
var $placeholder=this.selectionContainer();
$placeholder.text(Utils.entityDecode(this.display(placeholder)));
$placeholder.addClass('select2-selection__placeholder')
.removeClass('select2-selection__choice');
return $placeholder;
};
Placeholder.prototype.update=function (decorated, data){
var singlePlaceholder=(
data.length==1&&data[0].id!=this.placeholder.id
);
var multipleSelections=data.length > 1;
if(multipleSelections||singlePlaceholder){
return decorated.call(this, data);
}
this.clear();
var $placeholder=this.createPlaceholder(this.placeholder);
this.$selection.find('.select2-selection__rendered').append($placeholder);
};
return Placeholder;
});
S2.define('select2/selection/allowClear',[
'jquery',
'../keys'
], function ($, KEYS){
function AllowClear (){ }
AllowClear.prototype.bind=function (decorated, container, $container){
var self=this;
decorated.call(this, container, $container);
if(this.placeholder==null){
if(this.options.get('debug')&&window.console&&console.error){
console.error('Select2: The `allowClear` option should be used in combination ' +
'with the `placeholder` option.'
);
}}
this.$selection.on('mousedown', '.select2-selection__clear',
function (evt){
self._handleClear(evt);
});
container.on('keypress', function (evt){
self._handleKeyboardClear(evt, container);
});
};
AllowClear.prototype._handleClear=function (_, evt){
if(this.options.get('disabled')){
return;
}
var $clear=this.$selection.find('.select2-selection__clear');
if($clear.length===0){
return;
}
evt.stopPropagation();
var data=$clear.data('data');
for (var d=0; d < data.length; d++){
var unselectData={
data: data[d]
};
this.trigger('unselect', unselectData);
if(unselectData.prevented){
return;
}}
this.$element.val(this.placeholder.id).trigger('change');
this.trigger('toggle', {});
};
AllowClear.prototype._handleKeyboardClear=function (_, evt, container){
if(container.isOpen()){
return;
}
if(evt.which==KEYS.DELETE||evt.which==KEYS.BACKSPACE){
this._handleClear(evt);
}};
AllowClear.prototype.update=function (decorated, data){
decorated.call(this, data);
if(this.$selection.find('.select2-selection__placeholder').length > 0 ||
data.length===0){
return;
}
var $remove=$(
'<span class="select2-selection__clear">' +
'&times;' +
'</span>'
);
$remove.data('data', data);
this.$selection.find('.select2-selection__rendered').prepend($remove);
};
return AllowClear;
});
S2.define('select2/selection/search',[
'jquery',
'../utils',
'../keys'
], function ($, Utils, KEYS){
function Search (decorated, $element, options){
decorated.call(this, $element, options);
}
Search.prototype.render=function (decorated){
var $search=$(
'<li class="select2-search select2-search--inline">' +
'<input class="select2-search__field" type="text" tabindex="-1"' +
' autocomplete="off" autocorrect="off" autocapitalize="none"' +
' spellcheck="false" role="textbox" aria-autocomplete="list" />' +
'</li>'
);
this.$searchContainer=$search;
this.$search=$search.find('input');
var $rendered=decorated.call(this);
this._transferTabIndex();
return $rendered;
};
Search.prototype.bind=function (decorated, container, $container){
var self=this;
var resultsId=container.id + '-results';
decorated.call(this, container, $container);
container.on('open', function (){
self.$search.attr('aria-owns', resultsId);
self.$search.trigger('focus');
});
container.on('close', function (){
self.$search.val('');
self.$search.removeAttr('aria-activedescendant');
self.$search.removeAttr('aria-owns');
self.$search.trigger('focus');
});
container.on('enable', function (){
self.$search.prop('disabled', false);
self._transferTabIndex();
});
container.on('disable', function (){
self.$search.prop('disabled', true);
});
container.on('focus', function (evt){
self.$search.trigger('focus');
});
container.on('results:focus', function (params){
self.$search.attr('aria-activedescendant', params.data._resultId);
});
this.$selection.on('focusin', '.select2-search--inline', function (evt){
self.trigger('focus', evt);
});
this.$selection.on('focusout', '.select2-search--inline', function (evt){
self._handleBlur(evt);
});
this.$selection.on('keydown', '.select2-search--inline', function (evt){
evt.stopPropagation();
self.trigger('keypress', evt);
self._keyUpPrevented=evt.isDefaultPrevented();
var key=evt.which;
if(key===KEYS.BACKSPACE&&self.$search.val()===''){
var $previousChoice=self.$searchContainer
.prev('.select2-selection__choice');
if($previousChoice.length > 0){
var item=$previousChoice.data('data');
self.searchRemoveChoice(item);
evt.preventDefault();
}}else if(evt.which===KEYS.ENTER){
container.open();
evt.preventDefault();
}});
var msie=document.documentMode;
var disableInputEvents=msie&&msie <=11;
this.$selection.on('input.searchcheck',
'.select2-search--inline',
function (evt){
if(disableInputEvents){
self.$selection.off('input.search input.searchcheck');
return;
}
self.$selection.off('keyup.search');
}
);
this.$selection.on('keyup.search input.search',
'.select2-search--inline',
function (evt){
if(disableInputEvents&&evt.type==='input'){
self.$selection.off('input.search input.searchcheck');
return;
}
var key=evt.which;
if(key==KEYS.SHIFT||key==KEYS.CTRL||key==KEYS.ALT){
return;
}
if(key==KEYS.TAB){
return;
}
self.handleSearch(evt);
}
);
};
Search.prototype._transferTabIndex=function (decorated){
this.$search.attr('tabindex', this.$selection.attr('tabindex'));
this.$selection.attr('tabindex', '-1');
};
Search.prototype.createPlaceholder=function (decorated, placeholder){
this.$search.attr('placeholder', placeholder.text);
};
Search.prototype.update=function (decorated, data){
var searchHadFocus=this.$search[0]==document.activeElement;
this.$search.attr('placeholder', '');
decorated.call(this, data);
this.$selection.find('.select2-selection__rendered')
.append(this.$searchContainer);
this.resizeSearch();
if(searchHadFocus){
this.$search.trigger('focus');
}};
Search.prototype.handleSearch=function (){
this.resizeSearch();
if(!this._keyUpPrevented){
var input=this.$search.val();
this.trigger('query', {
term: input
});
}
this._keyUpPrevented=false;
};
Search.prototype.searchRemoveChoice=function (decorated, item){
this.trigger('unselect', {
data: item
});
this.$search.val(item.text);
this.handleSearch();
};
Search.prototype.resizeSearch=function (){
this.$search.css('width', '25px');
var width='';
if(this.$search.attr('placeholder')!==''){
width=this.$selection.find('.select2-selection__rendered').innerWidth();
}else{
var minimumWidth=this.$search.val().length + 1;
width=(minimumWidth * 0.75) + 'em';
}
this.$search.css('width', width);
};
return Search;
});
S2.define('select2/selection/eventRelay',[
'jquery'
], function ($){
function EventRelay (){ }
EventRelay.prototype.bind=function (decorated, container, $container){
var self=this;
var relayEvents=[
'open', 'opening',
'close', 'closing',
'select', 'selecting',
'unselect', 'unselecting'
];
var preventableEvents=['opening', 'closing', 'selecting', 'unselecting'];
decorated.call(this, container, $container);
container.on('*', function (name, params){
if($.inArray(name, relayEvents)===-1){
return;
}
params=params||{};
var evt=$.Event('select2:' + name, {
params: params
});
self.$element.trigger(evt);
if($.inArray(name, preventableEvents)===-1){
return;
}
params.prevented=evt.isDefaultPrevented();
});
};
return EventRelay;
});
S2.define('select2/translation',[
'jquery',
'require'
], function ($, require){
function Translation (dict){
this.dict=dict||{};}
Translation.prototype.all=function (){
return this.dict;
};
Translation.prototype.get=function (key){
return this.dict[key];
};
Translation.prototype.extend=function (translation){
this.dict=$.extend({}, translation.all(), this.dict);
};
Translation._cache={};
Translation.loadPath=function (path){
if(!(path in Translation._cache)){
var translations=require(path);
Translation._cache[path]=translations;
}
return new Translation(Translation._cache[path]);
};
return Translation;
});
S2.define('select2/diacritics',[
], function (){
var diacritics={
'\u24B6': 'A',
'\uFF21': 'A',
'\u00C0': 'A',
'\u00C1': 'A',
'\u00C2': 'A',
'\u1EA6': 'A',
'\u1EA4': 'A',
'\u1EAA': 'A',
'\u1EA8': 'A',
'\u00C3': 'A',
'\u0100': 'A',
'\u0102': 'A',
'\u1EB0': 'A',
'\u1EAE': 'A',
'\u1EB4': 'A',
'\u1EB2': 'A',
'\u0226': 'A',
'\u01E0': 'A',
'\u00C4': 'A',
'\u01DE': 'A',
'\u1EA2': 'A',
'\u00C5': 'A',
'\u01FA': 'A',
'\u01CD': 'A',
'\u0200': 'A',
'\u0202': 'A',
'\u1EA0': 'A',
'\u1EAC': 'A',
'\u1EB6': 'A',
'\u1E00': 'A',
'\u0104': 'A',
'\u023A': 'A',
'\u2C6F': 'A',
'\uA732': 'AA',
'\u00C6': 'AE',
'\u01FC': 'AE',
'\u01E2': 'AE',
'\uA734': 'AO',
'\uA736': 'AU',
'\uA738': 'AV',
'\uA73A': 'AV',
'\uA73C': 'AY',
'\u24B7': 'B',
'\uFF22': 'B',
'\u1E02': 'B',
'\u1E04': 'B',
'\u1E06': 'B',
'\u0243': 'B',
'\u0182': 'B',
'\u0181': 'B',
'\u24B8': 'C',
'\uFF23': 'C',
'\u0106': 'C',
'\u0108': 'C',
'\u010A': 'C',
'\u010C': 'C',
'\u00C7': 'C',
'\u1E08': 'C',
'\u0187': 'C',
'\u023B': 'C',
'\uA73E': 'C',
'\u24B9': 'D',
'\uFF24': 'D',
'\u1E0A': 'D',
'\u010E': 'D',
'\u1E0C': 'D',
'\u1E10': 'D',
'\u1E12': 'D',
'\u1E0E': 'D',
'\u0110': 'D',
'\u018B': 'D',
'\u018A': 'D',
'\u0189': 'D',
'\uA779': 'D',
'\u01F1': 'DZ',
'\u01C4': 'DZ',
'\u01F2': 'Dz',
'\u01C5': 'Dz',
'\u24BA': 'E',
'\uFF25': 'E',
'\u00C8': 'E',
'\u00C9': 'E',
'\u00CA': 'E',
'\u1EC0': 'E',
'\u1EBE': 'E',
'\u1EC4': 'E',
'\u1EC2': 'E',
'\u1EBC': 'E',
'\u0112': 'E',
'\u1E14': 'E',
'\u1E16': 'E',
'\u0114': 'E',
'\u0116': 'E',
'\u00CB': 'E',
'\u1EBA': 'E',
'\u011A': 'E',
'\u0204': 'E',
'\u0206': 'E',
'\u1EB8': 'E',
'\u1EC6': 'E',
'\u0228': 'E',
'\u1E1C': 'E',
'\u0118': 'E',
'\u1E18': 'E',
'\u1E1A': 'E',
'\u0190': 'E',
'\u018E': 'E',
'\u24BB': 'F',
'\uFF26': 'F',
'\u1E1E': 'F',
'\u0191': 'F',
'\uA77B': 'F',
'\u24BC': 'G',
'\uFF27': 'G',
'\u01F4': 'G',
'\u011C': 'G',
'\u1E20': 'G',
'\u011E': 'G',
'\u0120': 'G',
'\u01E6': 'G',
'\u0122': 'G',
'\u01E4': 'G',
'\u0193': 'G',
'\uA7A0': 'G',
'\uA77D': 'G',
'\uA77E': 'G',
'\u24BD': 'H',
'\uFF28': 'H',
'\u0124': 'H',
'\u1E22': 'H',
'\u1E26': 'H',
'\u021E': 'H',
'\u1E24': 'H',
'\u1E28': 'H',
'\u1E2A': 'H',
'\u0126': 'H',
'\u2C67': 'H',
'\u2C75': 'H',
'\uA78D': 'H',
'\u24BE': 'I',
'\uFF29': 'I',
'\u00CC': 'I',
'\u00CD': 'I',
'\u00CE': 'I',
'\u0128': 'I',
'\u012A': 'I',
'\u012C': 'I',
'\u0130': 'I',
'\u00CF': 'I',
'\u1E2E': 'I',
'\u1EC8': 'I',
'\u01CF': 'I',
'\u0208': 'I',
'\u020A': 'I',
'\u1ECA': 'I',
'\u012E': 'I',
'\u1E2C': 'I',
'\u0197': 'I',
'\u24BF': 'J',
'\uFF2A': 'J',
'\u0134': 'J',
'\u0248': 'J',
'\u24C0': 'K',
'\uFF2B': 'K',
'\u1E30': 'K',
'\u01E8': 'K',
'\u1E32': 'K',
'\u0136': 'K',
'\u1E34': 'K',
'\u0198': 'K',
'\u2C69': 'K',
'\uA740': 'K',
'\uA742': 'K',
'\uA744': 'K',
'\uA7A2': 'K',
'\u24C1': 'L',
'\uFF2C': 'L',
'\u013F': 'L',
'\u0139': 'L',
'\u013D': 'L',
'\u1E36': 'L',
'\u1E38': 'L',
'\u013B': 'L',
'\u1E3C': 'L',
'\u1E3A': 'L',
'\u0141': 'L',
'\u023D': 'L',
'\u2C62': 'L',
'\u2C60': 'L',
'\uA748': 'L',
'\uA746': 'L',
'\uA780': 'L',
'\u01C7': 'LJ',
'\u01C8': 'Lj',
'\u24C2': 'M',
'\uFF2D': 'M',
'\u1E3E': 'M',
'\u1E40': 'M',
'\u1E42': 'M',
'\u2C6E': 'M',
'\u019C': 'M',
'\u24C3': 'N',
'\uFF2E': 'N',
'\u01F8': 'N',
'\u0143': 'N',
'\u00D1': 'N',
'\u1E44': 'N',
'\u0147': 'N',
'\u1E46': 'N',
'\u0145': 'N',
'\u1E4A': 'N',
'\u1E48': 'N',
'\u0220': 'N',
'\u019D': 'N',
'\uA790': 'N',
'\uA7A4': 'N',
'\u01CA': 'NJ',
'\u01CB': 'Nj',
'\u24C4': 'O',
'\uFF2F': 'O',
'\u00D2': 'O',
'\u00D3': 'O',
'\u00D4': 'O',
'\u1ED2': 'O',
'\u1ED0': 'O',
'\u1ED6': 'O',
'\u1ED4': 'O',
'\u00D5': 'O',
'\u1E4C': 'O',
'\u022C': 'O',
'\u1E4E': 'O',
'\u014C': 'O',
'\u1E50': 'O',
'\u1E52': 'O',
'\u014E': 'O',
'\u022E': 'O',
'\u0230': 'O',
'\u00D6': 'O',
'\u022A': 'O',
'\u1ECE': 'O',
'\u0150': 'O',
'\u01D1': 'O',
'\u020C': 'O',
'\u020E': 'O',
'\u01A0': 'O',
'\u1EDC': 'O',
'\u1EDA': 'O',
'\u1EE0': 'O',
'\u1EDE': 'O',
'\u1EE2': 'O',
'\u1ECC': 'O',
'\u1ED8': 'O',
'\u01EA': 'O',
'\u01EC': 'O',
'\u00D8': 'O',
'\u01FE': 'O',
'\u0186': 'O',
'\u019F': 'O',
'\uA74A': 'O',
'\uA74C': 'O',
'\u01A2': 'OI',
'\uA74E': 'OO',
'\u0222': 'OU',
'\u24C5': 'P',
'\uFF30': 'P',
'\u1E54': 'P',
'\u1E56': 'P',
'\u01A4': 'P',
'\u2C63': 'P',
'\uA750': 'P',
'\uA752': 'P',
'\uA754': 'P',
'\u24C6': 'Q',
'\uFF31': 'Q',
'\uA756': 'Q',
'\uA758': 'Q',
'\u024A': 'Q',
'\u24C7': 'R',
'\uFF32': 'R',
'\u0154': 'R',
'\u1E58': 'R',
'\u0158': 'R',
'\u0210': 'R',
'\u0212': 'R',
'\u1E5A': 'R',
'\u1E5C': 'R',
'\u0156': 'R',
'\u1E5E': 'R',
'\u024C': 'R',
'\u2C64': 'R',
'\uA75A': 'R',
'\uA7A6': 'R',
'\uA782': 'R',
'\u24C8': 'S',
'\uFF33': 'S',
'\u1E9E': 'S',
'\u015A': 'S',
'\u1E64': 'S',
'\u015C': 'S',
'\u1E60': 'S',
'\u0160': 'S',
'\u1E66': 'S',
'\u1E62': 'S',
'\u1E68': 'S',
'\u0218': 'S',
'\u015E': 'S',
'\u2C7E': 'S',
'\uA7A8': 'S',
'\uA784': 'S',
'\u24C9': 'T',
'\uFF34': 'T',
'\u1E6A': 'T',
'\u0164': 'T',
'\u1E6C': 'T',
'\u021A': 'T',
'\u0162': 'T',
'\u1E70': 'T',
'\u1E6E': 'T',
'\u0166': 'T',
'\u01AC': 'T',
'\u01AE': 'T',
'\u023E': 'T',
'\uA786': 'T',
'\uA728': 'TZ',
'\u24CA': 'U',
'\uFF35': 'U',
'\u00D9': 'U',
'\u00DA': 'U',
'\u00DB': 'U',
'\u0168': 'U',
'\u1E78': 'U',
'\u016A': 'U',
'\u1E7A': 'U',
'\u016C': 'U',
'\u00DC': 'U',
'\u01DB': 'U',
'\u01D7': 'U',
'\u01D5': 'U',
'\u01D9': 'U',
'\u1EE6': 'U',
'\u016E': 'U',
'\u0170': 'U',
'\u01D3': 'U',
'\u0214': 'U',
'\u0216': 'U',
'\u01AF': 'U',
'\u1EEA': 'U',
'\u1EE8': 'U',
'\u1EEE': 'U',
'\u1EEC': 'U',
'\u1EF0': 'U',
'\u1EE4': 'U',
'\u1E72': 'U',
'\u0172': 'U',
'\u1E76': 'U',
'\u1E74': 'U',
'\u0244': 'U',
'\u24CB': 'V',
'\uFF36': 'V',
'\u1E7C': 'V',
'\u1E7E': 'V',
'\u01B2': 'V',
'\uA75E': 'V',
'\u0245': 'V',
'\uA760': 'VY',
'\u24CC': 'W',
'\uFF37': 'W',
'\u1E80': 'W',
'\u1E82': 'W',
'\u0174': 'W',
'\u1E86': 'W',
'\u1E84': 'W',
'\u1E88': 'W',
'\u2C72': 'W',
'\u24CD': 'X',
'\uFF38': 'X',
'\u1E8A': 'X',
'\u1E8C': 'X',
'\u24CE': 'Y',
'\uFF39': 'Y',
'\u1EF2': 'Y',
'\u00DD': 'Y',
'\u0176': 'Y',
'\u1EF8': 'Y',
'\u0232': 'Y',
'\u1E8E': 'Y',
'\u0178': 'Y',
'\u1EF6': 'Y',
'\u1EF4': 'Y',
'\u01B3': 'Y',
'\u024E': 'Y',
'\u1EFE': 'Y',
'\u24CF': 'Z',
'\uFF3A': 'Z',
'\u0179': 'Z',
'\u1E90': 'Z',
'\u017B': 'Z',
'\u017D': 'Z',
'\u1E92': 'Z',
'\u1E94': 'Z',
'\u01B5': 'Z',
'\u0224': 'Z',
'\u2C7F': 'Z',
'\u2C6B': 'Z',
'\uA762': 'Z',
'\u24D0': 'a',
'\uFF41': 'a',
'\u1E9A': 'a',
'\u00E0': 'a',
'\u00E1': 'a',
'\u00E2': 'a',
'\u1EA7': 'a',
'\u1EA5': 'a',
'\u1EAB': 'a',
'\u1EA9': 'a',
'\u00E3': 'a',
'\u0101': 'a',
'\u0103': 'a',
'\u1EB1': 'a',
'\u1EAF': 'a',
'\u1EB5': 'a',
'\u1EB3': 'a',
'\u0227': 'a',
'\u01E1': 'a',
'\u00E4': 'a',
'\u01DF': 'a',
'\u1EA3': 'a',
'\u00E5': 'a',
'\u01FB': 'a',
'\u01CE': 'a',
'\u0201': 'a',
'\u0203': 'a',
'\u1EA1': 'a',
'\u1EAD': 'a',
'\u1EB7': 'a',
'\u1E01': 'a',
'\u0105': 'a',
'\u2C65': 'a',
'\u0250': 'a',
'\uA733': 'aa',
'\u00E6': 'ae',
'\u01FD': 'ae',
'\u01E3': 'ae',
'\uA735': 'ao',
'\uA737': 'au',
'\uA739': 'av',
'\uA73B': 'av',
'\uA73D': 'ay',
'\u24D1': 'b',
'\uFF42': 'b',
'\u1E03': 'b',
'\u1E05': 'b',
'\u1E07': 'b',
'\u0180': 'b',
'\u0183': 'b',
'\u0253': 'b',
'\u24D2': 'c',
'\uFF43': 'c',
'\u0107': 'c',
'\u0109': 'c',
'\u010B': 'c',
'\u010D': 'c',
'\u00E7': 'c',
'\u1E09': 'c',
'\u0188': 'c',
'\u023C': 'c',
'\uA73F': 'c',
'\u2184': 'c',
'\u24D3': 'd',
'\uFF44': 'd',
'\u1E0B': 'd',
'\u010F': 'd',
'\u1E0D': 'd',
'\u1E11': 'd',
'\u1E13': 'd',
'\u1E0F': 'd',
'\u0111': 'd',
'\u018C': 'd',
'\u0256': 'd',
'\u0257': 'd',
'\uA77A': 'd',
'\u01F3': 'dz',
'\u01C6': 'dz',
'\u24D4': 'e',
'\uFF45': 'e',
'\u00E8': 'e',
'\u00E9': 'e',
'\u00EA': 'e',
'\u1EC1': 'e',
'\u1EBF': 'e',
'\u1EC5': 'e',
'\u1EC3': 'e',
'\u1EBD': 'e',
'\u0113': 'e',
'\u1E15': 'e',
'\u1E17': 'e',
'\u0115': 'e',
'\u0117': 'e',
'\u00EB': 'e',
'\u1EBB': 'e',
'\u011B': 'e',
'\u0205': 'e',
'\u0207': 'e',
'\u1EB9': 'e',
'\u1EC7': 'e',
'\u0229': 'e',
'\u1E1D': 'e',
'\u0119': 'e',
'\u1E19': 'e',
'\u1E1B': 'e',
'\u0247': 'e',
'\u025B': 'e',
'\u01DD': 'e',
'\u24D5': 'f',
'\uFF46': 'f',
'\u1E1F': 'f',
'\u0192': 'f',
'\uA77C': 'f',
'\u24D6': 'g',
'\uFF47': 'g',
'\u01F5': 'g',
'\u011D': 'g',
'\u1E21': 'g',
'\u011F': 'g',
'\u0121': 'g',
'\u01E7': 'g',
'\u0123': 'g',
'\u01E5': 'g',
'\u0260': 'g',
'\uA7A1': 'g',
'\u1D79': 'g',
'\uA77F': 'g',
'\u24D7': 'h',
'\uFF48': 'h',
'\u0125': 'h',
'\u1E23': 'h',
'\u1E27': 'h',
'\u021F': 'h',
'\u1E25': 'h',
'\u1E29': 'h',
'\u1E2B': 'h',
'\u1E96': 'h',
'\u0127': 'h',
'\u2C68': 'h',
'\u2C76': 'h',
'\u0265': 'h',
'\u0195': 'hv',
'\u24D8': 'i',
'\uFF49': 'i',
'\u00EC': 'i',
'\u00ED': 'i',
'\u00EE': 'i',
'\u0129': 'i',
'\u012B': 'i',
'\u012D': 'i',
'\u00EF': 'i',
'\u1E2F': 'i',
'\u1EC9': 'i',
'\u01D0': 'i',
'\u0209': 'i',
'\u020B': 'i',
'\u1ECB': 'i',
'\u012F': 'i',
'\u1E2D': 'i',
'\u0268': 'i',
'\u0131': 'i',
'\u24D9': 'j',
'\uFF4A': 'j',
'\u0135': 'j',
'\u01F0': 'j',
'\u0249': 'j',
'\u24DA': 'k',
'\uFF4B': 'k',
'\u1E31': 'k',
'\u01E9': 'k',
'\u1E33': 'k',
'\u0137': 'k',
'\u1E35': 'k',
'\u0199': 'k',
'\u2C6A': 'k',
'\uA741': 'k',
'\uA743': 'k',
'\uA745': 'k',
'\uA7A3': 'k',
'\u24DB': 'l',
'\uFF4C': 'l',
'\u0140': 'l',
'\u013A': 'l',
'\u013E': 'l',
'\u1E37': 'l',
'\u1E39': 'l',
'\u013C': 'l',
'\u1E3D': 'l',
'\u1E3B': 'l',
'\u017F': 'l',
'\u0142': 'l',
'\u019A': 'l',
'\u026B': 'l',
'\u2C61': 'l',
'\uA749': 'l',
'\uA781': 'l',
'\uA747': 'l',
'\u01C9': 'lj',
'\u24DC': 'm',
'\uFF4D': 'm',
'\u1E3F': 'm',
'\u1E41': 'm',
'\u1E43': 'm',
'\u0271': 'm',
'\u026F': 'm',
'\u24DD': 'n',
'\uFF4E': 'n',
'\u01F9': 'n',
'\u0144': 'n',
'\u00F1': 'n',
'\u1E45': 'n',
'\u0148': 'n',
'\u1E47': 'n',
'\u0146': 'n',
'\u1E4B': 'n',
'\u1E49': 'n',
'\u019E': 'n',
'\u0272': 'n',
'\u0149': 'n',
'\uA791': 'n',
'\uA7A5': 'n',
'\u01CC': 'nj',
'\u24DE': 'o',
'\uFF4F': 'o',
'\u00F2': 'o',
'\u00F3': 'o',
'\u00F4': 'o',
'\u1ED3': 'o',
'\u1ED1': 'o',
'\u1ED7': 'o',
'\u1ED5': 'o',
'\u00F5': 'o',
'\u1E4D': 'o',
'\u022D': 'o',
'\u1E4F': 'o',
'\u014D': 'o',
'\u1E51': 'o',
'\u1E53': 'o',
'\u014F': 'o',
'\u022F': 'o',
'\u0231': 'o',
'\u00F6': 'o',
'\u022B': 'o',
'\u1ECF': 'o',
'\u0151': 'o',
'\u01D2': 'o',
'\u020D': 'o',
'\u020F': 'o',
'\u01A1': 'o',
'\u1EDD': 'o',
'\u1EDB': 'o',
'\u1EE1': 'o',
'\u1EDF': 'o',
'\u1EE3': 'o',
'\u1ECD': 'o',
'\u1ED9': 'o',
'\u01EB': 'o',
'\u01ED': 'o',
'\u00F8': 'o',
'\u01FF': 'o',
'\u0254': 'o',
'\uA74B': 'o',
'\uA74D': 'o',
'\u0275': 'o',
'\u01A3': 'oi',
'\u0223': 'ou',
'\uA74F': 'oo',
'\u24DF': 'p',
'\uFF50': 'p',
'\u1E55': 'p',
'\u1E57': 'p',
'\u01A5': 'p',
'\u1D7D': 'p',
'\uA751': 'p',
'\uA753': 'p',
'\uA755': 'p',
'\u24E0': 'q',
'\uFF51': 'q',
'\u024B': 'q',
'\uA757': 'q',
'\uA759': 'q',
'\u24E1': 'r',
'\uFF52': 'r',
'\u0155': 'r',
'\u1E59': 'r',
'\u0159': 'r',
'\u0211': 'r',
'\u0213': 'r',
'\u1E5B': 'r',
'\u1E5D': 'r',
'\u0157': 'r',
'\u1E5F': 'r',
'\u024D': 'r',
'\u027D': 'r',
'\uA75B': 'r',
'\uA7A7': 'r',
'\uA783': 'r',
'\u24E2': 's',
'\uFF53': 's',
'\u00DF': 's',
'\u015B': 's',
'\u1E65': 's',
'\u015D': 's',
'\u1E61': 's',
'\u0161': 's',
'\u1E67': 's',
'\u1E63': 's',
'\u1E69': 's',
'\u0219': 's',
'\u015F': 's',
'\u023F': 's',
'\uA7A9': 's',
'\uA785': 's',
'\u1E9B': 's',
'\u24E3': 't',
'\uFF54': 't',
'\u1E6B': 't',
'\u1E97': 't',
'\u0165': 't',
'\u1E6D': 't',
'\u021B': 't',
'\u0163': 't',
'\u1E71': 't',
'\u1E6F': 't',
'\u0167': 't',
'\u01AD': 't',
'\u0288': 't',
'\u2C66': 't',
'\uA787': 't',
'\uA729': 'tz',
'\u24E4': 'u',
'\uFF55': 'u',
'\u00F9': 'u',
'\u00FA': 'u',
'\u00FB': 'u',
'\u0169': 'u',
'\u1E79': 'u',
'\u016B': 'u',
'\u1E7B': 'u',
'\u016D': 'u',
'\u00FC': 'u',
'\u01DC': 'u',
'\u01D8': 'u',
'\u01D6': 'u',
'\u01DA': 'u',
'\u1EE7': 'u',
'\u016F': 'u',
'\u0171': 'u',
'\u01D4': 'u',
'\u0215': 'u',
'\u0217': 'u',
'\u01B0': 'u',
'\u1EEB': 'u',
'\u1EE9': 'u',
'\u1EEF': 'u',
'\u1EED': 'u',
'\u1EF1': 'u',
'\u1EE5': 'u',
'\u1E73': 'u',
'\u0173': 'u',
'\u1E77': 'u',
'\u1E75': 'u',
'\u0289': 'u',
'\u24E5': 'v',
'\uFF56': 'v',
'\u1E7D': 'v',
'\u1E7F': 'v',
'\u028B': 'v',
'\uA75F': 'v',
'\u028C': 'v',
'\uA761': 'vy',
'\u24E6': 'w',
'\uFF57': 'w',
'\u1E81': 'w',
'\u1E83': 'w',
'\u0175': 'w',
'\u1E87': 'w',
'\u1E85': 'w',
'\u1E98': 'w',
'\u1E89': 'w',
'\u2C73': 'w',
'\u24E7': 'x',
'\uFF58': 'x',
'\u1E8B': 'x',
'\u1E8D': 'x',
'\u24E8': 'y',
'\uFF59': 'y',
'\u1EF3': 'y',
'\u00FD': 'y',
'\u0177': 'y',
'\u1EF9': 'y',
'\u0233': 'y',
'\u1E8F': 'y',
'\u00FF': 'y',
'\u1EF7': 'y',
'\u1E99': 'y',
'\u1EF5': 'y',
'\u01B4': 'y',
'\u024F': 'y',
'\u1EFF': 'y',
'\u24E9': 'z',
'\uFF5A': 'z',
'\u017A': 'z',
'\u1E91': 'z',
'\u017C': 'z',
'\u017E': 'z',
'\u1E93': 'z',
'\u1E95': 'z',
'\u01B6': 'z',
'\u0225': 'z',
'\u0240': 'z',
'\u2C6C': 'z',
'\uA763': 'z',
'\u0386': '\u0391',
'\u0388': '\u0395',
'\u0389': '\u0397',
'\u038A': '\u0399',
'\u03AA': '\u0399',
'\u038C': '\u039F',
'\u038E': '\u03A5',
'\u03AB': '\u03A5',
'\u038F': '\u03A9',
'\u03AC': '\u03B1',
'\u03AD': '\u03B5',
'\u03AE': '\u03B7',
'\u03AF': '\u03B9',
'\u03CA': '\u03B9',
'\u0390': '\u03B9',
'\u03CC': '\u03BF',
'\u03CD': '\u03C5',
'\u03CB': '\u03C5',
'\u03B0': '\u03C5',
'\u03C9': '\u03C9',
'\u03C2': '\u03C3'
};
return diacritics;
});
S2.define('select2/data/base',[
'../utils'
], function (Utils){
function BaseAdapter ($element, options){
BaseAdapter.__super__.constructor.call(this);
}
Utils.Extend(BaseAdapter, Utils.Observable);
BaseAdapter.prototype.current=function (callback){
throw new Error('The `current` method must be defined in child classes.');
};
BaseAdapter.prototype.query=function (params, callback){
throw new Error('The `query` method must be defined in child classes.');
};
BaseAdapter.prototype.bind=function (container, $container){
};
BaseAdapter.prototype.destroy=function (){
};
BaseAdapter.prototype.generateResultId=function (container, data){
var id='';
if(container!=null){
id +=container.id
}else{
id +=Utils.generateChars(4);
}
id +='-result-';
id +=Utils.generateChars(4);
if(data.id!=null){
id +='-' + data.id.toString();
}else{
id +='-' + Utils.generateChars(4);
}
return id;
};
return BaseAdapter;
});
S2.define('select2/data/select',[
'./base',
'../utils',
'jquery'
], function (BaseAdapter, Utils, $){
function SelectAdapter ($element, options){
this.$element=$element;
this.options=options;
SelectAdapter.__super__.constructor.call(this);
}
Utils.Extend(SelectAdapter, BaseAdapter);
SelectAdapter.prototype.current=function (callback){
var data=[];
var self=this;
this.$element.find(':selected').each(function (){
var $option=$(this);
var option=self.item($option);
data.push(option);
});
callback(data);
};
SelectAdapter.prototype.select=function (data){
var self=this;
data.selected=true;
if($(data.element).is('option')){
data.element.selected=true;
this.$element.trigger('change');
return;
}
if(this.$element.prop('multiple')){
this.current(function (currentData){
var val=[];
data=[data];
data.push.apply(data, currentData);
for (var d=0; d < data.length; d++){
var id=data[d].id;
if($.inArray(id, val)===-1){
val.push(id);
}}
self.$element.val(val);
self.$element.trigger('change');
});
}else{
var val=data.id;
this.$element.val(val);
this.$element.trigger('change');
}};
SelectAdapter.prototype.unselect=function (data){
var self=this;
if(!this.$element.prop('multiple')){
return;
}
data.selected=false;
if($(data.element).is('option')){
data.element.selected=false;
this.$element.trigger('change');
return;
}
this.current(function (currentData){
var val=[];
for (var d=0; d < currentData.length; d++){
var id=currentData[d].id;
if(id!==data.id&&$.inArray(id, val)===-1){
val.push(id);
}}
self.$element.val(val);
self.$element.trigger('change');
});
};
SelectAdapter.prototype.bind=function (container, $container){
var self=this;
this.container=container;
container.on('select', function (params){
self.select(params.data);
});
container.on('unselect', function (params){
self.unselect(params.data);
});
};
SelectAdapter.prototype.destroy=function (){
this.$element.find('*').each(function (){
$.removeData(this, 'data');
});
};
SelectAdapter.prototype.query=function (params, callback){
var data=[];
var self=this;
var $options=this.$element.children();
$options.each(function (){
var $option=$(this);
if(!$option.is('option')&&!$option.is('optgroup')){
return;
}
var option=self.item($option);
var matches=self.matches(params, option);
if(matches!==null){
data.push(matches);
}});
callback({
results: data
});
};
SelectAdapter.prototype.addOptions=function ($options){
Utils.appendMany(this.$element, $options);
};
SelectAdapter.prototype.option=function (data){
var option;
if(data.children){
option=document.createElement('optgroup');
option.label=data.text;
}else{
option=document.createElement('option');
if(option.textContent!==undefined){
option.textContent=data.text;
}else{
option.innerText=data.text;
}}
if(data.id!==undefined){
option.value=data.id;
}
if(data.disabled){
option.disabled=true;
}
if(data.selected){
option.selected=true;
}
if(data.title){
option.title=data.title;
}
var $option=$(option);
var normalizedData=this._normalizeItem(data);
normalizedData.element=option;
$.data(option, 'data', normalizedData);
return $option;
};
SelectAdapter.prototype.item=function ($option){
var data={};
data=$.data($option[0], 'data');
if(data!=null){
return data;
}
if($option.is('option')){
data={
id: $option.val(),
text: $option.text(),
disabled: $option.prop('disabled'),
selected: $option.prop('selected'),
title: $option.prop('title')
};}else if($option.is('optgroup')){
data={
text: $option.prop('label'),
children: [],
title: $option.prop('title')
};
var $children=$option.children('option');
var children=[];
for (var c=0; c < $children.length; c++){
var $child=$($children[c]);
var child=this.item($child);
children.push(child);
}
data.children=children;
}
data=this._normalizeItem(data);
data.element=$option[0];
$.data($option[0], 'data', data);
return data;
};
SelectAdapter.prototype._normalizeItem=function (item){
if(!$.isPlainObject(item)){
item={
id: item,
text: item
};}
item=$.extend({}, {
text: ''
}, item);
var defaults={
selected: false,
disabled: false
};
if(item.id!=null){
item.id=item.id.toString();
}
if(item.text!=null){
item.text=item.text.toString();
}
if(item._resultId==null&&item.id){
item._resultId=this.generateResultId(this.container, item);
}
return $.extend({}, defaults, item);
};
SelectAdapter.prototype.matches=function (params, data){
var matcher=this.options.get('matcher');
return matcher(params, data);
};
return SelectAdapter;
});
S2.define('select2/data/array',[
'./select',
'../utils',
'jquery'
], function (SelectAdapter, Utils, $){
function ArrayAdapter ($element, options){
var data=options.get('data')||[];
ArrayAdapter.__super__.constructor.call(this, $element, options);
this.addOptions(this.convertToOptions(data));
}
Utils.Extend(ArrayAdapter, SelectAdapter);
ArrayAdapter.prototype.select=function (data){
var $option=this.$element.find('option').filter(function (i, elm){
return elm.value==data.id.toString();
});
if($option.length===0){
$option=this.option(data);
this.addOptions($option);
}
ArrayAdapter.__super__.select.call(this, data);
};
ArrayAdapter.prototype.convertToOptions=function (data){
var self=this;
var $existing=this.$element.find('option');
var existingIds=$existing.map(function (){
return self.item($(this)).id;
}).get();
var $options=[];
function onlyItem (item){
return function (){
return $(this).val()==item.id;
};}
for (var d=0; d < data.length; d++){
var item=this._normalizeItem(data[d]);
if($.inArray(item.id, existingIds) >=0){
var $existingOption=$existing.filter(onlyItem(item));
var existingData=this.item($existingOption);
var newData=$.extend(true, {}, item, existingData);
var $newOption=this.option(newData);
$existingOption.replaceWith($newOption);
continue;
}
var $option=this.option(item);
if(item.children){
var $children=this.convertToOptions(item.children);
Utils.appendMany($option, $children);
}
$options.push($option);
}
return $options;
};
return ArrayAdapter;
});
S2.define('select2/data/ajax',[
'./array',
'../utils',
'jquery'
], function (ArrayAdapter, Utils, $){
function AjaxAdapter ($element, options){
this.ajaxOptions=this._applyDefaults(options.get('ajax'));
if(this.ajaxOptions.processResults!=null){
this.processResults=this.ajaxOptions.processResults;
}
AjaxAdapter.__super__.constructor.call(this, $element, options);
}
Utils.Extend(AjaxAdapter, ArrayAdapter);
AjaxAdapter.prototype._applyDefaults=function (options){
var defaults={
data: function (params){
return $.extend({}, params, {
q: params.term
});
},
transport: function (params, success, failure){
var $request=$.ajax(params);
$request.then(success);
$request.fail(failure);
return $request;
}};
return $.extend({}, defaults, options, true);
};
AjaxAdapter.prototype.processResults=function (results){
return results;
};
AjaxAdapter.prototype.query=function (params, callback){
var matches=[];
var self=this;
if(this._request!=null){
if('function'===typeof this._request.abort){
this._request.abort();
}
this._request=null;
}
var options=$.extend({
type: 'GET'
}, this.ajaxOptions);
if(typeof options.url==='function'){
options.url=options.url.call(this.$element, params);
}
if(typeof options.data==='function'){
options.data=options.data.call(this.$element, params);
}
function request (){
var $request=options.transport(options, function (data){
var results=self.processResults(data, params);
if(self.options.get('debug')&&window.console&&console.error){
if(!results||!results.results||!Array.isArray(results.results)){
console.error('Select2: The AJAX results did not return an array in the ' +
'`results` key of the response.'
);
}}
callback(results);
self.container.focusOnActiveElement();
}, function (){
if($request.status&&$request.status==='0'){
return;
}
self.trigger('results:message', {
message: 'errorLoading'
});
});
self._request=$request;
}
if(this.ajaxOptions.delay&&params.term!=null){
if(this._queryTimeout){
window.clearTimeout(this._queryTimeout);
}
this._queryTimeout=window.setTimeout(request, this.ajaxOptions.delay);
}else{
request();
}};
return AjaxAdapter;
});
S2.define('select2/data/tags',[
'jquery'
], function ($){
function Tags (decorated, $element, options){
var tags=options.get('tags');
var createTag=options.get('createTag');
if(createTag!==undefined){
this.createTag=createTag;
}
var insertTag=options.get('insertTag');
if(insertTag!==undefined){
this.insertTag=insertTag;
}
decorated.call(this, $element, options);
if(Array.isArray(tags)){
for (var t=0; t < tags.length; t++){
var tag=tags[t];
var item=this._normalizeItem(tag);
var $option=this.option(item);
this.$element.append($option);
}}
}
Tags.prototype.query=function (decorated, params, callback){
var self=this;
this._removeOldTags();
if(params.term==null||params.page!=null){
decorated.call(this, params, callback);
return;
}
function wrapper (obj, child){
var data=obj.results;
for (var i=0; i < data.length; i++){
var option=data[i];
var checkChildren=(
option.children!=null &&
!wrapper({
results: option.children
}, true)
);
var optionText=(option.text||'').toUpperCase();
var paramsTerm=(params.term||'').toUpperCase();
var checkText=optionText===paramsTerm;
if(checkText||checkChildren){
if(child){
return false;
}
obj.data=data;
callback(obj);
return;
}}
if(child){
return true;
}
var tag=self.createTag(params);
if(tag!=null){
var $option=self.option(tag);
$option.attr('data-select2-tag', true);
self.addOptions([$option]);
self.insertTag(data, tag);
}
obj.results=data;
callback(obj);
}
decorated.call(this, params, wrapper);
};
Tags.prototype.createTag=function (decorated, params){
var term=(params.term||0==params.term) ? params.term.toString().trim():'';
if(term===''){
return null;
}
return {
id: term,
text: term
};};
Tags.prototype.insertTag=function (_, data, tag){
data.unshift(tag);
};
Tags.prototype._removeOldTags=function (_){
var tag=this._lastTag;
var $options=this.$element.find('option[data-select2-tag]');
$options.each(function (){
if(this.selected){
return;
}
$(this).remove();
});
};
return Tags;
});
S2.define('select2/data/tokenizer',[
'jquery'
], function ($){
function Tokenizer (decorated, $element, options){
var tokenizer=options.get('tokenizer');
if(tokenizer!==undefined){
this.tokenizer=tokenizer;
}
decorated.call(this, $element, options);
}
Tokenizer.prototype.bind=function (decorated, container, $container){
decorated.call(this, container, $container);
this.$search=container.dropdown.$search||container.selection.$search ||
$container.find('.select2-search__field');
};
Tokenizer.prototype.query=function (decorated, params, callback){
var self=this;
function createAndSelect (data){
var item=self._normalizeItem(data);
var $existingOptions=self.$element.find('option').filter(function (){
return $(this).val()===item.id;
});
if(!$existingOptions.length){
var $option=self.option(item);
$option.attr('data-select2-tag', true);
self._removeOldTags();
self.addOptions([$option]);
}
select(item);
}
function select (data){
self.trigger('select', {
data: data
});
}
params.term=params.term||'';
var tokenData=this.tokenizer(params, this.options, createAndSelect);
if(tokenData.term!==params.term){
if(this.$search.length){
this.$search.val(tokenData.term);
this.$search.trigger('focus');
}
params.term=tokenData.term;
}
decorated.call(this, params, callback);
};
Tokenizer.prototype.tokenizer=function (_, params, options, callback){
var separators=options.get('tokenSeparators')||[];
var term=params.term;
var i=0;
var createTag=this.createTag||function (params){
return {
id: params.term,
text: params.term
};};
while (i < term.length){
var termChar=term[i];
if($.inArray(termChar, separators)===-1){
i++;
continue;
}
var part=term.substr(0, i);
var partParams=$.extend({}, params, {
term: part
});
var data=createTag(partParams);
if(data==null){
i++;
continue;
}
callback(data);
term=term.substr(i + 1)||'';
i=0;
}
return {
term: term
};};
return Tokenizer;
});
S2.define('select2/data/minimumInputLength',[
], function (){
function MinimumInputLength (decorated, $e, options){
this.minimumInputLength=options.get('minimumInputLength');
decorated.call(this, $e, options);
}
MinimumInputLength.prototype.query=function (decorated, params, callback){
params.term=params.term||'';
if(params.term.length < this.minimumInputLength){
this.trigger('results:message', {
message: 'inputTooShort',
args: {
minimum: this.minimumInputLength,
input: params.term,
params: params
}});
return;
}
decorated.call(this, params, callback);
};
return MinimumInputLength;
});
S2.define('select2/data/maximumInputLength',[
], function (){
function MaximumInputLength (decorated, $e, options){
this.maximumInputLength=options.get('maximumInputLength');
decorated.call(this, $e, options);
}
MaximumInputLength.prototype.query=function (decorated, params, callback){
params.term=params.term||'';
if(this.maximumInputLength > 0 &&
params.term.length > this.maximumInputLength){
this.trigger('results:message', {
message: 'inputTooLong',
args: {
maximum: this.maximumInputLength,
input: params.term,
params: params
}});
return;
}
decorated.call(this, params, callback);
};
return MaximumInputLength;
});
S2.define('select2/data/maximumSelectionLength',[
], function (){
function MaximumSelectionLength (decorated, $e, options){
this.maximumSelectionLength=options.get('maximumSelectionLength');
decorated.call(this, $e, options);
}
MaximumSelectionLength.prototype.query =
function (decorated, params, callback){
var self=this;
this.current(function (currentData){
var count=currentData!=null ? currentData.length:0;
if(self.maximumSelectionLength > 0 &&
count >=self.maximumSelectionLength){
self.trigger('results:message', {
message: 'maximumSelected',
args: {
maximum: self.maximumSelectionLength
}});
return;
}
decorated.call(self, params, callback);
});
};
return MaximumSelectionLength;
});
S2.define('select2/dropdown',[
'jquery',
'./utils'
], function ($, Utils){
function Dropdown ($element, options){
this.$element=$element;
this.options=options;
Dropdown.__super__.constructor.call(this);
}
Utils.Extend(Dropdown, Utils.Observable);
Dropdown.prototype.render=function (){
var $dropdown=$(
'<span class="select2-dropdown">' +
'<span class="select2-results"></span>' +
'</span>'
);
$dropdown.attr('dir', this.options.get('dir'));
this.$dropdown=$dropdown;
return $dropdown;
};
Dropdown.prototype.bind=function (){
};
Dropdown.prototype.position=function ($dropdown, $container){
};
Dropdown.prototype.destroy=function (){
this.$dropdown.remove();
};
return Dropdown;
});
S2.define('select2/dropdown/search',[
'jquery',
'../utils'
], function ($, Utils){
function Search (){ }
Search.prototype.render=function (decorated){
var $rendered=decorated.call(this);
var $search=$(
'<span class="select2-search select2-search--dropdown">' +
'<input class="select2-search__field" type="text" tabindex="-1"' +
' autocomplete="off" autocorrect="off" autocapitalize="none"' +
' spellcheck="false" role="combobox" aria-autocomplete="list" aria-expanded="true" />' +
'</span>'
);
this.$searchContainer=$search;
this.$search=$search.find('input');
$rendered.prepend($search);
return $rendered;
};
Search.prototype.bind=function (decorated, container, $container){
var self=this;
var resultsId=container.id + '-results';
decorated.call(this, container, $container);
this.$search.on('keydown', function (evt){
self.trigger('keypress', evt);
self._keyUpPrevented=evt.isDefaultPrevented();
});
this.$search.on('input', function (evt){
$(this).off('keyup');
});
this.$search.on('keyup input', function (evt){
self.handleSearch(evt);
});
container.on('open', function (){
self.$search.attr('tabindex', 0);
self.$search.attr('aria-owns', resultsId);
self.$search.trigger('focus');
window.setTimeout(function (){
self.$search.trigger('focus');
}, 0);
});
container.on('close', function (){
self.$search.attr('tabindex', -1);
self.$search.removeAttr('aria-activedescendant');
self.$search.removeAttr('aria-owns');
self.$search.val('');
});
container.on('focus', function (){
if(!container.isOpen()){
self.$search.trigger('focus');
}});
container.on('results:all', function (params){
if(params.query.term==null||params.query.term===''){
var showSearch=self.showSearch(params);
if(showSearch){
self.$searchContainer.removeClass('select2-search--hide');
}else{
self.$searchContainer.addClass('select2-search--hide');
}}
});
container.on('results:focus', function (params){
self.$search.attr('aria-activedescendant', params.data._resultId);
});
};
Search.prototype.handleSearch=function (evt){
if(!this._keyUpPrevented){
var input=this.$search.val();
this.trigger('query', {
term: input
});
}
this._keyUpPrevented=false;
};
Search.prototype.showSearch=function (_, params){
return true;
};
return Search;
});
S2.define('select2/dropdown/hidePlaceholder',[
], function (){
function HidePlaceholder (decorated, $element, options, dataAdapter){
this.placeholder=this.normalizePlaceholder(options.get('placeholder'));
decorated.call(this, $element, options, dataAdapter);
}
HidePlaceholder.prototype.append=function (decorated, data){
data.results=this.removePlaceholder(data.results);
decorated.call(this, data);
};
HidePlaceholder.prototype.normalizePlaceholder=function (_, placeholder){
if(typeof placeholder==='string'){
placeholder={
id: '',
text: placeholder
};}
return placeholder;
};
HidePlaceholder.prototype.removePlaceholder=function (_, data){
var modifiedData=data.slice(0);
for (var d=data.length - 1; d >=0; d--){
var item=data[d];
if(this.placeholder.id===item.id){
modifiedData.splice(d, 1);
}}
return modifiedData;
};
return HidePlaceholder;
});
S2.define('select2/dropdown/infiniteScroll',[
'jquery'
], function ($){
function InfiniteScroll (decorated, $element, options, dataAdapter){
this.lastParams={};
decorated.call(this, $element, options, dataAdapter);
this.$loadingMore=this.createLoadingMore();
this.loading=false;
}
InfiniteScroll.prototype.append=function (decorated, data){
this.$loadingMore.remove();
this.loading=false;
decorated.call(this, data);
if(this.showLoadingMore(data)){
this.$results.append(this.$loadingMore);
}};
InfiniteScroll.prototype.bind=function (decorated, container, $container){
var self=this;
decorated.call(this, container, $container);
container.on('query', function (params){
self.lastParams=params;
self.loading=true;
});
container.on('query:append', function (params){
self.lastParams=params;
self.loading=true;
});
this.$results.on('scroll', function (){
var isLoadMoreVisible=$.contains(document.documentElement,
self.$loadingMore[0]
);
if(self.loading||!isLoadMoreVisible){
return;
}
var currentOffset=self.$results.offset().top +
self.$results.outerHeight(false);
var loadingMoreOffset=self.$loadingMore.offset().top +
self.$loadingMore.outerHeight(false);
if(currentOffset + 50 >=loadingMoreOffset){
self.loadMore();
}});
};
InfiniteScroll.prototype.loadMore=function (){
this.loading=true;
var params=$.extend({}, {page: 1}, this.lastParams);
params.page++;
this.trigger('query:append', params);
};
InfiniteScroll.prototype.showLoadingMore=function (_, data){
return data.pagination&&data.pagination.more;
};
InfiniteScroll.prototype.createLoadingMore=function (){
var $option=$(
'<li ' +
'class="select2-results__option select2-results__option--load-more"' +
'role="option" aria-disabled="true"></li>'
);
var message=this.options.get('translations').get('loadingMore');
$option.html(message(this.lastParams));
return $option;
};
return InfiniteScroll;
});
S2.define('select2/dropdown/attachBody',[
'jquery',
'../utils'
], function ($, Utils){
function AttachBody (decorated, $element, options){
this.$dropdownParent=options.get('dropdownParent')||$(document.body);
decorated.call(this, $element, options);
}
AttachBody.prototype.bind=function (decorated, container, $container){
var self=this;
var setupResultsEvents=false;
decorated.call(this, container, $container);
container.on('open', function (){
self._showDropdown();
self._attachPositioningHandler(container);
if(!setupResultsEvents){
setupResultsEvents=true;
container.on('results:all', function (){
self._positionDropdown();
self._resizeDropdown();
});
container.on('results:append', function (){
self._positionDropdown();
self._resizeDropdown();
});
}});
container.on('close', function (){
self._hideDropdown();
self._detachPositioningHandler(container);
});
this.$dropdownContainer.on('mousedown', function (evt){
evt.stopPropagation();
});
};
AttachBody.prototype.destroy=function (decorated){
decorated.call(this);
this.$dropdownContainer.remove();
};
AttachBody.prototype.position=function (decorated, $dropdown, $container){
$dropdown.attr('class', $container.attr('class'));
$dropdown.removeClass('select2');
$dropdown.addClass('select2-container--open');
$dropdown.css({
position: 'absolute',
top: -999999
});
this.$container=$container;
};
AttachBody.prototype.render=function (decorated){
var $container=$('<span></span>');
var $dropdown=decorated.call(this);
$container.append($dropdown);
this.$dropdownContainer=$container;
return $container;
};
AttachBody.prototype._hideDropdown=function (decorated){
this.$dropdownContainer.detach();
};
AttachBody.prototype._attachPositioningHandler =
function (decorated, container){
var self=this;
var scrollEvent='scroll.select2.' + container.id;
var resizeEvent='resize.select2.' + container.id;
var orientationEvent='orientationchange.select2.' + container.id;
var $watchers=this.$container.parents().filter(Utils.hasScroll);
$watchers.each(function (){
$(this).data('select2-scroll-position', {
x: $(this).scrollLeft(),
y: $(this).scrollTop()
});
});
$watchers.on(scrollEvent, function (ev){
var position=$(this).data('select2-scroll-position');
$(this).scrollTop(position.y);
});
$(window).on(scrollEvent + ' ' + resizeEvent + ' ' + orientationEvent,
function (e){
self._positionDropdown();
self._resizeDropdown();
});
};
AttachBody.prototype._detachPositioningHandler =
function (decorated, container){
var scrollEvent='scroll.select2.' + container.id;
var resizeEvent='resize.select2.' + container.id;
var orientationEvent='orientationchange.select2.' + container.id;
var $watchers=this.$container.parents().filter(Utils.hasScroll);
$watchers.off(scrollEvent);
$(window).off(scrollEvent + ' ' + resizeEvent + ' ' + orientationEvent);
};
AttachBody.prototype._positionDropdown=function (){
var $window=$(window);
var isCurrentlyAbove=this.$dropdown.hasClass('select2-dropdown--above');
var isCurrentlyBelow=this.$dropdown.hasClass('select2-dropdown--below');
var newDirection=null;
var offset=this.$container.offset();
offset.bottom=offset.top + this.$container.outerHeight(false);
var container={
height: this.$container.outerHeight(false)
};
container.top=offset.top;
container.bottom=offset.top + container.height;
var dropdown={
height: this.$dropdown.outerHeight(false)
};
var viewport={
top: $window.scrollTop(),
bottom: $window.scrollTop() + $window.height()
};
var enoughRoomAbove=viewport.top < (offset.top - dropdown.height);
var enoughRoomBelow=viewport.bottom > (offset.bottom + dropdown.height);
var css={
left: offset.left,
top: container.bottom
};
var $offsetParent=this.$dropdownParent;
if($offsetParent.css('position')==='static'){
$offsetParent=$offsetParent.offsetParent();
}
var parentOffset=$offsetParent.offset();
css.left -=parentOffset.left;
if(!isCurrentlyAbove&&!isCurrentlyBelow){
newDirection='below';
}
if(!enoughRoomBelow&&enoughRoomAbove&&!isCurrentlyAbove){
newDirection='above';
}else if(!enoughRoomAbove&&enoughRoomBelow&&isCurrentlyAbove){
newDirection='below';
}
if(newDirection=='above' ||
(isCurrentlyAbove&&newDirection!=='below')){
css.top=container.top - dropdown.height;
}
if(newDirection!=null){
this.$dropdown
.removeClass('select2-dropdown--below select2-dropdown--above')
.addClass('select2-dropdown--' + newDirection);
this.$container
.removeClass('select2-container--below select2-container--above')
.addClass('select2-container--' + newDirection);
}
this.$dropdownContainer.css(css);
};
AttachBody.prototype._resizeDropdown=function (){
var css={
width: this.$container.outerWidth(false) + 'px'
};
if(this.options.get('dropdownAutoWidth')){
css.minWidth=css.width;
css.position='relative';
css.width='auto';
}
this.$dropdown.css(css);
};
AttachBody.prototype._showDropdown=function (decorated){
this.$dropdownContainer.appendTo(this.$dropdownParent);
this._positionDropdown();
this._resizeDropdown();
};
return AttachBody;
});
S2.define('select2/dropdown/minimumResultsForSearch',[
], function (){
function countResults (data){
var count=0;
for (var d=0; d < data.length; d++){
var item=data[d];
if(item.children){
count +=countResults(item.children);
}else{
count++;
}}
return count;
}
function MinimumResultsForSearch (decorated, $element, options, dataAdapter){
this.minimumResultsForSearch=options.get('minimumResultsForSearch');
if(this.minimumResultsForSearch < 0){
this.minimumResultsForSearch=Infinity;
}
decorated.call(this, $element, options, dataAdapter);
}
MinimumResultsForSearch.prototype.showSearch=function (decorated, params){
if(countResults(params.data.results) < this.minimumResultsForSearch){
return false;
}
return decorated.call(this, params);
};
return MinimumResultsForSearch;
});
S2.define('select2/dropdown/selectOnClose',[
], function (){
function SelectOnClose (){ }
SelectOnClose.prototype.bind=function (decorated, container, $container){
var self=this;
decorated.call(this, container, $container);
container.on('close', function (params){
self._handleSelectOnClose(params);
});
};
SelectOnClose.prototype._handleSelectOnClose=function (_, params){
if(params&&params.originalSelect2Event!=null){
var event=params.originalSelect2Event;
if(event._type==='select'||event._type==='unselect'){
return;
}}
var $highlightedResults=this.getHighlightedResults();
if($highlightedResults.length < 1){
return;
}
var data=$highlightedResults.data('data');
if((data.element!=null&&data.element.selected) ||
(data.element==null&&data.selected)
){
return;
}
this.trigger('select', {
data: data
});
};
return SelectOnClose;
});
S2.define('select2/dropdown/closeOnSelect',[
], function (){
function CloseOnSelect (){ }
CloseOnSelect.prototype.bind=function (decorated, container, $container){
var self=this;
decorated.call(this, container, $container);
container.on('select', function (evt){
self._selectTriggered(evt);
});
container.on('unselect', function (evt){
self._selectTriggered(evt);
});
};
CloseOnSelect.prototype._selectTriggered=function (_, evt){
var originalEvent=evt.originalEvent;
if(originalEvent&&originalEvent.ctrlKey){
return;
}
this.trigger('close', {
originalEvent: originalEvent,
originalSelect2Event: evt
});
};
return CloseOnSelect;
});
S2.define('select2/i18n/en',[],function (){
return {
errorLoading: function (){
return 'The results could not be loaded.';
},
inputTooLong: function (args){
var overChars=args.input.length - args.maximum;
var message='Please delete ' + overChars + ' character';
if(overChars!=1){
message +='s';
}
return message;
},
inputTooShort: function (args){
var remainingChars=args.minimum - args.input.length;
var message='Please enter ' + remainingChars + ' or more characters';
return message;
},
loadingMore: function (){
return 'Loading more results…';
},
maximumSelected: function (args){
var message='You can only select ' + args.maximum + ' item';
if(args.maximum!=1){
message +='s';
}
return message;
},
noResults: function (){
return 'No results found';
},
searching: function (){
return 'Searching…';
}};});
S2.define('select2/defaults',[
'jquery',
'require',
'./results',
'./selection/single',
'./selection/multiple',
'./selection/placeholder',
'./selection/allowClear',
'./selection/search',
'./selection/eventRelay',
'./utils',
'./translation',
'./diacritics',
'./data/select',
'./data/array',
'./data/ajax',
'./data/tags',
'./data/tokenizer',
'./data/minimumInputLength',
'./data/maximumInputLength',
'./data/maximumSelectionLength',
'./dropdown',
'./dropdown/search',
'./dropdown/hidePlaceholder',
'./dropdown/infiniteScroll',
'./dropdown/attachBody',
'./dropdown/minimumResultsForSearch',
'./dropdown/selectOnClose',
'./dropdown/closeOnSelect',
'./i18n/en'
], function ($, require,
ResultsList,
SingleSelection, MultipleSelection, Placeholder, AllowClear,
SelectionSearch, EventRelay,
Utils, Translation, DIACRITICS,
SelectData, ArrayData, AjaxData, Tags, Tokenizer,
MinimumInputLength, MaximumInputLength, MaximumSelectionLength,
Dropdown, DropdownSearch, HidePlaceholder, InfiniteScroll,
AttachBody, MinimumResultsForSearch, SelectOnClose, CloseOnSelect,
EnglishTranslation){
function Defaults (){
this.reset();
}
Defaults.prototype.apply=function (options){
options=$.extend(true, {}, this.defaults, options);
if(options.dataAdapter==null){
if(options.ajax!=null){
options.dataAdapter=AjaxData;
}else if(options.data!=null){
options.dataAdapter=ArrayData;
}else{
options.dataAdapter=SelectData;
}
if(options.minimumInputLength > 0){
options.dataAdapter=Utils.Decorate(options.dataAdapter,
MinimumInputLength
);
}
if(options.maximumInputLength > 0){
options.dataAdapter=Utils.Decorate(options.dataAdapter,
MaximumInputLength
);
}
if(options.maximumSelectionLength > 0){
options.dataAdapter=Utils.Decorate(options.dataAdapter,
MaximumSelectionLength
);
}
if(options.tags){
options.dataAdapter=Utils.Decorate(options.dataAdapter, Tags);
}
if(options.tokenSeparators!=null||options.tokenizer!=null){
options.dataAdapter=Utils.Decorate(options.dataAdapter,
Tokenizer
);
}
if(options.query!=null){
var Query=require(options.amdBase + 'compat/query');
options.dataAdapter=Utils.Decorate(options.dataAdapter,
Query
);
}
if(options.initSelection!=null){
var InitSelection=require(options.amdBase + 'compat/initSelection');
options.dataAdapter=Utils.Decorate(options.dataAdapter,
InitSelection
);
}}
if(options.resultsAdapter==null){
options.resultsAdapter=ResultsList;
if(options.ajax!=null){
options.resultsAdapter=Utils.Decorate(options.resultsAdapter,
InfiniteScroll
);
}
if(options.placeholder!=null){
options.resultsAdapter=Utils.Decorate(options.resultsAdapter,
HidePlaceholder
);
}
if(options.selectOnClose){
options.resultsAdapter=Utils.Decorate(options.resultsAdapter,
SelectOnClose
);
}}
if(options.dropdownAdapter==null){
if(options.multiple){
options.dropdownAdapter=Dropdown;
}else{
var SearchableDropdown=Utils.Decorate(Dropdown, DropdownSearch);
options.dropdownAdapter=SearchableDropdown;
}
if(options.minimumResultsForSearch!==0){
options.dropdownAdapter=Utils.Decorate(options.dropdownAdapter,
MinimumResultsForSearch
);
}
if(options.closeOnSelect){
options.dropdownAdapter=Utils.Decorate(options.dropdownAdapter,
CloseOnSelect
);
}
if(options.dropdownCssClass!=null ||
options.dropdownCss!=null ||
options.adaptDropdownCssClass!=null
){
var DropdownCSS=require(options.amdBase + 'compat/dropdownCss');
options.dropdownAdapter=Utils.Decorate(options.dropdownAdapter,
DropdownCSS
);
}
options.dropdownAdapter=Utils.Decorate(options.dropdownAdapter,
AttachBody
);
}
if(options.selectionAdapter==null){
if(options.multiple){
options.selectionAdapter=MultipleSelection;
}else{
options.selectionAdapter=SingleSelection;
}
if(options.placeholder!=null){
options.selectionAdapter=Utils.Decorate(options.selectionAdapter,
Placeholder
);
}
if(options.allowClear){
options.selectionAdapter=Utils.Decorate(options.selectionAdapter,
AllowClear
);
}
if(options.multiple){
options.selectionAdapter=Utils.Decorate(options.selectionAdapter,
SelectionSearch
);
}
if(options.containerCssClass!=null ||
options.containerCss!=null ||
options.adaptContainerCssClass!=null
){
var ContainerCSS=require(options.amdBase + 'compat/containerCss');
options.selectionAdapter=Utils.Decorate(options.selectionAdapter,
ContainerCSS
);
}
options.selectionAdapter=Utils.Decorate(options.selectionAdapter,
EventRelay
);
}
if(typeof options.language==='string'){
if(options.language.indexOf('-') > 0){
var languageParts=options.language.split('-');
var baseLanguage=languageParts[0];
options.language=[options.language, baseLanguage];
}else{
options.language=[options.language];
}}
if(Array.isArray(options.language)){
var languages=new Translation();
options.language.push('en');
var languageNames=options.language;
for (var l=0; l < languageNames.length; l++){
var name=languageNames[l];
var language={};
try {
language=Translation.loadPath(name);
} catch (e){
try {
name=this.defaults.amdLanguageBase + name;
language=Translation.loadPath(name);
} catch (ex){
if(options.debug&&window.console&&console.warn){
console.warn('Select2: The language file for "' + name + '" could not be ' +
'automatically loaded. A fallback will be used instead.'
);
}
continue;
}}
languages.extend(language);
}
options.translations=languages;
}else{
var baseTranslation=Translation.loadPath(this.defaults.amdLanguageBase + 'en'
);
var customTranslation=new Translation(options.language);
customTranslation.extend(baseTranslation);
options.translations=customTranslation;
}
return options;
};
Defaults.prototype.reset=function (){
function stripDiacritics (text){
function match(a){
return DIACRITICS[a]||a;
}
return text.replace(/[^\u0000-\u007E]/g, match);
}
function matcher (params, data){
if(params.term==null||params.term.toString().trim()===''){
return data;
}
if(data.children&&data.children.length > 0){
var match=$.extend(true, {}, data);
for (var c=data.children.length - 1; c >=0; c--){
var child=data.children[c];
var matches=matcher(params, child);
if(matches==null){
match.children.splice(c, 1);
}}
if(match.children.length > 0){
return match;
}
return matcher(params, match);
}
var original=stripDiacritics(data.text).toUpperCase();
var term=stripDiacritics(params.term).toUpperCase();
if(original.indexOf(term) > -1){
return data;
}
return null;
}
this.defaults={
amdBase: './',
amdLanguageBase: './i18n/',
closeOnSelect: true,
debug: false,
dropdownAutoWidth: false,
escapeMarkup: Utils.escapeMarkup,
language: EnglishTranslation,
matcher: matcher,
minimumInputLength: 0,
maximumInputLength: 0,
maximumSelectionLength: 0,
minimumResultsForSearch: 0,
selectOnClose: false,
sorter: function (data){
return data;
},
templateResult: function (result){
return result.text;
},
templateSelection: function (selection){
return selection.text;
},
theme: 'default',
width: 'resolve'
};};
Defaults.prototype.set=function (key, value){
var camelKey=$.camelCase(key);
var data={};
data[camelKey]=value;
var convertedData=Utils._convertData(data);
$.extend(this.defaults, convertedData);
};
var defaults=new Defaults();
return defaults;
});
S2.define('select2/options',[
'require',
'jquery',
'./defaults',
'./utils'
], function (require, $, Defaults, Utils){
function Options (options, $element){
this.options=options;
if($element!=null){
this.fromElement($element);
}
this.options=Defaults.apply(this.options);
if($element&&$element.is('input')){
var InputCompat=require(this.get('amdBase') + 'compat/inputData');
this.options.dataAdapter=Utils.Decorate(this.options.dataAdapter,
InputCompat
);
}}
Options.prototype.fromElement=function ($e){
var excludedData=['select2'];
if(this.options.multiple==null){
this.options.multiple=$e.prop('multiple');
}
if(this.options.disabled==null){
this.options.disabled=$e.prop('disabled');
}
if(!this.options.required){
this.options.required=$e.prop('required');
}
if(this.options.language==null){
if($e.prop('lang')){
this.options.language=$e.prop('lang').toLowerCase();
}else if($e.closest('[lang]').prop('lang')){
this.options.language=$e.closest('[lang]').prop('lang');
}}
if(this.options.dir==null){
if($e.prop('dir')){
this.options.dir=$e.prop('dir');
}else if($e.closest('[dir]').prop('dir')){
this.options.dir=$e.closest('[dir]').prop('dir');
}else{
this.options.dir='ltr';
}}
$e.prop('disabled', this.options.disabled);
$e.prop('multiple', this.options.multiple);
if($e.data('select2Tags')){
if(this.options.debug&&window.console&&console.warn){
console.warn('Select2: The `data-select2-tags` attribute has been changed to ' +
'use the `data-data` and `data-tags="true"` attributes and will be ' +
'removed in future versions of Select2.'
);
}
$e.data('data', $e.data('select2Tags'));
$e.data('tags', true);
}
if($e.data('ajaxUrl')){
if(this.options.debug&&window.console&&console.warn){
console.warn('Select2: The `data-ajax-url` attribute has been changed to ' +
'`data-ajax--url` and support for the old attribute will be removed' +
' in future versions of Select2.'
);
}
$e.attr('ajax--url', $e.data('ajaxUrl'));
$e.data('ajax--url', $e.data('ajaxUrl'));
}
var dataset={};
if($.fn.jquery&&$.fn.jquery.substr(0, 2)=='1.'&&$e[0].dataset){
dataset=$.extend(true, {}, $e[0].dataset, $e.data());
}else{
dataset=$e.data();
}
var data=$.extend(true, {}, dataset);
data=Utils._convertData(data);
for (var key in data){
if($.inArray(key, excludedData) > -1){
continue;
}
if($.isPlainObject(this.options[key])){
$.extend(this.options[key], data[key]);
}else{
this.options[key]=data[key];
}}
return this;
};
Options.prototype.get=function (key){
return this.options[key];
};
Options.prototype.set=function (key, val){
this.options[key]=val;
};
return Options;
});
S2.define('select2/core',[
'jquery',
'./options',
'./utils',
'./keys'
], function ($, Options, Utils, KEYS){
var Select2=function ($element, options){
if($element.data('select2')!=null){
$element.data('select2').destroy();
}
this.$element=$element;
this.id=this._generateId($element);
options=options||{};
this.options=new Options(options, $element);
Select2.__super__.constructor.call(this);
var tabindex=$element.attr('tabindex')||0;
$element.data('old-tabindex', tabindex);
$element.attr('tabindex', '-1');
var DataAdapter=this.options.get('dataAdapter');
this.dataAdapter=new DataAdapter($element, this.options);
var $container=this.render();
this._placeContainer($container);
var SelectionAdapter=this.options.get('selectionAdapter');
this.selection=new SelectionAdapter($element, this.options);
this.$selection=this.selection.render();
this.selection.position(this.$selection, $container);
var DropdownAdapter=this.options.get('dropdownAdapter');
this.dropdown=new DropdownAdapter($element, this.options);
this.$dropdown=this.dropdown.render();
this.dropdown.position(this.$dropdown, $container);
var ResultsAdapter=this.options.get('resultsAdapter');
this.results=new ResultsAdapter($element, this.options, this.dataAdapter);
this.$results=this.results.render();
this.results.position(this.$results, this.$dropdown);
var self=this;
this._bindAdapters();
this._registerDomEvents();
this._registerDataEvents();
this._registerSelectionEvents();
this._registerDropdownEvents();
this._registerResultsEvents();
this._registerEvents();
this.dataAdapter.current(function (initialData){
self.trigger('selection:update', {
data: initialData
});
});
$element.addClass('select2-hidden-accessible');
$element.attr('aria-hidden', 'true');
this._syncAttributes();
$element.data('select2', this);
};
Utils.Extend(Select2, Utils.Observable);
Select2.prototype._generateId=function ($element){
var id='';
if($element.attr('id')!=null){
id=$element.attr('id');
}else if($element.attr('name')!=null){
id=$element.attr('name') + '-' + Utils.generateChars(2);
}else{
id=Utils.generateChars(4);
}
id=id.replace(/(:|\.|\[|\]|,)/g, '');
id='select2-' + id;
return id;
};
Select2.prototype._placeContainer=function ($container){
$container.insertAfter(this.$element);
var width=this._resolveWidth(this.$element, this.options.get('width'));
if(width!=null){
$container.css('width', width);
}};
Select2.prototype._resolveWidth=function ($element, method){
var WIDTH=/^width:(([-+]?([0-9]*\.)?[0-9]+)(px|em|ex|%|in|cm|mm|pt|pc))/i;
if(method=='resolve'){
var styleWidth=this._resolveWidth($element, 'style');
if(styleWidth!=null){
return styleWidth;
}
return this._resolveWidth($element, 'element');
}
if(method=='element'){
var elementWidth=$element.outerWidth(false);
if(elementWidth <=0){
return 'auto';
}
return elementWidth + 'px';
}
if(method=='style'){
var style=$element.attr('style');
if(typeof(style)!=='string'){
return null;
}
var attrs=style.split(';');
for (var i=0, l=attrs.length; i < l; i=i + 1){
var attr=attrs[i].replace(/\s/g, '');
var matches=attr.match(WIDTH);
if(matches!==null&&matches.length >=1){
return matches[1];
}}
return null;
}
return method;
};
Select2.prototype._bindAdapters=function (){
this.dataAdapter.bind(this, this.$container);
this.selection.bind(this, this.$container);
this.dropdown.bind(this, this.$container);
this.results.bind(this, this.$container);
};
Select2.prototype._registerDomEvents=function (){
var self=this;
this.$element.on('change.select2', function (){
self.dataAdapter.current(function (data){
self.trigger('selection:update', {
data: data
});
});
});
this.$element.on('focus.select2', function (evt){
self.trigger('focus', evt);
});
this._syncA=Utils.bind(this._syncAttributes, this);
this._syncS=Utils.bind(this._syncSubtree, this);
if(this.$element[0].attachEvent){
this.$element[0].attachEvent('onpropertychange', this._syncA);
}
var observer=window.MutationObserver ||
window.WebKitMutationObserver ||
window.MozMutationObserver
;
if(observer!=null){
this._observer=new observer(function (mutations){
$.each(mutations, self._syncA);
$.each(mutations, self._syncS);
});
this._observer.observe(this.$element[0], {
attributes: true,
childList: true,
subtree: false
});
}else if(this.$element[0].addEventListener){
this.$element[0].addEventListener('DOMAttrModified',
self._syncA,
false
);
this.$element[0].addEventListener('DOMNodeInserted',
self._syncS,
false
);
this.$element[0].addEventListener('DOMNodeRemoved',
self._syncS,
false
);
}};
Select2.prototype._registerDataEvents=function (){
var self=this;
this.dataAdapter.on('*', function (name, params){
self.trigger(name, params);
});
};
Select2.prototype._registerSelectionEvents=function (){
var self=this;
var nonRelayEvents=['toggle', 'focus'];
this.selection.on('toggle', function (){
self.toggleDropdown();
});
this.selection.on('focus', function (params){
self.focus(params);
});
this.selection.on('*', function (name, params){
if($.inArray(name, nonRelayEvents)!==-1){
return;
}
self.trigger(name, params);
});
};
Select2.prototype._registerDropdownEvents=function (){
var self=this;
this.dropdown.on('*', function (name, params){
self.trigger(name, params);
});
};
Select2.prototype._registerResultsEvents=function (){
var self=this;
this.results.on('*', function (name, params){
self.trigger(name, params);
});
};
Select2.prototype._registerEvents=function (){
var self=this;
this.on('open', function (){
self.$container.addClass('select2-container--open');
});
this.on('close', function (){
self.$container.removeClass('select2-container--open');
});
this.on('enable', function (){
self.$container.removeClass('select2-container--disabled');
});
this.on('disable', function (){
self.$container.addClass('select2-container--disabled');
});
this.on('blur', function (){
self.$container.removeClass('select2-container--focus');
});
this.on('query', function (params){
if(!self.isOpen()){
self.trigger('open', {});
}
this.dataAdapter.query(params, function (data){
self.trigger('results:all', {
data: data,
query: params
});
});
});
this.on('query:append', function (params){
this.dataAdapter.query(params, function (data){
self.trigger('results:append', {
data: data,
query: params
});
});
});
this.on('open', function(){
setTimeout(function(){
self.focusOnActiveElement();
}, 1);
});
$(document).on('keydown', function (evt){
var key=evt.which;
if(self.isOpen()){
if(key===KEYS.ESC||(key===KEYS.UP&&evt.altKey)){
self.close();
evt.preventDefault();
}else if(key===KEYS.ENTER||key===KEYS.TAB){
self.trigger('results:select', {});
evt.preventDefault();
}else if((key===KEYS.SPACE&&evt.ctrlKey)){
self.trigger('results:toggle', {});
evt.preventDefault();
}else if(key===KEYS.UP){
self.trigger('results:previous', {});
evt.preventDefault();
}else if(key===KEYS.DOWN){
self.trigger('results:next', {});
evt.preventDefault();
}
var $searchField=self.$dropdown.find('.select2-search__field');
if(! $searchField.length){
$searchField=self.$container.find('.select2-search__field');
}
if(key===KEYS.DOWN||key===KEYS.UP){
self.focusOnActiveElement();
}else{
$searchField.trigger('focus');
setTimeout(function(){
self.focusOnActiveElement();
}, 1000);
}}else if(self.hasFocus()){
if(key===KEYS.ENTER||key===KEYS.SPACE ||
key===KEYS.DOWN){
self.open();
evt.preventDefault();
}}
});
};
Select2.prototype.focusOnActiveElement=function (){
if(this.isOpen()&&! Utils.isTouchscreen()){
this.$results.find('li.select2-results__option--highlighted').trigger('focus');
}};
Select2.prototype._syncAttributes=function (){
this.options.set('disabled', this.$element.prop('disabled'));
if(this.options.get('disabled')){
if(this.isOpen()){
this.close();
}
this.trigger('disable', {});
}else{
this.trigger('enable', {});
}};
Select2.prototype._syncSubtree=function (evt, mutations){
var changed=false;
var self=this;
if(evt&&evt.target&&(
evt.target.nodeName!=='OPTION'&&evt.target.nodeName!=='OPTGROUP'
)
){
return;
}
if(!mutations){
changed=true;
}else if(mutations.addedNodes&&mutations.addedNodes.length > 0){
for (var n=0; n < mutations.addedNodes.length; n++){
var node=mutations.addedNodes[n];
if(node.selected){
changed=true;
}}
}else if(mutations.removedNodes&&mutations.removedNodes.length > 0){
changed=true;
}
if(changed){
this.dataAdapter.current(function (currentData){
self.trigger('selection:update', {
data: currentData
});
});
}};
Select2.prototype.trigger=function (name, args){
var actualTrigger=Select2.__super__.trigger;
var preTriggerMap={
'open': 'opening',
'close': 'closing',
'select': 'selecting',
'unselect': 'unselecting'
};
if(args===undefined){
args={};}
if(name in preTriggerMap){
var preTriggerName=preTriggerMap[name];
var preTriggerArgs={
prevented: false,
name: name,
args: args
};
actualTrigger.call(this, preTriggerName, preTriggerArgs);
if(preTriggerArgs.prevented){
args.prevented=true;
return;
}}
actualTrigger.call(this, name, args);
};
Select2.prototype.toggleDropdown=function (){
if(this.options.get('disabled')){
return;
}
if(this.isOpen()){
this.close();
}else{
this.open();
}};
Select2.prototype.open=function (){
if(this.isOpen()){
return;
}
this.trigger('query', {});
};
Select2.prototype.close=function (){
if(!this.isOpen()){
return;
}
this.trigger('close', {});
};
Select2.prototype.isOpen=function (){
return this.$container.hasClass('select2-container--open');
};
Select2.prototype.hasFocus=function (){
return this.$container.hasClass('select2-container--focus');
};
Select2.prototype.focus=function (data){
if(this.hasFocus()){
return;
}
this.$container.addClass('select2-container--focus');
this.trigger('focus', {});
};
Select2.prototype.enable=function (args){
if(this.options.get('debug')&&window.console&&console.warn){
console.warn('Select2: The `select2("enable")` method has been deprecated and will' +
' be removed in later Select2 versions. Use $element.prop("disabled")' +
' instead.'
);
}
if(args==null||args.length===0){
args=[true];
}
var disabled = !args[0];
this.$element.prop('disabled', disabled);
};
Select2.prototype.data=function (){
if(this.options.get('debug') &&
arguments.length > 0&&window.console&&console.warn){
console.warn('Select2: Data can no longer be set using `select2("data")`. You ' +
'should consider setting the value instead using `$element.val()`.'
);
}
var data=[];
this.dataAdapter.current(function (currentData){
data=currentData;
});
return data;
};
Select2.prototype.val=function (args){
if(this.options.get('debug')&&window.console&&console.warn){
console.warn('Select2: The `select2("val")` method has been deprecated and will be' +
' removed in later Select2 versions. Use $element.val() instead.'
);
}
if(args==null||args.length===0){
return this.$element.val();
}
var newVal=args[0];
if(Array.isArray(newVal)){
newVal=$.map(newVal, function (obj){
return obj.toString();
});
}
this.$element.val(newVal).trigger('change');
};
Select2.prototype.destroy=function (){
this.$container.remove();
if(this.$element[0].detachEvent){
this.$element[0].detachEvent('onpropertychange', this._syncA);
}
if(this._observer!=null){
this._observer.disconnect();
this._observer=null;
}else if(this.$element[0].removeEventListener){
this.$element[0]
.removeEventListener('DOMAttrModified', this._syncA, false);
this.$element[0]
.removeEventListener('DOMNodeInserted', this._syncS, false);
this.$element[0]
.removeEventListener('DOMNodeRemoved', this._syncS, false);
}
this._syncA=null;
this._syncS=null;
this.$element.off('.select2');
this.$element.attr('tabindex', this.$element.data('old-tabindex'));
this.$element.removeClass('select2-hidden-accessible');
this.$element.attr('aria-hidden', 'false');
this.$element.removeData('select2');
this.dataAdapter.destroy();
this.selection.destroy();
this.dropdown.destroy();
this.results.destroy();
this.dataAdapter=null;
this.selection=null;
this.dropdown=null;
this.results=null;
};
Select2.prototype.render=function (){
var $container=$(
'<span class="select2 select2-container">' +
'<span class="selection"></span>' +
'<span class="dropdown-wrapper" aria-hidden="true"></span>' +
'</span>'
);
$container.attr('dir', this.options.get('dir'));
this.$container=$container;
this.$container.addClass('select2-container--' + this.options.get('theme'));
$container.data('element', this.$element);
return $container;
};
return Select2;
});
S2.define('select2/compat/utils',[
'jquery'
], function ($){
function syncCssClasses ($dest, $src, adapter){
var classes, replacements=[], adapted;
classes=($dest.attr('class')||0==$dest.attr('class')) ? $dest.attr('class').toString().trim():'';
if(classes){
classes='' + classes;
$(classes.split(/\s+/)).each(function (){
if(this.indexOf('select2-')===0){
replacements.push(this);
}});
}
classes=($src.attr('class')||0==$src.attr('class')) ? $src.attr('class').toString().trim():'';
if(classes){
classes='' + classes;
$(classes.split(/\s+/)).each(function (){
if(this.indexOf('select2-')!==0){
adapted=adapter(this);
if(adapted!=null){
replacements.push(adapted);
}}
});
}
$dest.attr('class', replacements.join(' '));
}
return {
syncCssClasses: syncCssClasses
};});
S2.define('select2/compat/containerCss',[
'jquery',
'./utils'
], function ($, CompatUtils){
function _containerAdapter (clazz){
return null;
}
function ContainerCSS (){ }
ContainerCSS.prototype.render=function (decorated){
var $container=decorated.call(this);
var containerCssClass=this.options.get('containerCssClass')||'';
if('function'===typeof containerCssClass){
containerCssClass=containerCssClass(this.$element);
}
var containerCssAdapter=this.options.get('adaptContainerCssClass');
containerCssAdapter=containerCssAdapter||_containerAdapter;
if(containerCssClass.indexOf(':all:')!==-1){
containerCssClass=containerCssClass.replace(':all:', '');
var _cssAdapter=containerCssAdapter;
containerCssAdapter=function (clazz){
var adapted=_cssAdapter(clazz);
if(adapted!=null){
return adapted + ' ' + clazz;
}
return clazz;
};}
var containerCss=this.options.get('containerCss')||{};
if('function'===typeof containerCss){
containerCss=containerCss(this.$element);
}
CompatUtils.syncCssClasses($container, this.$element, containerCssAdapter);
$container.css(containerCss);
$container.addClass(containerCssClass);
return $container;
};
return ContainerCSS;
});
S2.define('select2/compat/dropdownCss',[
'jquery',
'./utils'
], function ($, CompatUtils){
function _dropdownAdapter (clazz){
return null;
}
function DropdownCSS (){ }
DropdownCSS.prototype.render=function (decorated){
var $dropdown=decorated.call(this);
var dropdownCssClass=this.options.get('dropdownCssClass')||'';
if('function'===typeof dropdownCssClass){
dropdownCssClass=dropdownCssClass(this.$element);
}
var dropdownCssAdapter=this.options.get('adaptDropdownCssClass');
dropdownCssAdapter=dropdownCssAdapter||_dropdownAdapter;
if(dropdownCssClass.indexOf(':all:')!==-1){
dropdownCssClass=dropdownCssClass.replace(':all:', '');
var _cssAdapter=dropdownCssAdapter;
dropdownCssAdapter=function (clazz){
var adapted=_cssAdapter(clazz);
if(adapted!=null){
return adapted + ' ' + clazz;
}
return clazz;
};}
var dropdownCss=this.options.get('dropdownCss')||{};
if('function'===typeof dropdownCss){
dropdownCss=dropdownCss(this.$element);
}
CompatUtils.syncCssClasses($dropdown, this.$element, dropdownCssAdapter);
$dropdown.css(dropdownCss);
$dropdown.addClass(dropdownCssClass);
return $dropdown;
};
return DropdownCSS;
});
S2.define('select2/compat/initSelection',[
'jquery'
], function ($){
function InitSelection (decorated, $element, options){
if(options.get('debug')&&window.console&&console.warn){
console.warn('Select2: The `initSelection` option has been deprecated in favor' +
' of a custom data adapter that overrides the `current` method. ' +
'This method is now called multiple times instead of a single ' +
'time when the instance is initialized. Support will be removed ' +
'for the `initSelection` option in future versions of Select2'
);
}
this.initSelection=options.get('initSelection');
this._isInitialized=false;
decorated.call(this, $element, options);
}
InitSelection.prototype.current=function (decorated, callback){
var self=this;
if(this._isInitialized){
decorated.call(this, callback);
return;
}
this.initSelection.call(null, this.$element, function (data){
self._isInitialized=true;
if(!Array.isArray(data)){
data=[data];
}
callback(data);
});
};
return InitSelection;
});
S2.define('select2/compat/inputData',[
'jquery'
], function ($){
function InputData (decorated, $element, options){
this._currentData=[];
this._valueSeparator=options.get('valueSeparator')||',';
if($element.prop('type')==='hidden'){
if(options.get('debug')&&console&&console.warn){
console.warn('Select2: Using a hidden input with Select2 is no longer ' +
'supported and may stop working in the future. It is recommended ' +
'to use a `<select>` element instead.'
);
}}
decorated.call(this, $element, options);
}
InputData.prototype.current=function (_, callback){
function getSelected (data, selectedIds){
var selected=[];
if(data.selected||$.inArray(data.id, selectedIds)!==-1){
data.selected=true;
selected.push(data);
}else{
data.selected=false;
}
if(data.children){
selected.push.apply(selected, getSelected(data.children, selectedIds));
}
return selected;
}
var selected=[];
for (var d=0; d < this._currentData.length; d++){
var data=this._currentData[d];
selected.push.apply(selected,
getSelected(
data,
this.$element.val().split(this._valueSeparator
)
)
);
}
callback(selected);
};
InputData.prototype.select=function (_, data){
if(!this.options.get('multiple')){
this.current(function (allData){
$.map(allData, function (data){
data.selected=false;
});
});
this.$element.val(data.id);
this.$element.trigger('change');
}else{
var value=this.$element.val();
value +=this._valueSeparator + data.id;
this.$element.val(value);
this.$element.trigger('change');
}};
InputData.prototype.unselect=function (_, data){
var self=this;
data.selected=false;
this.current(function (allData){
var values=[];
for (var d=0; d < allData.length; d++){
var item=allData[d];
if(data.id==item.id){
continue;
}
values.push(item.id);
}
self.$element.val(values.join(self._valueSeparator));
self.$element.trigger('change');
});
};
InputData.prototype.query=function (_, params, callback){
var results=[];
for (var d=0; d < this._currentData.length; d++){
var data=this._currentData[d];
var matches=this.matches(params, data);
if(matches!==null){
results.push(matches);
}}
callback({
results: results
});
};
InputData.prototype.addOptions=function (_, $options){
var options=$.map($options, function ($option){
return $.data($option[0], 'data');
});
this._currentData.push.apply(this._currentData, options);
};
return InputData;
});
S2.define('select2/compat/matcher',[
'jquery'
], function ($){
function oldMatcher (matcher){
function wrappedMatcher (params, data){
var match=$.extend(true, {}, data);
if(params.term==null||params.term.trim()===''){
return match;
}
if(data.children){
for (var c=data.children.length - 1; c >=0; c--){
var child=data.children[c];
var doesMatch=matcher(params.term, child.text, child);
if(!doesMatch){
match.children.splice(c, 1);
}}
if(match.children.length > 0){
return match;
}}
if(matcher(params.term, data.text, data)){
return match;
}
return null;
}
return wrappedMatcher;
}
return oldMatcher;
});
S2.define('select2/compat/query',[
], function (){
function Query (decorated, $element, options){
if(options.get('debug')&&window.console&&console.warn){
console.warn('Select2: The `query` option has been deprecated in favor of a ' +
'custom data adapter that overrides the `query` method. Support ' +
'will be removed for the `query` option in future versions of ' +
'Select2.'
);
}
decorated.call(this, $element, options);
}
Query.prototype.query=function (_, params, callback){
params.callback=callback;
var query=this.options.get('query');
query.call(null, params);
};
return Query;
});
S2.define('select2/dropdown/attachContainer',[
], function (){
function AttachContainer (decorated, $element, options){
decorated.call(this, $element, options);
}
AttachContainer.prototype.position =
function (decorated, $dropdown, $container){
var $dropdownContainer=$container.find('.dropdown-wrapper');
$dropdownContainer.append($dropdown);
$dropdown.addClass('select2-dropdown--below');
$container.addClass('select2-container--below');
};
return AttachContainer;
});
S2.define('select2/dropdown/stopPropagation',[
], function (){
function StopPropagation (){ }
StopPropagation.prototype.bind=function (decorated, container, $container){
decorated.call(this, container, $container);
var stoppedEvents=[
'blur',
'change',
'click',
'dblclick',
'focus',
'focusin',
'focusout',
'input',
'keydown',
'keyup',
'keypress',
'mousedown',
'mouseenter',
'mouseleave',
'mousemove',
'mouseover',
'mouseup',
'search',
'touchend',
'touchstart'
];
this.$dropdown.on(stoppedEvents.join(' '), function (evt){
evt.stopPropagation();
});
};
return StopPropagation;
});
S2.define('select2/selection/stopPropagation',[
], function (){
function StopPropagation (){ }
StopPropagation.prototype.bind=function (decorated, container, $container){
decorated.call(this, container, $container);
var stoppedEvents=[
'blur',
'change',
'click',
'dblclick',
'focus',
'focusin',
'focusout',
'input',
'keydown',
'keyup',
'keypress',
'mousedown',
'mouseenter',
'mouseleave',
'mousemove',
'mouseover',
'mouseup',
'search',
'touchend',
'touchstart'
];
this.$selection.on(stoppedEvents.join(' '), function (evt){
evt.stopPropagation();
});
};
return StopPropagation;
});
(function (factory){
if(typeof S2.define==='function'&&S2.define.amd){
S2.define('jquery-mousewheel',['jquery'], factory);
}else if(typeof exports==='object'){
module.exports=factory;
}else{
factory(jQuery);
}}(function ($){
var toFix=['wheel', 'mousewheel', 'DOMMouseScroll', 'MozMousePixelScroll'],
toBind=('onwheel' in document||document.documentMode >=9) ?
['wheel']:['mousewheel', 'DomMouseScroll', 'MozMousePixelScroll'],
slice=Array.prototype.slice,
nullLowestDeltaTimeout, lowestDelta;
if($.event.fixHooks){
for(var i=toFix.length; i;){
$.event.fixHooks[ toFix[--i] ]=$.event.mouseHooks;
}}
var special=$.event.special.mousewheel={
version: '3.1.12',
setup: function(){
if(this.addEventListener){
for(var i=toBind.length; i;){
this.addEventListener(toBind[--i], handler, false);
}}else{
this.onmousewheel=handler;
}
$.data(this, 'mousewheel-line-height', special.getLineHeight(this));
$.data(this, 'mousewheel-page-height', special.getPageHeight(this));
},
teardown: function(){
if(this.removeEventListener){
for(var i=toBind.length; i;){
this.removeEventListener(toBind[--i], handler, false);
}}else{
this.onmousewheel=null;
}
$.removeData(this, 'mousewheel-line-height');
$.removeData(this, 'mousewheel-page-height');
},
getLineHeight: function(elem){
var $elem=$(elem),
$parent=$elem['offsetParent' in $.fn ? 'offsetParent':'parent']();
if(!$parent.length){
$parent=$('body');
}
return parseInt($parent.css('fontSize'), 10)||parseInt($elem.css('fontSize'), 10)||16;
},
getPageHeight: function(elem){
return $(elem).height();
},
settings: {
adjustOldDeltas: true,
normalizeOffset: true
}};
$.fn.extend({
mousewheel: function(fn){
return fn ? this.on('mousewheel', fn):this.trigger('mousewheel');
},
unmousewheel: function(fn){
return this.off('mousewheel', fn);
}});
function handler(event){
var orgEvent=event||window.event,
args=slice.call(arguments, 1),
delta=0,
deltaX=0,
deltaY=0,
absDelta=0,
offsetX=0,
offsetY=0;
event=$.event.fix(orgEvent);
event.type='mousewheel';
if('detail'      in orgEvent){ deltaY=orgEvent.detail * -1;      }
if('wheelDelta'  in orgEvent){ deltaY=orgEvent.wheelDelta;       }
if('wheelDeltaY' in orgEvent){ deltaY=orgEvent.wheelDeltaY;      }
if('wheelDeltaX' in orgEvent){ deltaX=orgEvent.wheelDeltaX * -1; }
if('axis' in orgEvent&&orgEvent.axis===orgEvent.HORIZONTAL_AXIS){
deltaX=deltaY * -1;
deltaY=0;
}
delta=deltaY===0 ? deltaX:deltaY;
if('deltaY' in orgEvent){
deltaY=orgEvent.deltaY * -1;
delta=deltaY;
}
if('deltaX' in orgEvent){
deltaX=orgEvent.deltaX;
if(deltaY===0){ delta=deltaX * -1; }}
if(deltaY===0&&deltaX===0){ return; }
if(orgEvent.deltaMode===1){
var lineHeight=$.data(this, 'mousewheel-line-height');
delta  *=lineHeight;
deltaY *=lineHeight;
deltaX *=lineHeight;
}else if(orgEvent.deltaMode===2){
var pageHeight=$.data(this, 'mousewheel-page-height');
delta  *=pageHeight;
deltaY *=pageHeight;
deltaX *=pageHeight;
}
absDelta=Math.max(Math.abs(deltaY), Math.abs(deltaX));
if(!lowestDelta||absDelta < lowestDelta){
lowestDelta=absDelta;
if(shouldAdjustOldDeltas(orgEvent, absDelta)){
lowestDelta /=40;
}}
if(shouldAdjustOldDeltas(orgEvent, absDelta)){
delta  /=40;
deltaX /=40;
deltaY /=40;
}
delta=Math[ delta  >=1 ? 'floor':'ceil' ](delta  / lowestDelta);
deltaX=Math[ deltaX >=1 ? 'floor':'ceil' ](deltaX / lowestDelta);
deltaY=Math[ deltaY >=1 ? 'floor':'ceil' ](deltaY / lowestDelta);
if(special.settings.normalizeOffset&&this.getBoundingClientRect){
var boundingRect=this.getBoundingClientRect();
offsetX=event.clientX - boundingRect.left;
offsetY=event.clientY - boundingRect.top;
}
event.deltaX=deltaX;
event.deltaY=deltaY;
event.deltaFactor=lowestDelta;
event.offsetX=offsetX;
event.offsetY=offsetY;
event.deltaMode=0;
args.unshift(event, delta, deltaX, deltaY);
if(nullLowestDeltaTimeout){ clearTimeout(nullLowestDeltaTimeout); }
nullLowestDeltaTimeout=setTimeout(nullLowestDelta, 200);
return ($.event.dispatch||$.event.handle).apply(this, args);
}
function nullLowestDelta(){
lowestDelta=null;
}
function shouldAdjustOldDeltas(orgEvent, absDelta){
return special.settings.adjustOldDeltas&&orgEvent.type==='mousewheel'&&absDelta % 120===0;
}}));
S2.define('jquery.select2',[
'jquery',
'jquery-mousewheel',
'./select2/core',
'./select2/defaults'
], function ($, _, Select2, Defaults){
if($.fn.selectWoo==null){
var thisMethods=['open', 'close', 'destroy'];
$.fn.selectWoo=function (options){
options=options||{};
if(typeof options==='object'){
this.each(function (){
var instanceOptions=$.extend(true, {}, options);
var instance=new Select2($(this), instanceOptions);
});
return this;
}else if(typeof options==='string'){
var ret;
var args=Array.prototype.slice.call(arguments, 1);
this.each(function (){
var instance=$(this).data('select2');
if(instance==null&&window.console&&console.error){
console.error('The select2(\'' + options + '\') method was called on an ' +
'element that is not using Select2.'
);
}
ret=instance[options].apply(instance, args);
});
if($.inArray(options, thisMethods) > -1){
return this;
}
return ret;
}else{
throw new Error('Invalid arguments for Select2: ' + options);
}};}
if($.fn.select2!=null&&$.fn.select2.defaults!=null){
$.fn.selectWoo.defaults=$.fn.select2.defaults;
}
if($.fn.selectWoo.defaults==null){
$.fn.selectWoo.defaults=Defaults;
}
$.fn.select2=$.fn.select2||$.fn.selectWoo;
return Select2;
});
return {
define: S2.define,
require: S2.require
};}());
var select2=S2.require('jquery.select2');
jQuery.fn.select2.amd=S2;
jQuery.fn.selectWoo.amd=S2;
return select2;
}));
!function(n,t){var r,e;"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define("underscore",t):(n="undefined"!=typeof globalThis?globalThis:n||self,r=n._,(e=n._=t()).noConflict=function(){return n._=r,e})}(this,function(){var n="1.13.7",t="object"==typeof self&&self.self===self&&self||"object"==typeof global&&global.global===global&&global||Function("return this")()||{},e=Array.prototype,V=Object.prototype,F="undefined"!=typeof Symbol?Symbol.prototype:null,P=e.push,f=e.slice,s=V.toString,q=V.hasOwnProperty,r="undefined"!=typeof ArrayBuffer,u="undefined"!=typeof DataView,U=Array.isArray,W=Object.keys,z=Object.create,L=r&&ArrayBuffer.isView,$=isNaN,C=isFinite,K=!{toString:null}.propertyIsEnumerable("toString"),J=["valueOf","isPrototypeOf","toString","propertyIsEnumerable","hasOwnProperty","toLocaleString"],G=Math.pow(2,53)-1;function l(u,o){return o=null==o?u.length-1:+o,function(){for(var n=Math.max(arguments.length-o,0),t=Array(n),r=0;r<n;r++)t[r]=arguments[r+o];switch(o){case 0:return u.call(this,t);case 1:return u.call(this,arguments[0],t);case 2:return u.call(this,arguments[0],arguments[1],t)}for(var e=Array(o+1),r=0;r<o;r++)e[r]=arguments[r];return e[o]=t,u.apply(this,e)}}function o(n){var t=typeof n;return"function"==t||"object"==t&&!!n}function H(n){return void 0===n}function Q(n){return!0===n||!1===n||"[object Boolean]"===s.call(n)}function i(n){var t="[object "+n+"]";return function(n){return s.call(n)===t}}var X=i("String"),Y=i("Number"),Z=i("Date"),nn=i("RegExp"),tn=i("Error"),rn=i("Symbol"),en=i("ArrayBuffer"),a=i("Function"),t=t.document&&t.document.childNodes,p=a="function"!=typeof/./&&"object"!=typeof Int8Array&&"function"!=typeof t?function(n){return"function"==typeof n||!1}:a,t=i("Object"),un=u&&(!/\[native code\]/.test(String(DataView))||t(new DataView(new ArrayBuffer(8)))),a="undefined"!=typeof Map&&t(new Map),u=i("DataView");var h=un?function(n){return null!=n&&p(n.getInt8)&&en(n.buffer)}:u,v=U||i("Array");function y(n,t){return null!=n&&q.call(n,t)}var on=i("Arguments"),an=(!function(){on(arguments)||(on=function(n){return y(n,"callee")})}(),on);function fn(n){return Y(n)&&$(n)}function cn(n){return function(){return n}}function ln(t){return function(n){n=t(n);return"number"==typeof n&&0<=n&&n<=G}}function sn(t){return function(n){return null==n?void 0:n[t]}}var d=sn("byteLength"),pn=ln(d),hn=/\[object ((I|Ui)nt(8|16|32)|Float(32|64)|Uint8Clamped|Big(I|Ui)nt64)Array\]/;var vn=r?function(n){return L?L(n)&&!h(n):pn(n)&&hn.test(s.call(n))}:cn(!1),g=sn("length");function yn(n,t){t=function(t){for(var r={},n=t.length,e=0;e<n;++e)r[t[e]]=!0;return{contains:function(n){return!0===r[n]},push:function(n){return r[n]=!0,t.push(n)}}}(t);var r=J.length,e=n.constructor,u=p(e)&&e.prototype||V,o="constructor";for(y(n,o)&&!t.contains(o)&&t.push(o);r--;)(o=J[r])in n&&n[o]!==u[o]&&!t.contains(o)&&t.push(o)}function b(n){if(!o(n))return[];if(W)return W(n);var t,r=[];for(t in n)y(n,t)&&r.push(t);return K&&yn(n,r),r}function dn(n,t){var r=b(t),e=r.length;if(null==n)return!e;for(var u=Object(n),o=0;o<e;o++){var i=r[o];if(t[i]!==u[i]||!(i in u))return!1}return!0}function m(n){return n instanceof m?n:this instanceof m?void(this._wrapped=n):new m(n)}function gn(n){return new Uint8Array(n.buffer||n,n.byteOffset||0,d(n))}m.VERSION=n,m.prototype.valueOf=m.prototype.toJSON=m.prototype.value=function(){return this._wrapped},m.prototype.toString=function(){return String(this._wrapped)};var bn="[object DataView]";function mn(n,t,r,e){var u;return n===t?0!==n||1/n==1/t:null!=n&&null!=t&&(n!=n?t!=t:("function"==(u=typeof n)||"object"==u||"object"==typeof t)&&function n(t,r,e,u){t instanceof m&&(t=t._wrapped);r instanceof m&&(r=r._wrapped);var o=s.call(t);if(o!==s.call(r))return!1;if(un&&"[object Object]"==o&&h(t)){if(!h(r))return!1;o=bn}switch(o){case"[object RegExp]":case"[object String]":return""+t==""+r;case"[object Number]":return+t!=+t?+r!=+r:0==+t?1/+t==1/r:+t==+r;case"[object Date]":case"[object Boolean]":return+t==+r;case"[object Symbol]":return F.valueOf.call(t)===F.valueOf.call(r);case"[object ArrayBuffer]":case bn:return n(gn(t),gn(r),e,u)}o="[object Array]"===o;if(!o&&vn(t)){var i=d(t);if(i!==d(r))return!1;if(t.buffer===r.buffer&&t.byteOffset===r.byteOffset)return!0;o=!0}if(!o){if("object"!=typeof t||"object"!=typeof r)return!1;var i=t.constructor,a=r.constructor;if(i!==a&&!(p(i)&&i instanceof i&&p(a)&&a instanceof a)&&"constructor"in t&&"constructor"in r)return!1}e=e||[];u=u||[];var f=e.length;for(;f--;)if(e[f]===t)return u[f]===r;e.push(t);u.push(r);if(o){if((f=t.length)!==r.length)return!1;for(;f--;)if(!mn(t[f],r[f],e,u))return!1}else{var c,l=b(t);if(f=l.length,b(r).length!==f)return!1;for(;f--;)if(c=l[f],!y(r,c)||!mn(t[c],r[c],e,u))return!1}e.pop();u.pop();return!0}(n,t,r,e))}function c(n){if(!o(n))return[];var t,r=[];for(t in n)r.push(t);return K&&yn(n,r),r}function jn(e){var u=g(e);return function(n){if(null==n)return!1;var t=c(n);if(g(t))return!1;for(var r=0;r<u;r++)if(!p(n[e[r]]))return!1;return e!==_n||!p(n[wn])}}var wn="forEach",t=["clear","delete"],u=["get","has","set"],U=t.concat(wn,u),_n=t.concat(u),r=["add"].concat(t,wn,"has"),u=a?jn(U):i("Map"),t=a?jn(_n):i("WeakMap"),U=a?jn(r):i("Set"),a=i("WeakSet");function j(n){for(var t=b(n),r=t.length,e=Array(r),u=0;u<r;u++)e[u]=n[t[u]];return e}function An(n){for(var t={},r=b(n),e=0,u=r.length;e<u;e++)t[n[r[e]]]=r[e];return t}function xn(n){var t,r=[];for(t in n)p(n[t])&&r.push(t);return r.sort()}function Sn(f,c){return function(n){var t=arguments.length;if(c&&(n=Object(n)),!(t<2||null==n))for(var r=1;r<t;r++)for(var e=arguments[r],u=f(e),o=u.length,i=0;i<o;i++){var a=u[i];c&&void 0!==n[a]||(n[a]=e[a])}return n}}var On=Sn(c),w=Sn(b),Mn=Sn(c,!0);function En(n){var t;return o(n)?z?z(n):((t=function(){}).prototype=n,n=new t,t.prototype=null,n):{}}function Bn(n){return v(n)?n:[n]}function _(n){return m.toPath(n)}function Nn(n,t){for(var r=t.length,e=0;e<r;e++){if(null==n)return;n=n[t[e]]}return r?n:void 0}function In(n,t,r){n=Nn(n,_(t));return H(n)?r:n}function Tn(n){return n}function A(t){return t=w({},t),function(n){return dn(n,t)}}function kn(t){return t=_(t),function(n){return Nn(n,t)}}function x(u,o,n){if(void 0===o)return u;switch(null==n?3:n){case 1:return function(n){return u.call(o,n)};case 3:return function(n,t,r){return u.call(o,n,t,r)};case 4:return function(n,t,r,e){return u.call(o,n,t,r,e)}}return function(){return u.apply(o,arguments)}}function Dn(n,t,r){return null==n?Tn:p(n)?x(n,t,r):(o(n)&&!v(n)?A:kn)(n)}function Rn(n,t){return Dn(n,t,1/0)}function S(n,t,r){return m.iteratee!==Rn?m.iteratee(n,t):Dn(n,t,r)}function Vn(){}function Fn(n,t){return null==t&&(t=n,n=0),n+Math.floor(Math.random()*(t-n+1))}m.toPath=Bn,m.iteratee=Rn;var O=Date.now||function(){return(new Date).getTime()};function Pn(t){function r(n){return t[n]}var n="(?:"+b(t).join("|")+")",e=RegExp(n),u=RegExp(n,"g");return function(n){return e.test(n=null==n?"":""+n)?n.replace(u,r):n}}var r={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#x27;","`":"&#x60;"},qn=Pn(r),r=Pn(An(r)),Un=m.templateSettings={evaluate:/<%([\s\S]+?)%>/g,interpolate:/<%=([\s\S]+?)%>/g,escape:/<%-([\s\S]+?)%>/g},Wn=/(.)^/,zn={"'":"'","\\":"\\","\r":"r","\n":"n","\u2028":"u2028","\u2029":"u2029"},Ln=/\\|'|\r|\n|\u2028|\u2029/g;function $n(n){return"\\"+zn[n]}var Cn=/^\s*(\w|\$)+\s*$/;var Kn=0;function Jn(n,t,r,e,u){return e instanceof t?(e=En(n.prototype),o(t=n.apply(e,u))?t:e):n.apply(r,u)}var M=l(function(u,o){function i(){for(var n=0,t=o.length,r=Array(t),e=0;e<t;e++)r[e]=o[e]===a?arguments[n++]:o[e];for(;n<arguments.length;)r.push(arguments[n++]);return Jn(u,i,this,this,r)}var a=M.placeholder;return i}),Gn=(M.placeholder=m,l(function(t,r,e){var u;if(p(t))return u=l(function(n){return Jn(t,u,r,this,e.concat(n))});throw new TypeError("Bind must be called on a function")})),E=ln(g);function B(n,t,r,e){if(e=e||[],t||0===t){if(t<=0)return e.concat(n)}else t=1/0;for(var u=e.length,o=0,i=g(n);o<i;o++){var a=n[o];if(E(a)&&(v(a)||an(a)))if(1<t)B(a,t-1,r,e),u=e.length;else for(var f=0,c=a.length;f<c;)e[u++]=a[f++];else r||(e[u++]=a)}return e}var Hn=l(function(n,t){var r=(t=B(t,!1,!1)).length;if(r<1)throw new Error("bindAll must be passed function names");for(;r--;){var e=t[r];n[e]=Gn(n[e],n)}return n});var Qn=l(function(n,t,r){return setTimeout(function(){return n.apply(null,r)},t)}),Xn=M(Qn,m,1);function Yn(n){return function(){return!n.apply(this,arguments)}}function Zn(n,t){var r;return function(){return 0<--n&&(r=t.apply(this,arguments)),n<=1&&(t=null),r}}var nt=M(Zn,2);function tt(n,t,r){t=S(t,r);for(var e,u=b(n),o=0,i=u.length;o<i;o++)if(t(n[e=u[o]],e,n))return e}function rt(o){return function(n,t,r){t=S(t,r);for(var e=g(n),u=0<o?0:e-1;0<=u&&u<e;u+=o)if(t(n[u],u,n))return u;return-1}}var et=rt(1),ut=rt(-1);function ot(n,t,r,e){for(var u=(r=S(r,e,1))(t),o=0,i=g(n);o<i;){var a=Math.floor((o+i)/2);r(n[a])<u?o=a+1:i=a}return o}function it(o,i,a){return function(n,t,r){var e=0,u=g(n);if("number"==typeof r)0<o?e=0<=r?r:Math.max(r+u,e):u=0<=r?Math.min(r+1,u):r+u+1;else if(a&&r&&u)return n[r=a(n,t)]===t?r:-1;if(t!=t)return 0<=(r=i(f.call(n,e,u),fn))?r+e:-1;for(r=0<o?e:u-1;0<=r&&r<u;r+=o)if(n[r]===t)return r;return-1}}var at=it(1,et,ot),ft=it(-1,ut);function ct(n,t,r){t=(E(n)?et:tt)(n,t,r);if(void 0!==t&&-1!==t)return n[t]}function N(n,t,r){if(t=x(t,r),E(n))for(u=0,o=n.length;u<o;u++)t(n[u],u,n);else for(var e=b(n),u=0,o=e.length;u<o;u++)t(n[e[u]],e[u],n);return n}function I(n,t,r){t=S(t,r);for(var e=!E(n)&&b(n),u=(e||n).length,o=Array(u),i=0;i<u;i++){var a=e?e[i]:i;o[i]=t(n[a],a,n)}return o}function lt(f){return function(n,t,r,e){var u=3<=arguments.length;return function(n,t,r,e){var u=!E(n)&&b(n),o=(u||n).length,i=0<f?0:o-1;for(e||(r=n[u?u[i]:i],i+=f);0<=i&&i<o;i+=f){var a=u?u[i]:i;r=t(r,n[a],a,n)}return r}(n,x(t,e,4),r,u)}}var st=lt(1),pt=lt(-1);function T(n,e,t){var u=[];return e=S(e,t),N(n,function(n,t,r){e(n,t,r)&&u.push(n)}),u}function ht(n,t,r){t=S(t,r);for(var e=!E(n)&&b(n),u=(e||n).length,o=0;o<u;o++){var i=e?e[o]:o;if(!t(n[i],i,n))return!1}return!0}function vt(n,t,r){t=S(t,r);for(var e=!E(n)&&b(n),u=(e||n).length,o=0;o<u;o++){var i=e?e[o]:o;if(t(n[i],i,n))return!0}return!1}function k(n,t,r,e){return E(n)||(n=j(n)),0<=at(n,t,r="number"==typeof r&&!e?r:0)}var yt=l(function(n,r,e){var u,o;return p(r)?o=r:(r=_(r),u=r.slice(0,-1),r=r[r.length-1]),I(n,function(n){var t=o;if(!t){if(null==(n=u&&u.length?Nn(n,u):n))return;t=n[r]}return null==t?t:t.apply(n,e)})});function dt(n,t){return I(n,kn(t))}function gt(n,e,t){var r,u,o=-1/0,i=-1/0;if(null==e||"number"==typeof e&&"object"!=typeof n[0]&&null!=n)for(var a=0,f=(n=E(n)?n:j(n)).length;a<f;a++)null!=(r=n[a])&&o<r&&(o=r);else e=S(e,t),N(n,function(n,t,r){u=e(n,t,r),(i<u||u===-1/0&&o===-1/0)&&(o=n,i=u)});return o}var bt=/[^\ud800-\udfff]|[\ud800-\udbff][\udc00-\udfff]|[\ud800-\udfff]/g;function mt(n){return n?v(n)?f.call(n):X(n)?n.match(bt):E(n)?I(n,Tn):j(n):[]}function jt(n,t,r){if(null==t||r)return(n=E(n)?n:j(n))[Fn(n.length-1)];for(var e=mt(n),r=g(e),u=(t=Math.max(Math.min(t,r),0),r-1),o=0;o<t;o++){var i=Fn(o,u),a=e[o];e[o]=e[i],e[i]=a}return e.slice(0,t)}function D(o,t){return function(r,e,n){var u=t?[[],[]]:{};return e=S(e,n),N(r,function(n,t){t=e(n,t,r);o(u,n,t)}),u}}var wt=D(function(n,t,r){y(n,r)?n[r].push(t):n[r]=[t]}),_t=D(function(n,t,r){n[r]=t}),At=D(function(n,t,r){y(n,r)?n[r]++:n[r]=1}),xt=D(function(n,t,r){n[r?0:1].push(t)},!0);function St(n,t,r){return t in r}var Ot=l(function(n,t){var r={},e=t[0];if(null!=n){p(e)?(1<t.length&&(e=x(e,t[1])),t=c(n)):(e=St,t=B(t,!1,!1),n=Object(n));for(var u=0,o=t.length;u<o;u++){var i=t[u],a=n[i];e(a,i,n)&&(r[i]=a)}}return r}),Mt=l(function(n,r){var t,e=r[0];return p(e)?(e=Yn(e),1<r.length&&(t=r[1])):(r=I(B(r,!1,!1),String),e=function(n,t){return!k(r,t)}),Ot(n,e,t)});function Et(n,t,r){return f.call(n,0,Math.max(0,n.length-(null==t||r?1:t)))}function Bt(n,t,r){return null==n||n.length<1?null==t||r?void 0:[]:null==t||r?n[0]:Et(n,n.length-t)}function R(n,t,r){return f.call(n,null==t||r?1:t)}var Nt=l(function(n,t){return t=B(t,!0,!0),T(n,function(n){return!k(t,n)})}),It=l(function(n,t){return Nt(n,t)});function Tt(n,t,r,e){Q(t)||(e=r,r=t,t=!1),null!=r&&(r=S(r,e));for(var u=[],o=[],i=0,a=g(n);i<a;i++){var f=n[i],c=r?r(f,i,n):f;t&&!r?(i&&o===c||u.push(f),o=c):r?k(o,c)||(o.push(c),u.push(f)):k(u,f)||u.push(f)}return u}var kt=l(function(n){return Tt(B(n,!0,!0))});function Dt(n){for(var t=n&&gt(n,g).length||0,r=Array(t),e=0;e<t;e++)r[e]=dt(n,e);return r}var Rt=l(Dt);function Vt(n,t){return n._chain?m(t).chain():t}function Ft(r){return N(xn(r),function(n){var t=m[n]=r[n];m.prototype[n]=function(){var n=[this._wrapped];return P.apply(n,arguments),Vt(this,t.apply(m,n))}}),m}N(["pop","push","reverse","shift","sort","splice","unshift"],function(t){var r=e[t];m.prototype[t]=function(){var n=this._wrapped;return null!=n&&(r.apply(n,arguments),"shift"!==t&&"splice"!==t||0!==n.length||delete n[0]),Vt(this,n)}}),N(["concat","join","slice"],function(n){var t=e[n];m.prototype[n]=function(){var n=this._wrapped;return Vt(this,n=null!=n?t.apply(n,arguments):n)}});n=Ft({__proto__:null,VERSION:n,restArguments:l,isObject:o,isNull:function(n){return null===n},isUndefined:H,isBoolean:Q,isElement:function(n){return!(!n||1!==n.nodeType)},isString:X,isNumber:Y,isDate:Z,isRegExp:nn,isError:tn,isSymbol:rn,isArrayBuffer:en,isDataView:h,isArray:v,isFunction:p,isArguments:an,isFinite:function(n){return!rn(n)&&C(n)&&!isNaN(parseFloat(n))},isNaN:fn,isTypedArray:vn,isEmpty:function(n){var t;return null==n||("number"==typeof(t=g(n))&&(v(n)||X(n)||an(n))?0===t:0===g(b(n)))},isMatch:dn,isEqual:function(n,t){return mn(n,t)},isMap:u,isWeakMap:t,isSet:U,isWeakSet:a,keys:b,allKeys:c,values:j,pairs:function(n){for(var t=b(n),r=t.length,e=Array(r),u=0;u<r;u++)e[u]=[t[u],n[t[u]]];return e},invert:An,functions:xn,methods:xn,extend:On,extendOwn:w,assign:w,defaults:Mn,create:function(n,t){return n=En(n),t&&w(n,t),n},clone:function(n){return o(n)?v(n)?n.slice():On({},n):n},tap:function(n,t){return t(n),n},get:In,has:function(n,t){for(var r=(t=_(t)).length,e=0;e<r;e++){var u=t[e];if(!y(n,u))return!1;n=n[u]}return!!r},mapObject:function(n,t,r){t=S(t,r);for(var e=b(n),u=e.length,o={},i=0;i<u;i++){var a=e[i];o[a]=t(n[a],a,n)}return o},identity:Tn,constant:cn,noop:Vn,toPath:Bn,property:kn,propertyOf:function(t){return null==t?Vn:function(n){return In(t,n)}},matcher:A,matches:A,times:function(n,t,r){var e=Array(Math.max(0,n));t=x(t,r,1);for(var u=0;u<n;u++)e[u]=t(u);return e},random:Fn,now:O,escape:qn,unescape:r,templateSettings:Un,template:function(o,n,t){n=Mn({},n=!n&&t?t:n,m.templateSettings);var r,t=RegExp([(n.escape||Wn).source,(n.interpolate||Wn).source,(n.evaluate||Wn).source].join("|")+"|$","g"),i=0,a="__p+='";if(o.replace(t,function(n,t,r,e,u){return a+=o.slice(i,u).replace(Ln,$n),i=u+n.length,t?a+="'+\n((__t=("+t+"))==null?'':_.escape(__t))+\n'":r?a+="'+\n((__t=("+r+"))==null?'':__t)+\n'":e&&(a+="';\n"+e+"\n__p+='"),n}),a+="';\n",t=n.variable){if(!Cn.test(t))throw new Error("variable is not a bare identifier: "+t)}else a="with(obj||{}){\n"+a+"}\n",t="obj";a="var __t,__p='',__j=Array.prototype.join,print=function(){__p+=__j.call(arguments,'');};\n"+a+"return __p;\n";try{r=new Function(t,"_",a)}catch(n){throw n.source=a,n}function e(n){return r.call(this,n,m)}return e.source="function("+t+"){\n"+a+"}",e},result:function(n,t,r){var e=(t=_(t)).length;if(!e)return p(r)?r.call(n):r;for(var u=0;u<e;u++){var o=null==n?void 0:n[t[u]];void 0===o&&(o=r,u=e),n=p(o)?o.call(n):o}return n},uniqueId:function(n){var t=++Kn+"";return n?n+t:t},chain:function(n){return(n=m(n))._chain=!0,n},iteratee:Rn,partial:M,bind:Gn,bindAll:Hn,memoize:function(e,u){function o(n){var t=o.cache,r=""+(u?u.apply(this,arguments):n);return y(t,r)||(t[r]=e.apply(this,arguments)),t[r]}return o.cache={},o},delay:Qn,defer:Xn,throttle:function(r,e,u){function o(){l=!1===u.leading?0:O(),i=null,c=r.apply(a,f),i||(a=f=null)}function n(){var n=O(),t=(l||!1!==u.leading||(l=n),e-(n-l));return a=this,f=arguments,t<=0||e<t?(i&&(clearTimeout(i),i=null),l=n,c=r.apply(a,f),i||(a=f=null)):i||!1===u.trailing||(i=setTimeout(o,t)),c}var i,a,f,c,l=0;return u=u||{},n.cancel=function(){clearTimeout(i),l=0,i=a=f=null},n},debounce:function(t,r,e){function u(){var n=O()-i;n<r?o=setTimeout(u,r-n):(o=null,e||(f=t.apply(c,a)),o||(a=c=null))}var o,i,a,f,c,n=l(function(n){return c=this,a=n,i=O(),o||(o=setTimeout(u,r),e&&(f=t.apply(c,a))),f});return n.cancel=function(){clearTimeout(o),o=a=c=null},n},wrap:function(n,t){return M(t,n)},negate:Yn,compose:function(){var r=arguments,e=r.length-1;return function(){for(var n=e,t=r[e].apply(this,arguments);n--;)t=r[n].call(this,t);return t}},after:function(n,t){return function(){if(--n<1)return t.apply(this,arguments)}},before:Zn,once:nt,findKey:tt,findIndex:et,findLastIndex:ut,sortedIndex:ot,indexOf:at,lastIndexOf:ft,find:ct,detect:ct,findWhere:function(n,t){return ct(n,A(t))},each:N,forEach:N,map:I,collect:I,reduce:st,foldl:st,inject:st,reduceRight:pt,foldr:pt,filter:T,select:T,reject:function(n,t,r){return T(n,Yn(S(t)),r)},every:ht,all:ht,some:vt,any:vt,contains:k,includes:k,include:k,invoke:yt,pluck:dt,where:function(n,t){return T(n,A(t))},max:gt,min:function(n,e,t){var r,u,o=1/0,i=1/0;if(null==e||"number"==typeof e&&"object"!=typeof n[0]&&null!=n)for(var a=0,f=(n=E(n)?n:j(n)).length;a<f;a++)null!=(r=n[a])&&r<o&&(o=r);else e=S(e,t),N(n,function(n,t,r){((u=e(n,t,r))<i||u===1/0&&o===1/0)&&(o=n,i=u)});return o},shuffle:function(n){return jt(n,1/0)},sample:jt,sortBy:function(n,e,t){var u=0;return e=S(e,t),dt(I(n,function(n,t,r){return{value:n,index:u++,criteria:e(n,t,r)}}).sort(function(n,t){var r=n.criteria,e=t.criteria;if(r!==e){if(e<r||void 0===r)return 1;if(r<e||void 0===e)return-1}return n.index-t.index}),"value")},groupBy:wt,indexBy:_t,countBy:At,partition:xt,toArray:mt,size:function(n){return null==n?0:(E(n)?n:b(n)).length},pick:Ot,omit:Mt,first:Bt,head:Bt,take:Bt,initial:Et,last:function(n,t,r){return null==n||n.length<1?null==t||r?void 0:[]:null==t||r?n[n.length-1]:R(n,Math.max(0,n.length-t))},rest:R,tail:R,drop:R,compact:function(n){return T(n,Boolean)},flatten:function(n,t){return B(n,t,!1)},without:It,uniq:Tt,unique:Tt,union:kt,intersection:function(n){for(var t=[],r=arguments.length,e=0,u=g(n);e<u;e++){var o=n[e];if(!k(t,o)){for(var i=1;i<r&&k(arguments[i],o);i++);i===r&&t.push(o)}}return t},difference:Nt,unzip:Dt,transpose:Dt,zip:Rt,object:function(n,t){for(var r={},e=0,u=g(n);e<u;e++)t?r[n[e]]=t[e]:r[n[e][0]]=n[e][1];return r},range:function(n,t,r){null==t&&(t=n||0,n=0),r=r||(t<n?-1:1);for(var e=Math.max(Math.ceil((t-n)/r),0),u=Array(e),o=0;o<e;o++,n+=r)u[o]=n;return u},chunk:function(n,t){if(null==t||t<1)return[];for(var r=[],e=0,u=n.length;e<u;)r.push(f.call(n,e,e+=t));return r},mixin:Ft,default:m});return n._=n});
window.wp=window.wp||{};
(function ($){
var settings=typeof _wpUtilSettings==='undefined' ? {}:_wpUtilSettings;
wp.template=_.memoize(function(id){
var compiled,
options={
evaluate:    /<#([\s\S]+?)#>/g,
interpolate: /\{\{\{([\s\S]+?)\}\}\}/g,
escape:      /\{\{([^\}]+?)\}\}(?!\})/g,
variable:    'data'
};
return function(data){
var el=document.querySelector('script#tmpl-' + id);
if(! el){
throw new Error('Template not found: ' + '#tmpl-' + id);
}
compiled=compiled||_.template($(el).html(), options);
return compiled(data);
};});
wp.ajax={
settings: settings.ajax||{},
post: function(action, data){
return wp.ajax.send({
data: _.isObject(action) ? action:_.extend(data||{}, { action: action })
});
},
send: function(action, options){
var promise, deferred;
if(_.isObject(action)){
options=action;
}else{
options=options||{};
options.data=_.extend(options.data||{}, { action: action });
}
options=_.defaults(options||{}, {
type:    'POST',
url:     wp.ajax.settings.url,
context: this
});
deferred=$.Deferred(function(deferred){
if(options.success){
deferred.done(options.success);
}
if(options.error){
deferred.fail(options.error);
}
delete options.success;
delete options.error;
deferred.jqXHR=$.ajax(options).done(function(response){
if(response==='1'||response===1){
response={ success: true };}
if(_.isObject(response)&&! _.isUndefined(response.success)){
var context=this;
deferred.done(function(){
if(action &&
action.data &&
'query-attachments'===action.data.action &&
deferred.jqXHR.hasOwnProperty('getResponseHeader') &&
deferred.jqXHR.getResponseHeader('X-WP-Total')
){
context.totalAttachments=parseInt(deferred.jqXHR.getResponseHeader('X-WP-Total'), 10);
}else{
context.totalAttachments=0;
}});
deferred[ response.success ? 'resolveWith':'rejectWith' ](this, [response.data]);
}else{
deferred.rejectWith(this, [response]);
}}).fail(function(){
deferred.rejectWith(this, arguments);
});
});
promise=deferred.promise();
promise.abort=function(){
deferred.jqXHR.abort();
return this;
};
return promise;
}};}(jQuery));
(function($, window, document, undefined){
var VariationForm=function($form){
var self=this;
self.$form=$form;
self.$attributeFields=$form.find('.variations select');
self.$singleVariation=$form.find('.single_variation');
self.$singleVariationWrap=$form.find('.single_variation_wrap');
self.$resetVariations=$form.find('.reset_variations');
self.$resetAlert=$form.find('.reset_variations_alert');
self.$product=$form.closest('.product');
self.variationData=$form.data('product_variations');
self.useAjax=false===self.variationData;
self.xhr=false;
self.loading=true;
self.$singleVariationWrap.show();
self.$form.off('.wc-variation-form');
self.getChosenAttributes=self.getChosenAttributes.bind(self);
self.findMatchingVariations=self.findMatchingVariations.bind(self);
self.isMatch=self.isMatch.bind(self);
self.toggleResetLink=self.toggleResetLink.bind(self);
self.showNoMatchingVariationsMsg =
self.showNoMatchingVariationsMsg.bind(self);
$form.on('click.wc-variation-form',
'.reset_variations',
{ variationForm: self },
self.onReset
);
$form.on('reload_product_variations',
{ variationForm: self },
self.onReload
);
$form.on('hide_variation', { variationForm: self }, self.onHide);
$form.on('show_variation', { variationForm: self }, self.onShow);
$form.on('click',
'.single_add_to_cart_button',
{ variationForm: self },
self.onAddToCart
);
$form.on('reset_data',
{ variationForm: self },
self.onResetDisplayedVariation
);
$form.on('reset_focus',
{ variationForm: self },
self.onResetVariationFocus
);
$form.on('announce_reset',
{ variationForm: self },
self.onAnnounceReset
);
$form.on('clear_reset_announcement',
{ variationForm: self },
self.onClearResetAnnouncement
);
$form.on('reset_image', { variationForm: self }, self.onResetImage);
$form.on('change.wc-variation-form',
'.variations select',
{ variationForm: self },
self.onChange
);
$form.on('found_variation.wc-variation-form',
{ variationForm: self },
self.onFoundVariation
);
$form.on('check_variations.wc-variation-form',
{ variationForm: self },
self.onFindVariation
);
$form.on('update_variation_values.wc-variation-form',
{ variationForm: self },
self.onUpdateAttributes
);
$form.on('keydown.wc-variation-form',
'.reset_variations',
{ variationForm: self },
self.onResetKeyDown
);
setTimeout(function (){
$form.trigger('check_variations');
$form.trigger('wc_variation_form', self);
self.loading=false;
}, 100);
};
VariationForm.prototype.onReset=function(event){
event.preventDefault();
event.data.variationForm.$attributeFields.val('').trigger('change');
event.data.variationForm.$form.trigger('announce_reset');
event.data.variationForm.$form.trigger('reset_data');
event.data.variationForm.$form.trigger('reset_focus');
};
VariationForm.prototype.onReload=function(event){
var form=event.data.variationForm;
form.variationData=form.$form.data('product_variations');
form.useAjax=false===form.variationData;
form.$form.trigger('check_variations');
};
VariationForm.prototype.onHide=function(event){
event.preventDefault();
event.data.variationForm.$form
.find('.single_add_to_cart_button')
.removeClass('wc-variation-is-unavailable')
.addClass('disabled wc-variation-selection-needed');
event.data.variationForm.$form
.find('.woocommerce-variation-add-to-cart')
.removeClass('woocommerce-variation-add-to-cart-enabled')
.addClass('woocommerce-variation-add-to-cart-disabled');
};
VariationForm.prototype.onShow=function (
event,
variation,
purchasable
){
event.preventDefault();
if(purchasable){
event.data.variationForm.$form
.find('.single_add_to_cart_button')
.removeClass('disabled wc-variation-selection-needed wc-variation-is-unavailable'
);
event.data.variationForm.$form
.find('.woocommerce-variation-add-to-cart')
.removeClass('woocommerce-variation-add-to-cart-disabled')
.addClass('woocommerce-variation-add-to-cart-enabled');
}else{
event.data.variationForm.$form
.find('.single_add_to_cart_button')
.removeClass('wc-variation-selection-needed')
.addClass('disabled wc-variation-is-unavailable');
event.data.variationForm.$form
.find('.woocommerce-variation-add-to-cart')
.removeClass('woocommerce-variation-add-to-cart-enabled')
.addClass('woocommerce-variation-add-to-cart-disabled');
}
if(wp.mediaelement){
event.data.variationForm.$form
.find('.wp-audio-shortcode, .wp-video-shortcode')
.not('.mejs-container')
.filter(function (){
return ! $(this).parent().hasClass('mejs-mediaelement');
})
.mediaelementplayer(wp.mediaelement.settings);
}};
VariationForm.prototype.onAddToCart=function(event){
if($(this).is('.disabled')){
event.preventDefault();
if($(this).is('.wc-variation-is-unavailable')){
window.alert(wc_add_to_cart_variation_params.i18n_unavailable_text
);
}else if($(this).is('.wc-variation-selection-needed')){
window.alert(wc_add_to_cart_variation_params.i18n_make_a_selection_text
);
}}
};
VariationForm.prototype.onResetDisplayedVariation=function(event){
var form=event.data.variationForm;
form.$product.find('.product_meta').find('.sku').wc_reset_content();
form.$product
.find('.product_weight, .woocommerce-product-attributes-item--weight .woocommerce-product-attributes-item__value'
)
.wc_reset_content();
form.$product
.find('.product_dimensions, .woocommerce-product-attributes-item--dimensions .woocommerce-product-attributes-item__value'
)
.wc_reset_content();
form.$form.trigger('reset_image');
form.$singleVariation.slideUp(200).trigger('hide_variation');
};
VariationForm.prototype.onAnnounceReset=function(event){
event.data.variationForm.$resetAlert.text(wc_add_to_cart_variation_params.i18n_reset_alert_text
);
};
VariationForm.prototype.onResetVariationFocus=function(event){
event.data.variationForm.$attributeFields[ 0 ].focus();
};
VariationForm.prototype.onClearResetAnnouncement=function(event){
event.data.variationForm.$resetAlert.text('');
};
VariationForm.prototype.onResetImage=function(event){
event.data.variationForm.$form.wc_variations_image_update(false);
};
VariationForm.prototype.onFindVariation=function (
event,
chosenAttributes
){
var form=event.data.variationForm,
attributes =
'undefined'!==typeof chosenAttributes
? chosenAttributes
: form.getChosenAttributes(),
currentAttributes=attributes.data;
if(attributes.count&&attributes.count===attributes.chosenCount){
if(form.useAjax){
if(form.xhr){
form.xhr.abort();
}
form.$form.block({
message: null,
overlayCSS: { background: '#fff', opacity: 0.6 },
});
currentAttributes.product_id=parseInt(
form.$form.data('product_id'),
10
);
currentAttributes.custom_data =
form.$form.data('custom_data');
form.xhr=$.ajax({
url: wc_add_to_cart_variation_params.wc_ajax_url
.toString()
.replace('%%endpoint%%', 'get_variation'),
type: 'POST',
data: currentAttributes,
success: function(variation){
if(variation){
form.$form.trigger('found_variation', [
variation,
]);
}else{
form.$form.trigger('reset_data');
attributes.chosenCount=0;
if(! form.loading){
form.showNoMatchingVariationsMsg();
}}
},
complete: function (){
form.$form.unblock();
},
});
}else{
form.$form.trigger('update_variation_values');
var matching_variations=form.findMatchingVariations(form.variationData,
currentAttributes
),
variation=matching_variations.shift();
if(variation){
form.$form.trigger('found_variation', [ variation ]);
}else{
form.$form.trigger('reset_data');
attributes.chosenCount=0;
if(! form.loading){
form.showNoMatchingVariationsMsg();
}}
}}else{
form.$form.trigger('update_variation_values');
form.$form.trigger('reset_data');
}
form.toggleResetLink(attributes.chosenCount > 0);
};
VariationForm.prototype.onFoundVariation=function(event, variation){
var form=event.data.variationForm,
$sku=form.$product.find('.product_meta').find('.sku'),
$weight=form.$product.find('.product_weight, .woocommerce-product-attributes-item--weight .woocommerce-product-attributes-item__value'
),
$dimensions=form.$product.find('.product_dimensions, .woocommerce-product-attributes-item--dimensions .woocommerce-product-attributes-item__value'
),
$qty_input=form.$singleVariationWrap.find('.quantity input.qty[name="quantity"]'
),
$qty=$qty_input.closest('.quantity'),
purchasable=true,
variation_id='',
template=false,
$template_html='';
if(variation.sku){
$sku.wc_set_content(variation.sku);
}else{
$sku.wc_reset_content();
}
if(variation.weight){
$weight.wc_set_content(variation.weight_html);
}else{
$weight.wc_reset_content();
}
if(variation.dimensions){
$dimensions.wc_set_content($.parseHTML(variation.dimensions_html)[ 0 ].data
);
}else{
$dimensions.wc_reset_content();
}
form.$form.wc_variations_image_update(variation);
if(! variation.variation_is_visible){
template=wp_template('unavailable-variation-template');
}else{
template=wp_template('variation-template');
variation_id=variation.variation_id;
}
$template_html=template({
variation: variation,
});
$template_html=$template_html.replace('', '');
$template_html=$template_html.replace('/*]]>*/', '');
form.$form
.find('input[name="variation_id"], input.variation_id')
.val(variation.variation_id)
.trigger('change');
if(variation.is_sold_individually==='yes'){
$qty_input
.val('1')
.attr('min', '1')
.attr('max', '')
.trigger('change');
$qty.hide();
}else{
var qty_val=parseFloat($qty_input.val());
if(isNaN(qty_val)){
qty_val=variation.min_qty;
}else{
qty_val =
qty_val > parseFloat(variation.max_qty)
? variation.max_qty
: qty_val;
qty_val =
qty_val < parseFloat(variation.min_qty)
? variation.min_qty
: qty_val;
}
$qty_input
.attr('min', variation.min_qty)
.attr('max', variation.max_qty)
.val(qty_val)
.trigger('change');
$qty.show();
}
if(! variation.is_purchasable ||
! variation.is_in_stock ||
! variation.variation_is_visible
){
purchasable=false;
}
setTimeout(function (){
form.$singleVariation.html($template_html);
if(form.$singleVariation.text().trim()){
form.$singleVariation
.slideDown(200)
.trigger('show_variation', [ variation, purchasable ]);
}else{
form.$singleVariation
.show()
.trigger('show_variation', [ variation, purchasable ]);
}}, 300);
};
VariationForm.prototype.onChange=function(event){
var form=event.data.variationForm;
form.$form
.find('input[name="variation_id"], input.variation_id')
.val('')
.trigger('change');
form.$form.trigger('clear_reset_announcement');
form.$form.find('.wc-no-matching-variations').parent().remove();
if(form.useAjax){
form.$form.trigger('check_variations');
}else{
form.$form.trigger('woocommerce_variation_select_change');
form.$form.trigger('check_variations');
}
form.$form.trigger('woocommerce_variation_has_changed');
};
VariationForm.prototype.addSlashes=function(string){
string=string.replace(/'/g, "\\'");
string=string.replace(/"/g, '\\"');
return string;
};
VariationForm.prototype.onUpdateAttributes=function(event){
var form=event.data.variationForm,
attributes=form.getChosenAttributes(),
currentAttributes=attributes.data;
if(form.useAjax){
return;
}
form.$attributeFields.each(function(index, el){
var current_attr_select=$(el),
current_attr_name =
current_attr_select.data('attribute_name') ||
current_attr_select.attr('name'),
show_option_none=$(el).data('show_option_none'),
option_gt_filter=':gt(0)',
attached_options_count=0,
new_attr_select=$('<select/>'),
selected_attr_val=current_attr_select.val()||'',
selected_attr_val_valid=true;
if(! current_attr_select.data('attribute_html')){
var refSelect=current_attr_select.clone();
refSelect
.find('option')
.removeAttr('attached')
.prop('disabled', false)
.prop('selected', false);
current_attr_select.data('attribute_options',
refSelect.find('option' + option_gt_filter).get()
);
current_attr_select.data('attribute_html', refSelect.html());
}
new_attr_select.html(current_attr_select.data('attribute_html')
);
var checkAttributes=$.extend(true, {}, currentAttributes);
checkAttributes[ current_attr_name ]='';
var variations=form.findMatchingVariations(form.variationData,
checkAttributes
);
for(var num in variations){
if(typeof variations[ num ]!=='undefined'){
var variationAttributes=variations[ num ].attributes;
for(var attr_name in variationAttributes){
if(variationAttributes.hasOwnProperty(attr_name)){
var attr_val=variationAttributes[ attr_name ],
variation_active='';
if(attr_name===current_attr_name){
if(variations[ num ].variation_is_active){
variation_active='enabled';
}
if(attr_val){
attr_val=$('<div/>')
.html(attr_val)
.text();
var $option_elements =
new_attr_select.find('option');
if($option_elements.length){
for (
var i=0,
len=$option_elements.length;
i < len;
i++
){
var $option_element=$(
$option_elements[ i ]
),
option_value =
$option_element.val();
if(attr_val===option_value){
$option_element.addClass('attached ' +
variation_active
);
break;
}}
}}else{
new_attr_select
.find('option:gt(0)')
.addClass('attached ' + variation_active
);
}}
}}
}}
attached_options_count =
new_attr_select.find('option.attached').length;
if(selected_attr_val){
selected_attr_val_valid=false;
if(0!==attached_options_count){
new_attr_select
.find('option.attached.enabled')
.each(function (){
var option_value=$(this).val();
if(selected_attr_val===option_value){
selected_attr_val_valid=true;
return false;
}});
}}
if(attached_options_count > 0 &&
selected_attr_val &&
selected_attr_val_valid &&
'no'===show_option_none
){
new_attr_select.find('option:first').remove();
option_gt_filter='';
}
new_attr_select
.find('option' + option_gt_filter + ':not(.attached)')
.remove();
current_attr_select.html(new_attr_select.html());
current_attr_select
.find('option' + option_gt_filter + ':not(.enabled)')
.prop('disabled', true);
if(selected_attr_val){
if(selected_attr_val_valid){
current_attr_select.val(selected_attr_val);
}else{
current_attr_select.val('').trigger('change');
}}else{
current_attr_select.val('');
}});
form.$form.trigger('woocommerce_update_variation_values');
};
VariationForm.prototype.getChosenAttributes=function (){
var data={};
var count=0;
var chosen=0;
this.$attributeFields.each(function (){
var attribute_name =
$(this).data('attribute_name')||$(this).attr('name');
var value=$(this).val()||'';
if(value.length > 0){
chosen++;
}
count++;
data[ attribute_name ]=value;
});
return {
count: count,
chosenCount: chosen,
data: data,
};};
VariationForm.prototype.findMatchingVariations=function (
variations,
attributes
){
var matching=[];
for(var i=0; i < variations.length; i++){
var variation=variations[ i ];
if(this.isMatch(variation.attributes, attributes)){
matching.push(variation);
}}
return matching;
};
VariationForm.prototype.isMatch=function (
variation_attributes,
attributes
){
var match=true;
for(var attr_name in variation_attributes){
if(variation_attributes.hasOwnProperty(attr_name)){
var val1=variation_attributes[ attr_name ];
var val2=attributes[ attr_name ];
if(val1!==undefined &&
val2!==undefined &&
val1.length!==0 &&
val2.length!==0 &&
val1!==val2
){
match=false;
}}
}
return match;
};
VariationForm.prototype.toggleResetLink=function(on){
if(on){
if(this.$resetVariations.css('visibility')==='hidden'){
this.$resetVariations
.css('visibility', 'visible')
.hide()
.fadeIn();
}}else{
this.$resetVariations.css('visibility', 'hidden');
}};
VariationForm.prototype.showNoMatchingVariationsMsg=function (){
this.$form
.find('.single_variation')
.after('<div role="alert">' +
'<p class="wc-no-matching-variations woocommerce-info">' +
wc_add_to_cart_variation_params.i18n_no_matching_variations_text +
'</p>' +
'</div>'
)
.next('div')
.find('.wc-no-matching-variations')
.slideDown(200);
};
VariationForm.prototype.onResetKeyDown=function(event){
if(event.code==='Enter'||event.code==='Space'){
event.preventDefault();
event.data.variationForm.onReset(event);
}};
$.fn.wc_variation_form=function (){
new VariationForm(this);
return this;
};
$.fn.wc_set_content=function(content){
if(undefined===this.attr('data-o_content')){
this.attr('data-o_content', this.text());
}
this.text(content);
};
$.fn.wc_reset_content=function (){
if(undefined!==this.attr('data-o_content')){
this.text(this.attr('data-o_content'));
}};
$.fn.wc_set_variation_attr=function(attr, value){
if(undefined===this.attr('data-o_' + attr)){
this.attr('data-o_' + attr,
! this.attr(attr) ? '':this.attr(attr)
);
}
if(false===value){
this.removeAttr(attr);
}else{
this.attr(attr, value);
}};
$.fn.wc_reset_variation_attr=function(attr){
if(undefined!==this.attr('data-o_' + attr)){
this.attr(attr, this.attr('data-o_' + attr));
}};
$.fn.wc_maybe_trigger_slide_position_reset=function(variation){
var $form=$(this),
$product=$form.closest('.product'),
$product_gallery=$product.find('.images'),
reset_slide_position=false,
new_image_id =
variation&&variation.image_id ? variation.image_id:'';
if($form.attr('current-image')!==new_image_id){
reset_slide_position=true;
}
$form.attr('current-image', new_image_id);
if(reset_slide_position){
$product_gallery.trigger('woocommerce_gallery_reset_slide_position'
);
}};
$.fn.wc_variations_image_update=function(variation){
var $form=this,
$product=$form.closest('.product'),
$product_gallery=$product.find('.images'),
$gallery_nav=$product.find('.flex-control-nav'),
$gallery_img=$gallery_nav.find('li:eq(0) img'),
$product_img_wrap=$product_gallery
.find('.woocommerce-product-gallery__image, .woocommerce-product-gallery__image--placeholder'
)
.eq(0),
$product_img=$product_img_wrap.find('.wp-post-image'),
$product_link=$product_img_wrap.find('a').eq(0);
if(variation &&
variation.image &&
variation.image.src &&
variation.image.src.length > 1
){
var galleryHasImage =
$gallery_nav.find('li img[data-o_src="' +
variation.image.gallery_thumbnail_src +
'"]'
).length > 0;
if(galleryHasImage){
$form.wc_variations_image_reset();
}
var slideToImage=$gallery_nav.find('li img[src="' + variation.image.gallery_thumbnail_src + '"]'
);
if(slideToImage.length > 0){
slideToImage.trigger('flexslider-click');
$form.attr('current-image', variation.image_id);
window.setTimeout(function (){
$(window).trigger('resize');
$product_gallery.trigger('woocommerce_gallery_init_zoom');
}, 20);
return;
}
$product_img.wc_set_variation_attr('src', variation.image.src);
$product_img.wc_set_variation_attr('height',
variation.image.src_h
);
$product_img.wc_set_variation_attr('width',
variation.image.src_w
);
$product_img.wc_set_variation_attr('srcset',
variation.image.srcset
);
$product_img.wc_set_variation_attr('sizes',
variation.image.sizes
);
$product_img.wc_set_variation_attr('title',
variation.image.title
);
$product_img.wc_set_variation_attr('data-caption',
variation.image.caption
);
$product_img.wc_set_variation_attr('alt', variation.image.alt);
$product_img.wc_set_variation_attr('data-src',
variation.image.full_src
);
$product_img.wc_set_variation_attr('data-large_image',
variation.image.full_src
);
$product_img.wc_set_variation_attr('data-large_image_width',
variation.image.full_src_w
);
$product_img.wc_set_variation_attr('data-large_image_height',
variation.image.full_src_h
);
$product_img_wrap.wc_set_variation_attr('data-thumb',
variation.image.src
);
$gallery_img.wc_set_variation_attr('src',
variation.image.gallery_thumbnail_src
);
$product_link.wc_set_variation_attr('href',
variation.image.full_src
);
}else{
$form.wc_variations_image_reset();
}
window.setTimeout(function (){
$(window).trigger('resize');
$form.wc_maybe_trigger_slide_position_reset(variation);
$product_gallery.trigger('woocommerce_gallery_init_zoom');
}, 20);
};
$.fn.wc_variations_image_reset=function (){
var $form=this,
$product=$form.closest('.product'),
$product_gallery=$product.find('.images'),
$gallery_nav=$product.find('.flex-control-nav'),
$gallery_img=$gallery_nav.find('li:eq(0) img'),
$product_img_wrap=$product_gallery
.find('.woocommerce-product-gallery__image, .woocommerce-product-gallery__image--placeholder'
)
.eq(0),
$product_img=$product_img_wrap.find('.wp-post-image'),
$product_link=$product_img_wrap.find('a').eq(0);
$product_img.wc_reset_variation_attr('src');
$product_img.wc_reset_variation_attr('width');
$product_img.wc_reset_variation_attr('height');
$product_img.wc_reset_variation_attr('srcset');
$product_img.wc_reset_variation_attr('sizes');
$product_img.wc_reset_variation_attr('title');
$product_img.wc_reset_variation_attr('data-caption');
$product_img.wc_reset_variation_attr('alt');
$product_img.wc_reset_variation_attr('data-src');
$product_img.wc_reset_variation_attr('data-large_image');
$product_img.wc_reset_variation_attr('data-large_image_width');
$product_img.wc_reset_variation_attr('data-large_image_height');
$product_img_wrap.wc_reset_variation_attr('data-thumb');
$gallery_img.wc_reset_variation_attr('src');
$product_link.wc_reset_variation_attr('href');
};
$(function (){
if(typeof wc_add_to_cart_variation_params!=='undefined'){
$('.variations_form').each(function (){
$(this).wc_variation_form();
});
}});
var wc_variation_form_matcher={
find_matching_variations: function(product_variations, settings){
var matching=[];
for(var i=0; i < product_variations.length; i++){
var variation=product_variations[ i ];
if(wc_variation_form_matcher.variations_match(variation.attributes,
settings
)
){
matching.push(variation);
}}
return matching;
},
variations_match: function(attrs1, attrs2){
var match=true;
for(var attr_name in attrs1){
if(attrs1.hasOwnProperty(attr_name)){
var val1=attrs1[ attr_name ];
var val2=attrs2[ attr_name ];
if(val1!==undefined &&
val2!==undefined &&
val1.length!==0 &&
val2.length!==0 &&
val1!==val2
){
match=false;
}}
}
return match;
},
};
var wp_template=function(templateId){
var html=document.getElementById('tmpl-' + templateId).textContent;
var hard=false;
hard=hard||/<#\s?data\./.test(html);
hard=hard||/{{{?\s?data\.(?!variation\.).+}}}?/.test(html);
hard=hard||/{{{?\s?data\.variation\.[\w-]*[^\s}]/.test(html);
if(hard){
return wp.template(templateId);
}
return function template(data){
var variation=data.variation||{};
return html.replace(/({{{?)\s?data\.variation\.([\w-]*)\s?(}}}?)/g,
function(_, open, key, close){
if(open.length!==close.length){
return '';
}
var replacement=variation[ key ]||'';
if(open.length===2){
return window.escape(replacement);
}
return replacement;
}
);
};};
})(jQuery, window, document);