function TRP_Translator(){
this.is_editor=false;
var _this=this;
var observer=null;
var observerConfig={
attributes: true,
childList: true,
characterData: false,
subtree: true
};
var translate_numerals_opt=trp_data.trp_translate_numerals_opt;
var custom_ajax_url=trp_data.trp_custom_ajax_url;
var wp_ajax_url=trp_data.trp_wp_ajax_url;
var language_to_query;
this.except_characters=" \t\n\r  �.,/`~!@#$€£%^&*():;-_=+[]{}\\|?/<>1234567890'";
var trim_characters=" \t\n\r  �\x0A\x0B" + "\302" + "\240";
var already_detected=[];
var duplicate_detections_allowed=parseInt(trp_data.duplicate_detections_allowed)
this.ajax_get_translation=function(nodesInfo, string_originals, url, skip_machine_translation){
jQuery.ajax({
url: url,
type: 'post',
dataType: 'json',
data: {
action:'trp_get_translations_regular',
all_languages:'false',
security:trp_data['gettranslationsnonceregular'],
language:language_to_query,
original_language:original_language,
originals:JSON.stringify(string_originals),
skip_machine_translation:JSON.stringify(skip_machine_translation),
dynamic_strings:'true',
translate_numerals_opt:translate_numerals_opt
},
success: function(response){
if(response==='error'){
_this.ajax_get_translation(nodesInfo, string_originals, wp_ajax_url, skip_machine_translation);
console.log('Notice: TranslatePress trp-ajax request uses fall back to admin ajax.');
}else{
_this.update_strings(response, nodesInfo);
}},
error: function(errorThrown){
if(url==custom_ajax_url&&custom_ajax_url!=wp_ajax_url){
_this.ajax_get_translation(nodesInfo, string_originals, wp_ajax_url, skip_machine_translation);
console.log('Notice: TranslatePress trp-ajax request uses fall back to admin ajax.');
}else{
_this.update_strings(null, nodesInfo);
console.log('TranslatePress AJAX Request Error');
}}
});
};
this.decode_html=function(html){
var txt=document.createElement("textarea");
txt.innerHTML=html;
return txt.value;
};
this.update_strings=function(response, nodesInfo){
_this.pause_observer();
if(response!=null&&response.length > 0){
var newEntries=[];
for (var j=0 ; j < nodesInfo.length; j++){
var nodeInfo=nodesInfo[j];
var translation_found=false;
var initial_value=nodeInfo.original;
for(var i=0; i <  response.length; i++){
var response_string=response[i].translationsArray[language_to_query];
if(response[i].original.trim()==nodeInfo.original.trim()){
var entry=response[i]
entry.selector='data-trp-translate-id'
entry.attribute=''
newEntries.push(entry)
if(_this.is_editor){
var jquery_object;
var trp_translate_id='data-trp-translate-id'
var trp_node_group='data-trp-node-group'
if(nodeInfo.attribute){
jquery_object=jQuery(nodeInfo.node)
trp_translate_id=trp_translate_id + '-' + nodeInfo.attribute
trp_node_group=trp_node_group + '-' + nodeInfo.attribute
}else{
jquery_object=jQuery(nodeInfo.node).parent('translate-press');
}
jquery_object.attr(trp_translate_id, response[i].dbID);
jquery_object.attr(trp_node_group, response[i].group);
}
if(response_string.translated!=''&&language_to_query==current_language){
var text_to_set=_this.decode_html(initial_value.replace(initial_value.trim(), response_string.translated));
if(nodeInfo.attribute){
nodeInfo.node.setAttribute(nodeInfo.attribute, text_to_set)
if(nodeInfo.attribute=='src'){
nodeInfo.node.setAttribute('srcset', '')
nodeInfo.node.setAttribute('data-src', text_to_set)
}}else{
nodeInfo.node.textContent=text_to_set;
}
translation_found=true;
}
break;
}}
already_detected[ initial_value ]=(initial_value in already_detected) ? already_detected[ initial_value ] + 1:0
if(! translation_found){
if(nodeInfo.attribute){
if(nodeInfo.attribute!='src'){
nodeInfo.node.setAttribute(nodeInfo.attribute, initial_value)
}}else{
nodeInfo.node.textContent=initial_value;
}}
}
if(_this.is_editor){
window.parent.dispatchEvent(new Event('trp_iframe_page_updated') );
window.dispatchEvent(new Event('trp_iframe_page_updated') );
}}else{
for (var j=0 ; j < nodesInfo.length; j++){
if(nodesInfo[j].attribute){
if(nodesInfo[j].attribute!='src'){
nodesInfo[j].node.setAttribute(nodesInfo[j].attribute, nodesInfo[j].original)
}}else{
nodesInfo[j].node.textContent=nodesInfo[j].original;
}
already_detected[ nodesInfo[j].original ]=(nodesInfo[j].original in already_detected) ? already_detected[ nodesInfo[j].original ] + 1:0
}}
_this.resume_observer();
};
this.detect_new_strings_callback=function(mutations){
observer.disconnect()
_this.detect_new_strings(mutations);
_this.resume_observer();
}
this.detect_new_strings=function(mutations){
var string_originals=[];
var nodesInfo=[];
var skip_machine_translation=[];
var translateable;
mutations.forEach(function (mutation){
for (var i=0; i < mutation.addedNodes.length; i++){
var node=mutation.addedNodes[i]
if(_this.is_editor){
var anchor_tags=jQuery(node).find('a')
if(typeof anchor_tags.context!=='undefined')
anchor_tags.context.href=_this.update_query_string('trp-edit-translation', 'preview', anchor_tags.context.href);
}
if(_this.skip_string(node)){
continue;
}
translateable=_this.get_translateable_textcontent(node)
string_originals=string_originals.concat(translateable.string_originals);
nodesInfo=nodesInfo.concat(translateable.nodesInfo);
skip_machine_translation=skip_machine_translation.concat(translateable.skip_machine_translation);
translateable=_this.get_translateable_attributes(node)
string_originals=string_originals.concat(translateable.string_originals);
nodesInfo=nodesInfo.concat(translateable.nodesInfo);
skip_machine_translation=skip_machine_translation.concat(translateable.skip_machine_translation);
}
if(mutation.attributeName){
if(! _this.in_array(mutation.attributeName, trp_data.trp_attributes_accessors) ){
return
}
if(_this.skip_string_attribute(mutation.target, mutation.attributeName)||_this.skip_string(mutation.target)){
return
}
translateable=_this.get_translateable_attributes(mutation.target)
string_originals=string_originals.concat(translateable.string_originals);
nodesInfo=nodesInfo.concat(translateable.nodesInfo);
skip_machine_translation=skip_machine_translation.concat(translateable.skip_machine_translation);
}});
if(nodesInfo.length > 0){
var ajax_url_to_call=(_this.is_editor) ? wp_ajax_url:custom_ajax_url;
_this.ajax_get_translation(nodesInfo, string_originals, ajax_url_to_call, skip_machine_translation);
}};
this.skip_string=function(node){
var selectors=trp_data.trp_skip_selectors;
for (var i=0; i < selectors.length ; i++){
if(jQuery(node).closest(selectors[ i ]).length > 0){
return true;
}}
return false;
};
this.skip_string_from_auto_translation=function(node){
var selectors=trp_data.trp_no_auto_translation_selectors;
for (var i=0; i < selectors.length ; i++){
if(jQuery(node).closest(selectors[ i ]).length > 0){
return true;
}}
return false;
};
this.contains_substring_that_needs_skipped=function(string, attribute){
for (var attribute_to_skip in trp_data.skip_strings_from_dynamic_translation_for_substrings){
if(trp_data.skip_strings_from_dynamic_translation_for_substrings.hasOwnProperty(attribute_to_skip)&&attribute===attribute_to_skip){
for(var i=0 ; i < trp_data.skip_strings_from_dynamic_translation_for_substrings[attribute_to_skip].length; i++){
if(string.indexOf(trp_data.skip_strings_from_dynamic_translation_for_substrings[attribute_to_skip][i])!==-1){
return true
}}
}}
return false
};
this.skip_string_original=function(string, attribute){
return (
(already_detected[string] > duplicate_detections_allowed) ||
_this.in_array(string, trp_data.skip_strings_from_dynamic_translation) ||
_this.contains_substring_that_needs_skipped(string, attribute)
)
}
this.skip_string_attribute=function(node, attribute){
var selectors=trp_data.trp_base_selectors;
for (var i=0; i < selectors.length ; i++){
if(typeof jQuery(node).attr(selectors[ i ] + '-' + attribute)!=='undefined'){
return true;
}}
return false;
};
this.in_array=function (needle, array){
var i
var length=array.length
for(i=length - 1; i >=0; i--){
if(array[i]===needle){
return true
}}
return false
}
this.get_translateable_textcontent=function(node){
var string_originals=[];
var nodesInfo=[];
var skip_machine_translation=[]
if(node.textContent&&_this.trim(node.textContent.trim(), _this.except_characters)!=''){
var direct_string=get_string_from_node(node);
if(direct_string){
if(_this.trim(direct_string.textContent, _this.except_characters)!=''){
var extracted_original=_this.trim(direct_string.textContent, trim_characters);
if(! _this.skip_string_original(extracted_original, false)){
nodesInfo.push({node: node, original: extracted_original, attribute: ''});
string_originals.push(extracted_original)
if(_this.skip_string_from_auto_translation(node)){
skip_machine_translation.push(extracted_original)
}
direct_string.textContent='';
if(_this.is_editor){
jQuery(node).wrap('<translate-press></translate-press>');
}}
}}else{
var all_nodes=jQuery(node).find('*').addBack();
var all_strings=all_nodes.contents().filter(function(){
if(this.nodeType===3&&/\S/.test(this.nodeValue)){
if(! _this.skip_string(this)){
return this;
}}});
if(_this.is_editor){
all_strings.wrap('<translate-press></translate-press>');
}
var all_strings_length=all_strings.length;
for (var j=0; j < all_strings_length; j++){
if(_this.trim(all_strings[j].textContent, _this.except_characters)!=''){
if(! _this.skip_string_original(all_strings[j].textContent, false)){
nodesInfo.push({node: all_strings[j], original: all_strings[j].textContent, attribute: ''});
string_originals.push(all_strings[j].textContent)
if(_this.skip_string_from_auto_translation(all_strings[j])){
skip_machine_translation.push(all_strings[j].textContent)
}
if(trp_data ['showdynamiccontentbeforetranslation']==false){
all_strings[j].textContent='';
}}
}}
}}
return { 'string_originals': string_originals, 'nodesInfo': nodesInfo, 'skip_machine_translation': skip_machine_translation  };}
this.get_translateable_attributes=function(node){
var nodesInfo=[]
var string_originals=[]
var skip_attr_machine_translation=[ 'href', 'src' ]
var skip_machine_translation=[]
for (var trp_attribute_key in trp_data.trp_attributes_selectors){
if(trp_data.trp_attributes_selectors.hasOwnProperty(trp_attribute_key)){
var attribute_selector_item=trp_data.trp_attributes_selectors[trp_attribute_key]
if(typeof attribute_selector_item['selector']!=='undefined'){
var all_nodes=jQuery(node).find(attribute_selector_item.selector).addBack(attribute_selector_item.selector)
var all_nodes_length=all_nodes.length
for (var j=0; j < all_nodes_length; j++){
if(_this.skip_string(all_nodes[j])||_this.skip_string_attribute(all_nodes[j], attribute_selector_item.accessor) ){
continue;
}
var attribute_content=all_nodes[j].getAttribute(attribute_selector_item.accessor)
if(_this.skip_string_original(attribute_content, attribute_selector_item.accessor)){
continue;
}
if(attribute_content&&_this.trim(attribute_content.trim(), _this.except_characters)!=''){
nodesInfo.push({node: all_nodes[j], original: attribute_content, attribute: attribute_selector_item.accessor });
string_originals.push(attribute_content)
if(trp_data ['showdynamiccontentbeforetranslation']==false&&(attribute_selector_item.accessor!='src')&&(attribute_selector_item.accessor!='href') ){
all_nodes[j].setAttribute(attribute_selector_item.accessor, '');
}
if(_this.skip_string_from_auto_translation(all_nodes[j])){
skip_machine_translation.push(attribute_content)
}else{
for(var s=0; s < skip_attr_machine_translation.length; s++){
if(attribute_selector_item.accessor===skip_attr_machine_translation[ s ]){
skip_machine_translation.push(attribute_content)
break
}}
}}
}}
}}
return { 'string_originals': string_originals, 'nodesInfo': nodesInfo, 'skip_machine_translation': skip_machine_translation };}
function get_string_from_node(node){
if(node.nodeType===3&&/\S/.test(node.nodeValue)){
if(! _this.skip_string(node)){
return node;
}}
}
this.cleanup_gettext_wrapper=function(){
jQuery('trp-gettext').contents().unwrap();
};
this.update_query_string=function(key, value, url){
if(!url) return url;
if(url.startsWith('#')){
return url;
}
var re=new RegExp("([?&])" + key + "=.*?(&|#|$)(.*)", "gi"),
hash;
if(re.test(url)){
if(typeof value!=='undefined'&&value!==null)
return url.replace(re, '$1' + key + "=" + value + '$2$3');
else {
hash=url.split('#');
url=hash[0].replace(re, '$1$3').replace(/(&|\?)$/, '');
if(typeof hash[1]!=='undefined'&&hash[1]!==null)
url +='#' + hash[1];
return url;
}}else{
if(typeof value!=='undefined'&&value!==null){
var separator=url.indexOf('?')!==-1 ? '&':'?';
hash=url.split('#');
url=hash[0] + separator + key + '=' + value;
if(typeof hash[1]!=='undefined'&&hash[1]!==null)
url +='#' + hash[1];
return url;
}
else
return url;
}};
this.initialize=function(){
this.is_editor=(typeof window.parent.tpEditorApp!=='undefined')
if(this.is_editor){
trp_data['gettranslationsnonceregular']=window.parent.trp_dynamic_nonce;
}
current_language=trp_data.trp_current_language;
original_language=trp_data.trp_original_language;
language_to_query=trp_data.trp_language_to_query;
translate_numerals_opt=trp_data.trp_translate_numerals_opt;
if(typeof translate_numerals_opt!=="undefined"&&translate_numerals_opt!==''&&translate_numerals_opt==="yes"){
_this.except_characters=" \t\n\r  �.,/`~!@#$€£%^&*():;-_=+[]{}\\|?/<>'";
}
if(trp_data['showdynamiccontentbeforetranslation']===true){
observer=new MutationObserver(mutations=> {
setTimeout(()=> _this.detect_new_strings_callback(mutations), 0);
});
}else{
observer=observer=new MutationObserver(_this.detect_new_strings_callback)
}
_this.resume_observer();
jQuery(document).ajaxComplete(function(event, request, settings){
if(typeof window.parent.jQuery!=="undefined"&&window.parent.jQuery('#trp-preview-iframe').length!=0){
var settingsdata="" + settings.data;
if(typeof settings.data=='undefined'||jQuery.isEmptyObject(settings.data)||settingsdata.indexOf('action=trp_')===-1){
window.parent.dispatchEvent(new Event('trp_iframe_page_updated') );
}}
});
_this.cleanup_gettext_wrapper();
};
this.resume_observer=function(){
if(language_to_query===''){
return;
}
observer.observe(document.body, observerConfig);
};
this.pause_observer=function(){
if(language_to_query===''){
return;
}
var mutations=observer.takeRecords()
observer.disconnect()
if(mutations.length > 0){
_this.detect_new_strings(mutations)
}};
this.trim=function (str, charlist){
var whitespace=[
' ',
'\n',
'\r',
'\t',
'\f',
'\x0b',
'\xa0',
'\u2000',
'\u2001',
'\u2002',
'\u2003',
'\u2004',
'\u2005',
'\u2006',
'\u2007',
'\u2008',
'\u2009',
'\u200a',
'\u200b',
'\u2028',
'\u2029',
'\u3000'
].join('');
var l=0;
var i=0;
str +='';
if(charlist){
whitespace +=(charlist + '').replace(/([[\]().?/*{}+$^:])/g, '$1');
}
l=str.length;
for (i=0; i < l; i++){
if(whitespace.indexOf(str.charAt(i))===-1){
str=str.substring(i);
break;
}}
l=str.length;
for (i=l - 1; i >=0; i--){
if(whitespace.indexOf(str.charAt(i))===-1){
str=str.substring(0, i + 1);
break;
}}
return whitespace.indexOf(str.charAt(0))===-1 ? str:'';
};
_this.initialize();
}
var trpTranslator;
var current_language;
var original_language;
function trp_get_IE_version(){
var sAgent=window.navigator.userAgent;
var Idx=sAgent.indexOf("MSIE");
if(Idx > 0)
return parseInt(sAgent.substring(Idx+ 5, sAgent.indexOf(".", Idx)));
else if(!!navigator.userAgent.match(/Trident\/7\./))
return 11;
else
return 0;
}
function trp_allow_detect_dom_changes_to_run(){
var IE_version=trp_get_IE_version();
if(IE_version!=0&&IE_version <=11){
return false;
}
return true;
}
if(trp_allow_detect_dom_changes_to_run()){
trpTranslator=new TRP_Translator();
};
!function(e){"function"==typeof define&&define.amd?define([],e):"undefined"!=typeof module&&null!==module&&module.exports?module.exports=e:e()}(function(){var i=Object.assign||window.jQuery&&jQuery.extend,p=8,a=window.requestAnimationFrame||window.webkitRequestAnimationFrame||window.mozRequestAnimationFrame||window.oRequestAnimationFrame||window.msRequestAnimationFrame||function(e,t){return window.setTimeout(function(){e()},25)};!function(){if("function"==typeof window.CustomEvent)return;function e(e,t){t=t||{bubbles:!1,cancelable:!1,detail:void 0};var n=document.createEvent("CustomEvent");return n.initCustomEvent(e,t.bubbles,t.cancelable,t.detail),n}e.prototype=window.Event.prototype,window.CustomEvent=e}();var o={textarea:!0,input:!0,select:!0,button:!0},u={move:"mousemove",cancel:"mouseup dragstart",end:"mouseup"},r={move:"touchmove",cancel:"touchend",end:"touchend"},d=/\s+/,c={bubbles:!0,cancelable:!0},t="function"==typeof Symbol?Symbol("events"):{};function m(e){return e[t]||(e[t]={})}function v(e,t,n,o,i){t=t.split(d);var a,c=m(e),u=t.length;function r(e){n(e,o)}for(;u--;)(c[a=t[u]]||(c[a]=[])).push([n,r]),e.addEventListener(a,r)}function f(e,t,n,o){t=t.split(d);var i,a,c,u=m(e),r=t.length;if(u)for(;r--;)if(a=u[i=t[r]])for(c=a.length;c--;)a[c][0]===n&&(e.removeEventListener(i,a[c][1]),a.splice(c,1))}function g(e,t,n){var o=new CustomEvent(t,c);n&&i(o,n),e.dispatchEvent(o)}function n(e){var n=e,o=!1,i=!1;function t(e){o?(n(),a(t),o=!(i=!0)):i=!1}this.kick=function(e){o=!0,i||t()},this.end=function(e){var t=n;e&&(i?(n=o?function(){t(),e()}:e,o=!0):e())}}function h(){}function s(e){e.preventDefault()}function l(e,t){var n,o;if(e.identifiedTouch)return e.identifiedTouch(t);for(n=-1,o=e.length;++n<o;)if(e[n].identifier===t)return e[n]}function X(e,t){var n=l(e.changedTouches,t.identifier);if(n&&(n.pageX!==t.pageX||n.pageY!==t.pageY))return n}function Y(e,t){T(e,t,e,w)}function y(e,t){w()}function w(){f(document,u.move,Y),f(document,u.cancel,y)}function b(e){f(document,r.move,e.touchmove),f(document,r.cancel,e.touchend)}function T(e,t,n,o){var i,a,c,u,r,d,m,v,f,s=n.pageX-t.pageX,l=n.pageY-t.pageY;s*s+l*l<p*p||(a=t,c=n,u=s,r=l,d=o,m=(i=e).targetTouches,v=i.timeStamp-a.timeStamp,f={altKey:i.altKey,ctrlKey:i.ctrlKey,shiftKey:i.shiftKey,startX:a.pageX,startY:a.pageY,distX:u,distY:r,deltaX:u,deltaY:r,pageX:c.pageX,pageY:c.pageY,velocityX:u/v,velocityY:r/v,identifier:a.identifier,targetTouches:m,finger:m?m.length:1,enableMove:function(){this.moveEnabled=!0,this.enableMove=h,i.preventDefault()}},g(a.target,"movestart",f),d(a))}function E(e,t){var n=t.timer;t.touch=e,t.timeStamp=e.timeStamp,n.kick()}function S(e,t){var n=t.target,o=t.event,i=t.timer;f(document,u.move,E),f(document,u.end,S),K(n,o,i,function(){setTimeout(function(){f(n,"click",s)},0)})}function k(e,t){var n,o=t.target,i=t.event,a=t.timer;l(e.changedTouches,i.identifier)&&(n=t,f(document,r.move,n.activeTouchmove),f(document,r.end,n.activeTouchend),K(o,i,a))}function K(e,t,n,o){n.end(function(){return g(e,"moveend",t),o&&o()})}if(v(document,"mousedown",function(e){var t;1!==(t=e).which||t.ctrlKey||t.altKey||o[e.target.tagName.toLowerCase()]||(v(document,u.move,Y,e),v(document,u.cancel,y,e))}),v(document,"touchstart",function(e){if(!o[e.target.tagName.toLowerCase()]){var t=e.changedTouches[0],n={target:t.target,pageX:t.pageX,pageY:t.pageY,identifier:t.identifier,touchmove:function(e,t){var n,o,i;(i=X(n=e,o=t))&&T(n,o,i,b)},touchend:function(e,t){var n;n=t,l(e.changedTouches,n.identifier)&&b(n)}};v(document,r.move,n.touchmove,n),v(document,r.cancel,n.touchend,n)}}),v(document,"movestart",function(e){if(!e.defaultPrevented&&e.moveEnabled){var a={startX:e.startX,startY:e.startY,pageX:e.pageX,pageY:e.pageY,distX:e.distX,distY:e.distY,deltaX:e.deltaX,deltaY:e.deltaY,velocityX:e.velocityX,velocityY:e.velocityY,identifier:e.identifier,targetTouches:e.targetTouches,finger:e.finger},c={target:e.target,event:a,timer:new n(function(e){var t,n,o,i;t=a,n=c.touch,o=c.timeStamp,i=o-t.timeStamp,t.distX=n.pageX-t.startX,t.distY=n.pageY-t.startY,t.deltaX=n.pageX-t.pageX,t.deltaY=n.pageY-t.pageY,t.velocityX=.3*t.velocityX+.7*t.deltaX/i,t.velocityY=.3*t.velocityY+.7*t.deltaY/i,t.pageX=n.pageX,t.pageY=n.pageY,g(c.target,"move",a)}),touch:void 0,timeStamp:e.timeStamp};void 0===e.identifier?(v(e.target,"click",s),v(document,u.move,E,c),v(document,u.end,S,c)):(c.activeTouchmove=function(e,t){var n,o,i,a,c;n=e,i=(o=t).event,a=o.timer,(c=X(n,i))&&(n.preventDefault(),i.targetTouches=n.targetTouches,o.touch=c,o.timeStamp=n.timeStamp,a.kick())},c.activeTouchend=function(e,t){k(e,t)},v(document,r.move,c.activeTouchmove,c),v(document,r.end,c.activeTouchend,c))}}),window.jQuery){var j="startX startY pageX pageY distX distY deltaX deltaY velocityX velocityY".split(" ");jQuery.event.special.movestart={setup:function(){return v(this,"movestart",e),!1},teardown:function(){return f(this,"movestart",e),!1},add:q},jQuery.event.special.move={setup:function(){return v(this,"movestart",C),!1},teardown:function(){return f(this,"movestart",C),!1},add:q},jQuery.event.special.moveend={setup:function(){return v(this,"movestart",Q),!1},teardown:function(){return f(this,"movestart",Q),!1},add:q}}function e(e){e.enableMove()}function C(e){e.enableMove()}function Q(e){e.enableMove()}function q(e){var o=e.handler;e.handler=function(e){for(var t,n=j.length;n--;)e[t=j[n]]=e.originalEvent[t];o.apply(this,arguments)}}});
!function(g){g.fn.twentytwenty=function(m){m=g.extend({default_offset_pct:.5,orientation:"horizontal",before_label:"Before",after_label:"After",no_overlay:!1,move_slider_on_hover:!1,move_with_handle_only:!0,click_to_move:!1},m);return this.each(function(){var e=m.default_offset_pct,s=g(this),r=m.orientation,t="vertical"===r?"down":"left",n="vertical"===r?"up":"right";s.wrap("<div class='twentytwenty-wrapper twentytwenty-"+r+"'></div>"),m.no_overlay||s.append("<div class='twentytwenty-overlay'></div>");var c=s.find("img:first"),d=s.find("img:last");s.append("<div class='twentytwenty-handle'></div>");var l=s.find(".twentytwenty-handle");l.append("<span class='twentytwenty-"+t+"-arrow'></span>"),l.append("<span class='twentytwenty-"+n+"-arrow'></span>"),s.addClass("twentytwenty-container"),c.addClass("twentytwenty-before"),d.addClass("twentytwenty-after");var i=s.find(".twentytwenty-overlay");i.append("<div class='twentytwenty-before-label'></div>"),i.append("<div class='twentytwenty-after-label'></div>");var a=function(t){var e,n,i,a,o=(e=t,n=c.width(),i=c.height(),{w:n+"px",h:i+"px",cw:e*n+"px",ch:e*i+"px"});l.css("vertical"===r?"top":"left","vertical"===r?o.ch:o.cw),a=o,"vertical"===r?(c.css("clip","rect(0,"+a.w+","+a.ch+",0)"),d.css("clip","rect("+a.ch+","+a.w+","+a.h+",0)")):(c.css("clip","rect(0,"+a.cw+","+a.h+",0)"),d.css("clip","rect(0,"+a.w+","+a.h+","+a.cw+")")),s.css("height",a.h)},o=function(t,e){var n,i,a;return n="vertical"===r?(e-v)/p:(t-w)/f,i=0,a=1,Math.max(i,Math.min(a,n))};g(window).on("resize.twentytwenty",function(t){a(e)});var w=0,v=0,f=0,p=0,y=function(t){(t.distX>t.distY&&t.distX<-t.distY||t.distX<t.distY&&t.distX>-t.distY)&&"vertical"!==r?t.preventDefault():(t.distX<t.distY&&t.distX<-t.distY||t.distX>t.distY&&t.distX>-t.distY)&&"vertical"===r&&t.preventDefault(),s.addClass("active"),w=s.offset().left,v=s.offset().top,f=c.width(),p=c.height()},h=function(t){s.hasClass("active")&&(e=o(t.pageX,t.pageY),a(e))},u=function(){s.removeClass("active")},_=m.move_with_handle_only?l:s;_.on("movestart",y),_.on("move",h),_.on("moveend",u),m.move_slider_on_hover&&(s.on("mouseenter",y),s.on("mousemove",h),s.on("mouseleave",u)),l.on("touchmove",function(t){t.preventDefault()}),s.find("img").on("mousedown",function(t){t.preventDefault()}),m.click_to_move&&s.on("click",function(t){w=s.offset().left,v=s.offset().top,f=c.width(),p=c.height(),e=o(t.pageX,t.pageY),a(e)}),g(window).trigger("resize.twentytwenty")})}}(jQuery);