From 963f0b616b82bffff9db7a33952a95ab3802c5b4 Mon Sep 17 00:00:00 2001 From: "Ruben C. Arslan" Date: Tue, 14 Aug 2018 14:32:27 +0200 Subject: [PATCH 1/7] closes #367 --- application/Model/Item.php | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/application/Model/Item.php b/application/Model/Item.php index d81cdcdbd..bd8ae1e5f 100644 --- a/application/Model/Item.php +++ b/application/Model/Item.php @@ -227,10 +227,11 @@ public function __construct($options = array()) { $this->js_showif = preg_replace("/FALSE/", "false", $this->js_showif); // uppercase, R, FALSE, to lowercase, JS, false $this->js_showif = preg_replace("/TRUE/", "true", $this->js_showif); // uppercase, R, TRUE, to lowercase, JS, true $quoted_string = "([\"'])((\\\\{2})*|(.*?[^\\\\](\\\\{2})*))\\1"; - $this->js_showif = preg_replace("/\s*\%contains\%\s*" . $quoted_string . "/", ".indexOf($1$2$1) > -1", $this->js_showif); - $this->js_showif = preg_replace("/\s*\%begins_with\%\s*" . $quoted_string . "/", ".indexOf($1$2$1) === 0", $this->js_showif); - $this->js_showif = preg_replace("/\s*\%starts_with\%\s*" . $quoted_string . "/", ".indexOf($1$2$1) === 0", $this->js_showif); - $this->js_showif = preg_replace("/\s*\%ends_with\%\s*" . $quoted_string . "/", ".endsWith($1$2$1)", $this->js_showif); + $this->js_showif = preg_replace("/\s*\%contains\%\s*" . $quoted_string . "/", ".toString().indexOf($1$2$1) > -1", $this->js_showif); + $this->js_showif = preg_replace("/\s*\%contains_word\%\s*" . $quoted_string . "/", ".toString().match(/\\b$2\\b/) !== null", $this->js_showif); + $this->js_showif = preg_replace("/\s*\%begins_with\%\s*" . $quoted_string . "/", ".toString().indexOf($1$2$1) === 0", $this->js_showif); + $this->js_showif = preg_replace("/\s*\%starts_with\%\s*" . $quoted_string . "/", ".toString().indexOf($1$2$1) === 0", $this->js_showif); + $this->js_showif = preg_replace("/\s*\%ends_with\%\s*" . $quoted_string . "/", ".toString().endsWith($1$2$1)", $this->js_showif); $this->js_showif = preg_replace("/\s*stringr::str_length\(([a-zA-Z0-9_'\"]+)\)/", "$1.length", $this->js_showif); if (strstr($this->showif, "//js_only") !== false) { From 2ce5634563aba098377753c65d1f6a80fce66164 Mon Sep 17 00:00:00 2001 From: "Ruben C. Arslan" Date: Tue, 14 Aug 2018 14:56:34 +0200 Subject: [PATCH 2/7] closes #368 --- webroot/assets/build/js/formr-material.min.js | 2 +- webroot/assets/build/js/formr.min.js | 2 +- webroot/assets/common/js/survey.js | 255 ++++++++++-------- 3 files changed, 141 insertions(+), 118 deletions(-) diff --git a/webroot/assets/build/js/formr-material.min.js b/webroot/assets/build/js/formr-material.min.js index 90c948242..eeaaca4e3 100644 --- a/webroot/assets/build/js/formr-material.min.js +++ b/webroot/assets/build/js/formr-material.min.js @@ -6,4 +6,4 @@ dataFilter:m}))},basePath:d},support:k,bugs:{},modules:{},features:{},featureLis p(a))}),j(e),e.on("keyup-change input paste",this.bind(this.updateResults)),e.on("focus",function(){e.addClass("select2-focused")}),e.on("blur",function(){e.removeClass("select2-focused")}),this.dropdown.on("mouseup",g,this.bind(function(b){a(b.target).closest(".select2-result-selectable").length>0&&(this.highlightUnderEvent(b),this.selectHighlighted(b))})),this.dropdown.on("click mouseup mousedown touchstart touchend focusin",function(a){a.stopPropagation()}),this.lastSearchTerm=b,a.isFunction(this.opts.initSelection)&&(this.initSelection(),this.monitorSource()),null!==c.maximumInputLength&&this.search.attr("maxlength",c.maximumInputLength);var h=c.element.prop("disabled");h===b&&(h=!1),this.enable(!h);var i=c.element.prop("readonly");i===b&&(i=!1),this.readonly(i),K=K||f(),this.autofocus=c.element.prop("autofocus"),c.element.prop("autofocus",!1),this.autofocus&&this.focus(),this.search.attr("placeholder",c.searchInputPlaceholder)},destroy:function(){var a=this.opts.element,c=a.data("select2"),d=this;this.close(),a.length&&a[0].detachEvent&&d._sync&&a.each(function(){d._sync&&this.detachEvent("onpropertychange",d._sync)}),this.propertyObserver&&(this.propertyObserver.disconnect(),this.propertyObserver=null),this._sync=null,c!==b&&(c.container.remove(),c.liveRegion.remove(),c.dropdown.remove(),a.removeData("select2").off(".select2"),a.is("input[type='hidden']")?a.css("display",""):(a.show().prop("autofocus",this.autofocus||!1),this.elementTabIndex?a.attr({tabindex:this.elementTabIndex}):a.removeAttr("tabindex"),a.show())),C.call(this,"container","liveRegion","dropdown","results","search")},optionToData:function(a){return a.is("option")?{id:a.prop("value"),text:a.text(),element:a.get(),css:a.attr("class"),disabled:a.prop("disabled"),locked:g(a.attr("locked"),"locked")||g(a.data("locked"),!0)}:a.is("optgroup")?{text:a.attr("label"),children:[],element:a.get(),css:a.attr("class")}:void 0},prepareOpts:function(c){var d,e,f,i,j=this;if(d=c.element,"select"===d.get(0).tagName.toLowerCase()&&(this.select=e=c.element),e&&a.each(["id","multiple","ajax","query","createSearchChoice","initSelection","data","tags"],function(){if(this in c)throw new Error("Option '"+this+"' is not allowed for Select2 when attached to a ","
"," ","
    ","
","
"].join(""));return b},enableInterface:function(){this.parent.enableInterface.apply(this,arguments)&&this.focusser.prop("disabled",!this.isInterfaceEnabled())},opening:function(){var b,c,d;this.opts.minimumResultsForSearch>=0&&this.showSearch(!0),this.parent.opening.apply(this,arguments),this.showSearchInput!==!1&&this.search.val(this.focusser.val()),this.opts.shouldFocusInput(this)&&(this.search.focus(),b=this.search.get(0),b.createTextRange?(c=b.createTextRange(),c.collapse(!1),c.select()):b.setSelectionRange&&(d=this.search.val().length,b.setSelectionRange(d,d))),this.prefillNextSearchTerm(),this.focusser.prop("disabled",!0).val(""),this.updateResults(!0),this.opts.element.trigger(a.Event("select2-open"))},close:function(){this.opened()&&(this.parent.close.apply(this,arguments),this.focusser.prop("disabled",!1),this.opts.shouldFocusInput(this)&&this.focusser.focus())},focus:function(){this.opened()?this.close():(this.focusser.prop("disabled",!1),this.opts.shouldFocusInput(this)&&this.focusser.focus())},isFocused:function(){return this.container.hasClass("select2-container-active")},cancel:function(){this.parent.cancel.apply(this,arguments),this.focusser.prop("disabled",!1),this.opts.shouldFocusInput(this)&&this.focusser.focus()},destroy:function(){a("label[for='"+this.focusser.attr("id")+"']").attr("for",this.opts.element.attr("id")),this.parent.destroy.apply(this,arguments),C.call(this,"selection","focusser")},initContainer:function(){var b,d,e=this.container,f=this.dropdown,g=H();this.opts.minimumResultsForSearch<0?this.showSearch(!1):this.showSearch(!0),this.selection=b=e.find(".select2-choice"),this.focusser=e.find(".select2-focusser"),b.find(".select2-chosen").attr("id","select2-chosen-"+g),this.focusser.attr("aria-labelledby","select2-chosen-"+g),this.results.attr("id","select2-results-"+g),this.search.attr("aria-owns","select2-results-"+g),this.focusser.attr("id","s2id_autogen"+g),d=a("label[for='"+this.opts.element.attr("id")+"']"),this.opts.element.on("focus.select2",this.bind(function(){this.focus()})),this.focusser.prev().text(d.text()).attr("for",this.focusser.attr("id"));var h=this.opts.element.attr("title");this.opts.element.attr("title",h||d.text()),this.focusser.attr("tabindex",this.elementTabIndex),this.search.attr("id",this.focusser.attr("id")+"_search"),this.search.prev().text(a("label[for='"+this.focusser.attr("id")+"']").text()).attr("for",this.search.attr("id")),this.search.on("keydown",this.bind(function(a){if(this.isInterfaceEnabled()&&229!=a.keyCode){if(a.which===M.PAGE_UP||a.which===M.PAGE_DOWN)return void p(a);switch(a.which){case M.UP:case M.DOWN:return this.moveHighlight(a.which===M.UP?-1:1),void p(a);case M.ENTER:return this.selectHighlighted(),void p(a);case M.TAB:return void this.selectHighlighted({noFocus:!0});case M.ESC:return this.cancel(a),void p(a)}}})),this.search.on("blur",this.bind(function(a){document.activeElement===this.body.get(0)&&window.setTimeout(this.bind(function(){this.opened()&&this.results&&this.results.length>1&&this.search.focus()}),0)})),this.focusser.on("keydown",this.bind(function(a){if(this.isInterfaceEnabled()&&a.which!==M.TAB&&!M.isControl(a)&&!M.isFunctionKey(a)&&a.which!==M.ESC){if(this.opts.openOnEnter===!1&&a.which===M.ENTER)return void p(a);if(a.which==M.DOWN||a.which==M.UP||a.which==M.ENTER&&this.opts.openOnEnter){if(a.altKey||a.ctrlKey||a.shiftKey||a.metaKey)return;return this.open(),void p(a)}return a.which==M.DELETE||a.which==M.BACKSPACE?(this.opts.allowClear&&this.clear(),void p(a)):void 0}})),j(this.focusser),this.focusser.on("keyup-change input",this.bind(function(a){if(this.opts.minimumResultsForSearch>=0){if(a.stopPropagation(),this.opened())return;this.open()}})),b.on("mousedown touchstart","abbr",this.bind(function(a){this.isInterfaceEnabled()&&(this.clear(),q(a),this.close(),this.selection&&this.selection.focus())})),b.on("mousedown touchstart",this.bind(function(d){c(b),this.container.hasClass("select2-container-active")||this.opts.element.trigger(a.Event("select2-focus")),this.opened()?this.close():this.isInterfaceEnabled()&&this.open(),p(d)})),f.on("mousedown touchstart",this.bind(function(){this.opts.shouldFocusInput(this)&&this.search.focus()})),b.on("focus",this.bind(function(a){p(a)})),this.focusser.on("focus",this.bind(function(){this.container.hasClass("select2-container-active")||this.opts.element.trigger(a.Event("select2-focus")),this.container.addClass("select2-container-active")})).on("blur",this.bind(function(){this.opened()||(this.container.removeClass("select2-container-active"),this.opts.element.trigger(a.Event("select2-blur")))})),this.search.on("focus",this.bind(function(){this.container.hasClass("select2-container-active")||this.opts.element.trigger(a.Event("select2-focus")),this.container.addClass("select2-container-active")})),this.initContainerWidth(),this.opts.element.hide(),this.setPlaceholder()},clear:function(b){var c=this.selection.data("select2-data");if(c){var d=a.Event("select2-clearing");if(this.opts.element.trigger(d),d.isDefaultPrevented())return;var e=this.getPlaceholderOption();this.opts.element.val(e?e.val():""),this.selection.find(".select2-chosen").empty(),this.selection.removeData("select2-data"),this.setPlaceholder(),b!==!1&&(this.opts.element.trigger({type:"select2-removed",val:this.id(c),choice:c}),this.triggerChange({removed:c}))}},initSelection:function(){if(this.isPlaceholderOptionSelected())this.updateSelection(null),this.close(),this.setPlaceholder();else{var a=this;this.opts.initSelection.call(null,this.opts.element,function(c){c!==b&&null!==c&&(a.updateSelection(c),a.close(),a.setPlaceholder(),a.lastSearchTerm=a.search.val())})}},isPlaceholderOptionSelected:function(){var a;return this.getPlaceholder()===b?!1:(a=this.getPlaceholderOption())!==b&&a.prop("selected")||""===this.opts.element.val()||this.opts.element.val()===b||null===this.opts.element.val()},prepareOpts:function(){var b=this.parent.prepareOpts.apply(this,arguments),c=this;return"select"===b.element.get(0).tagName.toLowerCase()?b.initSelection=function(a,b){var d=a.find("option").filter(function(){return this.selected&&!this.disabled});b(c.optionToData(d))}:"data"in b&&(b.initSelection=b.initSelection||function(c,d){var e=c.val(),f=null;b.query({matcher:function(a,c,d){var h=g(e,b.id(d));return h&&(f=d),h},callback:a.isFunction(d)?function(){d(f)}:a.noop})}),b},getPlaceholder:function(){return this.select&&this.getPlaceholderOption()===b?b:this.parent.getPlaceholder.apply(this,arguments)},setPlaceholder:function(){var a=this.getPlaceholder();if(this.isPlaceholderOptionSelected()&&a!==b){if(this.select&&this.getPlaceholderOption()===b)return;this.selection.find(".select2-chosen").html(this.opts.escapeMarkup(a)),this.selection.addClass("select2-default"),this.container.removeClass("select2-allowclear")}},postprocessResults:function(a,b,c){var d=0,e=this;if(this.findHighlightableChoices().each2(function(a,b){return g(e.id(b.data("select2-data")),e.opts.element.val())?(d=a,!1):void 0}),c!==!1&&(b===!0&&d>=0?this.highlight(d):this.highlight(0)),b===!0){var f=this.opts.minimumResultsForSearch;f>=0&&this.showSearch(A(a.results)>=f)}},showSearch:function(b){this.showSearchInput!==b&&(this.showSearchInput=b,this.dropdown.find(".select2-search").toggleClass("select2-search-hidden",!b),this.dropdown.find(".select2-search").toggleClass("select2-offscreen",!b),a(this.dropdown,this.container).toggleClass("select2-with-searchbox",b))},onSelect:function(a,b){if(this.triggerSelect(a)){var c=this.opts.element.val(),d=this.data();this.opts.element.val(this.id(a)),this.updateSelection(a),this.opts.element.trigger({type:"select2-selected",val:this.id(a),choice:a}),this.lastSearchTerm=this.search.val(),this.close(),b&&b.noFocus||!this.opts.shouldFocusInput(this)||this.focusser.focus(),g(c,this.id(a))||this.triggerChange({added:a,removed:d})}},updateSelection:function(a){var c,d,e=this.selection.find(".select2-chosen");this.selection.data("select2-data",a),e.empty(),null!==a&&(c=this.opts.formatSelection(a,e,this.opts.escapeMarkup)),c!==b&&e.append(c),d=this.opts.formatSelectionCssClass(a,e),d!==b&&e.addClass(d),this.selection.removeClass("select2-default"),this.opts.allowClear&&this.getPlaceholder()!==b&&this.container.addClass("select2-allowclear")},val:function(){var a,c=!1,d=null,e=this,f=this.data();if(0===arguments.length)return this.opts.element.val();if(a=arguments[0],arguments.length>1&&(c=arguments[1],this.opts.debug&&console&&console.warn&&console.warn('Select2: The second option to `select2("val")` is not supported in Select2 4.0.0. The `change` event will always be triggered in 4.0.0.')),this.select)this.opts.debug&&console&&console.warn&&console.warn('Select2: Setting the value on a "," ","","
","
    ","
","
"].join(""));return b},prepareOpts:function(){var b=this.parent.prepareOpts.apply(this,arguments),c=this;return"select"===b.element.get(0).tagName.toLowerCase()?b.initSelection=function(a,b){var d=[];a.find("option").filter(function(){return this.selected&&!this.disabled}).each2(function(a,b){d.push(c.optionToData(b))}),b(d)}:"data"in b&&(b.initSelection=b.initSelection||function(c,d){var e=h(c.val(),b.separator,b.transformVal),f=[];b.query({matcher:function(c,d,h){var i=a.grep(e,function(a){return g(a,b.id(h))}).length;return i&&f.push(h),i},callback:a.isFunction(d)?function(){for(var a=[],c=0;c0||(this.selectChoice(null),this.clearPlaceholder(),this.container.hasClass("select2-container-active")||this.opts.element.trigger(a.Event("select2-focus")),this.open(),this.focusSearch(),b.preventDefault()))})),this.container.on("focus",c,this.bind(function(){this.isInterfaceEnabled()&&(this.container.hasClass("select2-container-active")||this.opts.element.trigger(a.Event("select2-focus")),this.container.addClass("select2-container-active"),this.dropdown.addClass("select2-drop-active"),this.clearPlaceholder())})),this.initContainerWidth(),this.opts.element.hide(),this.clearSearch()},enableInterface:function(){this.parent.enableInterface.apply(this,arguments)&&this.search.prop("disabled",!this.isInterfaceEnabled())},initSelection:function(){if(""===this.opts.element.val()&&""===this.opts.element.text()&&(this.updateSelection([]),this.close(),this.clearSearch()),this.select||""!==this.opts.element.val()){var a=this;this.opts.initSelection.call(null,this.opts.element,function(c){c!==b&&null!==c&&(a.updateSelection(c),a.close(),a.clearSearch())})}},clearSearch:function(){var a=this.getPlaceholder(),c=this.getMaxSearchWidth();a!==b&&0===this.getVal().length&&this.search.hasClass("select2-focused")===!1?(this.search.val(a).addClass("select2-default"),this.search.width(c>0?c:this.container.css("width"))):this.search.val("").width(10)},clearPlaceholder:function(){this.search.hasClass("select2-default")&&this.search.val("").removeClass("select2-default")},opening:function(){this.clearPlaceholder(),this.resizeSearch(),this.parent.opening.apply(this,arguments),this.focusSearch(),this.prefillNextSearchTerm(),this.updateResults(!0),this.opts.shouldFocusInput(this)&&this.search.focus(),this.opts.element.trigger(a.Event("select2-open"))},close:function(){this.opened()&&this.parent.close.apply(this,arguments)},focus:function(){this.close(),this.search.focus()},isFocused:function(){return this.search.hasClass("select2-focused")},updateSelection:function(b){var c={},d=[],e=this;a(b).each(function(){e.id(this)in c||(c[e.id(this)]=0,d.push(this))}),this.selection.find(".select2-search-choice").remove(),this.addSelectedChoice(d),e.postprocessResults()},tokenize:function(){var a=this.search.val();a=this.opts.tokenizer.call(this,a,this.data(),this.bind(this.onSelect),this.opts),null!=a&&a!=b&&(this.search.val(a),a.length>0&&this.open())},onSelect:function(a,b){this.triggerSelect(a)&&""!==a.text&&(this.addSelectedChoice(a),this.opts.element.trigger({type:"selected",val:this.id(a),choice:a}),this.lastSearchTerm=this.search.val(),this.clearSearch(),this.updateResults(),!this.select&&this.opts.closeOnSelect||this.postprocessResults(a,!1,this.opts.closeOnSelect===!0),this.opts.closeOnSelect?(this.close(),this.search.width(10)):this.countSelectableResults()>0?(this.search.width(10),this.resizeSearch(),this.getMaximumSelectionSize()>0&&this.val().length>=this.getMaximumSelectionSize()?this.updateResults(!0):this.prefillNextSearchTerm()&&this.updateResults(),this.positionDropdown()):(this.close(),this.search.width(10)),this.triggerChange({added:a}),b&&b.noFocus||this.focusSearch())},cancel:function(){this.close(),this.focusSearch()},addSelectedChoice:function(b){var c=this.getVal(),d=this;a(b).each(function(){c.push(d.createChoice(this))}),this.setVal(c)},createChoice:function(c){var d,e,f=!c.locked,g=a("
  • "),h=a("
  • "),i=f?g:h,j=this.id(c);return d=this.opts.formatSelection(c,i.find("div"),this.opts.escapeMarkup),d!=b&&i.find("div").replaceWith(a("
    ").html(d)),e=this.opts.formatSelectionCssClass(c,i.find("div")),e!=b&&i.addClass(e),f&&i.find(".select2-search-choice-close").on("mousedown",p).on("click dblclick",this.bind(function(b){this.isInterfaceEnabled()&&(this.unselect(a(b.target)),this.selection.find(".select2-search-choice-focus").removeClass("select2-search-choice-focus"),p(b),this.close(),this.focusSearch())})).on("focus",this.bind(function(){this.isInterfaceEnabled()&&(this.container.addClass("select2-container-active"),this.dropdown.addClass("select2-drop-active"))})),i.data("select2-data",c),i.insertBefore(this.searchContainer),j},unselect:function(b){var c,d,f=this.getVal();if(b=b.closest(".select2-search-choice"),0===b.length)throw"Invalid argument: "+b+". Must be .select2-search-choice";if(c=b.data("select2-data")){var g=a.Event("select2-removing");if(g.val=this.id(c),g.choice=c,this.opts.element.trigger(g),g.isDefaultPrevented())return!1;for(;(d=e(this.id(c),f))>=0;)f.splice(d,1),this.setVal(f),this.select&&this.postprocessResults();return b.remove(),this.opts.element.trigger({type:"select2-removed",val:this.id(c),choice:c}),this.triggerChange({removed:c}),!0}},postprocessResults:function(a,b,c){var d=this.getVal(),f=this.results.find(".select2-result"),g=this.results.find(".select2-result-with-children"),h=this;f.each2(function(a,b){var c=h.id(b.data("select2-data"));e(c,d)>=0&&(b.addClass("select2-selected"),b.find(".select2-result-selectable").addClass("select2-selected"))}),g.each2(function(a,b){b.is(".select2-result-selectable")||0!==b.find(".select2-result-selectable:not(.select2-selected)").length||b.addClass("select2-selected")}),-1==this.highlight()&&c!==!1&&this.opts.closeOnSelect===!0&&h.highlight(0),!this.opts.createSearchChoice&&!f.filter(".select2-result:not(.select2-selected)").length>0&&(!a||a&&!a.more&&0===this.results.find(".select2-no-results").length)&&y(h.opts.formatNoMatches,"formatNoMatches")&&this.results.append("
  • "+z(h.opts.formatNoMatches,h.opts.element,h.search.val())+"
  • ")},getMaxSearchWidth:function(){return this.selection.width()-i(this.search)},resizeSearch:function(){var a,b,c,d,e,f=i(this.search);a=r(this.search)+10,b=this.search.offset().left,c=this.selection.width(),d=this.selection.offset().left,e=c-(b-d)-f,a>e&&(e=c-f),40>e&&(e=c-f),0>=e&&(e=a),this.search.width(Math.floor(e))},getVal:function(){var a;return this.select?(a=this.select.val(),null===a?[]:a):(a=this.opts.element.val(),h(a,this.opts.separator,this.opts.transformVal))},setVal:function(b){if(this.select)this.select.val(b);else{var c=[],d={};a(b).each(function(){this in d||(c.push(this),d[this]=0)}),this.opts.element.val(0===c.length?"":c.join(this.opts.separator))}},buildChangeDetails:function(a,b){for(var b=b.slice(0),a=a.slice(0),c=0;c. Attach to instead.");this.search.width(0),this.searchContainer.hide()},onSortEnd:function(){var b=[],c=this;this.searchContainer.show(),this.searchContainer.appendTo(this.searchContainer.parent()),this.resizeSearch(),this.selection.find(".select2-search-choice").each(function(){b.push(c.opts.id(a(this).data("select2-data")))}),this.setVal(b),this.triggerChange()},data:function(b,c){var d,e,f=this;return 0===arguments.length?this.selection.children(".select2-search-choice").map(function(){return a(this).data("select2-data")}).get():(e=this.data(),b||(b=[]),d=a.map(b,function(a){return f.opts.id(a)}),this.setVal(d),this.updateSelection(b),this.clearSearch(),c&&this.triggerChange(this.buildChangeDetails(e,this.data())),void 0)}}),a.fn.select2=function(){var c,d,f,g,h,i=Array.prototype.slice.call(arguments,0),j=["val","destroy","opened","open","close","focus","isFocused","container","dropdown","onSortStart","onSortEnd","enable","disable","readonly","positionDropdown","data","search"],k=["opened","isFocused","container","dropdown"],l=["val","data"],m={search:"externalSearch"};return this.each(function(){if(0===i.length||"object"==typeof i[0])c=0===i.length?{}:a.extend({},i[0]),c.element=a(this),"select"===c.element.get(0).tagName.toLowerCase()?h=c.element.prop("multiple"):(h=c.multiple||!1,"tags"in c&&(c.multiple=h=!0)),d=h?new window.Select2["class"].multi:new window.Select2["class"].single,d.init(c);else{if("string"!=typeof i[0])throw"Invalid arguments to select2 plugin: "+i;if(e(i[0],j)<0)throw"Unknown method: "+i[0];if(g=b,d=a(this).data("select2"),d===b)return;if(f=i[0],"container"===f?g=d.container:"dropdown"===f?g=d.dropdown:(m[f]&&(f=m[f]),g=d[f].apply(d,i.slice(1))),e(i[0],k)>=0||e(i[0],l)>=0&&1==i.length)return!1}}),g===b?this:g},a.fn.select2.defaults={debug:!1,width:"copy",loadMorePadding:0,closeOnSelect:!0,openOnEnter:!0,containerCss:{},dropdownCss:{},containerCssClass:"",dropdownCssClass:"",formatResult:function(a,b,c,d){var e=[];return t(this.text(a),c.term,e,d),e.join("")},transformVal:function(b){return a.trim(b)},formatSelection:function(a,c,d){return a?d(this.text(a)):b},sortResults:function(a,b,c){return a},formatResultCssClass:function(a){return a.css},formatSelectionCssClass:function(a,c){return b},minimumResultsForSearch:0,minimumInputLength:0,maximumInputLength:null,maximumSelectionSize:0,id:function(a){return a==b?null:a.id},text:function(b){return b&&this.data&&this.data.text?a.isFunction(this.data.text)?this.data.text(b):b[this.data.text]:b.text},matcher:function(a,b){return d(""+b).toUpperCase().indexOf(d(""+a).toUpperCase())>=0},separator:",",tokenSeparators:[],tokenizer:B,escapeMarkup:u,blurOnChange:!1,selectOnBlur:!1,adaptContainerCssClass:function(a){return a},adaptDropdownCssClass:function(a){return null},nextSearchTerm:function(a,c){return b},searchInputPlaceholder:"",createSearchChoicePosition:"top",shouldFocusInput:function(a){var b="ontouchstart"in window||navigator.msMaxTouchPoints>0;return b?!(a.opts.minimumResultsForSearch<0):!0}},a.fn.select2.locales=[],a.fn.select2.locales.en={formatMatches:function(a){return 1===a?"One result is available, press enter to select it.":a+" results are available, use up and down arrow keys to navigate."},formatNoMatches:function(){return"No matches found"},formatAjaxError:function(a,b,c){return"Loading failed"},formatInputTooShort:function(a,b){var c=b-a.length;return"Please enter "+c+" or more character"+(1==c?"":"s")},formatInputTooLong:function(a,b){var c=a.length-b;return"Please delete "+c+" character"+(1==c?"":"s")},formatSelectionTooBig:function(a){return"You can only select "+a+" item"+(1==a?"":"s")},formatLoadMore:function(a){return"Loading more results…"},formatSearching:function(){return"Searching…"}},a.extend(a.fn.select2.defaults,a.fn.select2.locales.en),a.fn.select2.ajaxDefaults={transport:a.ajax,params:{type:"GET",cache:!1,dataType:"json"}},window.Select2={query:{ajax:v,local:w,tags:x},util:{debounce:l,markMatch:t,escapeMarkup:u,stripDiacritics:d},"class":{"abstract":E,single:F,multi:G}}}}(jQuery),function(){var a=window.MutationObserver||window.WebKitMutationObserver,b="ontouchstart"in window||window.DocumentTouch&&document instanceof DocumentTouch,c=void 0!==document.documentElement.style["touch-action"]||document.documentElement.style["-ms-touch-action"];if(!c&&b&&a){window.Hammer=window.Hammer||{};var d=/touch-action[:][\s]*(none)[^;'"]*/,e=/touch-action[:][\s]*(manipulation)[^;'"]*/,f=/touch-action/,g=/(iP(ad|hone|od))/.test(navigator.userAgent)&&("indexedDB"in window||!!window.performance);window.Hammer.time={getTouchAction:function(a){return this.checkStyleString(a.getAttribute("style"))},checkStyleString:function(a){return f.test(a)?d.test(a)?"none":e.test(a)?"manipulation":!0:void 0},shouldHammer:function(a){var b=a.target.hasParent;return b&&(!g||Date.now()-a.target.lastStart<125)?b:!1},touchHandler:function(a){var b=this.shouldHammer(a);if("none"===b)this.dropHammer(a);else if("manipulation"===b){var c=a.target.getBoundingClientRect(),d=c.top!==this.pos.top||c.left!==this.pos.left;!d&&this.dropHammer(a)}this.scrolled=!1,delete a.target.lastStart,delete a.target.hasParent},dropHammer:function(a){"touchend"===a.type&&(a.target.focus(),setTimeout(function(){a.target.click()},0)),a.preventDefault()},touchStart:function(a){this.pos=a.target.getBoundingClientRect(),a.target.hasParent=this.hasParent(a.target),g&&a.target.hasParent&&(a.target.lastStart=Date.now())},styleWatcher:function(a){a.forEach(this.styleUpdater,this)},styleUpdater:function(a){if(a.target.updateNext)return void(a.target.updateNext=!1);var b=this.getTouchAction(a.target);return b?void("none"!==b&&(a.target.hadTouchNone=!1)):void(!b&&(a.oldValue&&this.checkStyleString(a.oldValue)||a.target.hadTouchNone)&&(a.target.hadTouchNone=!0,a.target.updateNext=!1,a.target.setAttribute("style",a.target.getAttribute("style")+" touch-action: none;")))},hasParent:function(a){for(var b,c=a;c&&c.parentNode;c=c.parentNode)if(b=this.getTouchAction(c))return b;return!1},installStartEvents:function(){document.addEventListener("touchstart",this.touchStart.bind(this)),document.addEventListener("mousedown",this.touchStart.bind(this))},installEndEvents:function(){document.addEventListener("touchend",this.touchHandler.bind(this),!0),document.addEventListener("mouseup",this.touchHandler.bind(this),!0)},installObserver:function(){this.observer=new a(this.styleWatcher.bind(this)).observe(document,{subtree:!0,attributes:!0,attributeOldValue:!0,attributeFilter:["style"]})},install:function(){this.installEndEvents(),this.installStartEvents(),this.installObserver()}},window.Hammer.time.install()}}(),!function(a){var b="object"==typeof window&&window||"object"==typeof self&&self;"undefined"!=typeof exports?a(exports):b&&(b.hljs=a({}),"function"==typeof define&&define.amd&&define([],function(){return b.hljs}))}(function(a){function b(a){return a.replace(/&/gm,"&").replace(//gm,">")}function c(a){return a.nodeName.toLowerCase()}function d(a,b){var c=a&&a.exec(b);return c&&0==c.index}function e(a){return/^(no-?highlight|plain|text)$/i.test(a)}function f(a){var b,c,d,f=a.className+" ";if(f+=a.parentNode?a.parentNode.className:"",c=/\blang(?:uage)?-([\w-]+)\b/i.exec(f))return u(c[1])?c[1]:"no-highlight";for(f=f.split(/\s+/),b=0,d=f.length;d>b;b++)if(u(f[b])||e(f[b]))return f[b]}function g(a,b){var c,d={};for(c in a)d[c]=a[c];if(b)for(c in b)d[c]=b[c];return d}function h(a){var b=[];return function d(a,e){for(var f=a.firstChild;f;f=f.nextSibling)3==f.nodeType?e+=f.nodeValue.length:1==f.nodeType&&(b.push({event:"start",offset:e,node:f}),e=d(f,e),c(f).match(/br|hr|img|input/)||b.push({event:"stop",offset:e,node:f}));return e}(a,0),b}function i(a,d,e){function f(){return a.length&&d.length?a[0].offset!=d[0].offset?a[0].offset"}function h(a){k+=""}function i(a){("start"==a.event?g:h)(a.node)}for(var j=0,k="",l=[];a.length||d.length;){var m=f();if(k+=b(e.substr(j,m[0].offset-j)),j=m[0].offset,m==a){l.reverse().forEach(h);do i(m.splice(0,1)[0]),m=f();while(m==a&&m.length&&m[0].offset==j);l.reverse().forEach(g)}else"start"==m[0].event?l.push(m[0].node):l.pop(),i(m.splice(0,1)[0])}return k+b(e.substr(j))}function j(a){function b(a){return a&&a.source||a}function c(c,d){return new RegExp(b(c),"m"+(a.cI?"i":"")+(d?"g":""))}function d(e,f){if(!e.compiled){if(e.compiled=!0,e.k=e.k||e.bK,e.k){var h={},i=function(b,c){a.cI&&(c=c.toLowerCase()),c.split(" ").forEach(function(a){var c=a.split("|");h[c[0]]=[b,c[1]?Number(c[1]):1]})};"string"==typeof e.k?i("keyword",e.k):Object.keys(e.k).forEach(function(a){i(a,e.k[a])}),e.k=h}e.lR=c(e.l||/\b\w+\b/,!0),f&&(e.bK&&(e.b="\\b("+e.bK.split(" ").join("|")+")\\b"),e.b||(e.b=/\B|\b/),e.bR=c(e.b),e.e||e.eW||(e.e=/\B|\b/),e.e&&(e.eR=c(e.e)),e.tE=b(e.e)||"",e.eW&&f.tE&&(e.tE+=(e.e?"|":"")+f.tE)),e.i&&(e.iR=c(e.i)),void 0===e.r&&(e.r=1),e.c||(e.c=[]);var j=[];e.c.forEach(function(a){a.v?a.v.forEach(function(b){j.push(g(a,b))}):j.push("self"==a?e:a)}),e.c=j,e.c.forEach(function(a){d(a,e)}),e.starts&&d(e.starts,f);var k=e.c.map(function(a){return a.bK?"\\.?("+a.b+")\\.?":a.b}).concat([e.tE,e.i]).map(b).filter(Boolean);e.t=k.length?c(k.join("|"),!0):{exec:function(){return null}}}}d(a)}function k(a,c,e,f){function g(a,b){for(var c=0;c";return f+=a+'">',f+b+g}function o(){if(!y.k)return b(B);var a="",c=0;y.lR.lastIndex=0;for(var d=y.lR.exec(B);d;){a+=b(B.substr(c,d.index-c));var e=m(y,d);e?(C+=e[1],a+=n(e[0],b(d[0]))):a+=b(d[0]),c=y.lR.lastIndex,d=y.lR.exec(B)}return a+b(B.substr(c))}function p(){var a="string"==typeof y.sL;if(a&&!w[y.sL])return b(B);var c=a?k(y.sL,B,!0,z[y.sL]):l(B,y.sL.length?y.sL:void 0);return y.r>0&&(C+=c.r),a&&(z[y.sL]=c.top),n(c.language,c.value,!1,!0)}function q(){A+=void 0!==y.sL?p():o(),B=""}function r(a,b){A+=a.cN?n(a.cN,"",!0):"",y=Object.create(a,{parent:{value:y}})}function s(a,b){if(B+=a,void 0===b)return q(),0;var c=g(b,y);if(c)return c.skip?B+=b:(c.eB&&(B+=b),q(),c.rB||c.eB||(B=b)),r(c,b),c.rB?0:b.length;var d=h(y,b);if(d){var e=y;e.skip?B+=b:(e.rE||e.eE||(B+=b),q(),e.eE&&(B=b));do y.cN&&(A+=""),y.skip||(C+=y.r),y=y.parent;while(y!=d.parent);return d.starts&&r(d.starts,""),e.rE?0:b.length}if(i(b,y))throw new Error('Illegal lexeme "'+b+'" for mode "'+(y.cN||"")+'"');return B+=b,b.length||1}var t=u(a);if(!t)throw new Error('Unknown language: "'+a+'"');j(t);var x,y=f||t,z={},A="";for(x=y;x!=t;x=x.parent)x.cN&&(A=n(x.cN,"",!0)+A);var B="",C=0;try{for(var D,E,F=0;y.t.lastIndex=F,D=y.t.exec(c),D;)E=s(c.substr(F,D.index-F),D[0]),F=D.index+E;for(s(c.substr(F)),x=y;x.parent;x=x.parent)x.cN&&(A+="");return{r:C,value:A,language:a,top:y}}catch(G){if(-1!=G.message.indexOf("Illegal"))return{r:0,value:b(c)};throw G}}function l(a,c){c=c||v.languages||Object.keys(w);var d={r:0,value:b(a)},e=d;return c.forEach(function(b){if(u(b)){var c=k(b,a,!1);c.language=b,c.r>e.r&&(e=c),c.r>d.r&&(e=d,d=c)}}),e.language&&(d.second_best=e),d}function m(a){return v.tabReplace&&(a=a.replace(/^((<[^>]+>|\t)+)/gm,function(a,b){return b.replace(/\t/g,v.tabReplace)})),v.useBR&&(a=a.replace(/\n/g,"
    ")),a}function n(a,b,c){var d=b?x[b]:c,e=[a.trim()];return a.match(/\bhljs\b/)||e.push("hljs"),-1===a.indexOf(d)&&e.push(d),e.join(" ").trim()}function o(a){var b=f(a);if(!e(b)){var c;v.useBR?(c=document.createElementNS("http://www.w3.org/1999/xhtml","div"),c.innerHTML=a.innerHTML.replace(/\n/g,"").replace(//g,"\n")):c=a;var d=c.textContent,g=b?k(b,d,!0):l(d),j=h(c);if(j.length){var o=document.createElementNS("http://www.w3.org/1999/xhtml","div");o.innerHTML=g.value,g.value=i(j,h(o),d)}g.value=m(g.value),a.innerHTML=g.value,a.className=n(a.className,b,g.language),a.result={language:g.language,re:g.r},g.second_best&&(a.second_best={language:g.second_best.language,re:g.second_best.r})}}function p(a){v=g(v,a)}function q(){if(!q.called){q.called=!0;var a=document.querySelectorAll("pre code");Array.prototype.forEach.call(a,o)}}function r(){addEventListener("DOMContentLoaded",q,!1),addEventListener("load",q,!1)}function s(b,c){var d=w[b]=c(a);d.aliases&&d.aliases.forEach(function(a){x[a]=b})}function t(){return Object.keys(w)}function u(a){return a=(a||"").toLowerCase(),w[a]||w[x[a]]}var v={classPrefix:"hljs-",tabReplace:null,useBR:!1,languages:void 0},w={},x={};return a.highlight=k,a.highlightAuto=l,a.fixMarkup=m,a.highlightBlock=o,a.configure=p,a.initHighlighting=q,a.initHighlightingOnLoad=r,a.registerLanguage=s,a.listLanguages=t,a.getLanguage=u,a.inherit=g,a.IR="[a-zA-Z]\\w*",a.UIR="[a-zA-Z_]\\w*",a.NR="\\b\\d+(\\.\\d+)?",a.CNR="(-?)(\\b0[xX][a-fA-F0-9]+|(\\b\\d+(\\.\\d*)?|\\.\\d+)([eE][-+]?\\d+)?)",a.BNR="\\b(0b[01]+)",a.RSR="!|!=|!==|%|%=|&|&&|&=|\\*|\\*=|\\+|\\+=|,|-|-=|/=|/|:|;|<<|<<=|<=|<|===|==|=|>>>=|>>=|>=|>>>|>>|>|\\?|\\[|\\{|\\(|\\^|\\^=|\\||\\|=|\\|\\||~",a.BE={b:"\\\\[\\s\\S]",r:0},a.ASM={cN:"string",b:"'",e:"'",i:"\\n",c:[a.BE]},a.QSM={cN:"string",b:'"',e:'"',i:"\\n",c:[a.BE]},a.PWM={b:/\b(a|an|the|are|I|I'm|isn't|don't|doesn't|won't|but|just|should|pretty|simply|enough|gonna|going|wtf|so|such|will|you|your|like)\b/},a.C=function(b,c,d){var e=a.inherit({cN:"comment",b:b,e:c,c:[]},d||{});return e.c.push(a.PWM),e.c.push({cN:"doctag",b:"(?:TODO|FIXME|NOTE|BUG|XXX):",r:0}),e},a.CLCM=a.C("//","$"),a.CBCM=a.C("/\\*","\\*/"),a.HCM=a.C("#","$"),a.NM={cN:"number",b:a.NR,r:0},a.CNM={cN:"number",b:a.CNR,r:0},a.BNM={cN:"number",b:a.BNR,r:0},a.CSSNM={cN:"number",b:a.NR+"(%|em|ex|ch|rem|vw|vh|vmin|vmax|cm|mm|in|pt|pc|px|deg|grad|rad|turn|s|ms|Hz|kHz|dpi|dpcm|dppx)?",r:0},a.RM={cN:"regexp",b:/\//,e:/\/[gimuy]*/,i:/\n/,c:[a.BE,{b:/\[/,e:/\]/,r:0,c:[a.BE]}]},a.TM={cN:"title",b:a.IR,r:0},a.UTM={cN:"title",b:a.UIR,r:0},a.METHOD_GUARD={b:"\\.\\s*"+a.UIR,r:0},a}),hljs.registerLanguage("json",function(a){var b={literal:"true false null"},c=[a.QSM,a.CNM],d={e:",",eW:!0,eE:!0,c:c,k:b},e={b:"{",e:"}",c:[{cN:"attr",b:/"/,e:/"/,c:[a.BE],i:"\\n"},a.inherit(d,{b:/:/})],i:"\\S"},f={b:"\\[",e:"\\]",c:[a.inherit(d)],i:"\\S"};return c.splice(c.length,0,e,f),{c:c,k:b,i:"\\S"}}),hljs.registerLanguage("css",function(a){var b="[a-zA-Z-][a-zA-Z0-9_-]*",c={b:/[A-Z\_\.\-]+\s*:/,rB:!0,e:";",eW:!0,c:[{cN:"attribute",b:/\S/,e:":",eE:!0,starts:{eW:!0,eE:!0,c:[{b:/[\w-]+\(/,rB:!0,c:[{cN:"built_in",b:/[\w-]+/},{b:/\(/,e:/\)/,c:[a.ASM,a.QSM]}]},a.CSSNM,a.QSM,a.ASM,a.CBCM,{cN:"number",b:"#[0-9A-Fa-f]+"},{cN:"meta",b:"!important"}]}}]};return{cI:!0,i:/[=\/|'\$]/,c:[a.CBCM,{cN:"selector-id",b:/#[A-Za-z0-9_-]+/},{cN:"selector-class",b:/\.[A-Za-z0-9_-]+/},{cN:"selector-attr",b:/\[/,e:/\]/,i:"$"},{cN:"selector-pseudo",b:/:(:)?[a-zA-Z0-9\_\-\+\(\)"'.]+/},{b:"@(font-face|page)",l:"[a-z-]+",k:"font-face page"},{b:"@",e:"[{;]",c:[{cN:"keyword",b:/\S+/},{b:/\s/,eW:!0,eE:!0,r:0,c:[a.ASM,a.QSM,a.CSSNM]}]},{cN:"selector-tag",b:b,r:0},{b:"{",e:"}",i:/\S/,c:[a.CBCM,c]}]}}),hljs.registerLanguage("xml",function(a){var b="[A-Za-z0-9\\._:-]+",c={eW:!0,i:/]+/}]}]}]};return{aliases:["html","xhtml","rss","atom","xsl","plist"],cI:!0,c:[{cN:"meta",b:"",r:10,c:[{b:"\\[",e:"\\]"}]},a.C("",{r:10}),{b:"<\\!\\[CDATA\\[",e:"\\]\\]>",r:10},{b:/<\?(php)?/,e:/\?>/,sL:"php",c:[{b:"/\\*",e:"\\*/",skip:!0}]},{cN:"tag",b:"|$)",e:">",k:{name:"style"},c:[c],starts:{e:"",rE:!0,sL:["css","xml"]}},{cN:"tag",b:"|$)",e:">",k:{name:"script"},c:[c],starts:{e:"",rE:!0,sL:["actionscript","javascript","handlebars","xml"]}},{cN:"meta",v:[{b:/<\?xml/,e:/\?>/,r:10},{b:/<\?\w+/,e:/\?>/}]},{cN:"tag",b:"",c:[{cN:"name",b:/[^\/><\s]+/,r:0},c]}]}}),hljs.registerLanguage("r",function(a){var b="([a-zA-Z]|\\.[a-zA-Z.])[a-zA-Z0-9._]*";return{c:[a.HCM,{b:b,l:b,k:{keyword:"function if in break next repeat else for return switch while try tryCatch stop warning require library attach detach source setMethod setGeneric setGroupGeneric setClass ...",literal:"NULL NA TRUE FALSE T F Inf NaN NA_integer_|10 NA_real_|10 NA_character_|10 NA_complex_|10"},r:0},{cN:"number",b:"0[xX][0-9a-fA-F]+[Li]?\\b",r:0},{cN:"number",b:"\\d+(?:[eE][+\\-]?\\d*)?L\\b",r:0},{cN:"number",b:"\\d+\\.(?!\\d)(?:i\\b)?",r:0},{cN:"number",b:"\\d+(?:\\.\\d*)?(?:[eE][+\\-]?\\d*)?i?\\b",r:0},{cN:"number",b:"\\.\\d+(?:[eE][+\\-]?\\d*)?i?\\b",r:0},{b:"`",e:"`",r:0},{cN:"string",c:[a.BE],v:[{b:'"',e:'"'},{b:"'",e:"'"}]}]}}),hljs.registerLanguage("markdown",function(a){return{aliases:["md","mkdown","mkd"],c:[{cN:"section",v:[{b:"^#{1,6}",e:"$"},{b:"^.+?\\n[=-]{2,}$"}]},{b:"<",e:">",sL:"xml",r:0},{cN:"bullet",b:"^([*+-]|(\\d+\\.))\\s+"},{cN:"strong",b:"[*_]{2}.+?[*_]{2}"},{cN:"emphasis",v:[{b:"\\*.+?\\*"},{b:"_.+?_",r:0}]},{cN:"quote",b:"^>\\s+",e:"$"},{cN:"code",v:[{b:"`.+?`"},{b:"^( {4}| )",e:"$",r:0}]},{b:"^[-\\*]{3,}",e:"$"},{b:"\\[.+?\\][\\(\\[].*?[\\)\\]]",rB:!0,c:[{cN:"string",b:"\\[",e:"\\]",eB:!0,rE:!0,r:0},{cN:"link",b:"\\]\\(",e:"\\)",eB:!0,eE:!0},{cN:"symbol",b:"\\]\\[",e:"\\]",eB:!0,eE:!0}],r:10},{b:"^\\[.+\\]:",rB:!0,c:[{cN:"symbol",b:"\\[",e:"\\]:",eB:!0,eE:!0,starts:{cN:"link",e:"$"}}]}]}}),window.performance=window.performance||{},performance.now=function(){return performance.now||performance.mozNow||performance.msNow||performance.oNow||performance.webkitNow}(),window.gccConfig={content:{message:"On our website we're using cookies to optimize user experience and to improve our website. By using our website you agree that cookies can be stored on your local computer."},palette:{popup:{background:"#333333",text:"#fff",link:"#fff"},button:{background:"#8dc63f",text:"#fff"}}},function(a){"use strict";!function(a){a.fn.stickyStuff=function(){var b=this,c=function(){var c=window.location.hash,d=c?'a[href="'+c+'"]':"li.active > a";if("tab"===a(d,b).data("toggle"))a(d,b).tab("show");else if("collapse"===a(d,b).data("toggle")){var e=c;a(e,b).collapse("show");var f=a(e,b).parents(".tab-pane");f&&!f.hasClass("active")&&a("a[href=#"+f.attr("id")+"]").tab("show")}};return c(b),a(window).on("hashchange",function(){c(b)}),a("a",b).on("click",function(a){history.pushState(null,null,this.href),c(b)}),this}}(jQuery),a(function(){if(1==a(".schmail").length){var b=a(".schmail").attr("href");b=b.replace("IMNOTSENDINGSPAMTO","").replace("that-big-googly-eyed-email-provider","gmail").replace(encodeURIComponent("If you are not a robot, I have high hopes that you can figure out how to get my proper email address from the above."),"").replace(encodeURIComponent("\r\n\r\n"),""),a(".schmail").attr("href",b)}if(a("*[title]").tooltip({container:"body"}),hljs.initHighlighting(),a(".nav-tabs, .tab-content").stickyStuff(),a(".navbar-toggle").attr("style","-ms-touch-action: manipulation; touch-action: manipulation;"),a("ul.menu-highlight a").each(function(){var b=a(this),c=b.attr("href");c===document.location.href&&b.parents("li").addClass("active"); }),a(".social-share-icon").unbind("click").bind("click",function(){var b=a(this),c=b.attr("data-href");c&&(b.attr("data-target")?window.open(c,b.attr("data-target"),b.attr("data-width")?"width="+b.attr("data-width")+",height="+b.attr("data-height"):void 0):window.location.href=c)}),a(".copy_clipboard").click(function(){this.select();try{var b=document.execCommand("copy");b&&a(this).tooltip({title:"Link was copied to clipboard.",position:"top"}).tooltip("show")}catch(c){}}),a(".copy-url").click(function(){try{var b=a(this).data("url"),c=document.createElement("input");document.body.appendChild(c),c.value=b,c.select(),document.execCommand("copy"),document.body.removeChild(c),bootstrap_modal("URL Copied",b)}catch(d){}}),a(".monkey-bar-modal").length&&a(".monkey-bar-modal").appendTo("body"),!cookies_enabled()){var c="The use of cookies seems to have been disabled in your browser. ";c+="In order to be able to use formr and have a good user experience, you will need to enable cookies.",bootstrap_modal("Cookies Disabled",c)}})}(jQuery),function(a){"use strict";function b(b,c){a(c).click(function(b){b.preventDefault();var c=a(this),d=c.attr("href");return""===d?!1:(c.attr("href",""),a.ajax({type:"GET",url:d,dataType:"html"}).done(a.proxy(function(b){var c=a(this);c.attr("href",d),c.hasClass("danger")||c.css("color","green");var e=c.find("i.fa");e.hasClass("fa-stethoscope")?(e.addClass("fa-heartbeat"),e.removeClass("fa-stethoscope")):e.hasClass("fa-heartbeat")?(e.removeClass("fa-heartbeat"),e.addClass("fa-stethoscope")):bootstrap_modal("Alert",b,"tpl-feedback-modal"),c.hasClass("refresh_on_success")&&document.location.reload(!0)},this)).fail(a.proxy(function(b,c,e,f){a(this).attr("href",d),ajaxErrorHandling(b,c,e,f)},this)),!1)})}function c(b,c){a(c).submit(function(b){b.preventDefault();var c=a(this),d=c.find("button[type=submit].btn");return d.attr("disabled",!0),a.ajax({type:c.attr("method"),url:c.attr("action"),data:c.serialize(),dataType:"html"}).done(a.proxy(function(b){d.attr("disabled",!1),d.css("color","green"),a(".alerts-container").prepend(b),d.hasClass("refresh_on_success")&&document.location.reload(!0)},this)).fail(a.proxy(function(a,b,c,e){d.attr("disabled",!1),ajaxErrorHandling(a,b,c,e)},this)),!1})}function d(b){var c=parseInt(a(this).data("user"),10),d=a(this).data("email");if(c&&d){var f={user_id:c,user_email:d,user_api:!0,api_action:"get"};h(saAjaxUrl,f,function(a){a&&a.success&&e(a.data,f)})}}function e(b,c){var d=a(a.parseHTML(getHTMLTemplate("tpl-user-api",{user:" ("+b.user+")",client_id:b.client_id,client_secret:b.client_secret})));b.client_id?d.find(".api-create").remove():d.find(".api-change, .api-delete").remove(),d.on("shown.bs.modal",function(){d.find(".api-create").click(function(){if(confirm("Are you sure?")){var a={user_id:c.user_id,user_email:c.user_email,user_api:!0,api_action:"create"};h(saAjaxUrl,a,function(a){a&&a.success&&(d.modal("hide"),e(a.data,c))})}}),d.find(".api-change").click(function(){if(confirm("Are you sure?")){var a={user_id:c.user_id,user_email:c.user_email,user_api:!0,api_action:"change"};h(saAjaxUrl,a,function(a){a&&a.success&&(d.modal("hide"),e(a.data,c))})}}),d.find(".api-delete").click(function(){if(confirm("Are you sure?")){var a={user_id:c.user_id,user_email:c.user_email,user_api:!0,api_action:"delete"};h(saAjaxUrl,a,function(a){a&&a.success&&(d.modal("hide"),e({user:b.user,client_id:"",client_secret:""},c))})}})}).on("hidden.bs.modal",function(){d.remove()}).modal("show")}function f(b){var d=a(this),e=a(a.parseHTML(getHTMLTemplate("tpl-delete-run-session",{action:d.data("href"),session:d.data("session")}))),f=d.parents("tr");d.css("border-color","#ee5f5b"),d.css("color","#ee5f5b"),e.find("form").each(c).submit(function(){f.css("background-color","#ee5f5b"),e.modal("hide")}),e.on("hidden.bs.modal",function(){e.remove(),d.css("border-color","black"),d.css("color","black")}).modal("show")}function g(b){var c=a(this),d=a(a.parseHTML(getHTMLTemplate("tpl-remind-run-session",{action:c.data("href"),session:c.data("session")})));c.parents("tr");d.on("shown.bs.modal",function(){d.find(".send").click(function(){var b=c.data("href"),e=a(this).data("reminder");a(this).append(bootstrap_spinner()),h(b,{reminder:e},function(a){d.modal("hide"),bootstrap_modal("Send Reminder",a,"tpl-feedback-modal").modal("show"),c.css("border-color","green"),c.css("color","green")},"html")})}),d.on("hidden.bs.modal",function(){d.remove()}),a.get(c.data("href"),{session:c.data("session"),get_count:!0},function(a,b,c){d.find(".reminder-row-count").text("(0)");for(var e in a){var f=a[e];d.find(".reminder-row-count-"+e).text(" ("+f+")")}d.modal("show")})}function h(b,c,d,e,f){e=e||"json",f=f||function(){},a.ajax({type:"POST",url:b,data:c,dataType:e,success:function(a,b,c){d(a)},error:function(b,c){a(".alerts-container").prepend(c),f(b,c)},beforeSend:function(a){}})}function i(){var b=a(this);"single"===b.data("active")?(b.siblings(".single").addClass("hidden"),b.siblings(".multiple").removeClass("hidden"),b.data("active","multiple")):(b.siblings(".single").removeClass("hidden"),b.siblings(".multiple").addClass("hidden"),b.data("active","single"))}function j(b){var c=a(this),d=[];a("input.ba-select-session").each(function(){a(this).is(":checked")&&d.push(a(this).val())}),d.length&&"function"==typeof k[c.data("action")]&&k[c.data("action")](c.parents("form").attr("action"),d)}var k={toggleTest:function(b,c){var d=a(a.parseHTML(getHTMLTemplate("tpl-confirmation",{content:"

    Are you sure you want to perform this action?

    "})));d.on("shown.bs.modal",function(){d.find(".btn-yes").click(function(e){a(this).append(bootstrap_spinner()),h(b,{action:"toggleTest",sessions:c},function(c){return d.modal("hide"),c.success?void(document.location=b.replace("ajax_user_bulk_actions","user_overview")):(a(this).find(".fa-spin").remove(),void bootstrap_modal("Error",c.error,"tpl-feedback-modal").modal("show"))},"json")}),d.find(".btn-no").click(function(a){d.modal("hide")})}).on("hidden.bs.modal",function(){d.remove()}).modal("show")},sendReminder:function(b,c){var d=a(a.parseHTML(getHTMLTemplate("tpl-remind-run-session",{action:b,session:null})));d.on("shown.bs.modal",function(){d.find(".send").click(function(){var e=a(this).data("reminder");a(this).append(bootstrap_spinner()),h(b,{action:"sendReminder",sessions:c,reminder:e},function(a){return d.modal("hide"),a.success?void(document.location=b.replace("ajax_user_bulk_actions","user_overview")):void bootstrap_modal("Error",a.error,"tpl-feedback-modal").modal("show")},"json")})}).on("hidden.bs.modal",function(){d.remove()}).modal("show")},deleteSessions:function(b,c){var d=a(a.parseHTML(getHTMLTemplate("tpl-confirmation",{content:"

    Are you sure you want delete "+c.length+" session(s)?

    "})));d.on("shown.bs.modal",function(){d.find(".btn-yes").click(function(e){a(this).append(bootstrap_spinner()),h(b,{action:"deleteSessions",sessions:c},function(c){return d.modal("hide"),c.success?void(document.location=b.replace("ajax_user_bulk_actions","user_overview")):(a(this).find(".fa-spin").remove(),void bootstrap_modal("Error",c.error,"tpl-feedback-modal").modal("show"))},"json")}),d.find(".btn-no").click(function(a){d.modal("hide")})}).on("hidden.bs.modal",function(){d.remove()}).modal("show")},positionSessions:function(b,c){var d=parseInt(a("select[name=ba_new_position]").val());if(isNaN(d))return void alert("Bad position selected");var e=a(a.parseHTML(getHTMLTemplate("tpl-confirmation",{content:"

    Are you sure you want push "+c.length+" session(s) to position "+d+"?

    "})));e.on("shown.bs.modal",function(){e.find(".btn-yes").click(function(f){a(this).append(bootstrap_spinner()),h(b,{action:"positionSessions",sessions:c,pos:d},function(c){return e.modal("hide"),c.success?void(document.location=b.replace("ajax_user_bulk_actions","user_overview")):(a(this).find(".fa-spin").remove(),void bootstrap_modal("Error",c.error,"tpl-feedback-modal").modal("show"))},"json")}),e.find(".btn-no").click(function(a){e.modal("hide")})}).on("hidden.bs.modal",function(){e.remove()}).modal("show")}};a(function(){var e;a(".form-ajax").each(c),a(".link-ajax").each(b),a(".link-ajax .fa-pause").parent(".btn").mouseenter(function(){a(this).find(".fa").removeClass("fa-pause").addClass("fa-play")}).mouseleave(function(){a(this).find(".fa").addClass("fa-pause").removeClass("fa-play")}),a(".link-ajax .fa-stop").parent(".btn").mouseenter(function(){a(this).find(".fa").removeClass("fa-stop").addClass("fa-play")}).mouseleave(function(){a(this).find(".fa").addClass("fa-stop").removeClass("fa-play")}),a(".api-btn").click(d),a(".sessions-search-switch").click(i),a(".hidden_debug_message").length>0&&(a(".show_hidden_debugging_messages").click(function(){return a(".hidden_debug_message").toggleClass("hidden"),!1}),a(".show_hidden_debugging_messages").attr("disabled",!1)),a("abbr.abbreviated_session").click(function(){a(this).text()!==a(this).data("full-session")?a(this).text(a(this).data("full-session")):a(this).text(a(this).data("full-session").substr(0,10)+"…")}),a(".download_r_code").length>0&&a(".download_r_code").click(function(){return download_next_textarea(this)}),a(".removal_modal").on("show.bs.modal",function(c){e=a(c.relatedTarget);var d=a(this);e.parents("tr").css("background-color","#ee5f5b"),a(this).find(".danger").attr("href",e.data("href")),b(1,a(this).find(".danger")),a(this).find(".danger").click(function(a){e.css("color","#ee5f5b"),d.hasClass("refresh_on_success")&&window.setTimeout(function(){document.location.reload(!0)},200),d.modal("hide")})}).on("hide.bs.modal",function(a){e.parents("tr").css("background-color","transparent")}),a("a.delete-run-session").bind("click",f),a("a.remind-run-session").bind("click",g),a("div.bulk-actions-ba").find(".ba").bind("click",j)})}(jQuery),function(a){"use strict";function b(b){this.run=b,this.block=a('
    '),b.form.find(".run_units").append(this.block)}function c(c){"undefined"==typeof this.autosaved&&(this.lastSave=a.now(),this.autosaved=!1),this.form=c,this.form.submit(function(){return!1}),this.name=this.form.find(".run_name").val(),this.url=this.form.prop("action"),this.units=[];for(var d=a.parseJSON(this.form.attr("data-units")),e=0;e0&&!c.select2("container").hasClass("select2-container")){var d,e=c.attr("data-select2init");d="object"!=typeof e?a.parseJSON(e):e,c.select2({createSearchChoice:function(b,c){return 0===a(c).filter(function(){return 0===this.text.localeCompare(b)}).length?{id:b,text:b}:void 0},initSelection:function(b,c){var e;e={id:b.val(),text:b.val()},a.each(d,function(a,c){return c.id===b.val()?(e=c,!1):void 0}),c(e)},data:d})}this.unsavedChanges=!1,this.save_button=this.block.find("a.unit_save"),this.block.find("button.from_days").click(function(b){b.preventDefault();var c=a(this).closest(".input-group").find("input[type=number]"),d=c.val();c.val(60*d*24).change()}),this.test_button=this.block.find("a.unit_test"),this.test_button.click(a.proxy(this.test,this)),this.remove_button=this.block.find("button.remove_unit_from_run"),this.remove_button.click(a.proxy(this.removeFromRun,this)).mouseenter(function(){a(this).addClass("btn-danger")}).mouseleave(function(){a(this).removeClass("btn-danger")});var f=this.block.find("textarea");f[0]&&(this.textarea=a(f[0]),this.session=this.hookAceToTextarea(this.textarea)),f[1]&&(this.textarea2=a(f[1]),this.session2=this.hookAceToTextarea(this.textarea2)),this.run.lock(this.run.lock_toggle.hasClass("btn-checked"),this.block),this.save_button.attr("disabled",!0).removeClass("btn-info").text("Saved").click(a.proxy(this.save,this))},b.prototype.position_changes=function(a){this.position_changed||(this.position_changed=!0,this.run.reorder_button.addClass("btn-info").removeAttr("disabled")),this.position.parent().addClass("pos_changed")},b.prototype.changes=function(a){this.unsavedChanges||(this.unsavedChanges=!0,this.save_button.addClass("btn-info").removeAttr("disabled").text("Save changes"),this.test_button.attr("disabled","disabled"))},b.prototype.test=function(b){b.preventDefault();var c=this.test_button.text();this.test_button.attr("disabled",!0).html(c+bootstrap_spinner());this.block;return a.ajax({url:this.run.url+"/"+this.test_button.attr("href"),dataType:"html",data:{run_unit_id:this.run_unit_id,special:this.special},method:"GET"}).done(a.proxy(function(b){var d=bootstrap_modal("Test Results",b);a(".opencpu_accordion",d).collapse({toggle:!0}),this.test_button.html(c).removeAttr("disabled");var e=d.find("pre code");Array.prototype.forEach.call(e,hljs.highlightBlock),d.find(".download_r_code").length>0&&d.find(".download_r_code").click(function(){return download_next_textarea(this)})},this)).fail(a.proxy(function(a,b,d,e){this.test_button.attr("disabled",!1).html(c),ajaxErrorHandling(a,b,d,e)},this)),!1},b.prototype.save=function(b){b.preventDefault();var c=this.save_button.text();this.save_button.attr("disabled","disabled").html(c+bootstrap_spinner()),this.session&&this.textarea.val(this.session.getValue()),this.session2&&this.textarea2.val(this.session2.getValue());this.block;return a.ajax({url:this.run.url+"/"+this.save_button.attr("href"),dataType:"html",data:this.save_inputs.serialize(),method:"POST"}).done(a.proxy(function(b){""!==b?a.proxy(this.init(b),this):(this.save_button.attr("disabled",!0).removeClass("btn-info").text("Saved").click(a.proxy(this.save,this)),this.unsavedChanges=!1,this.test_button.removeAttr("disabled"))},this)).fail(a.proxy(function(a,b,d,e){this.save_button.removeAttr("disabled").html(c),ajaxErrorHandling(a,b,d,e)},this)),!1},b.prototype.hookAceToTextarea=function(b){var c=b.data("editor"),d=a("
    ",{position:"absolute",width:b.width(),height:b.height(),"class":b.attr("class")}).insertBefore(b);b.css("display","none"),this.editor=ace.edit(d[0]),this.editor.setOptions({minLines:b.attr("rows")?b.attr("rows"):3,maxLines:30}),this.editor.setTheme("ace/theme/textmate"),this.editor.$blockScrolling=1/0;var e=this.editor.getSession();return e.setValue(b.val()),this.editor.renderer.setShowGutter(!1),e.setUseWrapMode(!0),e.setWrapLimitRange(42,42),e.setMode("ace/mode/"+c),this.editor.on("change",a.proxy(this.changes,this)),e},b.prototype.removeFromRun=function(b,c){b.preventDefault(),a(".tooltip").hide();var d,e=this,f=b,g=this.block,h=this.run.url+"/"+this.remove_button.attr("href"),i={run_unit_id:this.run_unit_id};return"yes"===c&&(i.confirm="yes"),g.hide(),a.ajax({url:h,dataType:"html",data:i,method:"POST"}).done(a.proxy(function(b){if(g.show(),b)if("warn"===b)d=a(a.parseHTML(getHTMLTemplate("tpl-confirmation",{content:"Are you sure you want to delete this run unit and all it's data?"}))),d.on("shown.bs.modal",function(){d.find(".btn-yes").click(function(a){e.removeFromRun(f,"yes"),d.modal("hide")}),d.find(".btn-no").click(function(a){d.modal("hide"),e.removeFromRun(f,"no")})}).on("hidden.bs.modal",function(){d.remove()}).modal("show");else{g.html(b),g.show();var c=this.run.units.indexOf(this);c>-1&&this.run.units.splice(c,1)}},this)).fail(function(a,b,c,d){g.show(),ajaxErrorHandling(a,b,c,d)}),!1},b.prototype.serialize=function(){var a=this.save_inputs.serializeArray(),b={};b.type=this.block.find(".run_unit_inner").data("type");for(var c=0;cb&&(b=d)}),null===b&&(b=0),b},c.prototype.loadUnit=function(b,c){a.ajax({url:this.url+"/ajax_get_unit",data:b,dataType:"html",success:a.proxy(function(a,b){c.init(a)},this)})},c.prototype.addUnit=function(c){var d=this.getMaxPosition(),e=new b(this);this.units.push(e),a.ajax({url:c,dataType:"html",method:"POST",data:{position:d+10}}).done(a.proxy(function(a){e.init(a)},this)).fail(ajaxErrorHandling)},c.prototype.exportUnits=function(){var b={},c=this.url,d=!1,e=a("
    "),f=this.lock_toggle.hasClass("btn-checked");f&&this.lock(!1,this.form);for(var g=0;g-1?(bootstrap_alert("You used the position "+c+" more than once, therefore the new order could not be saved. Click here to scroll to the duplicated position.","Error.",".run_units"),f=!0):(d[g.run_unit_id]=c,e.push(c))}),!f)return a.ajax({url:this.reorder_button.attr("href"),dataType:"html",method:"POST",data:{position:d}}).done(a.proxy(function(b){a(this.units).each(function(a,b){b.position_changed=!1}),this.reorder_button.removeClass("btn-info").attr("disabled","disabled");var c=e.join(","),d=e.sort(function(a,b){return a-b}).join(",");if(this.form.find(".pos_changed").removeClass("pos_changed"),c!=d){var f=this.form;a(this.units.sort(function(a,b){return+a.position.val()-+b.position.val()})).each(function(a,b){f.find(".run_units").append(b.block)})}},this)).fail(ajaxErrorHandling),!1}},c.prototype.lock=function(b,c){c.find(".import_run_units, .run_unit_description, .position, .remove_unit_from_run, .reorder_units, .unit_save, .form-control, select, .from_days, .add_run_unit").each(function(c,d){b?(d.onclick&&(d.onclick_disabled=d.onclick,d.onclick=function(a){return a.preventDefault(),!1}),a(d).attr("data-old_disabled",a(d).attr("disabled")),a(d).attr("disabled","disabled")):(d.onclick_disabled&&(d.onclick=d.onclick_disabled),a(d).attr("data-old-disabled")&&""!==a(d).attr("data-old-disabled")?a(d).attr("disabled",a(d).attr("data-old-disabled")):a(d).removeAttr("disabled"))})},c.prototype.publicToggle=function(b){var c=a(this);return c.parents(".btn-group").find(".btn-checked").removeClass("btn-checked"),c.toggleClass("btn-checked",1),a.ajax({url:c.attr("href"),dataType:"html",method:"POST"}).fail(ajaxErrorHandling),!1},c.prototype.panic=function(b){var c={content:"

    Don't panic!

    Are things not going your way? Users end up in the wrong places, too many emails being sent?

    This run will be made private, locked and cron tasks (automatic email and text messages) will be disabled. You will need to manually undo these actions later.

    This will essentially buy you some time to fix the bug or get help. By configuring the service message under settings, you can show your users an explanation.

    ",yes_url:this.url+"/panic",no_url:"javascript:void(0);"},d=a(a.parseHTML(getHTMLTemplate("tpl-confirmation",c))).attr("id","run-panic-dialog");d.on("shown.bs.modal",function(){d.find(".btn-yes").click(function(b){document.location=a(this).data("yes")})}).on("hidden.bs.modal",function(){d.remove()}).modal("show")},a(function(){a(".edit_run").each(function(b,d){new c(a(d))})})}(jQuery),function($){function ButtonGroup(a){this.$item=$(a),this.$button_group=this.$item.find(".btn-group"),this.$item.hasClass("btn-checkbox")?this.kind="checkbox":this.$item.hasClass("btn-check")?this.kind="check":this.kind="radio",this.$buttons=this.$button_group.find(".btn"),this.$inputs=this.$item.find("input[id]");var b=this;this.$buttons.off("click").each(function(){var a=$(this),c=b.$inputs.filter("#"+a.attr("data-for")),d=!!c.prop("checked");a.toggleClass("btn-checked",d),webshim.ready("dom-extend",function(){webshim.addShadowDom(c,b.$button_group)}),a.attr("style","-ms-touch-action: manipulation; touch-action: manipulation;"),a.click(function(){return b.button_click(b,a,c)})})}function Survey(){this.$form=$("form"),this.$progressbar=$(".progress .progress-bar"),this.already_answered=this.$progressbar.data("already-answered"),this.items_left=this.$progressbar.data("items-left"),this.items_on_page=this.$progressbar.data("items-on-page"),$(".default_formr_button")[0]||this.items_on_page--,this.hidden_but_rendered=this.$progressbar.data("hidden-but-rendered"),this.percentage_minimum=this.$progressbar.data("percentage-minimum"),this.percentage_maximum=this.$progressbar.data("percentage-maximum"),this.form_inputs={},this.last_update=!1,this.next_update=!1,this.dont_update=!1,this.spinner=' ',this.counterBtns=$('
    ');var a=this;$("button.submit_automatically_after_timeout").each(function(a,b){$('
    ').appendTo(b),$(window).on("load",function(){var a=$(b).data("timeout");$(".white_cover").remove(),window.setTimeout(function(){$(b).click()},a),$(".submit_fuse").animate({width:0},a)})}),webshim.ready("DOM geolocation",function(){"use strict";$(".geolocator").click(function(){var a=$(this).closest(".controls").find("input[type=hidden]"),b=$(this).closest(".controls").find("input[type=text]");return b.attr("placeholder","You can also enter your location manually"),b.prop("readonly",!1),navigator.geolocation.getCurrentPosition(function(c){a.val(flatStringifyGeo(c)),b.val("lat:"+c.coords.latitude+"/long:"+c.coords.longitude),b.prop("readonly",!0)},function(a){}),!1}).each(function(){$(this).closest(".input-group-btn.hidden").removeClass("hidden")})}),webshim.ready("DOM forms forms-ext dom-extend",function(){var b=$("div.btn-radio, div.btn-checkbox, div.btn-check");b.each(function(a,b){new ButtonGroup(b)}),$(".item-number.counter input[type=number]").each(function(){var b=$(this);b.parents("span").hide();var c=a.counterBtns;c.insertAfter(b.parents("span")),c.find(".btn-down").click(function(){var a=1;return b.attr("value")&&(a=+b.attr("value")),b.attr("min")a&&(b.attr("value",a+1),b.change()),!1}),webshim.ready("dom-extend",function(){webshim.addShadowDom(b,c)})}),a.setUpCounters(),$("select.select2zone, .form-group.select2 select").each(function(a,b){"use strict";var c=$(b);c.select2(),webshim.ready("dom-extend",function(){webshim.addShadowDom(c,c.select2("container"))})}),$(".select2pills select").each(function(a,b){"use strict";var c=$(b);c.select2({width:"width:300px",dropdownCssClass:"bigdrop",maximumSelectionSize:c.data("select2maximumSelectionSize"),maximumInputLength:c.data("select2maximumInputLength"),formatResult:function(a){if(""!==a.id){var b=""+a.text+"
    "+a.text+"";return b}return""},formatSelection:function(a){return a.text},escapeMarkup:function(a){return a}}).on("change select2-open",function(a){document.activeElement.blur()}),webshim.ready("dom-extend",function(){webshim.addShadowDom(c,c.select2("container"))})}),$(".clickable_map").each(function(a,b){"use strict";var c=$(b);c.find("label").attr("for",null);var d=c.find("label img"),e=$("");e.appendTo(c.find("label")),d.appendTo(e),c.find("label div a").click(function(a){return c.find(".selected").removeClass("selected"),c.find("input[type=text]").val($(this).attr("class")).change(),$(this).addClass("selected"),!1})}),$(".people_list textarea").each(function(a,b){"use strict";var c=$(b);c.select2({width:"element",height:"2000px",data:[],formatNoMatches:function(a){return""!==a?"Füge '"+a+"' hinzu!":"Weitere Personen hinzufügen."},tokenSeparators:["\n"],separator:"\n",createSearchChoice:function(a,b){return 0===$(b).filter(function(){return 0===this.text.localeCompare(a)}).length?(a=a.replace("\n","; "),{id:a,text:a}):void 0},initSelection:function(a,b){for(var c=a.val().split("\n"),d=[],e=0;e+");d.insertBefore(c.select2("container").find(".select2-search-field input")),webshim.ready("dom-extend",function(){webshim.addShadowDom(c,c.select2("container"))})}),$("input.select2add").each(function(a,b){var c=$(b);if(!c.select2("container").hasClass("select2-container")){var d=c.attr("data-select2add");"object"!=typeof d&&(d=$.parseJSON(d));for(var e,f=[],g=0;g0&&f.push({id:e[h],text:e[h]})}var i=$(b).parents(".form-group").hasClass("network_select")||$(b).parents(".form-group").hasClass("ratgeber_class")||$(b).parents(".form-group").hasClass("cant_add_choice");c.select2({createSearchChoice:function(a,b){return i?null:0===$(b).filter(function(){return 0===this.text.localeCompare(a)}).length?(a=a.replace(",",";"),{id:a,text:a}):void 0},initSelection:function(a,b){var d;if(c.data("select2multiple")){var e=a.val().split(",");d=new Array(e.length);for(var g=0;gb)return void(a.next_update||(a.next_update=window.setTimeout($.proxy(a.update,a),a.last_update+500-b))); -a.last_update=b,a.next_update=!1,a.getData(),a.showIf(),a.getProgress()}},Survey.prototype.getData=function(){var a=this.$form.serializeArray();this.data={};var b=this;$.each(a,function(a,c){if(0!==c.name.indexOf("_")&&"session_id"!=c.name){if(c.name.indexOf("[]",c.name.length-2)>-1&&(c.name=c.name.substring(0,c.name.length-2)),""===c.value&&1===$("input[type=hidden][name='"+c.name+"']").length&&c.value===$("input[type=hidden][name='"+c.name+"']").attr("value"))return b.data[c.name]=null,!0;if(b.data[c.name])b.data[c.name]+=", "+c.value;else{var d=c.value;$.isNumeric(d)&&(d=parseFloat(d)),b.data[c.name]=d}}})},Survey.prototype.getProgress=function(){var a=this;if($(".fmr-survey-page-count").length)return a.getPagingProgress();a.items_answered_on_page=$(".formr_answered").length+0,a.items_visible_on_page=$(".form-group:not(.hidden)").length+0;var b=(a.items_answered_on_page+a.already_answered)/(a.items_visible_on_page+a.items_left+a.already_answered),c=b*(a.percentage_maximum-a.percentage_minimum);return c+=a.percentage_minimum,c>a.percentage_maximum&&(c=a.percentage_maximum),a.$progressbar.css("width",Math.round(c)+"%"),a.$progressbar.text(Math.round(c)+"%"),c},Survey.prototype.getPagingProgress=function(){var a=this,b=0,c=$(".fmr-survey-page-count").data();if(c.answereditems)b=c.progress;else{var d=$(".form-group:not(.hidden)").length+0,e=$(".form-group.required:not(.hidden,.item-submit,.formr_answered,.counter)").length+0,f=(d-e)/d;b=f*c.pageprogress+c.prevprogress}var g=Math.round(100*b)+"%";return a.$progressbar.css("width",g),a.$progressbar.text(g),b},Survey.prototype.showIf=function(e){var survey=this;survey.items_with_showifs||(survey.items_with_showifs=$(".form-group[data-showif]"));var any_change=!1;return survey.items_with_showifs.each(function(i,elm){var $elm=$(elm),showif=$elm.data("showif");with(survey.data){var hide=!0;try{hide=!eval(showif)}catch(e){window.console&&console.log("JS showif failed",showif,e,$elm.find("input").attr("name")),$elm.data("show")&&(hide=!1)}any_change=survey.setItemVisibility($elm,hide)}}),any_change},Survey.prototype.setItemVisibility=function(a,b){return a.hasClass("hidden")!=b?(a.toggle(!b),a.toggleClass("hidden",b),a.find("input,select,textarea,button").prop("disabled",b),a.find(".select2-container").select2("enable",!b),b?(a.find("input,select,textarea").val(""),a.find("input[type=radio],input[type=checkbox]").prop("checked",!1)):(a.find("input.item_shown").val(mysql_datetime()),a.find("input.item_shown_relative").val(window.performance.now?performance.now():null)),!0):!1},Survey.prototype.doMonkey=function(a){var b=this;if(a>2)return window.setTimeout(function(){$("form.main_formr_survey button[type=submit]").click()},700),!1;void 0===a?a=0:a++,b.dont_update=!0;var c=$("form.main_formr_survey .form-row:not(.hidden):not(.formr_answered):not(.item-submit)"),d=new Date,e=d.toISOString().split("T")[0],f={text:"thank the formr monkey",textarea:"thank the formr monkey\nmany times",year:d.getFullYear(),email:"formr_monkey@example.org",url:"http://formrmonkey.example.org/",date:"07-08-2015",month:"07-08-2015",yearmonth:"07-08-2015",week:"07-08-2015",datetime:e,"datetime-local":d.toISOString(),day:d.getDay(),time:"11:22",color:"#ff0000",number:20,tel:"1234567890",cc:"4999-2939-2939-3",range:1};c.each(function(a,b){b=$(b);var c=null,d=null,e=null,g=null,h="text",i=null,j=null,k=null,l=null,m=null,n=null,o=null,p=b.find(".select2-container:visible");for(v=0,w=p.length;w>v;v++){var q=$(p[v]);return void(q.data("select2").opts.data?q.select2("data",q.data("select2").opts.data[0]):q.data("select2").select&&q.select2("val",q.data("select2").select[0].options[1].value))}var r=b.find("button.btn:visible");for(v=0,w=r.length;w>v;v++){var s=r[v];return void(s.disabled||s.click())}for(l=b.find("select:visible"),v=0,w=l.length;w>v;v++){if(k=l[v],!k.disabled&&!k.value.trim()){j=k.options;for(var t=0,u=j.length;u>t;t++)if(i=j.item(t),i&&i.text.trim()&&i.value.trim()){k.selectedIndex=t;break}}return}g=b.find("input:not(.ws-inputreplace):not(input[type=hidden])");for(var v=0,w=g.length;w>v;v++)c=g[v],e=c.getAttribute("name"),c.disabled||(h=c.getAttribute("type").toLowerCase(),f[h]?(d=c.getAttribute("maxlength"),f[h]&&$(c).val(f[h]),c.max&&$(c).val(c.max+""),c.min&&$(c).val(c.min+""),d&&c.value>d&&$(c).val(c.value.substr(0,d))):"checkbox"!=h&&"radio"!=h||$(c).prop("checked",!0));for(n=b.find("textarea:visible"),v=0,w=n.length;w>v;v++)m=n[v],m.disabled||m.value.trim()||(o=m.getAttribute("maxlength"),$(m).val(f.textarea),o&&m.value>o&&(m.value=m.value.substr(0,o)))}),c.each(function(a,b){$(b).trigger("change")}),b.dont_update=!1,b.update(),b.doMonkey(a)},Survey.prototype.setUpCounters=function(){var a=this;webshim.ready("DOM forms forms-ext dom-extend",function(){$(".form-group.item-number.is-counter .controls input").each(function(){function b(b){var d=c.parents(".is-counter").attr("class").replace(/\s+/g," ").split(" "),e=null;for(var f in d)if(-1!==d[f].indexOf("-counter")&&"is-counter"!==d[f]){e=d[f];break}if(!$("."+e+"-"+b).length)return!1;if(c.attr("value",b),e){$("div[class*="+e+"-]").each(function(){a.setItemVisibility($(this),!0)});for(var g=1;b>=g;g++)a.setItemVisibility($("."+e+"-"+g),!1)}}var c=$(this),d=c.parents("span"),e=a.counterBtns;d.hide(),e.insertAfter(d),b(c.val()),e.find(".btn").click(function(a){a.preventDefault();var d=$(this),e=1;return c.val()&&(e=+c.val()),d.is(".btn-down")&&c.attr("min")e&&(e+=1),b(e),!1})})})},$(function(){var a=new Survey;a.update(),$("form.main_formr_survey").on("change",function(){a.update()}),$(".form-row.hidden").length>0&&($(".show_hidden_items").click(function(){return $(".form-row.hidden").removeClass("hidden"),!1}),$(".show_hidden_items").attr("disabled",!1)),$("button.monkey").length>0&&($("button.monkey").click(function(){return a.doMonkey(0),!1}),$("button.monkey").attr("disabled",!1))})}(jQuery),function(){"use strict";var a=function(){var a=$(".fmr-learn-more"),b=a.width(),c=-b/2;a.css("margin-left",c)},b=function(){var a=$(".js-fullheight.full").length?0:49,b=Math.min($(window).height(),620)-a;$(".js-fullheight").css("min-height",b),$(".run-container").css("min-height",$(window).height()-1),b+=a;var c=$(".fmr-intro").height(),d=b>=c?(b-c)/2+5:120,e=d>120?d:120;$("#fmr-hero .fmr-intro .fmr-intro-text").css("padding-top",e),$(".js-fullheight.elongate").height(c+15)};$(window).resize(b);var c=function(){$("body").on("click",".scroll-btn",function(a){return a.preventDefault(),$("html, body").animate({scrollTop:$($(this).closest('[data-next="yes"]').next()).offset().top},1e3,"easeInOutExpo"),!1})},d=function(){$(document).click(function(a){var b=$("#fmr-offcanvas, .js-fmr-nav-toggle");b.is(a.target)||0!==b.has(a.target).length||$("body").hasClass("offcanvas-visible")&&($("body").removeClass("offcanvas-visible"),$(".js-fmr-nav-toggle").removeClass("active"))})},e=function(){$("body").prepend('
    '),$("#fmr-offcanvas").prepend('