This repository has been archived on 2022-05-20. You can view files and clone it, but cannot push or open issues or pull requests.
Calculators/Download/Calculators A First Look at the TI-Nspire CX II_files/aops_core.js

10 lines
78 KiB
JavaScript
Raw Normal View History

2022-05-20 18:50:33 +00:00
!function(i){(i.isEpicFailing=function(){return"undefined"==typeof $},i.isEpicFailing())&&(document.getElementById("epicfail").style.display="block")}(window.AoPS||{});
;$(document).on("ready",(function(){if(jQuery.support.cors=!0,document.getElementById("side-column")&&($("#breadcrumbs-wrapper").addClass("clickable-breadcrumb"),$("#breadcrumbs-wrapper").click((function(){window.innerWidth<840&&($("#side-column-wrapper").toggleClass("active"),$("#submenu-icon").toggleClass("open"))})),$("#side-column .dropdown-box > .title").click((function(e){$(e.currentTarget).parent().toggleClass("open")})),$("#side-column .menu").click((function(e){$("#side-column .submenu-wrapper").removeClass("open"),$(e.currentTarget).find(".submenu-wrapper").addClass("open")}))),$(".infobar").click((function(e){e.target.className.indexOf("infobar-hide")>=0&&($(this).hide(),AoPS.fixFooter(),$("#main-content").trigger($.Event("resize")),$.ajax({url:"/ajax.php",timeout:5e3,type:"post",data:{a:"infobar-hide",key:$(this).data("key")},success:function(e){}}))})),$("#menu-myaops-toggle").click((function(e){$("#menu-myaops").toggle(),e.preventDefault(),e.stopPropagation()})),!document.getElementById("side-column")){var e=document.getElementById("submenu-icon");e&&e.parentNode.removeChild(e)}AoPS.fixFooter(),$(window).on("resize.fix_footer",(function(){AoPS.fixFooter()})),AoPS.login.initialize(),AoPS.inputPlaceholders.initialize(),document.createElementNS&&document.createElementNS("http://www.w3.org/2000/svg","svg").createSVGRect?$("html").addClass("svg"):$("html").addClass("no-svg");var o=$("body"),n=$("#top-bar"),t=$("#main-logo"),i=!1,a=!1,r=!1,s=!1;n.on("mousemove.start_loc",(function(){i=!0})),t.on("mousemove.start_loc",(function(){s=!0})),o.on("mousemove.start_loc",(function(){n.off("mousemove.start_loc"),o.off("mousemove.start_loc"),t.off("mousemove.start_loc"),setTimeout((function(){i=!1,s=!1}),350)})),n.on("mouseenter",(function(){a=!0,setTimeout((function(){!i&&a&&$("#header-popin").animate({opacity:1},150)}),350)})),t.on("mouseenter",(function(){r=!0,setTimeout((function(){!s&&r&&$("#header-popin").animate({opacity:1},150)}),350)})),n.on("mouseleave",(function(){a=!1})),t.on("mouseleave",(function(){r=!1})),$("#header").on("mouseleave",(function(){$("#header-popin").animate({opacity:0},150)})),n.find(".site").hover((function(){var e=$(this);e.addClass("dropdown-visible");var o=e.find(".site-dropdown-wrapper");if(o.length){var n=$(window).width(),t=o.outerWidth(),i=o.offset().left+t+10-n;i>0&&o.css("left",-100-i+"px")}}),(function(){$(this).removeClass("dropdown-visible").find(".site-dropdown-wrapper").css("left","")})),AoPS.checkPrivacy()})),$(window).on("load",(function(){AoPS.fixFooter()})),AoPS.checkPrivacy=function(){if(document.URL.indexOf("/privacy")<0&&AoPS.session&&AoPS.session.show_privacy){var e=["<p>We've made a few updates to our privacy policy. These updates went into effect on Friday, February 4, 2022.</p>","<p>Click ",'<a href="'+AoPS.aops_url+'company/privacy" target="_blank">here</a> ',"to learn more about the new ",'<a href="'+AoPS.aops_url+'" target="_blank">artofproblemsolving.com</a> policy.</p>'],o=1,n=document.location.href;(n.indexOf("community")>0||n.indexOf("alcumus")>0||n.indexOf("baeditor")>0||n.indexOf("class/")>0)&&(o=1e3),setTimeout((function(){alert(e.join(""),{onButtonClick:function(){$.post("/ajax.php",{action:"update-accepted"})},max_width:"600px",closeX:!1,force_response:!0})}),o)}},window.classicAlert=window.alert,window.alert=function(e,o){AoPS.hasOwnProperty("Ui")?(AoPS.Ui.Modal.closeTopModal(),void 0===o?AoPS.Ui.Modal.showAlertQuick(e):AoPS.Ui.Modal.showAlertQuick(e,o)):window.classicAlert(e)},AoPS.setBreadcrumbs=function(e){for(var o,n=[],t=0;t<e.length;t++)o=e[t].text,e[t].url&&(o='<a href="'+e[t].url+'">'+o+"</a>"),n.push('<span class="crumb crumb-'+(t+1)+'">'+o+"</span>");$(".crumb-wrapper").html(n.join(' <i class="aops-font aops-angle-double-right"></i> '))},AoPS.fixFooter=function(){var e=$(window).height(),o=$("body").hasClass("small-footer");e-=$("#header-wrapper").outerHeight(),e-=$("#top-bar").outerHeight(),$("#breadcrumbs-wrapper:visible").length||(e-=26),e-=o?$("#small-footer-wrapper").outerHeight():$("#main-footer").outerHeight(),$("#main-content").css("min
;AoPS.hasOwnProperty("Ui")&&AoPS.hasOwnProperty("ui_main_loaded")||(AoPS.Ui=function(e){var t;t=$(window).height(),setInterval((function(){var e=$(window).height();e!=t&&(t=e,$(window).trigger("resize"))}),100),$(window).on("resize",(function(){t=$(window).height()})),e.buildTableRow=function(e){var t=$("<tr/>"),o=(e=_.defaults(e,{is_header:!1})).is_header?"th":"td";return _.each(e.data,(function(e){t.append($.parseHTML("<"+o+">"+e+"</"+o+">"))})),e.is_header&&t.addClass("aops-no-sort"),t},e.buildTable=function(t){var o,s,a=0,i=!1,n=!1;return t=_.defaults(t,{sortable:!1,table_id:"",sort_on_build:!1,table_class:"",sort_col:0,sort_order:"asc",repeating_header:0}),o=$("<table/>",{id:t.table_id,class:t.table_class}),s=$("<tbody/>").appendTo(o),t.hasOwnProperty("footer")&&$("<tfoot/>").prependTo(o).append(e.buildTableRow({data:t.footer,is_header:!0})),t.hasOwnProperty("header")&&$("<thead/>").prependTo(o).append(e.buildTableRow({data:t.header,is_header:!0})),t.hasOwnProperty("rows")&&_.each(t.rows,(function(o){s.append(e.buildTableRow({data:o})),a++,t.repeating_header>0&&a%t.repeating_header==0&&s.append(e.buildTableRow({data:t.header,is_header:!0}))})),t.sortable&&(o.tablesorter(t.sort_on_build?{sortList:t.hasOwnProperty("sortList")?t.sortList:[[t.sort_col,"asc"===t.sort_order?0:1]]}:{}),t.repeating_header>0&&(o.bind("sortStart",(function(){i?(i=!1,n=!0):(i=!0,s.find(".aops-no-sort").remove(),o.trigger("update"))})),o.bind("sortEnd",(function(){n?n=!1:s.find("tr:nth-child("+t.repeating_header+"n)").after(e.buildTableRow({data:t.header,is_header:!0}))})))),o},e.Flyout=function(){var e,t={},o=[],s={width:300,height:150,class:"",time:5e3,animation_time:1e3,close_function:"close"};function a(){if(o.length&&document.body){var e=document.getElementById("flyout");if(!e||!e.parentNode){var t=o.shift();i(t.html,t.opts)}}}function i(o,a){a=$.extend({},s,a),e=a;var i=document.createElement("div");i.id="flyout",i.style.width=a.width+"px",i.style.height=a.height+"px",i.style.right=-a.width+"px",i.className=a.class,i.innerHTML='<div class="close" onclick="AoPS.Ui.Flyout.'+a.close_function+'()"></div>'+o,document.body.appendChild(i),$("#flyout").animate({right:0},a.animation_time,(function(){t.timeout=setTimeout((function(){n()}),a.time)}))}function n(){$("#flyout").animate({right:-e.width},e.animation_time,(function(){t.timeout=0;var e=document.getElementById("flyout");e&&(e.parentNode.removeChild(e),a())}))}return t.display=function(e,s){document.body?(t.close(),o=[],i(e,s)):(AoPS.ErrorUtil.log("E_EARLY_FLYOUT"),t.queue(e,s))},t.queue=function(e,t){o.push({html:e,opts:t}),a()},t.close=function(){if(document.body){t.timeout&&clearTimeout(t.timeout),o=[];var e=document.getElementById("flyout");e&&e.parentNode&&e.parentNode.removeChild(e)}},t.closeWithoutClearingQueue=function(){document.body&&(t.timeout&&clearTimeout(t.timeout),n())},$(a),t}(),$.fn.extend({showUnstyledModal:function(e){var t=_.defaults({$obj:this},arguments.length>0?arguments[0]:{});return this.show(),AoPS.Ui.Modal.show$Object(t)},showPlainModal:function(e){var t=_.defaults({body:this},arguments.length>0?arguments[0]:{});return this.show(),AoPS.Ui.Modal.show(t)},showPlainBodyModal:function(e){var t=_.defaults({body:this},arguments.length>0?arguments[0]:{});return this.show(),AoPS.Ui.Modal.showPlainBody(t)},showModal:function(e){var t=arguments.length>0?arguments[0]:{};return this.show(),AoPS.Ui.Modal.showMessage(this,t)},showModalQuick:function(e){var t=arguments.length>0?arguments[0]:{};return this.show(),AoPS.Ui.Modal.showMessageQuick(this,t)},showPlainAlert:function(e){var t=_.defaults({body:this,type:"alert"},arguments.length>0?arguments[0]:{});return this.show(),AoPS.Ui.Modal.show(t)},showAlertQuick:function(e){var t=arguments.length>0?arguments[0]:{};return this.show(),AoPS.Ui.Modal.showAlertQuick(this,t)},showAlert:function(e){var t=arguments.length>0?arguments[0]:{};return this.show(),AoPS.Ui.Modal.showAlert(this,t)},cloneToPlainModal:function(e){var t=this.clone(!0),o=_.defaults({body:t,type:"message"},arguments.length>0?arguments[0]:{});return t.show(),AoPS.Ui.M
;AoPS.GoToHash=function(e){var s=e.substring(1).replace(/^([a-zA-Z0-9\-]*).*/,"$1");if(s){var n=$("#"+s).length?$("#"+s):$("a[name="+s+"]");if(canNavResize&&n.offset()){var a=n.offset().top;$("#header").hasClass("shrunken-header")?a-=$("#header").height():a-=2*$("#header").height(),$("body,html").animate({scrollTop:a},300,"swing")}}};var canNavResize=!1,getWindowWidth=function(){return window.innerWidth},isMobile=function(){return window.matchMedia("(max-width: 700px)").matches};$(document).ready((function(){var e=getWindowWidth();$(".menubar-label-link-outer").on("click",(function(e){var s,n,a,i,o,t;isMobile()&&(s=this,n=$(s).next().find(".dropdown-content"),a=$(s).parent(),i=$(a).height(),o=$(n).height(),t=i,t=i>o+12?i-o-6:i+o+6,$(a).height(t))})),$(window).on("resize",(function(s){if(getWindowWidth()!==e)if(e=getWindowWidth(),isMobile()){$(".menubar-labels").css({display:"none"});var n=$("body").height(),a=$("#header-wrapper").height();$(".menubar-labels").height(n-a),$(".menubar-label").each((function(e){$(this).height("auto")}))}else $(".menubar-label").each((function(e){$(this).height(16)})),$(".menubar-labels").css({display:"flex",minHeight:0}),$(".menubar-labels").height("auto")})),$(".menubar-hamburger").on("click",(function(e){var s=$("body").height(),n=$("#header-wrapper").height();"none"===$(".menubar-labels").css("display")?($(".menubar-labels").css({display:"block"}),$(".menubar-labels").css({height:"auto",minHeight:s-n+"px"})):$(".menubar-labels").css({display:"none"})})),$("#mobile-search-icon").on("click",(function(e){var s=$("body").height(),n=$("#header-wrapper").height();"none"===$(".menubar-labels").css("display")&&($(".menubar-labels").css({display:"block"}),$(".menubar-labels").css({height:"auto",minHeight:s-n+"px"})),$("#mobile-search-input").focus()})),$(".dropdown-content a").on("click",(function(e){isMobile()&&$(".menubar-labels").css({display:"none"})})),$(".superuser").on("click",(function(e){$.post("/ajax.php",{action:"toggle-superuser"},(function(e){e.response&&e.response.success?(AoPS.Ui.Flyout.display("Sucessfully "+(e.response.superuser?"enabled":"disabled")+" superuser permissions."),$(".superuser").text(e.response.superuser?"Disable Superuser":"Enable Superuser")):AoPS.Ui.Flyout.display(e.error_msg)}))}));var s=!1,n=!1,a=_.throttle(_.bind((function(e){n&&(s=!1,n=!1,$("body,html").stop().animate()),$(window).scrollTop()>5?$("#header").addClass("shrunken-header"):$("#header").removeClass("shrunken-header")}),this),200),i=$("body"),o=i.hasClass("community")||i.hasClass("school-class-page")||i.hasClass("mediawiki")||i.hasClass("cart")||i.hasClass("ebooks")||i.hasClass("dashboard")||i.hasClass("resources")||i.hasClass("small-header")||i.hasClass("no-nav-resize");isMobile()||o||(canNavResize=!0,window.location.hash&&AoPS.GoToHash(window.location.hash),a(),$(window).on("scroll",a)),$("div.slide-button").on("click",(function(){if(!s){s=!0,n=!1;var e=$(".callouts-container").offset().top;isMobile()||(e-=2*$("#main-menubar").height()),$("body,html").animate({scrollTop:e},1200,"swing",(function(){s=!1}))}})),document.body.addEventListener("wheel",(function(){n=!0})),$(window).on("resize",(function(e){isMobile()||canNavResize||o?isMobile()&&canNavResize&&(canNavResize=!1,$("#header").removeClass("shrunken-header"),$(window).off("scroll",a)):(canNavResize=!0,$(window).on("scroll",a))})),window.addEventListener("hashchange",(function(){setTimeout((function(){AoPS.GoToHash(window.location.hash)}),10)})),$(".menubar-label").on("click",(function(e){if($(document).width()<=700){var s=$(e.currentTarget);s.height()<50&&$([document.documentElement,document.body]).animate({scrollTop:s.offset().top-15},500)}}))}));
;AoPS.Utils=function(r){var t;return r.getKeyChain=function(r,t){if(_.isObject(r))return _.isArray(t)||(t=_.toArray(arguments).slice(1)),_.reduce(t,(function(r,t){if(!(!r||!r.hasOwnProperty(t)))return r[t]}),r)},r.hasKeyChain=function(){var t=r.getKeyChain.apply(this,arguments);return!_.isUndefined(t)},r.initKeyChain=function(r,t,e){return _.isArray(t)?_.isUndefined(e)&&(e={}):(t=_.toArray(arguments).slice(1),e={}),_.reduce(t,(function(r,n,o){var i=o===t.length-1?e:{};return r.hasOwnProperty(n)||(r[n]=i),r[n]}),r)},r.natSortBy=function(r,t,e){var n=new Intl.Collator("en",{numeric:!0});return r.sort((function(r,o){return(e?-1:1)*n.compare(""+t(r),""+t(o))}))},r.natSort=function(t,e){return r.natSortBy(t,(function(r){return r}),e)},r.Class=((t=function(){}).extend=function r(t){return function(e){var n,o,i;return(o=function(){}).prototype=t.prototype,n=new o,_.extend(n,e),i=function(){this.initialize&&this.initialize.apply(this,arguments)},i.prototype=n,i.extend=r(i),i}}(t),t),r}(AoPS.Utils||{});var Base64={_keyStr:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",encode:function(r){var t,e,n,o,i,a,h,c="",f=0;for(r=Base64._utf8_encode(r);f<r.length;)o=(t=r.charCodeAt(f++))>>2,i=(3&t)<<4|(e=r.charCodeAt(f++))>>4,a=(15&e)<<2|(n=r.charCodeAt(f++))>>6,h=63&n,isNaN(e)?a=h=64:isNaN(n)&&(h=64),c=c+this._keyStr.charAt(o)+this._keyStr.charAt(i)+this._keyStr.charAt(a)+this._keyStr.charAt(h);return c},decode:function(r){var t,e,n,o,i,a,h="",c=0;for(r=r.replace(/[^A-Za-z0-9\+\/\=]/g,"");c<r.length;)t=this._keyStr.indexOf(r.charAt(c++))<<2|(o=this._keyStr.indexOf(r.charAt(c++)))>>4,e=(15&o)<<4|(i=this._keyStr.indexOf(r.charAt(c++)))>>2,n=(3&i)<<6|(a=this._keyStr.indexOf(r.charAt(c++))),h+=String.fromCharCode(t),64!==i&&(h+=String.fromCharCode(e)),64!==a&&(h+=String.fromCharCode(n));return h=Base64._utf8_decode(h)},_utf8_encode:function(r){r=r.replace(/\r\n/g,"\n");for(var t="",e=0;e<r.length;e++){var n=r.charCodeAt(e);n<128?t+=String.fromCharCode(n):n>127&&n<2048?(t+=String.fromCharCode(n>>6|192),t+=String.fromCharCode(63&n|128)):(t+=String.fromCharCode(n>>12|224),t+=String.fromCharCode(n>>6&63|128),t+=String.fromCharCode(63&n|128))}return t},_utf8_decode:function(r){for(var t="",e=0,n=0,o=0,i=0;e<r.length;)(n=r.charCodeAt(e))<128?(t+=String.fromCharCode(n),e++):n>191&&n<224?(o=r.charCodeAt(e+1),t+=String.fromCharCode((31&n)<<6|63&o),e+=2):(o=r.charCodeAt(e+1),i=r.charCodeAt(e+2),t+=String.fromCharCode((15&n)<<12|(63&o)<<6|63&i),e+=3);return t}};
;AoPS.Utils.initKeyChain(AoPS,"Ajax"),AoPS.Ajax=function(e){var t,i,s=AoPS.Utils;function n(t,i,s){var n=i.ajax_data,o=i.callback,r=i.timeout||t.timeout;return i.action&&(n.a=i.action),AoPS.session&&(n.aops_logged_in=AoPS.session.logged_in,n.aops_user_id=AoPS.session.user_id,n.aops_session_id=AoPS.session.id),s||(s={checkQueue:function(){},signalComplete:function(){}}),$.ajax({url:t.script_path,data:n,dataType:"json",type:"POST",timeout:r,error:function(t,i){s.checkQueue(),s.signalComplete(),e.handleError(o,t,i)},success:function(e){s.checkQueue(),s.signalComplete();var i=!e.hasOwnProperty("error_code");o(i,e),_.each(t.global_handlers,(function(t){t(i,e)}))}})}return e.handleError=function(e,t,i){var s=parseInt(t.status);200!==s||t.responseText.length?"abort"===i?e(!1,{response:{},error_code:"E_AJAX_CANCEL",error_msg:"The request was cancelled by the calling code."}):"timeout"===i?e(!1,{response:{},error_code:"E_AJAX_TIMEOUT",error_msg:"Something took too long to happen, and your browser gave up. Please check your internet connection, then try again."}):"parsererror"===i?(console.log(t.responseText),e(!1,{response:{},error_code:"E_AJAX_BADRETURN",error_msg:"You have come across a temporary error with our website. Please try again in an hour, and let us know if you continue to experience problems."})):e(!1,404===s?{response:{},error_code:"E_AJAX_404",error_msg:"The requested script does not exist."}:{response:{},error_code:"E_AJAX_UNKNOWN",error_msg:"Something went wrong. Please check your internet connection, then try again."}):e(!0,{response:{}})},t=s.Class.extend({initialize:function(e){this.processing_id=0,this.processing_xhr=null,this.next_id=1,this.window_size=!e||e<1?1:e,this.processing_size=0,this.queue_id_list=[],this.queue_table={}},getRunningId:function(){return this.processing_id},checkQueue:function(){if(this.processing_id=this.queue_id_list.pop(),this.processing_xhr=null,this.processing_id){var e=this.queue_table[this.processing_id];if(!e)return this.checkQueue();delete this.queue_table[this.processing_id],this.processing_xhr=e.processFunction(e.data,this)}else this.processing_id=0},signalComplete:function(){this.processing_size-=1},cancelId:function(e){var t;return this.queue_table[e]?((t=this.queue_table[e])&&t.data.callback(!1,{response:{},error_code:"E_AJAX_CANCEL",error_msg:"The request was cancelled by the calling code."}),delete this.queue_table[e],!0):!(this.processing_id!==e||!this.processing_xhr||!this.processing_xhr.abort)&&(this.processing_xhr.abort(),!0)},addToQueue:function(e,t,i){var s=this.next_id;return this.next_id+=1,this.queue_table[s]={data:e,processFunction:t},i?this.queue_id_list.push(s):this.queue_id_list=[s].concat(this.queue_id_list),this.processing_size<this.window_size&&this.checkQueue(),this.processing_size+=1,s}}),e.RepetitionFilter=s.Class.extend({initialize:function(e){this.recent_inputs=[],this._clearRecentDebounced=_.debounce(_.bind((function(){this.recent_inputs=[]}),this),e)},sendToFilter:function(e){var t;return t=_.some(this.recent_inputs,(function(t){return _.isEqual(e,t)})),this._clearRecentDebounced(),t||this.recent_inputs.push(e),!t}}),i=new t,e.ScriptRunner=s.Class.extend({initialize:function(s,n){var o;n=n||{},this.script_path=s,this.global_handlers=[],this.timeout=2e4,_.isFinite(n.timeout)&&n.timeout>0&&(this.timeout=n.timeout),o=500,_.isFinite(n.filter_interval)&&(o=n.filter_interval),o>0&&(this.filter_object=new e.RepetitionFilter(o)),this.last_queue_id=0,this.queue_object=i,this.use_queue=!n.hasOwnProperty("use_queue")||!!n.use_queue,this.use_queue&&n.separate_queue&&(this.queue_object=new t(n.window_size))},addGlobalHandler:function(e){return!!_.isFunction(e)&&(this.global_handlers.push(e),!0)},removeGlobalHandler:function(e){var t=this.global_handlers.length;return this.global_handlers=_.reject(this.global_handlers,(function(t){return t===e}),this),this.global_handlers.length<t},getLastQueueId:function(){return this.last_queue_id},getRunningQueueId:function(){return this.use_queue&&this.queue_object?this.queue_object.getRunningId():0},cancelQueueId:function(
;AoPS.Utils.initKeyChain(AoPS,"BackboneExtras"),AoPS.BackboneExtras=function(e){var t=AoPS.Utils;function i(e,t){var i;return i='<a data-subviewloc="'+(e=Handlebars.Utils.escapeExpression(e))+'"></a>',new Handlebars.SafeString(i)}return Handlebars.registerHelper("equals",(function(e,t,i){return e==t?i.fn(this):i.inverse(this)})),e.AutocreateMixin={setCreateFunction:function(e){this.createFunction=e},getOrCreate:function(e,t){t=t||{};var i=_.omit(t,["delay_add"]),s=this.get(e);if(s||_.isFunction(this.createFunction))return s||(s=this.createFunction(e))&&!t.delay_add&&this.add(s,i),s}},e.TemplateMixin={setTemplate:function(e,t){"#"!==e[0]&&(e="#"+e),this.compiledTemplate=AoPS.View.compileTemplate(e),this.compiledTemplate||console.log("WARNING: Template ID "+e+" not found"),this.use_root_el=!!t,this.rendered_tpl_before=!1},setTemplateAndUseRootEl:function(e){this.setTemplate(e,!0)},renderTopOnly:function(){var e,t;this.compiledTemplate?""===(e=$.trim(this.compiledTemplate({})))||(this.use_root_el?this.rendered_tpl_before||(t=$($.parseHTML(e)).empty(),this.$el.replaceWith(t),this.setElement(t),this.rendered_tpl_before=!0):this.rendered_tpl_before=!0):this.$el.empty()},renderTemplate:function(e){var t,i;this.compiledTemplate?""===(t=$.trim(this.compiledTemplate(e)))||(this.use_root_el?this.rendered_tpl_before?(this.$el.empty(),this.$el.append($($.parseHTML(t)).contents())):(i=this.$el.html(t).contents(),this.$el.replaceWith(i),this.setElement(i),this.rendered_tpl_before=!0):(this.$el.html(t),this.rendered_tpl_before=!0)):this.$el.empty()}},Handlebars.registerHelper("SUBVIEWLOC",i),Handlebars.registerHelper("subviewloc",i),e.SubviewMixin={reorderAtLocation:function(e,i,s){t.initKeyChain(this,["subviews",e],[]);var n=this.subviews[e].length;if(n){var o=this.subviews[e][n-1];i=_.bind(i,this);var a=_.map(this.subviews[e],(function(e){return{cmp:i(e),view:e}}),this);if(a.sort((function(e,t){return e.cmp<t.cmp?-1:1})),this.subviews[e]=_.pluck(a,"view"),!s){var l=this.subviews[e][n-1];l!==o&&o.$el.after(l.$el),_.each(this.subviews[e].slice(0,-1),(function(e){l.$el.before(e.$el)}))}}},applyToAllAtLocation:function(e,i){t.initKeyChain(this,["subviews",e],[]),_.each(this.subviews[e],_.bind(i,this))},applyToAllSubviews:function(e){t.initKeyChain(this,"subviews"),_.each(this.subviews,(function(t,i){this.applyToAllAtLocation(i,_.partial(e,i))}),this)},isLocationEmpty:function(e){return t.initKeyChain(this,["subviews",e],[]),!this.subviews[e].length},getLocationList:function(){return t.initKeyChain(this,"subviews"),_.reject(_.keys(this.subviews),_.bind(this.isLocationEmpty,this))},clearLocation:function(e,i){t.initKeyChain(this,["subviews",e],[]),this.applyToAllAtLocation(e,(function(e){i?e.$el.detach():this.closeView(e)})),this.subviews[e]=[]},addSubviewToLocation:function(e,i){i=i||"",t.initKeyChain(this,["subviews",i],[]),this.subviews[i].push(e)},detachAllSubviews:function(){this.applyToAllSubviews((function(e,t){t.$el.detach()}))},renderAllSubviews:function(){this.applyToAllSubviews((function(e,t){t.render()}))},attachToHandlebarsLocation:function(e,t){var i=this.$('a[data-subviewloc="'+t+'"]');i.length&&i.first().before(e)},attachAllSubviews:function(){var e={};_.each(this.getLocationList(),(function(t){var i=[];this.applyToAllAtLocation(t,(function(e){i.push(e.$el)})),e[t]=i}),this),_.each(this.getLocationList(),(function(t){var i=e[t];""===t?this.$el.append(i):"@"===t[0]?this.attachToHandlebarsLocation(i,t.slice(1)):this.$(t).append(i)}),this)},removeHandlebarsLocationMarkers:function(){this.$("a[data-subviewloc]").remove()},closeAllSubviews:function(){this.applyToAllSubviews((function(e,t){this.closeView(t)})),this.subviews={}},closeView:function(e){e.remove(),e.unbind(),e.onClose&&e.onClose()}},e}(AoPS.BackboneExtras);
;AoPS.Page={},AoPS.Page.loader_html='<div class="aops-loader"><img src="/assets/images/logo-ludicrous.gif" /></div>',AoPS.Page.$loader=$($.parseHTML(AoPS.Page.loader_html)),AoPS.Page.buildLoader=function(){return AoPS.Page.$loader.clone()},AoPS.Page.Model=Backbone.Model.extend({initialize:function(){this.set("elements",{}),this.set("active_elements",[]),this.set("locations",[]),this.set("active_locations",[])},fetchElement:function(e){var t=e.hasOwnProperty("id")?this.findExistingElement(e.id):null;return _.isUndefined(t)||_.isNull(t)?t=this.createElement(e):"backbone"===t.type&&(t.dom_element=t.view.$el),t},findExistingElement:function(e){var t=this.get("elements");return t.hasOwnProperty(e)?t[e]:null},createElement:function(e){var t,o;return e.hasOwnProperty("type")&&"backbone"!==e.type?"jQuery_object"===e.type&&(e.hasOwnProperty("jQuery_object")||(console.log("You tried to initiate a jQuery_object element without sending the object!"),console.log("The id is "+e.id)),t={id:e.id,dom_element:e.jQuery_object,type:"jQuery_object",no_save:!!e.no_save,onAddToPage:e.hasOwnProperty("onAddToPage")?e.onAddToPage:function(){},onRemoveFromPage:e.hasOwnProperty("onRemoveFromPage")?e.onRemoveFromPage:function(){}}):(o=e.constructor(),t={id:e.id,dom_element:o.$el,type:"backbone",view:o,no_save:!!e.no_save,onAddToPage:"function"==typeof o.onAddToPage?function(e){o.onAddToPage(e)}:function(){},onRemoveFromPage:"function"==typeof o.onRemoveFromPage?function(){o.onRemoveFromPage()}:function(){}}),e.no_save||this.insertElement(t),t},insertElement:function(e){this.get("elements")[e.id]=e},activateElement:function(e){var t=this.fetchElement(e);return this.get("active_elements").push(t),t},fetchLocation:function(e){var t=_.find(this.get("locations"),(function(t){return t.id===e}));return _.isUndefined(t)&&(t=this.createLocation(e)),t},createLocation:function(e){var t={id:e,dom_element:$($.parseHTML('<div id="'+e+'"></div>')),is_active:!1};return this.get("locations").push(t),t},activateLocation:function(e){e.is_active=!0,this.get("active_locations").push(e)},clearActiveArrays:function(){this.set("active_elements",[]),this.set("active_locations",[])}}),AoPS.Page.View=Backbone.View.extend({classes:[],$breadcrumbs_wrapper:$("#breadcrumbs-wrapper"),$breadcrumbs_bar:$("#breadcrumbs .crumb-wrapper"),initialize:function(){this.$subheader=$("#subheader"),0===this.$subheader.length&&(this.$subheader=$('<div id="subheader"></div>').css({width:"100%","text-align":"center"}),$("#header").after(this.$subheader)),this.$error_window=$("#page_error_window"),0===this.$error_window.length&&(this.$error_window=$('<div id="page_error_window"></div>').css({width:"100%","text-align":"left"})),this.$loader=AoPS.Page.buildLoader()},findActiveElement:function(e){return _.find(this.model.get("active_elements"),(function(t){return t.id===e}))},showElement:function(e){var t,o=this.model.activateElement(e);return e.hasOwnProperty("location")?"subheader"===e.location?this.$subheader.append(o.dom_element):((t=this.model.fetchLocation(e.location)).is_active||(this.model.activateLocation(t),this.$el.append(t.dom_element)),t.dom_element.append(o.dom_element)):this.$el.append(o.dom_element),o.dom_element.trigger("added_to_page",e.hasOwnProperty("on_add_settings")?e.on_add_settings:{}),o.onAddToPage(e.hasOwnProperty("on_add_settings")?e.on_add_settings:{}),_.clone(o)},showElements:function(e){var t=[];return _.each(e,_.bind((function(e){t.push(this.showElement(e))}),this)),t},hideElement:function(e){e&&(e.dom_element.detach(),"backbone"===e.type&&e.view.$el.detach(),e.onRemoveFromPage(),e.no_save&&"backbone"===e.type&&e.view.close&&e.view.close())},clearPage:function(e){var t=_.extend({remove_modals:!0,hide_loader:!0,remove_all:!0,remove_classes:!0},e);t.remove_modals&&AoPS.Ui.Modal.closeAllModals(),t.hide_loader&&this.hideLoader(),t.remove_classes&&this.clearClasses(),t.remove_all&&(_.each(this.model.get("active_elements"),this.hideElement,this),_.each(this.model.get("active_locations"),(function(e){e.is_active=!1,e.dom_element.detach()})),this.model.clearActiveArrays()),thi
;AoPS.AskAoPS=AoPS.AskAops={display:function(a){var o=['<div class="aops-modal-body clearfix askaops">','<div class="askaops-categories">',"<h1>Ask AoPS</h1>","<strong>I have a question about:</strong><br>",'<div style="padding-left:10px;padding-top:10px;line-height:2em;">','<label><input type="radio" name="askaops-category" value="general" checked="checked"> General Information</label>','<label><input type="radio" name="askaops-category" value="book"> Book Recommendations</label>','<label><input type="radio" name="askaops-category" value="class"> Class Recommendations</label>','<label><input type="radio" name="askaops-category" value="order"> Order Information</label>','<label><input type="radio" name="askaops-category" value="myclass"> My Current Class</label>','<label><input type="radio" name="askaops-category" value="technical"> Technical Support</label>','<label><input type="radio" name="askaops-category" value="other"> Other</label>',"</div>","</div>",'<div class="askaops-form">','<div id="askaops-blurb">Have a general question about Art of Problem Solving? Let us know below.</div>','<div data-hj-suppress="" data-hj-masked="" id="askaops-error" class="error-box"></div>','<input data-hj-suppress="" data-hj-masked="" id="askaops-subject" class="form-control" placeholder="Message Subject">','<input data-hj-suppress="" data-hj-masked="" id="askaops-ordernumber" class="askaops-ordernumber form-control" placeholder="Order number - if known">','<input data-hj-suppress="" data-hj-masked="" id="askaops-course" class="askaops-course form-control" placeholder="Class name and id - if known">','<textarea data-hj-suppress="" data-hj-masked="" id="askaops-message" class="form-control" style="margin-top:10px;height:100px;" placeholder="How can we help you?"></textarea>','<input data-hj-suppress="" data-hj-masked="" id="askaops-username" class="askaops-username form-control" placeholder="AoPS Username - if known">','<input data-hj-suppress="" data-hj-masked="" id="askaops-name" style="margin-top:10px" class="form-control" placeholder="Your name">','<input data-hj-suppress="" data-hj-masked="" id="askaops-email" style="margin-top:10px" class="form-control" placeholder="Your email address">','<div style="text-align:right">','<input id="askaops-submit" style="margin-top:10px" type="submit" class="btn-lg btn btn-primary" value="Submit your message">',"</div>","</div>","</div>"];o=o.join("\n"),AoPS.Ui.Modal.showPlain({body:o,width:"75%",onClose:this.onClose,scrollable:!1,frame_class:"askaops-modal",height:"",max_height:""}),$(".askaops-modal").parent(".aops-modal-wrapper").addClass("askaops-modal-wrapper"),void 0!==a&&setTimeout((function(){"class"===a?($(".askaops input[name='askaops-category'][value=class]").prop("checked",!0),AoPS.AskAoPS.onChange()):"book"===a&&($(".askaops input[name='askaops-category'][value=book]").prop("checked",!0),AoPS.AskAoPS.onChange())}),1),this.onShow()},onChange:function(a){var o=$(".askaops input[name='askaops-category']:checked").val(),s=["Have a general question about Art of Problem Solving?","Let us know below.","<a href='../company/privacy'>View our Privacy Policy</a>."].join(" "),e=["Please tell us about your student's math background, including","their grade level, recent math classes, and contest experience","(if any), as well as your goals for choosing books. You can also","find suggestions on our ",'<a href="/store/recommendations">Recommendations page</a>.',"<a href='../company/privacy'>View our Privacy Policy</a>."].join(" "),r=["Please tell us about your student's math background, including","their grade level, recent math classes, and contest experience","(if any), as well as your goals for choosing a course. You can","also find suggestions on our",'<a href="/school/recommendations">Recommendations page</a>.',"Visit <a href=http://www.artofproblemsolving.com/school/how-school-works/faqs>","Frequently Asked Questions</a> for quick answers to common class questions.","<a href='../company/privacy'>View our Privacy Policy</a>."].join(" "),n=["Have a question about an order? Let us know below."
;//# sourceMappingURL=aops_core.js.map