diff --git a/assets/js/checkout.js b/assets/js/checkout.js new file mode 100644 index 0000000..bebc6ea --- /dev/null +++ b/assets/js/checkout.js @@ -0,0 +1,25 @@ +jQuery( function( $ ) { + 'use strict'; + $( document ).on( 'click', '#mondido-checkout-btn', function (e) { + e.preventDefault(); + + var elm = $(this); + + $.ajax({ + type: 'POST', + url: WC_Gateway_Mondido_Checkout.place_order_url, + //data: $form.serialize(), + dataType: 'json', + success: function( result ) { + console.log(result); + window.location.href = result.data.redirect_url; + }//, + //error: function( jqXHR, textStatus, errorThrown ) { + // wc_checkout_form.submit_error( '
' + errorThrown + '
' ); + //} + }); + + + return; + } ); +} ); diff --git a/assets/js/iframe-resizer/ie8.polyfils.map b/assets/js/iframe-resizer/ie8.polyfils.map new file mode 100644 index 0000000..eb0ef37 --- /dev/null +++ b/assets/js/iframe-resizer/ie8.polyfils.map @@ -0,0 +1 @@ +{"version":3,"file":"ie8.polyfils.min.js","sources":["../src/ie8.polyfils.js"],"names":["Array","prototype","forEach","fun","this","TypeError","t","Object","len","length","thisArg","arguments","i","call","Function","bind","oThis","aArgs","slice","fToBind","fNOP","fBound","apply","concat","callback","O","k"],"mappings":";;AAOMA,MAAMC,UAAUC,UACrBF,MAAMC,UAAUC,QAAU,SAASC,GAClC,YACA,IAAa,SAATC,MAA4B,OAATA,MAAgC,kBAARD,GAAoB,KAAM,IAAIE,UAO7E,KAAK,GAJJC,GAAIC,OAAOH,MACXI,EAAMF,EAAEG,SAAW,EACnBC,EAAUC,UAAUF,QAAU,EAAIE,UAAU,GAAK,OAEzCC,EAAI,EAAOJ,EAAJI,EAASA,IACpBA,IAAKN,IACRH,EAAIU,KAAKH,EAASJ,EAAEM,GAAIA,EAAGN,KAK1BQ,SAASb,UAAUc,OACtBD,SAASb,UAAUc,KAAO,SAASC,GACjC,GAAoB,kBAATZ,MAGT,KAAM,IAAIC,WAAU,uEAGtB,IAAIY,GAAUjB,MAAMC,UAAUiB,MAAML,KAAKF,UAAW,GAChDQ,EAAUf,KACVgB,EAAU,aACVC,EAAU,WACR,MAAOF,GAAQG,MAAMlB,eAAgBgB,GAAOhB,KAAOY,EAC5CC,EAAMM,OAAOvB,MAAMC,UAAUiB,MAAML,KAAKF,aAMrD,OAHAS,GAAKnB,UAAYG,KAAKH,UACtBoB,EAAOpB,UAAY,GAAImB,GAEhBC,IAINrB,MAAMC,UAAUC,UACnBF,MAAMC,UAAUC,QAAU,SAASsB,EAAUd,GAC3C,GAAa,OAATN,KAAe,KAAM,IAAIC,WAAU,+BACvC,IAAwB,kBAAbmB,GAAyB,KAAM,IAAInB,WAAUmB,EAAW,qBAMnE,KAAK,GAHHC,GAAIlB,OAAOH,MACXI,EAAMiB,EAAEhB,SAAW,EAEZiB,EAAE,EAAQlB,EAAJkB,EAAUA,IACnBA,IAAKD,IACPD,EAASX,KAAKH,EAASe,EAAEC,GAAIA,EAAGD","sourcesContent":["/*\n * IE8 Polyfils for iframeResizer.js\n *\n * Public domain code - Mozilla Contributors\n * https://developer.mozilla.org/\n */\n\n if (!Array.prototype.forEach){\n\tArray.prototype.forEach = function(fun /*, thisArg */){\n\t\t\"use strict\";\n\t\tif (this === void 0 || this === null || typeof fun !== \"function\") throw new TypeError();\n\n\t\tvar\n\t\t\tt = Object(this),\n\t\t\tlen = t.length >>> 0,\n\t\t\tthisArg = arguments.length >= 2 ? arguments[1] : void 0;\n\n\t\tfor (var i = 0; i < len; i++)\n\t\t\tif (i in t)\n\t\t\t\tfun.call(thisArg, t[i], i, t);\n\t};\n}\n\n\nif (!Function.prototype.bind) {\n Function.prototype.bind = function(oThis) {\n if (typeof this !== 'function') {\n // closest thing possible to the ECMAScript 5\n // internal IsCallable function\n throw new TypeError('Function.prototype.bind - what is trying to be bound is not callable');\n }\n\n var aArgs = Array.prototype.slice.call(arguments, 1),\n fToBind = this,\n fNOP = function() {},\n fBound = function() {\n return fToBind.apply(this instanceof fNOP ? this : oThis,\n aArgs.concat(Array.prototype.slice.call(arguments)));\n };\n\n fNOP.prototype = this.prototype;\n fBound.prototype = new fNOP();\n\n return fBound;\n };\n}\n\nif (!Array.prototype.forEach) {\n Array.prototype.forEach = function(callback, thisArg) {\n if (this === null) throw new TypeError(' this is null or not defined');\n if (typeof callback !== 'function') throw new TypeError(callback + ' is not a function');\n\n var\n O = Object(this),\n len = O.length >>> 0;\n\n for (var k=0 ; k < len ; k++) {\n if (k in O)\n callback.call(thisArg, O[k], k, O);\n }\n };\n}\n\n\n"]} \ No newline at end of file diff --git a/assets/js/iframe-resizer/ie8.polyfils.min.js b/assets/js/iframe-resizer/ie8.polyfils.min.js new file mode 100644 index 0000000..5836bac --- /dev/null +++ b/assets/js/iframe-resizer/ie8.polyfils.min.js @@ -0,0 +1,4 @@ +// IE8 polyfils for iframeResizer.js + +Array.prototype.forEach||(Array.prototype.forEach=function(a){"use strict";if(void 0===this||null===this||"function"!=typeof a)throw new TypeError;for(var b=Object(this),c=b.length>>>0,d=arguments.length>=2?arguments[1]:void 0,e=0;c>e;e++)e in b&&a.call(d,b[e],e,b)}),Function.prototype.bind||(Function.prototype.bind=function(a){if("function"!=typeof this)throw new TypeError("Function.prototype.bind - what is trying to be bound is not callable");var b=Array.prototype.slice.call(arguments,1),c=this,d=function(){},e=function(){return c.apply(this instanceof d?this:a,b.concat(Array.prototype.slice.call(arguments)))};return d.prototype=this.prototype,e.prototype=new d,e}),Array.prototype.forEach||(Array.prototype.forEach=function(a,b){if(null===this)throw new TypeError(" this is null or not defined");if("function"!=typeof a)throw new TypeError(a+" is not a function");for(var c=Object(this),d=c.length>>>0,e=0;d>e;e++)e in c&&a.call(b,c[e],e,c)}); +//# sourceMappingURL=ie8.polyfils.map \ No newline at end of file diff --git a/assets/js/iframe-resizer/iframeResizer.contentWindow.js b/assets/js/iframe-resizer/iframeResizer.contentWindow.js new file mode 100644 index 0000000..254ee50 --- /dev/null +++ b/assets/js/iframe-resizer/iframeResizer.contentWindow.js @@ -0,0 +1,1106 @@ +/* + * File: iframeResizer.contentWindow.js + * Desc: Include this file in any page being loaded into an iframe + * to force the iframe to resize to the content size. + * Requires: iframeResizer.js on host page. + * Doc: https://github.com/davidjbradshaw/iframe-resizer + * Author: David J. Bradshaw - dave@bradshaw.net + * Contributor: Jure Mav - jure.mav@gmail.com + * Contributor: Ian Caunce - ian@hallnet.co.uk + */ + + +;(function(undefined) { + 'use strict'; + + if(typeof window === 'undefined') return; // don't run for server side render + + var + autoResize = true, + base = 10, + bodyBackground = '', + bodyMargin = 0, + bodyMarginStr = '', + bodyObserver = null, + bodyPadding = '', + calculateWidth = false, + doubleEventList = {'resize':1,'click':1}, + eventCancelTimer = 128, + firstRun = true, + height = 1, + heightCalcModeDefault = 'bodyOffset', + heightCalcMode = heightCalcModeDefault, + initLock = true, + initMsg = '', + inPageLinks = {}, + interval = 32, + intervalTimer = null, + logging = false, + msgID = '[iFrameSizer]', //Must match host page msg ID + msgIdLen = msgID.length, + myID = '', + observer = null, + resetRequiredMethods = {max:1,min:1,bodyScroll:1,documentElementScroll:1}, + resizeFrom = 'child', + sendPermit = true, + target = window.parent, + targetOriginDefault = '*', + tolerance = 0, + triggerLocked = false, + triggerLockedTimer = null, + throttledTimer = 16, + width = 1, + widthCalcModeDefault = 'scroll', + widthCalcMode = widthCalcModeDefault, + win = window, + messageCallback = function(){ warn('MessageCallback function not defined'); }, + readyCallback = function(){}, + pageInfoCallback = function(){}, + customCalcMethods = { + height: function(){ + warn('Custom height calculation function not defined'); + return document.documentElement.offsetHeight; + }, + width: function(){ + warn('Custom width calculation function not defined'); + return document.body.scrollWidth; + } + }, + eventHandlersByName = {}; + + + function addEventListener(el,evt,func){ + /* istanbul ignore else */ // Not testable in phantonJS + if ('addEventListener' in window){ + el.addEventListener(evt,func, false); + } else if ('attachEvent' in window){ //IE + el.attachEvent('on'+evt,func); + } + } + + function removeEventListener(el,evt,func){ + /* istanbul ignore else */ // Not testable in phantonJS + if ('removeEventListener' in window){ + el.removeEventListener(evt,func, false); + } else if ('detachEvent' in window){ //IE + el.detachEvent('on'+evt,func); + } + } + + function capitalizeFirstLetter(string) { + return string.charAt(0).toUpperCase() + string.slice(1); + } + + //Based on underscore.js + function throttle(func) { + var + context, args, result, + timeout = null, + previous = 0, + later = function() { + previous = getNow(); + timeout = null; + result = func.apply(context, args); + if (!timeout) { + context = args = null; + } + }; + + return function() { + var now = getNow(); + + if (!previous) { + previous = now; + } + + var remaining = throttledTimer - (now - previous); + + context = this; + args = arguments; + + if (remaining <= 0 || remaining > throttledTimer) { + if (timeout) { + clearTimeout(timeout); + timeout = null; + } + + previous = now; + result = func.apply(context, args); + + if (!timeout) { + context = args = null; + } + + } else if (!timeout) { + timeout = setTimeout(later, remaining); + } + + return result; + }; + } + + var getNow = Date.now || function() { + /* istanbul ignore next */ // Not testable in PhantonJS + return new Date().getTime(); + }; + + function formatLogMsg(msg){ + return msgID + '[' + myID + ']' + ' ' + msg; + } + + function log(msg){ + if (logging && ('object' === typeof window.console)){ + console.log(formatLogMsg(msg)); + } + } + + function warn(msg){ + if ('object' === typeof window.console){ + console.warn(formatLogMsg(msg)); + } + } + + + function init(){ + readDataFromParent(); + log('Initialising iFrame ('+location.href+')'); + readDataFromPage(); + setMargin(); + setBodyStyle('background',bodyBackground); + setBodyStyle('padding',bodyPadding); + injectClearFixIntoBodyElement(); + checkHeightMode(); + checkWidthMode(); + stopInfiniteResizingOfIFrame(); + setupPublicMethods(); + startEventListeners(); + inPageLinks = setupInPageLinks(); + sendSize('init','Init message from host page'); + readyCallback(); + } + + function readDataFromParent(){ + + function strBool(str){ + return 'true' === str ? true : false; + } + + var data = initMsg.substr(msgIdLen).split(':'); + + myID = data[0]; + bodyMargin = (undefined !== data[1]) ? Number(data[1]) : bodyMargin; //For V1 compatibility + calculateWidth = (undefined !== data[2]) ? strBool(data[2]) : calculateWidth; + logging = (undefined !== data[3]) ? strBool(data[3]) : logging; + interval = (undefined !== data[4]) ? Number(data[4]) : interval; + autoResize = (undefined !== data[6]) ? strBool(data[6]) : autoResize; + bodyMarginStr = data[7]; + heightCalcMode = (undefined !== data[8]) ? data[8] : heightCalcMode; + bodyBackground = data[9]; + bodyPadding = data[10]; + tolerance = (undefined !== data[11]) ? Number(data[11]) : tolerance; + inPageLinks.enable = (undefined !== data[12]) ? strBool(data[12]): false; + resizeFrom = (undefined !== data[13]) ? data[13] : resizeFrom; + widthCalcMode = (undefined !== data[14]) ? data[14] : widthCalcMode; + } + + function readDataFromPage(){ + function readData(){ + var data = window.iFrameResizer; + + log('Reading data from page: ' + JSON.stringify(data)); + + messageCallback = ('messageCallback' in data) ? data.messageCallback : messageCallback; + readyCallback = ('readyCallback' in data) ? data.readyCallback : readyCallback; + targetOriginDefault = ('targetOrigin' in data) ? data.targetOrigin : targetOriginDefault; + heightCalcMode = ('heightCalculationMethod' in data) ? data.heightCalculationMethod : heightCalcMode; + widthCalcMode = ('widthCalculationMethod' in data) ? data.widthCalculationMethod : widthCalcMode; + } + + function setupCustomCalcMethods(calcMode, calcFunc){ + if ('function' === typeof calcMode) { + log('Setup custom ' + calcFunc + 'CalcMethod'); + customCalcMethods[calcFunc] = calcMode; + calcMode = 'custom'; + } + + return calcMode; + } + + if(('iFrameResizer' in window) && (Object === window.iFrameResizer.constructor)) { + readData(); + heightCalcMode = setupCustomCalcMethods(heightCalcMode, 'height'); + widthCalcMode = setupCustomCalcMethods(widthCalcMode, 'width'); + } + + log('TargetOrigin for parent set to: ' + targetOriginDefault); + } + + + function chkCSS(attr,value){ + if (-1 !== value.indexOf('-')){ + warn('Negative CSS value ignored for '+attr); + value=''; + } + return value; + } + + function setBodyStyle(attr,value){ + if ((undefined !== value) && ('' !== value) && ('null' !== value)){ + document.body.style[attr] = value; + log('Body '+attr+' set to "'+value+'"'); + } + } + + function setMargin(){ + //If called via V1 script, convert bodyMargin from int to str + if (undefined === bodyMarginStr){ + bodyMarginStr = bodyMargin+'px'; + } + + setBodyStyle('margin',chkCSS('margin',bodyMarginStr)); + } + + function stopInfiniteResizingOfIFrame(){ + document.documentElement.style.height = ''; + document.body.style.height = ''; + log('HTML & body height set to "auto"'); + } + + + function manageTriggerEvent(options){ + + var listener = { + add: function(eventName){ + function handleEvent(){ + sendSize(options.eventName,options.eventType); + } + + eventHandlersByName[eventName] = handleEvent; + + addEventListener(window,eventName,handleEvent); + }, + remove: function(eventName){ + var handleEvent = eventHandlersByName[eventName]; + delete eventHandlersByName[eventName]; + + removeEventListener(window,eventName,handleEvent); + } + }; + + if(options.eventNames && Array.prototype.map){ + options.eventName = options.eventNames[0]; + options.eventNames.map(listener[options.method]); + } else { + listener[options.method](options.eventName); + } + + log(capitalizeFirstLetter(options.method) + ' event listener: ' + options.eventType); + } + + function manageEventListeners(method){ + manageTriggerEvent({method:method, eventType: 'Animation Start', eventNames: ['animationstart','webkitAnimationStart'] }); + manageTriggerEvent({method:method, eventType: 'Animation Iteration', eventNames: ['animationiteration','webkitAnimationIteration'] }); + manageTriggerEvent({method:method, eventType: 'Animation End', eventNames: ['animationend','webkitAnimationEnd'] }); + manageTriggerEvent({method:method, eventType: 'Input', eventName: 'input' }); + manageTriggerEvent({method:method, eventType: 'Mouse Up', eventName: 'mouseup' }); + manageTriggerEvent({method:method, eventType: 'Mouse Down', eventName: 'mousedown' }); + manageTriggerEvent({method:method, eventType: 'Orientation Change', eventName: 'orientationchange' }); + manageTriggerEvent({method:method, eventType: 'Print', eventName: ['afterprint', 'beforeprint'] }); + manageTriggerEvent({method:method, eventType: 'Ready State Change', eventName: 'readystatechange' }); + manageTriggerEvent({method:method, eventType: 'Touch Start', eventName: 'touchstart' }); + manageTriggerEvent({method:method, eventType: 'Touch End', eventName: 'touchend' }); + manageTriggerEvent({method:method, eventType: 'Touch Cancel', eventName: 'touchcancel' }); + manageTriggerEvent({method:method, eventType: 'Transition Start', eventNames: ['transitionstart','webkitTransitionStart','MSTransitionStart','oTransitionStart','otransitionstart'] }); + manageTriggerEvent({method:method, eventType: 'Transition Iteration', eventNames: ['transitioniteration','webkitTransitionIteration','MSTransitionIteration','oTransitionIteration','otransitioniteration'] }); + manageTriggerEvent({method:method, eventType: 'Transition End', eventNames: ['transitionend','webkitTransitionEnd','MSTransitionEnd','oTransitionEnd','otransitionend'] }); + if('child' === resizeFrom){ + manageTriggerEvent({method:method, eventType: 'IFrame Resized', eventName: 'resize' }); + } + } + + function checkCalcMode(calcMode,calcModeDefault,modes,type){ + if (calcModeDefault !== calcMode){ + if (!(calcMode in modes)){ + warn(calcMode + ' is not a valid option for '+type+'CalculationMethod.'); + calcMode=calcModeDefault; + } + log(type+' calculation method set to "'+calcMode+'"'); + } + + return calcMode; + } + + function checkHeightMode(){ + heightCalcMode = checkCalcMode(heightCalcMode,heightCalcModeDefault,getHeight,'height'); + } + + function checkWidthMode(){ + widthCalcMode = checkCalcMode(widthCalcMode,widthCalcModeDefault,getWidth,'width'); + } + + function startEventListeners(){ + if ( true === autoResize ) { + manageEventListeners('add'); + setupMutationObserver(); + } + else { + log('Auto Resize disabled'); + } + } + + function stopMsgsToParent(){ + log('Disable outgoing messages'); + sendPermit = false; + } + + function removeMsgListener(){ + log('Remove event listener: Message'); + removeEventListener(window, 'message', receiver); + } + + function disconnectMutationObserver(){ + if (null !== bodyObserver){ + /* istanbul ignore next */ // Not testable in PhantonJS + bodyObserver.disconnect(); + } + } + + function stopEventListeners(){ + manageEventListeners('remove'); + disconnectMutationObserver(); + clearInterval(intervalTimer); + } + + function teardown(){ + stopMsgsToParent(); + removeMsgListener(); + if (true === autoResize) stopEventListeners(); + } + + function injectClearFixIntoBodyElement(){ + var clearFix = document.createElement('div'); + clearFix.style.clear = 'both'; + clearFix.style.display = 'block'; //Guard against this having been globally redefined in CSS. + document.body.appendChild(clearFix); + } + + function setupInPageLinks(){ + + function getPagePosition (){ + return { + x: (window.pageXOffset !== undefined) ? window.pageXOffset : document.documentElement.scrollLeft, + y: (window.pageYOffset !== undefined) ? window.pageYOffset : document.documentElement.scrollTop + }; + } + + function getElementPosition(el){ + var + elPosition = el.getBoundingClientRect(), + pagePosition = getPagePosition(); + + return { + x: parseInt(elPosition.left,10) + parseInt(pagePosition.x,10), + y: parseInt(elPosition.top,10) + parseInt(pagePosition.y,10) + }; + } + + function findTarget(location){ + function jumpToTarget(target){ + var jumpPosition = getElementPosition(target); + + log('Moving to in page link (#'+hash+') at x: '+jumpPosition.x+' y: '+jumpPosition.y); + sendMsg(jumpPosition.y, jumpPosition.x, 'scrollToOffset'); // X&Y reversed at sendMsg uses height/width + } + + var + hash = location.split('#')[1] || location, //Remove # if present + hashData = decodeURIComponent(hash), + target = document.getElementById(hashData) || document.getElementsByName(hashData)[0]; + + if (undefined !== target){ + jumpToTarget(target); + } else { + log('In page link (#' + hash + ') not found in iFrame, so sending to parent'); + sendMsg(0,0,'inPageLink','#'+hash); + } + } + + function checkLocationHash(){ + if ('' !== location.hash && '#' !== location.hash){ + findTarget(location.href); + } + } + + function bindAnchors(){ + function setupLink(el){ + function linkClicked(e){ + e.preventDefault(); + + /*jshint validthis:true */ + findTarget(this.getAttribute('href')); + } + + if ('#' !== el.getAttribute('href')){ + addEventListener(el,'click',linkClicked); + } + } + + Array.prototype.forEach.call( document.querySelectorAll( 'a[href^="#"]' ), setupLink ); + } + + function bindLocationHash(){ + addEventListener(window,'hashchange',checkLocationHash); + } + + function initCheck(){ //check if page loaded with location hash after init resize + setTimeout(checkLocationHash,eventCancelTimer); + } + + function enableInPageLinks(){ + /* istanbul ignore else */ // Not testable in phantonJS + if(Array.prototype.forEach && document.querySelectorAll){ + log('Setting up location.hash handlers'); + bindAnchors(); + bindLocationHash(); + initCheck(); + } else { + warn('In page linking not fully supported in this browser! (See README.md for IE8 workaround)'); + } + } + + if(inPageLinks.enable){ + enableInPageLinks(); + } else { + log('In page linking not enabled'); + } + + return { + findTarget:findTarget + }; + } + + function setupPublicMethods(){ + log('Enable public methods'); + + win.parentIFrame = { + + autoResize: function autoResizeF(resize){ + if (true === resize && false === autoResize) { + autoResize=true; + startEventListeners(); + //sendSize('autoResize','Auto Resize enabled'); + } else if (false === resize && true === autoResize) { + autoResize=false; + stopEventListeners(); + } + + return autoResize; + }, + + close: function closeF(){ + sendMsg(0,0,'close'); + teardown(); + }, + + getId: function getIdF(){ + return myID; + }, + + getPageInfo: function getPageInfoF(callback){ + if ('function' === typeof callback){ + pageInfoCallback = callback; + sendMsg(0,0,'pageInfo'); + } else { + pageInfoCallback = function(){}; + sendMsg(0,0,'pageInfoStop'); + } + }, + + moveToAnchor: function moveToAnchorF(hash){ + inPageLinks.findTarget(hash); + }, + + reset: function resetF(){ + resetIFrame('parentIFrame.reset'); + }, + + scrollTo: function scrollToF(x,y){ + sendMsg(y,x,'scrollTo'); // X&Y reversed at sendMsg uses height/width + }, + + scrollToOffset: function scrollToF(x,y){ + sendMsg(y,x,'scrollToOffset'); // X&Y reversed at sendMsg uses height/width + }, + + sendMessage: function sendMessageF(msg,targetOrigin){ + sendMsg(0,0,'message',JSON.stringify(msg),targetOrigin); + }, + + setHeightCalculationMethod: function setHeightCalculationMethodF(heightCalculationMethod){ + heightCalcMode = heightCalculationMethod; + checkHeightMode(); + }, + + setWidthCalculationMethod: function setWidthCalculationMethodF(widthCalculationMethod){ + widthCalcMode = widthCalculationMethod; + checkWidthMode(); + }, + + setTargetOrigin: function setTargetOriginF(targetOrigin){ + log('Set targetOrigin: '+targetOrigin); + targetOriginDefault = targetOrigin; + }, + + size: function sizeF(customHeight, customWidth){ + var valString = ''+(customHeight?customHeight:'')+(customWidth?','+customWidth:''); + //lockTrigger(); + sendSize('size','parentIFrame.size('+valString+')', customHeight, customWidth); + } + }; + } + + function initInterval(){ + if ( 0 !== interval ){ + log('setInterval: '+interval+'ms'); + intervalTimer = setInterval(function(){ + sendSize('interval','setInterval: '+interval); + },Math.abs(interval)); + } + } + + /* istanbul ignore next */ //Not testable in PhantomJS + function setupBodyMutationObserver(){ + function addImageLoadListners(mutation) { + function addImageLoadListener(element){ + if (false === element.complete) { + log('Attach listeners to ' + element.src); + element.addEventListener('load', imageLoaded, false); + element.addEventListener('error', imageError, false); + elements.push(element); + } + } + + if (mutation.type === 'attributes' && mutation.attributeName === 'src'){ + addImageLoadListener(mutation.target); + } else if (mutation.type === 'childList'){ + Array.prototype.forEach.call( + mutation.target.querySelectorAll('img'), + addImageLoadListener + ); + } + } + + function removeFromArray(element){ + elements.splice(elements.indexOf(element),1); + } + + function removeImageLoadListener(element){ + log('Remove listeners from ' + element.src); + element.removeEventListener('load', imageLoaded, false); + element.removeEventListener('error', imageError, false); + removeFromArray(element); + } + + function imageEventTriggered(event,type,typeDesc){ + removeImageLoadListener(event.target); + sendSize(type, typeDesc + ': ' + event.target.src, undefined, undefined); + } + + function imageLoaded(event) { + imageEventTriggered(event,'imageLoad','Image loaded'); + } + + function imageError(event) { + imageEventTriggered(event,'imageLoadFailed','Image load failed'); + } + + function mutationObserved(mutations) { + sendSize('mutationObserver','mutationObserver: ' + mutations[0].target + ' ' + mutations[0].type); + + //Deal with WebKit asyncing image loading when tags are injected into the page + mutations.forEach(addImageLoadListners); + } + + function createMutationObserver(){ + var + target = document.querySelector('body'), + + config = { + attributes : true, + attributeOldValue : false, + characterData : true, + characterDataOldValue : false, + childList : true, + subtree : true + }; + + observer = new MutationObserver(mutationObserved); + + log('Create body MutationObserver'); + observer.observe(target, config); + + return observer; + } + + var + elements = [], + MutationObserver = window.MutationObserver || window.WebKitMutationObserver, + observer = createMutationObserver(); + + return { + disconnect: function (){ + if ('disconnect' in observer){ + log('Disconnect body MutationObserver'); + observer.disconnect(); + elements.forEach(removeImageLoadListener); + } + } + }; + } + + function setupMutationObserver(){ + var forceIntervalTimer = 0 > interval; + + /* istanbul ignore if */ // Not testable in PhantomJS + if (window.MutationObserver || window.WebKitMutationObserver){ + if (forceIntervalTimer) { + initInterval(); + } else { + bodyObserver = setupBodyMutationObserver(); + } + } else { + log('MutationObserver not supported in this browser!'); + initInterval(); + } + } + + + // document.documentElement.offsetHeight is not reliable, so + // we have to jump through hoops to get a better value. + function getComputedStyle(prop,el) { + /* istanbul ignore next */ //Not testable in PhantomJS + function convertUnitsToPxForIE8(value) { + var PIXEL = /^\d+(px)?$/i; + + if (PIXEL.test(value)) { + return parseInt(value,base); + } + + var + style = el.style.left, + runtimeStyle = el.runtimeStyle.left; + + el.runtimeStyle.left = el.currentStyle.left; + el.style.left = value || 0; + value = el.style.pixelLeft; + el.style.left = style; + el.runtimeStyle.left = runtimeStyle; + + return value; + } + + var retVal = 0; + el = el || document.body; + + /* istanbul ignore else */ // Not testable in phantonJS + if (('defaultView' in document) && ('getComputedStyle' in document.defaultView)) { + retVal = document.defaultView.getComputedStyle(el, null); + retVal = (null !== retVal) ? retVal[prop] : 0; + } else {//IE8 + retVal = convertUnitsToPxForIE8(el.currentStyle[prop]); + } + + return parseInt(retVal,base); + } + + function chkEventThottle(timer){ + if(timer > throttledTimer/2){ + throttledTimer = 2*timer; + log('Event throttle increased to ' + throttledTimer + 'ms'); + } + } + + //Idea from https://github.com/guardian/iframe-messenger + function getMaxElement(side,elements) { + var + elementsLength = elements.length, + elVal = 0, + maxVal = 0, + Side = capitalizeFirstLetter(side), + timer = getNow(); + + for (var i = 0; i < elementsLength; i++) { + elVal = elements[i].getBoundingClientRect()[side] + getComputedStyle('margin'+Side,elements[i]); + if (elVal > maxVal) { + maxVal = elVal; + } + } + + timer = getNow() - timer; + + log('Parsed '+elementsLength+' HTML elements'); + log('Element position calculated in ' + timer + 'ms'); + + chkEventThottle(timer); + + return maxVal; + } + + function getAllMeasurements(dimention){ + return [ + dimention.bodyOffset(), + dimention.bodyScroll(), + dimention.documentElementOffset(), + dimention.documentElementScroll() + ]; + } + + function getTaggedElements(side,tag){ + function noTaggedElementsFound(){ + warn('No tagged elements ('+tag+') found on page'); + return document.querySelectorAll('body *'); + } + + var elements = document.querySelectorAll('['+tag+']'); + + if (0 === elements.length) noTaggedElementsFound(); + + return getMaxElement(side,elements); + } + + function getAllElements(){ + return document.querySelectorAll('body *'); + } + + var + getHeight = { + bodyOffset: function getBodyOffsetHeight(){ + return document.body.offsetHeight + getComputedStyle('marginTop') + getComputedStyle('marginBottom'); + }, + + offset: function(){ + return getHeight.bodyOffset(); //Backwards compatability + }, + + bodyScroll: function getBodyScrollHeight(){ + return document.body.scrollHeight; + }, + + custom: function getCustomWidth(){ + return customCalcMethods.height(); + }, + + documentElementOffset: function getDEOffsetHeight(){ + return document.documentElement.offsetHeight; + }, + + documentElementScroll: function getDEScrollHeight(){ + return document.documentElement.scrollHeight; + }, + + max: function getMaxHeight(){ + return Math.max.apply(null,getAllMeasurements(getHeight)); + }, + + min: function getMinHeight(){ + return Math.min.apply(null,getAllMeasurements(getHeight)); + }, + + grow: function growHeight(){ + return getHeight.max(); //Run max without the forced downsizing + }, + + lowestElement: function getBestHeight(){ + return Math.max(getHeight.bodyOffset(), getMaxElement('bottom',getAllElements())); + }, + + taggedElement: function getTaggedElementsHeight(){ + return getTaggedElements('bottom','data-iframe-height'); + } + }, + + getWidth = { + bodyScroll: function getBodyScrollWidth(){ + return document.body.scrollWidth; + }, + + bodyOffset: function getBodyOffsetWidth(){ + return document.body.offsetWidth; + }, + + custom: function getCustomWidth(){ + return customCalcMethods.width(); + }, + + documentElementScroll: function getDEScrollWidth(){ + return document.documentElement.scrollWidth; + }, + + documentElementOffset: function getDEOffsetWidth(){ + return document.documentElement.offsetWidth; + }, + + scroll: function getMaxWidth(){ + return Math.max(getWidth.bodyScroll(), getWidth.documentElementScroll()); + }, + + max: function getMaxWidth(){ + return Math.max.apply(null,getAllMeasurements(getWidth)); + }, + + min: function getMinWidth(){ + return Math.min.apply(null,getAllMeasurements(getWidth)); + }, + + rightMostElement: function rightMostElement(){ + return getMaxElement('right', getAllElements()); + }, + + taggedElement: function getTaggedElementsWidth(){ + return getTaggedElements('right', 'data-iframe-width'); + } + }; + + + function sizeIFrame(triggerEvent, triggerEventDesc, customHeight, customWidth){ + + function resizeIFrame(){ + height = currentHeight; + width = currentWidth; + + sendMsg(height,width,triggerEvent); + } + + function isSizeChangeDetected(){ + function checkTolarance(a,b){ + var retVal = Math.abs(a-b) <= tolerance; + return !retVal; + } + + currentHeight = (undefined !== customHeight) ? customHeight : getHeight[heightCalcMode](); + currentWidth = (undefined !== customWidth ) ? customWidth : getWidth[widthCalcMode](); + + return checkTolarance(height,currentHeight) || (calculateWidth && checkTolarance(width,currentWidth)); + } + + function isForceResizableEvent(){ + return !(triggerEvent in {'init':1,'interval':1,'size':1}); + } + + function isForceResizableCalcMode(){ + return (heightCalcMode in resetRequiredMethods) || (calculateWidth && widthCalcMode in resetRequiredMethods); + } + + function logIgnored(){ + log('No change in size detected'); + } + + function checkDownSizing(){ + if (isForceResizableEvent() && isForceResizableCalcMode()){ + resetIFrame(triggerEventDesc); + } else if (!(triggerEvent in {'interval':1})){ + logIgnored(); + } + } + + var currentHeight,currentWidth; + + if (isSizeChangeDetected() || 'init' === triggerEvent){ + lockTrigger(); + resizeIFrame(); + } else { + checkDownSizing(); + } + } + + var sizeIFrameThrottled = throttle(sizeIFrame); + + function sendSize(triggerEvent, triggerEventDesc, customHeight, customWidth){ + function recordTrigger(){ + if (!(triggerEvent in {'reset':1,'resetPage':1,'init':1})){ + log( 'Trigger event: ' + triggerEventDesc ); + } + } + + function isDoubleFiredEvent(){ + return triggerLocked && (triggerEvent in doubleEventList); + } + + if (!isDoubleFiredEvent()){ + recordTrigger(); + sizeIFrameThrottled(triggerEvent, triggerEventDesc, customHeight, customWidth); + } else { + log('Trigger event cancelled: '+triggerEvent); + } + } + + function lockTrigger(){ + if (!triggerLocked){ + triggerLocked = true; + log('Trigger event lock on'); + } + clearTimeout(triggerLockedTimer); + triggerLockedTimer = setTimeout(function(){ + triggerLocked = false; + log('Trigger event lock off'); + log('--'); + },eventCancelTimer); + } + + function triggerReset(triggerEvent){ + height = getHeight[heightCalcMode](); + width = getWidth[widthCalcMode](); + + sendMsg(height,width,triggerEvent); + } + + function resetIFrame(triggerEventDesc){ + var hcm = heightCalcMode; + heightCalcMode = heightCalcModeDefault; + + log('Reset trigger event: ' + triggerEventDesc); + lockTrigger(); + triggerReset('reset'); + + heightCalcMode = hcm; + } + + function sendMsg(height,width,triggerEvent,msg,targetOrigin){ + function setTargetOrigin(){ + if (undefined === targetOrigin){ + targetOrigin = targetOriginDefault; + } else { + log('Message targetOrigin: '+targetOrigin); + } + } + + function sendToParent(){ + var + size = height + ':' + width, + message = myID + ':' + size + ':' + triggerEvent + (undefined !== msg ? ':' + msg : ''); + + log('Sending message to host page (' + message + ')'); + target.postMessage( msgID + message, targetOrigin); + } + + if(true === sendPermit){ + setTargetOrigin(); + sendToParent(); + } + } + + function receiver(event) { + var processRequestFromParent = { + init: function initFromParent(){ + function fireInit(){ + initMsg = event.data; + target = event.source; + + init(); + firstRun = false; + setTimeout(function(){ initLock = false;},eventCancelTimer); + } + + if (document.readyState === "interactive" || document.readyState === "complete"){ + fireInit(); + } else { + log('Waiting for page ready'); + addEventListener(window,'readystatechange',processRequestFromParent.initFromParent); + } + }, + + reset: function resetFromParent(){ + if (!initLock){ + log('Page size reset by host page'); + triggerReset('resetPage'); + } else { + log('Page reset ignored by init'); + } + }, + + resize: function resizeFromParent(){ + sendSize('resizeParent','Parent window requested size check'); + }, + + moveToAnchor: function moveToAnchorF(){ + inPageLinks.findTarget(getData()); + }, + inPageLink: function inPageLinkF() {this.moveToAnchor();}, //Backward compatability + + pageInfo: function pageInfoFromParent(){ + var msgBody = getData(); + log('PageInfoFromParent called from parent: ' + msgBody ); + pageInfoCallback(JSON.parse(msgBody)); + log(' --'); + }, + + message: function messageFromParent(){ + var msgBody = getData(); + + log('MessageCallback called from parent: ' + msgBody ); + messageCallback(JSON.parse(msgBody)); + log(' --'); + } + }; + + function isMessageForUs(){ + return msgID === (''+event.data).substr(0,msgIdLen); //''+ Protects against non-string messages + } + + function getMessageType(){ + return event.data.split(']')[1].split(':')[0]; + } + + function getData(){ + return event.data.substr(event.data.indexOf(':')+1); + } + + function isMiddleTier(){ + return !(typeof module !== 'undefined' && module.exports) && ('iFrameResize' in window); + } + + function isInitMsg(){ + //Test if this message is from a child below us. This is an ugly test, however, updating + //the message format would break backwards compatibity. + return event.data.split(':')[2] in {'true':1,'false':1}; + } + + function callFromParent(){ + var messageType = getMessageType(); + + if (messageType in processRequestFromParent){ + processRequestFromParent[messageType](); + } else if (!isMiddleTier() && !isInitMsg()){ + warn('Unexpected message ('+event.data+')'); + } + } + + function processMessage(){ + if (false === firstRun) { + callFromParent(); + } else if (isInitMsg()) { + processRequestFromParent.init(); + } else { + log('Ignored message of type "' + getMessageType() + '". Received before initialization.'); + } + } + + if (isMessageForUs()){ + processMessage(); + } + } + + //Normally the parent kicks things off when it detects the iFrame has loaded. + //If this script is async-loaded, then tell parent page to retry init. + function chkLateLoaded(){ + if('loading' !== document.readyState){ + window.parent.postMessage('[iFrameResizerChild]Ready','*'); + } + } + + addEventListener(window, 'message', receiver); + chkLateLoaded(); + + + +})(); diff --git a/assets/js/iframe-resizer/iframeResizer.contentWindow.map b/assets/js/iframe-resizer/iframeResizer.contentWindow.map new file mode 100644 index 0000000..de230e5 --- /dev/null +++ b/assets/js/iframe-resizer/iframeResizer.contentWindow.map @@ -0,0 +1 @@ +{"version":3,"file":"iframeResizer.contentWindow.min.js","sources":["iframeResizer.contentWindow.js"],"names":["undefined","addEventListener","el","evt","func","window","attachEvent","removeEventListener","detachEvent","capitalizeFirstLetter","string","charAt","toUpperCase","slice","throttle","context","args","result","timeout","previous","later","getNow","apply","now","remaining","throttledTimer","this","arguments","clearTimeout","setTimeout","formatLogMsg","msg","msgID","myID","log","logging","console","warn","init","readDataFromParent","location","href","readDataFromPage","setMargin","setBodyStyle","bodyBackground","bodyPadding","injectClearFixIntoBodyElement","checkHeightMode","checkWidthMode","stopInfiniteResizingOfIFrame","setupPublicMethods","startEventListeners","inPageLinks","setupInPageLinks","sendSize","readyCallback","strBool","str","data","initMsg","substr","msgIdLen","split","bodyMargin","Number","calculateWidth","interval","autoResize","bodyMarginStr","heightCalcMode","tolerance","enable","resizeFrom","widthCalcMode","readData","iFrameResizer","JSON","stringify","messageCallback","targetOriginDefault","targetOrigin","heightCalculationMethod","widthCalculationMethod","setupCustomCalcMethods","calcMode","calcFunc","customCalcMethods","Object","constructor","chkCSS","attr","value","indexOf","document","body","style","documentElement","height","manageTriggerEvent","options","listener","add","eventName","handleEvent","eventType","eventHandlersByName","remove","eventNames","Array","prototype","map","method","manageEventListeners","checkCalcMode","calcModeDefault","modes","type","heightCalcModeDefault","getHeight","widthCalcModeDefault","getWidth","setupMutationObserver","stopMsgsToParent","sendPermit","removeMsgListener","receiver","disconnectMutationObserver","bodyObserver","disconnect","stopEventListeners","clearInterval","intervalTimer","teardown","clearFix","createElement","clear","display","appendChild","getPagePosition","x","pageXOffset","scrollLeft","y","pageYOffset","scrollTop","getElementPosition","elPosition","getBoundingClientRect","pagePosition","parseInt","left","top","findTarget","jumpToTarget","target","jumpPosition","hash","sendMsg","hashData","decodeURIComponent","getElementById","getElementsByName","checkLocationHash","bindAnchors","setupLink","linkClicked","e","preventDefault","getAttribute","forEach","call","querySelectorAll","bindLocationHash","initCheck","eventCancelTimer","enableInPageLinks","win","parentIFrame","resize","close","getId","getPageInfo","callback","pageInfoCallback","moveToAnchor","reset","resetIFrame","scrollTo","scrollToOffset","sendMessage","setHeightCalculationMethod","setWidthCalculationMethod","setTargetOrigin","size","customHeight","customWidth","valString","initInterval","setInterval","Math","abs","setupBodyMutationObserver","addImageLoadListners","mutation","addImageLoadListener","element","complete","src","imageLoaded","imageError","elements","push","attributeName","removeFromArray","splice","removeImageLoadListener","imageEventTriggered","event","typeDesc","mutationObserved","mutations","createMutationObserver","querySelector","config","attributes","attributeOldValue","characterData","characterDataOldValue","childList","subtree","observer","MutationObserver","observe","WebKitMutationObserver","forceIntervalTimer","getComputedStyle","prop","convertUnitsToPxForIE8","PIXEL","test","base","runtimeStyle","currentStyle","pixelLeft","retVal","defaultView","chkEventThottle","timer","getMaxElement","side","elementsLength","length","elVal","maxVal","Side","i","getAllMeasurements","dimention","bodyOffset","bodyScroll","documentElementOffset","documentElementScroll","getTaggedElements","tag","noTaggedElementsFound","getAllElements","sizeIFrame","triggerEvent","triggerEventDesc","resizeIFrame","currentHeight","width","currentWidth","isSizeChangeDetected","checkTolarance","a","b","isForceResizableEvent","isForceResizableCalcMode","resetRequiredMethods","logIgnored","checkDownSizing","lockTrigger","recordTrigger","resetPage","isDoubleFiredEvent","triggerLocked","doubleEventList","sizeIFrameThrottled","triggerLockedTimer","triggerReset","hcm","sendToParent","message","postMessage","isMessageForUs","getMessageType","getData","isMiddleTier","module","exports","isInitMsg","true","false","callFromParent","messageType","processRequestFromParent","processMessage","firstRun","fireInit","source","initLock","readyState","initFromParent","inPageLink","pageInfo","msgBody","parse","chkLateLoaded","parent","click","max","min","offsetHeight","scrollWidth","Date","getTime","offset","scrollHeight","custom","grow","lowestElement","taggedElement","offsetWidth","scroll","rightMostElement"],"mappings":";;;;;;;;CAYC,SAAUA,GACV,YA0DA,SAASC,GAAiBC,EAAGC,EAAIC,GAE5B,oBAAsBC,QACzBH,EAAGD,iBAAiBE,EAAIC,GAAM,GACpB,eAAiBC,SAC3BH,EAAGI,YAAY,KAAKH,EAAIC,GAI1B,QAASG,GAAoBL,EAAGC,EAAIC,GAE/B,uBAAyBC,QAC5BH,EAAGK,oBAAoBJ,EAAIC,GAAM,GACvB,eAAiBC,SAC3BH,EAAGM,YAAY,KAAKL,EAAIC,GAI1B,QAASK,GAAsBC,GAC9B,MAAOA,GAAOC,OAAO,GAAGC,cAAgBF,EAAOG,MAAM,GAItD,QAASC,GAASV,GACjB,GACCW,GAASC,EAAMC,EACfC,EAAU,KACVC,EAAW,EACXC,EAAQ,WACPD,EAAWE,KACXH,EAAU,KACVD,EAASb,EAAKkB,MAAMP,EAASC,GACxBE,IACJH,EAAUC,EAAO,MAIpB,OAAO,YACN,GAAIO,GAAMF,IAELF,KACJA,EAAWI,EAGZ,IAAIC,GAAYC,IAAkBF,EAAMJ,EAsBxC,OApBAJ,GAAUW,KACVV,EAAOW,UAEU,GAAbH,GAAkBA,EAAYC,IAC7BP,IACHU,aAAaV,GACbA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I,IACC2I,WAAY,WACX,MAAOtK,UAASC,KAAKsO,aAGtBlE,WAAY,WACX,MAAOrK,UAASC,KAAK+O,aAGtBJ,OAAQ,WACP,MAAOnP,IAAkByL,SAG1BV,sBAAuB,WACtB,MAAOxK,UAASG,gBAAgBoO,aAGjChE,sBAAuB,WACtB,MAAOvK,UAASG,gBAAgB6O,aAGjCC,OAAQ,WACP,MAAOvI,MAAK0H,IAAIzM,GAAS2I,aAAc3I,GAAS6I,0BAGjD4D,IAAK,WACJ,MAAO1H,MAAK0H,IAAI5S,MAAM,KAAK2O,EAAmBxI,MAG/C0M,IAAK,WACJ,MAAO3H,MAAK2H,IAAI7S,MAAM,KAAK2O,EAAmBxI,MAG/CuN,iBAAkB,WACjB,MAAOvF,GAAc,QAASiB,MAG/BmE,cAAe,WACd,MAAOtE,GAAkB,QAAS,uBAwDjC0B,GAAsBnR,EAAS6P,EAyLnC1Q,GAAiBI,OAAQ,UAAWyH,GACpCiM","sourcesContent":["/*\n * File: iframeResizer.contentWindow.js\n * Desc: Include this file in any page being loaded into an iframe\n * to force the iframe to resize to the content size.\n * Requires: iframeResizer.js on host page.\n * Doc: https://github.com/davidjbradshaw/iframe-resizer\n * Author: David J. Bradshaw - dave@bradshaw.net\n * Contributor: Jure Mav - jure.mav@gmail.com\n * Contributor: Ian Caunce - ian@hallnet.co.uk\n */\n\n\n;(function(undefined) {\n\t'use strict';\n\n\tif(typeof window === 'undefined') return; // don't run for server side render\n\n\tvar\n\t\tautoResize = true,\n\t\tbase = 10,\n\t\tbodyBackground = '',\n\t\tbodyMargin = 0,\n\t\tbodyMarginStr = '',\n\t\tbodyObserver = null,\n\t\tbodyPadding = '',\n\t\tcalculateWidth = false,\n\t\tdoubleEventList = {'resize':1,'click':1},\n\t\teventCancelTimer = 128,\n\t\tfirstRun = true,\n\t\theight = 1,\n\t\theightCalcModeDefault = 'bodyOffset',\n\t\theightCalcMode = heightCalcModeDefault,\n\t\tinitLock = true,\n\t\tinitMsg = '',\n\t\tinPageLinks = {},\n\t\tinterval = 32,\n\t\tintervalTimer = null,\n\t\tlogging = false,\n\t\tmsgID = '[iFrameSizer]', //Must match host page msg ID\n\t\tmsgIdLen = msgID.length,\n\t\tmyID = '',\n\t\tobserver = null,\n\t\tresetRequiredMethods = {max:1,min:1,bodyScroll:1,documentElementScroll:1},\n\t\tresizeFrom = 'child',\n\t\tsendPermit = true,\n\t\ttarget = window.parent,\n\t\ttargetOriginDefault = '*',\n\t\ttolerance = 0,\n\t\ttriggerLocked = false,\n\t\ttriggerLockedTimer = null,\n\t\tthrottledTimer = 16,\n\t\twidth = 1,\n\t\twidthCalcModeDefault = 'scroll',\n\t\twidthCalcMode = widthCalcModeDefault,\n\t\twin = window,\n\t\tmessageCallback = function(){ warn('MessageCallback function not defined'); },\n\t\treadyCallback = function(){},\n\t\tpageInfoCallback = function(){},\n\t\tcustomCalcMethods = {\n\t\t\theight: function(){\n\t\t\t\twarn('Custom height calculation function not defined');\n\t\t\t\treturn document.documentElement.offsetHeight;\n\t\t\t},\n\t\t\twidth: function(){\n\t\t\t\twarn('Custom width calculation function not defined');\n\t\t\t\treturn document.body.scrollWidth;\n\t\t\t}\n\t\t},\n\t\teventHandlersByName = {};\n\n\n\tfunction addEventListener(el,evt,func){\n\t\t/* istanbul ignore else */ // Not testable in phantonJS\n\t\tif ('addEventListener' in window){\n\t\t\tel.addEventListener(evt,func, false);\n\t\t} else if ('attachEvent' in window){ //IE\n\t\t\tel.attachEvent('on'+evt,func);\n\t\t}\n\t}\n\n\tfunction removeEventListener(el,evt,func){\n\t\t/* istanbul ignore else */ // Not testable in phantonJS\n\t\tif ('removeEventListener' in window){\n\t\t\tel.removeEventListener(evt,func, false);\n\t\t} else if ('detachEvent' in window){ //IE\n\t\t\tel.detachEvent('on'+evt,func);\n\t\t}\n\t}\n\n\tfunction capitalizeFirstLetter(string) {\n\t\treturn string.charAt(0).toUpperCase() + string.slice(1);\n\t}\n\n\t//Based on underscore.js\n\tfunction throttle(func) {\n\t\tvar\n\t\t\tcontext, args, result,\n\t\t\ttimeout = null,\n\t\t\tprevious = 0,\n\t\t\tlater = function() {\n\t\t\t\tprevious = getNow();\n\t\t\t\ttimeout = null;\n\t\t\t\tresult = func.apply(context, args);\n\t\t\t\tif (!timeout) {\n\t\t\t\t\tcontext = args = null;\n\t\t\t\t}\n\t\t\t};\n\n\t\treturn function() {\n\t\t\tvar now = getNow();\n\n\t\t\tif (!previous) {\n\t\t\t\tprevious = now;\n\t\t\t}\n\n\t\t\tvar remaining = throttledTimer - (now - previous);\n\n\t\t\tcontext = this;\n\t\t\targs = arguments;\n\n\t\t\tif (remaining <= 0 || remaining > throttledTimer) {\n\t\t\t\tif (timeout) {\n\t\t\t\t\tclearTimeout(timeout);\n\t\t\t\t\ttimeout = null;\n\t\t\t\t}\n\n\t\t\t\tprevious = now;\n\t\t\t\tresult = func.apply(context, args);\n\n\t\t\t\tif (!timeout) {\n\t\t\t\t\tcontext = args = null;\n\t\t\t\t}\n\n\t\t\t} else if (!timeout) {\n\t\t\t\ttimeout = setTimeout(later, remaining);\n\t\t\t}\n\n\t\t\treturn result;\n\t\t};\n\t}\n\n\tvar getNow = Date.now || function() {\n\t\t/* istanbul ignore next */ // Not testable in PhantonJS\n\t\treturn new Date().getTime();\n\t};\n\n\tfunction formatLogMsg(msg){\n\t\treturn msgID + '[' + myID + ']' + ' ' + msg;\n\t}\n\n\tfunction log(msg){\n\t\tif (logging && ('object' === typeof window.console)){\n\t\t\tconsole.log(formatLogMsg(msg));\n\t\t}\n\t}\n\n\tfunction warn(msg){\n\t\tif ('object' === typeof window.console){\n\t\t\tconsole.warn(formatLogMsg(msg));\n\t\t}\n\t}\n\n\n\tfunction init(){\n\t\treadDataFromParent();\n\t\tlog('Initialising iFrame ('+location.href+')');\n\t\treadDataFromPage();\n\t\tsetMargin();\n\t\tsetBodyStyle('background',bodyBackground);\n\t\tsetBodyStyle('padding',bodyPadding);\n\t\tinjectClearFixIntoBodyElement();\n\t\tcheckHeightMode();\n\t\tcheckWidthMode();\n\t\tstopInfiniteResizingOfIFrame();\n\t\tsetupPublicMethods();\n\t\tstartEventListeners();\n\t\tinPageLinks = setupInPageLinks();\n\t\tsendSize('init','Init message from host page');\n\t\treadyCallback();\n\t}\n\n\tfunction readDataFromParent(){\n\n\t\tfunction strBool(str){\n\t\t\treturn 'true' === str ? true : false;\n\t\t}\n\n\t\tvar data = initMsg.substr(msgIdLen).split(':');\n\n\t\tmyID = data[0];\n\t\tbodyMargin = (undefined !== data[1]) ? Number(data[1]) : bodyMargin; //For V1 compatibility\n\t\tcalculateWidth = (undefined !== data[2]) ? strBool(data[2]) : calculateWidth;\n\t\tlogging = (undefined !== data[3]) ? strBool(data[3]) : logging;\n\t\tinterval = (undefined !== data[4]) ? Number(data[4]) : interval;\n\t\tautoResize = (undefined !== data[6]) ? strBool(data[6]) : autoResize;\n\t\tbodyMarginStr = data[7];\n\t\theightCalcMode = (undefined !== data[8]) ? data[8] : heightCalcMode;\n\t\tbodyBackground = data[9];\n\t\tbodyPadding = data[10];\n\t\ttolerance = (undefined !== data[11]) ? Number(data[11]) : tolerance;\n\t\tinPageLinks.enable = (undefined !== data[12]) ? strBool(data[12]): false;\n\t\tresizeFrom = (undefined !== data[13]) ? data[13] : resizeFrom;\n\t\twidthCalcMode = (undefined !== data[14]) ? data[14] : widthCalcMode;\n\t}\n\n\tfunction readDataFromPage(){\n\t\tfunction readData(){\n\t\t\tvar data = window.iFrameResizer;\n\n\t\t\tlog('Reading data from page: ' + JSON.stringify(data));\n\n\t\t\tmessageCallback = ('messageCallback' in data) ? data.messageCallback : messageCallback;\n\t\t\treadyCallback = ('readyCallback' in data) ? data.readyCallback : readyCallback;\n\t\t\ttargetOriginDefault = ('targetOrigin' in data) ? data.targetOrigin : targetOriginDefault;\n\t\t\theightCalcMode = ('heightCalculationMethod' in data) ? data.heightCalculationMethod : heightCalcMode;\n\t\t\twidthCalcMode = ('widthCalculationMethod' in data) ? data.widthCalculationMethod : widthCalcMode;\n\t\t}\n\n\t\tfunction setupCustomCalcMethods(calcMode, calcFunc){\n\t\t\tif ('function' === typeof calcMode) {\n\t\t\t\tlog('Setup custom ' + calcFunc + 'CalcMethod');\n\t\t\t\tcustomCalcMethods[calcFunc] = calcMode;\n\t\t\t\tcalcMode = 'custom';\n\t\t\t}\n\n\t\t\treturn calcMode;\n\t\t}\n\n\t\tif(('iFrameResizer' in window) && (Object === window.iFrameResizer.constructor)) {\n\t\t\treadData();\n\t\t\theightCalcMode = setupCustomCalcMethods(heightCalcMode, 'height');\n\t\t\twidthCalcMode = setupCustomCalcMethods(widthCalcMode, 'width');\n\t\t}\n\n\t\tlog('TargetOrigin for parent set to: ' + targetOriginDefault);\n\t}\n\n\n\tfunction chkCSS(attr,value){\n\t\tif (-1 !== value.indexOf('-')){\n\t\t\twarn('Negative CSS value ignored for '+attr);\n\t\t\tvalue='';\n\t\t}\n\t\treturn value;\n\t}\n\n\tfunction setBodyStyle(attr,value){\n\t\tif ((undefined !== value) && ('' !== value) && ('null' !== value)){\n\t\t\tdocument.body.style[attr] = value;\n\t\t\tlog('Body '+attr+' set to \"'+value+'\"');\n\t\t}\n\t}\n\n\tfunction setMargin(){\n\t\t//If called via V1 script, convert bodyMargin from int to str\n\t\tif (undefined === bodyMarginStr){\n\t\t\tbodyMarginStr = bodyMargin+'px';\n\t\t}\n\n\t\tsetBodyStyle('margin',chkCSS('margin',bodyMarginStr));\n\t}\n\n\tfunction stopInfiniteResizingOfIFrame(){\n\t\tdocument.documentElement.style.height = '';\n\t\tdocument.body.style.height = '';\n\t\tlog('HTML & body height set to \"auto\"');\n\t}\n\n\n\tfunction manageTriggerEvent(options){\n\n\t\tvar listener = {\n\t\t\tadd: function(eventName){\n\t\t\t\tfunction handleEvent(){\n\t\t\t\t\tsendSize(options.eventName,options.eventType);\n\t\t\t\t}\n\n\t\t\t\teventHandlersByName[eventName] = handleEvent;\n\n\t\t\t\taddEventListener(window,eventName,handleEvent);\n\t\t\t},\n\t\t\tremove: function(eventName){\n\t\t\t\tvar handleEvent = eventHandlersByName[eventName];\n\t\t\t\tdelete eventHandlersByName[eventName];\n\n\t\t\t\tremoveEventListener(window,eventName,handleEvent);\n\t\t\t}\n\t\t};\n\n\t\tif(options.eventNames && Array.prototype.map){\n\t\t\toptions.eventName = options.eventNames[0];\n\t\t\toptions.eventNames.map(listener[options.method]);\n\t\t} else {\n\t\t\tlistener[options.method](options.eventName);\n\t\t}\n\n\t\tlog(capitalizeFirstLetter(options.method) + ' event listener: ' + options.eventType);\n\t}\n\n\tfunction manageEventListeners(method){\n\t\tmanageTriggerEvent({method:method, eventType: 'Animation Start', eventNames: ['animationstart','webkitAnimationStart'] });\n\t\tmanageTriggerEvent({method:method, eventType: 'Animation Iteration', eventNames: ['animationiteration','webkitAnimationIteration'] });\n\t\tmanageTriggerEvent({method:method, eventType: 'Animation End', eventNames: ['animationend','webkitAnimationEnd'] });\n\t\tmanageTriggerEvent({method:method, eventType: 'Input', eventName: 'input' });\n\t\tmanageTriggerEvent({method:method, eventType: 'Mouse Up', eventName: 'mouseup' });\n\t\tmanageTriggerEvent({method:method, eventType: 'Mouse Down', eventName: 'mousedown' });\n\t\tmanageTriggerEvent({method:method, eventType: 'Orientation Change', eventName: 'orientationchange' });\n\t\tmanageTriggerEvent({method:method, eventType: 'Print', eventName: ['afterprint', 'beforeprint'] });\n\t\tmanageTriggerEvent({method:method, eventType: 'Ready State Change', eventName: 'readystatechange' });\n\t\tmanageTriggerEvent({method:method, eventType: 'Touch Start', eventName: 'touchstart' });\n\t\tmanageTriggerEvent({method:method, eventType: 'Touch End', eventName: 'touchend' });\n\t\tmanageTriggerEvent({method:method, eventType: 'Touch Cancel', eventName: 'touchcancel' });\n\t\tmanageTriggerEvent({method:method, eventType: 'Transition Start', eventNames: ['transitionstart','webkitTransitionStart','MSTransitionStart','oTransitionStart','otransitionstart'] });\n\t\tmanageTriggerEvent({method:method, eventType: 'Transition Iteration', eventNames: ['transitioniteration','webkitTransitionIteration','MSTransitionIteration','oTransitionIteration','otransitioniteration'] });\n\t\tmanageTriggerEvent({method:method, eventType: 'Transition End', eventNames: ['transitionend','webkitTransitionEnd','MSTransitionEnd','oTransitionEnd','otransitionend'] });\n\t\tif('child' === resizeFrom){\n\t\t\tmanageTriggerEvent({method:method, eventType: 'IFrame Resized', eventName: 'resize' });\n\t\t}\n\t}\n\n\tfunction checkCalcMode(calcMode,calcModeDefault,modes,type){\n\t\tif (calcModeDefault !== calcMode){\n\t\t\tif (!(calcMode in modes)){\n\t\t\t\twarn(calcMode + ' is not a valid option for '+type+'CalculationMethod.');\n\t\t\t\tcalcMode=calcModeDefault;\n\t\t\t}\n\t\t\tlog(type+' calculation method set to \"'+calcMode+'\"');\n\t\t}\n\n\t\treturn calcMode;\n\t}\n\n\tfunction checkHeightMode(){\n\t\theightCalcMode = checkCalcMode(heightCalcMode,heightCalcModeDefault,getHeight,'height');\n\t}\n\n\tfunction checkWidthMode(){\n\t\twidthCalcMode = checkCalcMode(widthCalcMode,widthCalcModeDefault,getWidth,'width');\n\t}\n\n\tfunction startEventListeners(){\n\t\tif ( true === autoResize ) {\n\t\t\tmanageEventListeners('add');\n\t\t\tsetupMutationObserver();\n\t\t}\n\t\telse {\n\t\t\tlog('Auto Resize disabled');\n\t\t}\n\t}\n\n\tfunction stopMsgsToParent(){\n\t\tlog('Disable outgoing messages');\n\t\tsendPermit = false;\n\t}\n\n\tfunction removeMsgListener(){\n\t\tlog('Remove event listener: Message');\n\t\tremoveEventListener(window, 'message', receiver);\n\t}\n\n\tfunction disconnectMutationObserver(){\n\t\tif (null !== bodyObserver){\n\t\t\t/* istanbul ignore next */ // Not testable in PhantonJS\n\t\t\tbodyObserver.disconnect();\n\t\t}\n\t}\n\n\tfunction stopEventListeners(){\n\t\tmanageEventListeners('remove');\n\t\tdisconnectMutationObserver();\n\t\tclearInterval(intervalTimer);\n\t}\n\n\tfunction teardown(){\n\t\tstopMsgsToParent();\n\t\tremoveMsgListener();\n\t\tif (true === autoResize) stopEventListeners();\n\t}\n\n\tfunction injectClearFixIntoBodyElement(){\n\t\tvar clearFix = document.createElement('div');\n\t\tclearFix.style.clear = 'both';\n\t\tclearFix.style.display = 'block'; //Guard against this having been globally redefined in CSS.\n\t\tdocument.body.appendChild(clearFix);\n\t}\n\n\tfunction setupInPageLinks(){\n\n\t\tfunction getPagePosition (){\n\t\t\treturn {\n\t\t\t\tx: (window.pageXOffset !== undefined) ? window.pageXOffset : document.documentElement.scrollLeft,\n\t\t\t\ty: (window.pageYOffset !== undefined) ? window.pageYOffset : document.documentElement.scrollTop\n\t\t\t};\n\t\t}\n\n\t\tfunction getElementPosition(el){\n\t\t\tvar\n\t\t\t\telPosition = el.getBoundingClientRect(),\n\t\t\t\tpagePosition = getPagePosition();\n\n\t\t\treturn {\n\t\t\t\tx: parseInt(elPosition.left,10) + parseInt(pagePosition.x,10),\n\t\t\t\ty: parseInt(elPosition.top,10) + parseInt(pagePosition.y,10)\n\t\t\t};\n\t\t}\n\n\t\tfunction findTarget(location){\n\t\t\tfunction jumpToTarget(target){\n\t\t\t\tvar jumpPosition = getElementPosition(target);\n\n\t\t\t\tlog('Moving to in page link (#'+hash+') at x: '+jumpPosition.x+' y: '+jumpPosition.y);\n\t\t\t\tsendMsg(jumpPosition.y, jumpPosition.x, 'scrollToOffset'); // X&Y reversed at sendMsg uses height/width\n\t\t\t}\n\n\t\t\tvar\n\t\t\t\thash = location.split('#')[1] || location, //Remove # if present\n\t\t\t\thashData = decodeURIComponent(hash),\n\t\t\t\ttarget = document.getElementById(hashData) || document.getElementsByName(hashData)[0];\n\n\t\t\tif (undefined !== target){\n\t\t\t\tjumpToTarget(target);\n\t\t\t} else {\n\t\t\t\tlog('In page link (#' + hash + ') not found in iFrame, so sending to parent');\n\t\t\t\tsendMsg(0,0,'inPageLink','#'+hash);\n\t\t\t}\n\t\t}\n\n\t\tfunction checkLocationHash(){\n\t\t\tif ('' !== location.hash && '#' !== location.hash){\n\t\t\t\tfindTarget(location.href);\n\t\t\t}\n\t\t}\n\n\t\tfunction bindAnchors(){\n\t\t\tfunction setupLink(el){\n\t\t\t\tfunction linkClicked(e){\n\t\t\t\t\te.preventDefault();\n\n\t\t\t\t\t/*jshint validthis:true */\n\t\t\t\t\tfindTarget(this.getAttribute('href'));\n\t\t\t\t}\n\n\t\t\t\tif ('#' !== el.getAttribute('href')){\n\t\t\t\t\taddEventListener(el,'click',linkClicked);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tArray.prototype.forEach.call( document.querySelectorAll( 'a[href^=\"#\"]' ), setupLink );\n\t\t}\n\n\t\tfunction bindLocationHash(){\n\t\t\taddEventListener(window,'hashchange',checkLocationHash);\n\t\t}\n\n\t\tfunction initCheck(){ //check if page loaded with location hash after init resize\n\t\t\tsetTimeout(checkLocationHash,eventCancelTimer);\n\t\t}\n\n\t\tfunction enableInPageLinks(){\n\t\t\t/* istanbul ignore else */ // Not testable in phantonJS\n\t\t\tif(Array.prototype.forEach && document.querySelectorAll){\n\t\t\t\tlog('Setting up location.hash handlers');\n\t\t\t\tbindAnchors();\n\t\t\t\tbindLocationHash();\n\t\t\t\tinitCheck();\n\t\t\t} else {\n\t\t\t\twarn('In page linking not fully supported in this browser! (See README.md for IE8 workaround)');\n\t\t\t}\n\t\t}\n\n\t\tif(inPageLinks.enable){\n\t\t\tenableInPageLinks();\n\t\t} else {\n\t\t\tlog('In page linking not enabled');\n\t\t}\n\n\t\treturn {\n\t\t\tfindTarget:findTarget\n\t\t};\n\t}\n\n\tfunction setupPublicMethods(){\n\t\tlog('Enable public methods');\n\n\t\twin.parentIFrame = {\n\n\t\t\tautoResize: function autoResizeF(resize){\n\t\t\t\tif (true === resize && false === autoResize) {\n\t\t\t\t\tautoResize=true;\n\t\t\t\t\tstartEventListeners();\n\t\t\t\t\t//sendSize('autoResize','Auto Resize enabled');\n\t\t\t\t} else if (false === resize && true === autoResize) {\n\t\t\t\t\tautoResize=false;\n\t\t\t\t\tstopEventListeners();\n\t\t\t\t}\n\n\t\t\t\treturn autoResize;\n\t\t\t},\n\n\t\t\tclose: function closeF(){\n\t\t\t\tsendMsg(0,0,'close');\n\t\t\t\tteardown();\n\t\t\t},\n\n\t\t\tgetId: function getIdF(){\n\t\t\t\treturn myID;\n\t\t\t},\n\n\t\t\tgetPageInfo: function getPageInfoF(callback){\n\t\t\t\tif ('function' === typeof callback){\n\t\t\t\t\tpageInfoCallback = callback;\n\t\t\t\t\tsendMsg(0,0,'pageInfo');\n\t\t\t\t} else {\n\t\t\t\t\tpageInfoCallback = function(){};\n\t\t\t\t\tsendMsg(0,0,'pageInfoStop');\n\t\t\t\t}\n\t\t\t},\n\n\t\t\tmoveToAnchor: function moveToAnchorF(hash){\n\t\t\t\tinPageLinks.findTarget(hash);\n\t\t\t},\n\n\t\t\treset: function resetF(){\n\t\t\t\tresetIFrame('parentIFrame.reset');\n\t\t\t},\n\n\t\t\tscrollTo: function scrollToF(x,y){\n\t\t\t\tsendMsg(y,x,'scrollTo'); // X&Y reversed at sendMsg uses height/width\n\t\t\t},\n\n\t\t\tscrollToOffset: function scrollToF(x,y){\n\t\t\t\tsendMsg(y,x,'scrollToOffset'); // X&Y reversed at sendMsg uses height/width\n\t\t\t},\n\n\t\t\tsendMessage: function sendMessageF(msg,targetOrigin){\n\t\t\t\tsendMsg(0,0,'message',JSON.stringify(msg),targetOrigin);\n\t\t\t},\n\n\t\t\tsetHeightCalculationMethod: function setHeightCalculationMethodF(heightCalculationMethod){\n\t\t\t\theightCalcMode = heightCalculationMethod;\n\t\t\t\tcheckHeightMode();\n\t\t\t},\n\n\t\t\tsetWidthCalculationMethod: function setWidthCalculationMethodF(widthCalculationMethod){\n\t\t\t\twidthCalcMode = widthCalculationMethod;\n\t\t\t\tcheckWidthMode();\n\t\t\t},\n\n\t\t\tsetTargetOrigin: function setTargetOriginF(targetOrigin){\n\t\t\t\tlog('Set targetOrigin: '+targetOrigin);\n\t\t\t\ttargetOriginDefault = targetOrigin;\n\t\t\t},\n\n\t\t\tsize: function sizeF(customHeight, customWidth){\n\t\t\t\tvar valString = ''+(customHeight?customHeight:'')+(customWidth?','+customWidth:'');\n\t\t\t\t//lockTrigger();\n\t\t\t\tsendSize('size','parentIFrame.size('+valString+')', customHeight, customWidth);\n\t\t\t}\n\t\t};\n\t}\n\n\tfunction initInterval(){\n\t\tif ( 0 !== interval ){\n\t\t\tlog('setInterval: '+interval+'ms');\n\t\t\tintervalTimer = setInterval(function(){\n\t\t\t\tsendSize('interval','setInterval: '+interval);\n\t\t\t},Math.abs(interval));\n\t\t}\n\t}\n\n\t/* istanbul ignore next */ //Not testable in PhantomJS\n\tfunction setupBodyMutationObserver(){\n\t\tfunction addImageLoadListners(mutation) {\n\t\t\tfunction addImageLoadListener(element){\n\t\t\t\tif (false === element.complete) {\n\t\t\t\t\tlog('Attach listeners to ' + element.src);\n\t\t\t\t\telement.addEventListener('load', imageLoaded, false);\n\t\t\t\t\telement.addEventListener('error', imageError, false);\n\t\t\t\t\telements.push(element);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif (mutation.type === 'attributes' && mutation.attributeName === 'src'){\n\t\t\t\taddImageLoadListener(mutation.target);\n\t\t\t} else if (mutation.type === 'childList'){\n\t\t\t\tArray.prototype.forEach.call(\n\t\t\t\t\tmutation.target.querySelectorAll('img'),\n\t\t\t\t\taddImageLoadListener\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\n\t\tfunction removeFromArray(element){\n\t\t\telements.splice(elements.indexOf(element),1);\n\t\t}\n\n\t\tfunction removeImageLoadListener(element){\n\t\t\tlog('Remove listeners from ' + element.src);\n\t\t\telement.removeEventListener('load', imageLoaded, false);\n\t\t\telement.removeEventListener('error', imageError, false);\n\t\t\tremoveFromArray(element);\n\t\t}\n\n\t\tfunction imageEventTriggered(event,type,typeDesc){\n\t\t\tremoveImageLoadListener(event.target);\n\t\t\tsendSize(type, typeDesc + ': ' + event.target.src, undefined, undefined);\n\t\t}\n\n\t\tfunction imageLoaded(event) {\n\t\t\timageEventTriggered(event,'imageLoad','Image loaded');\n\t\t}\n\n\t\tfunction imageError(event) {\n\t\t\timageEventTriggered(event,'imageLoadFailed','Image load failed');\n\t\t}\n\n\t\tfunction mutationObserved(mutations) {\n\t\t\tsendSize('mutationObserver','mutationObserver: ' + mutations[0].target + ' ' + mutations[0].type);\n\n\t\t\t//Deal with WebKit asyncing image loading when tags are injected into the page\n\t\t\tmutations.forEach(addImageLoadListners);\n\t\t}\n\n\t\tfunction createMutationObserver(){\n\t\t\tvar\n\t\t\t\ttarget = document.querySelector('body'),\n\n\t\t\t\tconfig = {\n\t\t\t\t\tattributes : true,\n\t\t\t\t\tattributeOldValue : false,\n\t\t\t\t\tcharacterData : true,\n\t\t\t\t\tcharacterDataOldValue : false,\n\t\t\t\t\tchildList : true,\n\t\t\t\t\tsubtree : true\n\t\t\t\t};\n\n\t\t\tobserver = new MutationObserver(mutationObserved);\n\n\t\t\tlog('Create body MutationObserver');\n\t\t\tobserver.observe(target, config);\n\n\t\t\treturn observer;\n\t\t}\n\n\t\tvar\n\t\t\telements = [],\n\t\t\tMutationObserver = window.MutationObserver || window.WebKitMutationObserver,\n\t\t\tobserver = createMutationObserver();\n\n\t\treturn {\n\t\t\tdisconnect: function (){\n\t\t\t\tif ('disconnect' in observer){\n\t\t\t\t\tlog('Disconnect body MutationObserver');\n\t\t\t\t\tobserver.disconnect();\n\t\t\t\t\telements.forEach(removeImageLoadListener);\n\t\t\t\t}\n\t\t\t}\n\t\t};\n\t}\n\n\tfunction setupMutationObserver(){\n\t\tvar\tforceIntervalTimer = 0 > interval;\n\n\t\t/* istanbul ignore if */ // Not testable in PhantomJS\n\t\tif (window.MutationObserver || window.WebKitMutationObserver){\n\t\t\tif (forceIntervalTimer) {\n\t\t\t\tinitInterval();\n\t\t\t} else {\n\t\t\t\tbodyObserver = setupBodyMutationObserver();\n\t\t\t}\n\t\t} else {\n\t\t\tlog('MutationObserver not supported in this browser!');\n\t\t\tinitInterval();\n\t\t}\n\t}\n\n\n\t// document.documentElement.offsetHeight is not reliable, so\n\t// we have to jump through hoops to get a better value.\n\tfunction getComputedStyle(prop,el) {\n\t\t/* istanbul ignore next */ //Not testable in PhantomJS\n\t\tfunction convertUnitsToPxForIE8(value) {\n\t\t\tvar PIXEL = /^\\d+(px)?$/i;\n\n\t\t\tif (PIXEL.test(value)) {\n\t\t\t\treturn parseInt(value,base);\n\t\t\t}\n\n\t\t\tvar\n\t\t\t\tstyle = el.style.left,\n\t\t\t\truntimeStyle = el.runtimeStyle.left;\n\n\t\t\tel.runtimeStyle.left = el.currentStyle.left;\n\t\t\tel.style.left = value || 0;\n\t\t\tvalue = el.style.pixelLeft;\n\t\t\tel.style.left = style;\n\t\t\tel.runtimeStyle.left = runtimeStyle;\n\n\t\t\treturn value;\n\t\t}\n\n\t\tvar retVal = 0;\n\t\tel = el || document.body;\n\n\t\t/* istanbul ignore else */ // Not testable in phantonJS\n\t\tif (('defaultView' in document) && ('getComputedStyle' in document.defaultView)) {\n\t\t\tretVal = document.defaultView.getComputedStyle(el, null);\n\t\t\tretVal = (null !== retVal) ? retVal[prop] : 0;\n\t\t} else {//IE8\n\t\t\tretVal = convertUnitsToPxForIE8(el.currentStyle[prop]);\n\t\t}\n\n\t\treturn parseInt(retVal,base);\n\t}\n\n\tfunction chkEventThottle(timer){\n\t\tif(timer > throttledTimer/2){\n\t\t\tthrottledTimer = 2*timer;\n\t\t\tlog('Event throttle increased to ' + throttledTimer + 'ms');\n\t\t}\n\t}\n\n\t//Idea from https://github.com/guardian/iframe-messenger\n\tfunction getMaxElement(side,elements) {\n\t\tvar\n\t\t\telementsLength = elements.length,\n\t\t\telVal = 0,\n\t\t\tmaxVal = 0,\n\t\t\tSide = capitalizeFirstLetter(side),\n\t\t\ttimer = getNow();\n\n\t\tfor (var i = 0; i < elementsLength; i++) {\n\t\t\telVal = elements[i].getBoundingClientRect()[side] + getComputedStyle('margin'+Side,elements[i]);\n\t\t\tif (elVal > maxVal) {\n\t\t\t\tmaxVal = elVal;\n\t\t\t}\n\t\t}\n\n\t\ttimer = getNow() - timer;\n\n\t\tlog('Parsed '+elementsLength+' HTML elements');\n\t\tlog('Element position calculated in ' + timer + 'ms');\n\n\t\tchkEventThottle(timer);\n\n\t\treturn maxVal;\n\t}\n\n\tfunction getAllMeasurements(dimention){\n\t\treturn [\n\t\t\tdimention.bodyOffset(),\n\t\t\tdimention.bodyScroll(),\n\t\t\tdimention.documentElementOffset(),\n\t\t\tdimention.documentElementScroll()\n\t\t];\n\t}\n\n\tfunction getTaggedElements(side,tag){\n\t\tfunction noTaggedElementsFound(){\n\t\t\twarn('No tagged elements ('+tag+') found on page');\n\t\t\treturn document.querySelectorAll('body *');\n\t\t}\n\n\t\tvar elements = document.querySelectorAll('['+tag+']');\n\n\t\tif (0 === elements.length) noTaggedElementsFound();\n\n\t\treturn getMaxElement(side,elements);\n\t}\n\n\tfunction getAllElements(){\n\t\treturn document.querySelectorAll('body *');\n\t}\n\n\tvar\n\t\tgetHeight = {\n\t\t\tbodyOffset: function getBodyOffsetHeight(){\n\t\t\t\treturn document.body.offsetHeight + getComputedStyle('marginTop') + getComputedStyle('marginBottom');\n\t\t\t},\n\n\t\t\toffset: function(){\n\t\t\t\treturn getHeight.bodyOffset(); //Backwards compatability\n\t\t\t},\n\n\t\t\tbodyScroll: function getBodyScrollHeight(){\n\t\t\t\treturn document.body.scrollHeight;\n\t\t\t},\n\n\t\t\tcustom: function getCustomWidth(){\n\t\t\t\treturn customCalcMethods.height();\n\t\t\t},\n\n\t\t\tdocumentElementOffset: function getDEOffsetHeight(){\n\t\t\t\treturn document.documentElement.offsetHeight;\n\t\t\t},\n\n\t\t\tdocumentElementScroll: function getDEScrollHeight(){\n\t\t\t\treturn document.documentElement.scrollHeight;\n\t\t\t},\n\n\t\t\tmax: function getMaxHeight(){\n\t\t\t\treturn Math.max.apply(null,getAllMeasurements(getHeight));\n\t\t\t},\n\n\t\t\tmin: function getMinHeight(){\n\t\t\t\treturn Math.min.apply(null,getAllMeasurements(getHeight));\n\t\t\t},\n\n\t\t\tgrow: function growHeight(){\n\t\t\t\treturn getHeight.max(); //Run max without the forced downsizing\n\t\t\t},\n\n\t\t\tlowestElement: function getBestHeight(){\n\t\t\t\treturn Math.max(getHeight.bodyOffset(), getMaxElement('bottom',getAllElements()));\n\t\t\t},\n\n\t\t\ttaggedElement: function getTaggedElementsHeight(){\n\t\t\t\treturn getTaggedElements('bottom','data-iframe-height');\n\t\t\t}\n\t\t},\n\n\t\tgetWidth = {\n\t\t\tbodyScroll: function getBodyScrollWidth(){\n\t\t\t\treturn document.body.scrollWidth;\n\t\t\t},\n\n\t\t\tbodyOffset: function getBodyOffsetWidth(){\n\t\t\t\treturn document.body.offsetWidth;\n\t\t\t},\n\n\t\t\tcustom: function getCustomWidth(){\n\t\t\t\treturn customCalcMethods.width();\n\t\t\t},\n\n\t\t\tdocumentElementScroll: function getDEScrollWidth(){\n\t\t\t\treturn document.documentElement.scrollWidth;\n\t\t\t},\n\n\t\t\tdocumentElementOffset: function getDEOffsetWidth(){\n\t\t\t\treturn document.documentElement.offsetWidth;\n\t\t\t},\n\n\t\t\tscroll: function getMaxWidth(){\n\t\t\t\treturn Math.max(getWidth.bodyScroll(), getWidth.documentElementScroll());\n\t\t\t},\n\n\t\t\tmax: function getMaxWidth(){\n\t\t\t\treturn Math.max.apply(null,getAllMeasurements(getWidth));\n\t\t\t},\n\n\t\t\tmin: function getMinWidth(){\n\t\t\t\treturn Math.min.apply(null,getAllMeasurements(getWidth));\n\t\t\t},\n\n\t\t\trightMostElement: function rightMostElement(){\n\t\t\t\treturn getMaxElement('right', getAllElements());\n\t\t\t},\n\n\t\t\ttaggedElement: function getTaggedElementsWidth(){\n\t\t\t\treturn getTaggedElements('right', 'data-iframe-width');\n\t\t\t}\n\t\t};\n\n\n\tfunction sizeIFrame(triggerEvent, triggerEventDesc, customHeight, customWidth){\n\n\t\tfunction resizeIFrame(){\n\t\t\theight = currentHeight;\n\t\t\twidth = currentWidth;\n\n\t\t\tsendMsg(height,width,triggerEvent);\n\t\t}\n\n\t\tfunction isSizeChangeDetected(){\n\t\t\tfunction checkTolarance(a,b){\n\t\t\t\tvar retVal = Math.abs(a-b) <= tolerance;\n\t\t\t\treturn !retVal;\n\t\t\t}\n\n\t\t\tcurrentHeight = (undefined !== customHeight) ? customHeight : getHeight[heightCalcMode]();\n\t\t\tcurrentWidth = (undefined !== customWidth ) ? customWidth : getWidth[widthCalcMode]();\n\n\t\t\treturn\tcheckTolarance(height,currentHeight) || (calculateWidth && checkTolarance(width,currentWidth));\n\t\t}\n\n\t\tfunction isForceResizableEvent(){\n\t\t\treturn !(triggerEvent in {'init':1,'interval':1,'size':1});\n\t\t}\n\n\t\tfunction isForceResizableCalcMode(){\n\t\t\treturn (heightCalcMode in resetRequiredMethods) || (calculateWidth && widthCalcMode in resetRequiredMethods);\n\t\t}\n\n\t\tfunction logIgnored(){\n\t\t\tlog('No change in size detected');\n\t\t}\n\n\t\tfunction checkDownSizing(){\n\t\t\tif (isForceResizableEvent() && isForceResizableCalcMode()){\n\t\t\t\tresetIFrame(triggerEventDesc);\n\t\t\t} else if (!(triggerEvent in {'interval':1})){\n\t\t\t\tlogIgnored();\n\t\t\t}\n\t\t}\n\n\t\tvar\tcurrentHeight,currentWidth;\n\n\t\tif (isSizeChangeDetected() || 'init' === triggerEvent){\n\t\t\tlockTrigger();\n\t\t\tresizeIFrame();\n\t\t} else {\n\t\t\tcheckDownSizing();\n\t\t}\n\t}\n\n\tvar sizeIFrameThrottled = throttle(sizeIFrame);\n\n\tfunction sendSize(triggerEvent, triggerEventDesc, customHeight, customWidth){\n\t\tfunction recordTrigger(){\n\t\t\tif (!(triggerEvent in {'reset':1,'resetPage':1,'init':1})){\n\t\t\t\tlog( 'Trigger event: ' + triggerEventDesc );\n\t\t\t}\n\t\t}\n\n\t\tfunction isDoubleFiredEvent(){\n\t\t\treturn triggerLocked && (triggerEvent in doubleEventList);\n\t\t}\n\n\t\tif (!isDoubleFiredEvent()){\n\t\t\trecordTrigger();\n\t\t\tsizeIFrameThrottled(triggerEvent, triggerEventDesc, customHeight, customWidth);\n\t\t} else {\n\t\t\tlog('Trigger event cancelled: '+triggerEvent);\n\t\t}\n\t}\n\n\tfunction lockTrigger(){\n\t\tif (!triggerLocked){\n\t\t\ttriggerLocked = true;\n\t\t\tlog('Trigger event lock on');\n\t\t}\n\t\tclearTimeout(triggerLockedTimer);\n\t\ttriggerLockedTimer = setTimeout(function(){\n\t\t\ttriggerLocked = false;\n\t\t\tlog('Trigger event lock off');\n\t\t\tlog('--');\n\t\t},eventCancelTimer);\n\t}\n\n\tfunction triggerReset(triggerEvent){\n\t\theight = getHeight[heightCalcMode]();\n\t\twidth = getWidth[widthCalcMode]();\n\n\t\tsendMsg(height,width,triggerEvent);\n\t}\n\n\tfunction resetIFrame(triggerEventDesc){\n\t\tvar hcm = heightCalcMode;\n\t\theightCalcMode = heightCalcModeDefault;\n\n\t\tlog('Reset trigger event: ' + triggerEventDesc);\n\t\tlockTrigger();\n\t\ttriggerReset('reset');\n\n\t\theightCalcMode = hcm;\n\t}\n\n\tfunction sendMsg(height,width,triggerEvent,msg,targetOrigin){\n\t\tfunction setTargetOrigin(){\n\t\t\tif (undefined === targetOrigin){\n\t\t\t\ttargetOrigin = targetOriginDefault;\n\t\t\t} else {\n\t\t\t\tlog('Message targetOrigin: '+targetOrigin);\n\t\t\t}\n\t\t}\n\n\t\tfunction sendToParent(){\n\t\t\tvar\n\t\t\t\tsize = height + ':' + width,\n\t\t\t\tmessage = myID + ':' + size + ':' + triggerEvent + (undefined !== msg ? ':' + msg : '');\n\n\t\t\tlog('Sending message to host page (' + message + ')');\n\t\t\ttarget.postMessage( msgID + message, targetOrigin);\n\t\t}\n\n\t\tif(true === sendPermit){\n\t\t\tsetTargetOrigin();\n\t\t\tsendToParent();\n\t\t}\n\t}\n\n\tfunction receiver(event) {\n\t\tvar processRequestFromParent = {\n\t\t\tinit: function initFromParent(){\n\t\t\t\tfunction fireInit(){\n\t\t\t\t\tinitMsg = event.data;\n\t\t\t\t\ttarget = event.source;\n\n\t\t\t\t\tinit();\n\t\t\t\t\tfirstRun = false;\n\t\t\t\t\tsetTimeout(function(){ initLock = false;},eventCancelTimer);\n\t\t\t\t}\n\n\t\t\t\tif (document.readyState === \"interactive\" || document.readyState === \"complete\"){\n\t\t\t\t\tfireInit();\n\t\t\t\t} else {\n\t\t\t\t\tlog('Waiting for page ready');\n\t\t\t\t\taddEventListener(window,'readystatechange',processRequestFromParent.initFromParent);\n\t\t\t\t}\n\t\t\t},\n\n\t\t\treset: function resetFromParent(){\n\t\t\t\tif (!initLock){\n\t\t\t\t\tlog('Page size reset by host page');\n\t\t\t\t\ttriggerReset('resetPage');\n\t\t\t\t} else {\n\t\t\t\t\tlog('Page reset ignored by init');\n\t\t\t\t}\n\t\t\t},\n\n\t\t\tresize: function resizeFromParent(){\n\t\t\t\tsendSize('resizeParent','Parent window requested size check');\n\t\t\t},\n\n\t\t\tmoveToAnchor: function moveToAnchorF(){\n\t\t\t\tinPageLinks.findTarget(getData());\n\t\t\t},\n\t\t\tinPageLink: function inPageLinkF() {this.moveToAnchor();}, //Backward compatability\n\n\t\t\tpageInfo: function pageInfoFromParent(){\n\t\t\t\tvar msgBody = getData();\n\t\t\t\tlog('PageInfoFromParent called from parent: ' + msgBody );\n\t\t\t\tpageInfoCallback(JSON.parse(msgBody));\n\t\t\t\tlog(' --');\n\t\t\t},\n\n\t\t\tmessage: function messageFromParent(){\n\t\t\t\tvar msgBody = getData();\n\n\t\t\t\tlog('MessageCallback called from parent: ' + msgBody );\n\t\t\t\tmessageCallback(JSON.parse(msgBody));\n\t\t\t\tlog(' --');\n\t\t\t}\n\t\t};\n\n\t\tfunction isMessageForUs(){\n\t\t\treturn msgID === (''+event.data).substr(0,msgIdLen); //''+ Protects against non-string messages\n\t\t}\n\n\t\tfunction getMessageType(){\n\t\t\treturn event.data.split(']')[1].split(':')[0];\n\t\t}\n\n\t\tfunction getData(){\n\t\t\treturn event.data.substr(event.data.indexOf(':')+1);\n\t\t}\n\n\t\tfunction isMiddleTier(){\n\t\t\treturn !(typeof module !== 'undefined' && module.exports) && ('iFrameResize' in window);\n\t\t}\n\n\t\tfunction isInitMsg(){\n\t\t\t//Test if this message is from a child below us. This is an ugly test, however, updating\n\t\t\t//the message format would break backwards compatibity.\n\t\t\treturn event.data.split(':')[2] in {'true':1,'false':1};\n\t\t}\n\n\t\tfunction callFromParent(){\n\t\t\tvar messageType = getMessageType();\n\n\t\t\tif (messageType in processRequestFromParent){\n\t\t\t\tprocessRequestFromParent[messageType]();\n\t\t\t} else if (!isMiddleTier() && !isInitMsg()){\n\t\t\t\twarn('Unexpected message ('+event.data+')');\n\t\t\t}\n\t\t}\n\n\t\tfunction processMessage(){\n\t\t\tif (false === firstRun) {\n\t\t\t\tcallFromParent();\n\t\t\t} else if (isInitMsg()) {\n\t\t\t\tprocessRequestFromParent.init();\n\t\t\t} else {\n\t\t\t\tlog('Ignored message of type \"' + getMessageType() + '\". Received before initialization.');\n\t\t\t}\n\t\t}\n\n\t\tif (isMessageForUs()){\n\t\t\tprocessMessage();\n\t\t}\n\t}\n\n\t//Normally the parent kicks things off when it detects the iFrame has loaded.\n\t//If this script is async-loaded, then tell parent page to retry init.\n\tfunction chkLateLoaded(){\n\t\tif('loading' !== document.readyState){\n\t\t\twindow.parent.postMessage('[iFrameResizerChild]Ready','*');\n\t\t}\n\t}\n\n\taddEventListener(window, 'message', receiver);\n\tchkLateLoaded();\n\n\t\n\n})();\n"]} \ No newline at end of file diff --git a/assets/js/iframe-resizer/iframeResizer.contentWindow.min.js b/assets/js/iframe-resizer/iframeResizer.contentWindow.min.js new file mode 100644 index 0000000..950935b --- /dev/null +++ b/assets/js/iframe-resizer/iframeResizer.contentWindow.min.js @@ -0,0 +1,10 @@ +/*! iFrame Resizer (iframeSizer.contentWindow.min.js) - v3.5.15 - 2017-10-15 + * Desc: Include this file in any page being loaded into an iframe + * to force the iframe to resize to the content size. + * Requires: iframeResizer.min.js on host page. + * Copyright: (c) 2017 David J. Bradshaw - dave@bradshaw.net + * License: MIT + */ + +!function(a){"use strict";function b(a,b,c){"addEventListener"in window?a.addEventListener(b,c,!1):"attachEvent"in window&&a.attachEvent("on"+b,c)}function c(a,b,c){"removeEventListener"in window?a.removeEventListener(b,c,!1):"detachEvent"in window&&a.detachEvent("on"+b,c)}function d(a){return a.charAt(0).toUpperCase()+a.slice(1)}function e(a){var b,c,d,e=null,f=0,g=function(){f=Ha(),e=null,d=a.apply(b,c),e||(b=c=null)};return function(){var h=Ha();f||(f=h);var i=xa-(h-f);return b=this,c=arguments,0>=i||i>xa?(e&&(clearTimeout(e),e=null),f=h,d=a.apply(b,c),e||(b=c=null)):e||(e=setTimeout(g,i)),d}}function f(a){return ma+"["+oa+"] "+a}function g(a){la&&"object"==typeof window.console&&console.log(f(a))}function h(a){"object"==typeof window.console&&console.warn(f(a))}function i(){j(),g("Initialising iFrame ("+location.href+")"),k(),n(),m("background",W),m("padding",$),A(),s(),t(),o(),C(),u(),ia=B(),N("init","Init message from host page"),Da()}function j(){function b(a){return"true"===a?!0:!1}var c=ha.substr(na).split(":");oa=c[0],X=a!==c[1]?Number(c[1]):X,_=a!==c[2]?b(c[2]):_,la=a!==c[3]?b(c[3]):la,ja=a!==c[4]?Number(c[4]):ja,U=a!==c[6]?b(c[6]):U,Y=c[7],fa=a!==c[8]?c[8]:fa,W=c[9],$=c[10],ua=a!==c[11]?Number(c[11]):ua,ia.enable=a!==c[12]?b(c[12]):!1,qa=a!==c[13]?c[13]:qa,Aa=a!==c[14]?c[14]:Aa}function k(){function a(){var a=window.iFrameResizer;g("Reading data from page: "+JSON.stringify(a)),Ca="messageCallback"in a?a.messageCallback:Ca,Da="readyCallback"in a?a.readyCallback:Da,ta="targetOrigin"in a?a.targetOrigin:ta,fa="heightCalculationMethod"in a?a.heightCalculationMethod:fa,Aa="widthCalculationMethod"in a?a.widthCalculationMethod:Aa}function b(a,b){return"function"==typeof a&&(g("Setup custom "+b+"CalcMethod"),Fa[b]=a,a="custom"),a}"iFrameResizer"in window&&Object===window.iFrameResizer.constructor&&(a(),fa=b(fa,"height"),Aa=b(Aa,"width")),g("TargetOrigin for parent set to: "+ta)}function l(a,b){return-1!==b.indexOf("-")&&(h("Negative CSS value ignored for "+a),b=""),b}function m(b,c){a!==c&&""!==c&&"null"!==c&&(document.body.style[b]=c,g("Body "+b+' set to "'+c+'"'))}function n(){a===Y&&(Y=X+"px"),m("margin",l("margin",Y))}function o(){document.documentElement.style.height="",document.body.style.height="",g('HTML & body height set to "auto"')}function p(a){var e={add:function(c){function d(){N(a.eventName,a.eventType)}Ga[c]=d,b(window,c,d)},remove:function(a){var b=Ga[a];delete Ga[a],c(window,a,b)}};a.eventNames&&Array.prototype.map?(a.eventName=a.eventNames[0],a.eventNames.map(e[a.method])):e[a.method](a.eventName),g(d(a.method)+" event listener: "+a.eventType)}function q(a){p({method:a,eventType:"Animation Start",eventNames:["animationstart","webkitAnimationStart"]}),p({method:a,eventType:"Animation Iteration",eventNames:["animationiteration","webkitAnimationIteration"]}),p({method:a,eventType:"Animation End",eventNames:["animationend","webkitAnimationEnd"]}),p({method:a,eventType:"Input",eventName:"input"}),p({method:a,eventType:"Mouse Up",eventName:"mouseup"}),p({method:a,eventType:"Mouse Down",eventName:"mousedown"}),p({method:a,eventType:"Orientation Change",eventName:"orientationchange"}),p({method:a,eventType:"Print",eventName:["afterprint","beforeprint"]}),p({method:a,eventType:"Ready State Change",eventName:"readystatechange"}),p({method:a,eventType:"Touch Start",eventName:"touchstart"}),p({method:a,eventType:"Touch End",eventName:"touchend"}),p({method:a,eventType:"Touch Cancel",eventName:"touchcancel"}),p({method:a,eventType:"Transition Start",eventNames:["transitionstart","webkitTransitionStart","MSTransitionStart","oTransitionStart","otransitionstart"]}),p({method:a,eventType:"Transition Iteration",eventNames:["transitioniteration","webkitTransitionIteration","MSTransitionIteration","oTransitionIteration","otransitioniteration"]}),p({method:a,eventType:"Transition End",eventNames:["transitionend","webkitTransitionEnd","MSTransitionEnd","oTransitionEnd","otransitionend"]}),"child"===qa&&p({method:a,eventType:"IFrame Resized",eventName:"resize"})}function r(a,b,c,d){return b!==a&&(a in c||(h(a+" is not a valid option for "+d+"CalculationMethod."),a=b),g(d+' calculation method set to "'+a+'"')),a}function s(){fa=r(fa,ea,Ia,"height")}function t(){Aa=r(Aa,za,Ja,"width")}function u(){!0===U?(q("add"),F()):g("Auto Resize disabled")}function v(){g("Disable outgoing messages"),ra=!1}function w(){g("Remove event listener: Message"),c(window,"message",S)}function x(){null!==Z&&Z.disconnect()}function y(){q("remove"),x(),clearInterval(ka)}function z(){v(),w(),!0===U&&y()}function A(){var a=document.createElement("div");a.style.clear="both",a.style.display="block",document.body.appendChild(a)}function B(){function c(){return{x:window.pageXOffset!==a?window.pageXOffset:document.documentElement.scrollLeft,y:window.pageYOffset!==a?window.pageYOffset:document.documentElement.scrollTop}}function d(a){var b=a.getBoundingClientRect(),d=c();return{x:parseInt(b.left,10)+parseInt(d.x,10),y:parseInt(b.top,10)+parseInt(d.y,10)}}function e(b){function c(a){var b=d(a);g("Moving to in page link (#"+e+") at x: "+b.x+" y: "+b.y),R(b.y,b.x,"scrollToOffset")}var e=b.split("#")[1]||b,f=decodeURIComponent(e),h=document.getElementById(f)||document.getElementsByName(f)[0];a!==h?c(h):(g("In page link (#"+e+") not found in iFrame, so sending to parent"),R(0,0,"inPageLink","#"+e))}function f(){""!==location.hash&&"#"!==location.hash&&e(location.href)}function i(){function a(a){function c(a){a.preventDefault(),e(this.getAttribute("href"))}"#"!==a.getAttribute("href")&&b(a,"click",c)}Array.prototype.forEach.call(document.querySelectorAll('a[href^="#"]'),a)}function j(){b(window,"hashchange",f)}function k(){setTimeout(f,ba)}function l(){Array.prototype.forEach&&document.querySelectorAll?(g("Setting up location.hash handlers"),i(),j(),k()):h("In page linking not fully supported in this browser! (See README.md for IE8 workaround)")}return ia.enable?l():g("In page linking not enabled"),{findTarget:e}}function C(){g("Enable public methods"),Ba.parentIFrame={autoResize:function(a){return!0===a&&!1===U?(U=!0,u()):!1===a&&!0===U&&(U=!1,y()),U},close:function(){R(0,0,"close"),z()},getId:function(){return oa},getPageInfo:function(a){"function"==typeof a?(Ea=a,R(0,0,"pageInfo")):(Ea=function(){},R(0,0,"pageInfoStop"))},moveToAnchor:function(a){ia.findTarget(a)},reset:function(){Q("parentIFrame.reset")},scrollTo:function(a,b){R(b,a,"scrollTo")},scrollToOffset:function(a,b){R(b,a,"scrollToOffset")},sendMessage:function(a,b){R(0,0,"message",JSON.stringify(a),b)},setHeightCalculationMethod:function(a){fa=a,s()},setWidthCalculationMethod:function(a){Aa=a,t()},setTargetOrigin:function(a){g("Set targetOrigin: "+a),ta=a},size:function(a,b){var c=""+(a?a:"")+(b?","+b:"");N("size","parentIFrame.size("+c+")",a,b)}}}function D(){0!==ja&&(g("setInterval: "+ja+"ms"),ka=setInterval(function(){N("interval","setInterval: "+ja)},Math.abs(ja)))}function E(){function b(a){function b(a){!1===a.complete&&(g("Attach listeners to "+a.src),a.addEventListener("load",f,!1),a.addEventListener("error",h,!1),k.push(a))}"attributes"===a.type&&"src"===a.attributeName?b(a.target):"childList"===a.type&&Array.prototype.forEach.call(a.target.querySelectorAll("img"),b)}function c(a){k.splice(k.indexOf(a),1)}function d(a){g("Remove listeners from "+a.src),a.removeEventListener("load",f,!1),a.removeEventListener("error",h,!1),c(a)}function e(b,c,e){d(b.target),N(c,e+": "+b.target.src,a,a)}function f(a){e(a,"imageLoad","Image loaded")}function h(a){e(a,"imageLoadFailed","Image load failed")}function i(a){N("mutationObserver","mutationObserver: "+a[0].target+" "+a[0].type),a.forEach(b)}function j(){var a=document.querySelector("body"),b={attributes:!0,attributeOldValue:!1,characterData:!0,characterDataOldValue:!1,childList:!0,subtree:!0};return m=new l(i),g("Create body MutationObserver"),m.observe(a,b),m}var k=[],l=window.MutationObserver||window.WebKitMutationObserver,m=j();return{disconnect:function(){"disconnect"in m&&(g("Disconnect body MutationObserver"),m.disconnect(),k.forEach(d))}}}function F(){var a=0>ja;window.MutationObserver||window.WebKitMutationObserver?a?D():Z=E():(g("MutationObserver not supported in this browser!"),D())}function G(a,b){function c(a){var c=/^\d+(px)?$/i;if(c.test(a))return parseInt(a,V);var d=b.style.left,e=b.runtimeStyle.left;return b.runtimeStyle.left=b.currentStyle.left,b.style.left=a||0,a=b.style.pixelLeft,b.style.left=d,b.runtimeStyle.left=e,a}var d=0;return b=b||document.body,"defaultView"in document&&"getComputedStyle"in document.defaultView?(d=document.defaultView.getComputedStyle(b,null),d=null!==d?d[a]:0):d=c(b.currentStyle[a]),parseInt(d,V)}function H(a){a>xa/2&&(xa=2*a,g("Event throttle increased to "+xa+"ms"))}function I(a,b){for(var c=b.length,e=0,f=0,h=d(a),i=Ha(),j=0;c>j;j++)e=b[j].getBoundingClientRect()[a]+G("margin"+h,b[j]),e>f&&(f=e);return i=Ha()-i,g("Parsed "+c+" HTML elements"),g("Element position calculated in "+i+"ms"),H(i),f}function J(a){return[a.bodyOffset(),a.bodyScroll(),a.documentElementOffset(),a.documentElementScroll()]}function K(a,b){function c(){return h("No tagged elements ("+b+") found on page"),document.querySelectorAll("body *")}var d=document.querySelectorAll("["+b+"]");return 0===d.length&&c(),I(a,d)}function L(){return document.querySelectorAll("body *")}function M(b,c,d,e){function f(){da=m,ya=n,R(da,ya,b)}function h(){function b(a,b){var c=Math.abs(a-b)<=ua;return!c}return m=a!==d?d:Ia[fa](),n=a!==e?e:Ja[Aa](),b(da,m)||_&&b(ya,n)}function i(){return!(b in{init:1,interval:1,size:1})}function j(){return fa in pa||_&&Aa in pa}function k(){g("No change in size detected")}function l(){i()&&j()?Q(c):b in{interval:1}||k()}var m,n;h()||"init"===b?(O(),f()):l()}function N(a,b,c,d){function e(){a in{reset:1,resetPage:1,init:1}||g("Trigger event: "+b)}function f(){return va&&a in aa}f()?g("Trigger event cancelled: "+a):(e(),Ka(a,b,c,d))}function O(){va||(va=!0,g("Trigger event lock on")),clearTimeout(wa),wa=setTimeout(function(){va=!1,g("Trigger event lock off"),g("--")},ba)}function P(a){da=Ia[fa](),ya=Ja[Aa](),R(da,ya,a)}function Q(a){var b=fa;fa=ea,g("Reset trigger event: "+a),O(),P("reset"),fa=b}function R(b,c,d,e,f){function h(){a===f?f=ta:g("Message targetOrigin: "+f)}function i(){var h=b+":"+c,i=oa+":"+h+":"+d+(a!==e?":"+e:"");g("Sending message to host page ("+i+")"),sa.postMessage(ma+i,f)}!0===ra&&(h(),i())}function S(a){function c(){return ma===(""+a.data).substr(0,na)}function d(){return a.data.split("]")[1].split(":")[0]}function e(){return a.data.substr(a.data.indexOf(":")+1)}function f(){return!("undefined"!=typeof module&&module.exports)&&"iFrameResize"in window}function j(){return a.data.split(":")[2]in{"true":1,"false":1}}function k(){var b=d();b in m?m[b]():f()||j()||h("Unexpected message ("+a.data+")")}function l(){!1===ca?k():j()?m.init():g('Ignored message of type "'+d()+'". Received before initialization.')}var m={init:function(){function c(){ha=a.data,sa=a.source,i(),ca=!1,setTimeout(function(){ga=!1},ba)}"interactive"===document.readyState||"complete"===document.readyState?c():(g("Waiting for page ready"),b(window,"readystatechange",m.initFromParent))},reset:function(){ga?g("Page reset ignored by init"):(g("Page size reset by host page"),P("resetPage"))},resize:function(){N("resizeParent","Parent window requested size check")},moveToAnchor:function(){ia.findTarget(e())},inPageLink:function(){this.moveToAnchor()},pageInfo:function(){var a=e();g("PageInfoFromParent called from parent: "+a),Ea(JSON.parse(a)),g(" --")},message:function(){var a=e();g("MessageCallback called from parent: "+a),Ca(JSON.parse(a)),g(" --")}};c()&&l()}function T(){"loading"!==document.readyState&&window.parent.postMessage("[iFrameResizerChild]Ready","*")}if("undefined"!=typeof window){var U=!0,V=10,W="",X=0,Y="",Z=null,$="",_=!1,aa={resize:1,click:1},ba=128,ca=!0,da=1,ea="bodyOffset",fa=ea,ga=!0,ha="",ia={},ja=32,ka=null,la=!1,ma="[iFrameSizer]",na=ma.length,oa="",pa={max:1,min:1,bodyScroll:1,documentElementScroll:1},qa="child",ra=!0,sa=window.parent,ta="*",ua=0,va=!1,wa=null,xa=16,ya=1,za="scroll",Aa=za,Ba=window,Ca=function(){h("MessageCallback function not defined")},Da=function(){},Ea=function(){},Fa={height:function(){return h("Custom height calculation function not defined"),document.documentElement.offsetHeight},width:function(){return h("Custom width calculation function not defined"),document.body.scrollWidth}},Ga={},Ha=Date.now||function(){return(new Date).getTime()},Ia={bodyOffset:function(){return document.body.offsetHeight+G("marginTop")+G("marginBottom")},offset:function(){return Ia.bodyOffset()},bodyScroll:function(){return document.body.scrollHeight},custom:function(){return Fa.height()},documentElementOffset:function(){return document.documentElement.offsetHeight},documentElementScroll:function(){return document.documentElement.scrollHeight},max:function(){return Math.max.apply(null,J(Ia))},min:function(){return Math.min.apply(null,J(Ia))},grow:function(){return Ia.max()},lowestElement:function(){return Math.max(Ia.bodyOffset(),I("bottom",L()))},taggedElement:function(){return K("bottom","data-iframe-height")}},Ja={bodyScroll:function(){return document.body.scrollWidth},bodyOffset:function(){return document.body.offsetWidth},custom:function(){return Fa.width()},documentElementScroll:function(){return document.documentElement.scrollWidth},documentElementOffset:function(){return document.documentElement.offsetWidth},scroll:function(){return Math.max(Ja.bodyScroll(),Ja.documentElementScroll())},max:function(){return Math.max.apply(null,J(Ja))},min:function(){return Math.min.apply(null,J(Ja))},rightMostElement:function(){return I("right",L())},taggedElement:function(){return K("right","data-iframe-width")}},Ka=e(M);b(window,"message",S),T()}}(); +//# sourceMappingURL=iframeResizer.contentWindow.map \ No newline at end of file diff --git a/assets/js/iframe-resizer/iframeResizer.js b/assets/js/iframe-resizer/iframeResizer.js new file mode 100644 index 0000000..6c8848c --- /dev/null +++ b/assets/js/iframe-resizer/iframeResizer.js @@ -0,0 +1,1052 @@ +/* + * File: iframeResizer.js + * Desc: Force iframes to size to content. + * Requires: iframeResizer.contentWindow.js to be loaded into the target frame. + * Doc: https://github.com/davidjbradshaw/iframe-resizer + * Author: David J. Bradshaw - dave@bradshaw.net + * Contributor: Jure Mav - jure.mav@gmail.com + * Contributor: Reed Dadoune - reed@dadoune.com + */ + + +;(function(undefined) { + 'use strict'; + + if(typeof window === 'undefined') return; // don't run for server side render + + var + count = 0, + logEnabled = false, + hiddenCheckEnabled = false, + msgHeader = 'message', + msgHeaderLen = msgHeader.length, + msgId = '[iFrameSizer]', //Must match iframe msg ID + msgIdLen = msgId.length, + pagePosition = null, + requestAnimationFrame = window.requestAnimationFrame, + resetRequiredMethods = {max:1,scroll:1,bodyScroll:1,documentElementScroll:1}, + settings = {}, + timer = null, + logId = 'Host Page', + + defaults = { + autoResize : true, + bodyBackground : null, + bodyMargin : null, + bodyMarginV1 : 8, + bodyPadding : null, + checkOrigin : true, + inPageLinks : false, + enablePublicMethods : true, + heightCalculationMethod : 'bodyOffset', + id : 'iFrameResizer', + interval : 32, + log : false, + maxHeight : Infinity, + maxWidth : Infinity, + minHeight : 0, + minWidth : 0, + resizeFrom : 'parent', + scrolling : false, + sizeHeight : true, + sizeWidth : false, + warningTimeout : 5000, + tolerance : 0, + widthCalculationMethod : 'scroll', + closedCallback : function(){}, + initCallback : function(){}, + messageCallback : function(){warn('MessageCallback function not defined');}, + resizedCallback : function(){}, + scrollCallback : function(){return true;} + }; + + function addEventListener(obj,evt,func){ + /* istanbul ignore else */ // Not testable in PhantonJS + if ('addEventListener' in window){ + obj.addEventListener(evt,func, false); + } else if ('attachEvent' in window){//IE + obj.attachEvent('on'+evt,func); + } + } + + function removeEventListener(el,evt,func){ + /* istanbul ignore else */ // Not testable in phantonJS + if ('removeEventListener' in window){ + el.removeEventListener(evt,func, false); + } else if ('detachEvent' in window){ //IE + el.detachEvent('on'+evt,func); + } + } + + function setupRequestAnimationFrame(){ + var + vendors = ['moz', 'webkit', 'o', 'ms'], + x; + + // Remove vendor prefixing if prefixed and break early if not + for (x = 0; x < vendors.length && !requestAnimationFrame; x += 1) { + requestAnimationFrame = window[vendors[x] + 'RequestAnimationFrame']; + } + + if (!(requestAnimationFrame)){ + log('setup','RequestAnimationFrame not supported'); + } + } + + function getMyID(iframeId){ + var retStr = 'Host page: '+iframeId; + + if (window.top !== window.self){ + if (window.parentIFrame && window.parentIFrame.getId){ + retStr = window.parentIFrame.getId()+': '+iframeId; + } else { + retStr = 'Nested host page: '+iframeId; + } + } + + return retStr; + } + + function formatLogHeader(iframeId){ + return msgId + '[' + getMyID(iframeId) + ']'; + } + + function isLogEnabled(iframeId){ + return settings[iframeId] ? settings[iframeId].log : logEnabled; + } + + function log(iframeId,msg){ + output('log',iframeId,msg,isLogEnabled(iframeId)); + } + + function info(iframeId,msg){ + output('info',iframeId,msg,isLogEnabled(iframeId)); + } + + function warn(iframeId,msg){ + output('warn',iframeId,msg,true); + } + + function output(type,iframeId,msg,enabled){ + if (true === enabled && 'object' === typeof window.console){ + console[type](formatLogHeader(iframeId),msg); + } + } + + function iFrameListener(event){ + function resizeIFrame(){ + function resize(){ + setSize(messageData); + setPagePosition(iframeId); + callback('resizedCallback',messageData); + } + + ensureInRange('Height'); + ensureInRange('Width'); + + syncResize(resize,messageData,'init'); + } + + function processMsg(){ + var data = msg.substr(msgIdLen).split(':'); + + return { + iframe: settings[data[0]] && settings[data[0]].iframe, + id: data[0], + height: data[1], + width: data[2], + type: data[3] + }; + } + + function ensureInRange(Dimension){ + var + max = Number(settings[iframeId]['max' + Dimension]), + min = Number(settings[iframeId]['min' + Dimension]), + dimension = Dimension.toLowerCase(), + size = Number(messageData[dimension]); + + log(iframeId,'Checking ' + dimension + ' is in range ' + min + '-' + max); + + if (sizemax) { + size=max; + log(iframeId,'Set ' + dimension + ' to max value'); + } + + messageData[dimension] = '' + size; + } + + + function isMessageFromIFrame(){ + function checkAllowedOrigin(){ + function checkList(){ + var + i = 0, + retCode = false; + + log(iframeId,'Checking connection is from allowed list of origins: ' + checkOrigin); + + for (; i < checkOrigin.length; i++) { + if (checkOrigin[i] === origin) { + retCode = true; + break; + } + } + return retCode; + } + + function checkSingle(){ + var remoteHost = settings[iframeId] && settings[iframeId].remoteHost; + log(iframeId,'Checking connection is from: '+remoteHost); + return origin === remoteHost; + } + + return checkOrigin.constructor === Array ? checkList() : checkSingle(); + } + + var + origin = event.origin, + checkOrigin = settings[iframeId] && settings[iframeId].checkOrigin; + + if (checkOrigin && (''+origin !== 'null') && !checkAllowedOrigin()) { + throw new Error( + 'Unexpected message received from: ' + origin + + ' for ' + messageData.iframe.id + + '. Message was: ' + event.data + + '. This error can be disabled by setting the checkOrigin: false option or by providing of array of trusted domains.' + ); + } + + return true; + } + + function isMessageForUs(){ + return msgId === (('' + msg).substr(0,msgIdLen)) && (msg.substr(msgIdLen).split(':')[0] in settings); //''+Protects against non-string msg + } + + function isMessageFromMetaParent(){ + //Test if this message is from a parent above us. This is an ugly test, however, updating + //the message format would break backwards compatibity. + var retCode = messageData.type in {'true':1,'false':1,'undefined':1}; + + if (retCode){ + log(iframeId,'Ignoring init message from meta parent page'); + } + + return retCode; + } + + function getMsgBody(offset){ + return msg.substr(msg.indexOf(':')+msgHeaderLen+offset); + } + + function forwardMsgFromIFrame(msgBody){ + log(iframeId,'MessageCallback passed: {iframe: '+ messageData.iframe.id + ', message: ' + msgBody + '}'); + callback('messageCallback',{ + iframe: messageData.iframe, + message: JSON.parse(msgBody) + }); + log(iframeId,'--'); + } + + function getPageInfo(){ + var + bodyPosition = document.body.getBoundingClientRect(), + iFramePosition = messageData.iframe.getBoundingClientRect(); + + return JSON.stringify({ + iframeHeight: iFramePosition.height, + iframeWidth: iFramePosition.width, + clientHeight: Math.max(document.documentElement.clientHeight, window.innerHeight || 0), + clientWidth: Math.max(document.documentElement.clientWidth, window.innerWidth || 0), + offsetTop: parseInt(iFramePosition.top - bodyPosition.top, 10), + offsetLeft: parseInt(iFramePosition.left - bodyPosition.left, 10), + scrollTop: window.pageYOffset, + scrollLeft: window.pageXOffset + }); + } + + function sendPageInfoToIframe(iframe,iframeId){ + function debouncedTrigger(){ + trigger( + 'Send Page Info', + 'pageInfo:' + getPageInfo(), + iframe, + iframeId + ); + } + + debouce(debouncedTrigger,32); + } + + + function startPageInfoMonitor(){ + function setListener(type,func){ + function sendPageInfo(){ + if (settings[id]){ + sendPageInfoToIframe(settings[id].iframe,id); + } else { + stop(); + } + } + + ['scroll','resize'].forEach(function(evt){ + log(id, type + evt + ' listener for sendPageInfo'); + func(window,evt,sendPageInfo); + }); + } + + function stop(){ + setListener('Remove ', removeEventListener); + } + + function start(){ + setListener('Add ', addEventListener); + } + + var id = iframeId; //Create locally scoped copy of iFrame ID + + start(); + + if (settings[id]) { + settings[id].stopPageInfo = stop; + } + } + + function stopPageInfoMonitor(){ + if (settings[iframeId] && settings[iframeId].stopPageInfo){ + settings[iframeId].stopPageInfo(); + delete settings[iframeId].stopPageInfo; + } + } + + function checkIFrameExists(){ + var retBool = true; + + if (null === messageData.iframe) { + warn(iframeId,'IFrame ('+messageData.id+') not found'); + retBool = false; + } + return retBool; + } + + function getElementPosition(target){ + var iFramePosition = target.getBoundingClientRect(); + + getPagePosition(iframeId); + + return { + x: Math.floor( Number(iFramePosition.left) + Number(pagePosition.x) ), + y: Math.floor( Number(iFramePosition.top) + Number(pagePosition.y) ) + }; + } + + function scrollRequestFromChild(addOffset){ + /* istanbul ignore next */ //Not testable in Karma + function reposition(){ + pagePosition = newPosition; + scrollTo(); + log(iframeId,'--'); + } + + function calcOffset(){ + return { + x: Number(messageData.width) + offset.x, + y: Number(messageData.height) + offset.y + }; + } + + function scrollParent(){ + if (window.parentIFrame){ + window.parentIFrame['scrollTo'+(addOffset?'Offset':'')](newPosition.x,newPosition.y); + } else { + warn(iframeId,'Unable to scroll to requested position, window.parentIFrame not found'); + } + } + + var + offset = addOffset ? getElementPosition(messageData.iframe) : {x:0,y:0}, + newPosition = calcOffset(); + + log(iframeId,'Reposition requested from iFrame (offset x:'+offset.x+' y:'+offset.y+')'); + + if(window.top !== window.self){ + scrollParent(); + } else { + reposition(); + } + } + + function scrollTo(){ + if (false !== callback('scrollCallback',pagePosition)){ + setPagePosition(iframeId); + } else { + unsetPagePosition(); + } + } + + function findTarget(location){ + function jumpToTarget(){ + var jumpPosition = getElementPosition(target); + + log(iframeId,'Moving to in page link (#'+hash+') at x: '+jumpPosition.x+' y: '+jumpPosition.y); + pagePosition = { + x: jumpPosition.x, + y: jumpPosition.y + }; + + scrollTo(); + log(iframeId,'--'); + } + + function jumpToParent(){ + if (window.parentIFrame){ + window.parentIFrame.moveToAnchor(hash); + } else { + log(iframeId,'In page link #'+hash+' not found and window.parentIFrame not found'); + } + } + + var + hash = location.split('#')[1] || '', + hashData = decodeURIComponent(hash), + target = document.getElementById(hashData) || document.getElementsByName(hashData)[0]; + + if (target){ + jumpToTarget(); + } else if(window.top!==window.self){ + jumpToParent(); + } else { + log(iframeId,'In page link #'+hash+' not found'); + } + } + + function callback(funcName,val){ + return chkCallback(iframeId,funcName,val); + } + + function actionMsg(){ + + if(settings[iframeId] && settings[iframeId].firstRun) firstRun(); + + switch(messageData.type){ + case 'close': + if(settings[iframeId].closeRequestCallback) chkCallback(iframeId, 'closeRequestCallback', settings[iframeId].iframe); + else closeIFrame(messageData.iframe); + break; + case 'message': + forwardMsgFromIFrame(getMsgBody(6)); + break; + case 'scrollTo': + scrollRequestFromChild(false); + break; + case 'scrollToOffset': + scrollRequestFromChild(true); + break; + case 'pageInfo': + sendPageInfoToIframe(settings[iframeId] && settings[iframeId].iframe,iframeId); + startPageInfoMonitor(); + break; + case 'pageInfoStop': + stopPageInfoMonitor(); + break; + case 'inPageLink': + findTarget(getMsgBody(9)); + break; + case 'reset': + resetIFrame(messageData); + break; + case 'init': + resizeIFrame(); + callback('initCallback',messageData.iframe); + break; + default: + resizeIFrame(); + } + } + + function hasSettings(iframeId){ + var retBool = true; + + if (!settings[iframeId]){ + retBool = false; + warn(messageData.type + ' No settings for ' + iframeId + '. Message was: ' + msg); + } + + return retBool; + } + + function iFrameReadyMsgReceived(){ + for (var iframeId in settings){ + trigger('iFrame requested init',createOutgoingMsg(iframeId),document.getElementById(iframeId),iframeId); + } + } + + function firstRun() { + if (settings[iframeId]) { + settings[iframeId].firstRun = false; + } + } + + function clearWarningTimeout() { + if (settings[iframeId]) { + clearTimeout(settings[iframeId].msgTimeout); + settings[iframeId].warningTimeout = 0; + } + } + + var + msg = event.data, + messageData = {}, + iframeId = null; + + if('[iFrameResizerChild]Ready' === msg){ + iFrameReadyMsgReceived(); + } else if (isMessageForUs()){ + messageData = processMsg(); + iframeId = logId = messageData.id; + if (settings[iframeId]) { + settings[iframeId].loaded = true; + } + + if (!isMessageFromMetaParent() && hasSettings(iframeId)){ + log(iframeId,'Received: '+msg); + + if ( checkIFrameExists() && isMessageFromIFrame() ){ + actionMsg(); + } + } + } else { + info(iframeId,'Ignored: '+msg); + } + + } + + + function chkCallback(iframeId,funcName,val){ + var + func = null, + retVal = null; + + if(settings[iframeId]){ + func = settings[iframeId][funcName]; + + if( 'function' === typeof func){ + retVal = func(val); + } else { + throw new TypeError(funcName+' on iFrame['+iframeId+'] is not a function'); + } + } + + return retVal; + } + + function closeIFrame(iframe){ + var iframeId = iframe.id; + + log(iframeId,'Removing iFrame: '+iframeId); + if (iframe.parentNode) { iframe.parentNode.removeChild(iframe); } + chkCallback(iframeId,'closedCallback',iframeId); + log(iframeId,'--'); + delete settings[iframeId]; + } + + function getPagePosition(iframeId){ + if(null === pagePosition){ + pagePosition = { + x: (window.pageXOffset !== undefined) ? window.pageXOffset : document.documentElement.scrollLeft, + y: (window.pageYOffset !== undefined) ? window.pageYOffset : document.documentElement.scrollTop + }; + log(iframeId,'Get page position: '+pagePosition.x+','+pagePosition.y); + } + } + + function setPagePosition(iframeId){ + if(null !== pagePosition){ + window.scrollTo(pagePosition.x,pagePosition.y); + log(iframeId,'Set page position: '+pagePosition.x+','+pagePosition.y); + unsetPagePosition(); + } + } + + function unsetPagePosition(){ + pagePosition = null; + } + + function resetIFrame(messageData){ + function reset(){ + setSize(messageData); + trigger('reset','reset',messageData.iframe,messageData.id); + } + + log(messageData.id,'Size reset requested by '+('init'===messageData.type?'host page':'iFrame')); + getPagePosition(messageData.id); + syncResize(reset,messageData,'reset'); + } + + function setSize(messageData){ + function setDimension(dimension){ + messageData.iframe.style[dimension] = messageData[dimension] + 'px'; + log( + messageData.id, + 'IFrame (' + iframeId + + ') ' + dimension + + ' set to ' + messageData[dimension] + 'px' + ); + } + + function chkZero(dimension){ + //FireFox sets dimension of hidden iFrames to zero. + //So if we detect that set up an event to check for + //when iFrame becomes visible. + + /* istanbul ignore next */ //Not testable in PhantomJS + if (!hiddenCheckEnabled && '0' === messageData[dimension]){ + hiddenCheckEnabled = true; + log(iframeId,'Hidden iFrame detected, creating visibility listener'); + fixHiddenIFrames(); + } + } + + function processDimension(dimension){ + setDimension(dimension); + chkZero(dimension); + } + + var iframeId = messageData.iframe.id; + + if(settings[iframeId]){ + if( settings[iframeId].sizeHeight) { processDimension('height'); } + if( settings[iframeId].sizeWidth ) { processDimension('width'); } + } + } + + function syncResize(func,messageData,doNotSync){ + /* istanbul ignore if */ //Not testable in PhantomJS + if(doNotSync!==messageData.type && requestAnimationFrame){ + log(messageData.id,'Requesting animation frame'); + requestAnimationFrame(func); + } else { + func(); + } + } + + function trigger(calleeMsg, msg, iframe, id, noResponseWarning) { + function postMessageToIFrame(){ + var target = settings[id] && settings[id].targetOrigin; + log(id,'[' + calleeMsg + '] Sending msg to iframe['+id+'] ('+msg+') targetOrigin: '+target); + iframe.contentWindow.postMessage( msgId + msg, target ); + } + + function iFrameNotFound(){ + warn(id,'[' + calleeMsg + '] IFrame('+id+') not found'); + } + + function chkAndSend(){ + if(iframe && 'contentWindow' in iframe && (null !== iframe.contentWindow)){ //Null test for PhantomJS + postMessageToIFrame(); + } else { + iFrameNotFound(); + } + } + + function warnOnNoResponse() { + function warning() { + if (settings[id] && !settings[id].loaded && !errorShown) { + errorShown = true; + warn(id, 'IFrame has not responded within '+ settings[id].warningTimeout/1000 +' seconds. Check iFrameResizer.contentWindow.js has been loaded in iFrame. This message can be ingored if everything is working, or you can set the warningTimeout option to a higher value or zero to suppress this warning.'); + } + } + + if (!!noResponseWarning && settings[id] && !!settings[id].warningTimeout) { + settings[id].msgTimeout = setTimeout(warning, settings[id].warningTimeout); + } + } + + var errorShown = false; + + id = id || iframe.id; + + if(settings[id]) { + chkAndSend(); + warnOnNoResponse(); + } + + } + + function createOutgoingMsg(iframeId){ + return iframeId + + ':' + settings[iframeId].bodyMarginV1 + + ':' + settings[iframeId].sizeWidth + + ':' + settings[iframeId].log + + ':' + settings[iframeId].interval + + ':' + settings[iframeId].enablePublicMethods + + ':' + settings[iframeId].autoResize + + ':' + settings[iframeId].bodyMargin + + ':' + settings[iframeId].heightCalculationMethod + + ':' + settings[iframeId].bodyBackground + + ':' + settings[iframeId].bodyPadding + + ':' + settings[iframeId].tolerance + + ':' + settings[iframeId].inPageLinks + + ':' + settings[iframeId].resizeFrom + + ':' + settings[iframeId].widthCalculationMethod; + } + + function setupIFrame(iframe,options){ + function setLimits(){ + function addStyle(style){ + if ((Infinity !== settings[iframeId][style]) && (0 !== settings[iframeId][style])){ + iframe.style[style] = settings[iframeId][style] + 'px'; + log(iframeId,'Set '+style+' = '+settings[iframeId][style]+'px'); + } + } + + function chkMinMax(dimension){ + if (settings[iframeId]['min'+dimension]>settings[iframeId]['max'+dimension]){ + throw new Error('Value for min'+dimension+' can not be greater than max'+dimension); + } + } + + chkMinMax('Height'); + chkMinMax('Width'); + + addStyle('maxHeight'); + addStyle('minHeight'); + addStyle('maxWidth'); + addStyle('minWidth'); + } + + function newId(){ + var id = ((options && options.id) || defaults.id + count++); + if (null !== document.getElementById(id)){ + id = id + count++; + } + return id; + } + + function ensureHasId(iframeId){ + logId=iframeId; + if (''===iframeId){ + iframe.id = iframeId = newId(); + logEnabled = (options || {}).log; + logId=iframeId; + log(iframeId,'Added missing iframe ID: '+ iframeId +' (' + iframe.src + ')'); + } + + + return iframeId; + } + + function setScrolling(){ + log(iframeId,'IFrame scrolling ' + (settings[iframeId] && settings[iframeId].scrolling ? 'enabled' : 'disabled') + ' for ' + iframeId); + iframe.style.overflow = false === (settings[iframeId] && settings[iframeId].scrolling) ? 'hidden' : 'auto'; + switch(settings[iframeId] && settings[iframeId].scrolling) { + case true: + iframe.scrolling = 'yes'; + break; + case false: + iframe.scrolling = 'no'; + break; + default: + iframe.scrolling = settings[iframeId] ? settings[iframeId].scrolling : 'no'; + } + } + + //The V1 iFrame script expects an int, where as in V2 expects a CSS + //string value such as '1px 3em', so if we have an int for V2, set V1=V2 + //and then convert V2 to a string PX value. + function setupBodyMarginValues(){ + if (('number'===typeof(settings[iframeId] && settings[iframeId].bodyMargin)) || ('0'===(settings[iframeId] && settings[iframeId].bodyMargin))){ + settings[iframeId].bodyMarginV1 = settings[iframeId].bodyMargin; + settings[iframeId].bodyMargin = '' + settings[iframeId].bodyMargin + 'px'; + } + } + + function checkReset(){ + // Reduce scope of firstRun to function, because IE8's JS execution + // context stack is borked and this value gets externally + // changed midway through running this function!!! + var + firstRun = settings[iframeId] && settings[iframeId].firstRun, + resetRequertMethod = settings[iframeId] && settings[iframeId].heightCalculationMethod in resetRequiredMethods; + + if (!firstRun && resetRequertMethod){ + resetIFrame({iframe:iframe, height:0, width:0, type:'init'}); + } + } + + function setupIFrameObject(){ + if(Function.prototype.bind && settings[iframeId]){ //Ignore unpolyfilled IE8. + settings[iframeId].iframe.iFrameResizer = { + + close : closeIFrame.bind(null,settings[iframeId].iframe), + + resize : trigger.bind(null,'Window resize', 'resize', settings[iframeId].iframe), + + moveToAnchor : function(anchor){ + trigger('Move to anchor','moveToAnchor:'+anchor, settings[iframeId].iframe,iframeId); + }, + + sendMessage : function(message){ + message = JSON.stringify(message); + trigger('Send Message','message:'+message, settings[iframeId].iframe, iframeId); + } + }; + } + } + + //We have to call trigger twice, as we can not be sure if all + //iframes have completed loading when this code runs. The + //event listener also catches the page changing in the iFrame. + function init(msg){ + function iFrameLoaded(){ + trigger('iFrame.onload', msg, iframe, undefined , true); + checkReset(); + } + + addEventListener(iframe,'load',iFrameLoaded); + trigger('init', msg, iframe, undefined, true); + } + + function checkOptions(options){ + if ('object' !== typeof options){ + throw new TypeError('Options is not an object'); + } + } + + function copyOptions(options){ + for (var option in defaults) { + if (defaults.hasOwnProperty(option)){ + settings[iframeId][option] = options.hasOwnProperty(option) ? options[option] : defaults[option]; + } + } + } + + function getTargetOrigin (remoteHost){ + return ('' === remoteHost || 'file://' === remoteHost) ? '*' : remoteHost; + } + + function processOptions(options){ + options = options || {}; + settings[iframeId] = { + firstRun : true, + iframe : iframe, + remoteHost : iframe.src.split('/').slice(0,3).join('/') + }; + + checkOptions(options); + copyOptions(options); + + if (settings[iframeId]) { + settings[iframeId].targetOrigin = true === settings[iframeId].checkOrigin ? getTargetOrigin(settings[iframeId].remoteHost) : '*'; + } + } + + function beenHere(){ + return (iframeId in settings && 'iFrameResizer' in iframe); + } + + var iframeId = ensureHasId(iframe.id); + + if (!beenHere()){ + processOptions(options); + setScrolling(); + setLimits(); + setupBodyMarginValues(); + init(createOutgoingMsg(iframeId)); + setupIFrameObject(); + } else { + warn(iframeId,'Ignored iFrame, already setup.'); + } + } + + function debouce(fn,time){ + if (null === timer){ + timer = setTimeout(function(){ + timer = null; + fn(); + }, time); + } + } + + /* istanbul ignore next */ //Not testable in PhantomJS + function fixHiddenIFrames(){ + function checkIFrames(){ + function checkIFrame(settingId){ + function chkDimension(dimension){ + return '0px' === (settings[settingId] && settings[settingId].iframe.style[dimension]); + } + + function isVisible(el) { + return (null !== el.offsetParent); + } + + if (settings[settingId] && isVisible(settings[settingId].iframe) && (chkDimension('height') || chkDimension('width'))){ + trigger('Visibility change', 'resize', settings[settingId].iframe, settingId); + } + } + + for (var settingId in settings){ + checkIFrame(settingId); + } + } + + function mutationObserved(mutations){ + log('window','Mutation observed: ' + mutations[0].target + ' ' + mutations[0].type); + debouce(checkIFrames,16); + } + + function createMutationObserver(){ + var + target = document.querySelector('body'), + + config = { + attributes : true, + attributeOldValue : false, + characterData : true, + characterDataOldValue : false, + childList : true, + subtree : true + }, + + observer = new MutationObserver(mutationObserved); + + observer.observe(target, config); + } + + var MutationObserver = window.MutationObserver || window.WebKitMutationObserver; + + if (MutationObserver) createMutationObserver(); + } + + + function resizeIFrames(event){ + function resize(){ + sendTriggerMsg('Window '+event,'resize'); + } + + log('window','Trigger event: '+event); + debouce(resize,16); + } + + /* istanbul ignore next */ //Not testable in PhantomJS + function tabVisible() { + function resize(){ + sendTriggerMsg('Tab Visable','resize'); + } + + if('hidden' !== document.visibilityState) { + log('document','Trigger event: Visiblity change'); + debouce(resize,16); + } + } + + function sendTriggerMsg(eventName,event){ + function isIFrameResizeEnabled(iframeId) { + return settings[iframeId] && + 'parent' === settings[iframeId].resizeFrom && + settings[iframeId].autoResize && + !settings[iframeId].firstRun; + } + + for (var iframeId in settings){ + if(isIFrameResizeEnabled(iframeId)){ + trigger(eventName, event, document.getElementById(iframeId), iframeId); + } + } + } + + function setupEventListeners(){ + addEventListener(window,'message',iFrameListener); + + addEventListener(window,'resize', function(){resizeIFrames('resize');}); + + addEventListener(document,'visibilitychange',tabVisible); + addEventListener(document,'-webkit-visibilitychange',tabVisible); //Andriod 4.4 + addEventListener(window,'focusin',function(){resizeIFrames('focus');}); //IE8-9 + addEventListener(window,'focus',function(){resizeIFrames('focus');}); + } + + + function factory(){ + function init(options,element){ + function chkType(){ + if(!element.tagName) { + throw new TypeError('Object is not a valid DOM element'); + } else if ('IFRAME' !== element.tagName.toUpperCase()) { + throw new TypeError('Expected + diff --git a/templates/checkout/mondido-redirect.php b/templates/checkout/mondido-redirect.php new file mode 100644 index 0000000..00e8d9f --- /dev/null +++ b/templates/checkout/mondido-redirect.php @@ -0,0 +1,15 @@ + + diff --git a/templates/checkout/payment-fields.php b/templates/checkout/payment-fields.php index 19a0cc4..a7f3125 100644 --- a/templates/checkout/payment-fields.php +++ b/templates/checkout/payment-fields.php @@ -9,6 +9,7 @@ +logos = array_filter($gateway->logos, 'strlen'); ?> logos ) > 0 ): ?>
logos as $logo ): ?> diff --git a/templates/checkout/product-button.php b/templates/checkout/product-button.php new file mode 100644 index 0000000..36ff99e --- /dev/null +++ b/templates/checkout/product-button.php @@ -0,0 +1,23 @@ + +
 
+ + + + + +
 
diff --git a/vendors/league-iso3166/composer.json b/vendors/league-iso3166/composer.json new file mode 100644 index 0000000..e278f81 --- /dev/null +++ b/vendors/league-iso3166/composer.json @@ -0,0 +1,5 @@ +{ + "require": { + "league/iso3166": "^2.0" + } +} diff --git a/vendors/league-iso3166/composer.lock b/vendors/league-iso3166/composer.lock new file mode 100644 index 0000000..66d7945 --- /dev/null +++ b/vendors/league-iso3166/composer.lock @@ -0,0 +1,73 @@ +{ + "_readme": [ + "This file locks the dependencies of your project to a known state", + "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file", + "This file is @generated automatically" + ], + "hash": "006684f7154e90460313bb2e9cee2112", + "content-hash": "7a8685f60fbd84b7d02b0c5e20dfbabd", + "packages": [ + { + "name": "league/iso3166", + "version": "2.0.0", + "source": { + "type": "git", + "url": "https://github.com/thephpleague/iso3166.git", + "reference": "81c6a2c9250c2689460e5120a9b5952eedd927b0" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/thephpleague/iso3166/zipball/81c6a2c9250c2689460e5120a9b5952eedd927b0", + "reference": "81c6a2c9250c2689460e5120a9b5952eedd927b0", + "shasum": "" + }, + "require": { + "php": "^5.6 || ^7.0" + }, + "require-dev": { + "friendsofphp/php-cs-fixer": "^2.0@dev || ^2.0", + "phpunit/phpunit": "^4.6 || ^5.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.x-dev" + } + }, + "autoload": { + "psr-4": { + "League\\ISO3166\\": "src" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Rob Bast", + "email": "rob.bast@gmail.com" + } + ], + "description": "ISO 3166-1 PHP Library", + "homepage": "https://github.com/thephpleague/iso3166", + "keywords": [ + "3166", + "3166-1", + "ISO 3166", + "countries", + "iso", + "library" + ], + "time": "2017-05-11 11:54:51" + } + ], + "packages-dev": [], + "aliases": [], + "minimum-stability": "stable", + "stability-flags": [], + "prefer-stable": false, + "prefer-lowest": false, + "platform": [], + "platform-dev": [] +} diff --git a/vendors/league-iso3166/vendor/autoload.php b/vendors/league-iso3166/vendor/autoload.php new file mode 100644 index 0000000..2b30d76 --- /dev/null +++ b/vendors/league-iso3166/vendor/autoload.php @@ -0,0 +1,7 @@ + + * Jordi Boggiano + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Composer\Autoload; + +/** + * ClassLoader implements a PSR-0, PSR-4 and classmap class loader. + * + * $loader = new \Composer\Autoload\ClassLoader(); + * + * // register classes with namespaces + * $loader->add('Symfony\Component', __DIR__.'/component'); + * $loader->add('Symfony', __DIR__.'/framework'); + * + * // activate the autoloader + * $loader->register(); + * + * // to enable searching the include path (eg. for PEAR packages) + * $loader->setUseIncludePath(true); + * + * In this example, if you try to use a class in the Symfony\Component + * namespace or one of its children (Symfony\Component\Console for instance), + * the autoloader will first look for the class under the component/ + * directory, and it will then fallback to the framework/ directory if not + * found before giving up. + * + * This class is loosely based on the Symfony UniversalClassLoader. + * + * @author Fabien Potencier + * @author Jordi Boggiano + * @see http://www.php-fig.org/psr/psr-0/ + * @see http://www.php-fig.org/psr/psr-4/ + */ +class ClassLoader +{ + // PSR-4 + private $prefixLengthsPsr4 = array(); + private $prefixDirsPsr4 = array(); + private $fallbackDirsPsr4 = array(); + + // PSR-0 + private $prefixesPsr0 = array(); + private $fallbackDirsPsr0 = array(); + + private $useIncludePath = false; + private $classMap = array(); + + private $classMapAuthoritative = false; + + public function getPrefixes() + { + if (!empty($this->prefixesPsr0)) { + return call_user_func_array('array_merge', $this->prefixesPsr0); + } + + return array(); + } + + public function getPrefixesPsr4() + { + return $this->prefixDirsPsr4; + } + + public function getFallbackDirs() + { + return $this->fallbackDirsPsr0; + } + + public function getFallbackDirsPsr4() + { + return $this->fallbackDirsPsr4; + } + + public function getClassMap() + { + return $this->classMap; + } + + /** + * @param array $classMap Class to filename map + */ + public function addClassMap(array $classMap) + { + if ($this->classMap) { + $this->classMap = array_merge($this->classMap, $classMap); + } else { + $this->classMap = $classMap; + } + } + + /** + * Registers a set of PSR-0 directories for a given prefix, either + * appending or prepending to the ones previously set for this prefix. + * + * @param string $prefix The prefix + * @param array|string $paths The PSR-0 root directories + * @param bool $prepend Whether to prepend the directories + */ + public function add($prefix, $paths, $prepend = false) + { + if (!$prefix) { + if ($prepend) { + $this->fallbackDirsPsr0 = array_merge( + (array) $paths, + $this->fallbackDirsPsr0 + ); + } else { + $this->fallbackDirsPsr0 = array_merge( + $this->fallbackDirsPsr0, + (array) $paths + ); + } + + return; + } + + $first = $prefix[0]; + if (!isset($this->prefixesPsr0[$first][$prefix])) { + $this->prefixesPsr0[$first][$prefix] = (array) $paths; + + return; + } + if ($prepend) { + $this->prefixesPsr0[$first][$prefix] = array_merge( + (array) $paths, + $this->prefixesPsr0[$first][$prefix] + ); + } else { + $this->prefixesPsr0[$first][$prefix] = array_merge( + $this->prefixesPsr0[$first][$prefix], + (array) $paths + ); + } + } + + /** + * Registers a set of PSR-4 directories for a given namespace, either + * appending or prepending to the ones previously set for this namespace. + * + * @param string $prefix The prefix/namespace, with trailing '\\' + * @param array|string $paths The PSR-4 base directories + * @param bool $prepend Whether to prepend the directories + * + * @throws \InvalidArgumentException + */ + public function addPsr4($prefix, $paths, $prepend = false) + { + if (!$prefix) { + // Register directories for the root namespace. + if ($prepend) { + $this->fallbackDirsPsr4 = array_merge( + (array) $paths, + $this->fallbackDirsPsr4 + ); + } else { + $this->fallbackDirsPsr4 = array_merge( + $this->fallbackDirsPsr4, + (array) $paths + ); + } + } elseif (!isset($this->prefixDirsPsr4[$prefix])) { + // Register directories for a new namespace. + $length = strlen($prefix); + if ('\\' !== $prefix[$length - 1]) { + throw new \InvalidArgumentException("A non-empty PSR-4 prefix must end with a namespace separator."); + } + $this->prefixLengthsPsr4[$prefix[0]][$prefix] = $length; + $this->prefixDirsPsr4[$prefix] = (array) $paths; + } elseif ($prepend) { + // Prepend directories for an already registered namespace. + $this->prefixDirsPsr4[$prefix] = array_merge( + (array) $paths, + $this->prefixDirsPsr4[$prefix] + ); + } else { + // Append directories for an already registered namespace. + $this->prefixDirsPsr4[$prefix] = array_merge( + $this->prefixDirsPsr4[$prefix], + (array) $paths + ); + } + } + + /** + * Registers a set of PSR-0 directories for a given prefix, + * replacing any others previously set for this prefix. + * + * @param string $prefix The prefix + * @param array|string $paths The PSR-0 base directories + */ + public function set($prefix, $paths) + { + if (!$prefix) { + $this->fallbackDirsPsr0 = (array) $paths; + } else { + $this->prefixesPsr0[$prefix[0]][$prefix] = (array) $paths; + } + } + + /** + * Registers a set of PSR-4 directories for a given namespace, + * replacing any others previously set for this namespace. + * + * @param string $prefix The prefix/namespace, with trailing '\\' + * @param array|string $paths The PSR-4 base directories + * + * @throws \InvalidArgumentException + */ + public function setPsr4($prefix, $paths) + { + if (!$prefix) { + $this->fallbackDirsPsr4 = (array) $paths; + } else { + $length = strlen($prefix); + if ('\\' !== $prefix[$length - 1]) { + throw new \InvalidArgumentException("A non-empty PSR-4 prefix must end with a namespace separator."); + } + $this->prefixLengthsPsr4[$prefix[0]][$prefix] = $length; + $this->prefixDirsPsr4[$prefix] = (array) $paths; + } + } + + /** + * Turns on searching the include path for class files. + * + * @param bool $useIncludePath + */ + public function setUseIncludePath($useIncludePath) + { + $this->useIncludePath = $useIncludePath; + } + + /** + * Can be used to check if the autoloader uses the include path to check + * for classes. + * + * @return bool + */ + public function getUseIncludePath() + { + return $this->useIncludePath; + } + + /** + * Turns off searching the prefix and fallback directories for classes + * that have not been registered with the class map. + * + * @param bool $classMapAuthoritative + */ + public function setClassMapAuthoritative($classMapAuthoritative) + { + $this->classMapAuthoritative = $classMapAuthoritative; + } + + /** + * Should class lookup fail if not found in the current class map? + * + * @return bool + */ + public function isClassMapAuthoritative() + { + return $this->classMapAuthoritative; + } + + /** + * Registers this instance as an autoloader. + * + * @param bool $prepend Whether to prepend the autoloader or not + */ + public function register($prepend = false) + { + spl_autoload_register(array($this, 'loadClass'), true, $prepend); + } + + /** + * Unregisters this instance as an autoloader. + */ + public function unregister() + { + spl_autoload_unregister(array($this, 'loadClass')); + } + + /** + * Loads the given class or interface. + * + * @param string $class The name of the class + * @return bool|null True if loaded, null otherwise + */ + public function loadClass($class) + { + if ($file = $this->findFile($class)) { + includeFile($file); + + return true; + } + } + + /** + * Finds the path to the file where the class is defined. + * + * @param string $class The name of the class + * + * @return string|false The path if found, false otherwise + */ + public function findFile($class) + { + // work around for PHP 5.3.0 - 5.3.2 https://bugs.php.net/50731 + if ('\\' == $class[0]) { + $class = substr($class, 1); + } + + // class map lookup + if (isset($this->classMap[$class])) { + return $this->classMap[$class]; + } + if ($this->classMapAuthoritative) { + return false; + } + + $file = $this->findFileWithExtension($class, '.php'); + + // Search for Hack files if we are running on HHVM + if ($file === null && defined('HHVM_VERSION')) { + $file = $this->findFileWithExtension($class, '.hh'); + } + + if ($file === null) { + // Remember that this class does not exist. + return $this->classMap[$class] = false; + } + + return $file; + } + + private function findFileWithExtension($class, $ext) + { + // PSR-4 lookup + $logicalPathPsr4 = strtr($class, '\\', DIRECTORY_SEPARATOR) . $ext; + + $first = $class[0]; + if (isset($this->prefixLengthsPsr4[$first])) { + foreach ($this->prefixLengthsPsr4[$first] as $prefix => $length) { + if (0 === strpos($class, $prefix)) { + foreach ($this->prefixDirsPsr4[$prefix] as $dir) { + if (file_exists($file = $dir . DIRECTORY_SEPARATOR . substr($logicalPathPsr4, $length))) { + return $file; + } + } + } + } + } + + // PSR-4 fallback dirs + foreach ($this->fallbackDirsPsr4 as $dir) { + if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr4)) { + return $file; + } + } + + // PSR-0 lookup + if (false !== $pos = strrpos($class, '\\')) { + // namespaced class name + $logicalPathPsr0 = substr($logicalPathPsr4, 0, $pos + 1) + . strtr(substr($logicalPathPsr4, $pos + 1), '_', DIRECTORY_SEPARATOR); + } else { + // PEAR-like class name + $logicalPathPsr0 = strtr($class, '_', DIRECTORY_SEPARATOR) . $ext; + } + + if (isset($this->prefixesPsr0[$first])) { + foreach ($this->prefixesPsr0[$first] as $prefix => $dirs) { + if (0 === strpos($class, $prefix)) { + foreach ($dirs as $dir) { + if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr0)) { + return $file; + } + } + } + } + } + + // PSR-0 fallback dirs + foreach ($this->fallbackDirsPsr0 as $dir) { + if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr0)) { + return $file; + } + } + + // PSR-0 include paths. + if ($this->useIncludePath && $file = stream_resolve_include_path($logicalPathPsr0)) { + return $file; + } + } +} + +/** + * Scope isolated include. + * + * Prevents access to $this/self from included files. + */ +function includeFile($file) +{ + include $file; +} diff --git a/vendors/league-iso3166/vendor/composer/LICENSE b/vendors/league-iso3166/vendor/composer/LICENSE new file mode 100644 index 0000000..ee274f1 --- /dev/null +++ b/vendors/league-iso3166/vendor/composer/LICENSE @@ -0,0 +1,433 @@ +Format: http://www.debian.org/doc/packaging-manuals/copyright-format/1.0/ +Upstream-Name: Composer +Upstream-Contact: Jordi Boggiano +Source: https://github.com/composer/composer + +Files: * +Copyright: 2016, Nils Adermann + 2016, Jordi Boggiano +License: Expat + +Files: res/cacert.pem +Copyright: 2015, Mozilla Foundation +License: MPL-2.0 + +Files: src/Composer/Util/RemoteFilesystem.php + src/Composer/Util/TlsHelper.php +Copyright: 2016, Nils Adermann + 2016, Jordi Boggiano + 2013, Evan Coury +License: Expat and BSD-2-Clause + +License: BSD-2-Clause + Redistribution and use in source and binary forms, with or without modification, + are permitted provided that the following conditions are met: + . + * Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + . + * Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + . + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR + ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +License: Expat + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is furnished + to do so, subject to the following conditions: + . + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + . + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + THE SOFTWARE. + +License: MPL-2.0 + 1. Definitions + -------------- + . + 1.1. "Contributor" + means each individual or legal entity that creates, contributes to + the creation of, or owns Covered Software. + . + 1.2. "Contributor Version" + means the combination of the Contributions of others (if any) used + by a Contributor and that particular Contributor's Contribution. + . + 1.3. "Contribution" + means Covered Software of a particular Contributor. + . + 1.4. "Covered Software" + means Source Code Form to which the initial Contributor has attached + the notice in Exhibit A, the Executable Form of such Source Code + Form, and Modifications of such Source Code Form, in each case + including portions thereof. + . + 1.5. "Incompatible With Secondary Licenses" + means + . + (a) that the initial Contributor has attached the notice described + in Exhibit B to the Covered Software; or + . + (b) that the Covered Software was made available under the terms of + version 1.1 or earlier of the License, but not also under the + terms of a Secondary License. + . + 1.6. "Executable Form" + means any form of the work other than Source Code Form. + . + 1.7. "Larger Work" + means a work that combines Covered Software with other material, in + a separate file or files, that is not Covered Software. + . + 1.8. "License" + means this document. + . + 1.9. "Licensable" + means having the right to grant, to the maximum extent possible, + whether at the time of the initial grant or subsequently, any and + all of the rights conveyed by this License. + . + 1.10. "Modifications" + means any of the following: + . + (a) any file in Source Code Form that results from an addition to, + deletion from, or modification of the contents of Covered + Software; or + . + (b) any new file in Source Code Form that contains any Covered + Software. + . + 1.11. "Patent Claims" of a Contributor + means any patent claim(s), including without limitation, method, + process, and apparatus claims, in any patent Licensable by such + Contributor that would be infringed, but for the grant of the + License, by the making, using, selling, offering for sale, having + made, import, or transfer of either its Contributions or its + Contributor Version. + . + 1.12. "Secondary License" + means either the GNU General Public License, Version 2.0, the GNU + Lesser General Public License, Version 2.1, the GNU Affero General + Public License, Version 3.0, or any later versions of those + licenses. + . + 1.13. "Source Code Form" + means the form of the work preferred for making modifications. + . + 1.14. "You" (or "Your") + means an individual or a legal entity exercising rights under this + License. For legal entities, "You" includes any entity that + controls, is controlled by, or is under common control with You. For + purposes of this definition, "control" means (a) the power, direct + or indirect, to cause the direction or management of such entity, + whether by contract or otherwise, or (b) ownership of more than + fifty percent (50%) of the outstanding shares or beneficial + ownership of such entity. + . + 2. License Grants and Conditions + -------------------------------- + . + 2.1. Grants + . + Each Contributor hereby grants You a world-wide, royalty-free, + non-exclusive license: + . + (a) under intellectual property rights (other than patent or trademark) + Licensable by such Contributor to use, reproduce, make available, + modify, display, perform, distribute, and otherwise exploit its + Contributions, either on an unmodified basis, with Modifications, or + as part of a Larger Work; and + . + (b) under Patent Claims of such Contributor to make, use, sell, offer + for sale, have made, import, and otherwise transfer either its + Contributions or its Contributor Version. + . + 2.2. Effective Date + . + The licenses granted in Section 2.1 with respect to any Contribution + become effective for each Contribution on the date the Contributor first + distributes such Contribution. + . + 2.3. Limitations on Grant Scope + . + The licenses granted in this Section 2 are the only rights granted under + this License. No additional rights or licenses will be implied from the + distribution or licensing of Covered Software under this License. + Notwithstanding Section 2.1(b) above, no patent license is granted by a + Contributor: + . + (a) for any code that a Contributor has removed from Covered Software; + or + . + (b) for infringements caused by: (i) Your and any other third party's + modifications of Covered Software, or (ii) the combination of its + Contributions with other software (except as part of its Contributor + Version); or + . + (c) under Patent Claims infringed by Covered Software in the absence of + its Contributions. + . + This License does not grant any rights in the trademarks, service marks, + or logos of any Contributor (except as may be necessary to comply with + the notice requirements in Section 3.4). + . + 2.4. Subsequent Licenses + . + No Contributor makes additional grants as a result of Your choice to + distribute the Covered Software under a subsequent version of this + License (see Section 10.2) or under the terms of a Secondary License (if + permitted under the terms of Section 3.3). + . + 2.5. Representation + . + Each Contributor represents that the Contributor believes its + Contributions are its original creation(s) or it has sufficient rights + to grant the rights to its Contributions conveyed by this License. + . + 2.6. Fair Use + . + This License is not intended to limit any rights You have under + applicable copyright doctrines of fair use, fair dealing, or other + equivalents. + . + 2.7. Conditions + . + Sections 3.1, 3.2, 3.3, and 3.4 are conditions of the licenses granted + in Section 2.1. + . + 3. Responsibilities + ------------------- + . + 3.1. Distribution of Source Form + . + All distribution of Covered Software in Source Code Form, including any + Modifications that You create or to which You contribute, must be under + the terms of this License. You must inform recipients that the Source + Code Form of the Covered Software is governed by the terms of this + License, and how they can obtain a copy of this License. You may not + attempt to alter or restrict the recipients' rights in the Source Code + Form. + . + 3.2. Distribution of Executable Form + . + If You distribute Covered Software in Executable Form then: + . + (a) such Covered Software must also be made available in Source Code + Form, as described in Section 3.1, and You must inform recipients of + the Executable Form how they can obtain a copy of such Source Code + Form by reasonable means in a timely manner, at a charge no more + than the cost of distribution to the recipient; and + . + (b) You may distribute such Executable Form under the terms of this + License, or sublicense it under different terms, provided that the + license for the Executable Form does not attempt to limit or alter + the recipients' rights in the Source Code Form under this License. + . + 3.3. Distribution of a Larger Work + . + You may create and distribute a Larger Work under terms of Your choice, + provided that You also comply with the requirements of this License for + the Covered Software. If the Larger Work is a combination of Covered + Software with a work governed by one or more Secondary Licenses, and the + Covered Software is not Incompatible With Secondary Licenses, this + License permits You to additionally distribute such Covered Software + under the terms of such Secondary License(s), so that the recipient of + the Larger Work may, at their option, further distribute the Covered + Software under the terms of either this License or such Secondary + License(s). + . + 3.4. Notices + . + You may not remove or alter the substance of any license notices + (including copyright notices, patent notices, disclaimers of warranty, + or limitations of liability) contained within the Source Code Form of + the Covered Software, except that You may alter any license notices to + the extent required to remedy known factual inaccuracies. + . + 3.5. Application of Additional Terms + . + You may choose to offer, and to charge a fee for, warranty, support, + indemnity or liability obligations to one or more recipients of Covered + Software. However, You may do so only on Your own behalf, and not on + behalf of any Contributor. You must make it absolutely clear that any + such warranty, support, indemnity, or liability obligation is offered by + You alone, and You hereby agree to indemnify every Contributor for any + liability incurred by such Contributor as a result of warranty, support, + indemnity or liability terms You offer. You may include additional + disclaimers of warranty and limitations of liability specific to any + jurisdiction. + . + 4. Inability to Comply Due to Statute or Regulation + --------------------------------------------------- + . + If it is impossible for You to comply with any of the terms of this + License with respect to some or all of the Covered Software due to + statute, judicial order, or regulation then You must: (a) comply with + the terms of this License to the maximum extent possible; and (b) + describe the limitations and the code they affect. Such description must + be placed in a text file included with all distributions of the Covered + Software under this License. Except to the extent prohibited by statute + or regulation, such description must be sufficiently detailed for a + recipient of ordinary skill to be able to understand it. + . + 5. Termination + -------------- + . + 5.1. The rights granted under this License will terminate automatically + if You fail to comply with any of its terms. However, if You become + compliant, then the rights granted under this License from a particular + Contributor are reinstated (a) provisionally, unless and until such + Contributor explicitly and finally terminates Your grants, and (b) on an + ongoing basis, if such Contributor fails to notify You of the + non-compliance by some reasonable means prior to 60 days after You have + come back into compliance. Moreover, Your grants from a particular + Contributor are reinstated on an ongoing basis if such Contributor + notifies You of the non-compliance by some reasonable means, this is the + first time You have received notice of non-compliance with this License + from such Contributor, and You become compliant prior to 30 days after + Your receipt of the notice. + . + 5.2. If You initiate litigation against any entity by asserting a patent + infringement claim (excluding declaratory judgment actions, + counter-claims, and cross-claims) alleging that a Contributor Version + directly or indirectly infringes any patent, then the rights granted to + You by any and all Contributors for the Covered Software under Section + 2.1 of this License shall terminate. + . + 5.3. In the event of termination under Sections 5.1 or 5.2 above, all + end user license agreements (excluding distributors and resellers) which + have been validly granted by You or Your distributors under this License + prior to termination shall survive termination. + . + ************************************************************************ + * * + * 6. Disclaimer of Warranty * + * ------------------------- * + * * + * Covered Software is provided under this License on an "as is" * + * basis, without warranty of any kind, either expressed, implied, or * + * statutory, including, without limitation, warranties that the * + * Covered Software is free of defects, merchantable, fit for a * + * particular purpose or non-infringing. The entire risk as to the * + * quality and performance of the Covered Software is with You. * + * Should any Covered Software prove defective in any respect, You * + * (not any Contributor) assume the cost of any necessary servicing, * + * repair, or correction. This disclaimer of warranty constitutes an * + * essential part of this License. No use of any Covered Software is * + * authorized under this License except under this disclaimer. * + * * + ************************************************************************ + . + ************************************************************************ + * * + * 7. Limitation of Liability * + * -------------------------- * + * * + * Under no circumstances and under no legal theory, whether tort * + * (including negligence), contract, or otherwise, shall any * + * Contributor, or anyone who distributes Covered Software as * + * permitted above, be liable to You for any direct, indirect, * + * special, incidental, or consequential damages of any character * + * including, without limitation, damages for lost profits, loss of * + * goodwill, work stoppage, computer failure or malfunction, or any * + * and all other commercial damages or losses, even if such party * + * shall have been informed of the possibility of such damages. This * + * limitation of liability shall not apply to liability for death or * + * personal injury resulting from such party's negligence to the * + * extent applicable law prohibits such limitation. Some * + * jurisdictions do not allow the exclusion or limitation of * + * incidental or consequential damages, so this exclusion and * + * limitation may not apply to You. * + * * + ************************************************************************ + . + 8. Litigation + ------------- + . + Any litigation relating to this License may be brought only in the + courts of a jurisdiction where the defendant maintains its principal + place of business and such litigation shall be governed by laws of that + jurisdiction, without reference to its conflict-of-law provisions. + Nothing in this Section shall prevent a party's ability to bring + cross-claims or counter-claims. + . + 9. Miscellaneous + ---------------- + . + This License represents the complete agreement concerning the subject + matter hereof. If any provision of this License is held to be + unenforceable, such provision shall be reformed only to the extent + necessary to make it enforceable. Any law or regulation which provides + that the language of a contract shall be construed against the drafter + shall not be used to construe this License against a Contributor. + . + 10. Versions of the License + --------------------------- + . + 10.1. New Versions + . + Mozilla Foundation is the license steward. Except as provided in Section + 10.3, no one other than the license steward has the right to modify or + publish new versions of this License. Each version will be given a + distinguishing version number. + . + 10.2. Effect of New Versions + . + You may distribute the Covered Software under the terms of the version + of the License under which You originally received the Covered Software, + or under the terms of any subsequent version published by the license + steward. + . + 10.3. Modified Versions + . + If you create software not governed by this License, and you want to + create a new license for such software, you may create and use a + modified version of this License if you rename the license and remove + any references to the name of the license steward (except to note that + such modified license differs from this License). + . + 10.4. Distributing Source Code Form that is Incompatible With Secondary + Licenses + . + If You choose to distribute Source Code Form that is Incompatible With + Secondary Licenses under the terms of this version of the License, the + notice described in Exhibit B of this License must be attached. + . + Exhibit A - Source Code Form License Notice + ------------------------------------------- + . + This Source Code Form is subject to the terms of the Mozilla Public + License, v. 2.0. If a copy of the MPL was not distributed with this + file, You can obtain one at http://mozilla.org/MPL/2.0/. + . + If it is not possible or desirable to put the notice in a particular + file, then You may include the notice in a location (such as a LICENSE + file in a relevant directory) where a recipient would be likely to look + for such a notice. + . + You may add additional accurate notices of copyright ownership. + . + Exhibit B - "Incompatible With Secondary Licenses" Notice + --------------------------------------------------------- + . + This Source Code Form is "Incompatible With Secondary Licenses", as + defined by the Mozilla Public License, v. 2.0. diff --git a/vendors/league-iso3166/vendor/composer/autoload_classmap.php b/vendors/league-iso3166/vendor/composer/autoload_classmap.php new file mode 100644 index 0000000..7a91153 --- /dev/null +++ b/vendors/league-iso3166/vendor/composer/autoload_classmap.php @@ -0,0 +1,9 @@ + array($vendorDir . '/league/iso3166/src'), +); diff --git a/vendors/league-iso3166/vendor/composer/autoload_real.php b/vendors/league-iso3166/vendor/composer/autoload_real.php new file mode 100644 index 0000000..063d92e --- /dev/null +++ b/vendors/league-iso3166/vendor/composer/autoload_real.php @@ -0,0 +1,45 @@ + $path) { + $loader->set($namespace, $path); + } + + $map = require __DIR__ . '/autoload_psr4.php'; + foreach ($map as $namespace => $path) { + $loader->setPsr4($namespace, $path); + } + + $classMap = require __DIR__ . '/autoload_classmap.php'; + if ($classMap) { + $loader->addClassMap($classMap); + } + + $loader->register(true); + + return $loader; + } +} diff --git a/vendors/league-iso3166/vendor/composer/installed.json b/vendors/league-iso3166/vendor/composer/installed.json new file mode 100644 index 0000000..421d94d --- /dev/null +++ b/vendors/league-iso3166/vendor/composer/installed.json @@ -0,0 +1,58 @@ +[ + { + "name": "league/iso3166", + "version": "2.0.0", + "version_normalized": "2.0.0.0", + "source": { + "type": "git", + "url": "https://github.com/thephpleague/iso3166.git", + "reference": "81c6a2c9250c2689460e5120a9b5952eedd927b0" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/thephpleague/iso3166/zipball/81c6a2c9250c2689460e5120a9b5952eedd927b0", + "reference": "81c6a2c9250c2689460e5120a9b5952eedd927b0", + "shasum": "" + }, + "require": { + "php": "^5.6 || ^7.0" + }, + "require-dev": { + "friendsofphp/php-cs-fixer": "^2.0@dev || ^2.0", + "phpunit/phpunit": "^4.6 || ^5.0" + }, + "time": "2017-05-11 11:54:51", + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.x-dev" + } + }, + "installation-source": "dist", + "autoload": { + "psr-4": { + "League\\ISO3166\\": "src" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Rob Bast", + "email": "rob.bast@gmail.com" + } + ], + "description": "ISO 3166-1 PHP Library", + "homepage": "https://github.com/thephpleague/iso3166", + "keywords": [ + "3166", + "3166-1", + "ISO 3166", + "countries", + "iso", + "library" + ] + } +] diff --git a/vendors/league-iso3166/vendor/league/iso3166/LICENSE b/vendors/league-iso3166/vendor/league/iso3166/LICENSE new file mode 100644 index 0000000..fe97913 --- /dev/null +++ b/vendors/league-iso3166/vendor/league/iso3166/LICENSE @@ -0,0 +1,19 @@ +Copyright (C) Rob Bast + +Permission is hereby granted, free of charge, to any person obtaining a copy of +this software and associated documentation files (the "Software"), to deal in +the Software without restriction, including without limitation the rights to +use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies +of the Software, and to permit persons to whom the Software is furnished to do +so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/vendors/league-iso3166/vendor/league/iso3166/composer.json b/vendors/league-iso3166/vendor/league/iso3166/composer.json new file mode 100644 index 0000000..f09c918 --- /dev/null +++ b/vendors/league-iso3166/vendor/league/iso3166/composer.json @@ -0,0 +1,36 @@ +{ + "name": "league/iso3166", + "description": "ISO 3166-1 PHP Library", + "autoload": { + "psr-4": { "League\\ISO3166\\": "src" } + }, + "autoload-dev": { + "psr-4": { "League\\ISO3166\\": "tests" } + }, + "require": { + "php": "^5.6 || ^7.0" + }, + "require-dev": { + "friendsofphp/php-cs-fixer": "^2.0@dev || ^2.0", + "phpunit/phpunit": "^4.6 || ^5.0" + }, + "scripts": { + "cs-review": "php-cs-fixer fix --verbose --diff --dry-run", + "cs-fix": "php-cs-fixer fix --verbose", + "test": "phpunit" + }, + "extra": { + "branch-alias": { "dev-master": "2.x-dev" } + }, + "keywords": ["ISO 3166", "ISO", "3166", "3166-1", "countries", "library"], + "homepage": "https://github.com/thephpleague/iso3166", + "license": "MIT", + "authors": [{ + "name": "Rob Bast", + "email": "rob.bast@gmail.com" + }], + "support": { + "issues": "https://github.com/thephpleague/iso3166/issues", + "source": "https://github.com/thephpleague/iso3166" + } +} diff --git a/vendors/league-iso3166/vendor/league/iso3166/src/Exception/DomainException.php b/vendors/league-iso3166/vendor/league/iso3166/src/Exception/DomainException.php new file mode 100644 index 0000000..dbb788e --- /dev/null +++ b/vendors/league-iso3166/vendor/league/iso3166/src/Exception/DomainException.php @@ -0,0 +1,14 @@ + + * + * For the full copyright and license information, please view + * the LICENSE file that was distributed with this source code. + */ + +namespace League\ISO3166\Exception; + +final class DomainException extends \DomainException +{ +} diff --git a/vendors/league-iso3166/vendor/league/iso3166/src/Exception/InvalidArgumentException.php b/vendors/league-iso3166/vendor/league/iso3166/src/Exception/InvalidArgumentException.php new file mode 100644 index 0000000..fa334e8 --- /dev/null +++ b/vendors/league-iso3166/vendor/league/iso3166/src/Exception/InvalidArgumentException.php @@ -0,0 +1,14 @@ + + * + * For the full copyright and license information, please view + * the LICENSE file that was distributed with this source code. + */ + +namespace League\ISO3166\Exception; + +final class InvalidArgumentException extends \InvalidArgumentException +{ +} diff --git a/vendors/league-iso3166/vendor/league/iso3166/src/Exception/OutOfBoundsException.php b/vendors/league-iso3166/vendor/league/iso3166/src/Exception/OutOfBoundsException.php new file mode 100644 index 0000000..4fab4ef --- /dev/null +++ b/vendors/league-iso3166/vendor/league/iso3166/src/Exception/OutOfBoundsException.php @@ -0,0 +1,14 @@ + + * + * For the full copyright and license information, please view + * the LICENSE file that was distributed with this source code. + */ + +namespace League\ISO3166\Exception; + +final class OutOfBoundsException extends \OutOfBoundsException +{ +} diff --git a/vendors/league-iso3166/vendor/league/iso3166/src/Guards.php b/vendors/league-iso3166/vendor/league/iso3166/src/Guards.php new file mode 100644 index 0000000..8131871 --- /dev/null +++ b/vendors/league-iso3166/vendor/league/iso3166/src/Guards.php @@ -0,0 +1,85 @@ + + * + * For the full copyright and license information, please view + * the LICENSE file that was distributed with this source code. + */ + +namespace League\ISO3166; + +use League\ISO3166\Exception\DomainException; +use League\ISO3166\Exception\InvalidArgumentException; + +final class Guards +{ + /** + * Assert that input looks like an alpha2 key. + * + * @param string $alpha2 + * + * @throws \League\ISO3166\Exception\InvalidArgumentException if input is not a string + * @throws \League\ISO3166\Exception\DomainException if input does not look like an alpha2 key + */ + public static function guardAgainstInvalidAlpha2($alpha2) + { + if (!is_string($alpha2)) { + throw new InvalidArgumentException( + sprintf('Expected $alpha2 to be of type string, got: %s', gettype($alpha2)) + ); + } + + if (!preg_match('/^[a-zA-Z]{2}$/', $alpha2)) { + throw new DomainException( + sprintf('Not a valid alpha2 key: %s', $alpha2) + ); + } + } + + /** + * Assert that input looks like an alpha3 key. + * + * @param string $alpha3 + * + * @throws \League\ISO3166\Exception\InvalidArgumentException if input is not a string + * @throws \League\ISO3166\Exception\DomainException if input does not look like an alpha3 key + */ + public static function guardAgainstInvalidAlpha3($alpha3) + { + if (!is_string($alpha3)) { + throw new InvalidArgumentException( + sprintf('Expected $alpha3 to be of type string, got: %s', gettype($alpha3)) + ); + } + + if (!preg_match('/^[a-zA-Z]{3}$/', $alpha3)) { + throw new DomainException( + sprintf('Not a valid alpha3 key: %s', $alpha3) + ); + } + } + + /** + * Assert that input looks like a numeric key. + * + * @param string $numeric + * + * @throws \League\ISO3166\Exception\InvalidArgumentException if input is not a string + * @throws \League\ISO3166\Exception\DomainException if input does not look like a numeric key + */ + public static function guardAgainstInvalidNumeric($numeric) + { + if (!is_string($numeric)) { + throw new InvalidArgumentException( + sprintf('Expected $numeric to be of type string, got: %s', gettype($numeric)) + ); + } + + if (!preg_match('/^[0-9]{3}$/', $numeric)) { + throw new DomainException( + sprintf('Not a valid numeric key: %s', $numeric) + ); + } + } +} diff --git a/vendors/league-iso3166/vendor/league/iso3166/src/ISO3166.php b/vendors/league-iso3166/vendor/league/iso3166/src/ISO3166.php new file mode 100644 index 0000000..78d0762 --- /dev/null +++ b/vendors/league-iso3166/vendor/league/iso3166/src/ISO3166.php @@ -0,0 +1,2437 @@ + + * + * For the full copyright and license information, please view + * the LICENSE file that was distributed with this source code. + */ + +namespace League\ISO3166; + +use League\ISO3166\Exception\DomainException; +use League\ISO3166\Exception\OutOfBoundsException; + +final class ISO3166 implements \Countable, \IteratorAggregate, ISO3166DataProvider +{ + /** + * @var string + */ + const KEY_ALPHA2 = 'alpha2'; + /** + * @var string + */ + const KEY_ALPHA3 = 'alpha3'; + /** + * @var string + */ + const KEY_NUMERIC = 'numeric'; + /** + * @var string[] + */ + private $keys = [self::KEY_ALPHA2, self::KEY_ALPHA3, self::KEY_NUMERIC]; + + /** + * @param array[] $countries replace default dataset with given array + */ + public function __construct(array $countries = []) + { + if ($countries) { + $this->countries = $countries; + } + } + + /** + * {@inheritdoc} + */ + public function alpha2($alpha2) + { + Guards::guardAgainstInvalidAlpha2($alpha2); + + return $this->lookup(self::KEY_ALPHA2, $alpha2); + } + + /** + * {@inheritdoc} + */ + public function alpha3($alpha3) + { + Guards::guardAgainstInvalidAlpha3($alpha3); + + return $this->lookup(self::KEY_ALPHA3, $alpha3); + } + + /** + * {@inheritdoc} + */ + public function numeric($numeric) + { + Guards::guardAgainstInvalidNumeric($numeric); + + return $this->lookup(self::KEY_NUMERIC, $numeric); + } + + /** + * @return array[] + */ + public function all() + { + return $this->countries; + } + + /** + * @param string $key + * + * @throws \League\ISO3166\Exception\DomainException if an invalid key is specified + * + * @return \Generator + */ + public function iterator($key = self::KEY_ALPHA2) + { + if (!in_array($key, $this->keys, true)) { + throw new DomainException(sprintf( + 'Invalid value for $indexBy, got "%s", expected one of: %s', + $key, + implode(', ', $this->keys) + )); + } + + foreach ($this->countries as $country) { + yield $country[$key] => $country; + } + } + + /** + * @see \Countable + * + * @internal + * + * @return int + */ + public function count() + { + return count($this->countries); + } + + /** + * @see \IteratorAggregate + * + * @internal + * + * @return \Generator + */ + public function getIterator() + { + foreach ($this->countries as $country) { + yield $country; + } + } + + /** + * Lookup ISO3166-1 data by given identifier. + * + * Looks for a match against the given key for each entry in the dataset. + * + * @param string $key + * @param string $value + * + * @throws \League\ISO3166\Exception\OutOfBoundsException if key does not exist in dataset + * + * @return array + */ + private function lookup($key, $value) + { + foreach ($this->countries as $country) { + if (0 === strcasecmp($value, $country[$key])) { + return $country; + } + } + + throw new OutOfBoundsException( + sprintf('No "%s" key found matching: %s', $key, $value) + ); + } + + /** + * Default dataset. + * + * @var array[] + */ + protected $countries = [ + [ + 'name' => 'Afghanistan', + 'alpha2' => 'AF', + 'alpha3' => 'AFG', + 'numeric' => '004', + 'currency' => [ + 'AFN', + ], + ], + [ + 'name' => 'Åland Islands', + 'alpha2' => 'AX', + 'alpha3' => 'ALA', + 'numeric' => '248', + 'currency' => [ + 'EUR', + ], + ], + [ + 'name' => 'Albania', + 'alpha2' => 'AL', + 'alpha3' => 'ALB', + 'numeric' => '008', + 'currency' => [ + 'ALL', + ], + ], + [ + 'name' => 'Algeria', + 'alpha2' => 'DZ', + 'alpha3' => 'DZA', + 'numeric' => '012', + 'currency' => [ + 'DZD', + ], + ], + [ + 'name' => 'American Samoa', + 'alpha2' => 'AS', + 'alpha3' => 'ASM', + 'numeric' => '016', + 'currency' => [ + 'USD', + ], + ], + [ + 'name' => 'Andorra', + 'alpha2' => 'AD', + 'alpha3' => 'AND', + 'numeric' => '020', + 'currency' => [ + 'EUR', + ], + ], + [ + 'name' => 'Angola', + 'alpha2' => 'AO', + 'alpha3' => 'AGO', + 'numeric' => '024', + 'currency' => [ + 'AOA', + ], + ], + [ + 'name' => 'Anguilla', + 'alpha2' => 'AI', + 'alpha3' => 'AIA', + 'numeric' => '660', + 'currency' => [ + 'XCD', + ], + ], + [ + 'name' => 'Antarctica', + 'alpha2' => 'AQ', + 'alpha3' => 'ATA', + 'numeric' => '010', + 'currency' => [ + 'ARS', + 'AUD', + 'BGN', + 'BRL', + 'BYR', + 'CLP', + 'CNY', + 'CZK', + 'EUR', + 'GBP', + 'INR', + 'JPY', + 'KRW', + 'NOK', + 'NZD', + 'PEN', + 'PKR', + 'PLN', + 'RON', + 'RUB', + 'SEK', + 'UAH', + 'USD', + 'UYU', + 'ZAR', + ], + ], + [ + 'name' => 'Antigua and Barbuda', + 'alpha2' => 'AG', + 'alpha3' => 'ATG', + 'numeric' => '028', + 'currency' => [ + 'XCD', + ], + ], + [ + 'name' => 'Argentina', + 'alpha2' => 'AR', + 'alpha3' => 'ARG', + 'numeric' => '032', + 'currency' => [ + 'ARS', + ], + ], + [ + 'name' => 'Armenia', + 'alpha2' => 'AM', + 'alpha3' => 'ARM', + 'numeric' => '051', + 'currency' => [ + 'AMD', + ], + ], + [ + 'name' => 'Aruba', + 'alpha2' => 'AW', + 'alpha3' => 'ABW', + 'numeric' => '533', + 'currency' => [ + 'AWG', + ], + ], + [ + 'name' => 'Australia', + 'alpha2' => 'AU', + 'alpha3' => 'AUS', + 'numeric' => '036', + 'currency' => [ + 'AUD', + ], + ], + [ + 'name' => 'Austria', + 'alpha2' => 'AT', + 'alpha3' => 'AUT', + 'numeric' => '040', + 'currency' => [ + 'EUR', + ], + ], + [ + 'name' => 'Azerbaijan', + 'alpha2' => 'AZ', + 'alpha3' => 'AZE', + 'numeric' => '031', + 'currency' => [ + 'AZN', + ], + ], + [ + 'name' => 'Bahamas', + 'alpha2' => 'BS', + 'alpha3' => 'BHS', + 'numeric' => '044', + 'currency' => [ + 'BSD', + ], + ], + [ + 'name' => 'Bahrain', + 'alpha2' => 'BH', + 'alpha3' => 'BHR', + 'numeric' => '048', + 'currency' => [ + 'BHD', + ], + ], + [ + 'name' => 'Bangladesh', + 'alpha2' => 'BD', + 'alpha3' => 'BGD', + 'numeric' => '050', + 'currency' => [ + 'BDT', + ], + ], + [ + 'name' => 'Barbados', + 'alpha2' => 'BB', + 'alpha3' => 'BRB', + 'numeric' => '052', + 'currency' => [ + 'BBD', + ], + ], + [ + 'name' => 'Belarus', + 'alpha2' => 'BY', + 'alpha3' => 'BLR', + 'numeric' => '112', + 'currency' => [ + 'BYN', + ], + ], + [ + 'name' => 'Belgium', + 'alpha2' => 'BE', + 'alpha3' => 'BEL', + 'numeric' => '056', + 'currency' => [ + 'EUR', + ], + ], + [ + 'name' => 'Belize', + 'alpha2' => 'BZ', + 'alpha3' => 'BLZ', + 'numeric' => '084', + 'currency' => [ + 'BZD', + ], + ], + [ + 'name' => 'Benin', + 'alpha2' => 'BJ', + 'alpha3' => 'BEN', + 'numeric' => '204', + 'currency' => [ + 'XOF', + ], + ], + [ + 'name' => 'Bermuda', + 'alpha2' => 'BM', + 'alpha3' => 'BMU', + 'numeric' => '060', + 'currency' => [ + 'BMD', + ], + ], + [ + 'name' => 'Bhutan', + 'alpha2' => 'BT', + 'alpha3' => 'BTN', + 'numeric' => '064', + 'currency' => [ + 'BTN', + ], + ], + [ + 'name' => 'Bolivia (Plurinational State of)', + 'alpha2' => 'BO', + 'alpha3' => 'BOL', + 'numeric' => '068', + 'currency' => [ + 'BOB', + ], + ], + [ + 'name' => 'Bonaire, Sint Eustatius and Saba', + 'alpha2' => 'BQ', + 'alpha3' => 'BES', + 'numeric' => '535', + 'currency' => [ + 'USD', + ], + ], + [ + 'name' => 'Bosnia and Herzegovina', + 'alpha2' => 'BA', + 'alpha3' => 'BIH', + 'numeric' => '070', + 'currency' => [ + 'BAM', + ], + ], + [ + 'name' => 'Botswana', + 'alpha2' => 'BW', + 'alpha3' => 'BWA', + 'numeric' => '072', + 'currency' => [ + 'BWP', + ], + ], + [ + 'name' => 'Bouvet Island', + 'alpha2' => 'BV', + 'alpha3' => 'BVT', + 'numeric' => '074', + 'currency' => [ + 'NOK', + ], + ], + [ + 'name' => 'Brazil', + 'alpha2' => 'BR', + 'alpha3' => 'BRA', + 'numeric' => '076', + 'currency' => [ + 'BRL', + ], + ], + [ + 'name' => 'British Indian Ocean Territory', + 'alpha2' => 'IO', + 'alpha3' => 'IOT', + 'numeric' => '086', + 'currency' => [ + 'GBP', + ], + ], + [ + 'name' => 'Brunei Darussalam', + 'alpha2' => 'BN', + 'alpha3' => 'BRN', + 'numeric' => '096', + 'currency' => [ + 'BND', + 'SGD', + ], + ], + [ + 'name' => 'Bulgaria', + 'alpha2' => 'BG', + 'alpha3' => 'BGR', + 'numeric' => '100', + 'currency' => [ + 'BGN', + ], + ], + [ + 'name' => 'Burkina Faso', + 'alpha2' => 'BF', + 'alpha3' => 'BFA', + 'numeric' => '854', + 'currency' => [ + 'XOF', + ], + ], + [ + 'name' => 'Burundi', + 'alpha2' => 'BI', + 'alpha3' => 'BDI', + 'numeric' => '108', + 'currency' => [ + 'BIF', + ], + ], + [ + 'name' => 'Cabo Verde', + 'alpha2' => 'CV', + 'alpha3' => 'CPV', + 'numeric' => '132', + 'currency' => [ + 'CVE', + ], + ], + [ + 'name' => 'Cambodia', + 'alpha2' => 'KH', + 'alpha3' => 'KHM', + 'numeric' => '116', + 'currency' => [ + 'KHR', + ], + ], + [ + 'name' => 'Cameroon', + 'alpha2' => 'CM', + 'alpha3' => 'CMR', + 'numeric' => '120', + 'currency' => [ + 'XAF', + ], + ], + [ + 'name' => 'Canada', + 'alpha2' => 'CA', + 'alpha3' => 'CAN', + 'numeric' => '124', + 'currency' => [ + 'CAD', + ], + ], + [ + 'name' => 'Cayman Islands', + 'alpha2' => 'KY', + 'alpha3' => 'CYM', + 'numeric' => '136', + 'currency' => [ + 'KYD', + ], + ], + [ + 'name' => 'Central African Republic', + 'alpha2' => 'CF', + 'alpha3' => 'CAF', + 'numeric' => '140', + 'currency' => [ + 'XAF', + ], + ], + [ + 'name' => 'Chad', + 'alpha2' => 'TD', + 'alpha3' => 'TCD', + 'numeric' => '148', + 'currency' => [ + 'XAF', + ], + ], + [ + 'name' => 'Chile', + 'alpha2' => 'CL', + 'alpha3' => 'CHL', + 'numeric' => '152', + 'currency' => [ + 'CLP', + ], + ], + [ + 'name' => 'China', + 'alpha2' => 'CN', + 'alpha3' => 'CHN', + 'numeric' => '156', + 'currency' => [ + 'CNY', + ], + ], + [ + 'name' => 'Christmas Island', + 'alpha2' => 'CX', + 'alpha3' => 'CXR', + 'numeric' => '162', + 'currency' => [ + 'AUD', + ], + ], + [ + 'name' => 'Cocos (Keeling) Islands', + 'alpha2' => 'CC', + 'alpha3' => 'CCK', + 'numeric' => '166', + 'currency' => [ + 'AUD', + ], + ], + [ + 'name' => 'Colombia', + 'alpha2' => 'CO', + 'alpha3' => 'COL', + 'numeric' => '170', + 'currency' => [ + 'COP', + ], + ], + [ + 'name' => 'Comoros', + 'alpha2' => 'KM', + 'alpha3' => 'COM', + 'numeric' => '174', + 'currency' => [ + 'KMF', + ], + ], + [ + 'name' => 'Congo', + 'alpha2' => 'CG', + 'alpha3' => 'COG', + 'numeric' => '178', + 'currency' => [ + 'XAF', + ], + ], + [ + 'name' => 'Congo (Democratic Republic of the)', + 'alpha2' => 'CD', + 'alpha3' => 'COD', + 'numeric' => '180', + 'currency' => [ + 'CDF', + ], + ], + [ + 'name' => 'Cook Islands', + 'alpha2' => 'CK', + 'alpha3' => 'COK', + 'numeric' => '184', + 'currency' => [ + 'NZD', + ], + ], + [ + 'name' => 'Costa Rica', + 'alpha2' => 'CR', + 'alpha3' => 'CRI', + 'numeric' => '188', + 'currency' => [ + 'CRC', + ], + ], + [ + 'name' => 'Côte d\'Ivoire', + 'alpha2' => 'CI', + 'alpha3' => 'CIV', + 'numeric' => '384', + 'currency' => [ + 'XOF', + ], + ], + [ + 'name' => 'Croatia', + 'alpha2' => 'HR', + 'alpha3' => 'HRV', + 'numeric' => '191', + 'currency' => [ + 'HRK', + ], + ], + [ + 'name' => 'Cuba', + 'alpha2' => 'CU', + 'alpha3' => 'CUB', + 'numeric' => '192', + 'currency' => [ + 'CUC', + 'CUP', + ], + ], + [ + 'name' => 'Curaçao', + 'alpha2' => 'CW', + 'alpha3' => 'CUW', + 'numeric' => '531', + 'currency' => [ + 'ANG', + ], + ], + [ + 'name' => 'Cyprus', + 'alpha2' => 'CY', + 'alpha3' => 'CYP', + 'numeric' => '196', + 'currency' => [ + 'EUR', + ], + ], + [ + 'name' => 'Czechia', + 'alpha2' => 'CZ', + 'alpha3' => 'CZE', + 'numeric' => '203', + 'currency' => [ + 'CZK', + ], + ], + [ + 'name' => 'Denmark', + 'alpha2' => 'DK', + 'alpha3' => 'DNK', + 'numeric' => '208', + 'currency' => [ + 'DKK', + ], + ], + [ + 'name' => 'Djibouti', + 'alpha2' => 'DJ', + 'alpha3' => 'DJI', + 'numeric' => '262', + 'currency' => [ + 'DJF', + ], + ], + [ + 'name' => 'Dominica', + 'alpha2' => 'DM', + 'alpha3' => 'DMA', + 'numeric' => '212', + 'currency' => [ + 'XCD', + ], + ], + [ + 'name' => 'Dominican Republic', + 'alpha2' => 'DO', + 'alpha3' => 'DOM', + 'numeric' => '214', + 'currency' => [ + 'DOP', + ], + ], + [ + 'name' => 'Ecuador', + 'alpha2' => 'EC', + 'alpha3' => 'ECU', + 'numeric' => '218', + 'currency' => [ + 'USD', + ], + ], + [ + 'name' => 'Egypt', + 'alpha2' => 'EG', + 'alpha3' => 'EGY', + 'numeric' => '818', + 'currency' => [ + 'EGP', + ], + ], + [ + 'name' => 'El Salvador', + 'alpha2' => 'SV', + 'alpha3' => 'SLV', + 'numeric' => '222', + 'currency' => [ + 'USD', + ], + ], + [ + 'name' => 'Equatorial Guinea', + 'alpha2' => 'GQ', + 'alpha3' => 'GNQ', + 'numeric' => '226', + 'currency' => [ + 'XAF', + ], + ], + [ + 'name' => 'Eritrea', + 'alpha2' => 'ER', + 'alpha3' => 'ERI', + 'numeric' => '232', + 'currency' => [ + 'ERN', + ], + ], + [ + 'name' => 'Estonia', + 'alpha2' => 'EE', + 'alpha3' => 'EST', + 'numeric' => '233', + 'currency' => [ + 'EEK', + ], + ], + [ + 'name' => 'Ethiopia', + 'alpha2' => 'ET', + 'alpha3' => 'ETH', + 'numeric' => '231', + 'currency' => [ + 'ETB', + ], + ], + [ + 'name' => 'Falkland Islands (Malvinas)', + 'alpha2' => 'FK', + 'alpha3' => 'FLK', + 'numeric' => '238', + 'currency' => [ + 'FKP', + ], + ], + [ + 'name' => 'Faroe Islands', + 'alpha2' => 'FO', + 'alpha3' => 'FRO', + 'numeric' => '234', + 'currency' => [ + 'DKK', + ], + ], + [ + 'name' => 'Fiji', + 'alpha2' => 'FJ', + 'alpha3' => 'FJI', + 'numeric' => '242', + 'currency' => [ + 'FJD', + ], + ], + [ + 'name' => 'Finland', + 'alpha2' => 'FI', + 'alpha3' => 'FIN', + 'numeric' => '246', + 'currency' => [ + 'EUR', + ], + ], + [ + 'name' => 'France', + 'alpha2' => 'FR', + 'alpha3' => 'FRA', + 'numeric' => '250', + 'currency' => [ + 'EUR', + ], + ], + [ + 'name' => 'French Guiana', + 'alpha2' => 'GF', + 'alpha3' => 'GUF', + 'numeric' => '254', + 'currency' => [ + 'EUR', + ], + ], + [ + 'name' => 'French Polynesia', + 'alpha2' => 'PF', + 'alpha3' => 'PYF', + 'numeric' => '258', + 'currency' => [ + 'XPF', + ], + ], + [ + 'name' => 'French Southern Territories', + 'alpha2' => 'TF', + 'alpha3' => 'ATF', + 'numeric' => '260', + 'currency' => [ + 'EUR', + ], + ], + [ + 'name' => 'Gabon', + 'alpha2' => 'GA', + 'alpha3' => 'GAB', + 'numeric' => '266', + 'currency' => [ + 'XAF', + ], + ], + [ + 'name' => 'Gambia', + 'alpha2' => 'GM', + 'alpha3' => 'GMB', + 'numeric' => '270', + 'currency' => [ + 'GMD', + ], + ], + [ + 'name' => 'Georgia', + 'alpha2' => 'GE', + 'alpha3' => 'GEO', + 'numeric' => '268', + 'currency' => [ + 'GEL', + ], + ], + [ + 'name' => 'Germany', + 'alpha2' => 'DE', + 'alpha3' => 'DEU', + 'numeric' => '276', + 'currency' => [ + 'EUR', + ], + ], + [ + 'name' => 'Ghana', + 'alpha2' => 'GH', + 'alpha3' => 'GHA', + 'numeric' => '288', + 'currency' => [ + 'GHS', + ], + ], + [ + 'name' => 'Gibraltar', + 'alpha2' => 'GI', + 'alpha3' => 'GIB', + 'numeric' => '292', + 'currency' => [ + 'GIP', + ], + ], + [ + 'name' => 'Greece', + 'alpha2' => 'GR', + 'alpha3' => 'GRC', + 'numeric' => '300', + 'currency' => [ + 'EUR', + ], + ], + [ + 'name' => 'Greenland', + 'alpha2' => 'GL', + 'alpha3' => 'GRL', + 'numeric' => '304', + 'currency' => [ + 'DKK', + ], + ], + [ + 'name' => 'Grenada', + 'alpha2' => 'GD', + 'alpha3' => 'GRD', + 'numeric' => '308', + 'currency' => [ + 'XCD', + ], + ], + [ + 'name' => 'Guadeloupe', + 'alpha2' => 'GP', + 'alpha3' => 'GLP', + 'numeric' => '312', + 'currency' => [ + 'EUR', + ], + ], + [ + 'name' => 'Guam', + 'alpha2' => 'GU', + 'alpha3' => 'GUM', + 'numeric' => '316', + 'currency' => [ + 'USD', + ], + ], + [ + 'name' => 'Guatemala', + 'alpha2' => 'GT', + 'alpha3' => 'GTM', + 'numeric' => '320', + 'currency' => [ + 'GTQ', + ], + ], + [ + 'name' => 'Guernsey', + 'alpha2' => 'GG', + 'alpha3' => 'GGY', + 'numeric' => '831', + 'currency' => [ + 'GBP', + ], + ], + [ + 'name' => 'Guinea', + 'alpha2' => 'GN', + 'alpha3' => 'GIN', + 'numeric' => '324', + 'currency' => [ + 'GNF', + ], + ], + [ + 'name' => 'Guinea-Bissau', + 'alpha2' => 'GW', + 'alpha3' => 'GNB', + 'numeric' => '624', + 'currency' => [ + 'XOF', + ], + ], + [ + 'name' => 'Guyana', + 'alpha2' => 'GY', + 'alpha3' => 'GUY', + 'numeric' => '328', + 'currency' => [ + 'GYD', + ], + ], + [ + 'name' => 'Haiti', + 'alpha2' => 'HT', + 'alpha3' => 'HTI', + 'numeric' => '332', + 'currency' => [ + 'HTG', + ], + ], + [ + 'name' => 'Heard Island and McDonald Islands', + 'alpha2' => 'HM', + 'alpha3' => 'HMD', + 'numeric' => '334', + 'currency' => [ + 'AUD', + ], + ], + [ + 'name' => 'Holy See', + 'alpha2' => 'VA', + 'alpha3' => 'VAT', + 'numeric' => '336', + 'currency' => [ + 'EUR', + ], + ], + [ + 'name' => 'Honduras', + 'alpha2' => 'HN', + 'alpha3' => 'HND', + 'numeric' => '340', + 'currency' => [ + 'HNL', + ], + ], + [ + 'name' => 'Hong Kong', + 'alpha2' => 'HK', + 'alpha3' => 'HKG', + 'numeric' => '344', + 'currency' => [ + 'HKD', + ], + ], + [ + 'name' => 'Hungary', + 'alpha2' => 'HU', + 'alpha3' => 'HUN', + 'numeric' => '348', + 'currency' => [ + 'HUF', + ], + ], + [ + 'name' => 'Iceland', + 'alpha2' => 'IS', + 'alpha3' => 'ISL', + 'numeric' => '352', + 'currency' => [ + 'ISK', + ], + ], + [ + 'name' => 'India', + 'alpha2' => 'IN', + 'alpha3' => 'IND', + 'numeric' => '356', + 'currency' => [ + 'INR', + ], + ], + [ + 'name' => 'Indonesia', + 'alpha2' => 'ID', + 'alpha3' => 'IDN', + 'numeric' => '360', + 'currency' => [ + 'IDR', + ], + ], + [ + 'name' => 'Iran (Islamic Republic of)', + 'alpha2' => 'IR', + 'alpha3' => 'IRN', + 'numeric' => '364', + 'currency' => [ + 'IRR', + ], + ], + [ + 'name' => 'Iraq', + 'alpha2' => 'IQ', + 'alpha3' => 'IRQ', + 'numeric' => '368', + 'currency' => [ + 'IQD', + ], + ], + [ + 'name' => 'Ireland', + 'alpha2' => 'IE', + 'alpha3' => 'IRL', + 'numeric' => '372', + 'currency' => [ + 'EUR', + ], + ], + [ + 'name' => 'Isle of Man', + 'alpha2' => 'IM', + 'alpha3' => 'IMN', + 'numeric' => '833', + 'currency' => [ + 'GBP', + ], + ], + [ + 'name' => 'Israel', + 'alpha2' => 'IL', + 'alpha3' => 'ISR', + 'numeric' => '376', + 'currency' => [ + 'ILS', + ], + ], + [ + 'name' => 'Italy', + 'alpha2' => 'IT', + 'alpha3' => 'ITA', + 'numeric' => '380', + 'currency' => [ + 'EUR', + ], + ], + [ + 'name' => 'Jamaica', + 'alpha2' => 'JM', + 'alpha3' => 'JAM', + 'numeric' => '388', + 'currency' => [ + 'JMD', + ], + ], + [ + 'name' => 'Japan', + 'alpha2' => 'JP', + 'alpha3' => 'JPN', + 'numeric' => '392', + 'currency' => [ + 'JPY', + ], + ], + [ + 'name' => 'Jersey', + 'alpha2' => 'JE', + 'alpha3' => 'JEY', + 'numeric' => '832', + 'currency' => [ + 'GBP', + ], + ], + [ + 'name' => 'Jordan', + 'alpha2' => 'JO', + 'alpha3' => 'JOR', + 'numeric' => '400', + 'currency' => [ + 'JOD', + ], + ], + [ + 'name' => 'Kazakhstan', + 'alpha2' => 'KZ', + 'alpha3' => 'KAZ', + 'numeric' => '398', + 'currency' => [ + 'KZT', + ], + ], + [ + 'name' => 'Kenya', + 'alpha2' => 'KE', + 'alpha3' => 'KEN', + 'numeric' => '404', + 'currency' => [ + 'KES', + ], + ], + [ + 'name' => 'Kiribati', + 'alpha2' => 'KI', + 'alpha3' => 'KIR', + 'numeric' => '296', + 'currency' => [ + 'AUD', + ], + ], + [ + 'name' => 'Korea (Democratic People\'s Republic of)', + 'alpha2' => 'KP', + 'alpha3' => 'PRK', + 'numeric' => '408', + 'currency' => [ + 'KPW', + ], + ], + [ + 'name' => 'Korea (Republic of)', + 'alpha2' => 'KR', + 'alpha3' => 'KOR', + 'numeric' => '410', + 'currency' => [ + 'KRW', + ], + ], + [ + 'name' => 'Kuwait', + 'alpha2' => 'KW', + 'alpha3' => 'KWT', + 'numeric' => '414', + 'currency' => [ + 'KWD', + ], + ], + [ + 'name' => 'Kyrgyzstan', + 'alpha2' => 'KG', + 'alpha3' => 'KGZ', + 'numeric' => '417', + 'currency' => [ + 'KGS', + ], + ], + [ + 'name' => 'Lao People\'s Democratic Republic', + 'alpha2' => 'LA', + 'alpha3' => 'LAO', + 'numeric' => '418', + 'currency' => [ + 'LAK', + ], + ], + [ + 'name' => 'Latvia', + 'alpha2' => 'LV', + 'alpha3' => 'LVA', + 'numeric' => '428', + 'currency' => [ + 'LVL', + ], + ], + [ + 'name' => 'Lebanon', + 'alpha2' => 'LB', + 'alpha3' => 'LBN', + 'numeric' => '422', + 'currency' => [ + 'LBP', + ], + ], + [ + 'name' => 'Lesotho', + 'alpha2' => 'LS', + 'alpha3' => 'LSO', + 'numeric' => '426', + 'currency' => [ + 'LSL', + 'ZAR', + ], + ], + [ + 'name' => 'Liberia', + 'alpha2' => 'LR', + 'alpha3' => 'LBR', + 'numeric' => '430', + 'currency' => [ + 'LRD', + ], + ], + [ + 'name' => 'Libya', + 'alpha2' => 'LY', + 'alpha3' => 'LBY', + 'numeric' => '434', + 'currency' => [ + 'LYD', + ], + ], + [ + 'name' => 'Liechtenstein', + 'alpha2' => 'LI', + 'alpha3' => 'LIE', + 'numeric' => '438', + 'currency' => [ + 'CHF', + ], + ], + [ + 'name' => 'Lithuania', + 'alpha2' => 'LT', + 'alpha3' => 'LTU', + 'numeric' => '440', + 'currency' => [ + 'EUR', + ], + ], + [ + 'name' => 'Luxembourg', + 'alpha2' => 'LU', + 'alpha3' => 'LUX', + 'numeric' => '442', + 'currency' => [ + 'EUR', + ], + ], + [ + 'name' => 'Macao', + 'alpha2' => 'MO', + 'alpha3' => 'MAC', + 'numeric' => '446', + 'currency' => [ + 'MOP', + ], + ], + [ + 'name' => 'Macedonia (the former Yugoslav Republic of)', + 'alpha2' => 'MK', + 'alpha3' => 'MKD', + 'numeric' => '807', + 'currency' => [ + 'MKD', + ], + ], + [ + 'name' => 'Madagascar', + 'alpha2' => 'MG', + 'alpha3' => 'MDG', + 'numeric' => '450', + 'currency' => [ + 'MGA', + ], + ], + [ + 'name' => 'Malawi', + 'alpha2' => 'MW', + 'alpha3' => 'MWI', + 'numeric' => '454', + 'currency' => [ + 'MWK', + ], + ], + [ + 'name' => 'Malaysia', + 'alpha2' => 'MY', + 'alpha3' => 'MYS', + 'numeric' => '458', + 'currency' => [ + 'MYR', + ], + ], + [ + 'name' => 'Maldives', + 'alpha2' => 'MV', + 'alpha3' => 'MDV', + 'numeric' => '462', + 'currency' => [ + 'MVR', + ], + ], + [ + 'name' => 'Mali', + 'alpha2' => 'ML', + 'alpha3' => 'MLI', + 'numeric' => '466', + 'currency' => [ + 'XOF', + ], + ], + [ + 'name' => 'Malta', + 'alpha2' => 'MT', + 'alpha3' => 'MLT', + 'numeric' => '470', + 'currency' => [ + 'EUR', + ], + ], + [ + 'name' => 'Marshall Islands', + 'alpha2' => 'MH', + 'alpha3' => 'MHL', + 'numeric' => '584', + 'currency' => [ + 'USD', + ], + ], + [ + 'name' => 'Martinique', + 'alpha2' => 'MQ', + 'alpha3' => 'MTQ', + 'numeric' => '474', + 'currency' => [ + 'EUR', + ], + ], + [ + 'name' => 'Mauritania', + 'alpha2' => 'MR', + 'alpha3' => 'MRT', + 'numeric' => '478', + 'currency' => [ + 'MRO', + ], + ], + [ + 'name' => 'Mauritius', + 'alpha2' => 'MU', + 'alpha3' => 'MUS', + 'numeric' => '480', + 'currency' => [ + 'MUR', + ], + ], + [ + 'name' => 'Mayotte', + 'alpha2' => 'YT', + 'alpha3' => 'MYT', + 'numeric' => '175', + 'currency' => [ + 'EUR', + ], + ], + [ + 'name' => 'Mexico', + 'alpha2' => 'MX', + 'alpha3' => 'MEX', + 'numeric' => '484', + 'currency' => [ + 'MXN', + ], + ], + [ + 'name' => 'Micronesia (Federated States of)', + 'alpha2' => 'FM', + 'alpha3' => 'FSM', + 'numeric' => '583', + 'currency' => [ + 'USD', + ], + ], + [ + 'name' => 'Moldova (Republic of)', + 'alpha2' => 'MD', + 'alpha3' => 'MDA', + 'numeric' => '498', + 'currency' => [ + 'MDL', + ], + ], + [ + 'name' => 'Monaco', + 'alpha2' => 'MC', + 'alpha3' => 'MCO', + 'numeric' => '492', + 'currency' => [ + 'EUR', + ], + ], + [ + 'name' => 'Mongolia', + 'alpha2' => 'MN', + 'alpha3' => 'MNG', + 'numeric' => '496', + 'currency' => [ + 'MNT', + ], + ], + [ + 'name' => 'Montenegro', + 'alpha2' => 'ME', + 'alpha3' => 'MNE', + 'numeric' => '499', + 'currency' => [ + 'EUR', + ], + ], + [ + 'name' => 'Montserrat', + 'alpha2' => 'MS', + 'alpha3' => 'MSR', + 'numeric' => '500', + 'currency' => [ + 'XCD', + ], + ], + [ + 'name' => 'Morocco', + 'alpha2' => 'MA', + 'alpha3' => 'MAR', + 'numeric' => '504', + 'currency' => [ + 'MAD', + ], + ], + [ + 'name' => 'Mozambique', + 'alpha2' => 'MZ', + 'alpha3' => 'MOZ', + 'numeric' => '508', + 'currency' => [ + 'MZN', + ], + ], + [ + 'name' => 'Myanmar', + 'alpha2' => 'MM', + 'alpha3' => 'MMR', + 'numeric' => '104', + 'currency' => [ + 'MMK', + ], + ], + [ + 'name' => 'Namibia', + 'alpha2' => 'NA', + 'alpha3' => 'NAM', + 'numeric' => '516', + 'currency' => [ + 'NAD', + 'ZAR', + ], + ], + [ + 'name' => 'Nauru', + 'alpha2' => 'NR', + 'alpha3' => 'NRU', + 'numeric' => '520', + 'currency' => [ + 'AUD', + ], + ], + [ + 'name' => 'Nepal', + 'alpha2' => 'NP', + 'alpha3' => 'NPL', + 'numeric' => '524', + 'currency' => [ + 'NPR', + ], + ], + [ + 'name' => 'Netherlands', + 'alpha2' => 'NL', + 'alpha3' => 'NLD', + 'numeric' => '528', + 'currency' => [ + 'EUR', + ], + ], + [ + 'name' => 'New Caledonia', + 'alpha2' => 'NC', + 'alpha3' => 'NCL', + 'numeric' => '540', + 'currency' => [ + 'XPF', + ], + ], + [ + 'name' => 'New Zealand', + 'alpha2' => 'NZ', + 'alpha3' => 'NZL', + 'numeric' => '554', + 'currency' => [ + 'NZD', + ], + ], + [ + 'name' => 'Nicaragua', + 'alpha2' => 'NI', + 'alpha3' => 'NIC', + 'numeric' => '558', + 'currency' => [ + 'NIO', + ], + ], + [ + 'name' => 'Niger', + 'alpha2' => 'NE', + 'alpha3' => 'NER', + 'numeric' => '562', + 'currency' => [ + 'XOF', + ], + ], + [ + 'name' => 'Nigeria', + 'alpha2' => 'NG', + 'alpha3' => 'NGA', + 'numeric' => '566', + 'currency' => [ + 'NGN', + ], + ], + [ + 'name' => 'Niue', + 'alpha2' => 'NU', + 'alpha3' => 'NIU', + 'numeric' => '570', + 'currency' => [ + 'NZD', + ], + ], + [ + 'name' => 'Norfolk Island', + 'alpha2' => 'NF', + 'alpha3' => 'NFK', + 'numeric' => '574', + 'currency' => [ + 'AUD', + ], + ], + [ + 'name' => 'Northern Mariana Islands', + 'alpha2' => 'MP', + 'alpha3' => 'MNP', + 'numeric' => '580', + 'currency' => [ + 'USD', + ], + ], + [ + 'name' => 'Norway', + 'alpha2' => 'NO', + 'alpha3' => 'NOR', + 'numeric' => '578', + 'currency' => [ + 'NOK', + ], + ], + [ + 'name' => 'Oman', + 'alpha2' => 'OM', + 'alpha3' => 'OMN', + 'numeric' => '512', + 'currency' => [ + 'OMR', + ], + ], + [ + 'name' => 'Pakistan', + 'alpha2' => 'PK', + 'alpha3' => 'PAK', + 'numeric' => '586', + 'currency' => [ + 'PKR', + ], + ], + [ + 'name' => 'Palau', + 'alpha2' => 'PW', + 'alpha3' => 'PLW', + 'numeric' => '585', + 'currency' => [ + 'USD', + ], + ], + [ + 'name' => 'Palestine, State of', + 'alpha2' => 'PS', + 'alpha3' => 'PSE', + 'numeric' => '275', + 'currency' => [ + 'ILS', + ], + ], + [ + 'name' => 'Panama', + 'alpha2' => 'PA', + 'alpha3' => 'PAN', + 'numeric' => '591', + 'currency' => [ + 'PAB', + ], + ], + [ + 'name' => 'Papua New Guinea', + 'alpha2' => 'PG', + 'alpha3' => 'PNG', + 'numeric' => '598', + 'currency' => [ + 'PGK', + ], + ], + [ + 'name' => 'Paraguay', + 'alpha2' => 'PY', + 'alpha3' => 'PRY', + 'numeric' => '600', + 'currency' => [ + 'PYG', + ], + ], + [ + 'name' => 'Peru', + 'alpha2' => 'PE', + 'alpha3' => 'PER', + 'numeric' => '604', + 'currency' => [ + 'PEN', + ], + ], + [ + 'name' => 'Philippines', + 'alpha2' => 'PH', + 'alpha3' => 'PHL', + 'numeric' => '608', + 'currency' => [ + 'PHP', + ], + ], + [ + 'name' => 'Pitcairn', + 'alpha2' => 'PN', + 'alpha3' => 'PCN', + 'numeric' => '612', + 'currency' => [ + 'NZD', + ], + ], + [ + 'name' => 'Poland', + 'alpha2' => 'PL', + 'alpha3' => 'POL', + 'numeric' => '616', + 'currency' => [ + 'PLN', + ], + ], + [ + 'name' => 'Portugal', + 'alpha2' => 'PT', + 'alpha3' => 'PRT', + 'numeric' => '620', + 'currency' => [ + 'EUR', + ], + ], + [ + 'name' => 'Puerto Rico', + 'alpha2' => 'PR', + 'alpha3' => 'PRI', + 'numeric' => '630', + 'currency' => [ + 'USD', + ], + ], + [ + 'name' => 'Qatar', + 'alpha2' => 'QA', + 'alpha3' => 'QAT', + 'numeric' => '634', + 'currency' => [ + 'QAR', + ], + ], + [ + 'name' => 'Réunion', + 'alpha2' => 'RE', + 'alpha3' => 'REU', + 'numeric' => '638', + 'currency' => [ + 'EUR', + ], + ], + [ + 'name' => 'Romania', + 'alpha2' => 'RO', + 'alpha3' => 'ROU', + 'numeric' => '642', + 'currency' => [ + 'RON', + ], + ], + [ + 'name' => 'Russian Federation', + 'alpha2' => 'RU', + 'alpha3' => 'RUS', + 'numeric' => '643', + 'currency' => [ + 'RUB', + ], + ], + [ + 'name' => 'Rwanda', + 'alpha2' => 'RW', + 'alpha3' => 'RWA', + 'numeric' => '646', + 'currency' => [ + 'RWF', + ], + ], + [ + 'name' => 'Saint Barthélemy', + 'alpha2' => 'BL', + 'alpha3' => 'BLM', + 'numeric' => '652', + 'currency' => [ + 'EUR', + ], + ], + [ + 'name' => 'Saint Helena, Ascension and Tristan da Cunha', + 'alpha2' => 'SH', + 'alpha3' => 'SHN', + 'numeric' => '654', + 'currency' => [ + 'SHP', + ], + ], + [ + 'name' => 'Saint Kitts and Nevis', + 'alpha2' => 'KN', + 'alpha3' => 'KNA', + 'numeric' => '659', + 'currency' => [ + 'XCD', + ], + ], + [ + 'name' => 'Saint Lucia', + 'alpha2' => 'LC', + 'alpha3' => 'LCA', + 'numeric' => '662', + 'currency' => [ + 'XCD', + ], + ], + [ + 'name' => 'Saint Martin (French part)', + 'alpha2' => 'MF', + 'alpha3' => 'MAF', + 'numeric' => '663', + 'currency' => [ + 'EUR', + 'USD', + ], + ], + [ + 'name' => 'Saint Pierre and Miquelon', + 'alpha2' => 'PM', + 'alpha3' => 'SPM', + 'numeric' => '666', + 'currency' => [ + 'EUR', + ], + ], + [ + 'name' => 'Saint Vincent and the Grenadines', + 'alpha2' => 'VC', + 'alpha3' => 'VCT', + 'numeric' => '670', + 'currency' => [ + 'XCD', + ], + ], + [ + 'name' => 'Samoa', + 'alpha2' => 'WS', + 'alpha3' => 'WSM', + 'numeric' => '882', + 'currency' => [ + 'WST', + ], + ], + [ + 'name' => 'San Marino', + 'alpha2' => 'SM', + 'alpha3' => 'SMR', + 'numeric' => '674', + 'currency' => [ + 'EUR', + ], + ], + [ + 'name' => 'Sao Tome and Principe', + 'alpha2' => 'ST', + 'alpha3' => 'STP', + 'numeric' => '678', + 'currency' => [ + 'STD', + ], + ], + [ + 'name' => 'Saudi Arabia', + 'alpha2' => 'SA', + 'alpha3' => 'SAU', + 'numeric' => '682', + 'currency' => [ + 'SAR', + ], + ], + [ + 'name' => 'Senegal', + 'alpha2' => 'SN', + 'alpha3' => 'SEN', + 'numeric' => '686', + 'currency' => [ + 'XOF', + ], + ], + [ + 'name' => 'Serbia', + 'alpha2' => 'RS', + 'alpha3' => 'SRB', + 'numeric' => '688', + 'currency' => [ + 'RSD', + ], + ], + [ + 'name' => 'Seychelles', + 'alpha2' => 'SC', + 'alpha3' => 'SYC', + 'numeric' => '690', + 'currency' => [ + 'SCR', + ], + ], + [ + 'name' => 'Sierra Leone', + 'alpha2' => 'SL', + 'alpha3' => 'SLE', + 'numeric' => '694', + 'currency' => [ + 'SLL', + ], + ], + [ + 'name' => 'Singapore', + 'alpha2' => 'SG', + 'alpha3' => 'SGP', + 'numeric' => '702', + 'currency' => [ + 'SGD', + ], + ], + [ + 'name' => 'Sint Maarten (Dutch part)', + 'alpha2' => 'SX', + 'alpha3' => 'SXM', + 'numeric' => '534', + 'currency' => [ + 'ANG', + ], + ], + [ + 'name' => 'Slovakia', + 'alpha2' => 'SK', + 'alpha3' => 'SVK', + 'numeric' => '703', + 'currency' => [ + 'EUR', + ], + ], + [ + 'name' => 'Slovenia', + 'alpha2' => 'SI', + 'alpha3' => 'SVN', + 'numeric' => '705', + 'currency' => [ + 'EUR', + ], + ], + [ + 'name' => 'Solomon Islands', + 'alpha2' => 'SB', + 'alpha3' => 'SLB', + 'numeric' => '090', + 'currency' => [ + 'SBD', + ], + ], + [ + 'name' => 'Somalia', + 'alpha2' => 'SO', + 'alpha3' => 'SOM', + 'numeric' => '706', + 'currency' => [ + 'SOS', + ], + ], + [ + 'name' => 'South Africa', + 'alpha2' => 'ZA', + 'alpha3' => 'ZAF', + 'numeric' => '710', + 'currency' => [ + 'ZAR', + ], + ], + [ + 'name' => 'South Georgia and the South Sandwich Islands', + 'alpha2' => 'GS', + 'alpha3' => 'SGS', + 'numeric' => '239', + 'currency' => [ + 'GBP', + ], + ], + [ + 'name' => 'South Sudan', + 'alpha2' => 'SS', + 'alpha3' => 'SSD', + 'numeric' => '728', + 'currency' => [ + 'SSP', + ], + ], + [ + 'name' => 'Spain', + 'alpha2' => 'ES', + 'alpha3' => 'ESP', + 'numeric' => '724', + 'currency' => [ + 'EUR', + ], + ], + [ + 'name' => 'Sri Lanka', + 'alpha2' => 'LK', + 'alpha3' => 'LKA', + 'numeric' => '144', + 'currency' => [ + 'LKR', + ], + ], + [ + 'name' => 'Sudan', + 'alpha2' => 'SD', + 'alpha3' => 'SDN', + 'numeric' => '729', + 'currency' => [ + 'SDG', + ], + ], + [ + 'name' => 'Suriname', + 'alpha2' => 'SR', + 'alpha3' => 'SUR', + 'numeric' => '740', + 'currency' => [ + 'SRD', + ], + ], + [ + 'name' => 'Svalbard and Jan Mayen', + 'alpha2' => 'SJ', + 'alpha3' => 'SJM', + 'numeric' => '744', + 'currency' => [ + 'NOK', + ], + ], + [ + 'name' => 'Swaziland', + 'alpha2' => 'SZ', + 'alpha3' => 'SWZ', + 'numeric' => '748', + 'currency' => [ + 'SZL', + 'ZAR', + ], + ], + [ + 'name' => 'Sweden', + 'alpha2' => 'SE', + 'alpha3' => 'SWE', + 'numeric' => '752', + 'currency' => [ + 'SEK', + ], + ], + [ + 'name' => 'Switzerland', + 'alpha2' => 'CH', + 'alpha3' => 'CHE', + 'numeric' => '756', + 'currency' => [ + 'CHF', + ], + ], + [ + 'name' => 'Syrian Arab Republic', + 'alpha2' => 'SY', + 'alpha3' => 'SYR', + 'numeric' => '760', + 'currency' => [ + 'SYP', + ], + ], + [ + 'name' => 'Taiwan (Province of China)', + 'alpha2' => 'TW', + 'alpha3' => 'TWN', + 'numeric' => '158', + 'currency' => [ + 'TWD', + ], + ], + [ + 'name' => 'Tajikistan', + 'alpha2' => 'TJ', + 'alpha3' => 'TJK', + 'numeric' => '762', + 'currency' => [ + 'TJS', + ], + ], + [ + 'name' => 'Tanzania, United Republic of', + 'alpha2' => 'TZ', + 'alpha3' => 'TZA', + 'numeric' => '834', + 'currency' => [ + 'TZS', + ], + ], + [ + 'name' => 'Thailand', + 'alpha2' => 'TH', + 'alpha3' => 'THA', + 'numeric' => '764', + 'currency' => [ + 'THB', + ], + ], + [ + 'name' => 'Timor-Leste', + 'alpha2' => 'TL', + 'alpha3' => 'TLS', + 'numeric' => '626', + 'currency' => [ + 'USD', + ], + ], + [ + 'name' => 'Togo', + 'alpha2' => 'TG', + 'alpha3' => 'TGO', + 'numeric' => '768', + 'currency' => [ + 'XOF', + ], + ], + [ + 'name' => 'Tokelau', + 'alpha2' => 'TK', + 'alpha3' => 'TKL', + 'numeric' => '772', + 'currency' => [ + 'NZD', + ], + ], + [ + 'name' => 'Tonga', + 'alpha2' => 'TO', + 'alpha3' => 'TON', + 'numeric' => '776', + 'currency' => [ + 'TOP', + ], + ], + [ + 'name' => 'Trinidad and Tobago', + 'alpha2' => 'TT', + 'alpha3' => 'TTO', + 'numeric' => '780', + 'currency' => [ + 'TTD', + ], + ], + [ + 'name' => 'Tunisia', + 'alpha2' => 'TN', + 'alpha3' => 'TUN', + 'numeric' => '788', + 'currency' => [ + 'TND', + ], + ], + [ + 'name' => 'Turkey', + 'alpha2' => 'TR', + 'alpha3' => 'TUR', + 'numeric' => '792', + 'currency' => [ + 'TRY', + ], + ], + [ + 'name' => 'Turkmenistan', + 'alpha2' => 'TM', + 'alpha3' => 'TKM', + 'numeric' => '795', + 'currency' => [ + 'TMT', + ], + ], + [ + 'name' => 'Turks and Caicos Islands', + 'alpha2' => 'TC', + 'alpha3' => 'TCA', + 'numeric' => '796', + 'currency' => [ + 'USD', + ], + ], + [ + 'name' => 'Tuvalu', + 'alpha2' => 'TV', + 'alpha3' => 'TUV', + 'numeric' => '798', + 'currency' => [ + 'AUD', + ], + ], + [ + 'name' => 'Uganda', + 'alpha2' => 'UG', + 'alpha3' => 'UGA', + 'numeric' => '800', + 'currency' => [ + 'UGX', + ], + ], + [ + 'name' => 'Ukraine', + 'alpha2' => 'UA', + 'alpha3' => 'UKR', + 'numeric' => '804', + 'currency' => [ + 'UAH', + ], + ], + [ + 'name' => 'United Arab Emirates', + 'alpha2' => 'AE', + 'alpha3' => 'ARE', + 'numeric' => '784', + 'currency' => [ + 'AED', + ], + ], + [ + 'name' => 'United Kingdom of Great Britain and Northern Ireland', + 'alpha2' => 'GB', + 'alpha3' => 'GBR', + 'numeric' => '826', + 'currency' => [ + 'GBP', + ], + ], + [ + 'name' => 'United States of America', + 'alpha2' => 'US', + 'alpha3' => 'USA', + 'numeric' => '840', + 'currency' => [ + 'USD', + ], + ], + [ + 'name' => 'United States Minor Outlying Islands', + 'alpha2' => 'UM', + 'alpha3' => 'UMI', + 'numeric' => '581', + 'currency' => [ + 'USD', + ], + ], + [ + 'name' => 'Uruguay', + 'alpha2' => 'UY', + 'alpha3' => 'URY', + 'numeric' => '858', + 'currency' => [ + 'UYU', + ], + ], + [ + 'name' => 'Uzbekistan', + 'alpha2' => 'UZ', + 'alpha3' => 'UZB', + 'numeric' => '860', + 'currency' => [ + 'UZS', + ], + ], + [ + 'name' => 'Vanuatu', + 'alpha2' => 'VU', + 'alpha3' => 'VUT', + 'numeric' => '548', + 'currency' => [ + 'VUV', + ], + ], + [ + 'name' => 'Venezuela (Bolivarian Republic of)', + 'alpha2' => 'VE', + 'alpha3' => 'VEN', + 'numeric' => '862', + 'currency' => [ + 'VEF', + ], + ], + [ + 'name' => 'Viet Nam', + 'alpha2' => 'VN', + 'alpha3' => 'VNM', + 'numeric' => '704', + 'currency' => [ + 'VND', + ], + ], + [ + 'name' => 'Virgin Islands (British)', + 'alpha2' => 'VG', + 'alpha3' => 'VGB', + 'numeric' => '092', + 'currency' => [ + 'USD', + ], + ], + [ + 'name' => 'Virgin Islands (U.S.)', + 'alpha2' => 'VI', + 'alpha3' => 'VIR', + 'numeric' => '850', + 'currency' => [ + 'USD', + ], + ], + [ + 'name' => 'Wallis and Futuna', + 'alpha2' => 'WF', + 'alpha3' => 'WLF', + 'numeric' => '876', + 'currency' => [ + 'XPF', + ], + ], + [ + 'name' => 'Western Sahara', + 'alpha2' => 'EH', + 'alpha3' => 'ESH', + 'numeric' => '732', + 'currency' => [ + 'MAD', + ], + ], + [ + 'name' => 'Yemen', + 'alpha2' => 'YE', + 'alpha3' => 'YEM', + 'numeric' => '887', + 'currency' => [ + 'YER', + ], + ], + [ + 'name' => 'Zambia', + 'alpha2' => 'ZM', + 'alpha3' => 'ZMB', + 'numeric' => '894', + 'currency' => [ + 'ZMW', + ], + ], + [ + 'name' => 'Zimbabwe', + 'alpha2' => 'ZW', + 'alpha3' => 'ZWE', + 'numeric' => '716', + 'currency' => [ + 'BWP', + 'EUR', + 'GBP', + 'USD', + 'ZAR', + ], + ], + ]; +} diff --git a/vendors/league-iso3166/vendor/league/iso3166/src/ISO3166DataProvider.php b/vendors/league-iso3166/vendor/league/iso3166/src/ISO3166DataProvider.php new file mode 100644 index 0000000..71da6de --- /dev/null +++ b/vendors/league-iso3166/vendor/league/iso3166/src/ISO3166DataProvider.php @@ -0,0 +1,58 @@ + + * + * For the full copyright and license information, please view + * the LICENSE file that was distributed with this source code. + */ + +namespace League\ISO3166; + +interface ISO3166DataProvider +{ + /** + * Lookup ISO3166-1 data by alpha2 identifier. + * + * @api + * + * @param string $alpha2 + * + * @throws \League\ISO3166\Exception\InvalidArgumentException if input is not a string + * @throws \League\ISO3166\Exception\DomainException if input does not look like an alpha2 key + * @throws \League\ISO3166\Exception\OutOfBoundsException if input does not exist in dataset + * + * @return array + */ + public function alpha2($alpha2); + + /** + * Lookup ISO3166-1 data by alpha3 identifier. + * + * @api + * + * @param string $alpha3 + * + * @throws \League\ISO3166\Exception\InvalidArgumentException if input is not a string + * @throws \League\ISO3166\Exception\DomainException if input does not look like an alpha3 key + * @throws \League\ISO3166\Exception\OutOfBoundsException if input does not exist in dataset + * + * @return array + */ + public function alpha3($alpha3); + + /** + * Lookup ISO3166-1 data by numeric identifier (numerical string, that is). + * + * @api + * + * @param string $numeric + * + * @throws \League\ISO3166\Exception\InvalidArgumentException if input is not a string + * @throws \League\ISO3166\Exception\DomainException if input does not look like a numeric key + * @throws \League\ISO3166\Exception\OutOfBoundsException if input does not exist in dataset + * + * @return array + */ + public function numeric($numeric); +} diff --git a/vendors/league-iso3166/vendor/league/iso3166/src/ISO3166DataValidator.php b/vendors/league-iso3166/vendor/league/iso3166/src/ISO3166DataValidator.php new file mode 100644 index 0000000..9b907eb --- /dev/null +++ b/vendors/league-iso3166/vendor/league/iso3166/src/ISO3166DataValidator.php @@ -0,0 +1,55 @@ + + * + * For the full copyright and license information, please view + * the LICENSE file that was distributed with this source code. + */ + +namespace League\ISO3166; + +use League\ISO3166\Exception\DomainException; + +final class ISO3166DataValidator +{ + /** + * @param array $data + * + * @return array + */ + public function validate(array $data) + { + foreach ($data as $entry) { + $this->assertEntryHasRequiredKeys($entry); + } + + return $data; + } + + /** + * @param array $entry + * + * @throws \League\ISO3166\Exception\DomainException if given data entry does not have all the required keys + */ + private function assertEntryHasRequiredKeys(array $entry) + { + if (!isset($entry[ISO3166::KEY_ALPHA2])) { + throw new DomainException('Each data entry must have a valid alpha2 key.'); + } + + Guards::guardAgainstInvalidAlpha2($entry[ISO3166::KEY_ALPHA2]); + + if (!isset($entry[ISO3166::KEY_ALPHA3])) { + throw new DomainException('Each data entry must have a valid alpha3 key.'); + } + + Guards::guardAgainstInvalidAlpha3($entry[ISO3166::KEY_ALPHA3]); + + if (!isset($entry[ISO3166::KEY_NUMERIC])) { + throw new DomainException('Each data entry must have a valid numeric key.'); + } + + Guards::guardAgainstInvalidNumeric($entry[ISO3166::KEY_NUMERIC]); + } +} diff --git a/woocommerce-gateway-mondido.php b/woocommerce-gateway-mondido.php index d16b81e..00dd731 100644 --- a/woocommerce-gateway-mondido.php +++ b/woocommerce-gateway-mondido.php @@ -20,6 +20,9 @@ class WC_Mondido_Payments { * Constructor */ public function __construct() { + // Includes + $this->includes(); + // Actions add_filter( 'plugin_action_links_' . plugin_basename( __FILE__ ), array( $this, @@ -60,7 +63,25 @@ public function __construct() { // WC_Order Compatibility for WC < 3.0 add_action( 'woocommerce_init', __CLASS__ . '::add_compatibility' ); - } + + // Mondido Checkout + add_action( 'wp_ajax_mondido_place_order', array( $this, 'ajax_mondido_place_order' ) ); + add_action( 'wp_ajax_nopriv_mondido_place_order', array( $this, 'ajax_mondido_place_order' ) ); + + add_action( 'wp_ajax_mondido_buy_product', array( $this, 'ajax_mondido_buy_product' ) ); + add_action( 'wp_ajax_nopriv_mondido_buy_product', array( $this, 'ajax_mondido_buy_product' ) ); + } + + /** + * Load Vendors + */ + public function includes() { + $vendorsDir = dirname( __FILE__ ) . '/vendors'; + + if ( ! class_exists( '\\League\\ISO3166\\ISO3166', FALSE ) ) { + require_once $vendorsDir . '/league-iso3166/vendor/autoload.php'; + } + } /** * Add relevant links to plugins page @@ -91,6 +112,7 @@ public function init() { // Includes include_once( dirname( __FILE__ ) . '/includes/class-wc-gateway-mondido-abstract.php' ); include_once( dirname( __FILE__ ) . '/includes/class-wc-gateway-mondido-hw.php' ); + include_once( dirname( __FILE__ ) . '/includes/class-wc-gateway-mondido-checkout.php' ); include_once( dirname( __FILE__ ) . '/includes/class-wc-gateway-mondido-invoice.php' ); include_once( dirname( __FILE__ ) . '/includes/class-wc-gateway-mondido-bank.php' ); include_once( dirname( __FILE__ ) . '/includes/class-wc-gateway-mondido-swish.php' ); @@ -102,6 +124,7 @@ public function init() { */ public function register_gateway( $methods ) { $methods[] = 'WC_Gateway_Mondido_HW'; + $methods[] = 'WC_Gateway_Mondido_Checkout'; $methods[] = 'WC_Gateway_Mondido_Invoice'; $methods[] = 'WC_Gateway_Mondido_Bank'; $methods[] = 'WC_Gateway_Mondido_Swish'; @@ -115,6 +138,23 @@ public function register_gateway( $methods ) { */ public function add_scripts() { wp_enqueue_style( 'wc-gateway-mondido', plugins_url( '/assets/css/style.css', __FILE__ ), array(), FALSE, 'all' ); + wp_enqueue_script( 'iframe-resizer', untrailingslashit( plugins_url( '/', __FILE__ ) ) . '/assets/js/iframe-resizer/iframeResizer.min.js', array(), NULL, FALSE ); + + wp_register_script( 'wc-gateway-mondido-checkout', untrailingslashit( plugins_url( '/', __FILE__ ) ) . '/assets/js/checkout.js', array( 'jquery' ), NULL, TRUE ); + + // Localize the script with new data + $translation_array = array( + 'place_order_url' => add_query_arg( 'action', 'mondido_place_order', admin_url( 'admin-ajax.php' ) ), + 'buy_product_url' => add_query_arg( 'action', 'mondido_buy_product', admin_url( 'admin-ajax.php' ) ) + ); + wp_localize_script( 'wc-gateway-mondido-checkout', 'WC_Gateway_Mondido_Checkout', $translation_array ); + + if ( is_product() ) { + wp_enqueue_script( 'wc-gateway-mondido-product', untrailingslashit( plugins_url( '/', __FILE__ ) ) . '/assets/js/product.js', array( 'wc-gateway-mondido-checkout' ), NULL, TRUE ); + } + + // Enqueued script with localized data. + wp_enqueue_script( 'wc-gateway-mondido-checkout' ); } /** @@ -372,6 +412,10 @@ public static function order_needs_payment( $needs_payment, $order, $valid_order * @return mixed */ public function add_recurring_items( $fields, $order, $gateway ) { + if ( ! $order ) { + return $fields; + } + foreach ( $order->get_items( 'line_item' ) as $order_item ) { if ( version_compare( WC()->version, '3.0', '>=' ) ) { $plan_id = get_post_meta( $order_item->get_product_id(), '_mondido_plan_id', TRUE ); @@ -423,6 +467,60 @@ public static function add_compatibility() { include_once( dirname( __FILE__ ) . '/includes/deprecated/class-wc-order-compatibility-mondido.php' ); } } + + /** + * Place Order + * @return void + */ + public function ajax_mondido_place_order() + { + define( 'WOOCOMMERCE_CHECKOUT', TRUE ); + WC()->cart->get_cart_from_session(); + + try { + // @todo WC 2.6 support + $data = array( + 'payment_method' => 'mondido_checkout', + 'customer_id' => get_current_user_id(), + 'status' => 'pending' + ); + + $order_id = WC()->checkout()->create_order( $data ); + if ( is_wp_error( $order_id ) ) { + throw new Exception( $order_id->get_error_message() ); + } + + $order = wc_get_order( $order_id ); + do_action( 'woocommerce_checkout_order_processed', $order_id, $data, $order ); + } catch ( Exception $e ) { + wp_send_json_error( $e->getMessage() ); + + return; + } + + // Mondido Checkout flag + update_post_meta( $order_id, '_mondido_checkout', TRUE ); + + wp_send_json_success( array( + 'order_id' => $order_id, + 'redirect_url' => $order->get_checkout_payment_url( TRUE ) + ) ); + } + + public function ajax_mondido_buy_product() + { + define( 'WOOCOMMERCE_CART', TRUE ); + $product_id = stripslashes( $_POST['product_id'] ); + $qty = stripslashes( $_POST['qty'] ); + + // @todo Variations + + WC()->cart->empty_cart( TRUE ); + WC()->cart->add_to_cart($product_id, $qty); + WC()->cart->calculate_totals(); + + wp_send_json_success(); + } } new WC_Mondido_Payments();