// source --> https://redpenguin.it/wp-includes/js/jquery/jquery.min.js?ver=3.7.1 /*! jQuery v3.7.1 | (c) OpenJS Foundation and other contributors | jquery.org/license */ !function(e,t){"use strict";"object"==typeof module&&"object"==typeof module.exports?module.exports=e.document?t(e,!0):function(e){if(!e.document)throw new Error("jQuery requires a window with a document");return t(e)}:t(e)}("undefined"!=typeof window?window:this,function(ie,e){"use strict";var oe=[],r=Object.getPrototypeOf,ae=oe.slice,g=oe.flat?function(e){return oe.flat.call(e)}:function(e){return oe.concat.apply([],e)},s=oe.push,se=oe.indexOf,n={},i=n.toString,ue=n.hasOwnProperty,o=ue.toString,a=o.call(Object),le={},v=function(e){return"function"==typeof e&&"number"!=typeof e.nodeType&&"function"!=typeof e.item},y=function(e){return null!=e&&e===e.window},C=ie.document,u={type:!0,src:!0,nonce:!0,noModule:!0};function m(e,t,n){var r,i,o=(n=n||C).createElement("script");if(o.text=e,t)for(r in u)(i=t[r]||t.getAttribute&&t.getAttribute(r))&&o.setAttribute(r,i);n.head.appendChild(o).parentNode.removeChild(o)}function x(e){return null==e?e+"":"object"==typeof e||"function"==typeof e?n[i.call(e)]||"object":typeof e}var t="3.7.1",l=/HTML$/i,ce=function(e,t){return new ce.fn.init(e,t)};function c(e){var t=!!e&&"length"in e&&e.length,n=x(e);return!v(e)&&!y(e)&&("array"===n||0===t||"number"==typeof t&&0+~]|"+ge+")"+ge+"*"),x=new RegExp(ge+"|>"),j=new RegExp(g),A=new RegExp("^"+t+"$"),D={ID:new RegExp("^#("+t+")"),CLASS:new RegExp("^\\.("+t+")"),TAG:new RegExp("^("+t+"|[*])"),ATTR:new RegExp("^"+p),PSEUDO:new RegExp("^"+g),CHILD:new RegExp("^:(only|first|last|nth|nth-last)-(child|of-type)(?:\\("+ge+"*(even|odd|(([+-]|)(\\d*)n|)"+ge+"*(?:([+-]|)"+ge+"*(\\d+)|))"+ge+"*\\)|)","i"),bool:new RegExp("^(?:"+f+")$","i"),needsContext:new RegExp("^"+ge+"*[>+~]|:(even|odd|eq|gt|lt|nth|first|last)(?:\\("+ge+"*((?:-\\d)?\\d*)"+ge+"*\\)|)(?=[^-]|$)","i")},N=/^(?:input|select|textarea|button)$/i,q=/^h\d$/i,L=/^(?:#([\w-]+)|(\w+)|\.([\w-]+))$/,H=/[+~]/,O=new RegExp("\\\\[\\da-fA-F]{1,6}"+ge+"?|\\\\([^\\r\\n\\f])","g"),P=function(e,t){var n="0x"+e.slice(1)-65536;return t||(n<0?String.fromCharCode(n+65536):String.fromCharCode(n>>10|55296,1023&n|56320))},M=function(){V()},R=J(function(e){return!0===e.disabled&&fe(e,"fieldset")},{dir:"parentNode",next:"legend"});try{k.apply(oe=ae.call(ye.childNodes),ye.childNodes),oe[ye.childNodes.length].nodeType}catch(e){k={apply:function(e,t){me.apply(e,ae.call(t))},call:function(e){me.apply(e,ae.call(arguments,1))}}}function I(t,e,n,r){var i,o,a,s,u,l,c,f=e&&e.ownerDocument,p=e?e.nodeType:9;if(n=n||[],"string"!=typeof t||!t||1!==p&&9!==p&&11!==p)return n;if(!r&&(V(e),e=e||T,C)){if(11!==p&&(u=L.exec(t)))if(i=u[1]){if(9===p){if(!(a=e.getElementById(i)))return n;if(a.id===i)return k.call(n,a),n}else if(f&&(a=f.getElementById(i))&&I.contains(e,a)&&a.id===i)return k.call(n,a),n}else{if(u[2])return k.apply(n,e.getElementsByTagName(t)),n;if((i=u[3])&&e.getElementsByClassName)return k.apply(n,e.getElementsByClassName(i)),n}if(!(h[t+" "]||d&&d.test(t))){if(c=t,f=e,1===p&&(x.test(t)||m.test(t))){(f=H.test(t)&&U(e.parentNode)||e)==e&&le.scope||((s=e.getAttribute("id"))?s=ce.escapeSelector(s):e.setAttribute("id",s=S)),o=(l=Y(t)).length;while(o--)l[o]=(s?"#"+s:":scope")+" "+Q(l[o]);c=l.join(",")}try{return k.apply(n,f.querySelectorAll(c)),n}catch(e){h(t,!0)}finally{s===S&&e.removeAttribute("id")}}}return re(t.replace(ve,"$1"),e,n,r)}function W(){var r=[];return function e(t,n){return r.push(t+" ")>b.cacheLength&&delete e[r.shift()],e[t+" "]=n}}function F(e){return e[S]=!0,e}function $(e){var t=T.createElement("fieldset");try{return!!e(t)}catch(e){return!1}finally{t.parentNode&&t.parentNode.removeChild(t),t=null}}function B(t){return function(e){return fe(e,"input")&&e.type===t}}function _(t){return function(e){return(fe(e,"input")||fe(e,"button"))&&e.type===t}}function z(t){return function(e){return"form"in e?e.parentNode&&!1===e.disabled?"label"in e?"label"in e.parentNode?e.parentNode.disabled===t:e.disabled===t:e.isDisabled===t||e.isDisabled!==!t&&R(e)===t:e.disabled===t:"label"in e&&e.disabled===t}}function X(a){return F(function(o){return o=+o,F(function(e,t){var n,r=a([],e.length,o),i=r.length;while(i--)e[n=r[i]]&&(e[n]=!(t[n]=e[n]))})})}function U(e){return e&&"undefined"!=typeof e.getElementsByTagName&&e}function V(e){var t,n=e?e.ownerDocument||e:ye;return n!=T&&9===n.nodeType&&n.documentElement&&(r=(T=n).documentElement,C=!ce.isXMLDoc(T),i=r.matches||r.webkitMatchesSelector||r.msMatchesSelector,r.msMatchesSelector&&ye!=T&&(t=T.defaultView)&&t.top!==t&&t.addEventListener("unload",M),le.getById=$(function(e){return r.appendChild(e).id=ce.expando,!T.getElementsByName||!T.getElementsByName(ce.expando).length}),le.disconnectedMatch=$(function(e){return i.call(e,"*")}),le.scope=$(function(){return T.querySelectorAll(":scope")}),le.cssHas=$(function(){try{return T.querySelector(":has(*,:jqfake)"),!1}catch(e){return!0}}),le.getById?(b.filter.ID=function(e){var t=e.replace(O,P);return function(e){return e.getAttribute("id")===t}},b.find.ID=function(e,t){if("undefined"!=typeof t.getElementById&&C){var n=t.getElementById(e);return n?[n]:[]}}):(b.filter.ID=function(e){var n=e.replace(O,P);return function(e){var t="undefined"!=typeof e.getAttributeNode&&e.getAttributeNode("id");return t&&t.value===n}},b.find.ID=function(e,t){if("undefined"!=typeof t.getElementById&&C){var n,r,i,o=t.getElementById(e);if(o){if((n=o.getAttributeNode("id"))&&n.value===e)return[o];i=t.getElementsByName(e),r=0;while(o=i[r++])if((n=o.getAttributeNode("id"))&&n.value===e)return[o]}return[]}}),b.find.TAG=function(e,t){return"undefined"!=typeof t.getElementsByTagName?t.getElementsByTagName(e):t.querySelectorAll(e)},b.find.CLASS=function(e,t){if("undefined"!=typeof t.getElementsByClassName&&C)return t.getElementsByClassName(e)},d=[],$(function(e){var t;r.appendChild(e).innerHTML="",e.querySelectorAll("[selected]").length||d.push("\\["+ge+"*(?:value|"+f+")"),e.querySelectorAll("[id~="+S+"-]").length||d.push("~="),e.querySelectorAll("a#"+S+"+*").length||d.push(".#.+[+~]"),e.querySelectorAll(":checked").length||d.push(":checked"),(t=T.createElement("input")).setAttribute("type","hidden"),e.appendChild(t).setAttribute("name","D"),r.appendChild(e).disabled=!0,2!==e.querySelectorAll(":disabled").length&&d.push(":enabled",":disabled"),(t=T.createElement("input")).setAttribute("name",""),e.appendChild(t),e.querySelectorAll("[name='']").length||d.push("\\["+ge+"*name"+ge+"*="+ge+"*(?:''|\"\")")}),le.cssHas||d.push(":has"),d=d.length&&new RegExp(d.join("|")),l=function(e,t){if(e===t)return a=!0,0;var n=!e.compareDocumentPosition-!t.compareDocumentPosition;return n||(1&(n=(e.ownerDocument||e)==(t.ownerDocument||t)?e.compareDocumentPosition(t):1)||!le.sortDetached&&t.compareDocumentPosition(e)===n?e===T||e.ownerDocument==ye&&I.contains(ye,e)?-1:t===T||t.ownerDocument==ye&&I.contains(ye,t)?1:o?se.call(o,e)-se.call(o,t):0:4&n?-1:1)}),T}for(e in I.matches=function(e,t){return I(e,null,null,t)},I.matchesSelector=function(e,t){if(V(e),C&&!h[t+" "]&&(!d||!d.test(t)))try{var n=i.call(e,t);if(n||le.disconnectedMatch||e.document&&11!==e.document.nodeType)return n}catch(e){h(t,!0)}return 0":{dir:"parentNode",first:!0}," ":{dir:"parentNode"},"+":{dir:"previousSibling",first:!0},"~":{dir:"previousSibling"}},preFilter:{ATTR:function(e){return e[1]=e[1].replace(O,P),e[3]=(e[3]||e[4]||e[5]||"").replace(O,P),"~="===e[2]&&(e[3]=" "+e[3]+" "),e.slice(0,4)},CHILD:function(e){return e[1]=e[1].toLowerCase(),"nth"===e[1].slice(0,3)?(e[3]||I.error(e[0]),e[4]=+(e[4]?e[5]+(e[6]||1):2*("even"===e[3]||"odd"===e[3])),e[5]=+(e[7]+e[8]||"odd"===e[3])):e[3]&&I.error(e[0]),e},PSEUDO:function(e){var t,n=!e[6]&&e[2];return D.CHILD.test(e[0])?null:(e[3]?e[2]=e[4]||e[5]||"":n&&j.test(n)&&(t=Y(n,!0))&&(t=n.indexOf(")",n.length-t)-n.length)&&(e[0]=e[0].slice(0,t),e[2]=n.slice(0,t)),e.slice(0,3))}},filter:{TAG:function(e){var t=e.replace(O,P).toLowerCase();return"*"===e?function(){return!0}:function(e){return fe(e,t)}},CLASS:function(e){var t=s[e+" "];return t||(t=new RegExp("(^|"+ge+")"+e+"("+ge+"|$)"))&&s(e,function(e){return t.test("string"==typeof e.className&&e.className||"undefined"!=typeof e.getAttribute&&e.getAttribute("class")||"")})},ATTR:function(n,r,i){return function(e){var t=I.attr(e,n);return null==t?"!="===r:!r||(t+="","="===r?t===i:"!="===r?t!==i:"^="===r?i&&0===t.indexOf(i):"*="===r?i&&-1:\x20\t\r\n\f]*)[\x20\t\r\n\f]*\/?>(?:<\/\1>|)$/i;function T(e,n,r){return v(n)?ce.grep(e,function(e,t){return!!n.call(e,t,e)!==r}):n.nodeType?ce.grep(e,function(e){return e===n!==r}):"string"!=typeof n?ce.grep(e,function(e){return-1)[^>]*|#([\w-]+))$/;(ce.fn.init=function(e,t,n){var r,i;if(!e)return this;if(n=n||k,"string"==typeof e){if(!(r="<"===e[0]&&">"===e[e.length-1]&&3<=e.length?[null,e,null]:S.exec(e))||!r[1]&&t)return!t||t.jquery?(t||n).find(e):this.constructor(t).find(e);if(r[1]){if(t=t instanceof ce?t[0]:t,ce.merge(this,ce.parseHTML(r[1],t&&t.nodeType?t.ownerDocument||t:C,!0)),w.test(r[1])&&ce.isPlainObject(t))for(r in t)v(this[r])?this[r](t[r]):this.attr(r,t[r]);return this}return(i=C.getElementById(r[2]))&&(this[0]=i,this.length=1),this}return e.nodeType?(this[0]=e,this.length=1,this):v(e)?void 0!==n.ready?n.ready(e):e(ce):ce.makeArray(e,this)}).prototype=ce.fn,k=ce(C);var E=/^(?:parents|prev(?:Until|All))/,j={children:!0,contents:!0,next:!0,prev:!0};function A(e,t){while((e=e[t])&&1!==e.nodeType);return e}ce.fn.extend({has:function(e){var t=ce(e,this),n=t.length;return this.filter(function(){for(var e=0;e\x20\t\r\n\f]*)/i,Ce=/^$|^module$|\/(?:java|ecma)script/i;xe=C.createDocumentFragment().appendChild(C.createElement("div")),(be=C.createElement("input")).setAttribute("type","radio"),be.setAttribute("checked","checked"),be.setAttribute("name","t"),xe.appendChild(be),le.checkClone=xe.cloneNode(!0).cloneNode(!0).lastChild.checked,xe.innerHTML="",le.noCloneChecked=!!xe.cloneNode(!0).lastChild.defaultValue,xe.innerHTML="",le.option=!!xe.lastChild;var ke={thead:[1,"","
"],col:[2,"","
"],tr:[2,"","
"],td:[3,"","
"],_default:[0,"",""]};function Se(e,t){var n;return n="undefined"!=typeof e.getElementsByTagName?e.getElementsByTagName(t||"*"):"undefined"!=typeof e.querySelectorAll?e.querySelectorAll(t||"*"):[],void 0===t||t&&fe(e,t)?ce.merge([e],n):n}function Ee(e,t){for(var n=0,r=e.length;n",""]);var je=/<|&#?\w+;/;function Ae(e,t,n,r,i){for(var o,a,s,u,l,c,f=t.createDocumentFragment(),p=[],d=0,h=e.length;d\s*$/g;function Re(e,t){return fe(e,"table")&&fe(11!==t.nodeType?t:t.firstChild,"tr")&&ce(e).children("tbody")[0]||e}function Ie(e){return e.type=(null!==e.getAttribute("type"))+"/"+e.type,e}function We(e){return"true/"===(e.type||"").slice(0,5)?e.type=e.type.slice(5):e.removeAttribute("type"),e}function Fe(e,t){var n,r,i,o,a,s;if(1===t.nodeType){if(_.hasData(e)&&(s=_.get(e).events))for(i in _.remove(t,"handle events"),s)for(n=0,r=s[i].length;n").attr(n.scriptAttrs||{}).prop({charset:n.scriptCharset,src:n.url}).on("load error",i=function(e){r.remove(),i=null,e&&t("error"===e.type?404:200,e.type)}),C.head.appendChild(r[0])},abort:function(){i&&i()}}});var Jt,Kt=[],Zt=/(=)\?(?=&|$)|\?\?/;ce.ajaxSetup({jsonp:"callback",jsonpCallback:function(){var e=Kt.pop()||ce.expando+"_"+jt.guid++;return this[e]=!0,e}}),ce.ajaxPrefilter("json jsonp",function(e,t,n){var r,i,o,a=!1!==e.jsonp&&(Zt.test(e.url)?"url":"string"==typeof e.data&&0===(e.contentType||"").indexOf("application/x-www-form-urlencoded")&&Zt.test(e.data)&&"data");if(a||"jsonp"===e.dataTypes[0])return r=e.jsonpCallback=v(e.jsonpCallback)?e.jsonpCallback():e.jsonpCallback,a?e[a]=e[a].replace(Zt,"$1"+r):!1!==e.jsonp&&(e.url+=(At.test(e.url)?"&":"?")+e.jsonp+"="+r),e.converters["script json"]=function(){return o||ce.error(r+" was not called"),o[0]},e.dataTypes[0]="json",i=ie[r],ie[r]=function(){o=arguments},n.always(function(){void 0===i?ce(ie).removeProp(r):ie[r]=i,e[r]&&(e.jsonpCallback=t.jsonpCallback,Kt.push(r)),o&&v(i)&&i(o[0]),o=i=void 0}),"script"}),le.createHTMLDocument=((Jt=C.implementation.createHTMLDocument("").body).innerHTML="
",2===Jt.childNodes.length),ce.parseHTML=function(e,t,n){return"string"!=typeof e?[]:("boolean"==typeof t&&(n=t,t=!1),t||(le.createHTMLDocument?((r=(t=C.implementation.createHTMLDocument("")).createElement("base")).href=C.location.href,t.head.appendChild(r)):t=C),o=!n&&[],(i=w.exec(e))?[t.createElement(i[1])]:(i=Ae([e],t,o),o&&o.length&&ce(o).remove(),ce.merge([],i.childNodes)));var r,i,o},ce.fn.load=function(e,t,n){var r,i,o,a=this,s=e.indexOf(" ");return-1").append(ce.parseHTML(e)).find(r):e)}).always(n&&function(e,t){a.each(function(){n.apply(this,o||[e.responseText,t,e])})}),this},ce.expr.pseudos.animated=function(t){return ce.grep(ce.timers,function(e){return t===e.elem}).length},ce.offset={setOffset:function(e,t,n){var r,i,o,a,s,u,l=ce.css(e,"position"),c=ce(e),f={};"static"===l&&(e.style.position="relative"),s=c.offset(),o=ce.css(e,"top"),u=ce.css(e,"left"),("absolute"===l||"fixed"===l)&&-1<(o+u).indexOf("auto")?(a=(r=c.position()).top,i=r.left):(a=parseFloat(o)||0,i=parseFloat(u)||0),v(t)&&(t=t.call(e,n,ce.extend({},s))),null!=t.top&&(f.top=t.top-s.top+a),null!=t.left&&(f.left=t.left-s.left+i),"using"in t?t.using.call(e,f):c.css(f)}},ce.fn.extend({offset:function(t){if(arguments.length)return void 0===t?this:this.each(function(e){ce.offset.setOffset(this,t,e)});var e,n,r=this[0];return r?r.getClientRects().length?(e=r.getBoundingClientRect(),n=r.ownerDocument.defaultView,{top:e.top+n.pageYOffset,left:e.left+n.pageXOffset}):{top:0,left:0}:void 0},position:function(){if(this[0]){var e,t,n,r=this[0],i={top:0,left:0};if("fixed"===ce.css(r,"position"))t=r.getBoundingClientRect();else{t=this.offset(),n=r.ownerDocument,e=r.offsetParent||n.documentElement;while(e&&(e===n.body||e===n.documentElement)&&"static"===ce.css(e,"position"))e=e.parentNode;e&&e!==r&&1===e.nodeType&&((i=ce(e).offset()).top+=ce.css(e,"borderTopWidth",!0),i.left+=ce.css(e,"borderLeftWidth",!0))}return{top:t.top-i.top-ce.css(r,"marginTop",!0),left:t.left-i.left-ce.css(r,"marginLeft",!0)}}},offsetParent:function(){return this.map(function(){var e=this.offsetParent;while(e&&"static"===ce.css(e,"position"))e=e.offsetParent;return e||J})}}),ce.each({scrollLeft:"pageXOffset",scrollTop:"pageYOffset"},function(t,i){var o="pageYOffset"===i;ce.fn[t]=function(e){return M(this,function(e,t,n){var r;if(y(e)?r=e:9===e.nodeType&&(r=e.defaultView),void 0===n)return r?r[i]:e[t];r?r.scrollTo(o?r.pageXOffset:n,o?n:r.pageYOffset):e[t]=n},t,e,arguments.length)}}),ce.each(["top","left"],function(e,n){ce.cssHooks[n]=Ye(le.pixelPosition,function(e,t){if(t)return t=Ge(e,n),_e.test(t)?ce(e).position()[n]+"px":t})}),ce.each({Height:"height",Width:"width"},function(a,s){ce.each({padding:"inner"+a,content:s,"":"outer"+a},function(r,o){ce.fn[o]=function(e,t){var n=arguments.length&&(r||"boolean"!=typeof e),i=r||(!0===e||!0===t?"margin":"border");return M(this,function(e,t,n){var r;return y(e)?0===o.indexOf("outer")?e["inner"+a]:e.document.documentElement["client"+a]:9===e.nodeType?(r=e.documentElement,Math.max(e.body["scroll"+a],r["scroll"+a],e.body["offset"+a],r["offset"+a],r["client"+a])):void 0===n?ce.css(e,t,i):ce.style(e,t,n,i)},s,n?e:void 0,n)}})}),ce.each(["ajaxStart","ajaxStop","ajaxComplete","ajaxError","ajaxSuccess","ajaxSend"],function(e,t){ce.fn[t]=function(e){return this.on(t,e)}}),ce.fn.extend({bind:function(e,t,n){return this.on(e,null,t,n)},unbind:function(e,t){return this.off(e,null,t)},delegate:function(e,t,n,r){return this.on(t,e,n,r)},undelegate:function(e,t,n){return 1===arguments.length?this.off(e,"**"):this.off(t,e||"**",n)},hover:function(e,t){return this.on("mouseenter",e).on("mouseleave",t||e)}}),ce.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(e,n){ce.fn[n]=function(e,t){return 0 https://redpenguin.it/wp-includes/js/jquery/jquery-migrate.min.js?ver=3.4.1 /*! jQuery Migrate v3.4.1 | (c) OpenJS Foundation and other contributors | jquery.org/license */ "undefined"==typeof jQuery.migrateMute&&(jQuery.migrateMute=!0),function(t){"use strict";"function"==typeof define&&define.amd?define(["jquery"],function(e){return t(e,window)}):"object"==typeof module&&module.exports?module.exports=t(require("jquery"),window):t(jQuery,window)}(function(s,n){"use strict";function e(e){return 0<=function(e,t){for(var r=/^(\d+)\.(\d+)\.(\d+)/,n=r.exec(e)||[],o=r.exec(t)||[],a=1;a<=3;a++){if(+o[a]<+n[a])return 1;if(+n[a]<+o[a])return-1}return 0}(s.fn.jquery,e)}s.migrateVersion="3.4.1";var t=Object.create(null);s.migrateDisablePatches=function(){for(var e=0;e\x20\t\r\n\f]*)[^>]*)\/>/gi;s.UNSAFE_restoreLegacyHtmlPrefilter=function(){s.migrateEnablePatches("self-closed-tags")},i(s,"htmlPrefilter",function(e){var t,r;return(r=(t=e).replace(F,"<$1>"))!==t&&T(t)!==T(r)&&u("self-closed-tags","HTML tags must be properly nested and closed: "+t),e.replace(F,"<$1>")},"self-closed-tags"),s.migrateDisablePatches("self-closed-tags");var D,W,_,I=s.fn.offset;return i(s.fn,"offset",function(){var e=this[0];return!e||e.nodeType&&e.getBoundingClientRect?I.apply(this,arguments):(u("offset-valid-elem","jQuery.fn.offset() requires a valid DOM element"),arguments.length?this:void 0)},"offset-valid-elem"),s.ajax&&(D=s.param,i(s,"param",function(e,t){var r=s.ajaxSettings&&s.ajaxSettings.traditional;return void 0===t&&r&&(u("param-ajax-traditional","jQuery.param() no longer uses jQuery.ajaxSettings.traditional"),t=r),D.call(this,e,t)},"param-ajax-traditional")),c(s.fn,"andSelf",s.fn.addBack,"andSelf","jQuery.fn.andSelf() is deprecated and removed, use jQuery.fn.addBack()"),s.Deferred&&(W=s.Deferred,_=[["resolve","done",s.Callbacks("once memory"),s.Callbacks("once memory"),"resolved"],["reject","fail",s.Callbacks("once memory"),s.Callbacks("once memory"),"rejected"],["notify","progress",s.Callbacks("memory"),s.Callbacks("memory")]],i(s,"Deferred",function(e){var a=W(),i=a.promise();function t(){var o=arguments;return s.Deferred(function(n){s.each(_,function(e,t){var r="function"==typeof o[e]&&o[e];a[t[1]](function(){var e=r&&r.apply(this,arguments);e&&"function"==typeof e.promise?e.promise().done(n.resolve).fail(n.reject).progress(n.notify):n[t[0]+"With"](this===i?n.promise():this,r?[e]:arguments)})}),o=null}).promise()}return c(a,"pipe",t,"deferred-pipe","deferred.pipe() is deprecated"),c(i,"pipe",t,"deferred-pipe","deferred.pipe() is deprecated"),e&&e.call(a,a),a},"deferred-pipe"),s.Deferred.exceptionHook=W.exceptionHook),s}); // source --> https://redpenguin.it/wp-content/plugins/bt_cost_calculator/jquery.dd.js?ver=6.4.4 // MSDropDown - jquery.dd.js // author: Marghoob Suleman - http://www.marghoobsuleman.com/ // Date: 10 Nov, 2012 // Version: 3.2 // Revision: 21 // web: www.marghoobsuleman.com /* // msDropDown is free jQuery Plugin: you can redistribute it and/or modify // it under the terms of the either the MIT License or the Gnu General Public License (GPL) Version 2 */ var msBeautify = msBeautify || {}; (function ($) { msBeautify = { version: {msDropdown:'3.2'}, author: "Marghoob Suleman", counter: 20, debug: function (v) { if (v !== false) { $(".ddOutOfVision").css({height: 'auto', position: 'relative'}); } else { //$(".ddOutOfVision").css({height: '0px', position: 'absolute'}); $(".ddOutOfVision").css({height: '0px', position: 'relative'}); } }, oldDiv: '', create: function (id, settings, type) { type = type || "dropdown"; var data; switch (type.toLowerCase()) { case "dropdown": case "select": data = $(id).msDropdown(settings).data("dd"); break; } return data; } }; $.msDropDown = {}; $.msDropdown = {}; $.extend(true, $.msDropDown, msBeautify); $.extend(true, $.msDropdown, msBeautify); // make compatibiliy with old and new jquery if ($.fn.prop === undefined) {$.fn.prop = $.fn.attr;} if ($.fn.on === undefined) {$.fn.on = $.fn.bind;$.fn.off = $.fn.unbind;} if (typeof $.expr.createPseudo === 'function') { //jQuery 1.8 or greater $.expr[':'].Contains = $.expr.createPseudo(function (arg) {return function (elem) { return $(elem).text().toUpperCase().indexOf(arg.toUpperCase()) >= 0; }; }); } else { //lower version $.expr[':'].Contains = function (a, i, m) {return $(a).text().toUpperCase().indexOf(m[3].toUpperCase()) >= 0; }; } //dropdown class function dd(element, settings) { var _settings = $.extend(true,{byJson: {data: null, selectedIndex: 0, name: null, size: 0, multiple: false, width: 250}, mainCSS: 'dd', height: 120, //not using currently visibleRows: 7, rowHeight: 0, showIcon: true, zIndex: 9999, useSprite: false, animStyle: '', event:'click', openDirection: 'auto', //auto || alwaysUp jsonTitle: false, style: '', disabledOpacity: 0.7, disabledOptionEvents: true, childWidth:0, enableCheckbox:false, //this needs to multiple or it will set element to multiple checkboxNameSuffix:'_mscheck', append:'', prepend:'', on: {create: null,open: null,close: null,add: null,remove: null,change: null,blur: null,click: null,dblclick: null,mousemove: null,mouseover: null,mouseout: null,focus: null,mousedown: null,mouseup: null} }, settings); var _this = this; //this class var _holderId = {postElementHolder: '_msddHolder', postID: '_msdd', postTitleID: '_title',postTitleTextID: '_titleText', postChildID: '_child'}; var _styles = {dd:_settings.mainCSS, ddTitle: 'ddTitle', arrow: 'arrow arrowoff', ddChild: 'ddChild', ddTitleText: 'ddTitleText',disabled: 'disabled', enabled: 'enabled', ddOutOfVision: 'ddOutOfVision', borderTop: 'borderTop', noBorderTop: 'noBorderTop', selected: 'selected', divider: 'divider', optgroup: "optgroup", optgroupTitle: "optgroupTitle", description: "description", label: "ddlabel",hover: 'hover',disabledAll: 'disabledAll'}; var _styles_i = {li: '_msddli_',borderRadiusTp: 'borderRadiusTp',ddChildMore: 'border shadow',fnone: "fnone"}; var _isList = false, _isMultiple=false,_isDisabled=false, _cacheElement = {}, _element, _orginial, _isOpen=false; var DOWN_ARROW = 40, UP_ARROW = 38, LEFT_ARROW=37, RIGHT_ARROW=39, ESCAPE = 27, ENTER = 13, ALPHABETS_START = 47, SHIFT=16 , CONTROL = 17; var _shiftHolded=false, _controlHolded=false,_lastTarget=null,_forcedTrigger=false, _oldSelected, _isCreated = false; var _doc = document; var _checkDataSetting = function() { _settings.mainCSS = $("#"+_element).data("maincss") || _settings.mainCSS; _settings.visibleRows = $("#"+_element).data("visiblerows") || _settings.visibleRows; if($("#"+_element).data("showicon")==false) {_settings.showIcon = $("#"+_element).data("showicon");}; _settings.useSprite = $("#"+_element).data("usesprite") || _settings.useSprite; _settings.animStyle = $("#"+_element).data("animstyle") || _settings.animStyle; _settings.event = $("#"+_element).data("event") || _settings.event; _settings.openDirection = $("#"+_element).data("opendirection") || _settings.openDirection; _settings.jsonTitle = $("#"+_element).data("jsontitle") || _settings.jsonTitle; _settings.disabledOpacity = $("#"+_element).data("disabledopacity") || _settings.disabledOpacity; _settings.childWidth = $("#"+_element).data("childwidth") || _settings.childWidth; _settings.enableCheckbox = $("#"+_element).data("enablecheckbox") || _settings.enableCheckbox; _settings.checkboxNameSuffix = $("#"+_element).data("checkboxnamesuffix") || _settings.checkboxNameSuffix; _settings.append = $("#"+_element).data("append") || _settings.append; _settings.prepend = $("#"+_element).data("prepend") || _settings.prepend; }; var getElement = function(ele) { if (_cacheElement[ele] === undefined) { _cacheElement[ele] = _doc.getElementById(ele); } return _cacheElement[ele]; }; var _getIndex = function(opt) { var childid = _getPostID("postChildID"); return $("#"+childid + " li."+_styles_i.li).index(opt); }; var _createByJson = function() { if (_settings.byJson.data) { var validData = ["description","image", "title"]; try { if (!element.id) { element.id = "dropdown"+msBeautify.counter; }; _settings.byJson.data = eval(_settings.byJson.data); //change element var id = "msdropdown"+(msBeautify.counter++); var obj = {}; obj.id = id; obj.name = _settings.byJson.name || element.id; //its name if (_settings.byJson.size>0) { obj.size = _settings.byJson.size; }; obj.multiple = _settings.byJson.multiple; var oSelect = _createElement("select", obj); for(var i=0;i<_settings.byJson.data.length;i++) { var current = _settings.byJson.data[i]; var opt = new Option(current.text, current.value); for(var p in current) { if (p.toLowerCase() != 'text') { var key = ($.inArray(p.toLowerCase(), validData)!=-1) ? "data-" : ""; opt.setAttribute(key+p, current[p]); }; }; oSelect.options[i] = opt; }; getElement(element.id).appendChild(oSelect); oSelect.selectedIndex = _settings.byJson.selectedIndex; $(oSelect).css({width: _settings.byJson.width+'px'}); //now change element for access other things element = oSelect; } catch(e) { throw "There is an error in json data."; }; }; }; var _construct = function() { //set properties _createByJson(); if (!element.id) { element.id = "msdrpdd"+(msBeautify.counter++); }; _element = element.id; _this._element = _element; _checkDataSetting(); _isDisabled = getElement(_element).disabled; var useCheckbox = _settings.enableCheckbox; if(Boolean(useCheckbox)===true) { getElement(_element).multiple = true; _settings.enableCheckbox = true; }; _isList = (getElement(_element).size>1 || getElement(_element).multiple==true) ? true : false; //trace("_isList "+_isList); if (_isList) {_isMultiple = getElement(_element).multiple;}; _mergeAllProp(); //create layout _createLayout(); //set ui prop _updateProp("uiData", _getDataAndUI()); _updateProp("selectedOptions", $("#"+_element +" option:selected")); var childid = _getPostID("postChildID"); _oldSelected = $("#" + childid + " li." + _styles.selected); }; /********************************************************************************************/ var _getPostID = function (id) { return _element+_holderId[id]; }; var _getInternalStyle = function(ele) { var s = (ele.style === undefined) ? "" : ele.style.cssText; return s; }; var _parseOption = function(opt) { var imagePath = '', title ='', description='', value=-1, text='', className='', imagecss = ''; if (opt !== undefined) { var attrTitle = opt.title || ""; //data-title if (attrTitle!="") { var reg = /^\{.*\}$/; var isJson = reg.test(attrTitle); if (isJson && _settings.jsonTitle) { var obj = eval("["+attrTitle+"]"); }; title = (isJson && _settings.jsonTitle) ? obj[0].title : title; description = (isJson && _settings.jsonTitle) ? obj[0].description : description; imagePath = (isJson && _settings.jsonTitle) ? obj[0].image : attrTitle; imagecss = (isJson && _settings.jsonTitle) ? obj[0].imagecss : imagecss; }; text = opt.text || ''; value = opt.value || ''; className = opt.className || ""; //ignore title attribute if playing with data tags title = $(opt).prop("data-title") || $(opt).data("title") || (title || ""); description = $(opt).prop("data-description") || $(opt).data("description") || (description || ""); imagePath = $(opt).prop("data-image") || $(opt).data("image") || (imagePath || ""); imagecss = $(opt).prop("data-imagecss") || $(opt).data("imagecss") || (imagecss || ""); }; var o = {image: imagePath, title: title, description: description, value: value, text: text, className: className, imagecss:imagecss}; return o; }; var _createElement = function(nm, attr, html) { var tag = _doc.createElement(nm); if (attr) { for(var i in attr) { switch(i) { case "style": tag.style.cssText = attr[i]; break; default: tag[i] = attr[i]; break; }; }; }; if (html) { tag.innerHTML = html; }; return tag; }; /********************************************************************************************/ /*********************** *************************************/ var _hideOriginal = function() { var hidid = _getPostID("postElementHolder"); if ($("#"+hidid).length==0) { //var obj = {style: 'height: 0px;overflow: hidden;position: absolute;',className: _styles.ddOutOfVision}; var obj = {style: 'height: 0px;overflow: hidden;position: relative;',className: _styles.ddOutOfVision}; obj.id = hidid; var oDiv = _createElement("div", obj); $("#"+_element).after(oDiv); $("#"+_element).appendTo($("#"+hidid)); } else { //$("#"+hidid).css({height: 0,overflow: 'hidden',position: 'absolute'}); $("#"+hidid).css({height: 0,overflow: 'hidden',position: 'relative'}); }; }; var _createWrapper = function () { var obj = { className: _styles.dd + " ddcommon borderRadius" }; var styles = _getInternalStyle(getElement(_element)); var w = $("#" + _element).outerWidth(); //obj.style = "width: " + w + "px;"; if (styles.length > 0) { obj.style = obj.style + "" + styles; }; obj.id = _getPostID("postID"); var oDiv = _createElement("div", obj); return oDiv; }; var _createTitle = function () { var selectedOption; if(getElement(_element).selectedIndex>=0) { selectedOption = getElement(_element).options[getElement(_element).selectedIndex]; } else { selectedOption = {value:'', text:''}; } var spriteClass = "", selectedClass = ""; //check sprite var useSprite = $("#"+_element).data("usesprite"); if(useSprite) { _settings.useSprite = useSprite; }; if (_settings.useSprite != false) { spriteClass = " " + _settings.useSprite; selectedClass = " " + selectedOption.className; }; var oTitle = _createElement("div", {className: _styles.ddTitle + spriteClass + " " + _styles_i.borderRadiusTp}); //divider var oDivider = _createElement("span", {className: _styles.divider}); //arrow var oArrow = _createElement("span", {className: _styles.arrow}); //title Text var titleid = _getPostID("postTitleID"); var oTitleText = _createElement("span", {className: _styles.ddTitleText + selectedClass, id: titleid}); var parsed = _parseOption(selectedOption); var arrowPath = parsed.image; var sText = parsed.text || ""; if (arrowPath != "" && _settings.showIcon) { var oIcon = _createElement("img"); var oIconParent = _createElement("span", {className: "ddImage"}); oIcon.src = arrowPath; if(parsed.imagecss!="") { oIcon.className = parsed.imagecss+" "; }; }; var oTitleText_in = _createElement("span", {className: _styles.label}, sText); oTitle.appendChild(oDivider); oTitle.appendChild(oArrow); if (oIcon) { oIconParent.appendChild(oIcon); oTitleText.appendChild(oIconParent); }; oTitleText.appendChild(oTitleText_in); oTitle.appendChild(oTitleText); var oDescription = _createElement("span", {className: _styles.description}, parsed.description); oTitleText_in.appendChild(oDescription); return oTitle; }; var _createFilterBox = function () { var tid = _getPostID("postTitleTextID"); var sText = _createElement("input", {id: tid, type: 'text', value: '', autocomplete: 'off', className: 'text shadow borderRadius', style: 'display: none'}); return sText; }; var _createChild = function (opt) { var obj = {}; var styles = _getInternalStyle(opt); if (styles.length > 0) {obj.style = styles; }; var css = (opt.disabled) ? _styles.disabled : _styles.enabled; css = (opt.selected) ? (css + " " + _styles.selected) : css; css = css + " " + _styles_i.li; obj.className = css; if (_settings.useSprite != false) { obj.className = css + " " + opt.className; }; var li = _createElement("li", obj); var parsed = _parseOption(opt); if (parsed.title != "") { li.title = parsed.title; }; var arrowPath = parsed.image; if (arrowPath != "" && _settings.showIcon) { var oIcon = _createElement("img"); oIcon.src = arrowPath; var oIconParent = _createElement("span", {className: "ddImage"}); if(parsed.imagecss!="") { oIcon.className = parsed.imagecss+" "; }; }; if (parsed.description != "") { var oDescription = _createElement("span", { className: _styles.description }, parsed.description); }; var sText = opt.text || ""; var oTitleText = _createElement("span", { className: _styles.label }, sText); //checkbox if(_settings.enableCheckbox===true) { var chkbox = _createElement("input", { type: 'checkbox', name:_element+_settings.checkboxNameSuffix+'[]', value:opt.value||""}); //this can be used for future li.appendChild(chkbox); if(_settings.enableCheckbox===true) { chkbox.checked = (opt.selected) ? true : false; }; }; if (oIcon) { oIconParent.appendChild(oIcon); li.appendChild(oIconParent); }; li.appendChild(oTitleText); if (oDescription) { oTitleText.appendChild(oDescription); } else { if (oIcon) { oIcon.className = oIcon.className+_styles_i.fnone; }; }; var oClear = _createElement("div", {className: 'clear'}); li.appendChild(oClear); return li; }; var _createChildren = function () { var childid = _getPostID("postChildID"); var obj = {className: _styles.ddChild + " ddchild_ " + _styles_i.ddChildMore, id: childid}; if (_isList == false) { obj.style = "z-index: " + _settings.zIndex; } else { obj.style = "z-index:1"; }; var childWidth = $("#"+_element).data("childwidth") || _settings.childWidth; if(childWidth) { obj.style = (obj.style || "") + ";width:"+childWidth; }; var oDiv = _createElement("div", obj); var ul = _createElement("ul"); if (_settings.useSprite != false) { ul.className = _settings.useSprite; }; var allOptions = getElement(_element).children; for (var i = 0; i < allOptions.length; i++) { var current = allOptions[i]; var li; if (current.nodeName.toLowerCase() == "optgroup") { //create ul li = _createElement("li", {className: _styles.optgroup}); var span = _createElement("span", {className: _styles.optgroupTitle}, current.label); li.appendChild(span); var optChildren = current.children; var optul = _createElement("ul"); for (var j = 0; j < optChildren.length; j++) { var opt_li = _createChild(optChildren[j]); optul.appendChild(opt_li); }; li.appendChild(optul); } else { li = _createChild(current); }; ul.appendChild(li); }; oDiv.appendChild(ul); return oDiv; }; var _childHeight = function (val) { var childid = _getPostID("postChildID"); if (val) { if (val == -1) { //auto $("#"+childid).css({height: "auto", overflow: "auto"}); } else { $("#"+childid).css("height", val+"px"); }; return false; }; //else return height var iHeight; if (getElement(_element).options.length > _settings.visibleRows) { var margin = parseInt($("#" + childid + " li:first").css("padding-bottom")) + parseInt($("#" + childid + " li:first").css("padding-top")); if(_settings.rowHeight===0) { $("#" + childid).css({visibility:'hidden',display:'block'}); //hack for first child _settings.rowHeight = Math.round($("#" + childid + " li:first").height()); $("#" + childid).css({visibility:'visible'}); if(!_isList || _settings.enableCheckbox===true) { $("#" + childid).css({display:'none'}); }; }; iHeight = ((_settings.rowHeight + margin) * _settings.visibleRows); } else if (_isList) { iHeight = $("#" + _element).height(); //get height from original element }; return iHeight; }; var _applyChildEvents = function () { var childid = _getPostID("postChildID"); $("#" + childid).on("click", function (e) { if (_isDisabled === true) return false; //prevent body click e.preventDefault(); e.stopPropagation(); if (_isList) { _bind_on_events(); }; }); $("#" + childid + " li." + _styles.enabled).on("click", function (e) { if(e.target.nodeName.toLowerCase() !== "input") { _close(this); }; }); $("#" + childid + " li." + _styles.enabled).on("mousedown", function (e) { if (_isDisabled === true) return false; _oldSelected = $("#" + childid + " li." + _styles.selected); _lastTarget = this; e.preventDefault(); e.stopPropagation(); //select current input if(_settings.enableCheckbox===true) { if(e.target.nodeName.toLowerCase() === "input") { _controlHolded = true; }; }; if (_isList === true) { if (_isMultiple) { if (_shiftHolded === true) { $(this).addClass(_styles.selected); var selected = $("#" + childid + " li." + _styles.selected); var lastIndex = _getIndex(this); if (selected.length > 1) { var items = $("#" + childid + " li." + _styles_i.li); var ind1 = _getIndex(selected[0]); var ind2 = _getIndex(selected[1]); if (lastIndex > ind2) { ind1 = (lastIndex); ind2 = ind2 + 1; }; for (var i = Math.min(ind1, ind2); i <= Math.max(ind1, ind2); i++) { var current = items[i]; if ($(current).hasClass(_styles.enabled)) { $(current).addClass(_styles.selected); }; }; }; } else if (_controlHolded === true) { $(this).toggleClass(_styles.selected); //toggle if(_settings.enableCheckbox===true) { var checkbox = this.childNodes[0]; checkbox.checked = !checkbox.checked; //toggle }; } else { $("#" + childid + " li." + _styles.selected).removeClass(_styles.selected); $("#" + childid + " input:checkbox").prop("checked", false); $(this).addClass(_styles.selected); if(_settings.enableCheckbox===true) { this.childNodes[0].checked = true; }; }; } else { $("#" + childid + " li." + _styles.selected).removeClass(_styles.selected); $(this).addClass(_styles.selected); }; //fire event on mouseup } else { $("#" + childid + " li." + _styles.selected).removeClass(_styles.selected); $(this).addClass(_styles.selected); }; }); $("#" + childid + " li." + _styles.enabled).on("mouseenter", function (e) { if (_isDisabled === true) return false; e.preventDefault(); e.stopPropagation(); if (_lastTarget != null) { if (_isMultiple) { $(this).addClass(_styles.selected); if(_settings.enableCheckbox===true) { this.childNodes[0].checked = true; }; }; }; }); $("#" + childid + " li." + _styles.enabled).on("mouseover", function (e) { if (_isDisabled === true) return false; $(this).addClass(_styles.hover); }); $("#" + childid + " li." + _styles.enabled).on("mouseout", function (e) { if (_isDisabled === true) return false; $("#" + childid + " li." + _styles.hover).removeClass(_styles.hover); }); $("#" + childid + " li." + _styles.enabled).on("mouseup", function (e) { if (_isDisabled === true) return false; e.preventDefault(); e.stopPropagation(); if(_settings.enableCheckbox===true) { _controlHolded = false; }; var selected = $("#" + childid + " li." + _styles.selected).length; _forcedTrigger = (_oldSelected.length != selected || selected == 0) ? true : false; _fireAfterItemClicked(); _unbind_on_events(); //remove old one _bind_on_events(); _lastTarget = null; }); /* options events */ if (_settings.disabledOptionEvents == false) { $("#" + childid + " li." + _styles_i.li).on("click", function (e) { if (_isDisabled === true) return false; fireOptionEventIfExist(this, "click"); }); $("#" + childid + " li." + _styles_i.li).on("mouseenter", function (e) { if (_isDisabled === true) return false; fireOptionEventIfExist(this, "mouseenter"); }); $("#" + childid + " li." + _styles_i.li).on("mouseover", function (e) { if (_isDisabled === true) return false; fireOptionEventIfExist(this, "mouseover"); }); $("#" + childid + " li." + _styles_i.li).on("mouseout", function (e) { if (_isDisabled === true) return false; fireOptionEventIfExist(this, "mouseout"); }); $("#" + childid + " li." + _styles_i.li).on("mousedown", function (e) { if (_isDisabled === true) return false; fireOptionEventIfExist(this, "mousedown"); }); $("#" + childid + " li." + _styles_i.li).on("mouseup", function (e) { if (_isDisabled === true) return false; fireOptionEventIfExist(this, "mouseup"); }); }; }; var _removeChildEvents = function () { var childid = _getPostID("postChildID"); $("#" + childid).off("click"); $("#" + childid + " li." + _styles.enabled).off("mouseenter"); $("#" + childid + " li." + _styles.enabled).off("click"); $("#" + childid + " li." + _styles.enabled).off("mouseover"); $("#" + childid + " li." + _styles.enabled).off("mouseout"); $("#" + childid + " li." + _styles.enabled).off("mousedown"); $("#" + childid + " li." + _styles.enabled).off("mouseup"); }; var _applyEvents = function () { var id = _getPostID("postID"); var childid = _getPostID("postChildID"); $("#" + id).on(_settings.event, function (e) { if (_isDisabled === true) return false; fireEventIfExist("click"); //prevent body click e.preventDefault(); e.stopPropagation(); _open(e); }); _applyChildEvents(); $("#" + id).on("dblclick", on_dblclick); $("#" + id).on("mousemove", on_mousemove); $("#" + id).on("mouseenter", on_mouseover); $("#" + id).on("mouseleave", on_mouseout); $("#" + id).on("mousedown", on_mousedown); $("#" + id).on("mouseup", on_mouseup); }; //after create var _fixedForList = function () { var id = _getPostID("postID"); var childid = _getPostID("postChildID"); if (_isList === true && _settings.enableCheckbox===false) { $("#" + id + " ." + _styles.ddTitle).hide(); $("#" + childid).css({display: 'block', position: 'relative'}); //_open(); } else { if(_settings.enableCheckbox===false) { _isMultiple = false; //set multiple off if this is not a list }; $("#" + id + " ." + _styles.ddTitle).show(); //$("#" + childid).css({display: 'none', position: 'absolute'}); $("#" + childid).css({display: 'none', position: 'relative'}); //set value var first = $("#" + childid + " li." + _styles.selected)[0]; $("#" + childid + " li." + _styles.selected).removeClass(_styles.selected); var index = _getIndex($(first).addClass(_styles.selected)); _setValue(index); }; _childHeight(_childHeight()); //get and set height }; var _fixedForDisabled = function () { var id = _getPostID("postID"); var opc = (_isDisabled == true) ? _settings.disabledOpacity : 1; if (_isDisabled === true) { $("#" + id).addClass(_styles.disabledAll); } else { $("#" + id).removeClass(_styles.disabledAll); }; }; var _fixedSomeUI = function () { //auto filter var tid = _getPostID("postTitleTextID"); $("#" + tid).on("keyup", _applyFilters); //if is list _fixedForList(); _fixedForDisabled(); }; var _createLayout = function () { var oDiv = _createWrapper(); var oTitle = _createTitle(); oDiv.appendChild(oTitle); //auto filter box var oFilterBox = _createFilterBox(); oDiv.appendChild(oFilterBox); var oChildren = _createChildren(); oDiv.appendChild(oChildren); $("#" + _element).after(oDiv); _hideOriginal(); //hideOriginal _fixedSomeUI(); _applyEvents(); var childid = _getPostID("postChildID"); //append if(_settings.append!='') { $("#" + childid).append(_settings.append); }; //prepend if(_settings.prepend!='') { $("#" + childid).prepend(_settings.prepend); }; if (typeof _settings.on.create == "function") { _settings.on.create.apply(_this, arguments); }; }; var _selectMutipleOptions = function (bySelected) { var childid = _getPostID("postChildID"); var selected = bySelected || $("#" + childid + " li." + _styles.selected); //bySelected or by argument for (var i = 0; i < selected.length; i++) { var ind = _getIndex(selected[i]); getElement(_element).options[ind].selected = "selected"; }; _setValue(selected); }; var _fireAfterItemClicked = function () { //console.log("_fireAfterItemClicked") var childid = _getPostID("postChildID"); var selected = $("#" + childid + " li." + _styles.selected); if (_isMultiple && (_shiftHolded || _controlHolded) || _forcedTrigger) { getElement(_element).selectedIndex = -1; //reset old }; var index; if (selected.length == 0) { index = -1; } else if (selected.length > 1) { //selected multiple _selectMutipleOptions(selected); //index = $("#" + childid + " li." + _styles.selected); } else { //if one selected index = _getIndex($("#" + childid + " li." + _styles.selected)); }; if ((getElement(_element).selectedIndex != index || _forcedTrigger) && selected.length<=1) { _forcedTrigger = false; var evt = has_handler("change"); getElement(_element).selectedIndex = index; _setValue(index); //local if (typeof _settings.on.change == "function") { var d = _getDataAndUI(); _settings.on.change(d.data, d.ui); }; $("#" + _element).trigger("change"); }; }; var _setValue = function (index, byvalue) { if (index !== undefined) { var selectedIndex, value, selectedText; if (index == -1) { selectedIndex = -1; value = ""; selectedText = ""; _updateTitleUI(-1); } else { //by index or byvalue if (typeof index != "object") { var opt = getElement(_element).options[index]; getElement(_element).selectedIndex = index; selectedIndex = index; value = _parseOption(opt); selectedText = (index >= 0) ? getElement(_element).options[index].text : ""; _updateTitleUI(undefined, value); value = value.value; //for bottom } else { //this is multiple or by option selectedIndex = (byvalue && byvalue.index) || getElement(_element).selectedIndex; value = (byvalue && byvalue.value) || getElement(_element).value; selectedText = (byvalue && byvalue.text) || getElement(_element).options[getElement(_element).selectedIndex].text || ""; _updateTitleUI(selectedIndex); }; }; _updateProp("selectedIndex", selectedIndex); _updateProp("value", value); _updateProp("selectedText", selectedText); _updateProp("children", getElement(_element).children); _updateProp("uiData", _getDataAndUI()); _updateProp("selectedOptions", $("#" + _element + " option:selected")); }; }; var has_handler = function (name) { //True if a handler has been added in the html. var evt = {byElement: false, byJQuery: false, hasEvent: false}; var obj = $("#" + _element); //console.log(name) try { //console.log(obj.prop("on" + name) + " "+name); if (obj.prop("on" + name) !== null) { evt.hasEvent = true; evt.byElement = true; }; } catch(e) { //console.log(e.message); } // True if a handler has been added using jQuery. var evs; if (typeof $._data == "function") { //1.8 evs = $._data(obj[0], "events"); } else { evs = obj.data("events"); }; if (evs && evs[name]) { evt.hasEvent = true; evt.byJQuery = true; }; return evt; }; var _bind_on_events = function () { _unbind_on_events(); $("body").on("click", _close); //bind more events $(document).on("keydown", on_keydown); $(document).on("keyup", on_keyup); //focus will work on this }; var _unbind_on_events = function () { $("body").off("click", _close); //bind more events $(document).off("keydown", on_keydown); $(document).off("keyup", on_keyup); }; var _applyFilters = function () { var childid = _getPostID("postChildID"); var tid = _getPostID("postTitleTextID"); var sText = getElement(tid).value; if (sText.length == 0) { $("#" + childid + " li:hidden").show(); //show if hidden _childHeight(_childHeight()); } else { $("#" + childid + " li").hide(); $("#" + childid + " li:Contains('" + sText + "')").show(); if ($("#" + childid + " li:visible").length <= _settings.visibleRows) { _childHeight(-1); //set autoheight }; }; }; var _showFilterBox = function () { var tid = _getPostID("postTitleTextID"); if ($("#" + tid + ":hidden").length > 0 && _controlHolded == false) { $("#" + tid + ":hidden").show().val(""); getElement(tid).focus(); }; }; var _hideFilterBox = function () { var tid = _getPostID("postTitleTextID"); if ($("#" + tid + ":visible").length > 0) { $("#" + tid + ":visible").hide(); getElement(tid).blur(); }; }; var on_keydown = function (evt) { var tid = _getPostID("postTitleTextID"); var childid = _getPostID("postChildID"); switch (evt.keyCode) { case DOWN_ARROW: case RIGHT_ARROW: evt.preventDefault(); evt.stopPropagation(); //_hideFilterBox(); _next(); break; case UP_ARROW: case LEFT_ARROW: evt.preventDefault(); evt.stopPropagation(); //_hideFilterBox(); _previous(); break; case ESCAPE: case ENTER: evt.preventDefault(); evt.stopPropagation(); _close(); var selected = $("#" + childid + " li." + _styles.selected).length; _forcedTrigger = (_oldSelected.length != selected || selected == 0) ? true : false; _fireAfterItemClicked(); _unbind_on_events(); //remove old one _lastTarget = null; break; case SHIFT: _shiftHolded = true; break; case CONTROL: _controlHolded = true; break; default: if (evt.keyCode >= ALPHABETS_START && _isList === false) { //_showFilterBox(); }; break; }; if (_isDisabled === true) return false; fireEventIfExist("keydown"); }; var on_keyup = function (evt) { switch (evt.keyCode) { case SHIFT: _shiftHolded = false; break; case CONTROL: _controlHolded = false; break; }; if (_isDisabled === true) return false; fireEventIfExist("keyup"); }; var on_dblclick = function (evt) { if (_isDisabled === true) return false; fireEventIfExist("dblclick"); }; var on_mousemove = function (evt) { if (_isDisabled === true) return false; fireEventIfExist("mousemove"); }; var on_mouseover = function (evt) { if (_isDisabled === true) return false; evt.preventDefault(); fireEventIfExist("mouseover"); }; var on_mouseout = function (evt) { if (_isDisabled === true) return false; evt.preventDefault(); fireEventIfExist("mouseout"); }; var on_mousedown = function (evt) { if (_isDisabled === true) return false; fireEventIfExist("mousedown"); }; var on_mouseup = function (evt) { if (_isDisabled === true) return false; fireEventIfExist("mouseup"); }; var option_has_handler = function (opt, name) { //True if a handler has been added in the html. var evt = {byElement: false, byJQuery: false, hasEvent: false}; if ($(opt).prop("on" + name) != undefined) { evt.hasEvent = true; evt.byElement = true; }; // True if a handler has been added using jQuery. var evs = $(opt).data("events"); if (evs && evs[name]) { evt.hasEvent = true; evt.byJQuery = true; }; return evt; }; var fireOptionEventIfExist = function (li, evt_n) { if (_settings.disabledOptionEvents == false) { var opt = getElement(_element).options[_getIndex(li)]; //check if original has some if (option_has_handler(opt, evt_n).hasEvent === true) { if (option_has_handler(opt, evt_n).byElement === true) { opt["on" + evt_n](); }; if (option_has_handler(opt, evt_n).byJQuery === true) { switch (evt_n) { case "keydown": case "keyup": //key down/up will check later break; default: $(opt).trigger(evt_n); break; }; }; return false; }; }; }; var fireEventIfExist = function (evt_n) { //local if (typeof _settings.on[evt_n] == "function") { _settings.on[evt_n].apply(this, arguments); }; //check if original has some if (has_handler(evt_n).hasEvent === true) { if (has_handler(evt_n).byElement === true) { getElement(_element)["on" + evt_n](); }; if (has_handler(evt_n).byJQuery === true) { switch (evt_n) { case "keydown": case "keyup": //key down/up will check later break; default: $("#" + _element).trigger(evt_n); break; }; }; return false; }; }; /******************************* navigation **********************************************/ var _scrollToIfNeeded = function (opt) { var childid = _getPostID("postChildID"); //if scroll is needed opt = (opt !== undefined) ? opt : $("#" + childid + " li." + _styles.selected); if (opt.length > 0) { var pos = parseInt(($(opt).position().top)); var ch = parseInt($("#" + childid).height()); if (pos > ch) { var top = pos + $("#" + childid).scrollTop() - (ch/2); $("#" + childid); }; }; }; var _next = function () { var childid = _getPostID("postChildID"); var items = $("#" + childid + " li:visible." + _styles_i.li); var selected = $("#" + childid + " li:visible." + _styles.selected); selected = (selected.length==0) ? items[0] : selected; var index = $("#" + childid + " li:visible." + _styles_i.li).index(selected); if ((index < items.length - 1)) { index = getNext(index); if (index < items.length) { //check again - hack for last disabled if (!_shiftHolded || !_isList || !_isMultiple) { $("#" + childid + " ." + _styles.selected).removeClass(_styles.selected); }; $(items[index]).addClass(_styles.selected); _updateTitleUI(index); if (_isList == true) { _fireAfterItemClicked(); }; _scrollToIfNeeded($(items[index])); }; if (!_isList) { _adjustOpen(); }; }; function getNext(ind) { ind = ind + 1; if (ind > items.length) { return ind; }; if ($(items[ind]).hasClass(_styles.enabled) === true) { return ind; }; return ind = getNext(ind); }; }; var _previous = function () { var childid = _getPostID("postChildID"); var selected = $("#" + childid + " li:visible." + _styles.selected); var items = $("#" + childid + " li:visible." + _styles_i.li); var index = $("#" + childid + " li:visible." + _styles_i.li).index(selected[0]); if (index >= 0) { index = getPrev(index); if (index >= 0) { //check again - hack for disabled if (!_shiftHolded || !_isList || !_isMultiple) { $("#" + childid + " ." + _styles.selected).removeClass(_styles.selected); }; $(items[index]).addClass(_styles.selected); _updateTitleUI(index); if (_isList == true) { _fireAfterItemClicked(); }; if (parseInt(($(items[index]).position().top + $(items[index]).height())) <= 0) { var top = ($("#" + childid).scrollTop() - $("#" + childid).height()) - $(items[index]).height(); $("#" + childid); }; }; if (!_isList) { _adjustOpen(); }; }; function getPrev(ind) { ind = ind - 1; if (ind < 0) { return ind; }; if ($(items[ind]).hasClass(_styles.enabled) === true) { return ind; }; return ind = getPrev(ind); }; }; var _adjustOpen = function () { var id = _getPostID("postID"); var childid = _getPostID("postChildID"); var pos = $("#" + id).offset(); var mH = $("#" + id).height(); var wH = $(window).height(); var st = $(window).scrollTop(); var cH = $("#" + childid).height(); var top = $("#" + id).height(); //this close so its title height var contBottom = $("#" + id).closest('.btQuoteBooking').offset().top + $("#" + id).closest('.btQuoteBooking').height(); if (contBottom < Math.floor(cH + mH + pos.top) || _settings.openDirection.toLowerCase() == 'alwaysup') { top = cH; $("#" + childid).css({top: "-" + top + "px", display: 'block', zIndex: _settings.zIndex}); $("#" + id).removeClass("borderRadius borderRadiusTp").addClass("borderRadiusBtm"); var top = $("#" + childid).offset().top; if (top < -10) { $("#" + childid).css({top: (parseInt($("#" + childid).css("top")) - top + 20 + st) + "px", zIndex: _settings.zIndex}); $("#" + id).removeClass("borderRadiusBtm borderRadiusTp").addClass("borderRadius"); }; } else { $("#" + childid).css({top: top + "px", zIndex: _settings.zIndex}); $("#" + id).removeClass("borderRadius borderRadiusBtm").addClass("borderRadiusTp"); }; //hack for ie zindex //i hate ie :D /*if($.browser.msie) { if(parseInt($.browser.version)<=7) { $('div.ddcommon').css("zIndex", _settings.zIndex-10); $("#" + id).css("zIndex", _settings.zIndex+5); }; };*/ }; var _open = function (e) { if (_isDisabled === true) return false; var id = _getPostID("postID"); var childid = _getPostID("postChildID"); if (!_isOpen) { _isOpen = true; if (msBeautify.oldDiv != '') { $("#" + msBeautify.oldDiv).css({display: "none"}); //hide all }; msBeautify.oldDiv = childid; $("#" + childid + " li:hidden").show(); //show if hidden _adjustOpen(); var animStyle = _settings.animStyle; if(animStyle=="" || animStyle=="none") { $("#" + childid).css({display:"block"}); _scrollToIfNeeded(); if (typeof _settings.on.open == "function") { var d = _getDataAndUI(); _settings.on.open(d.data, d.ui); }; } else { $("#" + childid)[animStyle]("fast", function () { _scrollToIfNeeded(); if (typeof _settings.on.open == "function") { var d = _getDataAndUI(); _settings.on.open(d.data, d.ui); }; }); }; _bind_on_events(); } else { if(_settings.event!=='mouseover') { _close(); }; }; }; var _close = function (e) { _isOpen = false; var id = _getPostID("postID"); var childid = _getPostID("postChildID"); if (_isList === false || _settings.enableCheckbox===true) { $("#" + childid).css({display: "none"}); $("#" + id).removeClass("borderRadiusTp borderRadiusBtm").addClass("borderRadius"); }; _unbind_on_events(); if (typeof _settings.on.close == "function") { var d = _getDataAndUI(); _settings.on.close(d.data, d.ui); }; //rest some old stuff _hideFilterBox(); _childHeight(_childHeight()); //its needed after filter applied $("#" + childid).css({zIndex:1}) }; /*********************** *************************************/ var _mergeAllProp = function () { _orginial = $.extend(true, {}, getElement(_element)); for (var i in _orginial) { if (typeof _orginial[i] != "function") { _this[i] = _orginial[i]; //properties }; }; _this.selectedText = (_orginial.selectedIndex >= 0) ? _orginial.options[_orginial.selectedIndex].text : ""; _this.version = msBeautify.version.msDropdown; _this.author = msBeautify.author; }; var _getDataAndUIByOption = function (opt) { if (opt != null && typeof opt != "undefined") { var childid = _getPostID("postChildID"); var data = _parseOption(opt); var ui = $("#" + childid + " li." + _styles_i.li + ":eq(" + (opt.index) + ")"); return {data: data, ui: ui, option: opt, index: opt.index}; }; return null; }; var _getDataAndUI = function () { var childid = _getPostID("postChildID"); var ele = getElement(_element); var data, ui, option, index; if (ele.selectedIndex == -1) { data = null; ui = null; option = null; index = -1; } else { ui = $("#" + childid + " li." + _styles.selected); if (ui.length > 1) { var d = [], op = [], ind = []; for (var i = 0; i < ui.length; i++) { var pd = _getIndex(ui[i]); d.push(pd); op.push(ele.options[pd]); }; data = d; option = op; index = d; } else { option = ele.options[ele.selectedIndex]; data = _parseOption(option); index = ele.selectedIndex; }; }; return {data: data, ui: ui, index: index, option: option}; }; var _updateTitleUI = function (index, byvalue) { var titleid = _getPostID("postTitleID"); var value = {}; if (index == -1) { value.text = " "; value.className = ""; value.description = ""; value.image = ""; } else if (typeof index != "undefined") { var opt = getElement(_element).options[index]; value = _parseOption(opt); } else { value = byvalue; }; //update title and current $("#" + titleid).find("." + _styles.label).html(value.text); var textnode = document.createTextNode( value.description ); var desc = _createElement("span", {className: _styles.description}); desc.appendChild( textnode ); $("#" + titleid).find("." + _styles.description).remove(); $("#" + titleid).find("." + _styles.label).append( desc ); getElement(titleid).className = _styles.ddTitleText + " " + value.className; $("#" + titleid).removeClass( 'btNotSelected' ); $("#" + titleid).closest( '.btContactField' ).removeClass( 'btNotSelected' ); if ( value.value == '' ) { $("#" + titleid).addClass( 'btNotSelected' ); $("#" + titleid).closest( '.btContactField' ).addClass( 'btNotSelected' ); } //update desction if (value.description != "") { $("#" + titleid).find("." + _styles.description).html(value.description).show(); } else { $("#" + titleid).find("." + _styles.description).html("").hide(); }; //update icon var img = $("#" + titleid).find("img"); if (img.length > 0) { $(img).parent().remove(); }; if (value.image != "" && _settings.showIcon) { img = _createElement("img", {src: value.image}); var imgParent = _createElement("span", {className: "ddImage"}); imgParent.appendChild(img); $("#" + titleid).prepend(imgParent); if(value.imagecss!="") { img.className = value.imagecss+" "; }; if (value.description == "") { img.className = img.className+_styles_i.fnone; }; }; }; var _updateProp = function (p, v) { _this[p] = v; }; var _updateUI = function (a, opt, i) { //action, index, opt var childid = _getPostID("postChildID"); var wasSelected = false; switch (a) { case "add": var li = _createChild(opt || getElement(_element).options[i]); var index; if (arguments.length == 3) { index = i; } else { index = $("#" + childid + " li." + _styles_i.li).length - 1; }; if (index < 0 || !index) { $("#" + childid + " ul").append(li); } else { var at = $("#" + childid + " li." + _styles_i.li)[index]; $(at).before(li); }; _removeChildEvents(); _applyChildEvents(); if (_settings.on.add != null) { _settings.on.add.apply(this, arguments); }; break; case "remove": wasSelected = $($("#" + childid + " li." + _styles_i.li)[i]).hasClass(_styles.selected); $("#" + childid + " li." + _styles_i.li + ":eq(" + i + ")").remove(); var items = $("#" + childid + " li." + _styles.enabled); if (wasSelected == true) { if (items.length > 0) { $(items[0]).addClass(_styles.selected); var ind = $("#" + childid + " li." + _styles_i.li).index(items[0]); _setValue(ind); }; }; if (items.length == 0) { _setValue(-1); }; if ($("#" + childid + " li." + _styles_i.li).length < _settings.visibleRows && !_isList) { _childHeight(-1); //set autoheight }; if (_settings.on.remove != null) { _settings.on.remove.apply(this, arguments); }; break; }; }; /************************** public methods/events **********************/ this.act = function () { var action = arguments[0]; Array.prototype.shift.call(arguments); switch (action) { case "add": _this.add.apply(this, arguments); break; case "remove": _this.remove.apply(this, arguments); break; default: try { getElement(_element)[action].apply(getElement(_element), arguments); } catch (e) { //there is some error. }; break; }; }; this.add = function () { var text, value, title, image, description; var obj = arguments[0]; if (typeof obj == "string") { text = obj; value = text; opt = new Option(text, value); } else { text = obj.text || ''; value = obj.value || text; title = obj.title || ''; image = obj.image || ''; description = obj.description || ''; //image:imagePath, title:title, description:description, value:opt.value, text:opt.text, className:opt.className||"" opt = new Option(text, value); $(opt).data("description", description); $(opt).data("image", image); $(opt).data("title", title); }; arguments[0] = opt; //this option getElement(_element).add.apply(getElement(_element), arguments); _updateProp("children", getElement(_element)["children"]); _updateProp("length", getElement(_element).length); _updateUI("add", opt, arguments[1]); }; this.remove = function (i) { getElement(_element).remove(i); _updateProp("children", getElement(_element)["children"]); _updateProp("length", getElement(_element).length); _updateUI("remove", undefined, i); }; this.set = function (prop, val) { if (typeof prop == "undefined" || typeof val == "undefined") return false; prop = prop.toString(); try { _updateProp(prop, val); } catch (e) {/*this is ready only */}; switch (prop) { case "size": getElement(_element)[prop] = val; if (val == 0) { getElement(_element).multiple = false; //if size is zero multiple should be false }; _isList = (getElement(_element).size > 1 || getElement(_element).multiple == true) ? true : false; _fixedForList(); break; case "multiple": getElement(_element)[prop] = val; _isList = (getElement(_element).size > 1 || getElement(_element).multiple == true) ? true : false; _isMultiple = getElement(_element).multiple; _fixedForList(); _updateProp(prop, val); break; case "disabled": getElement(_element)[prop] = val; _isDisabled = val; _fixedForDisabled(); break; case "selectedIndex": case "value": getElement(_element)[prop] = val; var childid = _getPostID("postChildID"); $("#" + childid + " li." + _styles_i.li).removeClass(_styles.selected); $($("#" + childid + " li." + _styles_i.li)[getElement(_element).selectedIndex]).addClass(_styles.selected); _setValue(getElement(_element).selectedIndex); break; case "length": var childid = _getPostID("postChildID"); if (val < getElement(_element).length) { getElement(_element)[prop] = val; if (val == 0) { $("#" + childid + " li." + _styles_i.li).remove(); _setValue(-1); } else { $("#" + childid + " li." + _styles_i.li + ":gt(" + (val - 1) + ")").remove(); if ($("#" + childid + " li." + _styles.selected).length == 0) { $("#" + childid + " li." + _styles.enabled + ":eq(0)").addClass(_styles.selected); }; }; _updateProp(prop, val); _updateProp("children", getElement(_element)["children"]); }; break; case "id": //please i need this. so preventing to change it. will work on this later break; default: //check if this is not a readonly properties try { getElement(_element)[prop] = val; _updateProp(prop, val); } catch (e) { //silent }; break; } }; this.get = function (prop) { return _this[prop] || getElement(_element)[prop]; //return if local else from original }; this.visible = function (val) { var id = _getPostID("postID"); if (val === true) { $("#" + id).show(); } else if (val === false) { $("#" + id).hide(); } else { return ($("#" + id).css("display")=="none") ? false : true; }; }; this.debug = function (v) { msBeautify.debug(v); }; this.close = function () { _close(); }; this.open = function () { _open(); }; this.showRows = function (r) { if (typeof r == "undefined" || r == 0) { return false; }; _settings.visibleRows = r; _childHeight(_childHeight()); }; this.visibleRows = this.showRows; this.on = function (type, fn) { $("#" + _element).on(type, fn); }; this.off = function (type, fn) { $("#" + _element).off(type, fn); }; this.addMyEvent = this.on; this.getData = function () { return _getDataAndUI() }; this.namedItem = function () { var opt = getElement(_element).namedItem.apply(getElement(_element), arguments); return _getDataAndUIByOption(opt); }; this.item = function () { var opt = getElement(_element).item.apply(getElement(_element), arguments); return _getDataAndUIByOption(opt); }; //v 3.2 this.setIndexByValue = function(val) { this.set("value", val); }; this.destory = function () { var hidid = _getPostID("postElementHolder"); var id = _getPostID("postID"); $("#" + id + ", #" + id + " *").off(); $("#" + id).remove(); $("#" + _element).parent().replaceWith($("#" + _element)); $("#" + _element).data("dd", null); }; //Create msDropDown _construct(); }; //bind in jquery $.fn.extend({ msDropDown: function(settings) { return this.each(function() { if (!$(this).data('dd')){ var mydropdown = new dd(this, settings); $(this).data('dd', mydropdown); }; }); } }); $.fn.msDropdown = $.fn.msDropDown; //make a copy })(jQuery); // source --> https://redpenguin.it/wp-content/plugins/bt_cost_calculator/cc.main.js?ver=6.4.4 // Cost calculator // author: Bold Themes - http://www.bold-themes.com/ // Date: 15 Nov, 2017 // web: http://www.bold-themes.com (function( $ ) { var is_rtl = false; var rtl_direction = 1; // --------------- // Functions start // --------------- // Base functions window.bt_parse_float = function( x ) { r = parseFloat( x ); if ( isNaN( r ) ) r = 0; return r; } $.fn.bt_cc_lock = function(){ $(this).addClass( 'btCCLock' ); return $(this); } $.fn.bt_cc_unlock = function(){ $(this).removeClass( 'btCCLock' ); return $(this); } // function to be called from element conditions window.bt_cc_set_slider_value = function( elem, value, calc ){ if ( elem.slider( 'instance' ) ) { elem.slider( 'value', value ); elem.find('.btQuoteSliderValue').html( value ); if ( calc ) { bt_quote_total( elem.closest( '.btQuoteBooking' ) ); bt_paypal_items( elem.closest( '.btQuoteBooking' ) ); } } } window.bt_cc_get_slider_value = function( elem ){ if ( elem.slider( 'instance' ) ) { // console.log( 'elem.slider_html: ' + elem.find('.btQuoteSliderValue').html() ); // val = bt_parse_float( window.rtl_direction * elem.slider( 'value' ) ); val = bt_parse_float( elem.find('.btQuoteSliderValue').html() ); } else { val = bt_parse_float( elem.data( 'initial-value' ) ); } // console.log( 'bt_cc_get_slider_value: ' + val ); return val; } $.fn.bt_cc_set_value = function( value ){ if ( value !== null && value !== 'undefined' && value !== undefined ) { var initial_value = value; } else { var initial_value = $( this ).find( '.btQuoteElement' ).data( 'initial-value' ); } if ( $( this ).find( '.btQuoteItemInput > .btQuoteSelect' ).length > 0 ) { var oDropdown = $( this ).find( '.btQuoteSelect' ).data("dd"); if ( oDropdown !== undefined ) { bt_cc_init_dropdown( oDropdown, "#"+$( this ).attr('id'), initial_value ); } } else if ( $( this ).find( '.btQuoteItemInput > .btQuoteSlider' ).length > 0 ) { if ( $( this ).find( '.btQuoteItemInput > .btQuoteSlider' ).slider( 'instance' ) ) { bt_cc_set_slider_value( $( this ).find( '.btQuoteItemInput > .btQuoteSlider' ), initial_value ); } else { /* W3 Tiotal cache safe path */ setTimeout( bt_cc_set_slider_value, 2000, $( this ).find( '.btQuoteItemInput > .btQuoteSlider' ), initial_value, true ); } } else if ( $( this ).find( '.btQuoteItemInput > .btQuoteText' ).length > 0 ) { $( this ).find( '.btQuoteText' ).val( initial_value ); } else if ( $( this ).find( '.btQuoteItemInput > .btQuoteSwitch' ).length > 0 ) { if ( ( $( this ).find( '.btQuoteSwitch' ).data('on') == initial_value && !$( this ).find( '.btQuoteSwitch' ).hasClass('on') ) || ( $( this ).find( '.btQuoteSwitch' ).data('off') == initial_value && $( this ).find( '.btQuoteSwitch' ).hasClass('on') ) ) { $( this ).find( '.btQuoteSwitch' ).trigger('click'); } } bt_cc_eval_conditions( initial_value, $( this ).find( '.btQuoteElement' ).data( 'condition' ) ); bt_quote_total( $( this ).closest( '.btQuoteBooking' ) ); bt_paypal_items( $( this ).closest( '.btQuoteBooking' ) ); return $(this); } window.bt_cc_eval_conditions = function( val, conditions ){ // alert(conditions); if ( conditions == '' || conditions == undefined ) return false; if ( val == '' ) val = 0; if ( conditions.indexOf(';') == -1 ) { conditions = atob( conditions ); var bt_cc_conditions = conditions.split(/\r?\n/); } else { var bt_cc_conditions = conditions.split("#bt_cc_nl#"); } $.each( bt_cc_conditions, function( index, value ) { if ( bt_cc_conditions[index] != undefined ) { var bt_cc_single_condition = bt_cc_conditions[index].split(";"); var eval_action = bt_cc_single_condition[2]; if ( bt_cc_single_condition[3] == 'lock' ) { eval_action += '.bt_cc_lock()'; } else if ( bt_cc_single_condition[3] == 'unlock' ) { eval_action += '.bt_cc_unlock()'; } if ( bt_cc_single_condition[0] != '' ) { var eval_code = 'if ( ' + val + decodeURIComponent( bt_cc_single_condition[0] ) + ' ) { $(\'#' + bt_cc_single_condition[1] + '\').' + eval_action + '; }' ; eval( eval_code ); } } }); return false; } // Paypal calculation window.bt_paypal_items = function( c ) { $( c ).each(function() { if ( $( this ).find( '.btPayPalButton' ).length > 0 ) { var form = $( this ).find( '.btPayPalButton' ).next(); form.find( '.btPayPalItem' ).remove(); var x = 0; // items not in multiply and group $( this ).find( '.btQuoteBookingForm' ).find( '.btQuoteItem' ).not( '.btQuoteMBlock .btQuoteItem' ).not( '.btQuoteGBlock .btQuoteItem' ).each(function() { var unit_price = 0; var val = 0; var selected_name = ''; $( this ).find( '.btQuoteText' ).each(function() { unit_price = bt_parse_float( $( this ).data( 'price' ) ); val = bt_parse_float( $( this ).val() ); }); $( this ).find( '.btQuoteSelect' ).find( '._msddli_.selected' ).each(function() { unit_price = bt_parse_float( $( this ).data( 'value' ) ); val = 1; selected_name = $( this ).find( '.ddlabel' )[0].innerHTML; if ( $( this ).is( ':first-child' ) ) { selected_name = ''; } }); var is_slider = false; $( this ).find( '.btQuoteSlider' ).each(function() { unit_price = bt_parse_float( $( this ).data( 'price' ) ); val = bt_cc_get_slider_value ( $( this ) ); is_slider = true; }); $( this ).find( '.btQuoteSwitch' ).each(function() { if ( $( this ).hasClass( 'on' ) ) { unit_price = bt_parse_float( $( this ).data( 'on' ) ); } else { unit_price = bt_parse_float( $( this ).data( 'off' ) ); } val = 1; }); var label = $( this ).find( 'label' ).html(); if ( is_slider ) { label = label + ': ' + val; } if ( selected_name != '' ) { selected_name = selected_name.replace( '', '/' ); selected_name = selected_name.replace( '', '' ); if ( label.endsWith( '?' ) || label.endsWith( ':' ) ) { label = label + ' ' + selected_name; } else { label = label + ': ' + selected_name; } } val = val * unit_price; if ( label !== undefined && val > 0 ) { x++; val = val.toFixed( 2 ); form.append( '' ); } }); // multiply $( this ).find( '.btQuoteBookingForm' ).find( '.btQuoteMBlock' ).each(function() { var m_total = 1; var m_first = true; var m_val = 0; var selected_name = ''; var label = ''; $( this ).find( '.btQuoteItem' ).each(function() { $( this ).find( '.btQuoteText' ).each(function() { var unit_price = bt_parse_float( $( this ).data( 'price' ) ); var val = bt_parse_float( $( this ).val() ); val = val * unit_price; if ( m_first ) { m_val = val; label = $( this ).closest( '.btQuoteItem' ).find( 'label' ).html(); } else { m_total *= val; } m_first = false; }); $( this ).find( '.btQuoteSelect' ).find( '._msddli_.selected' ).each(function() { var val = bt_parse_float( $( this ).data( 'value' ) ); if ( m_first ) { m_val = val; label = $( this ).closest( '.btQuoteItem' ).find( 'label' ).html(); selected_name = $( this ).find( '.ddlabel' )[0].innerHTML; selected_name = selected_name.substring( 0, selected_name.indexOf( ' 0 && m_val > 0 ) { x++; m_val = m_val.toFixed( 2 ); form.append( '' ); } }); // group $( this ).find( '.btQuoteBookingForm' ).find( '.btQuoteGBlock' ).each(function() { var eval_code = $( this ).data( 'eval' ); var paypal_label = $( this ).data( 'paypal_label' ); var group_array = []; $( this ).find( '.btQuoteItem' ).each(function() { var val; $( this ).find( '.btQuoteText' ).each(function() { var unit_price = bt_parse_float( $( this ).data( 'price' ) ); val = bt_parse_float( $( this ).val() ); val = val * unit_price; }); $( this ).find( '.btQuoteSelect' ).find( '._msddli_.selected' ).each(function() { val = bt_parse_float( $( this ).data( 'value' ) ); }); $( this ).find( '.btQuoteSlider' ).each(function() { var unit_price = bt_parse_float( $( this ).data( 'price' ) ); // val = bt_parse_float( $( this ).slider( 'value' ) ); val = bt_cc_get_slider_value ( $( this ) ); val = val * unit_price; }); $( this ).find( '.btQuoteSwitch' ).each(function() { if ( $( this ).hasClass( 'on' ) ) { val = bt_parse_float( $( this ).data( 'on' ) ); } else { val = bt_parse_float( $( this ).data( 'off' ) ); } }); group_array.push( val ); }); var patt = /\$\d+/igm; var match = eval_code.match( patt ); if ( match === null ) { eval_code = atob( eval_code ); match = eval_code.match( patt ); } if ( match === null ) { return; } for ( var i = 0; i < match.length; i++ ) { eval_code = eval_code.replace( match[ i ], group_array[ i ] ); } var g_total = eval( '(function() {' + decodeURIComponent(eval_code) + '}())' ); if ( paypal_label != '' && g_total > 0 ) { x++; g_total = g_total.toFixed( 2 ); form.append( '' ); } }); } }); } // Total calculation window.bt_quote_total = function( c ) { var c = $( c ); total = 0; c.find( '.btQuoteText' ).not( '.btQuoteMBlock .btQuoteText' ).not( '.btQuoteGBlock .btQuoteText' ).each(function() { var unit_price = bt_parse_float( $( this ).data( 'price' ) ); var val = bt_parse_float( $( this ).val() ); val = val * unit_price; total += val; }); c.find( '.btQuoteSelect' ).not( '.btQuoteMBlock .btQuoteSelect' ).not( '.btQuoteGBlock .btQuoteSelect' ).find( '._msddli_.selected' ).each(function() { var val = bt_parse_float( $( this ).data( 'value' ) ); total += val; }); c.find( '.btQuoteSlider' ).not( '.btQuoteMBlock .btQuoteSlider' ).not( '.btQuoteGBlock .btQuoteSlider' ).each(function() { var unit_price = bt_parse_float( $( this ).data( 'price' ) ); var offset = bt_parse_float( $( this ).data( 'offset' ) ); var val = bt_cc_get_slider_value ( $( this ) ); val = val * unit_price; total += val; if ( ! $( this ).closest( '.btQuoteBooking' ).find( '.btPayPalButton' ).length > 0 ) { total += offset; } }); c.find( '.btQuoteSwitch' ).not( '.btQuoteMBlock .btQuoteSwitch' ).not( '.btQuoteGBlock .btQuoteSwitch' ).each(function() { if ( $( this ).hasClass( 'on' ) ) { total += bt_parse_float( $( this ).data( 'on' ) ); } else { total += bt_parse_float( $( this ).data( 'off' ) ); } }); // multiply c.find( '.btQuoteMBlock' ).each(function() { var m_total = 0; var m_first = true; $( this ).find( '.btQuoteText' ).each(function() { var unit_price = bt_parse_float( $( this ).data( 'price' ) ); var val = bt_parse_float( $( this ).val() ); val = val * unit_price; if ( m_first ) { m_total = val; } else { m_total *= val; } m_first = false; }); $( this ).find( '.btQuoteSelect' ).find( '._msddli_.selected' ).each(function() { var val = bt_parse_float( $( this ).data( 'value' ) ); if ( m_first ) { m_total = val; } else { m_total *= val; } m_first = false; }); $( this ).find( '.btQuoteSlider' ).each(function() { var unit_price = bt_parse_float( $( this ).data( 'price' ) ); var offset = bt_parse_float( $( this ).data( 'offset' ) ); //var val = bt_parse_float( $( this ).slider( 'value' ) ); var val = bt_cc_get_slider_value ( $( this ) ); val = val * unit_price; if ( m_first ) { m_total = val; } else { m_total *= val; } m_total += offset; m_first = false; }); $( this ).find( '.btQuoteSwitch' ).each(function() { if ( $( this ).hasClass( 'on' ) ) { var val = bt_parse_float( $( this ).data( 'on' ) ); } else { var val = bt_parse_float( $( this ).data( 'off' ) ); } if ( m_first ) { m_total = val; } else { m_total *= val; } m_first = false; }); total += m_total; }); // group c.find( '.btQuoteGBlock' ).each(function() { var eval_code = $( this ).data( 'eval' ); var group_array = []; $( this ).find( '.btQuoteItem .btQuoteItemInput' ).each(function() { var val = 0; $( this ).find( '.btQuoteText' ).each(function() { var unit_price = bt_parse_float( $( this ).data( 'price' ) ); val = bt_parse_float( $( this ).val() ); val = val * unit_price; }); $( this ).find( '.btQuoteSelect' ).find( '._msddli_.selected' ).each(function() { val = bt_parse_float( $( this ).data( 'value' ) ); }); $( this ).find( '.btQuoteSlider' ).each(function() { var unit_price = bt_parse_float( $( this ).data( 'price' ) ); var offset = bt_parse_float( $( this ).data( 'offset' ) ); val = bt_cc_get_slider_value( $( this ) ); val = val * unit_price; }); $( this ).find( '.btQuoteSwitch' ).each(function() { if ( $( this ).hasClass( 'on' ) ) { val = bt_parse_float( $( this ).data( 'on' ) ); } else { val = bt_parse_float( $( this ).data( 'off' ) ); } }); group_array.push( val ); }); var patt = /\$\d+/igm; var match = eval_code.match( patt ); if ( match === null ) { eval_code = atob( eval_code ); match = eval_code.match( patt ); } if ( match === null ) { return; } for ( var i = 0; i < match.length; i++ ) { eval_code = eval_code.replace( match[ i ], group_array[ i ] ); } var g_total = eval( '(function() {' + decodeURIComponent( eval_code ) + '}())' ); total += g_total; }); total = total.toFixed( 2 ).replace( /(\d)(?=(\d{3})+\.)/g, '$1,' ); c.find( '.btQuoteTotalCalc' ).html( total ); c.find( '.btQuoteTotalCalc' ).data( 'total', total ); } // Init functions // Dropdown init window.bt_cc_init_dropdown = function( elem, id, index ) { elem.set( "selectedIndex", index ); var ui2 = $( id ).find( '._msddli_.selected' ); var val = elem.getData().data.value; ui2.data( 'value', val ); bt_cc_eval_conditions( val, ui2.closest( '.btQuoteSelect' ).data( 'condition' ) ); bt_quote_total( ui2.closest( '.btQuoteBooking' ) ); bt_paypal_items( ui2.closest( '.btQuoteBooking' ) ); } // Base init window.bt_cc_init = function( ) { $( ".btQuoteBooking" ).each(function( index ) { var c = $( this ); // Init elements c.find( '.btContactDate' ).datepicker({ beforeShow: function( input, inst ) { $( '.ui-datepicker' ).addClass( 'btDatePicker' ); } }); // console.log(window.is_rtl); // console.log(window.rtl_direction); c.find( '.btQuoteSlider' ).each(function() { $( this ).slider({ min: ! window.is_rtl ? $( this ).data( 'min' ) : -$( this ).data( 'max' ), max: ! window.is_rtl ? $( this ).data( 'max' ) : -$( this ).data( 'min' ), step: $( this ).data( 'step' ), value: ! window.is_rtl ? $( this ).data( 'value' ) : -$( this ).data( 'value' ), change: function( event, ui ) { // console.log( 'ui.value change: ' + ui.value ); $( this ).find('.btQuoteSliderValue').html( window.rtl_direction * $( this ).slider( 'value' ) ); bt_cc_eval_conditions( window.rtl_direction * $( this ).slider( 'value' ), $( this ).data( 'condition' ) ); } }); bt_cc_eval_conditions( window.rtl_direction * $( this ).data( 'value' ), $( this ).data( 'condition' ) ); }); c.find( '.ui-slider-handle' ).each(function() { $( this ).append( $( this ).closest( '.btQuoteItemInput' ).find( $( '.btQuoteSliderValue' ) ) ); }); c.find( '.btQuoteSlider' ).each(function() { var this_slider = $( this ); $( this ).slider({ slide: function( event, ui ) { var val = window.rtl_direction * ui.value; // console.log( 'ui.value slide: ' + ui.value ); // console.log( 'val slide: ' + val ); this_slider.slider( 'value', val ); this_slider.find('.btQuoteSliderValue').html( val ); bt_quote_total( c ); bt_paypal_items( c ); } }); }); c.find( '.btQuoteSwitch' ).on( 'click', function() { if ( $( this ).hasClass( 'on' ) ) { $( this ).removeClass( 'on' ); bt_cc_eval_conditions( $( this ).data( 'off' ), $( this ).data( 'condition' ) ); } else { $( this ).addClass( 'on' ); bt_cc_eval_conditions( $( this ).data( 'on' ), $( this ).data( 'condition' ) ); } bt_quote_total( c ); bt_paypal_items( c ); }); c.find( '.btQuoteSwitch' ).each( function() { if ( $( this ).hasClass( 'on' ) ) { bt_cc_eval_conditions( $( this ).data( 'on' ), $( this ).data( 'condition' ) ); } else { bt_cc_eval_conditions( $( this ).data( 'off' ), $( this ).data( 'condition' ) ); } }); c.find( '.btPayPalButton' ).on( 'click', function() { $( this ).next().submit(); }); c.find( '.btQuoteText' ).each(function() { bt_cc_eval_conditions( $( this ).val(), $( this ).data( 'condition' ) ); }); c.find( '.btQuoteText' ).keyup(function() { bt_quote_total( c ); bt_paypal_items( c ); bt_cc_eval_conditions( $( this ).val(), $( this ).data( 'condition' ) ); }); c.find( '.btContactNext' ).click(function() { $( 'html, body' ).delay( 1000 ).animate({ scrollTop: ( $( this ).closest( '.btQuoteBooking' ).find( '.btTotalQuoteContactGroup' ).offset().top - 30 ) }, 400 ); var contact_group = $( this ).closest( '.btQuoteBooking' ).find( '.btTotalQuoteContactGroup' ); $( this ).closest( '.btQuoteBooking' ).find( '.btTotalQuoteContactGroup' ).addClass( 'btActive' ); $( this ).closest( '.btQuoteBooking' ).find( '.btQuoteBookingForm' ).removeClass( 'btActive' ); }); c.find( '.btContactSubmit' ).click(function() { c.find( '.btContactFieldError' ).removeClass( 'btContactFieldError' ); var val = true; c.find( '.btContactField' ).each(function() { if ( $( this ).parent().hasClass( 'btContactFieldMandatory' ) && ( ( $( this ).val() == '' && ! $( this ).hasClass( 'btContactTime' ) ) || ( $( this ).hasClass( 'btContactTime' ) && $( this ).hasClass( 'btNotSelected' ) ) ) ) { $( this ).parent().addClass( 'btContactFieldError' ); val = false; } }); if ( ! val ) { c.find( '.btSubmitMessage' ).hide().html( c.data( 'message_mandatory' ) ).fadeIn(); return false; } var quote = ''; var back = 0; var bt_is_odd = function( n ) { return ( n % 2 ) == 1; } c.find( '.btQuoteItem' ).each(function() { back++; var item_val = 0; var selected_name = ''; $( this ).find( '.btQuoteText' ).each(function() { item_val = bt_parse_float( $( this ).val() ); }); $( this ).find( '.btQuoteSelect' ).find( '._msddli_.selected' ).each(function() { selected_name = $( this ).find( '.ddlabel' )[0].innerHTML; if ( $( this ).is( ':first-child' ) ) { selected_name = ''; } item_val = bt_parse_float( $( this ).data( 'value' ) ); }); var is_slider = false; var slider_val; $( this ).find( '.btQuoteSlider' ).each(function() { var unit_price = bt_parse_float( $( this ).data( 'price' ) ); // slider_val = bt_parse_float( $( this ).slider( 'value' ) ); slider_val = bt_cc_get_slider_value ( $( this ) ); item_val = slider_val * unit_price; is_slider = true; }); $( this ).find( '.btQuoteSwitch' ).each(function() { if ( $( this ).hasClass( 'on' ) ) { item_val = bt_parse_float( $( this ).data( 'on' ) ); } else { item_val = bt_parse_float( $( this ).data( 'off' ) ); } }); var label = $( this ).find( 'label' ).html(); if ( is_slider ) { label = label + ': ' + slider_val; } if ( selected_name != '' ) { selected_name = selected_name.replace( '', '/' ); selected_name = selected_name.replace( '', '' ); label = label + ': ' + selected_name; } var background = ''; if ( bt_is_odd( back ) ) background = ' ' + 'style="background:#eee;"'; item_val = item_val.toFixed( 2 ); if ( label !== undefined && label !== null ) { quote += encodeURI( '\r\n' + label + '\r\n' + item_val + '\r\n' ) + "\r\n"; } }); var recaptcha_response = ''; if ( typeof grecaptcha !== 'undefined' ) { var recaptcha_response = grecaptcha.getResponse( c.find( '.g-rec' ).data( 'widget_id' ) ); grecaptcha.reset( c.find( '.g-rec' ).data( 'widget_id' ) ); } var email_confirmation = 'no'; if ( c.find( '.bt_cc_email_confirmation' ).length ) { if ( c.find( '.bt_cc_email_confirmation' ).prop( 'checked' ) ) { email_confirmation = 'yes'; } } else { email_confirmation = 'yes'; } var data = { 'action': 'bt_cc', 'recaptcha_response': recaptcha_response, 'recaptcha_secret': c.data( 'rec_secret_key' ), 'admin_email': c.data( 'admin_email' ), 'email_client': c.data( 'email_client' ), 'currency': c.data( 'currency' ), 'currency_after': c.data( 'currency_after' ), 'email_confirmation': email_confirmation, 'url_confirmation': c.data( 'url_confirmation' ), 'subject': c.data( 'subject' ), 'quote' : quote, 'total' : c.find( '.btQuoteTotalCalc' ).data( 'total' ), 'total_text' : c.data( 'total_text' ), 'name' : c.find( '.btContactName' ).val(), 'email' : c.find( '.btContactEmail' ).val(), 'phone' : c.find( '.btContactPhone' ).val(), 'address' : c.find( '.btContactAddress' ).val(), 'date' : c.find( '.btContactDate' ).val(), 'time' : c.find( '.btContactTime ._msddli_.selected .ddlabel' ).html(), 'date_text': c.data( 'date_text' ), 'time_text': c.data( 'time_text' ), 'message' : c.find( '.btContactMessage' ).val() }; c.find( '.btSubmitMessage' ).hide().html( c.data( 'message_please_wait' ) ).fadeIn(); $.ajax({ type: 'POST', url: c.data( 'url_ajax' ), data: data, async: true, success: function( response ) { response = $.trim( response ); if ( response == 'ok' ) { if ( c.data( 'url_confirmation' ) == "" || c.data( 'url_confirmation' ) == null ) { c.find( '.btSubmitMessage' ).hide().html( c.data( 'message_success' ) ).fadeIn(); } else { window.location = c.data( 'url_confirmation' ); } } else { c.find( '.btSubmitMessage' ).hide().html( c.data( 'message_error' ) ).fadeIn(); } }, error: function( xhr, status, error ) { c.find( '.btSubmitMessage' ).hide().html( c.data( 'message_error' ) ).fadeIn(); } }); return false; }); // CF 7 support c.find( '.wpcf7-submit' ).click(function() { var val = true; var quote = ''; c.find( '.btQuoteItem' ).each(function() { var item_val = 0; var selected_name = ''; $( this ).find( '.btQuoteText' ).each(function() { item_val = bt_parse_float( $( this ).val() ); }); $( this ).find( '.btQuoteSelect' ).find( '._msddli_.selected' ).each(function() { selected_name = $( this ).find( '.ddlabel' )[0].innerHTML; if ( $( this ).is( ':first-child' ) ) { selected_name = ''; } item_val = bt_parse_float( $( this ).data( 'value' ) ); }); var is_slider = false; var slider_val; $( this ).find( '.btQuoteSlider' ).each(function() { var unit_price = bt_parse_float( $( this ).data( 'price' ) ); // slider_val = bt_parse_float( $( this ).slider( 'value' ) ); slider_val = bt_cc_get_slider_value ( $( this ) ); item_val = slider_val * unit_price; is_slider = true; }); $( this ).find( '.btQuoteSwitch' ).each(function() { if ( $( this ).hasClass( 'on' ) ) { item_val = bt_parse_float( $( this ).data( 'on' ) ); } else { item_val = bt_parse_float( $( this ).data( 'off' ) ); } }); var label = $( this ).find( 'label' ).html(); if ( is_slider ) { label = label + ' (' + slider_val + ') ' ; } if ( selected_name != '' ) { selected_name = selected_name.replace( '', '/' ); selected_name = selected_name.replace( '', '' ); label = label + ' (' + selected_name + ') '; } item_val = item_val.toFixed( 2 ); if ( label !== undefined && label !== null ) { quote += label + ': ' + item_val + "\r\n"; } }); quote += 'Total: ' + c.find( '.btQuoteTotalCalc' ).data( 'total' ) + "\r\n"; c.find( 'input[name=bt-cc-data]' ).val( quote ); //alert( c.find( '[name=bt-cc-data]' ).val() ); }); var total = 0; total = total.toFixed( 2 ); bt_quote_total( c ); bt_paypal_items( c ); }); } // --------------- // Functions end // --------------- // Init var bt_cc_init_finished = false; document.addEventListener('readystatechange', function() { if ( ! bt_cc_init_finished && document.readyState === 'complete' ) { // base variables window.is_rtl = $( 'body' ).hasClass( 'rtl' ); window.rtl_direction = !window.is_rtl ? 1 : -1; // console.log( 'init_is_rtl: ' + window.is_rtl ); // console.log( 'init_rtl_direction: ' + window.rtl_direction ); bt_cc_init(); bt_cc_init_finished = true; } }, false); })( jQuery );