').addClass(e).insertAfter(this.$el);var t=this.$el.val();this.textPreview.text(t||this.$el.attr("placeholder")),this.textPreview.toggleClass("placeholder",!t)},onTextInput:function(e){var t=$(e.target),i=t.val();this.textPreview.text(i||t.attr("placeholder")),this.textPreview.toggleClass("placeholder",!i)}}),e.View.Widget.TextareaWithMenu=Backbone.View.extend({className:"textarea-with-menu",events:{'click input[name="_post_type"]':"onMenuClicked","olv:painting:start":"paint","click .textarea-memo-preview":function(){this.$el.trigger("olv:painting:start")}},initialize:function(){this.painting=this.$('form input[name="painting"]'),this.paintingPreview=this.$(".textarea-memo-preview"),this.body=this.$('input[name="body"], textarea[name="body"]'),cave.memo_hasValidImage()&&this.previePaint();var e=this.$('input[name="_post_type"]:checked');this.toggleMenu(e)},onMenuClicked:function(e){var t=$(e.target);this.toggleMenu(t),"painting"===t.val()?this.$el.trigger("olv:painting:start"):this.inputTextBody(),this.$el.trigger("olv:textarea:menu:change")},toggleMenu:function(e){var t="body"===e.val();this.$el.toggleClass("active-text",t),this.$el.toggleClass("active-memo",!t),this.$('input[name="body"], textarea[name="body"]').prop("disabled",!t),this.painting.prop("disabled",t)},inputTextBody:function(){setTimeout($.proxy(function(){var e=cave.swkbd_callFullKeyboard(this.body.val(),+this.body.attr("maxlength")||200,0,!1,!0,!0);null!=e&&(this.body.val(e),this.body.trigger("input"))},this),0)},paint:function(){setTimeout($.proxy(function(){cave.memo_open(),cave.memo_hasValidImage()&&(this.previePaint(),this.$el.trigger("olv:painting:end"))},this),0)},previePaint:function(){var e=cave.memo_getImageBmp(),t="data:image/bmp;base64,"+e;this.paintingPreview.css("background-image","url("+t+")"),this.painting.val(e)}}),e.View.Widget.UpdateChecker=Backbone.View.extend({events:{"olv:updatechecker:update":"onUpdate"},onUpdate:function(t,i){var o=e.UpdateChecker.getInstance();$.each(o._settings,function(e,t){$.each(t.params,function(e,t){null==i[e]&&(this.success=!1)}),t.update.call(void 0,i,t.params)})},initialize:function(){var t=e.UpdateChecker.getInstance();e.View.Widget.UpdateChecker.isInvoked||(t.onUpdate("checkupdate",{news:{},admin_message:{},mission:{}},function(t,i){var o=0;$.each(i,function(e,i){o+=Number(t[e].unread_count)}),e.Toolbar.setNotificationCount(o)}),e.View.Widget.UpdateChecker.isInvoked=!0),t.invoke(),$(document).one("olv:pagechange:end",function(e,i){t.pjaxLoadLog=i?i.join(","):""}),$(document).one("olv:pagechange:start",function(){t.clearTimeout()})}},{isInvoked:!1}),e.View.Widget.GuestDialog=Backbone.View.extend({events:{"click .guest-dialog":"onButtonClick"},onButtonClick:function(t){t.preventDefault(),e.deferredConfirm(null,e.loc("olv.portal.guest.alert.message")).done(function(e){e&&cave.jump_toAccount(0)})}}),e.View.Widget.AgeGateDialog=Backbone.View.extend({events:{"click .age-confirm-button":"onAgeConfirmButton","mousedown .age-gate select":"onMousedownSelect","change .age-gate select":"onChangeSelect","click .cancel-button":function(){e.Browsing.goBack()}},initialize:function(){$("#body").children().filter(function(){return!$(this).hasClass("age-gate-dialog")}).hide(),this.$day=this.$(".day"),this.$month=this.$(".month"),this.$year=this.$(".year")},validateDate:function(e,t,i){if(isNaN(e)||isNaN(t)||isNaN(i))return!1;var o=new Date(e,t-1,i);return o.getFullYear()===e&&o.getMonth()+1===t&&o.getDate()===i},calculateAge:function(e,t,i){var o=new Date,n=100*t+i>100*(o.getMonth()+1)+o.getDate()?1:0;return o.getFullYear()-e-n},validateAge:function(e,t,i){return this.calculateAge(e,t,i)>=18},defaultDate:{year:1990,month:1,day:1},selectDefault:function(e,t){var i=this.defaultDate[t],o=$(e[0].options[e[0].selectedIndex]);isNaN(o.val())&&(e.find('[value="'+i+'"]').prop("selected",!0),e.trigger("change"),this.adjustDay(),o.remove())},onMousedownSelect:function(e){var t=$(e.currentTarget);this.selectDefault(t,t.attr("name"))},adjustDay:function(){var e=this.$day,t=+e.val(),i=+this.$month.val(),o=+this.$year.val();if(!isNaN(i)){var n=new Date(o,i,0).getDate(),a=+e.find("option").last().val();if(a>n)$(Array.prototype.slice.call(e[0].options,n-a)).remove();else if(a
").val(s).text(s));!isNaN(t)&&t>n&&(e.find('[value="'+n+'"]').prop("selected",!0),e.trigger("change"))}},passAgeGate:function(){this.$el.remove(),$("#body").children().show(),e.Cookie.set("age_gate_done","1")},onChangeSelect:function(e){this.adjustDay()},onAgeConfirmButton:function(t){var i=+this.$year.val(),o=+this.$month.val(),n=+this.$day.val();e.Cookie.get("age_gate_done")?this.passAgeGate():this.validateDate(i,o,n)?this.validateAge(i,o,n)?this.passAgeGate():(this.$(".age-gate").addClass("none"),this.$(".back-dialog").removeClass("none")):e.deferredAlert(null,e.Locale.text("olv.portal.age_gate.select_label"))}}),e.View.Widget.HiddenContent=Backbone.View.extend({className:"post multi-timeline-post",events:{"click .hidden-content-button":"onHiddenClick"},onHiddenClick:function(e){var t=$(e.currentTarget),i=t.closest(".hidden");i.removeClass("hidden"),i.filter("[data-href-hidden]").add(i.find("[data-href-hidden]")).each(function(){var e=$(this);e.attr(e.is("a")?"href":"data-href",e.attr("data-href-hidden"))}),t.closest(".hidden-content").remove()}}),e.View.Widget.YoutubeJump=Backbone.View.extend({events:{click:"onClick"},onClick:function(t){t.preventDefault();var i=$(t.currentTarget),o=cave.jump_getYoutubeVersion(),n=i.attr("data-jump-query");-1!==o?o<1024?e.deferredAlert(null,e.loc("olv.portal.n3ds.youtube.alert.patch")):cave.jump_suspendedYoutube()?e.deferredConfirm(null,e.loc("olv.portal.n3ds.youtube.jump")).done(function(e){e&&cave.jump_toSuspendedYoutube(n)}):setTimeout(function(){cave.jump_toYoutube(1,n)},0):e.deferredAlert(null,e.loc("olv.portal.n3ds.youtube.alert"))}}),e.View.Widget.Reply=Backbone.View.extend({events:{"click .more-button":"onMoreButtonClick"},onMoreButtonClick:function(t){var i=$(t.currentTarget).closest("a");t.preventDefault(),this.loader||e.Form.isDisabled(i)||(e.Loading.lock(),this.loader=e.Form.get(i.attr("href"),null,i,!1).done($.proxy(function(e){var t=$(e);if(i.hasClass("all-replies-button")){i.remove();var o=t.filter(".post-permalink-reply").children().filter(function(){return!$("#"+this.id).length});this.$el.find(".post-permalink-reply").prepend(o)}else this.$el.empty().append(t);i.hasClass("newer-replies-button")?window.scroll(0,this.$el.offset().top):(i.hasClass("older-replies-button")||i.hasClass("newest-replies-button"))&&window.scroll(0,$(document).height())},this)).always($.proxy(function(){i.removeClass("loading"),this.loader=null,setTimeout(function(){e.Loading.unlock()},0)},this)))}}),e.View.Widget.FirstPostNotice=Backbone.View.extend({events:{click:"onTriggerClick"},onTriggerClick:function(t){if($(document.body).attr("data-is-first-post")&&!e.Form.isDisabled(this.$el)){var i=$(t.currentTarget);t.preventDefault(),i.removeAttr("data-pjax"),e.deferredAlert(null,e.loc("olv.portal.confirm_display_played_mark")).done(function(){i.attr("data-pjax","1");var e=i.attr("data-sound");i.attr("data-sound",""),i.trigger("click"),i.attr("data-sound",e)}),$(document.body).removeAttr("data-is-first-post"),$.post("/settings/struct_post").fail(function(){$(document.body).attr("data-is-first-post","1")})}}}),e.View.Widget.Empathy=Backbone.View.extend({className:"post",events:{"click .empathy-button":"onEmpathyClick","olv:entry:empathy:toggle":"onEmpathyToggle","olv:entry:empathy:toggle:fail":"onEmpathyToggle"},isEmpathyAdded:function(e){return e.hasClass("empathy-added")},onEmpathyClick:function(t){var i=$(t.currentTarget);if(!(e.Form.isDisabled(i)||e.Guest.isGuest()||t.defaultPrevented)){var o=this.isEmpathyAdded(i),n=!o,a=i.attr("data-action");return i.trigger("olv:entry:empathy:toggle",[n]),o&&(a+=".delete"),e.Form.post(a,null,i).done(function(){i.trigger("olv:entry:empathy:toggle:done",[n])}).fail(function(){i.trigger("olv:entry:empathy:toggle:fail",[o])})}},onEmpathyToggle:function(e,t){var i,o=$(e.target);this.toggleButtonStatus(o,t),(i=o.hasClass("reply")?o.closest(".reply-meta").find(".empathy-count"):o.closest(".post-meta").find(".empathy-count")).text(+i.text()+(t?1:-1))},toggleButtonStatus:function(t,i){t.toggleClass("empathy-added",i),t.attr("data-sound",i?"SE_OLV_MII_ADD":"SE_OLV_CANCEL");var o=t.attr("data-feeling")||"normal";t.find(".empathy-button-text").text(e.loc("olv.portal.miitoo."+o+(i?".delete":"")))}}),e.View.Widget.ImageViewer=Backbone.View.extend({events:{"click a":"onScreenshotClick"},onScreenshotClick:function(t){if(e.router.lockRequest)return!1;e.router.lockRequest=!0,cave.brw_notifyPageMoving()}}),e.View.Widget.EmpathyWithIcons=e.View.Widget.Empathy.extend({initialize:function(){e.View.Widget.Empathy.prototype.initialize.call(this);var t=this.$(".empathy-button"),i=this.isEmpathyAdded(t);this.updateIcons(t,i)},onEmpathyToggle:function(e,t){var i=$(e.target);this.toggleButtonStatus(i,t),this.updateIcons(i,t)},updateIcons:function(t,i){var o=$("#empathy-content"),n=+t.attr("data-other-empathy-count"),a=n>0?e.loc_n(i?"olv.portal.empathy.you_and_n_added":"olv.portal.empathy.n_added",n,n):i?e.loc("olv.portal.empathy.you_added"):"";o.toggle(!!a),o.find(".post-permalink-feeling-text").text(a),o.find(".visitor").toggle(i),o.find(".extra").toggle(!i)}}),e.View.Widget.ConfirmBlacklist=Backbone.View.extend({events:{"click .unblock-button, .block-button":"onButtonClick","click .cancel-button":function(){e.Browsing.goBack()}},onButtonClick:function(t){var i=$(t.currentTarget),o=i.hasClass("block"),n=i.attr("data-action"),a=i.attr("data-screen-name"),s=o?{title:e.loc("olv.portal.blocklist.add"),body:e.loc("olv.portal.blocklist.block_successed_to",a)}:{title:e.loc("olv.portal.blocklist.delete"),body:e.loc("olv.portal.blocklist.unblock_successed_to",a)};e.Net.ajax({type:"POST",url:n,lock:!0}).done(function(){e.alert(s.title,s.body);var t=i.attr("data-user-url");location.protocol+"//"+location.host+t===cave.history_getPrev()&&cave.history_removePrev(),e.Browsing.replaceWith(t)})}}),e.View.Widget.Blacklist=Backbone.View.extend({events:{"click .unblock-button, .block-button":"onButtonClick"},onButtonClick:function(t){var i=$(t.currentTarget),o=i.hasClass("block"),n=i.attr("data-screen-name"),a=o?{title:e.loc("olv.portal.blocklist.add"),body:e.loc("olv.portal.blocklist.block_confirm_to.for_n3ds",n),back:e.loc("olv.portal.back"),ok:e.loc("olv.portal.block"),done:e.loc("olv.portal.blocklist.block_successed_to",n)}:{title:e.loc("olv.portal.blocklist.delete"),body:e.loc("olv.portal.confirm.remove_from_blocklist_to",n),back:e.loc("olv.portal.back"),ok:e.loc("olv.portal.button.remove"),done:e.loc("olv.portal.blocklist.unblock_successed_to",n)};e.deferredConfirm(a.title,a.body,a.back,a.ok).done(function(t){if(t){var o=i.attr("data-action");e.Form.post(o,null,i,!0).done(function(){e.alert(a.title,a.done),e.Browsing.replaceWith(location.pathname)}).fail(function(t,i,o,n){n&&o.status&&503!==o.status&&e.Browsing.replaceWith(location.pathname)})}})}}),e.View.Widget.Follow=Backbone.View.extend({events:{"click .unfollow-button, .follow-button":"onButtonClick"},onButtonClick:function(t){var i=$(t.currentTarget);if(!(e.Form.isDisabled(i)||e.Guest.isGuest()||t.defaultPrevented)){var o,n=i.hasClass("unfollow-button"),a="",s="";if(n){a=i.attr("data-screen-name"),s=e.loc("olv.portal.unfollow");var r=e.loc("olv.portal.followlist.confirm_unfollow_to",a);o=e.deferredConfirm(s,r,e.loc("olv.portal.back"),e.loc("olv.portal.button.remove"))}else o=$.Deferred().resolve(!0);o.done(function(t){if(t){var o=i.attr("data-action");e.Form.post(o,null,i,!0).done(function(){n&&e.alert(s,e.loc("olv.portal.unfollow_succeeded_to",a)),i.addClass("none").siblings().removeClass("none"),i.hasClass("relation")&&e.Browsing.replaceWith(location.href)})}})}}}),e.View.Widget.FavoriteButtons=Backbone.View.extend({events:{"click .favorite-button":"onFavoriteClick"},onFavoriteClick:function(t){t.preventDefault();var i=$(t.currentTarget);if(!e.Form.isDisabled(i)){var o=i.hasClass("checked"),n=i.attr(o?"data-action-unfavorite":"data-action-favorite");this.toggleFavoriteButton(i,!o),$(document.body).attr("data-is-first-favorite")&&!o&&e.deferredAlert(null,e.loc("olv.portal.confirm_first_favorite")).done(function(){$(document.body).removeAttr("data-is-first-favorite")});var a=this;e.Form.post(n,null,i).done(function(){o=!o,i.trigger("olv:community:favorite:toggle",[o])}).fail(function(){a.toggleFavoriteButton(i,o)})}},toggleFavoriteButton:function(e,t){e.toggleClass("checked",t),e.attr("data-sound",t?"SE_OLV_CHECKBOX_CHECK":"SE_OLV_CHECKBOX_UNCHECK")}}),e.View.Widget._Search=Backbone.View.extend({onInput:function(t){var i=$(t.currentTarget),o=i.attr("data-action"),n=i.val();n&&(i.val(""),e.Browsing.navigate(o+"?"+i.attr("name")+"="+encodeURIComponent(n)))}}),e.View.Widget.UserSearch=e.View.Widget._Search.extend({className:"user-search-button",events:{"input .user-search-user-id":"onInput"}}),e.View.Widget.TitleSearch=e.View.Widget._Search.extend({className:"title-search-button",events:{"input .title-search-title-id":"onInput"}}),e.View.Widget.InfoTicker=Backbone.View.extend({events:{"click a[href]":"onTickerClick"},initialize:function(){var e=this.$el,t="last-seen."+e.attr("data-olive-title-id"),i=+cave.ls_getItem(t)||0,o=+e.attr("data-last-seen")||0;o>i&&(i=o,cave.ls_setItem(t,""+i)),i<+e.attr("data-last-posted")?e.removeClass("none"):e.remove()},onTickerClick:function(t){var i=$(t.currentTarget);if(!e.Form.isDisabled(i)&&!t.defaultPrevented){if(i.attr("data-pjax")){var o=this;$(document).one("olv:pjax:end olv:pjax:error",function(){o.$el.remove()})}else t.preventDefault(),this.$el.remove();var n="last-seen."+this.$el.attr("data-olive-title-id");cave.ls_setItem(n,""+Math.floor(+new Date/1e3)),!e.Guest.isGuest()&&this.$el.attr("data-is-of-miiverse")&&$.post("/settings/miiverse_info_post")}}}),e.View.Widget.ExitOrBackButton=Backbone.View.extend({initialize:function(){var t=location.pathname,i=location.search,o=$("body").attr("data-profile-url"),n=new RegExp("^(/|/communities|/friend_messages|/guide/for_guest|/news/.+|"+o+"|/welcome/profile)$"),a="1"===e.URI.getQueryVars()._cannot_back,s=(!n.test(t)||/^\/$/.test(t)&&/^\?.*page_param=/.test(i))&&cave.history_getBackCount()>0&&!a,r=e.Toolbar;r.setCornerButtonType(s?r.buttons.BACK:r.buttons.EXIT)}}),e.View.Widget.ToolbarVisibility=Backbone.View.extend({initialize:function(){var t=!/^\/(?:titles\/.+\/.+\/(?:topic\/|artwork\/)?(?:post)|users\/.+\/diary\/post|posts\/.+\/reply|welcome\/(?:3ds|redesign_tutorial)?|warning\/.+|welcome|register|login|titles\/.+\/select_album_image)$/.test(location.pathname);e.Toolbar.setVisible(t)}}),e.View.Widget.HomeButton=Backbone.View.extend({initialize:function(){cave.home_setEnabled&&(/^\/(?:titles\/.+\/.+\/(?:topic\/|artwork\/)?(?:post)|users\/.+\/diary\/post|posts\/.+\/reply)$/.test(location.pathname)?cave.home_setEnabled(0):cave.home_setEnabled(1))}}),e.View.Widget.SelectButtons=Backbone.View.extend({events:{"change select":"onSelectChange"},onSelectChange:function(e){var t=$(e.currentTarget);this.updateLabel(t)},updateLabel:function(e){var t=e[0].options[e[0].selectedIndex];e.siblings(".select-button-content").text(t.text)}}),e.View.Widget.SelectableElements=Backbone.View.extend({events:{"change select":"onSelectChange"},initialize:function(){var e=this;e.$el.find("select").each(function(){e.updateClass($(this))})},updateClass:function(e){var t=!!e.val();e.parent().toggleClass("selected",t)},onSelectChange:function(e){var t=$(e.currentTarget);this.updateClass(t)}}),e.View.Widget.URLSelector=e.View.Widget.SelectableElements.extend({onSelectChange:function(t){e.View.Widget.SelectableElements.prototype.onSelectChange.call(this,t);var i=$(t.currentTarget).val();i&&e.Browsing.navigate(i)}}),e.View.Widget.eShopJump=Backbone.View.extend({events:{click:"onClick"},onClick:function(t){t.preventDefault();var i=$(t.currentTarget).attr("data-dst-title-id");i&&e.deferredConfirm(null,e.loc("olv.portal.confirm_open_eshop")).done(function(e){cave.jump_toShop(1,i)})}}),e.View.Widget.CheckableControls=Backbone.View.extend({events:{"click input":"onClick"},initialize:function(){("input"===this.el.tagName.toLowerCase()?this.$el:this.$("input:checked")).each(function(){e.Form.updateParentClass(this)})},onClick:function(t){e.Form.updateParentClass(t.currentTarget)}}),e.View.Widget.FreshPost=Backbone.View.extend({initialize:function(){var t=e.View.Widget.FreshPost.stock.shift();if(t){var i=!!$("#"+t.attr("data-id")).length,o=this.isInAppropriatePage(t);!i&&o&&this.insertPost(t);var n=+t.attr("data-requires-to-scroll");o&&n&&this.scrollToPost(t)}},isInAppropriatePage:function(e){var t=e.attr("data-post-subtype-id"),i=+this.$el.attr("data-is-visitors-diary-posts");if("diary_post"===t&&i)return!0;var o=e.attr("data-olv-community-id");return!!o&&o===this.$el.attr("data-olv-community-id")},insertPost:function(e){var t=this.$el.next();t.length&&t.hasClass("no-content-window")&&t.remove(),this.el.insertAdjacentHTML("afterbegin",e.prop("text"))},scrollToPost:function(t){var i=e.ScrollGuide.WINDOW_INNER_HEIGHT/2-20,o=$("#"+t.attr("data-id"));o.length&&$(document).one("olv:pagechange:end",function(){setTimeout(function(){cave.brw_scrollImmediately(0,o.offset().top-i),o.attr("data-test-scrolled","1")},5)})}}),e.View.Widget.FreshPost.stock=[],e.View.Widget.FreshReply=e.View.Widget.FreshPost.extend({isInAppropriatePage:function(e){var t=e.attr("data-parent-post-id");return!!t&&t===this.$el.attr("data-parent-post-id")},insertPost:function(e){this.el.insertAdjacentHTML("beforeend",e.prop("text"))}}),e.View.Widget.PostScroller=Backbone.View.extend({events:{keydown:"onKeyDown"},initialize:function(){this.offset=224,this.lastScrollTop=0},onKeyDown:function(e){82===e.which?this.scrollToNearestElement(!1):76===e.which&&this.scrollToNearestElement(!0)},scrollToNearestElement:function(e){var t,i=this.$(".scroll:not(.none)"),o=null,n=this,a=cave.brw_getScrollTopY(),s=document.body.scrollHeight;if(s-a<=460&&s-this.lastScrollTop<=460&&(a=this.lastScrollTop),i.each(function(){var t=$(this),i=t.offset().top-(a+n.offset);if(e){if(i>=0)return!1;o=t}else if(i>0)return o=t,!1}),o){var r="a"===o[0].nodeName.toLowerCase()?o:o.find(".scroll-focus").first(),l=r.prop("type");"text"===l||"textarea"===l?(r.attr("open","false"),r.focus(),r.removeAttr("open")):r.focus(),t=o.offset().top-n.offset,o.trigger("olv:keyhandler:scroll:element")}else t=e?0:s,$(document.activeElement).blur(),$(document).trigger("olv:keyhandler:scroll:document");return window.scrollTo(0,t),this.lastScrollTop=t,o}}),e.View.Widget.PageReloader=Backbone.View.extend({events:{keydown:"onKeyDown"},onKeyDown:function(t){89===t.which&&($(document).trigger("olv:pagereloader:reload"),e.Browsing.reload())}}),e.View.Widget.Dropdown=Backbone.View.extend({className:"dropdown",events:{"click .dropdown-toggle":"onToggleClick"},initialize:function(){this.isOpen=this.$el.hasClass("open"),this.eventNS=".delegateEvents"+this.cid,this.$toggle=this.$(".dropdown-toggle").first(),this.$menu=this.$(".dropdown-menu").first()},open:function(e){if(!this.isOpen){this.isOpen=!0,this.$el.addClass("open"),this.$el.trigger("olv:dropdown:open",[this,e||null]);var t="click"+this.eventNS,i=$.proxy(this.onBodyClick,this);setTimeout(function(){$(document.body).on(t,i)})}},close:function(e){this.isOpen&&(this.isOpen=!1,this.$el.removeClass("open"),this.$el.trigger("olv:dropdown:close",[this,e||null]),$(document.body).off(this.eventNS))},isClosableElement:function(e){for(var t=this.$menu[0];e&&e!==t;e=e.parentNode){var i=e.nodeName.toLowerCase();if("input"===i||"button"===i||"a"===i)return!0}return!1},onToggleClick:function(e){e.preventDefault(),this.$el.hasClass("disabled")||this.isOpen||this.open(this.$toggle[0])},onBodyClick:function(e){var t=e.target,i=this.$menu[0];(i!==t&&!$.contains(i,t)||this.isClosableElement(t))&&this.close(t)},undelegateEvents:function(){this.close(),Backbone.View.prototype.undelegateEvents.call(this)}}),e.View.Widget.CloseTutorial=Backbone.View.extend({events:{click:"onCloseTutorialClick"},onCloseTutorialClick:function(t){var i=$(t.currentTarget);if(i.parent().hide(),i.attr("data-tutorial-name"))e.Net.post("/settings/tutorial_post",{tutorial_name:i.attr("data-tutorial-name")}).done(function(){});else if(i.attr("data-achievement-name")){var o=i.attr("data-achievement-name").split(/\s*,\s*/);e.Achievement.requestAchieveWithoutRegard(o)}t.preventDefault()}}),e.View.Widget.PostToBack=Backbone.View.extend({events:{submit:"onSubmit"},onSubmit:function(t){t.preventDefault();var i=$(t.currentTarget),o=i.find('input[type="submit"]');e.Form.submit(i,o,!0).done(function(){history.back()})}}),e.View.Widget.BodyLanguageSelector=Backbone.View.extend({events:{"change select":"onSelectChange"},onSelectChange:function(e){var t=$(e.currentTarget).val();$("#body-language-"+t).toggleClass("none",!1).siblings(".multi-language-body").toggleClass("none",!0)}}),e.View.Widget.MoreContentButton=Backbone.View.extend({events:{"click .more-content-button":"onMoreContentButton"},initialize:function(t){var i=this.$el.find(".post-content-text");i&&0!=i.length&&i.each(function(){var t=$(this),i=t.text().match(/([\s\S]+)(\n+---+\n[\s\S]+)/);if(i){t.text(i[1]);var o=$('').text(i[2]);t.append(o);var n=$('');n.text(e.loc("olv.portal.read_more_content")),t.after(n)}})},onMoreContentButton:function(e){e.preventDefault();var t=$(e.currentTarget);t.prev().find(".wrapped").removeClass("none"),t.remove()}}),e.View.Widget.MultipleSelectMediator=Backbone.View.extend({events:{"change select":"onChange"},initialize:function(){var t=this,i=_.map(this.$("select"),function(t){return new e.View.Widget.MultipleSelect({el:t})});this.selectsByName=_.groupBy(i,function(e){return e.el.name}),this.$("select").each(function(){t.imposeDistinctRestrictionOn(this)})},uniq:function(e){return _.chain(e).groupBy(function(e){return e}).keys().value()},buildComplementSelector:function(e){return e.map(function(e){return":not("+e+")"}).join("")},onChange:function(e){this.imposeDistinctRestrictionOn(e.currentTarget)},imposeDistinctRestrictionOn:function(t){var i=t.name,o=t.value,n=this.selectsByName[i],a=n.map(function(e){return e.getSelectedConfigurableOption()}).filter(function(e){return e}),s=this.uniq(a.map(function(e){return e.value})),r=n.filter(function(e){return e.el!==t}),l={enableOptionsSelector:"option"+this.buildComplementSelector(s.map(function(e){return"[value="+e+"]"}))};new e.View.Widget.MultipleSelect({el:t}).getSelectedConfigurableOption()&&(l.disableOptionsSelector="option[value="+o+"]"),r.forEach(function(e){e.$el.trigger("olv:select:change",l)})}}),e.View.Widget.MultipleSelect=Backbone.View.extend({events:{"olv:select:change":"onChanged"},getSelectedConfigurableOption:function(){return _.find(this.$el.find("option").toArray(),function(e){return e.selected&&e.hasAttribute("data-is-configurable")})},enableOptions:function(e){this.$el.find(e).prop("disabled",!1)},disableOptions:function(e){this.$el.find(e).prop("disabled",!0)},onChanged:function(e,t){"enableOptionsSelector"in t&&this.enableOptions(t.enableOptionsSelector),"disableOptionsSelector"in t&&this.disableOptions(t.disableOptionsSelector)}}),e.View.Widget.AchievementUpdater=Backbone.View.extend({events:{"olv:achievement:update":"onAchievementUpdate"},onAchievementUpdate:function(t){var i=$(t.target),o=i.attr("data-achievement-name");o&&e.Achievement.requestAchieveWithoutRegard([o]).done(function(e){i.trigger("olv:achievement:update:done",[e])})}}),e.View.Page.AlbumDetail=e.View.Page.Common.extend({events:{"click .js-album-delete-button":"onDeleteAlbumClick"},initialize:function(){e.View.Page.Common.prototype.initialize.call(this),this.widgets.push(new e.View.Widget.URLSelector({el:$("#post-target-selector")}))},onDeleteAlbumClick:function(t){var i=$(t.currentTarget.form),o=$(t.currentTarget).find(".js-album-delete-button");e.Form.isDisabled(o)||t.defaultPrevented||(t.preventDefault(),e.confirm(null,e.loc("olv.portal.album.delete_confirm"))&&e.Form.submit(i,o,!0).done(function(e){history.back()}))}}),e.View.Widget.CreateDiaryOrSaveScreenshotWindow=Backbone.View.extend({events:{"click .js-edit-diary-button":"onPostDiaryClick","click .js-save-album-button":"onSaveScreenshotClick"},initialize:function(){if(+this.$el.attr("data-can-create")){var e=this.setupScreenshotSelector();e.hasImage&&this.$el.toggleClass("no-screenshots",!1);var t=this;e.loadDeferred.then(function(){t.toggleActionEnabled(!0)})}this.$el.toggleClass("none",!1)},toggleActionEnabled:function(e){if(!+this.$el.attr("data-is-readonly")||!e){var t=this.$el.find(".js-edit-diary-button"),i=this.$el.find(".js-save-album-button");t.toggleClass("disabled",!e),i.toggleClass("disabled",!e)}},setupScreenshotSelector:function(){var t=this.$el.find(".js-diary-screenshot-window-image-container").find(".js-screenshot-capture-button"),i=[];t.each(function(t,o){var n=$(o),a=e.Screenshot[n.hasClass("js-upside")?"SCREEN_UPSIDE":"SCREEN_DOWNSIDE"];if(e.Screenshot.isEnabled(a)){var s=e.Screenshot.retrieveImagePath(a);if(s){var r=n.find("img"),l=$.Deferred();r.one("load",function(){setTimeout(l.resolve,300)}),i.push(l),r.prop("src",s),n.find('input[type="radio"]').prop("disabled",!1)}}});var o,n=i.length>0;if(n){for(var a=0,s=t.length;a").html(e).find("#body");document.body.replaceChild(i[0],t[0])},e.Form={toggleDisabled:function(t,i){var o=void 0===i;return t.each(function(){var t=$(this),n=o?!e.Form.isDisabled(t):i;if(t.toggleClass("disabled",n),void 0!==this.form)t.prop("disabled",n);else{var a=n?"href":"data-disabled-href",s=n?"data-disabled-href":"href",r=t.attr(a);void 0!==r&&(t.removeAttr(a),t.attr(s,r))}}),t},isDisabled:function(e){return e.length&&void 0!==e[0].form?e.prop("disabled"):e.hasClass("disabled")},disable:function(t,i){return e.Form.toggleDisabled(t,!0),i.always(function(){e.Form.toggleDisabled(t,!1)}),t},submit:function(e,t,i,o){e.trigger("olv:form:submit",[t||$()]);var n=e.serializeArray(),a=t&&t.is("input, button")&&t.prop("name");a&&n.push({name:a,value:t.val()});var s={type:e.prop("method"),url:e.attr("action"),data:n,lock:i};return o||(s.headers={"X-Requested-With":""}),this.send(s,t)},get:function(e,t,i,o){var n={type:"GET",url:e,data:t,lock:o};return this.send(n,i)},post:function(e,t,i,o){var n={type:"POST",url:e,data:t,lock:o};return this.send(n,i)},send:function(t,i){var o=e.Net.ajax(t);return $(document).trigger("olv:form:send",[o,t,i||$()]),i&&(e.Form.disable(i,o),i.addClass("loading"),o.always(function(){i.removeClass("loading")})),o},updateParentClass:function(e){switch(e.type){case"radio":var t;if(e.form){var i=e.form.elements[e.name];t=i.length?$(Array.prototype.slice.call(i)):$(i)}else t=$('input[name="'+e.name+'"]');t.each(function(){$(this).parent().toggleClass("checked",this.checked)});break;case"checkbox":$(e).parent().toggleClass("checked",e.checked)}},setup:function(){$(document).on("olv:form:send",function(t,i,o){"POST"===(o.type||"").toUpperCase()&&e.Pjax.cacheClear()})},reset:function(t){t.each(function(){this.reset(),$(this).find("input").each(function(){e.Form.updateParentClass(this)})})},serializeUserInputs:function(e){var t={};return e.$("[data-save-user-input]").each(function(){var e=$(this);if("checkbox"!==e.attr("type")&&"radio"!==e.attr("type")||e.prop("checked")){var i='[name="'+e.attr("name")+'"]';t[i]=e.val()}}),t},fillInputsWithSerializedObject:function(t,i){for(var o in i){var n=i[o],a=t.$(o);"checkbox"===a.attr("type")||"radio"===a.attr("type")?(a.prop("checked",!1).filter('[value="'+n+'"]').prop("checked",!0),e.Form.updateParentClass(a.get(0))):a.val(n)}}},e.Form.setup(),e.Guest={isGuest:function(){return $("#body").hasClass("guest")}},e.Sound={defaultActivationSound:"SE_OLV_OK",playActivationSound:function(e){var t=e.attr("data-sound");""!==t&&this.playSound(t||this.defaultActivationSound)},playSound:function(e){cave.snd_playSe(e)},playBGM:function(e){cave.snd_playBgm(e)},playBGMByPath:function(e){var t=/^\/welcome\//.test(e)?"BGM_CAVE_SYOKAI":/^\/(?:settings(?:\/|$)|help\/|guide\/)/.test(e)?"BGM_CAVE_SETTING":"BGM_CAVE_MAIN";this.playBGM(t)},activationTarget:null,onPreActivate:function(e){for(var t=!1,i=e.target,o=document.body;i&&i!==o;i=i.parentNode){var n=i.nodeName.toLowerCase();if("a"===n){t=!!i.href;break}if("input"===n){var a=i.type;t="text"!==a&&"password"!==a&&"file"!==a&&!i.disabled;break}if("button"===n){t=!i.disabled;break}if("textarea"===n||"select"===n)break;var s=" "+i.className+" ";if(s.indexOf(" trigger ")>=0){t=s.indexOf(" disabled ")<0;break}}this.activationTarget=t?i:null},onActivate:function(e){var t=this.activationTarget;this.activationTarget=null,t&&this.playActivationSound($(t))},onPageChange:function(){this.playBGMByPath(location.pathname)},onScrollElement:function(){this.playSound("SE_WAVE_SCROLL_PAGE_LR")},onScrollDocument:function(){this.playSound("SE_WAVE_SCROLL_LIMIT_LR")},onPageReload:function(e){this.playSound("SE_OLV_RELOAD")},onDropdownOpen:function(e,t,i){t.$toggle.attr("data-sound","SE_OLV_BALLOON_OPEN")},onDropdownClose:function(e,t,i){t.$toggle.attr("data-sound","SE_OLV_BALLOON_CLOSE"),this.activationTarget||this.playSound("SE_OLV_BALLOON_CLOSE")},setup:function(){document.addEventListener("click",$.proxy(this.onPreActivate,this),!0),document.addEventListener("click",$.proxy(this.onActivate,this),!1);var e=$(document);e.on("olv:pagechange:ready",$.proxy(this.onPageChange,this)),this.onPageChange(),e.on("olv:keyhandler:scroll:element",$.proxy(this.onScrollElement,this)),e.on("olv:keyhandler:scroll:document",$.proxy(this.onScrollDocument,this)),e.on("olv:pagereloader:reload",$.proxy(this.onPageReload,this)),e.on("olv:dropdown:open",$.proxy(this.onDropdownOpen,this)),e.on("olv:dropdown:close",$.proxy(this.onDropdownClose,this))}},e.Sound.setup(),e.ScrollGuide={WINDOW_INNER_HEIGHT:480,activate:function(){var e=this,t=history.state?history.state.id:null;$(document).one("olv:router:dispatch:end",function(){setTimeout(function(){var i=history.state?history.state.id:null;document.body.clientHeight>e.WINDOW_INNER_HEIGHT&&cave.brw_getScrollTopY()<=0&&t===i&&e.show()},1500)})},show:function(){e.Toolbar.isVisible()?cave.effect_setScrollGuideOffsetPos(0,28):cave.effect_setScrollGuideOffsetPos(0,0),cave.effect_scrollGuide(1)},hide:function(){cave.effect_scrollGuide(0)}},e.URI={getQueryVars:function(){for(var e,t={},i=window.location.href,o=i.slice(i.indexOf("?")+1).split("&"),n=0;n "+t),i.replace=!0);var a={id:e.Pjax.uniqueId(),url:t,fragment:o,scrollTo:0,replace:!!i.replace};Backbone.Router.prototype.navigate.call(this,o,_.extend({},i,{trigger:!1})),window.history.replaceState(a,null,t),e.History.needToSetState&&(history.state=a),i.trigger&&Backbone.history.loadUrl(o),e.History.isInitialLoad=!1}else Backbone.Router.prototype.navigate.call(this,o,i)}},route:function(t,i,o){return _.isFunction(i)||o||(o=this[i]),Backbone.Router.prototype.route.call(this,t,i,function(){function t(){e.Router.prototype._isSameUrl(r,history.state.url)?o&&o.apply(n,a):e.Router.prototype._routeManually(Backbone.history.getFragment()),$(document).trigger("olv:router:dispatch:end")}var n=this,a=arguments;if(n.isReverting)return n.isReverting=!1,void $(document).trigger("olv:pagechange:end");console.log("Routing: "+Backbone.history.fragment+" -> "+i);var s=e.History.state?e.History.state.id>history.state.id?"back":history.state.replace?"replace":"forward":void 0,r=history.state.url;e.History.isInitialLoad?t():e.Pjax.go(history.state.url,{direction:s,cacheId:history.state.id}).done(t)})},_isSameUrl:function(e,t){return e&&t&&e.replace(/%20/g,"+")===t.replace(/%20/g,"+")},_routeManually:function(t){var i,o=(t||"").replace(/\?.*/,""),n=_.find(this.routes,function(e,t){return(i=Backbone.Router.prototype._routeToRegExp(t)).test(o)}),a=Backbone.Router.prototype._extractParameters(i,o);_.isFunction(n)?n.apply(e.router,a):this[n]&&this[n].apply(e.router,a)}}),e.Router=e.Router.extend({routes:{"":"activity",communities:"communities","communities/categories/:category":"communities","communities/favorites":"communities",identified_user_posts:"identifiedUserPosts","titles/:titleId/:communityId/post":"postForm","titles/:titleId/:communityId/topic/post":"postForm","titles/:titleId/:communityId/artwork/post":"postForm","titles/:titleId/:communityId/post_memo":"postMemo","titles/:titleId/:communityId/artwork/post_memo":"postMemo","titles/:titleId/select_album_image":"postFormAlbumSelector","users/:userId/diary/post_memo":"postMemo",post_memo:"postMemo","titles/:titleId/:communityId":"community","titles/:titleId/:communityId/new":"community","titles/:titleId/:communityId/hot":"community","titles/:titleId/:communityId/diary":"community","titles/:titleId/:communityId/topic":"community","titles/:titleId/:communityId/topic/new":"community","titles/:titleId/:communityId/topic/open":"community","titles/:titleId/:communityId/artwork":"community","titles/:titleId/:communityId/artwork/new":"community","titles/:titleId/:communityId/artwork/hot":"community","titles/:titleId/:communityId/in_game":"community","titles/:titleId/:communityId/old":"community","titles/search":"titleSearch","posts/:postId":"post","posts/:postId/reply":"replyForm","posts/:postId/violations.create":"violation","replies/:postId/violations.create":"violation","posts/:postId/edit":"editForm","replies/:postId/edit":"editForm",posts:"postProcess",diary_posts:"postProcess",artwork_posts:"postProcess",topic_posts:"postProcess","posts/:postId/replies":"postProcess","replies/:postId":"reply","users/:userId":"user","users/:userId/posts":"user","users/:userId/diary":"userDiary","users/:userId/diary/post":"postDiaryForm","users/:userId/empathies":"user","users/:userId/following":"user","users/:userId/followers":"user","users/:userId/violators.create":"violation","users/:userId/blacklist.confirm":"confirmBlacklist","users/:userId/album/:albumImageId":"albumDetail","users/:userId/album.confirm":"confirmAlbum","settings/account":"accountSettings","settings/profile":"profileSettings","settings/:page":"settings","settings/titles/:titleId":"settings","admin_messages.post":"violation",my_blacklist:"blacklist","welcome/(3ds)":"welcome","welcome/profile":"welcomeProfile",welcome_guest:"guestWelcome",welcome:"welcomePage","welcome/favorite_community_visibility":"welcomeFavoriteCommunityVisibility",users:"users","news/my_news":"my_news","warning/:page":"warning","error/post_form/:page":"errorPostForm","help/(:page)":"help","guide/(:page)":"guide","*path":"defaultRoute"},defaultRoute:function(t){new e.View.Page.Common({el:"body"})},activity:function(){new e.View.Page.Activity({el:"body"})},communities:function(){new e.View.Page.Communities({el:"body"})},postForm:function(){new e.View.Page.PostForm({el:"body"})},postDiaryForm:function(){new e.View.Page.PostDiaryForm({el:"body"})},replyForm:function(){new e.View.Page.ReplyForm({el:"body"})},postMemo:function(){new e.View.Page.PostMemo({el:"body"})},postProcess:function(){new e.View.Page.PostRedirection({el:"body"})},postFormAlbumSelector:function(){new e.View.Page.PostFormAlbumSelector({el:"body"})},violation:function(){new e.View.Page.Violation({el:"body"})},editForm:function(){new e.View.Page.EditForm({el:"body"})},post:function(){new e.View.Page.Post({el:"body"})},reply:function(){new e.View.Page.Reply({el:"body"})},community:function(){new e.View.Page.Community({el:"body"})},titleSearch:function(){new e.View.Page.TitleSearch({el:"body"})},user:function(){new e.View.Page.User({el:"body"})},userDiary:function(){new e.View.Page.UserDiary({el:"body"})},settings:function(){new e.View.Page.Settings({el:"body"})},accountSettings:function(){new e.View.Page.AccountSettings({el:"body"})},profileSettings:function(){new e.View.Page.ProfileSettings({el:"body"})},users:function(){new e.View.Page.Users({el:"body"})},blacklist:function(){new e.View.Page.Blacklist({el:"body"})},confirmBlacklist:function(){new e.View.Page.ConfirmBlacklist({el:"body "})},identifiedUserPosts:function(){new e.View.Page.IdentifiedUserPosts({el:"body"})},my_news:function(){new e.View.Page.MyNews({el:"body"})},welcome:function(){new e.View.Page.Welcome({el:"body"})},guestWelcome:function(){new e.View.Page.GuestWelcome({el:"body"})},welcomeProfile:function(){new e.View.Page.WelcomeProfile({el:"body"})},welcomePage:function(){new e.View.Page.Common({el:"body"})},welcomeFavoriteCommunityVisibility:function(){new e.View.Page.WelcomeFavoriteCommunityVisibility({el:"body"})},warning:function(){new e.View.Page.Warning({el:"body"})},help:function(){new e.View.Page.Help({el:"body"})},guide:function(){new e.View.Page.Common({el:"body"}),$(".guide-exit-button").length&&e.Toolbar.setVisible(!1),e.ScrollGuide.activate()},albumDetail:function(){new e.View.Page.AlbumDetail({el:"body"})},confirmAlbum:function(){new e.View.Page.ConfirmAlbum({el:"body "})},errorPostForm:function(){new e.View.Page.PostFormError({el:"body"})}}))}).call(this,Olv);
\ No newline at end of file