From e8e994d2086c98a6a1bb652e04b87613de99f468 Mon Sep 17 00:00:00 2001 From: Schlaefer Date: Fri, 8 Nov 2013 12:35:00 +0100 Subject: [PATCH] fixes testcases and some cleanup --- app/Controller/SaitosController.php | 2 +- app/webroot/dist/main.js | 8 ++-- app/webroot/js/models/app.js | 2 +- app/webroot/js/models/appStatus.js | 30 ++++++++------ app/webroot/js/test.js | 1 - .../js/tests/models/AppStatusModelSpec.js | 11 +++-- .../js/tests/models/StatusModelSpec.js | 41 ------------------- contributing.md | 2 + 8 files changed, 32 insertions(+), 65 deletions(-) delete mode 100644 app/webroot/js/tests/models/StatusModelSpec.js diff --git a/app/Controller/SaitosController.php b/app/Controller/SaitosController.php index 163bea187..09eb7c118 100644 --- a/app/Controller/SaitosController.php +++ b/app/Controller/SaitosController.php @@ -25,7 +25,7 @@ public function status() { 'lastShoutId' => $this->Shout->findLastId() ]; $data = json_encode($data); - if($this->request->accepts('text/event-streams')) { + if ($this->request->accepts('text/event-streams')) { return $this->_statusAsEventStream($data); } else { return $this->_statusAsJson($data); diff --git a/app/webroot/dist/main.js b/app/webroot/dist/main.js index 5bb9f5794..81a5864dd 100644 --- a/app/webroot/dist/main.js +++ b/app/webroot/dist/main.js @@ -1,4 +1,4 @@ -"undefined"==typeof console&&(console={},console.log=function(){},console.error=console.debug=console.info=console.log),window.redirect=function(t){document.location.replace(t)},$.ajaxSetup({cache:!1}),define("jquery",[],function(){return jQuery}),define("lib/bootstrapHelper",function(){}),define("app/core",["marionette"],function(t){return new t.Application}),define("app/vent",["marionette"],function(){var t=function(){this.vent=new Backbone.Wreqr.EventAggregator,this.commands=new Backbone.Wreqr.Commands,this.reqres=new Backbone.Wreqr.RequestResponse,this.request=function(){var t=Array.prototype.slice.apply(arguments);return this.reqres.request.apply(this.reqres,t)}};return new t}),define("models/appSetting",["underscore","backbone"],function(t,e){var i=e.Model.extend({});return i}),define("models/appStatus",["underscore","backbone","cakeRest","app/vent"],function(t,e,i,n){var o=e.Model.extend({stream:null,initialize:function(e){this.settings=e.settings,this.methodToCakePhpUrl=t.clone(this.methodToCakePhpUrl),this.methodToCakePhpUrl.read="status/",this.listenTo(this,"change:lastShoutId",this._onNewShout)},start:function(){this._setWebroot(this.settings.get("webroot")),this._poll()},_onNewShout:function(t){var e=t.get("lastShoutId");n.commands.execute("shoutbox:update",e)},_setWebroot:function(t){this.webroot=t+"saitos/"},_eventStream:function(){this.stream=new EventSource(this.webroot+this.methodToCakePhpUrl.read),this.stream.addEventListener("message",t.bind(function(t){var e=JSON.parse(t.data);this.set(e)},this),!1)},_poll:function(){var e,i,n,o,s,r,a=1e4,l=9e4;s=function(){void 0!==o&&clearTimeout(o)},e=function(){s(),r=a},n=function(){o=setTimeout(i,r)},i=t.bind(function(){n(),this.fetch(),r=Math.floor(r*(1+r/4e4)),r>l&&(r=l)},this),this.listenTo(this,"change",function(){e(),n()}),i(),e(),n()}});return t.extend(o.prototype,i),o}),define("models/currentUser",["underscore","backbone"],function(t,e){var i=e.Model.extend({isLoggedIn:function(){return this.get("id")>0}});return i}),define("models/app",["underscore","backbone","app/vent","models/appSetting","models/appStatus","models/currentUser"],function(t,e,i,n,o,s){var r=e.Model.extend({eventBus:null,settings:null,status:null,currentUser:null,request:null,initialize:function(){this.eventBus=i.vent,this.commands=i.commands,this.reqres=i.reqres,this.settings=new n,this.status=new o({settings:this.settings}),this.currentUser=new s}});return new r}),define("modules/html5-notification/views/notification",["underscore","backbone","models/app"],function(t,e,i){var n=e.View.extend({_hideAfter:10,_iconUrl:!1,initialize:function(t){this._iconUrl=t.iconUrl,this.listenTo(i.eventBus,"html5-notification",this.notification),i.commands.setHandler("app:html5-notification:activate",this._activate,this),i.reqres.setHandler("app:html5-notification:available",this._isEnabled,this)},notification:function(e){var n=!i.reqres.request("isAppVisible");if(e=t.defaults(e,{icon:this._iconUrl,always:!1}),e.always||n){var o=new window.Notification(e.title,{icon:e.icon,body:e.message}),s=navigator.userAgent.toLowerCase().indexOf("chrome")>-1;s&&setTimeout(function(){o.close()},1e3*this._hideAfter)}},_activate:function(){return"permission"in window.Notification&&"granted"!==window.Notification.permission?(window.Notification.requestPermission(),void 0):(window.Notification.requestPermission(),void 0)},_isEnabled:function(){return"Notification"in window?!0:!1}});return n}),define("modules/html5-notification/html5-notification",["app/core","marionette","modules/html5-notification/views/notification"],function(t,e,i){var n=t.module("html5-notification");return n.addInitializer(function(t){new i({iconUrl:t.SaitoApp.app.settings.notificationIcon})}),n}),define("modules/shoutbox/models/shout",["underscore","backbone"],function(t,e){var i=e.Model.extend({initialize:function(t,e){this.urlRoot=e.urlRoot}});return i}),define("modules/shoutbox/collections/shouts",["underscore","backbone","modules/shoutbox/models/shout"],function(t,e,i){var n=e.Collection.extend({model:i,initialize:function(t,e){this.apiroot=e.apiroot+"shouts/"},fetch:function(){$.ajax({url:this.apiroot,dataType:"json",context:this}).done(function(t){t.length>0&&this.reset(t)})}});return n}),function(t){function e(t,e){return function(i){return l(t.call(this,i),e)}}function i(t,e){return function(i){return this.lang().ordinal(t.call(this,i),e)}}function n(){}function o(t){w(t),r(this,t)}function s(t){var e=p(t),i=e.year||0,n=e.month||0,o=e.week||0,s=e.day||0,r=e.hour||0,a=e.minute||0,l=e.second||0,h=e.millisecond||0;this._input=t,this._milliseconds=+h+1e3*l+6e4*a+36e5*r,this._days=+s+7*o,this._months=+n+12*i,this._data={},this._bubble()}function r(t,e){for(var i in e)e.hasOwnProperty(i)&&(t[i]=e[i]);return e.hasOwnProperty("toString")&&(t.toString=e.toString),e.hasOwnProperty("valueOf")&&(t.valueOf=e.valueOf),t}function a(t){return 0>t?Math.ceil(t):Math.floor(t)}function l(t,e){for(var i=t+"";i.lengthn;n++)(i&&t[n]!==e[n]||!i&&g(t[n])!==g(e[n]))&&r++;return r+s}function f(t){if(t){var e=t.toLowerCase().replace(/(.)s$/,"$1");t=Ae[t]||He[e]||e}return t}function p(t){var e,i,n={};for(i in t)t.hasOwnProperty(i)&&(e=f(i),e&&(n[e]=t[i]));return n}function m(e){var i,n;if(0===e.indexOf("week"))i=7,n="day";else{if(0!==e.indexOf("month"))return;i=12,n="month"}ee[e]=function(o,s){var r,a,l=ee.fn._lang[e],h=[];if("number"==typeof o&&(s=o,o=t),a=function(t){var e=ee().utc().set(n,t);return l.call(ee.fn._lang,e,o||"")},null!=s)return a(s);for(r=0;i>r;r++)h.push(a(r));return h}}function g(t){var e=+t,i=0;return 0!==e&&isFinite(e)&&(i=e>=0?Math.floor(e):Math.ceil(e)),i}function v(t,e){return new Date(Date.UTC(t,e+1,0)).getUTCDate()}function y(t){return b(t)?366:365}function b(t){return 0===t%4&&0!==t%100||0===t%400}function w(t){var e;t._a&&-2===t._pf.overflow&&(e=t._a[re]<0||t._a[re]>11?re:t._a[ae]<1||t._a[ae]>v(t._a[se],t._a[re])?ae:t._a[le]<0||t._a[le]>23?le:t._a[he]<0||t._a[he]>59?he:t._a[ce]<0||t._a[ce]>59?ce:t._a[ue]<0||t._a[ue]>999?ue:-1,t._pf._overflowDayOfYear&&(se>e||e>ae)&&(e=ae),t._pf.overflow=e)}function _(t){t._pf={empty:!1,unusedTokens:[],unusedInput:[],overflow:-2,charsLeftOver:0,nullInput:!1,invalidMonth:null,invalidFormat:!1,userInvalidated:!1}}function x(t){return null==t._isValid&&(t._isValid=!isNaN(t._d.getTime())&&t._pf.overflow<0&&!t._pf.empty&&!t._pf.invalidMonth&&!t._pf.nullInput&&!t._pf.invalidFormat&&!t._pf.userInvalidated,t._strict&&(t._isValid=t._isValid&&0===t._pf.charsLeftOver&&0===t._pf.unusedTokens.length)),t._isValid}function k(t){return t?t.toLowerCase().replace("_","-"):t}function C(t,e){return e.abbr=t,de[t]||(de[t]=new n),de[t].set(e),de[t]}function T(t){delete de[t]}function S(t){var e,i,n,o,s=0,r=function(t){if(!de[t]&&fe)try{require("./lang/"+t)}catch(e){}return de[t]};if(!t)return ee.fn._lang;if(!c(t)){if(i=r(t))return i;t=[t]}for(;s0;){if(i=r(o.slice(0,e).join("-")))return i;if(n&&n.length>=e&&d(o,n,!0)>=e-1)break;e--}s++}return ee.fn._lang}function I(t){return t.match(/\[[\s\S]/)?t.replace(/^\[|\]$/g,""):t.replace(/\\/g,"")}function M(t){var e,i,n=t.match(ve);for(e=0,i=n.length;i>e;e++)n[e]=Fe[n[e]]?Fe[n[e]]:I(n[e]);return function(o){var s="";for(e=0;i>e;e++)s+=n[e]instanceof Function?n[e].call(o,t):n[e];return s}}function D(t,e){return t.isValid()?(e=z(e,t.lang()),je[e]||(je[e]=M(e)),je[e](t)):t.lang().invalidDate()}function z(t,e){function i(t){return e.longDateFormat(t)||t}var n=5;for(ye.lastIndex=0;n>=0&&ye.test(t);)t=t.replace(ye,i),ye.lastIndex=0,n-=1;return t}function E(t,e){var i;switch(t){case"DDDD":return _e;case"YYYY":case"GGGG":case"gggg":return xe;case"YYYYY":case"GGGGG":case"ggggg":return ke;case"S":case"SS":case"SSS":case"DDD":return we;case"MMM":case"MMMM":case"dd":case"ddd":case"dddd":return Ce;case"a":case"A":return S(e._l)._meridiemParse;case"X":return Ie;case"Z":case"ZZ":return Te;case"T":return Se;case"MM":case"DD":case"YY":case"GG":case"gg":case"HH":case"hh":case"mm":case"ss":case"M":case"D":case"d":case"H":case"h":case"m":case"s":case"w":case"ww":case"W":case"WW":case"e":case"E":return be;default:return i=new RegExp(R(N(t.replace("\\","")),"i"))}}function P(t){var e=(Te.exec(t)||[])[0],i=(e+"").match(Pe)||["-",0,0],n=+(60*i[1])+g(i[2]);return"+"===i[0]?-n:n}function $(t,e,i){var n,o=i._a;switch(t){case"M":case"MM":null!=e&&(o[re]=g(e)-1);break;case"MMM":case"MMMM":n=S(i._l).monthsParse(e),null!=n?o[re]=n:i._pf.invalidMonth=e;break;case"D":case"DD":null!=e&&(o[ae]=g(e));break;case"DDD":case"DDDD":null!=e&&(i._dayOfYear=g(e));break;case"YY":o[se]=g(e)+(g(e)>68?1900:2e3);break;case"YYYY":case"YYYYY":o[se]=g(e);break;case"a":case"A":i._isPm=S(i._l).isPM(e);break;case"H":case"HH":case"h":case"hh":o[le]=g(e);break;case"m":case"mm":o[he]=g(e);break;case"s":case"ss":o[ce]=g(e);break;case"S":case"SS":case"SSS":o[ue]=g(1e3*("0."+e));break;case"X":i._d=new Date(1e3*parseFloat(e));break;case"Z":case"ZZ":i._useUTC=!0,i._tzm=P(e);break;case"w":case"ww":case"W":case"WW":case"d":case"dd":case"ddd":case"dddd":case"e":case"E":t=t.substr(0,1);case"gg":case"gggg":case"GG":case"GGGG":case"GGGGG":t=t.substr(0,2),e&&(i._w=i._w||{},i._w[t]=e)}}function O(t){var e,i,n,o,s,r,a,l,h,c,u=[];if(!t._d){for(n=H(t),t._w&&null==t._a[ae]&&null==t._a[re]&&(s=function(e){return e?e.length<3?parseInt(e,10)>68?"19"+e:"20"+e:e:null==t._a[se]?ee().weekYear():t._a[se]},r=t._w,null!=r.GG||null!=r.W||null!=r.E?a=G(s(r.GG),r.W||1,r.E,4,1):(l=S(t._l),h=null!=r.d?U(r.d,l):null!=r.e?parseInt(r.e,10)+l._week.dow:0,c=parseInt(r.w,10)||1,null!=r.d&&hy(o)&&(t._pf._overflowDayOfYear=!0),i=B(o,0,t._dayOfYear),t._a[re]=i.getUTCMonth(),t._a[ae]=i.getUTCDate()),e=0;3>e&&null==t._a[e];++e)t._a[e]=u[e]=n[e];for(;7>e;e++)t._a[e]=u[e]=null==t._a[e]?2===e?1:0:t._a[e];u[le]+=g((t._tzm||0)/60),u[he]+=g((t._tzm||0)%60),t._d=(t._useUTC?B:q).apply(null,u)}}function A(t){var e;t._d||(e=p(t._i),t._a=[e.year,e.month,e.day,e.hour,e.minute,e.second,e.millisecond],O(t))}function H(t){var e=new Date;return t._useUTC?[e.getUTCFullYear(),e.getUTCMonth(),e.getUTCDate()]:[e.getFullYear(),e.getMonth(),e.getDate()]}function j(t){t._a=[],t._pf.empty=!0;var e,i,n,o,s,r=S(t._l),a=""+t._i,l=a.length,h=0;for(n=z(t._f,r).match(ve)||[],e=0;e0&&t._pf.unusedInput.push(s),a=a.slice(a.indexOf(i)+i.length),h+=i.length),Fe[o]?(i?t._pf.empty=!1:t._pf.unusedTokens.push(o),$(o,i,t)):t._strict&&!i&&t._pf.unusedTokens.push(o);t._pf.charsLeftOver=l-h,a.length>0&&t._pf.unusedInput.push(a),t._isPm&&t._a[le]<12&&(t._a[le]+=12),t._isPm===!1&&12===t._a[le]&&(t._a[le]=0),O(t),w(t)}function N(t){return t.replace(/\\(\[)|\\(\])|\[([^\]\[]*)\]|\\(.)/g,function(t,e,i,n,o){return e||i||n||o})}function R(t){return t.replace(/[-\/\\^$*+?.()|[\]{}]/g,"\\$&")}function F(t){var e,i,n,o,s;if(0===t._f.length)return t._pf.invalidFormat=!0,t._d=new Date(0/0),void 0;for(o=0;os)&&(n=s,i=e));r(t,i||e)}function W(t){var e,i=t._i,n=Me.exec(i);if(n){for(e=4;e>0;e--)if(n[e]){t._f=ze[e-1]+(n[6]||" ");break}for(e=0;4>e;e++)if(Ee[e][1].exec(i)){t._f+=Ee[e][0];break}Te.exec(i)&&(t._f+=" Z"),j(t)}else t._d=new Date(i)}function L(e){var i=e._i,n=pe.exec(i);i===t?e._d=new Date:n?e._d=new Date(+n[1]):"string"==typeof i?W(e):c(i)?(e._a=i.slice(0),O(e)):u(i)?e._d=new Date(+i):"object"==typeof i?A(e):e._d=new Date(i)}function q(t,e,i,n,o,s,r){var a=new Date(t,e,i,n,o,s,r);return 1970>t&&a.setFullYear(t),a}function B(t){var e=new Date(Date.UTC.apply(null,arguments));return 1970>t&&e.setUTCFullYear(t),e}function U(t,e){if("string"==typeof t)if(isNaN(t)){if(t=e.weekdaysParse(t),"number"!=typeof t)return null}else t=parseInt(t,10);return t}function V(t,e,i,n,o){return o.relativeTime(e||1,!!i,t,n)}function Y(t,e,i){var n=oe(Math.abs(t)/1e3),o=oe(n/60),s=oe(o/60),r=oe(s/24),a=oe(r/365),l=45>n&&["s",n]||1===o&&["m"]||45>o&&["mm",o]||1===s&&["h"]||22>s&&["hh",s]||1===r&&["d"]||25>=r&&["dd",r]||45>=r&&["M"]||345>r&&["MM",oe(r/30)]||1===a&&["y"]||["yy",a];return l[2]=e,l[3]=t>0,l[4]=i,V.apply({},l)}function X(t,e,i){var n,o=i-e,s=i-t.day();return s>o&&(s-=7),o-7>s&&(s+=7),n=ee(t).add("d",s),{week:Math.ceil(n.dayOfYear()/7),year:n.year()}}function G(t,e,i,n,o){var s,r,a=new Date(Date.UTC(t,0)).getUTCDay();return i=null!=i?i:o,s=o-a+(a>n?7:0),r=7*(e-1)+(i-o)+s+1,{year:r>0?t:t-1,dayOfYear:r>0?r:y(t-1)+r}}function Q(t){var e=t._i,i=t._f;return"undefined"==typeof t._pf&&_(t),null===e?ee.invalid({nullInput:!0}):("string"==typeof e&&(t._i=e=S().preparse(e)),ee.isMoment(e)?(t=r({},e),t._d=new Date(+e._d)):i?c(i)?F(t):j(t):L(t),new o(t))}function J(t,e){ee.fn[t]=ee.fn[t+"s"]=function(t){var i=this._isUTC?"UTC":"";return null!=t?(this._d["set"+i+e](t),ee.updateOffset(this),this):this._d["get"+i+e]()}}function Z(t){ee.duration.fn[t]=function(){return this._data[t]}}function K(t,e){ee.duration.fn["as"+t]=function(){return+this/e}}function te(){"undefined"==typeof ender&&(this.moment=ee)}for(var ee,ie,ne="2.3.1",oe=Math.round,se=0,re=1,ae=2,le=3,he=4,ce=5,ue=6,de={},fe="undefined"!=typeof module&&module.exports,pe=/^\/?Date\((\-?\d+)/i,me=/(\-)?(?:(\d*)\.)?(\d+)\:(\d+)(?:\:(\d+)\.?(\d{3})?)?/,ge=/^(-)?P(?:(?:([0-9,.]*)Y)?(?:([0-9,.]*)M)?(?:([0-9,.]*)D)?(?:T(?:([0-9,.]*)H)?(?:([0-9,.]*)M)?(?:([0-9,.]*)S)?)?|([0-9,.]*)W)$/,ve=/(\[[^\[]*\])|(\\)?(Mo|MM?M?M?|Do|DDDo|DD?D?D?|ddd?d?|do?|w[o|w]?|W[o|W]?|YYYYY|YYYY|YY|gg(ggg?)?|GG(GGG?)?|e|E|a|A|hh?|HH?|mm?|ss?|SS?S?|X|zz?|ZZ?|.)/g,ye=/(\[[^\[]*\])|(\\)?(LT|LL?L?L?|l{1,4})/g,be=/\d\d?/,we=/\d{1,3}/,_e=/\d{3}/,xe=/\d{1,4}/,ke=/[+\-]?\d{1,6}/,Ce=/[0-9]*['a-z\u00A0-\u05FF\u0700-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]+|[\u0600-\u06FF\/]+(\s*?[\u0600-\u06FF]+){1,2}/i,Te=/Z|[\+\-]\d\d:?\d\d/i,Se=/T/i,Ie=/[\+\-]?\d+(\.\d{1,3})?/,Me=/^\s*\d{4}-(?:(\d\d-\d\d)|(W\d\d$)|(W\d\d-\d)|(\d\d\d))((T| )(\d\d(:\d\d(:\d\d(\.\d\d?\d?)?)?)?)?([\+\-]\d\d:?\d\d)?)?$/,De="YYYY-MM-DDTHH:mm:ssZ",ze=["YYYY-MM-DD","GGGG-[W]WW","GGGG-[W]WW-E","YYYY-DDD"],Ee=[["HH:mm:ss.S",/(T| )\d\d:\d\d:\d\d\.\d{1,3}/],["HH:mm:ss",/(T| )\d\d:\d\d:\d\d/],["HH:mm",/(T| )\d\d:\d\d/],["HH",/(T| )\d\d/]],Pe=/([\+\-]|\d\d)/gi,$e="Date|Hours|Minutes|Seconds|Milliseconds".split("|"),Oe={Milliseconds:1,Seconds:1e3,Minutes:6e4,Hours:36e5,Days:864e5,Months:2592e6,Years:31536e6},Ae={ms:"millisecond",s:"second",m:"minute",h:"hour",d:"day",D:"date",w:"week",W:"isoWeek",M:"month",y:"year",DDD:"dayOfYear",e:"weekday",E:"isoWeekday",gg:"weekYear",GG:"isoWeekYear"},He={dayofyear:"dayOfYear",isoweekday:"isoWeekday",isoweek:"isoWeek",weekyear:"weekYear",isoweekyear:"isoWeekYear"},je={},Ne="DDD w W M D d".split(" "),Re="M D H h m s w W".split(" "),Fe={M:function(){return this.month()+1},MMM:function(t){return this.lang().monthsShort(this,t)},MMMM:function(t){return this.lang().months(this,t)},D:function(){return this.date()},DDD:function(){return this.dayOfYear()},d:function(){return this.day()},dd:function(t){return this.lang().weekdaysMin(this,t)},ddd:function(t){return this.lang().weekdaysShort(this,t)},dddd:function(t){return this.lang().weekdays(this,t)},w:function(){return this.week()},W:function(){return this.isoWeek()},YY:function(){return l(this.year()%100,2)},YYYY:function(){return l(this.year(),4)},YYYYY:function(){return l(this.year(),5)},gg:function(){return l(this.weekYear()%100,2)},gggg:function(){return this.weekYear()},ggggg:function(){return l(this.weekYear(),5)},GG:function(){return l(this.isoWeekYear()%100,2)},GGGG:function(){return this.isoWeekYear()},GGGGG:function(){return l(this.isoWeekYear(),5)},e:function(){return this.weekday()},E:function(){return this.isoWeekday()},a:function(){return this.lang().meridiem(this.hours(),this.minutes(),!0)},A:function(){return this.lang().meridiem(this.hours(),this.minutes(),!1)},H:function(){return this.hours()},h:function(){return this.hours()%12||12},m:function(){return this.minutes()},s:function(){return this.seconds()},S:function(){return g(this.milliseconds()/100)},SS:function(){return l(g(this.milliseconds()/10),2)},SSS:function(){return l(this.milliseconds(),3)},Z:function(){var t=-this.zone(),e="+";return 0>t&&(t=-t,e="-"),e+l(g(t/60),2)+":"+l(g(t)%60,2)},ZZ:function(){var t=-this.zone(),e="+";return 0>t&&(t=-t,e="-"),e+l(g(10*t/6),4)},z:function(){return this.zoneAbbr()},zz:function(){return this.zoneName()},X:function(){return this.unix()}},We=["months","monthsShort","weekdays","weekdaysShort","weekdaysMin"];Ne.length;)ie=Ne.pop(),Fe[ie+"o"]=i(Fe[ie],ie);for(;Re.length;)ie=Re.pop(),Fe[ie+ie]=e(Fe[ie],2);for(Fe.DDDD=e(Fe.DDD,3),r(n.prototype,{set:function(t){var e,i;for(i in t)e=t[i],"function"==typeof e?this[i]=e:this["_"+i]=e},_months:"January_February_March_April_May_June_July_August_September_October_November_December".split("_"),months:function(t){return this._months[t.month()]},_monthsShort:"Jan_Feb_Mar_Apr_May_Jun_Jul_Aug_Sep_Oct_Nov_Dec".split("_"),monthsShort:function(t){return this._monthsShort[t.month()]},monthsParse:function(t){var e,i,n;for(this._monthsParse||(this._monthsParse=[]),e=0;12>e;e++)if(this._monthsParse[e]||(i=ee.utc([2e3,e]),n="^"+this.months(i,"")+"|^"+this.monthsShort(i,""),this._monthsParse[e]=new RegExp(n.replace(".",""),"i")),this._monthsParse[e].test(t))return e},_weekdays:"Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday".split("_"),weekdays:function(t){return this._weekdays[t.day()]},_weekdaysShort:"Sun_Mon_Tue_Wed_Thu_Fri_Sat".split("_"),weekdaysShort:function(t){return this._weekdaysShort[t.day()]},_weekdaysMin:"Su_Mo_Tu_We_Th_Fr_Sa".split("_"),weekdaysMin:function(t){return this._weekdaysMin[t.day()]},weekdaysParse:function(t){var e,i,n;for(this._weekdaysParse||(this._weekdaysParse=[]),e=0;7>e;e++)if(this._weekdaysParse[e]||(i=ee([2e3,1]).day(e),n="^"+this.weekdays(i,"")+"|^"+this.weekdaysShort(i,"")+"|^"+this.weekdaysMin(i,""),this._weekdaysParse[e]=new RegExp(n.replace(".",""),"i")),this._weekdaysParse[e].test(t))return e},_longDateFormat:{LT:"h:mm A",L:"MM/DD/YYYY",LL:"MMMM D YYYY",LLL:"MMMM D YYYY LT",LLLL:"dddd, MMMM D YYYY LT"},longDateFormat:function(t){var e=this._longDateFormat[t];return!e&&this._longDateFormat[t.toUpperCase()]&&(e=this._longDateFormat[t.toUpperCase()].replace(/MMMM|MM|DD|dddd/g,function(t){return t.slice(1)}),this._longDateFormat[t]=e),e},isPM:function(t){return"p"===(t+"").toLowerCase().charAt(0)},_meridiemParse:/[ap]\.?m?\.?/i,meridiem:function(t,e,i){return t>11?i?"pm":"PM":i?"am":"AM"},_calendar:{sameDay:"[Today at] LT",nextDay:"[Tomorrow at] LT",nextWeek:"dddd [at] LT",lastDay:"[Yesterday at] LT",lastWeek:"[Last] dddd [at] LT",sameElse:"L"},calendar:function(t,e){var i=this._calendar[t];return"function"==typeof i?i.apply(e):i},_relativeTime:{future:"in %s",past:"%s ago",s:"a few seconds",m:"a minute",mm:"%d minutes",h:"an hour",hh:"%d hours",d:"a day",dd:"%d days",M:"a month",MM:"%d months",y:"a year",yy:"%d years"},relativeTime:function(t,e,i,n){var o=this._relativeTime[i];return"function"==typeof o?o(t,e,i,n):o.replace(/%d/i,t)},pastFuture:function(t,e){var i=this._relativeTime[t>0?"future":"past"];return"function"==typeof i?i(e):i.replace(/%s/i,e)},ordinal:function(t){return this._ordinal.replace("%d",t)},_ordinal:"%d",preparse:function(t){return t},postformat:function(t){return t},week:function(t){return X(t,this._week.dow,this._week.doy).week},_week:{dow:0,doy:6},_invalidDate:"Invalid date",invalidDate:function(){return this._invalidDate}}),ee=function(e,i,n,o){return"boolean"==typeof n&&(o=n,n=t),Q({_i:e,_f:i,_l:n,_strict:o,_isUTC:!1})},ee.utc=function(e,i,n,o){var s;return"boolean"==typeof n&&(o=n,n=t),s=Q({_useUTC:!0,_isUTC:!0,_l:n,_i:e,_f:i,_strict:o}).utc()},ee.unix=function(t){return ee(1e3*t)},ee.duration=function(t,e){var i,n,o,r=ee.isDuration(t),a="number"==typeof t,l=r?t._input:a?{}:t,h=null;return a?e?l[e]=t:l.milliseconds=t:(h=me.exec(t))?(i="-"===h[1]?-1:1,l={y:0,d:g(h[ae])*i,h:g(h[le])*i,m:g(h[he])*i,s:g(h[ce])*i,ms:g(h[ue])*i}):(h=ge.exec(t))&&(i="-"===h[1]?-1:1,o=function(t){var e=t&&parseFloat(t.replace(",","."));return(isNaN(e)?0:e)*i},l={y:o(h[2]),M:o(h[3]),d:o(h[4]),h:o(h[5]),m:o(h[6]),s:o(h[7]),w:o(h[8])}),n=new s(l),r&&t.hasOwnProperty("_lang")&&(n._lang=t._lang),n},ee.version=ne,ee.defaultFormat=De,ee.updateOffset=function(){},ee.lang=function(t,e){var i;return t?(e?C(k(t),e):null===e?(T(t),t="en"):de[t]||S(t),i=ee.duration.fn._lang=ee.fn._lang=S(t),i._abbr):ee.fn._lang._abbr},ee.langData=function(t){return t&&t._lang&&t._lang._abbr&&(t=t._lang._abbr),S(t)},ee.isMoment=function(t){return t instanceof o},ee.isDuration=function(t){return t instanceof s},ie=We.length-1;ie>=0;--ie)m(We[ie]);for(ee.normalizeUnits=function(t){return f(t)},ee.invalid=function(t){var e=ee.utc(0/0);return null!=t?r(e._pf,t):e._pf.userInvalidated=!0,e},ee.parseZone=function(t){return ee(t).parseZone()},r(ee.fn=o.prototype,{clone:function(){return ee(this)},valueOf:function(){return+this._d+6e4*(this._offset||0)},unix:function(){return Math.floor(+this/1e3)},toString:function(){return this.clone().lang("en").format("ddd MMM DD YYYY HH:mm:ss [GMT]ZZ")},toDate:function(){return this._offset?new Date(+this):this._d},toISOString:function(){return D(ee(this).utc(),"YYYY-MM-DD[T]HH:mm:ss.SSS[Z]")},toArray:function(){var t=this;return[t.year(),t.month(),t.date(),t.hours(),t.minutes(),t.seconds(),t.milliseconds()]},isValid:function(){return x(this)},isDSTShifted:function(){return this._a?this.isValid()&&d(this._a,(this._isUTC?ee.utc(this._a):ee(this._a)).toArray())>0:!1},parsingFlags:function(){return r({},this._pf)},invalidAt:function(){return this._pf.overflow},utc:function(){return this.zone(0)},local:function(){return this.zone(0),this._isUTC=!1,this},format:function(t){var e=D(this,t||ee.defaultFormat);return this.lang().postformat(e)},add:function(t,e){var i;return i="string"==typeof t?ee.duration(+e,t):ee.duration(t,e),h(this,i,1),this},subtract:function(t,e){var i;return i="string"==typeof t?ee.duration(+e,t):ee.duration(t,e),h(this,i,-1),this},diff:function(t,e,i){var n,o,s=this._isUTC?ee(t).zone(this._offset||0):ee(t).local(),r=6e4*(this.zone()-s.zone());return e=f(e),"year"===e||"month"===e?(n=432e5*(this.daysInMonth()+s.daysInMonth()),o=12*(this.year()-s.year())+(this.month()-s.month()),o+=(this-ee(this).startOf("month")-(s-ee(s).startOf("month")))/n,o-=6e4*(this.zone()-ee(this).startOf("month").zone()-(s.zone()-ee(s).startOf("month").zone()))/n,"year"===e&&(o/=12)):(n=this-s,o="second"===e?n/1e3:"minute"===e?n/6e4:"hour"===e?n/36e5:"day"===e?(n-r)/864e5:"week"===e?(n-r)/6048e5:n),i?o:a(o)},from:function(t,e){return ee.duration(this.diff(t)).lang(this.lang()._abbr).humanize(!e)},fromNow:function(t){return this.from(ee(),t)},calendar:function(){var t=this.diff(ee().zone(this.zone()).startOf("day"),"days",!0),e=-6>t?"sameElse":-1>t?"lastWeek":0>t?"lastDay":1>t?"sameDay":2>t?"nextDay":7>t?"nextWeek":"sameElse";return this.format(this.lang().calendar(e,this))},isLeapYear:function(){return b(this.year())},isDST:function(){return this.zone()+ee(t).startOf(e)},isBefore:function(t,e){return e="undefined"!=typeof e?e:"millisecond",+this.clone().startOf(e)<+ee(t).startOf(e)},isSame:function(t,e){return e="undefined"!=typeof e?e:"millisecond",+this.clone().startOf(e)===+ee(t).startOf(e)},min:function(t){return t=ee.apply(null,arguments),this>t?this:t},max:function(t){return t=ee.apply(null,arguments),t>this?this:t},zone:function(t){var e=this._offset||0;return null==t?this._isUTC?e:this._d.getTimezoneOffset():("string"==typeof t&&(t=P(t)),Math.abs(t)<16&&(t=60*t),this._offset=t,this._isUTC=!0,e!==t&&h(this,ee.duration(e-t,"m"),1,!0),this)},zoneAbbr:function(){return this._isUTC?"UTC":""},zoneName:function(){return this._isUTC?"Coordinated Universal Time":""},parseZone:function(){return"string"==typeof this._i&&this.zone(this._i),this},hasAlignedHourOffset:function(t){return t=t?ee(t).zone():0,0===(this.zone()-t)%60},daysInMonth:function(){return v(this.year(),this.month())},dayOfYear:function(t){var e=oe((ee(this).startOf("day")-ee(this).startOf("year"))/864e5)+1;return null==t?e:this.add("d",t-e)},weekYear:function(t){var e=X(this,this.lang()._week.dow,this.lang()._week.doy).year;return null==t?e:this.add("y",t-e)},isoWeekYear:function(t){var e=X(this,1,4).year;return null==t?e:this.add("y",t-e)},week:function(t){var e=this.lang().week(this);return null==t?e:this.add("d",7*(t-e))},isoWeek:function(t){var e=X(this,1,4).week;return null==t?e:this.add("d",7*(t-e))},weekday:function(t){var e=(this.day()+7-this.lang()._week.dow)%7;return null==t?e:this.add("d",t-e)},isoWeekday:function(t){return null==t?this.day()||7:this.day(this.day()%7?t:t-7)},get:function(t){return t=f(t),this[t]()},set:function(t,e){return t=f(t),"function"==typeof this[t]&&this[t](e),this},lang:function(e){return e===t?this._lang:(this._lang=S(e),this)}}),ie=0;ie<$e.length;ie++)J($e[ie].toLowerCase().replace(/s$/,""),$e[ie]);J("year","FullYear"),ee.fn.days=ee.fn.day,ee.fn.months=ee.fn.month,ee.fn.weeks=ee.fn.week,ee.fn.isoWeeks=ee.fn.isoWeek,ee.fn.toJSON=ee.fn.toISOString,r(ee.duration.fn=s.prototype,{_bubble:function(){var t,e,i,n,o=this._milliseconds,s=this._days,r=this._months,l=this._data;l.milliseconds=o%1e3,t=a(o/1e3),l.seconds=t%60,e=a(t/60),l.minutes=e%60,i=a(e/60),l.hours=i%24,s+=a(i/24),l.days=s%30,r+=a(s/30),l.months=r%12,n=a(r/12),l.years=n},weeks:function(){return a(this.days()/7)},valueOf:function(){return this._milliseconds+864e5*this._days+2592e6*(this._months%12)+31536e6*g(this._months/12)},humanize:function(t){var e=+this,i=Y(e,!t,this.lang());return t&&(i=this.lang().pastFuture(e,i)),this.lang().postformat(i)},add:function(t,e){var i=ee.duration(t,e);return this._milliseconds+=i._milliseconds,this._days+=i._days,this._months+=i._months,this._bubble(),this},subtract:function(t,e){var i=ee.duration(t,e);return this._milliseconds-=i._milliseconds,this._days-=i._days,this._months-=i._months,this._bubble(),this},get:function(t){return t=f(t),this[t.toLowerCase()+"s"]()},as:function(t){return t=f(t),this["as"+t.charAt(0).toUpperCase()+t.slice(1)+"s"]()},lang:ee.fn.lang,toIsoString:function(){var t=Math.abs(this.years()),e=Math.abs(this.months()),i=Math.abs(this.days()),n=Math.abs(this.hours()),o=Math.abs(this.minutes()),s=Math.abs(this.seconds()+this.milliseconds()/1e3);return this.asSeconds()?(this.asSeconds()<0?"-":"")+"P"+(t?t+"Y":"")+(e?e+"M":"")+(i?i+"D":"")+(n||o||s?"T":"")+(n?n+"H":"")+(o?o+"M":"")+(s?s+"S":""):"P0D"}});for(ie in Oe)Oe.hasOwnProperty(ie)&&(K(ie,Oe[ie]),Z(ie.toLowerCase()));K("Weeks",6048e5),ee.duration.fn.asMonths=function(){return(+this-31536e6*this.years())/2592e6+12*this.years()},ee.lang("en",{ordinal:function(t){var e=t%10,i=1===g(t%100/10)?"th":1===e?"st":2===e?"nd":3===e?"rd":"th";return t+i}}),fe?(module.exports=ee,te()):"function"==typeof define&&define.amd?define("moment",["require","exports","module"],function(t,e,i){return i.config().noGlobal!==!0&&te(),ee}):te()}.call(this),define("text!modules/shoutbox/templates/shout.html",[],function(){return'\n <%= user_name %>:\n\n<%= html %>\n'}),define("modules/shoutbox/views/shout",["jquery","underscore","backbone","marionette","text!modules/shoutbox/templates/shout.html"],function(t,e,i,n,o){var s=n.ItemView.extend({className:"shout",initialize:function(t){this.webroot=t.webroot},serializeData:function(){var t=this.model.toJSON();return t.user_url=this.webroot+"users/view/"+this.model.get("user_id"),t},template:function(t){return e.template(o,t)}});return s}),define("modules/shoutbox/models/control",["underscore","backbone"],function(t,e){var i=e.Model.extend({defaults:{notify:!1},initialize:function(){this.restoreNotify(),this.listenTo(this,"change:notify",this.saveNotify)},restoreNotify:function(){"localStorage"in window&&this.set("notify","true"===localStorage.getItem("shoutbox-notify"))},saveNotify:function(){"localStorage"in window&&localStorage.setItem("shoutbox-notify",this.get("notify"))}});return new i}),define("modules/shoutbox/views/shouts",["jquery","underscore","backbone","marionette","moment","models/app","modules/shoutbox/views/shout","modules/shoutbox/models/control"],function(t,e,i,n,o,s,r,a){var l=n.CollectionView.extend({itemView:r,itemViewOptions:{},_Notifications:{_last:0,_models:[],_isEnabled:!1,init:function(t){this._currentUserId=t.currentUserId,this._isEnabled=t.isEnabled,this._last=t.last},add:function(t){this._isEnabled===!0&&this._currentUserId!==t.get("user_id")&&(t.get("id")<=this._last||this._models.push(t))},send:function(){0!==this._models.length&&(e.each(this._models,function(t){s.eventBus.trigger("html5-notification",{title:t.get("user_name"),message:t.get("text")})}),this._last=e.first(this._models).get("id"),this._models=[])}},_Delimiter:{_conversationCoolOff:300,_previousItemTime:null,tpl:e.template('
<%= time %>
'),init:function(t){this.$el=t.$el},append:function(t){var e=o(t.model.get("time"));return this._itemTime=e,null===this._previousItemTime?(this._previousItemTime=e,void 0):(this._previousItemTime.unix()-e.unix()>this._conversationCoolOff?this._append(this._previousItemTime):this._append("
"),this._previousItemTime=e,void 0)},finish:function(){this._previousItemTime=null,this._itemTime&&this._append(this._itemTime)},_append:function(t){var i=t;e.isObject(t)&&(i=this.tpl({time:t.format("LT"),time_long:t.format("llll")})),this.$el.append(i)}},initialize:function(t){this.itemViewOptions.webroot=t.webroot,this._Delimiter.init({$el:this.$el}),this.setupNotifications(),this.listenTo(a,"change:notify",this.setupNotifications)},setupNotifications:function(){var t=0;this.collection.size()>0&&(t=this.collection.first().get("id")),this._Notifications.init({currentUserId:s.currentUser.get("id"),isEnabled:a.get("notify"),last:t})},onBeforeRender:function(){this.$el.html("")},onBeforeItemAdded:function(t){this._Delimiter.append(t)},onAfterItemAdded:function(t){this._Notifications.add(t.model)},onRender:function(){this._Delimiter.finish(),this._Notifications.send()}});return l}),define("text!modules/shoutbox/templates/add.html",[],function(){return'
\n \n
\n'}),define("modules/shoutbox/views/add",["jquery","underscore","backbone","marionette","models/app","modules/shoutbox/models/shout","text!modules/shoutbox/templates/add.html","jqueryAutosize"],function(t,e,i,n,o,s,r){var a=n.ItemView.extend({template:e.template(r),events:{"keyup form":"formUp","keydown form":"formDown"},submit:function(){this.model.save({text:this.textarea.val()},{success:e.bind(function(t,e){this.collection.reset(e) -},this)})},clearForm:function(){this.textarea.val("").trigger("autosize.resize")},formDown:function(t){13===t.keyCode&&t.shiftKey===!1&&(t.preventDefault(),this.submit(),this.clearForm())},formUp:function(){this.textarea.val().length>0?o.eventBus.trigger("breakAutoreload"):0===this.textarea.val().length&&o.eventBus.trigger("initAutoreload")},onShow:function(){this.textarea=this.$("#shoutbox-input"),this.textarea.autosize()}});return a}),define("text!modules/shoutbox/templates/control.html",[],function(){return"\n"}),define("modules/shoutbox/views/control",["jquery","underscore","backbone","marionette","models/app","modules/shoutbox/models/control","text!modules/shoutbox/templates/control.html"],function(t,e,i,n,o,s,r){var a=n.ItemView.extend({template:e.template(r),events:{"click #shoutbox-notify":"onChangeNotify"},initialize:function(){this.model=s},onRender:function(){this._putNotifyCheckbox()},serializeData:function(){return{n:t.i18n.__("Notification")}},_putNotifyCheckbox:function(){var t=o.reqres.request("app:html5-notification:available");t===!0&&(this.notify=this.$("#shoutbox-notify"),this.model.get("notify")?this.notify.attr("checked","checked"):this.notify.removeAttr("checked"),this.$("#shoutbox-notify-label").show())},onChangeNotify:function(){var t=this.notify.is(":checked");this.model.set("notify",t),t&&o.commands.execute("app:html5-notification:activate")}});return a}),define("text!modules/shoutbox/templates/layout.html",[],function(){return"
\n
\n
\n
\n
\n"}),define("modules/shoutbox/shoutbox",["jquery","app/app","models/app","marionette","modules/shoutbox/collections/shouts","modules/shoutbox/models/shout","modules/shoutbox/views/shouts","modules/shoutbox/views/add","modules/shoutbox/views/control","text!modules/shoutbox/templates/layout.html"],function(t,e,i,n,o,s,r,a,l,h){var c=e.module("Shoutbox");return c.addInitializer(function(e){var c=e.SaitoApp.shouts,u=i.reqres.request("webroot"),d=i.reqres.request("apiroot");if(t("#shoutbox").length){var f={layout:null,shoutsCollection:null,initialize:function(){this.initLayout(),this.initShoutsCollection(),this.initAdd(),this.initShouts(),this.initControl()},initShoutsCollection:function(){this.shoutsCollection=new o(c,{apiroot:d});var t=_.bind(function(){var t=!i.reqres.request("slidetab:open","shoutbox");t||this.shoutsCollection.fetch()},this);i.eventBus.on("slidetab:open",_.bind(function(e){"shoutbox"===e.slidetab&&t()},this)),i.commands.setHandler("shoutbox:update",_.bind(function(e){var i=0;this.shoutsCollection.size()>0&&(i=this.shoutsCollection.at(0).get("id")),e!==i&&t()},this))},initLayout:function(){var t=n.Layout.extend({el:"#shoutbox",template:h,regions:{add:"#shoutbox-add",shouts:"#shoutbox-shouts",control:"#shoutbox-control"}});this.layout=new t,this.layout.render()},initShouts:function(){var t=new r({collection:this.shoutsCollection,webroot:u});this.layout.shouts.show(t)},initControl:function(){var t=new l;this.layout.control.show(t)},initAdd:function(){var t=new s({},{urlRoot:d+"shouts/"});this.layout.add.show(new a({model:t,collection:this.shoutsCollection}))}};f.initialize()}}),c}),define("models/threadline",["underscore","backbone","models/app","cakeRest"],function(t,e,i,n){var o=e.Model.extend({defaults:{isInlineOpened:!1,shouldScrollOnInlineOpen:!0,isAlwaysShownInline:!1,isNewToUser:!1,posting:"",html:""},initialize:function(){this.webroot=i.settings.get("webroot")+"entries/",this.methodToCakePhpUrl=t.clone(this.methodToCakePhpUrl),this.methodToCakePhpUrl.read="threadLine/",this.set("isAlwaysShownInline",i.currentUser.get("user_show_inline")||!1),this.listenTo(this,"change:html",this._setIsNewToUser)},_setIsNewToUser:function(){this.set("isNewToUser","1"===$(this.get("html")).data("data-new"))}});return t.extend(o.prototype,n),o}),define("collections/threadlines",["underscore","backbone","models/threadline"],function(t,e,i){var n=e.Collection.extend({model:i});return n}),define("views/threadline-spinner",["jquery","underscore","backbone"],function(t,e,i){var n=i.View.extend({running:!1,show:function(){var t=e.bind(function(){return this.running===!1?(this.$el.css({opacity:1}),void 0):(this.$el.animate({opacity:.1},900,e.bind(function(){this.$el.animate({opacity:1},500,t())},this)),void 0)},this);this.running=!0,t()},hide:function(){this.running=!1}});return n}),define("text!templates/threadline-spinner.html",[],function(){return''}),define("views/postingActionBookmark",["jquery","underscore","marionette","models/app"],function(t,e,i,n){return i.ItemView.extend({tagName:"a",className:"btn-bookmark-add",template:e.template(''),events:{click:"_onClick"},modelEvents:{"change:isBookmarked":"_toggle"},initialize:function(){this._shouldRender()&&(this.$el.attr("href","#"),this.render())},_shouldRender:function(){return n.currentUser.isLoggedIn()?!0:!1},_onClick:function(t){t.preventDefault(),this.model.get("isBookmarked")?window.location=n.settings.get("webroot")+"bookmarks/index/#"+this.model.get("id"):this.model.set("isBookmarked",!0)},_toggle:function(){var e=this.$("i");this.model.get("isBookmarked")?(e.removeClass("fa-bookmark-o"),e.addClass("fa-bookmark"),this.$el.attr("title",t.i18n.__("Entry is bookmarked"))):(e.removeClass("fa-bookmark"),e.addClass("fa-bookmark-o"),this.$el.attr("title",t.i18n.__("Bookmark the entry")))},onRender:function(){this._toggle()}})}),define("views/postingActionSolves",["jquery","marionette","models/app"],function(t,e,i){return e.ItemView.extend({tagName:"a",className:"btn-solves",template:_.template(''),events:{click:"_onClick"},modelEvents:{"change:isSolves":"_toggle"},initialize:function(){this._shouldRender()&&(this.$el.attr({href:"#",title:t.i18n.__("Mark entry as helpful")}),this.render())},_shouldRender:function(){return i.currentUser.isLoggedIn()?this.model.isRoot()?!1:this.model.get("rootEntryUserId")!==i.currentUser.get("id")?!1:!0:!1},_onClick:function(t){t.preventDefault(),this.model.toggle("isSolves")},_toggle:function(){var e=this.$("i"),i=this.model.get("isSolves"),n="";i?(e.addClass("solves-isSolved"),e.removeClass("fa-badge-solves-o"),e.addClass("fa-badge-solves"),n=this.$el.html(),n=t(n).removeClass("fa-lg")):(e.removeClass("fa-badge-solves"),e.addClass("fa-badge-solves-o"),e.removeClass("solves-isSolved")),this._toggleGlobal(n)},_toggleGlobal:function(e){var i=t(".solves."+this.model.get("id"));i.html(e)},onRender:function(){this._toggle()}})}),define("views/postingAction",["jquery","underscore","marionette","models/app","views/postingActionBookmark","views/postingActionSolves"],function(t,e,i,n,o,s){var r=i.ItemView.extend({events:{"click .js-btn-setAnsweringForm":"onBtnAnswer"},_jsButtons:[o,s],initialize:function(){this._initFormElements(),this.listenTo(this.model,"change:isAnsweringFormShown",this._toggleAnsweringForm)},_initFormElements:function(){e.each(this._jsButtons,function(t){this.$(".js-buttons").append(new t({model:this.model}).$el)},this)},onBtnAnswer:function(t){t.preventDefault(),this.model.set("isAnsweringFormShown",!0)},_toggleAnsweringForm:function(){this.model.get("isAnsweringFormShown")?this.$el.slideUp("fast"):this.$el.slideDown("fast")}});return r}),define("models/geshi",["underscore","backbone"],function(t,e){var i=e.Model.extend({defaults:{isPlaintext:!1}});return i}),define("collections/geshis",["underscore","backbone","models/geshi"],function(t,e,i){var n=e.Collection.extend({model:i});return n}),define("views/geshi",["jquery","underscore","backbone","models/geshi"],function(t,e,i,n){var o=i.View.extend({plainText:!1,htmlText:!1,events:{"click .geshi-plain-text":"_togglePlaintext"},initialize:function(){this.model=new n,this.collection.push(this.model),this.block=this.$(".geshi-plain-text").next(),this._setPlaintextButton(),this.listenTo(this.model,"change",this.render)},_setPlaintextButton:function(){this.model.get("isPlaintext")?this.$(".geshi-plain-text").html(""):this.$(".geshi-plain-text").html("")},_togglePlaintext:function(t){t.preventDefault(),this.model.set("isPlaintext",!this.model.get("isPlaintext"))},_extractPlaintext:function(){this.plainText===!1&&(this.htmlText=this.block.html(),"Microsoft Internet Explorer"===navigator.appName?(this.htmlText=this.htmlText.replace(/\n\r/g,"+"),this.plainText=t(this.htmlText).text().replace(/\+\+/g,"\r")):this.plainText=this.block.text().replace(/code /g,"code \n"))},_renderText:function(){this.model.get("isPlaintext")?this.block.text(this.plainText).wrapInner('
'):this.block.html(this.htmlText)},render:function(){return this._setPlaintextButton(),this._extractPlaintext(),this._renderText(),this}});return o}),define("views/postingContent",["jquery","underscore","marionette","collections/geshis","views/geshi"],function(t,e,i,n,o){return i.ItemView.extend({initialize:function(){this.listenTo(this.model,"change:isAnsweringFormShown",this._toggleAnsweringForm),this.listenTo(this.model,"change:html",this.render),this._initGeshi(".c_bbc_code-wrapper")},_toggleAnsweringForm:function(){this.model.get("isAnsweringFormShown")?this._hideSignature():this._showSignature()},_showSignature:function(){this.$(".signature").slideDown("fast")},_hideSignature:function(){this.$(".signature").slideUp("fast")},_initGeshi:function(t){var e=this.$(t);if(e.length>0){var i=new n;e.each(function(t,e){new o({el:e,collection:i})})}},render:function(){return this.$el.html(this.model.get("html")),this._initGeshi(".c_bbc_code-wrapper"),this}})}),define("models/upload",["underscore","backbone","models/app","cakeRest"],function(t,e,i,n){var o=e.Model.extend({initialize:function(){this.webroot=i.settings.get("webroot")+"uploads/"}});return t.extend(o.prototype,n),o}),define("collections/uploads",["underscore","backbone","models/upload"],function(t,e,i){var n=e.Collection.extend({model:i,initialize:function(t){this.url=t.url+"uploads/index/"}});return n}),define("text!templates/upload.html",[],function(){return'
\n <%= linkDelete %>\n
\n
\n
\n <%= linkImage %>\n
\n
\n
\n \n
\n'}),function(t,e){"function"==typeof define&&define.amd?define("lib/saito/jquery.insertAtCaret",["jquery"],function(t){return e(t)}):e(jQuery)}(this,function(t){t.fn.insertAtCaret=function(t){var e,i=this[0],n=0,o=i.selectionStart||"0"===i.selectionStart?"standard":document.selection?"ie":!1;"ie"===o?(i.focus(),e=document.selection.createRange(),e.moveStart("character",-i.value.length),n=e.text.length):"standard"===o&&(n=i.selectionStart);var s=i.value.substring(0,n),r=i.value.substring(n,i.value.length);return i.value=s+t+r,n+=t.length,"ie"===o?(i.focus(),e=document.selection.createRange(),e.moveStart("character",-i.value.length),e.moveStart("character",n),e.moveEnd("character",0),e.select()):"standard"===o&&(i.selectionStart=n,i.selectionEnd=n,i.focus()),this}}),define("views/upload",["jquery","underscore","backbone","models/app","text!templates/upload.html","lib/saito/jquery.insertAtCaret"],function(t,e,i,n,o){var s=i.View.extend({className:"box-content upload_box current",events:{"click .upload_box_delete":"_removeUpload","click .btn-submit":"_insert"},initialize:function(t){this.textarea=t.textarea,this.listenTo(this.model,"destroy",this._uploadRemoved)},_removeUpload:function(t){t.preventDefault(),this.model.destroy({success:e.bind(function(t,e){n.eventBus.trigger("notification",e)},this)})},_uploadRemoved:function(){this.remove()},_insert:function(e){e.preventDefault(),t(this.textarea).insertAtCaret("[upload]"+this.model.get("name")+"[/upload]")},render:function(){return this.$el.html(e.template(o,this.model.toJSON())),this}});return s}),function(t){function e(){}jQuery.event.props.push("dataTransfer");var i,n,o={fallback_id:"",url:"",refresh:1e3,paramname:"userfile",allowedfiletypes:[],maxfiles:25,maxfilesize:1,queuefiles:0,queuewait:200,data:{},headers:{},drop:e,dragStart:e,dragEnter:e,dragOver:e,dragLeave:e,docEnter:e,docOver:e,docLeave:e,beforeEach:e,afterAll:e,rename:e,error:function(t){alert(t)},uploadStarted:e,uploadFinished:e,progressUpdated:e,globalProgressUpdated:e,speedUpdated:e},s=["BrowserNotSupported","TooManyFiles","FileTooLarge","FileTypeNotAllowed","NotFound","NotReadable","AbortError","ReadError"],r=!1,a=0;t.fn.filedrop=function(e){function l(t){return C.drop.call(this,t)===!1?!1:(n=t.dataTransfer.files,null===n||void 0===n||0===n.length?(C.error(s[0]),!1):(a=n.length,d(),t.preventDefault(),!1))}function h(e,i,n,o){var s="--",r="\r\n",a="";if(C.data){var l=t.param(C.data).replace(/\+/g,"%20").split(/&/);t.each(l,function(){var t=this.split("=",2),e=decodeURIComponent(t[0]),i=decodeURIComponent(t[1]);a+=s,a+=o,a+=r,a+='Content-Disposition: form-data; name="'+e+'"',a+=r,a+=r,a+=i,a+=r})}return a+=s,a+=o,a+=r,a+='Content-Disposition: form-data; name="'+C.paramname+'"',a+='; filename="'+e+'"',a+=r,a+="Content-Type: "+n,a+=r,a+=r,a+=i,a+=r,a+=s,a+=o,a+=s,a+=r}function c(t){if(t.lengthComputable){var e=Math.round(100*t.loaded/t.total);if(this.currentProgress!==e){this.currentProgress=e,C.progressUpdated(this.index,this.file,this.currentProgress),T[this.global_progress_index]=this.currentProgress,u();var i=(new Date).getTime(),n=i-this.currentStart;if(n>=C.refresh){var o=t.loaded-this.startData,s=o/n;C.speedUpdated(this.index,this.file,s),this.startData=t.loaded,this.currentStart=i}}}}function u(){if(0!==T.length){var t,e=0;for(t in T)T.hasOwnProperty(t)&&(e+=T[t]);C.globalProgressUpdated(Math.round(e/T.length))}}function d(){if(r=!1,!n)return C.error(s[0]),!1;if(C.allowedfiletypes.push&&C.allowedfiletypes.length)for(var e=n.length;e--;)if(!n[e].type||t.inArray(n[e].type,C.allowedfiletypes)<0)return C.error(s[3],n[e]),!1;var i=0,o=0;if(a>C.maxfiles&&0===C.queuefiles)return C.error(s[1]),!1;for(var l=[],d=[],v=[],y=0;a>y;y++)l.push(y);var b=function(t){setTimeout(w,t)},w=function(){var t;if(r)return!1;if(C.queuefiles>0&&d.length>=C.queuefiles)return b(C.queuewait);t=l[0],l.splice(0,1),d.push(t);try{if(m(n[t])!==!1){if(t===a)return;var e=new FileReader,i=1048576*C.maxfilesize;if(e.index=t,n[t].size>i)return C.error(s[2],n[t],t),d.forEach(function(e,i){e===t&&d.splice(i,1)}),o++,!0;e.onerror=function(t){switch(t.target.error.code){case t.target.error.NOT_FOUND_ERR:return C.error(s[4]),!1;case t.target.error.NOT_READABLE_ERR:return C.error(s[5]),!1;case t.target.error.ABORT_ERR:return C.error(s[6]),!1;default:return C.error(s[7]),!1}},e.onloadend=C.beforeSend?function(e){C.beforeSend(n[t],t,function(){_(e)})}:_,e.readAsBinaryString(n[t])}else o++}catch(h){return d.forEach(function(e,i){e===t&&d.splice(i,1)}),C.error(s[0]),!1}l.length>0&&w()},_=function(e){var s=("undefined"==typeof e.srcElement?e.target:e.srcElement).index;void 0===e.target.index&&(e.target.index=f(e.total));var l,m=new XMLHttpRequest,y=m.upload,b=n[e.target.index],w=e.target.index,_=(new Date).getTime(),x="------multipartformboundary"+(new Date).getTime(),k=T.length,S=p(b.name),I=b.type;C.withCredentials&&(m.withCredentials=C.withCredentials),l="string"==typeof S?h(S,e.target.result,I,x):h(b.name,e.target.result,I,x),y.index=w,y.file=b,y.downloadStartTime=_,y.currentStart=_,y.currentProgress=0,y.global_progress_index=k,y.startData=0,y.addEventListener("progress",c,!1),jQuery.isFunction(C.url)?m.open("POST",C.url(),!0):m.open("POST",C.url,!0),m.setRequestHeader("content-type","multipart/form-data; boundary="+x),t.each(C.headers,function(t,e){m.setRequestHeader(t,e)}),m.sendAsBinary(l),T[k]=0,u(),C.uploadStarted(w,b,a),m.onload=function(){var t=null;if(m.responseText)try{t=jQuery.parseJSON(m.responseText)}catch(e){t=m.responseText}var n=(new Date).getTime(),l=n-_,h=C.uploadFinished(w,b,t,l,m);i++,d.forEach(function(t,e){t===s&&d.splice(e,1)}),v.push(s),T[k]=100,u(),i===a-o&&g(),h===!1&&(r=!0),(m.status<200||m.status>299)&&C.error(m.statusText,b,s,m.status)}};w()}function f(t){for(var e=0;a>e;e++)if(n[e].size===t)return e;return void 0}function p(t){return C.rename(t)}function m(t){return C.beforeEach(t)}function g(){return C.afterAll()}function v(t){clearTimeout(i),t.preventDefault(),C.dragEnter.call(this,t)}function y(t){clearTimeout(i),t.preventDefault(),C.docOver.call(this,t),C.dragOver.call(this,t)}function b(t){clearTimeout(i),C.dragLeave.call(this,t),t.stopPropagation()}function w(t){return t.preventDefault(),C.docLeave.call(this,t),!1}function _(t){return clearTimeout(i),t.preventDefault(),C.docEnter.call(this,t),!1}function x(t){return clearTimeout(i),t.preventDefault(),C.docOver.call(this,t),!1}function k(t){i=setTimeout(function(e){return function(){C.docLeave.call(e,t)}}(this),200)}var C=t.extend({},o,e),T=[];return this.on("drop",l).on("dragstart",C.dragStart).on("dragenter",v).on("dragover",y).on("dragleave",b),t(document).on("drop",w).on("dragenter",_).on("dragover",x).on("dragleave",k),t("#"+C.fallback_id).change(function(t){C.drop(t),n=t.target.files,a=n.length,d()}),this};try{if(XMLHttpRequest.prototype.sendAsBinary)return;XMLHttpRequest.prototype.sendAsBinary=function(t){function e(t){return 255&t.charCodeAt(0)}var i=Array.prototype.map.call(t,e),n=new Uint8Array(i);this.send(n.buffer)}}catch(l){}}(jQuery),define("views/../../dev/vendors/jquery-filedrop/jquery.filedrop",function(){}),define("text!templates/uploadNew.html",[],function(){return'
\n
\n
\n
\n
\n \n
\n

<%- $.i18n.__(\'upload_new_title\') %>

\n

\n <%- $.i18n.__(\'upload_info\', {size: upload_size}) %>\n

\n
\n \n
\n\n'}),define("text!templates/spinner.html",[],function(){return'
\n'}),define("views/uploadNew",["jquery","underscore","backbone","../../dev/vendors/jquery-filedrop/jquery.filedrop","models/app","text!templates/uploadNew.html","text!templates/spinner.html","humanize"],function(t,e,i,n,o,s,r,a){var l=i.View.extend({className:"box-content upload_box upload-new",wasChild:"unset",events:{"change #Upload0File":"_uploadManual"},initialize:function(t){this.uploadUrl=o.settings.get("webroot")+"uploads/add",this.collection=t.collection},_initDropUploader:function(){this._browserSupportsDragAndDrop()&&window.FileReader?this.$(".upload-layer").filedrop({maxfiles:1,maxfilesize:o.settings.get("upload_max_img_size")/1024,url:this.uploadUrl,paramname:"data[Upload][0][file]",allowedfiletypes:["image/jpeg","image/jpg","image/png","image/gif"],dragOver:e.bind(function(){this._showDragIndicator()},this),dragLeave:e.bind(function(){this._hideDragIndicator()},this),uploadFinished:e.bind(function(t,e,i){this._postUpload(i)},this),beforeSend:e.bind(function(t,e,i){this._hideDragIndicator(),this._setUploadSpinner(),i()},this),error:e.bind(function(e,i){var n;switch(this._hideDragIndicator(),e){case"FileTypeNotAllowed":n=t.i18n.__("upload_fileTypeNotAllowed");break;case"FileTooLarge":n=t.i18n.__("upload_fileToLarge",{name:i.name});break;case"BrowserNotSupported":n=t.i18n.__("upload_browserNotSupported");break;case"TooManyFiles":n=t.i18n.__("upload_toManyFiles");break;default:n=e}o.eventBus.trigger("notification",{title:"Error",message:n,type:"error"})},this)}):this.$("h2").html(t.i18n.__("Upload"))},_browserSupportsDragAndDrop:function(){var t=this.$(".upload-layer")[0];return"draggable"in t||"ondragstart"in t&&"ondrop"in t},_showDragIndicator:function(){this.$(".upload-drag-indicator").fadeIn()},_hideDragIndicator:function(){this.$(".upload-drag-indicator").fadeOut()},_setUploadSpinner:function(){this.$(".upload_box_header").html(r)},_uploadManual:function(t){var e,i,n=!0;t.preventDefault();try{e=new FormData,i=this.$("#Upload0File")[0],e.append(i.name,i.files[0])}catch(o){n=!1}this._setUploadSpinner(),n?this._uploadAjax(e):this._uploadIFrame()},_uploadIFrame:function(){var t=this.$("form"),i=this.$("#uploadIFrame");i.load(e.bind(function(){this._postUpload(i.contents().find("body").html()),i.off("load")},this)),t.submit()},_uploadAjax:function(t){var i=new XMLHttpRequest;i.open("POST",this.uploadUrl),i.onloadend=e.bind(function(t){this._postUpload(t.target.response)},this),i.onerror=this._onUploadError,i.send(t)},_onUploadError:function(){o.eventBus.trigger("notification",{type:"error",message:t.i18n.__("upload_genericError")})},_postUpload:function(t){if(e.isString(t))try{t=JSON.parse(t)}catch(i){this._onUploadError()}o.eventBus.trigger("notification",t),this.collection.fetch({reset:!0}),this.render()},render:function(){return this.$el.html(e.template(s)({url:this.uploadUrl,upload_size:a.filesize(o.settings.get("upload_max_img_size"))})),this._initDropUploader(),this}});return l}),define("text!templates/uploads.html",[],function(){return'
\n
\n
\n
\n'}),define("views/uploads",["jquery","underscore","backbone","models/app","collections/uploads","views/upload","views/uploadNew","text!templates/uploads.html"],function(t,e,i,n,o,s,r,a){var l=i.View.extend({events:{"click .current .btn-submit":"_closeDialog"},initialize:function(t){this.textarea=t.textarea,this.collection=new o({url:n.settings.get("webroot")}),this.listenTo(this.collection,"reset",this._addAll),this.$(".body").html(e.template(a)),this.uploadNewView=new r({collection:this.collection}),this.$(".content").append(this.uploadNewView.el),this.render(),this.collection.fetch({reset:!0})},_addOne:function(t){var e=new s({model:t,textarea:this.textarea});this.$(".upload-new").after(e.render().el)},_addAll:function(){this._removeAll(),this.collection.each(this._addOne,this)},_removeAll:function(){this.$(".upload_box.current").remove()},_setDialogSize:function(){this.$el.dialog("option","width",window.innerWidth-80),this.$el.dialog("option","height",window.innerHeight-80)},_closeDialog:function(){this.$el.dialog("close")},render:function(){return this.uploadNewView.render(),this.$el.dialog({title:t.i18n.__("Upload"),modal:!0,draggable:!1,resizable:!1,position:[40,40],hide:"fade"}),this._setDialogSize(),t(window).resize(e.bind(function(){this._setDialogSize()},this)),window.onorientationchange=e.bind(function(){this._setDialogSize()},this),this}});return l}),define("lib/saito/markItUp.media",["jquery","underscore"],function(t,e){var i={cleanUp:function(t){return t=t.replace(/https:\/\/www\.dropbox\.com\//,"https://dl.dropbox.com/")}},n={rawUrlCleaner:[i],multimedia:function(i,o){var s=t.trim(i),r="([\\/?]|$)",a=new RegExp("\\.(png|gif|jpg|jpeg|webp)"+r,"i"),l=new RegExp("\\.(mp4|webm|m4v)"+r,"i"),h=new RegExp("\\.(m4a|ogg|mp3|wav|opus)"+r,"i"),c=/.*?<\/iframe>/i.exec(t)[1];return e=e.replace(/["']/g,""),"[iframe"+e+"][/iframe]"},_videoFallback:function(t){var e,i="";if(/http/.test(t)===!1&&(t="http://"+t),/(http|https):\/\/(\w+:{0,1}\w*@)?(\S+)(:[0-9]+)?(\/|\/([\w#!:.?+=&%@!\-\/]))?/i.test(t)){var o=t.match(/(https?:\/\/)?(www\.)?(.[^\/:]+)/i).pop();if("youtu.be"===o&&/youtu.be\/(.*?)(&.*)?$/.test(t))return e=t.match(/youtu.be\/(.*?)(&.*)?$/)[1],i=n._createIframe({url:"//www.youtube.com/embed/"+e}),i=n._videoIframe(i);if("youtube.com"===o)return/v=(.*?)(&.*)?$/.test(t)&&(e=t.match(/v=(.*?)(&.*)?$/)[1],i=n._createIframe({url:"//www.youtube.com/embed/"+e}),i=n._videoIframe(i)),i}return i},_embedly:function(t){return"[embed]"+t+"[/embed]"},_createIframe:function(t){return''}};return n}),define("text!templates/mediaInsert.html",[],function(){return'
\n \n \n
\n
\n
\n \n
\n
\n
\n \n
\n'}),define("views/mediaInsert",["jquery","underscore","backbone","models/app","lib/saito/markItUp.media","text!templates/mediaInsert.html"],function(t,e,i,n,o,s){return i.View.extend({template:e.template(s),events:{"click #markitup_media_btn":"_insert"},initialize:function(){void 0!==this.model&&null!==this.model&&this.listenTo(this.model,"change:isAnsweringFormShown",this.remove)},_insert:function(e){var i,s;e.preventDefault(),s=o,i=s.multimedia(this.$("#markitup_media_txta").val(),{embedlyEnabled:n.settings.get("embedly_enabled")===!0}),""===i?this._invalidInput():(t.markItUp({replaceWith:i}),this._closeDialog())},_hideErrorMessages:function(){this.$("#markitup_media_message").hide()},_invalidInput:function(){this.$("#markitup_media_message").show(),this.$el.dialog().parent().effect("shake",{times:2},250)},_closeDialog:function(){this.$el.dialog("close"),this._hideErrorMessages(),this.$("#markitup_media_txta").val("")},_showDialog:function(){this.$el.dialog({show:{effect:"scale",duration:200},hide:{effect:"fade",duration:200},title:t.i18n.__("Multimedia"),resizable:!1,open:function(){setTimeout(function(){t("#markitup_media_txta").focus()},210)},close:e.bind(function(){this._hideErrorMessages()},this)})},render:function(){return this.$el.html(this.template),this._showDialog(),this}})}),define("models/preview",["underscore","backbone","models/app"],function(t,e,i){var n=e.Model.extend({defaults:{rendered:"",data:"",fetchingData:0},initialize:function(){this.webroot=i.settings.get("webroot"),this.listenTo(this,"change:data",this._fetchRendered)},_fetchRendered:function(){this.set("fetchingData",1),$.post(this.webroot+"entries/preview/",this.get("data"),t.bind(function(t){this.set("fetchingData",0),this.set("rendered",t.html),i.eventBus.trigger("notificationUnset","all"),i.eventBus.trigger("notification",t)},this),"json")}});return n}),define("views/preview",["jquery","underscore","backbone","text!templates/spinner.html"],function(t,e,i,n){var o=i.View.extend({initialize:function(){this.render(),this.listenTo(this.model,"change:fetchingData",this._spinner),this.listenTo(this.model,"change:rendered",this.render)},_spinner:function(t){t.get("fetchingData")?this.$el.html(n):this.$el.html("")},render:function(){var t;return t=this.model.get("rendered"),t||(t=""),this.$el.html(t),this}});return o}),function(t){var e={_scrollToTop:function(e){t("body").animate({scrollTop:e.offset().top-10,easing:"swing"},300)},_scrollToBottom:function(i){t("body").animate({scrollTop:e._elementBottom(i)-t(window).height()+20,easing:"swing"},300,function(){e._isHeigherThanView(i)&&e._scrollToTop(i)})},_elementBottom:function(t){return t.offset().top+t.height()},_isScrolledIntoView:function(i){if(0===t(i).length)return!0;var n=t(window).scrollTop(),o=n+t(window).height(),s=t(i).offset().top,r=e._elementBottom(i);return o>=r&&s>=n},_isHeigherThanView:function(e){return t(window).height()<=e.height()}},i={top:function(){var i;return i=t(this),e._isScrolledIntoView(i)||e._scrollToTop(i),this},bottom:function(){var i;return i=t(this),e._isScrolledIntoView(i)||e._scrollToBottom(i),this},isInView:function(){var i;return i=t(this),e._isScrolledIntoView(i)}};t.fn.scrollIntoView=function(e){return i[e]?i[e].apply(this,Array.prototype.slice.call(arguments,1)):"object"!=typeof e&&e?(t.error("Method "+e+" does not exist on jQuery.scrollIntoView"),void 0):i.init.apply(this,arguments)}}(jQuery),define("lib/saito/jquery.scrollIntoView",function(){}),define("views/answering",["jquery","underscore","backbone","models/app","views/uploads","views/mediaInsert","models/preview","views/preview","lib/saito/jquery.scrollIntoView"],function(t,e,i,n,o,s,r,a){var l=i.View.extend({rendered:!1,answeringForm:!1,preview:!1,mediaView:!1,sendInProgress:!1,model:null,events:{"click .btn-previewClose":"_closePreview","click .btn-preview":"_showPreview","click .btn-markItUp-Upload":"_upload","click .btn-markItUp-Media":"_media","click .btn-submit":"_send","click .btn-cite":"_cite","keypress .inp-subject":"_onKeyPressSubject"},initialize:function(t){this.parentThreadline=t.parentThreadline||null,this.parentThreadline||this._setupTextArea(),this.listenTo(n.eventBus,"isAppVisible",this._focusSubject)},_cite:function(t){t.preventDefault();var e=this.$(".cite-container"),i=this.$(".btn-cite").data("text"),n=this.$textarea.val();this.$textarea.val(i+"\n\n"+n),e.slideToggle(),this.$textarea.focus()},_onKeyPressSubject:function(t){13===t.keyCode&&this._send(t)},_upload:function(t){var e;t.preventDefault(),e=new o({el:"#markitup_upload",textarea:this.$textarea[0]})},_media:function(t){t.preventDefault(),this.mediaView===!1&&(this.mediaView=new s({el:"#markitup_media",model:this.model})),this.mediaView.render()},_showPreview:function(t){var e;t.preventDefault(),this.$(".preview").slideDown("fast"),this.preview===!1&&(e=new r,this.preview=new a({el:this.$(".preview .content"),model:e})),this.preview.model.set("data",this.$("form").serialize())},_closePreview:function(t){t.preventDefault(),this.$(".preview").slideUp("fast") -},_setupTextArea:function(){this.$textarea=t("textarea#EntryText")},_requestAnsweringForm:function(){t.ajax({url:n.settings.get("webroot")+"entries/add/"+this.model.get("id"),success:e.bind(function(t){this.answeringForm=t,this.render()},this)})},_postRendering:function(){this.$el.scrollIntoView("bottom"),this._focusSubject()},_focusSubject:function(){this.$(".postingform input[type=text]:first").focus()},_send:function(t){return this.sendInProgress?(t.preventDefault(),void 0):(this.sendInProgress=!0,this.parentThreadline?this._sendInline(t):this._sendRedirect(t),void 0)},_sendRedirect:function(i){var n=this.$(".btn-submit")[0];if(i.preventDefault(),"object"==typeof n.validity&&n.form.checkValidity()===!1){var o=e.bind(function(){this.checkValidityDummy||(this.checkValidityDummy=t("",{type:"submit",style:"display: none;"}),t(n).after(this.checkValidityDummy)),this.checkValidityDummy.click()},this);o(),this.sendInProgress=!1}else n.disabled=!0,n.form.submit()},_sendInline:function(i){i.preventDefault(),t.ajax({url:n.settings.get("webroot")+"entries/add",type:"POST",dataType:"json",data:this.$("#EntryAddForm").serialize(),beforeSend:e.bind(function(){this.$(".btn.btn-submit").attr("disabled","disabled")},this),success:e.bind(function(t){this.model.set({isAnsweringFormShown:!1}),null!==this.parentThreadline&&this.parentThreadline.set("isInlineOpened",!1),n.eventBus.trigger("newEntry",{tid:t.tid,pid:this.model.get("id"),id:t.id})},this)})},render:function(){return this.answeringForm===!1?this._requestAnsweringForm():this.rendered===!1&&(this.rendered=!0,this.$el.html(this.answeringForm),this._setupTextArea(),e.defer(function(t){t._postRendering()},this)),this}});return l}),define("views/postingSlider",["jquery","marionette","models/app","views/answering","text!templates/spinner.html"],function(t,e,i,n,o){return e.ItemView.extend({answeringForm:!1,events:{"click .btn-answeringClose":"onBtnClose"},initialize:function(t){this.parentThreadline=t.parentThreadline||null,this.listenTo(this.model,"change:isAnsweringFormShown",this.toggleAnsweringForm)},onBtnClose:function(t){t.preventDefault(),this.model.set("isAnsweringFormShown",!1)},toggleAnsweringForm:function(){this.model.get("isAnsweringFormShown")?(this._hideAllAnsweringForms(),this._showAnsweringForm()):this._hideAnsweringForm()},_showAnsweringForm:function(){i.eventBus.trigger("breakAutoreload"),this.answeringForm===!1&&this.$el.html(o),this.$el.slideDown("fast"),this.answeringForm===!1&&(this.answeringForm=new n({el:this.$el,model:this.model,parentThreadline:this.parentThreadline})),this.answeringForm.render()},_hideAnsweringForm:function(){this.$el.slideUp("fast")},_hideAllAnsweringForms:function(){this.collection.forEach(function(t){t.get("id")!==this.model.get("id")&&t.set("isAnsweringFormShown",!1)},this)}})}),define("views/postingLayout",["underscore","marionette","views/postingAction","views/postingContent","views/postingSlider"],function(t,e,i,n,o){var s=e.Layout.extend({initialize:function(e){t.defaults(e,{inline:!1,parentThreadline:!1}),e.inline&&(this.model.fetchHtml(),this.$el.html(this.model.get("html")));var s=this.$(".js-data").data("entry");this.model.set(s,{silent:!0}),new n({el:this.$(".content"),model:this.model}),new i({el:this.$(".box-footer-form"),model:this.model}),new o({el:this.$(".posting_formular_slider"),model:this.model,collection:this.collection,parentThreadline:e.parentThreadline})}});return s}),function(t,e){"function"==typeof define&&define.amd?define("lib/saito/backbone.modelHelper",["underscore","backbone"],function(i,n){return e(i||t._,n||t.Backbone)}):e(_,Backbone)}(this,function(t,e){e.Model.prototype.toggle=function(t){this.set(t,!this.get(t))}}),define("models/posting",["underscore","backbone","models/app","lib/saito/backbone.modelHelper"],function(t,e,i){var n=e.Model.extend({defaults:{isBookmarked:!1,isSolves:!1,isAnsweringFormShown:!1,html:""},initialize:function(){this.listenTo(this,"change:isSolves",this.syncSolved),this.listenTo(this,"change:isBookmarked",this.syncBookmarked)},isRoot:function(){var e=this.get("pid");if(!t.isNumber(e))throw"pid is not a number.";return 0===e},syncBookmarked:function(){this.get("isBookmarked")&&$.ajax({url:i.settings.get("webroot")+"bookmarks/add",type:"POST",dataType:"json",data:"id="+this.get("id")})},syncSolved:function(){$.ajax({url:i.settings.get("webroot")+"entries/solve/"+this.get("id"),type:"POST",dateType:"json"})},fetchHtml:function(){$.ajax({success:t.bind(function(t){this.set("html",t)},this),type:"POST",async:!1,dateType:"html",url:i.settings.get("webroot")+"entries/view/"+this.get("id")})}});return n}),define("views/threadlines",["jquery","underscore","backbone","models/app","models/threadline","views/threadline-spinner","text!templates/threadline-spinner.html","views/postingLayout","models/posting","lib/saito/jquery.scrollIntoView"],function(t,e,i,n,o,s,r,a,l){var h=i.View.extend({className:"js-thread_line",tagName:"li",spinnerTpl:e.template(r),postings:null,events:{"click .btn_show_thread":"toggleInlineOpen","click .link_show_thread":"toggleInlineOpenFromLink"},initialize:function(t){this.postings=t.postings,this.model=new o({id:t.id}),void 0===t.el?this.model.fetch():this.model.set({html:this.el},{silent:!0}),this.collection.add(this.model,{silent:!0}),this.attributes={"data-id":t.id},this.listenTo(this.model,"change:isInlineOpened",this._toggleInlineOpened),this.listenTo(this.model,"change:html",this.render)},toggleInlineOpenFromLink:function(t){this.model.get("isAlwaysShownInline")&&this.toggleInlineOpen(t)},toggleInlineOpen:function(t){t.preventDefault(),this.model.get("isInlineOpened")?this.model.set({isInlineOpened:!1}):this.model.set({isInlineOpened:!0})},_toggleInlineOpened:function(t,i){if(i){var n=this.model.id;this.model.get("isContentLoaded")?this._showInlineView():(this.tlsV=new s({el:this.$el.find(".thread_line-pre i")}),this.tlsV.show(),this.$el.find(".js-thread_line-content").after(this.spinnerTpl({id:n})),this.$el.find(".js-btn-strip").on("click",e.bind(this.toggleInlineOpen,this)),this._insertContent())}else this._closeInlineView()},_insertContent:function(){var t,e;t=this.model.get("id"),this.postingModel=new l({id:t}),this.postings.add(this.postingModel),e=new a({el:this.$(".t_s"),inline:!0,model:this.postingModel,collection:this.postings,parentThreadline:this.model}),this.model.set("isContentLoaded",!0),this._showInlineView()},_showInlineView:function(){var t=e.bind(function(){var t=this.model.get("shouldScrollOnInlineOpen");this.tlsV.hide(),t?this.$el.scrollIntoView("isInView")===!1&&this.$el.scrollIntoView("bottom"):this.model.set("shouldScrollOnInlineOpen",!0)},this);this.$el.find(".js-thread_line-content").fadeOut(100,e.bind(function(){this.$(".js-thread_inline").show(0,t)},this))},_closeInlineView:function(){this.$(".js-thread_inline").hide(0,e.bind(function(){this.$el.find(".js-thread_line-content").slideDown(),this._scrollLineIntoView()},this))},_scrollLineIntoView:function(){var t=this.$(".js-thread_line-content");t.scrollIntoView("isInView")||t.scrollIntoView("top").effect("highlight",{times:1},3e3)},render:function(){var e,i,n;return i=this.model.get("html"),i.length>0&&(e=this.$el,n=t(this.model.get("html")),this.setElement(n),e.replaceWith(n)),this}});return h}),define("models/thread",["underscore","backbone","collections/threadlines"],function(t,e,i){var n=e.Model.extend({defaults:{isThreadCollapsed:!1},initialize:function(){this.threadlines=new i}});return n}),define("collections/threads",["underscore","backbone","backboneLocalStorage","models/thread"],function(t,e,i,n){var o=e.Collection.extend({model:n,localStorage:new i("Threads")});return o}),define("views/thread",["jquery","underscore","backbone","models/app","collections/threadlines","views/threadlines"],function(t,e,i,n,o,s){var r=i.View.extend({className:"thread_box",events:{"click .btn-threadCollapse":"collapseThread","click .js-btn-openAllThreadlines":"openAllThreadlines","click .js-btn-closeAllThreadlines":"closeAllThreadlines","click .js-btn-showAllNewThreadlines":"showAllNewThreadlines"},initialize:function(e){this.postings=e.postings,this.$rootUl=this.$("ul.root"),this.$subThreadRootIl=t(this.$rootUl.find("li:not(:first-child)")[0]),this.model.get("isThreadCollapsed")?this.hide():this.show(),this.listenTo(n.eventBus,"newEntry",this._showNewThreadLine),this.listenTo(this.model,"change:isThreadCollapsed",this.toggleCollapseThread)},_showNewThreadLine:function(t){var e;t.tid===this.model.get("id")&&(e=new s({id:t.id,collection:this.model.threadlines,postings:this.postings}),this._appendThreadlineToThread(t.pid,e.render().$el))},_appendThreadlineToThread:function(t,e){var i,n;i=this.$('.js-thread_line[data-id="'+t+'"]'),n=i.next().not(".js_threadline").find("ul:first"),0===n.length?e.wrap("
    ").parent().wrap("
  • ").parent().insertAfter(i):n.append(e)},openAllThreadlines:function(t){t.preventDefault(),e.each(this.model.threadlines.where({isInlineOpened:!1}),function(t){t.set({isInlineOpened:!0,shouldScrollOnInlineOpen:!1})},this)},closeAllThreadlines:function(t){t&&t.preventDefault(),e.each(this.model.threadlines.where({isInlineOpened:!0}),function(t){t.set({isInlineOpened:!1})},this)},showAllNewThreadlines:function(t){t.preventDefault(),e.each(this.model.threadlines.where({isInlineOpened:!1,isNewToUser:!0}),function(t){t.set({isInlineOpened:!0,shouldScrollOnInlineOpen:!1})},this)},collapseThread:function(t){t.preventDefault(),this.closeAllThreadlines(),this.model.toggle("isThreadCollapsed"),this.model.save()},toggleCollapseThread:function(t,e){e?this.slideUp():this.slideDown()},slideUp:function(){this.$subThreadRootIl.slideUp(300),this.markHidden()},slideDown:function(){this.$subThreadRootIl.slideDown(300),this.markShown()},hide:function(){this.$subThreadRootIl.hide(),this.markHidden()},show:function(){this.$subThreadRootIl.show(),this.markShown()},markShown:function(){t(this.el).find(".fa-thread-closed").removeClass("fa-thread-closed").addClass("fa-thread-open")},markHidden:function(){t(this.el).find(".fa-thread-open").removeClass("fa-thread-open").addClass("fa-thread-closed")}});return r}),define("collections/postings",["underscore","backbone","models/posting"],function(t,e,i){var n=e.Collection.extend({model:i});return n}),define("models/bookmark",["underscore","backbone","models/app","cakeRest"],function(t,e,i,n){var o=e.Model.extend({initialize:function(){this.webroot=i.settings.get("webroot")+"bookmarks/"}});return t.extend(o.prototype,n),o}),define("collections/bookmarks",["underscore","backbone","models/bookmark"],function(t,e,i){var n=e.Collection.extend({model:i});return n}),define("views/bookmark",["jquery","underscore","backbone"],function(t,e,i){var n=i.View.extend({events:{"click .btn-bookmark-delete":"deleteBookmark"},initialize:function(){e.bindAll(this,"render"),this.model.on("destroy",this.removeBookmark,this)},deleteBookmark:function(t){t.preventDefault(),this.model.destroy()},removeBookmark:function(){this.$el.hide("slide",null,500,function(){t(this).remove()})}});return n}),define("views/bookmarks",["jquery","underscore","backbone","views/bookmark"],function(t,e,i,n){var o=i.View.extend({initialize:function(){this.initCollectionFromDom(".js-bookmark",this.collection,n)}});return o}),define("views/helps",["jquery","underscore","backbone"],function(t,e,i){var n=i.View.extend({isHelpShown:!1,events:function(){var t={};return t["click "+this.indicatorName]="toggle",t},initialize:function(t){this.indicatorName=t.indicatorName,this.elementName=t.elementName,this.activateHelpButton(),this.placeHelp()},activateHelpButton:function(){this.isHelpOnPage()&&t(this.indicatorName).removeClass("no-color")},placeHelp:function(){var e={trigger:"manual",html:!0},i=["bottom","right","left"];for(var n in i)t(this.elementName+"-"+i[n]).popover(t.extend(e,{placement:i[n]}));t(this.indicatorName).popover({placement:"left",trigger:"manual"})},isHelpOnPage:function(){return this.$el.find(this.elementName).length>0},toggle:function(){event.preventDefault(),this.isHelpShown?this.hide():this.show()},show:function(){this.isHelpShown=!0,this.isHelpOnPage()?t(this.elementName).popover("show"):t(this.indicatorName).popover("show")},hide:function(){this.isHelpShown=!1,t(this.elementName).popover("hide"),t(this.indicatorName).popover("hide")}});return n}),define("views/categoryChooser",["jquery","underscore","backbone"],function(t,e,i){return i.View.extend({initialize:function(){this.$el.dialog({autoOpen:!1,show:{effect:"scale",duration:200},hide:{effect:"fade",duration:200},width:400,position:[t("#btn-category-chooser").offset().left+t("#btn-category-chooser").width()-t(window).scrollLeft()-410,t("#btn-category-chooser").offset().top-t(window).scrollTop()+t("#btn-category-chooser").height()],title:t.i18n.__("Categories"),resizable:!1})},toggle:function(){this.$el.dialog("isOpen")?this.$el.dialog("close"):this.$el.dialog("open")}})}),define("models/slidetab",["underscore","backbone","app/vent","models/app"],function(t,e,i,n){var o=e.Model.extend({defaults:{isOpen:!1},initialize:function(){this.webroot=n.settings.get("webroot"),this.listenTo(this,"change:isOpen",this.onChangeIsOpen)},onChangeIsOpen:function(){i.vent.trigger("slidetab:open",{slidetab:this.get("id"),open:this.get("isOpen")})},sync:function(){$.ajax({url:this.webroot+"users/ajax_toggle/show_"+this.get("id")})}});return o}),define("collections/slidetabs",["underscore","backbone","models/app","models/slidetab"],function(t,e,i,n){var o=e.Collection.extend({model:n,initialize:function(){i.reqres.setHandler("slidetab:open",t.bind(this.isOpen,this))},isOpen:function(t){return this.get(t).get("isOpen")}});return o}),define("views/slidetab",["jquery","underscore","backbone"],function(t,e,i){var n=i.View.extend({events:{"click .slidetab-tab":"clickSlidetab"},initialize:function(t){this.collection=t.collection,this.model.set({isOpen:this.isOpen()},{silent:!0}),this.listenTo(this.model,"change",this.toggleSlidetab)},isOpen:function(){return this.$el.find(".slidetab-content").is(":visible")},clickSlidetab:function(){this.model.save("isOpen",!this.model.get("isOpen"))},toggleSlidetab:function(){this.model.get("isOpen")?this.show():this.hide(),this.toggleSlidetabTabInfo()},show:function(){this.$el.animate({width:250}),this.$el.find(".slidetab-content").css("display","block")},hide:function(){this.$el.animate({width:28},e.bind(function(){this.$el.find(".slidetab-content").css("display","none")},this))},toggleSlidetabTabInfo:function(){this.$el.find(".slidetab-tab-info").toggle()}});return n}),define("views/slidetabs",["jquery","underscore","backbone","models/app","views/slidetab"],function(t,e,i,n,o){var s=i.View.extend({initialize:function(){this.webroot=n.settings.get("webroot"),this.initCollectionFromDom(".slidetab",this.collection,o),this.makeSortable()},makeSortable:function(){var i=this.webroot;this.$el.sortable({handle:".slidetab-tab",start:e.bind(function(){this.$el.css("overflow","visible")},this),stop:e.bind(function(){this.$el.css("overflow","hidden")},this),update:function(){var e=t(this).sortable("toArray",{attribute:"data-id"});e=e.map(function(t){return"slidetab_"+t}),t.ajax({type:"POST",url:i+"users/ajax_set",data:{data:{User:{slidetab_order:e}}},dataType:"json"})}})}});return s}),define("views/app",["jquery","underscore","backbone","models/app","collections/threadlines","views/threadlines","collections/threads","views/thread","collections/postings","models/posting","views/postingLayout","collections/bookmarks","views/bookmarks","views/helps","views/categoryChooser","collections/slidetabs","views/slidetabs","views/answering","jqueryUi"],function(t,e,i,n,o,s,r,a,l,h,c,u,d,f,p,m,g,v){var y=i.View.extend({el:t("body"),autoPageReloadTimer:!1,events:{"click #showLoginForm":"showLoginForm","focus #header-searchField":"widenSearchField","click #btn-scrollToTop":"scrollToTop","click #btn-manuallyMarkAsRead":"manuallyMarkAsRead","click #btn-category-chooser":"toggleCategoryChooser"},initialize:function(){this.threads=new r,"entries"===n.request.controller&&"index"===n.request.action&&this.threads.fetch(),this.postings=new l,this.threadLines=new o,this.listenTo(n.eventBus,"initAutoreload",this.initAutoreload),this.listenTo(n.eventBus,"breakAutoreload",this.breakAutoreload),this.$el.on("dialogopen",this.fixJqueryUiDialog)},initFromDom:function(i){if(t(".thread_box").each(e.bind(function(e,i){var o,s;s=parseInt(t(i).attr("data-id"),10),this.threads.get(s)||this.threads.add([{id:s,isThreadCollapsed:"entries"===n.request.controller&&"index"===n.request.action&&n.currentUser.get("user_show_thread_collapsed")}],{silent:!0}),o=new a({el:t(i),postings:this.postings,model:this.threads.get(s)})},this)),t(".js-entry-view-core").each(e.bind(function(e,i){var n,o,s;n=parseInt(i.getAttribute("data-id"),10),s=new h({id:n}),this.postings.add(s,{silent:!0}),o=new c({el:t(i),model:this.postings.get(n),collection:this.postings})},this)),t(".js-thread_line").each(e.bind(function(e,i){var n,o,r,a;o=parseInt(i.getAttribute("data-tid"),10),a=this.threads.get(o)?this.threads.get(o).threadlines:this.threadLines,r=parseInt(i.getAttribute("data-id"),10),n=new s({el:t(i),id:r,postings:this.postings,collection:a})},this)),this.initAutoreload(),this.initBookmarks("#bookmarks"),this.initHelp(".shp"),this.initSlidetabs("#slidetabs"),this.initCategoryChooser("#category-chooser"),t(".entry.add-not-inline").length>0&&(this.answeringForm=new v({el:this.$(".entry.add-not-inline"),id:"foo"})),n.status.start(),this._showPage(i.SaitoApp.timeAppStart,i.contentTimer),n.eventBus.trigger("notification",i.SaitoApp),window.location.href.indexOf("/jump:")>-1){var o=/jump:(\d+)/.exec(window.location.href);this.scrollToThread(o[1]),window.history.replaceState("object or string","Title",window.location.pathname.replace(/jump:\d+(\/)?/,""))}},_showPage:function(e,i){var o=function(){n.eventBus.trigger("isAppVisible",!0)};n.request.isMobile||(new Date).getTime()-e>1500?(t("#content").css("visibility","visible"),o()):t("#content").css({visibility:"visible",opacity:0}).animate({opacity:1},{duration:150,easing:"easeInOutQuart",complete:o}),i.cancel()},fixJqueryUiDialog:function(){t(".ui-icon-closethick").attr("class","jqueryUi-closethick-fix").html("")},initBookmarks:function(e){var i;if(t(e).length){var n=new u;i=new d({el:e,collection:n})}},initSlidetabs:function(t){var e,i;e=new m,i=new g({el:t,collection:e})},initCategoryChooser:function(e){t(e).length>0&&(this.categoryChooser=new p({el:e}))},toggleCategoryChooser:function(){this.categoryChooser.toggle()},initHelp:function(t){new f({el:"body",elementName:t,indicatorName:"#shp-show"})},scrollToThread:function(e){t(".thread_box[data-id="+e+"]")[0].scrollIntoView("top")},initAutoreload:function(){this.breakAutoreload(),n.settings.get("autoPageReload")&&(this.autoPageReloadTimer=setTimeout(e.bind(function(){window.location=n.settings.get("webroot")+"entries/"},this),1e3*n.settings.get("autoPageReload")))},breakAutoreload:function(){this.autoPageReloadTimer!==!1&&(clearTimeout(this.autoPageReloadTimer),this.autoPageReloadTimer=!1)},widenSearchField:function(e){var i=350;e.preventDefault(),t(e.currentTarget).width()",{"class":"ui-pnotify "+l.addclass,css:{display:"none"},mouseenter:function(t){l.nonblock&&t.stopPropagation(),l.mouse_reset&&"out"==a&&(p.stop(!0),a="in",p.css("height","auto").animate({width:l.width,opacity:l.nonblock?l.nonblock_opacity:l.opacity},"fast")),l.nonblock&&p.animate({opacity:l.nonblock_opacity},"fast"),l.hide&&l.mouse_reset&&p.pnotify_cancel_remove(),l.sticker&&!l.nonblock&&p.sticker.trigger("pnotify_icon").css("visibility","visible"),l.closer&&!l.nonblock&&p.closer.css("visibility","visible")},mouseleave:function(e){l.nonblock&&e.stopPropagation(),c=null,p.css("cursor","auto"),l.nonblock&&"out"!=a&&p.animate({opacity:l.opacity},"fast"),l.hide&&l.mouse_reset&&p.pnotify_queue_remove(),l.sticker_hover&&p.sticker.css("visibility","hidden"),l.closer_hover&&p.closer.css("visibility","hidden"),t.pnotify_position_all()},mouseover:function(t){l.nonblock&&t.stopPropagation()},mouseout:function(t){l.nonblock&&t.stopPropagation()},mousemove:function(t){l.nonblock&&(t.stopPropagation(),d(t,"onmousemove"))},mousedown:function(t){l.nonblock&&(t.stopPropagation(),t.preventDefault(),d(t,"onmousedown"))},mouseup:function(t){l.nonblock&&(t.stopPropagation(),t.preventDefault(),d(t,"onmouseup"))},click:function(t){l.nonblock&&(t.stopPropagation(),d(t,"onclick"))},dblclick:function(t){l.nonblock&&(t.stopPropagation(),d(t,"ondblclick"))}});p.opts=l,p.container=t("
    ",{"class":f.container+" ui-pnotify-container "+("error"==l.type?f.error:"info"==l.type?f.info:"success"==l.type?f.success:f.notice)}).appendTo(p),""!=l.cornerclass&&p.container.removeClass("ui-corner-all").addClass(l.cornerclass),l.shadow&&p.container.addClass("ui-pnotify-shadow"),p.pnotify_version="1.2.0",p.pnotify=function(e){var i=l;"string"==typeof e?l.text=e:l=t.extend({},l,e);for(var n in l)"string"==typeof n&&n.match(/^pnotify_/)&&(l[n.replace(/^pnotify_/,"")]=l[n]);return p.opts=l,l.cornerclass!=i.cornerclass&&p.container.removeClass("ui-corner-all").addClass(l.cornerclass),l.shadow!=i.shadow&&(l.shadow?p.container.addClass("ui-pnotify-shadow"):p.container.removeClass("ui-pnotify-shadow")),l.addclass===!1?p.removeClass(i.addclass):l.addclass!==i.addclass&&p.removeClass(i.addclass).addClass(l.addclass),l.title===!1?p.title_container.slideUp("fast"):l.title!==i.title&&(l.title_escape?p.title_container.text(l.title).slideDown(200):p.title_container.html(l.title).slideDown(200)),l.text===!1?p.text_container.slideUp("fast"):l.text!==i.text&&(l.text_escape?p.text_container.text(l.text).slideDown(200):p.text_container.html(l.insert_brs?String(l.text).replace(/\n/g,"
    "):l.text).slideDown(200)),p.pnotify_history=l.history,p.pnotify_hide=l.hide,l.type!=i.type&&p.container.removeClass(f.error+" "+f.notice+" "+f.success+" "+f.info).addClass("error"==l.type?f.error:"info"==l.type?f.info:"success"==l.type?f.success:f.notice),(l.icon!==i.icon||l.icon===!0&&l.type!=i.type)&&(p.container.find("div.ui-pnotify-icon").remove(),l.icon!==!1&&t("
    ",{"class":"ui-pnotify-icon"}).append(t("",{"class":l.icon===!0?"error"==l.type?f.error_icon:"info"==l.type?f.info_icon:"success"==l.type?f.success_icon:f.notice_icon:l.icon})).prependTo(p.container)),l.width!==i.width&&p.animate({width:l.width}),l.min_height!==i.min_height&&p.container.animate({minHeight:l.min_height}),l.opacity!==i.opacity&&p.fadeTo(l.animate_speed,l.opacity),!l.closer||l.nonblock?p.closer.css("display","none"):p.closer.css("display","block"),!l.sticker||l.nonblock?p.sticker.css("display","none"):p.sticker.css("display","block"),p.sticker.trigger("pnotify_icon"),l.sticker_hover?p.sticker.css("visibility","hidden"):l.nonblock||p.sticker.css("visibility","visible"),l.closer_hover?p.closer.css("visibility","hidden"):l.nonblock||p.closer.css("visibility","visible"),l.hide?i.hide||p.pnotify_queue_remove():p.pnotify_cancel_remove(),p.pnotify_queue_position(),p},p.pnotify_position=function(t){var e=p.opts.stack;if(e){e.nextpos1||(e.nextpos1=e.firstpos1),e.nextpos2||(e.nextpos2=e.firstpos2),e.addpos2||(e.addpos2=0);var i="none"==p.css("display");if(!i||t){var n,s,r,a={};switch(e.dir1){case"down":r="top";break;case"up":r="bottom";break;case"left":r="right";break;case"right":r="left"}n=parseInt(p.css(r)),isNaN(n)&&(n=0),"undefined"!=typeof e.firstpos1||i||(e.firstpos1=n,e.nextpos1=e.firstpos1);var l;switch(e.dir2){case"down":l="top";break;case"up":l="bottom";break;case"left":l="right";break;case"right":l="left"}if(s=parseInt(p.css(l)),isNaN(s)&&(s=0),"undefined"!=typeof e.firstpos2||i||(e.firstpos2=s,e.nextpos2=e.firstpos2),("down"==e.dir1&&e.nextpos1+p.height()>o.height()||"up"==e.dir1&&e.nextpos1+p.height()>o.height()||"left"==e.dir1&&e.nextpos1+p.width()>o.width()||"right"==e.dir1&&e.nextpos1+p.width()>o.width())&&(e.nextpos1=e.firstpos1,e.nextpos2+=e.addpos2+("undefined"==typeof e.spacing2?25:e.spacing2),e.addpos2=0),e.animation&&e.nextpos2e.addpos2&&(e.addpos2=p.height());break;case"left":case"right":p.outerWidth(!0)>e.addpos2&&(e.addpos2=p.width())}if(e.nextpos1)if(e.animation&&(n>e.nextpos1||a.top||a.bottom||a.right||a.left))switch(e.dir1){case"down":a.top=e.nextpos1+"px";break;case"up":a.bottom=e.nextpos1+"px";break;case"left":a.right=e.nextpos1+"px";break;case"right":a.left=e.nextpos1+"px"}else p.css(r,e.nextpos1+"px");switch((a.top||a.bottom||a.right||a.left)&&p.animate(a,{duration:500,queue:!1}),e.dir1){case"down":case"up":e.nextpos1+=p.height()+("undefined"==typeof e.spacing1?25:e.spacing1);break;case"left":case"right":e.nextpos1+=p.width()+("undefined"==typeof e.spacing1?25:e.spacing1)}}}},p.pnotify_queue_position=function(e){i&&clearTimeout(i),e||(e=10),i=setTimeout(t.pnotify_position_all,e)},p.pnotify_display=function(){p.parent().length||p.appendTo(n),l.before_open&&l.before_open(p)===!1||("top"!=l.stack.push&&p.pnotify_position(!0),"fade"==l.animation||"fade"==l.animation.effect_in?p.show().fadeTo(0,0).hide():1!=l.opacity&&p.show().fadeTo(0,l.opacity).hide(),p.animate_in(function(){l.after_open&&l.after_open(p),p.pnotify_queue_position(),l.hide&&p.pnotify_queue_remove()}))},p.pnotify_remove=function(){p.timer&&(window.clearTimeout(p.timer),p.timer=null),l.before_close&&l.before_close(p)===!1||p.animate_out(function(){l.after_close&&l.after_close(p)===!1||(p.pnotify_queue_position(),l.remove&&p.detach())})},p.animate_in=function(t){a="in";var e;e="undefined"!=typeof l.animation.effect_in?l.animation.effect_in:l.animation,"none"==e?(p.show(),t()):"show"==e?p.show(l.animate_speed,t):"fade"==e?p.show().fadeTo(l.animate_speed,l.opacity,t):"slide"==e?p.slideDown(l.animate_speed,t):"function"==typeof e?e("in",t,p):p.show(e,"object"==typeof l.animation.options_in?l.animation.options_in:{},l.animate_speed,t)},p.animate_out=function(t){a="out";var e;e="undefined"!=typeof l.animation.effect_out?l.animation.effect_out:l.animation,"none"==e?(p.hide(),t()):"show"==e?p.hide(l.animate_speed,t):"fade"==e?p.fadeOut(l.animate_speed,t):"slide"==e?p.slideUp(l.animate_speed,t):"function"==typeof e?e("out",t,p):p.hide(e,"object"==typeof l.animation.options_out?l.animation.options_out:{},l.animate_speed,t)},p.pnotify_cancel_remove=function(){p.timer&&window.clearTimeout(p.timer)},p.pnotify_queue_remove=function(){p.pnotify_cancel_remove(),p.timer=window.setTimeout(function(){p.pnotify_remove()},isNaN(l.delay)?0:l.delay)},p.closer=t("
    ",{"class":"ui-pnotify-closer",css:{cursor:"pointer",visibility:l.closer_hover?"hidden":"visible"},click:function(){p.pnotify_remove(),p.sticker.css("visibility","hidden"),p.closer.css("visibility","hidden")}}).append(t("",{"class":f.closer})).appendTo(p.container),(!l.closer||l.nonblock)&&p.closer.css("display","none"),p.sticker=t("
    ",{"class":"ui-pnotify-sticker",css:{cursor:"pointer",visibility:l.sticker_hover?"hidden":"visible"},click:function(){l.hide=!l.hide,l.hide?p.pnotify_queue_remove():p.pnotify_cancel_remove(),t(this).trigger("pnotify_icon")}}).bind("pnotify_icon",function(){t(this).children().removeClass(f.pin_up+" "+f.pin_down).addClass(l.hide?f.pin_up:f.pin_down)}).append(t("",{"class":f.pin_up})).appendTo(p.container),(!l.sticker||l.nonblock)&&p.sticker.css("display","none"),l.icon!==!1&&t("
    ",{"class":"ui-pnotify-icon"}).append(t("",{"class":l.icon===!0?"error"==l.type?f.error_icon:"info"==l.type?f.info_icon:"success"==l.type?f.success_icon:f.notice_icon:l.icon})).prependTo(p.container),p.title_container=t("

    ",{"class":"ui-pnotify-title"}).appendTo(p.container),l.title===!1?p.title_container.hide():l.title_escape?p.title_container.text(l.title):p.title_container.html(l.title),p.text_container=t("
    ",{"class":"ui-pnotify-text"}).appendTo(p.container),l.text===!1?p.text_container.hide():l.text_escape?p.text_container.text(l.text):p.text_container.html(l.insert_brs?String(l.text).replace(/\n/g,"
    "):l.text),"string"==typeof l.width&&p.css("width",l.width),"string"==typeof l.min_height&&p.container.css("min-height",l.min_height),p.pnotify_history=l.history,p.pnotify_hide=l.hide;var m=o.data("pnotify");if((null==m||"object"!=typeof m)&&(m=[]),m="top"==l.stack.push?t.merge([p],m):t.merge(m,[p]),o.data("pnotify",m),"top"==l.stack.push&&p.pnotify_queue_position(1),l.after_init&&l.after_init(p),l.history){var g=o.data("pnotify_history");if("undefined"==typeof g){g=t("
    ",{"class":"ui-pnotify-history-container "+f.hi_menu,mouseleave:function(){g.animate({top:"-"+e+"px"},{duration:100,queue:!1})}}).append(t("
    ",{"class":"ui-pnotify-history-header",text:"Redisplay"})).append(t("\n
    \n \n
    \n
    \n
    \n\n\n'}),define("text!templates/spinner.html",[],function(){return'
    \n'}),define("views/uploadNew",["jquery","underscore","backbone","../../dev/vendors/jquery-filedrop/jquery.filedrop","models/app","text!templates/uploadNew.html","text!templates/spinner.html","humanize"],function(t,e,i,n,o,s,r,a){var l=i.View.extend({className:"box-content upload_box upload-new",wasChild:"unset",events:{"change #Upload0File":"_uploadManual"},initialize:function(t){this.uploadUrl=o.settings.get("webroot")+"uploads/add",this.collection=t.collection},_initDropUploader:function(){this._browserSupportsDragAndDrop()&&window.FileReader?this.$(".upload-layer").filedrop({maxfiles:1,maxfilesize:o.settings.get("upload_max_img_size")/1024,url:this.uploadUrl,paramname:"data[Upload][0][file]",allowedfiletypes:["image/jpeg","image/jpg","image/png","image/gif"],dragOver:e.bind(function(){this._showDragIndicator()},this),dragLeave:e.bind(function(){this._hideDragIndicator()},this),uploadFinished:e.bind(function(t,e,i){this._postUpload(i)},this),beforeSend:e.bind(function(t,e,i){this._hideDragIndicator(),this._setUploadSpinner(),i()},this),error:e.bind(function(e,i){var n;switch(this._hideDragIndicator(),e){case"FileTypeNotAllowed":n=t.i18n.__("upload_fileTypeNotAllowed");break;case"FileTooLarge":n=t.i18n.__("upload_fileToLarge",{name:i.name});break;case"BrowserNotSupported":n=t.i18n.__("upload_browserNotSupported");break;case"TooManyFiles":n=t.i18n.__("upload_toManyFiles");break;default:n=e}o.eventBus.trigger("notification",{title:"Error",message:n,type:"error"})},this)}):this.$("h2").html(t.i18n.__("Upload"))},_browserSupportsDragAndDrop:function(){var t=this.$(".upload-layer")[0];return"draggable"in t||"ondragstart"in t&&"ondrop"in t},_showDragIndicator:function(){this.$(".upload-drag-indicator").fadeIn()},_hideDragIndicator:function(){this.$(".upload-drag-indicator").fadeOut()},_setUploadSpinner:function(){this.$(".upload_box_header").html(r)},_uploadManual:function(t){var e,i,n=!0;t.preventDefault();try{e=new FormData,i=this.$("#Upload0File")[0],e.append(i.name,i.files[0])}catch(o){n=!1}this._setUploadSpinner(),n?this._uploadAjax(e):this._uploadIFrame()},_uploadIFrame:function(){var t=this.$("form"),i=this.$("#uploadIFrame");i.load(e.bind(function(){this._postUpload(i.contents().find("body").html()),i.off("load")},this)),t.submit()},_uploadAjax:function(t){var i=new XMLHttpRequest;i.open("POST",this.uploadUrl),i.onloadend=e.bind(function(t){this._postUpload(t.target.response)},this),i.onerror=this._onUploadError,i.send(t)},_onUploadError:function(){o.eventBus.trigger("notification",{type:"error",message:t.i18n.__("upload_genericError")})},_postUpload:function(t){if(e.isString(t))try{t=JSON.parse(t)}catch(i){this._onUploadError()}o.eventBus.trigger("notification",t),this.collection.fetch({reset:!0}),this.render()},render:function(){return this.$el.html(e.template(s)({url:this.uploadUrl,upload_size:a.filesize(o.settings.get("upload_max_img_size"))})),this._initDropUploader(),this}});return l}),define("text!templates/uploads.html",[],function(){return'
    \n
    \n
    \n
    \n'}),define("views/uploads",["jquery","underscore","backbone","models/app","collections/uploads","views/upload","views/uploadNew","text!templates/uploads.html"],function(t,e,i,n,o,s,r,a){var l=i.View.extend({events:{"click .current .btn-submit":"_closeDialog"},initialize:function(t){this.textarea=t.textarea,this.collection=new o({url:n.settings.get("webroot")}),this.listenTo(this.collection,"reset",this._addAll),this.$(".body").html(e.template(a)),this.uploadNewView=new r({collection:this.collection}),this.$(".content").append(this.uploadNewView.el),this.render(),this.collection.fetch({reset:!0})},_addOne:function(t){var e=new s({model:t,textarea:this.textarea});this.$(".upload-new").after(e.render().el)},_addAll:function(){this._removeAll(),this.collection.each(this._addOne,this)},_removeAll:function(){this.$(".upload_box.current").remove()},_setDialogSize:function(){this.$el.dialog("option","width",window.innerWidth-80),this.$el.dialog("option","height",window.innerHeight-80)},_closeDialog:function(){this.$el.dialog("close")},render:function(){return this.uploadNewView.render(),this.$el.dialog({title:t.i18n.__("Upload"),modal:!0,draggable:!1,resizable:!1,position:[40,40],hide:"fade"}),this._setDialogSize(),t(window).resize(e.bind(function(){this._setDialogSize()},this)),window.onorientationchange=e.bind(function(){this._setDialogSize()},this),this}});return l}),define("lib/saito/markItUp.media",["jquery","underscore"],function(t,e){var i={cleanUp:function(t){return t=t.replace(/https:\/\/www\.dropbox\.com\//,"https://dl.dropbox.com/")}},n={rawUrlCleaner:[i],multimedia:function(i,o){var s=t.trim(i),r="([\\/?]|$)",a=new RegExp("\\.(png|gif|jpg|jpeg|webp)"+r,"i"),l=new RegExp("\\.(mp4|webm|m4v)"+r,"i"),h=new RegExp("\\.(m4a|ogg|mp3|wav|opus)"+r,"i"),c=/.*?<\/iframe>/i.exec(t)[1];return e=e.replace(/["']/g,""),"[iframe"+e+"][/iframe]"},_videoFallback:function(t){var e,i="";if(/http/.test(t)===!1&&(t="http://"+t),/(http|https):\/\/(\w+:{0,1}\w*@)?(\S+)(:[0-9]+)?(\/|\/([\w#!:.?+=&%@!\-\/]))?/i.test(t)){var o=t.match(/(https?:\/\/)?(www\.)?(.[^\/:]+)/i).pop();if("youtu.be"===o&&/youtu.be\/(.*?)(&.*)?$/.test(t))return e=t.match(/youtu.be\/(.*?)(&.*)?$/)[1],i=n._createIframe({url:"//www.youtube.com/embed/"+e}),i=n._videoIframe(i);if("youtube.com"===o)return/v=(.*?)(&.*)?$/.test(t)&&(e=t.match(/v=(.*?)(&.*)?$/)[1],i=n._createIframe({url:"//www.youtube.com/embed/"+e}),i=n._videoIframe(i)),i}return i},_embedly:function(t){return"[embed]"+t+"[/embed]"},_createIframe:function(t){return''}};return n}),define("text!templates/mediaInsert.html",[],function(){return'
    \n \n \n
    \n
    \n
    \n \n
    \n
    \n
    \n \n
    \n'}),define("views/mediaInsert",["jquery","underscore","backbone","models/app","lib/saito/markItUp.media","text!templates/mediaInsert.html"],function(t,e,i,n,o,s){return i.View.extend({template:e.template(s),events:{"click #markitup_media_btn":"_insert"},initialize:function(){void 0!==this.model&&null!==this.model&&this.listenTo(this.model,"change:isAnsweringFormShown",this.remove)},_insert:function(e){var i,s;e.preventDefault(),s=o,i=s.multimedia(this.$("#markitup_media_txta").val(),{embedlyEnabled:n.settings.get("embedly_enabled")===!0}),""===i?this._invalidInput():(t.markItUp({replaceWith:i}),this._closeDialog())},_hideErrorMessages:function(){this.$("#markitup_media_message").hide()},_invalidInput:function(){this.$("#markitup_media_message").show(),this.$el.dialog().parent().effect("shake",{times:2},250)},_closeDialog:function(){this.$el.dialog("close"),this._hideErrorMessages(),this.$("#markitup_media_txta").val("")},_showDialog:function(){this.$el.dialog({show:{effect:"scale",duration:200},hide:{effect:"fade",duration:200},title:t.i18n.__("Multimedia"),resizable:!1,open:function(){setTimeout(function(){t("#markitup_media_txta").focus()},210)},close:e.bind(function(){this._hideErrorMessages()},this)})},render:function(){return this.$el.html(this.template),this._showDialog(),this}})}),define("models/preview",["underscore","backbone","models/app"],function(t,e,i){var n=e.Model.extend({defaults:{rendered:"",data:"",fetchingData:0},initialize:function(){this.webroot=i.settings.get("webroot"),this.listenTo(this,"change:data",this._fetchRendered)},_fetchRendered:function(){this.set("fetchingData",1),$.post(this.webroot+"entries/preview/",this.get("data"),t.bind(function(t){this.set("fetchingData",0),this.set("rendered",t.html),i.eventBus.trigger("notificationUnset","all"),i.eventBus.trigger("notification",t)},this),"json")}});return n}),define("views/preview",["jquery","underscore","backbone","text!templates/spinner.html"],function(t,e,i,n){var o=i.View.extend({initialize:function(){this.render(),this.listenTo(this.model,"change:fetchingData",this._spinner),this.listenTo(this.model,"change:rendered",this.render)},_spinner:function(t){t.get("fetchingData")?this.$el.html(n):this.$el.html("")},render:function(){var t;return t=this.model.get("rendered"),t||(t=""),this.$el.html(t),this}});return o}),function(t){var e={_scrollToTop:function(e){t("body").animate({scrollTop:e.offset().top-10,easing:"swing"},300)},_scrollToBottom:function(i){t("body").animate({scrollTop:e._elementBottom(i)-t(window).height()+20,easing:"swing"},300,function(){e._isHeigherThanView(i)&&e._scrollToTop(i)})},_elementBottom:function(t){return t.offset().top+t.height()},_isScrolledIntoView:function(i){if(0===t(i).length)return!0;var n=t(window).scrollTop(),o=n+t(window).height(),s=t(i).offset().top,r=e._elementBottom(i);return o>=r&&s>=n},_isHeigherThanView:function(e){return t(window).height()<=e.height()}},i={top:function(){var i;return i=t(this),e._isScrolledIntoView(i)||e._scrollToTop(i),this},bottom:function(){var i;return i=t(this),e._isScrolledIntoView(i)||e._scrollToBottom(i),this},isInView:function(){var i;return i=t(this),e._isScrolledIntoView(i)}};t.fn.scrollIntoView=function(e){return i[e]?i[e].apply(this,Array.prototype.slice.call(arguments,1)):"object"!=typeof e&&e?(t.error("Method "+e+" does not exist on jQuery.scrollIntoView"),void 0):i.init.apply(this,arguments)}}(jQuery),define("lib/saito/jquery.scrollIntoView",function(){}),define("views/answering",["jquery","underscore","backbone","models/app","views/uploads","views/mediaInsert","models/preview","views/preview","lib/saito/jquery.scrollIntoView"],function(t,e,i,n,o,s,r,a){var l=i.View.extend({rendered:!1,answeringForm:!1,preview:!1,mediaView:!1,sendInProgress:!1,model:null,events:{"click .btn-previewClose":"_closePreview","click .btn-preview":"_showPreview","click .btn-markItUp-Upload":"_upload","click .btn-markItUp-Media":"_media","click .btn-submit":"_send","click .btn-cite":"_cite","keypress .inp-subject":"_onKeyPressSubject"},initialize:function(t){this.parentThreadline=t.parentThreadline||null,this.parentThreadline||this._setupTextArea(),this.listenTo(n.eventBus,"isAppVisible",this._focusSubject)},_cite:function(t){t.preventDefault();var e=this.$(".cite-container"),i=this.$(".btn-cite").data("text"),n=this.$textarea.val();this.$textarea.val(i+"\n\n"+n),e.slideToggle(),this.$textarea.focus()},_onKeyPressSubject:function(t){13===t.keyCode&&this._send(t)},_upload:function(t){var e;t.preventDefault(),e=new o({el:"#markitup_upload",textarea:this.$textarea[0]}) +},_media:function(t){t.preventDefault(),this.mediaView===!1&&(this.mediaView=new s({el:"#markitup_media",model:this.model})),this.mediaView.render()},_showPreview:function(t){var e;t.preventDefault(),this.$(".preview").slideDown("fast"),this.preview===!1&&(e=new r,this.preview=new a({el:this.$(".preview .content"),model:e})),this.preview.model.set("data",this.$("form").serialize())},_closePreview:function(t){t.preventDefault(),this.$(".preview").slideUp("fast")},_setupTextArea:function(){this.$textarea=t("textarea#EntryText")},_requestAnsweringForm:function(){t.ajax({url:n.settings.get("webroot")+"entries/add/"+this.model.get("id"),success:e.bind(function(t){this.answeringForm=t,this.render()},this)})},_postRendering:function(){this.$el.scrollIntoView("bottom"),this._focusSubject()},_focusSubject:function(){this.$(".postingform input[type=text]:first").focus()},_send:function(t){return this.sendInProgress?(t.preventDefault(),void 0):(this.sendInProgress=!0,this.parentThreadline?this._sendInline(t):this._sendRedirect(t),void 0)},_sendRedirect:function(i){var n=this.$(".btn-submit")[0];if(i.preventDefault(),"object"==typeof n.validity&&n.form.checkValidity()===!1){var o=e.bind(function(){this.checkValidityDummy||(this.checkValidityDummy=t("",{type:"submit",style:"display: none;"}),t(n).after(this.checkValidityDummy)),this.checkValidityDummy.click()},this);o(),this.sendInProgress=!1}else n.disabled=!0,n.form.submit()},_sendInline:function(i){i.preventDefault(),t.ajax({url:n.settings.get("webroot")+"entries/add",type:"POST",dataType:"json",data:this.$("#EntryAddForm").serialize(),beforeSend:e.bind(function(){this.$(".btn.btn-submit").attr("disabled","disabled")},this),success:e.bind(function(t){this.model.set({isAnsweringFormShown:!1}),null!==this.parentThreadline&&this.parentThreadline.set("isInlineOpened",!1),n.eventBus.trigger("newEntry",{tid:t.tid,pid:this.model.get("id"),id:t.id})},this)})},render:function(){return this.answeringForm===!1?this._requestAnsweringForm():this.rendered===!1&&(this.rendered=!0,this.$el.html(this.answeringForm),this._setupTextArea(),e.defer(function(t){t._postRendering()},this)),this}});return l}),define("views/postingSlider",["jquery","marionette","models/app","views/answering","text!templates/spinner.html"],function(t,e,i,n,o){return e.ItemView.extend({answeringForm:!1,events:{"click .btn-answeringClose":"onBtnClose"},initialize:function(t){this.parentThreadline=t.parentThreadline||null,this.listenTo(this.model,"change:isAnsweringFormShown",this.toggleAnsweringForm)},onBtnClose:function(t){t.preventDefault(),this.model.set("isAnsweringFormShown",!1)},toggleAnsweringForm:function(){this.model.get("isAnsweringFormShown")?(this._hideAllAnsweringForms(),this._showAnsweringForm()):this._hideAnsweringForm()},_showAnsweringForm:function(){i.eventBus.trigger("breakAutoreload"),this.answeringForm===!1&&this.$el.html(o),this.$el.slideDown("fast"),this.answeringForm===!1&&(this.answeringForm=new n({el:this.$el,model:this.model,parentThreadline:this.parentThreadline})),this.answeringForm.render()},_hideAnsweringForm:function(){this.$el.slideUp("fast")},_hideAllAnsweringForms:function(){this.collection.forEach(function(t){t.get("id")!==this.model.get("id")&&t.set("isAnsweringFormShown",!1)},this)}})}),define("views/postingLayout",["underscore","marionette","views/postingAction","views/postingContent","views/postingSlider"],function(t,e,i,n,o){var s=e.Layout.extend({initialize:function(e){t.defaults(e,{inline:!1,parentThreadline:!1}),e.inline&&(this.model.fetchHtml(),this.$el.html(this.model.get("html")));var s=this.$(".js-data").data("entry");this.model.set(s,{silent:!0}),new n({el:this.$(".content"),model:this.model}),new i({el:this.$(".box-footer-form"),model:this.model}),new o({el:this.$(".posting_formular_slider"),model:this.model,collection:this.collection,parentThreadline:e.parentThreadline})}});return s}),function(t,e){"function"==typeof define&&define.amd?define("lib/saito/backbone.modelHelper",["underscore","backbone"],function(i,n){return e(i||t._,n||t.Backbone)}):e(_,Backbone)}(this,function(t,e){e.Model.prototype.toggle=function(t){this.set(t,!this.get(t))}}),define("models/posting",["underscore","backbone","models/app","lib/saito/backbone.modelHelper"],function(t,e,i){var n=e.Model.extend({defaults:{isBookmarked:!1,isSolves:!1,isAnsweringFormShown:!1,html:""},initialize:function(){this.listenTo(this,"change:isSolves",this.syncSolved),this.listenTo(this,"change:isBookmarked",this.syncBookmarked)},isRoot:function(){var e=this.get("pid");if(!t.isNumber(e))throw"pid is not a number.";return 0===e},syncBookmarked:function(){this.get("isBookmarked")&&$.ajax({url:i.settings.get("webroot")+"bookmarks/add",type:"POST",dataType:"json",data:"id="+this.get("id")})},syncSolved:function(){$.ajax({url:i.settings.get("webroot")+"entries/solve/"+this.get("id"),type:"POST",dateType:"json"})},fetchHtml:function(){$.ajax({success:t.bind(function(t){this.set("html",t)},this),type:"POST",async:!1,dateType:"html",url:i.settings.get("webroot")+"entries/view/"+this.get("id")})}});return n}),define("views/threadlines",["jquery","underscore","backbone","models/app","models/threadline","views/threadline-spinner","text!templates/threadline-spinner.html","views/postingLayout","models/posting","lib/saito/jquery.scrollIntoView"],function(t,e,i,n,o,s,r,a,l){var h=i.View.extend({className:"js-thread_line",tagName:"li",spinnerTpl:e.template(r),postings:null,events:{"click .btn_show_thread":"toggleInlineOpen","click .link_show_thread":"toggleInlineOpenFromLink"},initialize:function(t){this.postings=t.postings,this.model=new o({id:t.id}),void 0===t.el?this.model.fetch():this.model.set({html:this.el},{silent:!0}),this.collection.add(this.model,{silent:!0}),this.attributes={"data-id":t.id},this.listenTo(this.model,"change:isInlineOpened",this._toggleInlineOpened),this.listenTo(this.model,"change:html",this.render)},toggleInlineOpenFromLink:function(t){this.model.get("isAlwaysShownInline")&&this.toggleInlineOpen(t)},toggleInlineOpen:function(t){t.preventDefault(),this.model.get("isInlineOpened")?this.model.set({isInlineOpened:!1}):this.model.set({isInlineOpened:!0})},_toggleInlineOpened:function(t,i){if(i){var n=this.model.id;this.model.get("isContentLoaded")?this._showInlineView():(this.tlsV=new s({el:this.$el.find(".thread_line-pre i")}),this.tlsV.show(),this.$el.find(".js-thread_line-content").after(this.spinnerTpl({id:n})),this.$el.find(".js-btn-strip").on("click",e.bind(this.toggleInlineOpen,this)),this._insertContent())}else this._closeInlineView()},_insertContent:function(){var t,e;t=this.model.get("id"),this.postingModel=new l({id:t}),this.postings.add(this.postingModel),e=new a({el:this.$(".t_s"),inline:!0,model:this.postingModel,collection:this.postings,parentThreadline:this.model}),this.model.set("isContentLoaded",!0),this._showInlineView()},_showInlineView:function(){var t=e.bind(function(){var t=this.model.get("shouldScrollOnInlineOpen");this.tlsV.hide(),t?this.$el.scrollIntoView("isInView")===!1&&this.$el.scrollIntoView("bottom"):this.model.set("shouldScrollOnInlineOpen",!0)},this);this.$el.find(".js-thread_line-content").fadeOut(100,e.bind(function(){this.$(".js-thread_inline").show(0,t)},this))},_closeInlineView:function(){this.$(".js-thread_inline").hide(0,e.bind(function(){this.$el.find(".js-thread_line-content").slideDown(),this._scrollLineIntoView()},this))},_scrollLineIntoView:function(){var t=this.$(".js-thread_line-content");t.scrollIntoView("isInView")||t.scrollIntoView("top").effect("highlight",{times:1},3e3)},render:function(){var e,i,n;return i=this.model.get("html"),i.length>0&&(e=this.$el,n=t(this.model.get("html")),this.setElement(n),e.replaceWith(n)),this}});return h}),define("models/thread",["underscore","backbone","collections/threadlines"],function(t,e,i){var n=e.Model.extend({defaults:{isThreadCollapsed:!1},initialize:function(){this.threadlines=new i}});return n}),define("collections/threads",["underscore","backbone","backboneLocalStorage","models/thread"],function(t,e,i,n){var o=e.Collection.extend({model:n,localStorage:new i("Threads")});return o}),define("views/thread",["jquery","underscore","backbone","models/app","collections/threadlines","views/threadlines"],function(t,e,i,n,o,s){var r=i.View.extend({className:"thread_box",events:{"click .btn-threadCollapse":"collapseThread","click .js-btn-openAllThreadlines":"openAllThreadlines","click .js-btn-closeAllThreadlines":"closeAllThreadlines","click .js-btn-showAllNewThreadlines":"showAllNewThreadlines"},initialize:function(e){this.postings=e.postings,this.$rootUl=this.$("ul.root"),this.$subThreadRootIl=t(this.$rootUl.find("li:not(:first-child)")[0]),this.model.get("isThreadCollapsed")?this.hide():this.show(),this.listenTo(n.eventBus,"newEntry",this._showNewThreadLine),this.listenTo(this.model,"change:isThreadCollapsed",this.toggleCollapseThread)},_showNewThreadLine:function(t){var e;t.tid===this.model.get("id")&&(e=new s({id:t.id,collection:this.model.threadlines,postings:this.postings}),this._appendThreadlineToThread(t.pid,e.render().$el))},_appendThreadlineToThread:function(t,e){var i,n;i=this.$('.js-thread_line[data-id="'+t+'"]'),n=i.next().not(".js_threadline").find("ul:first"),0===n.length?e.wrap("
      ").parent().wrap("
    • ").parent().insertAfter(i):n.append(e)},openAllThreadlines:function(t){t.preventDefault(),e.each(this.model.threadlines.where({isInlineOpened:!1}),function(t){t.set({isInlineOpened:!0,shouldScrollOnInlineOpen:!1})},this)},closeAllThreadlines:function(t){t&&t.preventDefault(),e.each(this.model.threadlines.where({isInlineOpened:!0}),function(t){t.set({isInlineOpened:!1})},this)},showAllNewThreadlines:function(t){t.preventDefault(),e.each(this.model.threadlines.where({isInlineOpened:!1,isNewToUser:!0}),function(t){t.set({isInlineOpened:!0,shouldScrollOnInlineOpen:!1})},this)},collapseThread:function(t){t.preventDefault(),this.closeAllThreadlines(),this.model.toggle("isThreadCollapsed"),this.model.save()},toggleCollapseThread:function(t,e){e?this.slideUp():this.slideDown()},slideUp:function(){this.$subThreadRootIl.slideUp(300),this.markHidden()},slideDown:function(){this.$subThreadRootIl.slideDown(300),this.markShown()},hide:function(){this.$subThreadRootIl.hide(),this.markHidden()},show:function(){this.$subThreadRootIl.show(),this.markShown()},markShown:function(){t(this.el).find(".fa-thread-closed").removeClass("fa-thread-closed").addClass("fa-thread-open")},markHidden:function(){t(this.el).find(".fa-thread-open").removeClass("fa-thread-open").addClass("fa-thread-closed")}});return r}),define("collections/postings",["underscore","backbone","models/posting"],function(t,e,i){var n=e.Collection.extend({model:i});return n}),define("models/bookmark",["underscore","backbone","models/app","cakeRest"],function(t,e,i,n){var o=e.Model.extend({initialize:function(){this.webroot=i.settings.get("webroot")+"bookmarks/"}});return t.extend(o.prototype,n),o}),define("collections/bookmarks",["underscore","backbone","models/bookmark"],function(t,e,i){var n=e.Collection.extend({model:i});return n}),define("views/bookmark",["jquery","underscore","backbone"],function(t,e,i){var n=i.View.extend({events:{"click .btn-bookmark-delete":"deleteBookmark"},initialize:function(){e.bindAll(this,"render"),this.model.on("destroy",this.removeBookmark,this)},deleteBookmark:function(t){t.preventDefault(),this.model.destroy()},removeBookmark:function(){this.$el.hide("slide",null,500,function(){t(this).remove()})}});return n}),define("views/bookmarks",["jquery","underscore","backbone","views/bookmark"],function(t,e,i,n){var o=i.View.extend({initialize:function(){this.initCollectionFromDom(".js-bookmark",this.collection,n)}});return o}),define("views/helps",["jquery","underscore","backbone"],function(t,e,i){var n=i.View.extend({isHelpShown:!1,events:function(){var t={};return t["click "+this.indicatorName]="toggle",t},initialize:function(t){this.indicatorName=t.indicatorName,this.elementName=t.elementName,this.activateHelpButton(),this.placeHelp()},activateHelpButton:function(){this.isHelpOnPage()&&t(this.indicatorName).removeClass("no-color")},placeHelp:function(){var e={trigger:"manual",html:!0},i=["bottom","right","left"];for(var n in i)t(this.elementName+"-"+i[n]).popover(t.extend(e,{placement:i[n]}));t(this.indicatorName).popover({placement:"left",trigger:"manual"})},isHelpOnPage:function(){return this.$el.find(this.elementName).length>0},toggle:function(){event.preventDefault(),this.isHelpShown?this.hide():this.show()},show:function(){this.isHelpShown=!0,this.isHelpOnPage()?t(this.elementName).popover("show"):t(this.indicatorName).popover("show")},hide:function(){this.isHelpShown=!1,t(this.elementName).popover("hide"),t(this.indicatorName).popover("hide")}});return n}),define("views/categoryChooser",["jquery","underscore","backbone"],function(t,e,i){return i.View.extend({initialize:function(){this.$el.dialog({autoOpen:!1,show:{effect:"scale",duration:200},hide:{effect:"fade",duration:200},width:400,position:[t("#btn-category-chooser").offset().left+t("#btn-category-chooser").width()-t(window).scrollLeft()-410,t("#btn-category-chooser").offset().top-t(window).scrollTop()+t("#btn-category-chooser").height()],title:t.i18n.__("Categories"),resizable:!1})},toggle:function(){this.$el.dialog("isOpen")?this.$el.dialog("close"):this.$el.dialog("open")}})}),define("models/slidetab",["underscore","backbone","app/vent","models/app"],function(t,e,i,n){var o=e.Model.extend({defaults:{isOpen:!1},initialize:function(){this.webroot=n.settings.get("webroot"),this.listenTo(this,"change:isOpen",this.onChangeIsOpen)},onChangeIsOpen:function(){i.vent.trigger("slidetab:open",{slidetab:this.get("id"),open:this.get("isOpen")})},sync:function(){$.ajax({url:this.webroot+"users/ajax_toggle/show_"+this.get("id")})}});return o}),define("collections/slidetabs",["underscore","backbone","models/app","models/slidetab"],function(t,e,i,n){var o=e.Collection.extend({model:n,initialize:function(){i.reqres.setHandler("slidetab:open",t.bind(this.isOpen,this))},isOpen:function(t){return this.get(t).get("isOpen")}});return o}),define("views/slidetab",["jquery","underscore","backbone"],function(t,e,i){var n=i.View.extend({events:{"click .slidetab-tab":"clickSlidetab"},initialize:function(t){this.collection=t.collection,this.model.set({isOpen:this.isOpen()},{silent:!0}),this.listenTo(this.model,"change",this.toggleSlidetab)},isOpen:function(){return this.$el.find(".slidetab-content").is(":visible")},clickSlidetab:function(){this.model.save("isOpen",!this.model.get("isOpen"))},toggleSlidetab:function(){this.model.get("isOpen")?this.show():this.hide(),this.toggleSlidetabTabInfo()},show:function(){this.$el.animate({width:250}),this.$el.find(".slidetab-content").css("display","block")},hide:function(){this.$el.animate({width:28},e.bind(function(){this.$el.find(".slidetab-content").css("display","none")},this))},toggleSlidetabTabInfo:function(){this.$el.find(".slidetab-tab-info").toggle()}});return n}),define("views/slidetabs",["jquery","underscore","backbone","models/app","views/slidetab"],function(t,e,i,n,o){var s=i.View.extend({initialize:function(){this.webroot=n.settings.get("webroot"),this.initCollectionFromDom(".slidetab",this.collection,o),this.makeSortable()},makeSortable:function(){var i=this.webroot;this.$el.sortable({handle:".slidetab-tab",start:e.bind(function(){this.$el.css("overflow","visible")},this),stop:e.bind(function(){this.$el.css("overflow","hidden")},this),update:function(){var e=t(this).sortable("toArray",{attribute:"data-id"});e=e.map(function(t){return"slidetab_"+t}),t.ajax({type:"POST",url:i+"users/ajax_set",data:{data:{User:{slidetab_order:e}}},dataType:"json"})}})}});return s}),define("views/app",["jquery","underscore","backbone","models/app","collections/threadlines","views/threadlines","collections/threads","views/thread","collections/postings","models/posting","views/postingLayout","collections/bookmarks","views/bookmarks","views/helps","views/categoryChooser","collections/slidetabs","views/slidetabs","views/answering","jqueryUi"],function(t,e,i,n,o,s,r,a,l,h,c,u,d,f,p,m,g,v){var y=i.View.extend({el:t("body"),autoPageReloadTimer:!1,events:{"click #showLoginForm":"showLoginForm","focus #header-searchField":"widenSearchField","click #btn-scrollToTop":"scrollToTop","click #btn-manuallyMarkAsRead":"manuallyMarkAsRead","click #btn-category-chooser":"toggleCategoryChooser"},initialize:function(){this.threads=new r,"entries"===n.request.controller&&"index"===n.request.action&&this.threads.fetch(),this.postings=new l,this.threadLines=new o,this.listenTo(n.eventBus,"initAutoreload",this.initAutoreload),this.listenTo(n.eventBus,"breakAutoreload",this.breakAutoreload),this.$el.on("dialogopen",this.fixJqueryUiDialog)},initFromDom:function(i){if(t(".thread_box").each(e.bind(function(e,i){var o,s;s=parseInt(t(i).attr("data-id"),10),this.threads.get(s)||this.threads.add([{id:s,isThreadCollapsed:"entries"===n.request.controller&&"index"===n.request.action&&n.currentUser.get("user_show_thread_collapsed")}],{silent:!0}),o=new a({el:t(i),postings:this.postings,model:this.threads.get(s)})},this)),t(".js-entry-view-core").each(e.bind(function(e,i){var n,o,s;n=parseInt(i.getAttribute("data-id"),10),s=new h({id:n}),this.postings.add(s,{silent:!0}),o=new c({el:t(i),model:this.postings.get(n),collection:this.postings})},this)),t(".js-thread_line").each(e.bind(function(e,i){var n,o,r,a;o=parseInt(i.getAttribute("data-tid"),10),a=this.threads.get(o)?this.threads.get(o).threadlines:this.threadLines,r=parseInt(i.getAttribute("data-id"),10),n=new s({el:t(i),id:r,postings:this.postings,collection:a})},this)),this.initAutoreload(),this.initBookmarks("#bookmarks"),this.initHelp(".shp"),this.initSlidetabs("#slidetabs"),this.initCategoryChooser("#category-chooser"),t(".entry.add-not-inline").length>0&&(this.answeringForm=new v({el:this.$(".entry.add-not-inline"),id:"foo"})),n.status.start(),this._showPage(i.SaitoApp.timeAppStart,i.contentTimer),n.eventBus.trigger("notification",i.SaitoApp),window.location.href.indexOf("/jump:")>-1){var o=/jump:(\d+)/.exec(window.location.href);this.scrollToThread(o[1]),window.history.replaceState("object or string","Title",window.location.pathname.replace(/jump:\d+(\/)?/,""))}},_showPage:function(e,i){var o=function(){n.eventBus.trigger("isAppVisible",!0)};n.request.isMobile||(new Date).getTime()-e>1500?(t("#content").css("visibility","visible"),o()):t("#content").css({visibility:"visible",opacity:0}).animate({opacity:1},{duration:150,easing:"easeInOutQuart",complete:o}),i.cancel()},fixJqueryUiDialog:function(){t(".ui-icon-closethick").attr("class","jqueryUi-closethick-fix").html("")},initBookmarks:function(e){var i;if(t(e).length){var n=new u;i=new d({el:e,collection:n})}},initSlidetabs:function(t){var e,i;e=new m,i=new g({el:t,collection:e})},initCategoryChooser:function(e){t(e).length>0&&(this.categoryChooser=new p({el:e}))},toggleCategoryChooser:function(){this.categoryChooser.toggle()},initHelp:function(t){new f({el:"body",elementName:t,indicatorName:"#shp-show"})},scrollToThread:function(e){t(".thread_box[data-id="+e+"]")[0].scrollIntoView("top")},initAutoreload:function(){this.breakAutoreload(),n.settings.get("autoPageReload")&&(this.autoPageReloadTimer=setTimeout(e.bind(function(){window.location=n.settings.get("webroot")+"entries/"},this),1e3*n.settings.get("autoPageReload")))},breakAutoreload:function(){this.autoPageReloadTimer!==!1&&(clearTimeout(this.autoPageReloadTimer),this.autoPageReloadTimer=!1)},widenSearchField:function(e){var i=350;e.preventDefault(),t(e.currentTarget).width()",{"class":"ui-pnotify "+l.addclass,css:{display:"none"},mouseenter:function(t){l.nonblock&&t.stopPropagation(),l.mouse_reset&&"out"==a&&(p.stop(!0),a="in",p.css("height","auto").animate({width:l.width,opacity:l.nonblock?l.nonblock_opacity:l.opacity},"fast")),l.nonblock&&p.animate({opacity:l.nonblock_opacity},"fast"),l.hide&&l.mouse_reset&&p.pnotify_cancel_remove(),l.sticker&&!l.nonblock&&p.sticker.trigger("pnotify_icon").css("visibility","visible"),l.closer&&!l.nonblock&&p.closer.css("visibility","visible")},mouseleave:function(e){l.nonblock&&e.stopPropagation(),c=null,p.css("cursor","auto"),l.nonblock&&"out"!=a&&p.animate({opacity:l.opacity},"fast"),l.hide&&l.mouse_reset&&p.pnotify_queue_remove(),l.sticker_hover&&p.sticker.css("visibility","hidden"),l.closer_hover&&p.closer.css("visibility","hidden"),t.pnotify_position_all()},mouseover:function(t){l.nonblock&&t.stopPropagation()},mouseout:function(t){l.nonblock&&t.stopPropagation()},mousemove:function(t){l.nonblock&&(t.stopPropagation(),d(t,"onmousemove"))},mousedown:function(t){l.nonblock&&(t.stopPropagation(),t.preventDefault(),d(t,"onmousedown"))},mouseup:function(t){l.nonblock&&(t.stopPropagation(),t.preventDefault(),d(t,"onmouseup"))},click:function(t){l.nonblock&&(t.stopPropagation(),d(t,"onclick"))},dblclick:function(t){l.nonblock&&(t.stopPropagation(),d(t,"ondblclick"))}});p.opts=l,p.container=t("
      ",{"class":f.container+" ui-pnotify-container "+("error"==l.type?f.error:"info"==l.type?f.info:"success"==l.type?f.success:f.notice)}).appendTo(p),""!=l.cornerclass&&p.container.removeClass("ui-corner-all").addClass(l.cornerclass),l.shadow&&p.container.addClass("ui-pnotify-shadow"),p.pnotify_version="1.2.0",p.pnotify=function(e){var i=l;"string"==typeof e?l.text=e:l=t.extend({},l,e);for(var n in l)"string"==typeof n&&n.match(/^pnotify_/)&&(l[n.replace(/^pnotify_/,"")]=l[n]);return p.opts=l,l.cornerclass!=i.cornerclass&&p.container.removeClass("ui-corner-all").addClass(l.cornerclass),l.shadow!=i.shadow&&(l.shadow?p.container.addClass("ui-pnotify-shadow"):p.container.removeClass("ui-pnotify-shadow")),l.addclass===!1?p.removeClass(i.addclass):l.addclass!==i.addclass&&p.removeClass(i.addclass).addClass(l.addclass),l.title===!1?p.title_container.slideUp("fast"):l.title!==i.title&&(l.title_escape?p.title_container.text(l.title).slideDown(200):p.title_container.html(l.title).slideDown(200)),l.text===!1?p.text_container.slideUp("fast"):l.text!==i.text&&(l.text_escape?p.text_container.text(l.text).slideDown(200):p.text_container.html(l.insert_brs?String(l.text).replace(/\n/g,"
      "):l.text).slideDown(200)),p.pnotify_history=l.history,p.pnotify_hide=l.hide,l.type!=i.type&&p.container.removeClass(f.error+" "+f.notice+" "+f.success+" "+f.info).addClass("error"==l.type?f.error:"info"==l.type?f.info:"success"==l.type?f.success:f.notice),(l.icon!==i.icon||l.icon===!0&&l.type!=i.type)&&(p.container.find("div.ui-pnotify-icon").remove(),l.icon!==!1&&t("
      ",{"class":"ui-pnotify-icon"}).append(t("",{"class":l.icon===!0?"error"==l.type?f.error_icon:"info"==l.type?f.info_icon:"success"==l.type?f.success_icon:f.notice_icon:l.icon})).prependTo(p.container)),l.width!==i.width&&p.animate({width:l.width}),l.min_height!==i.min_height&&p.container.animate({minHeight:l.min_height}),l.opacity!==i.opacity&&p.fadeTo(l.animate_speed,l.opacity),!l.closer||l.nonblock?p.closer.css("display","none"):p.closer.css("display","block"),!l.sticker||l.nonblock?p.sticker.css("display","none"):p.sticker.css("display","block"),p.sticker.trigger("pnotify_icon"),l.sticker_hover?p.sticker.css("visibility","hidden"):l.nonblock||p.sticker.css("visibility","visible"),l.closer_hover?p.closer.css("visibility","hidden"):l.nonblock||p.closer.css("visibility","visible"),l.hide?i.hide||p.pnotify_queue_remove():p.pnotify_cancel_remove(),p.pnotify_queue_position(),p},p.pnotify_position=function(t){var e=p.opts.stack;if(e){e.nextpos1||(e.nextpos1=e.firstpos1),e.nextpos2||(e.nextpos2=e.firstpos2),e.addpos2||(e.addpos2=0);var i="none"==p.css("display");if(!i||t){var n,s,r,a={};switch(e.dir1){case"down":r="top";break;case"up":r="bottom";break;case"left":r="right";break;case"right":r="left"}n=parseInt(p.css(r)),isNaN(n)&&(n=0),"undefined"!=typeof e.firstpos1||i||(e.firstpos1=n,e.nextpos1=e.firstpos1);var l;switch(e.dir2){case"down":l="top";break;case"up":l="bottom";break;case"left":l="right";break;case"right":l="left"}if(s=parseInt(p.css(l)),isNaN(s)&&(s=0),"undefined"!=typeof e.firstpos2||i||(e.firstpos2=s,e.nextpos2=e.firstpos2),("down"==e.dir1&&e.nextpos1+p.height()>o.height()||"up"==e.dir1&&e.nextpos1+p.height()>o.height()||"left"==e.dir1&&e.nextpos1+p.width()>o.width()||"right"==e.dir1&&e.nextpos1+p.width()>o.width())&&(e.nextpos1=e.firstpos1,e.nextpos2+=e.addpos2+("undefined"==typeof e.spacing2?25:e.spacing2),e.addpos2=0),e.animation&&e.nextpos2e.addpos2&&(e.addpos2=p.height());break;case"left":case"right":p.outerWidth(!0)>e.addpos2&&(e.addpos2=p.width())}if(e.nextpos1)if(e.animation&&(n>e.nextpos1||a.top||a.bottom||a.right||a.left))switch(e.dir1){case"down":a.top=e.nextpos1+"px";break;case"up":a.bottom=e.nextpos1+"px";break;case"left":a.right=e.nextpos1+"px";break;case"right":a.left=e.nextpos1+"px"}else p.css(r,e.nextpos1+"px");switch((a.top||a.bottom||a.right||a.left)&&p.animate(a,{duration:500,queue:!1}),e.dir1){case"down":case"up":e.nextpos1+=p.height()+("undefined"==typeof e.spacing1?25:e.spacing1);break;case"left":case"right":e.nextpos1+=p.width()+("undefined"==typeof e.spacing1?25:e.spacing1)}}}},p.pnotify_queue_position=function(e){i&&clearTimeout(i),e||(e=10),i=setTimeout(t.pnotify_position_all,e)},p.pnotify_display=function(){p.parent().length||p.appendTo(n),l.before_open&&l.before_open(p)===!1||("top"!=l.stack.push&&p.pnotify_position(!0),"fade"==l.animation||"fade"==l.animation.effect_in?p.show().fadeTo(0,0).hide():1!=l.opacity&&p.show().fadeTo(0,l.opacity).hide(),p.animate_in(function(){l.after_open&&l.after_open(p),p.pnotify_queue_position(),l.hide&&p.pnotify_queue_remove()}))},p.pnotify_remove=function(){p.timer&&(window.clearTimeout(p.timer),p.timer=null),l.before_close&&l.before_close(p)===!1||p.animate_out(function(){l.after_close&&l.after_close(p)===!1||(p.pnotify_queue_position(),l.remove&&p.detach())})},p.animate_in=function(t){a="in";var e;e="undefined"!=typeof l.animation.effect_in?l.animation.effect_in:l.animation,"none"==e?(p.show(),t()):"show"==e?p.show(l.animate_speed,t):"fade"==e?p.show().fadeTo(l.animate_speed,l.opacity,t):"slide"==e?p.slideDown(l.animate_speed,t):"function"==typeof e?e("in",t,p):p.show(e,"object"==typeof l.animation.options_in?l.animation.options_in:{},l.animate_speed,t)},p.animate_out=function(t){a="out";var e;e="undefined"!=typeof l.animation.effect_out?l.animation.effect_out:l.animation,"none"==e?(p.hide(),t()):"show"==e?p.hide(l.animate_speed,t):"fade"==e?p.fadeOut(l.animate_speed,t):"slide"==e?p.slideUp(l.animate_speed,t):"function"==typeof e?e("out",t,p):p.hide(e,"object"==typeof l.animation.options_out?l.animation.options_out:{},l.animate_speed,t)},p.pnotify_cancel_remove=function(){p.timer&&window.clearTimeout(p.timer)},p.pnotify_queue_remove=function(){p.pnotify_cancel_remove(),p.timer=window.setTimeout(function(){p.pnotify_remove()},isNaN(l.delay)?0:l.delay)},p.closer=t("
      ",{"class":"ui-pnotify-closer",css:{cursor:"pointer",visibility:l.closer_hover?"hidden":"visible"},click:function(){p.pnotify_remove(),p.sticker.css("visibility","hidden"),p.closer.css("visibility","hidden")}}).append(t("",{"class":f.closer})).appendTo(p.container),(!l.closer||l.nonblock)&&p.closer.css("display","none"),p.sticker=t("
      ",{"class":"ui-pnotify-sticker",css:{cursor:"pointer",visibility:l.sticker_hover?"hidden":"visible"},click:function(){l.hide=!l.hide,l.hide?p.pnotify_queue_remove():p.pnotify_cancel_remove(),t(this).trigger("pnotify_icon")}}).bind("pnotify_icon",function(){t(this).children().removeClass(f.pin_up+" "+f.pin_down).addClass(l.hide?f.pin_up:f.pin_down)}).append(t("",{"class":f.pin_up})).appendTo(p.container),(!l.sticker||l.nonblock)&&p.sticker.css("display","none"),l.icon!==!1&&t("
      ",{"class":"ui-pnotify-icon"}).append(t("",{"class":l.icon===!0?"error"==l.type?f.error_icon:"info"==l.type?f.info_icon:"success"==l.type?f.success_icon:f.notice_icon:l.icon})).prependTo(p.container),p.title_container=t("

      ",{"class":"ui-pnotify-title"}).appendTo(p.container),l.title===!1?p.title_container.hide():l.title_escape?p.title_container.text(l.title):p.title_container.html(l.title),p.text_container=t("
      ",{"class":"ui-pnotify-text"}).appendTo(p.container),l.text===!1?p.text_container.hide():l.text_escape?p.text_container.text(l.text):p.text_container.html(l.insert_brs?String(l.text).replace(/\n/g,"
      "):l.text),"string"==typeof l.width&&p.css("width",l.width),"string"==typeof l.min_height&&p.container.css("min-height",l.min_height),p.pnotify_history=l.history,p.pnotify_hide=l.hide;var m=o.data("pnotify");if((null==m||"object"!=typeof m)&&(m=[]),m="top"==l.stack.push?t.merge([p],m):t.merge(m,[p]),o.data("pnotify",m),"top"==l.stack.push&&p.pnotify_queue_position(1),l.after_init&&l.after_init(p),l.history){var g=o.data("pnotify_history");if("undefined"==typeof g){g=t("
      ",{"class":"ui-pnotify-history-container "+f.hi_menu,mouseleave:function(){g.animate({top:"-"+e+"px"},{duration:100,queue:!1}) +}}).append(t("
      ",{"class":"ui-pnotify-history-header",text:"Redisplay"})).append(t("