lychee/dist/main.js

6 lines
170 KiB
JavaScript
Raw Normal View History

2015-02-27 19:37:24 +00:00
function gup(e){e=e.replace(/[\[]/,"\\[").replace(/[\]]/,"\\]");var t="[\\?&]"+e+"=([^&#]*)",n=new RegExp(t),o=n.exec(window.location.href);return null===o?"":o[1]}!function(e,t){"object"==typeof module&&"object"==typeof module.exports?module.exports=e.document?t(e,!0):function(e){if(!e.document)throw new Error("jQuery requires a window with a document");return t(e)}:t(e)}("undefined"!=typeof window?window:this,function(e,t){function n(e){var t=e.length,n=J.type(e);return"function"===n||J.isWindow(e)?!1:1===e.nodeType&&t?!0:"array"===n||0===t||"number"==typeof t&&t>0&&t-1 in e}function o(e,t,n){if(J.isFunction(t))return J.grep(e,function(e,o){return!!t.call(e,o,e)!==n});if(t.nodeType)return J.grep(e,function(e){return e===t!==n});if("string"==typeof t){if(rt.test(t))return J.filter(t,e,n);t=J.filter(t,e)}return J.grep(e,function(e){return z.call(t,e)>=0!==n})}function i(e,t){for(;(e=e[t])&&1!==e.nodeType;);return e}function a(e){var t=ft[e]={};return J.each(e.match(ht)||[],function(e,n){t[n]=!0}),t}function s(){Q.removeEventListener("DOMContentLoaded",s,!1),e.removeEventListener("load",s,!1),J.ready()}function r(){Object.defineProperty(this.cache={},0,{get:function(){return{}}}),this.expando=J.expando+r.uid++}function l(e,t,n){var o;if(void 0===n&&1===e.nodeType)if(o="data-"+t.replace(wt,"-$1").toLowerCase(),n=e.getAttribute(o),"string"==typeof n){try{n="true"===n?!0:"false"===n?!1:"null"===n?null:+n+""===n?+n:yt.test(n)?J.parseJSON(n):n}catch(i){}vt.set(e,t,n)}else n=void 0;return n}function c(){return!0}function u(){return!1}function d(){try{return Q.activeElement}catch(e){}}function p(e,t){return J.nodeName(e,"table")&&J.nodeName(11!==t.nodeType?t:t.firstChild,"tr")?e.getElementsByTagName("tbody")[0]||e.appendChild(e.ownerDocument.createElement("tbody")):e}function h(e){return e.type=(null!==e.getAttribute("type"))+"/"+e.type,e}function f(e){var t=Lt.exec(e.type);return t?e.type=t[1]:e.removeAttribute("type"),e}function m(e,t){for(var n=0,o=e.length;o>n;n++)gt.set(e[n],"globalEval",!t||gt.get(t[n],"globalEval"))}function b(e,t){var n,o,i,a,s,r,l,c;if(1===t.nodeType){if(gt.hasData(e)&&(a=gt.access(e),s=gt.set(t,a),c=a.events)){delete s.handle,s.events={};for(i in c)for(n=0,o=c[i].length;o>n;n++)J.event.add(t,i,c[i][n])}vt.hasData(e)&&(r=vt.access(e),l=J.extend({},r),vt.set(t,l))}}function g(e,t){var n=e.getElementsByTagName?e.getElementsByTagName(t||"*"):e.querySelectorAll?e.querySelectorAll(t||"*"):[];return void 0===t||t&&J.nodeName(e,t)?J.merge([e],n):n}function v(e,t){var n=t.nodeName.toLowerCase();"input"===n&&kt.test(e.type)?t.checked=e.checked:("input"===n||"textarea"===n)&&(t.defaultValue=e.defaultValue)}function y(t,n){var o,i=J(n.createElement(t)).appendTo(n.body),a=e.getDefaultComputedStyle&&(o=e.getDefaultComputedStyle(i[0]))?o.display:J.css(i[0],"display");return i.detach(),a}function w(e){var t=Q,n=Rt[e];return n||(n=y(e,t),"none"!==n&&n||(Ht=(Ht||J("<iframe frameborder='0' width='0' height='0'/>")).appendTo(t.documentElement),t=Ht[0].contentDocument,t.write(),t.close(),n=y(e,t),Ht.detach()),Rt[e]=n),n}function x(e,t,n){var o,i,a,s,r=e.style;return n=n||Ut(e),n&&(s=n.getPropertyValue(t)||n[t]),n&&(""!==s||J.contains(e.ownerDocument,e)||(s=J.style(e,t)),Bt.test(s)&&Ft.test(t)&&(o=r.width,i=r.minWidth,a=r.maxWidth,r.minWidth=r.maxWidth=r.width=s,s=n.width,r.width=o,r.minWidth=i,r.maxWidth=a)),void 0!==s?s+"":s}function M(e,t){return{get:function(){return e()?void delete this.get:(this.get=t).apply(this,arguments)}}}function T(e,t){if(t in e)return t;for(var n=t[0].toUpperCase()+t.slice(1),o=t,i=Vt.length;i--;)if(t=Vt[i]+n,t in e)return t;return o}function k(e,t,n){var o=Xt.exec(t);return o?Math.max(0,o[1]-(n||0))+(o[2]||"px"):t}function j(e,t,n,o,i){for(var a=n===(o?"border":"content")?4:"width"===t?1:0,s=0;4>a;a+=2)"margin"===n&&(s+=J.css(e,n+Mt[a],!0,i)),o?("content"===n&&(s-=J.css(e,"padding"+Mt[a],!0,i)),"margin"!==n&&(s-=J.css(e,"border"+Mt[a]+"Width",!0,i))):(s+=J.css(e,"padding"+Mt[a],!0,i),"padding"!==n&&(s+=J.css(e,"border"+Mt[a]+"Width",!0,i)));return s}function C(e,t,n){var o=!0,i="width"===t?e.
}))},J.fn.extend({find:function(e){var t,n=this.length,o=[],i=this;if("string"!=typeof e)return this.pushStack(J(e).filter(function(){for(t=0;n>t;t++)if(J.contains(i[t],this))return!0}));for(t=0;n>t;t++)J.find(e,i[t],o);return o=this.pushStack(n>1?J.unique(o):o),o.selector=this.selector?this.selector+" "+e:e,o},filter:function(e){return this.pushStack(o(this,e||[],!1))},not:function(e){return this.pushStack(o(this,e||[],!0))},is:function(e){return!!o(this,"string"==typeof e&&at.test(e)?J(e):e||[],!1).length}});var lt,ct=/^(?:\s*(<[\w\W]+>)[^>]*|#([\w-]*))$/,ut=J.fn.init=function(e,t){var n,o;if(!e)return this;if("string"==typeof e){if(n="<"===e[0]&&">"===e[e.length-1]&&e.length>=3?[null,e,null]:ct.exec(e),!n||!n[1]&&t)return!t||t.jquery?(t||lt).find(e):this.constructor(t).find(e);if(n[1]){if(t=t instanceof J?t[0]:t,J.merge(this,J.parseHTML(n[1],t&&t.nodeType?t.ownerDocument||t:Q,!0)),st.test(n[1])&&J.isPlainObject(t))for(n in t)J.isFunction(this[n])?this[n](t[n]):this.attr(n,t[n]);return this}return o=Q.getElementById(n[2]),o&&o.parentNode&&(this.length=1,this[0]=o),this.context=Q,this.selector=e,this}return e.nodeType?(this.context=this[0]=e,this.length=1,this):J.isFunction(e)?"undefined"!=typeof lt.ready?lt.ready(e):e(J):(void 0!==e.selector&&(this.selector=e.selector,this.context=e.context),J.makeArray(e,this))};ut.prototype=J.fn,lt=J(Q);var dt=/^(?:parents|prev(?:Until|All))/,pt={children:!0,contents:!0,next:!0,prev:!0};J.extend({dir:function(e,t,n){for(var o=[],i=void 0!==n;(e=e[t])&&9!==e.nodeType;)if(1===e.nodeType){if(i&&J(e).is(n))break;o.push(e)}return o},sibling:function(e,t){for(var n=[];e;e=e.nextSibling)1===e.nodeType&&e!==t&&n.push(e);return n}}),J.fn.extend({has:function(e){var t=J(e,this),n=t.length;return this.filter(function(){for(var e=0;n>e;e++)if(J.contains(this,t[e]))return!0})},closest:function(e,t){for(var n,o=0,i=this.length,a=[],s=at.test(e)||"string"!=typeof e?J(e,t||this.context):0;i>o;o++)for(n=this[o];n&&n!==t;n=n.parentNode)if(n.nodeType<11&&(s?s.index(n)>-1:1===n.nodeType&&J.find.matchesSelector(n,e))){a.push(n);break}return this.pushStack(a.length>1?J.unique(a):a)},index:function(e){return e?"string"==typeof e?z.call(J(e),this[0]):z.call(this,e.jquery?e[0]:e):this[0]&&this[0].parentNode?this.first().prevAll().length:-1},add:function(e,t){return this.pushStack(J.unique(J.merge(this.get(),J(e,t))))},addBack:function(e){return this.add(null==e?this.prevObject:this.prevObject.filter(e))}}),J.each({parent:function(e){var t=e.parentNode;return t&&11!==t.nodeType?t:null},parents:function(e){return J.dir(e,"parentNode")},parentsUntil:function(e,t,n){return J.dir(e,"parentNode",n)},next:function(e){return i(e,"nextSibling")},prev:function(e){return i(e,"previousSibling")},nextAll:function(e){return J.dir(e,"nextSibling")},prevAll:function(e){return J.dir(e,"previousSibling")},nextUntil:function(e,t,n){return J.dir(e,"nextSibling",n)},prevUntil:function(e,t,n){return J.dir(e,"previousSibling",n)},siblings:function(e){return J.sibling((e.parentNode||{}).firstChild,e)},children:function(e){return J.sibling(e.firstChild)},contents:function(e){return e.contentDocument||J.merge([],e.childNodes)}},function(e,t){J.fn[e]=function(n,o){var i=J.map(this,t,n);return"Until"!==e.slice(-5)&&(o=n),o&&"string"==typeof o&&(i=J.filter(o,i)),this.length>1&&(pt[e]||J.unique(i),dt.test(e)&&i.reverse()),this.pushStack(i)}});var ht=/\S+/g,ft={};J.Callbacks=function(e){e="string"==typeof e?ft[e]||a(e):J.extend({},e);var t,n,o,i,s,r,l=[],c=!e.once&&[],u=function(a){for(t=e.memory&&a,n=!0,r=i||0,i=0,s=l.length,o=!0;l&&s>r;r++)if(l[r].apply(a[0],a[1])===!1&&e.stopOnFalse){t=!1;break}o=!1,l&&(c?c.length&&u(c.shift()):t?l=[]:d.disable())},d={add:function(){if(l){var n=l.length;!function a(t){J.each(t,function(t,n){var o=J.type(n);"function"===o?e.unique&&d.has(n)||l.push(n):n&&n.length&&"string"!==o&&a(n)})}(arguments),o?s=l.length:t&&(i=n,u(t))}return this},remove:function(){return l&&J.each(arguments,function(e,t){for(var n;(n=J.inArray(t,l,n))>-1;)l.splice(n,1),o&&(s>=n&&s--,r>=n&&r--)}),this},has:function(e){return e?J.i
for(n.finish=!0,J.queue(this,e,[]),i&&i.stop&&i.stop.call(this,!0),t=a.length;t--;)a[t].elem===this&&a[t].queue===e&&(a[t].anim.stop(!0),a.splice(t,1));for(t=0;s>t;t++)o[t]&&o[t].finish&&o[t].finish.call(this);delete n.finish})}}),J.each(["toggle","show","hide"],function(e,t){var n=J.fn[t];J.fn[t]=function(e,o,i){return null==e||"boolean"==typeof e?n.apply(this,arguments):this.animate(S(t,!0),e,o,i)}}),J.each({slideDown:S("show"),slideUp:S("hide"),slideToggle:S("toggle"),fadeIn:{opacity:"show"},fadeOut:{opacity:"hide"},fadeToggle:{opacity:"toggle"}},function(e,t){J.fn[e]=function(e,n,o){return this.animate(t,e,n,o)}}),J.timers=[],J.fx.tick=function(){var e,t=0,n=J.timers;for(Gt=J.now();t<n.length;t++)e=n[t],e()||n[t]!==e||n.splice(t--,1);n.length||J.fx.stop(),Gt=void 0},J.fx.timer=function(e){J.timers.push(e),e()?J.fx.start():J.timers.pop()},J.fx.interval=13,J.fx.start=function(){Qt||(Qt=setInterval(J.fx.tick,J.fx.interval))},J.fx.stop=function(){clearInterval(Qt),Qt=null},J.fx.speeds={slow:600,fast:200,_default:400},J.fn.delay=function(e,t){return e=J.fx?J.fx.speeds[e]||e:e,t=t||"fx",this.queue(t,function(t,n){var o=setTimeout(t,e);n.stop=function(){clearTimeout(o)}})},function(){var e=Q.createElement("input"),t=Q.createElement("select"),n=t.appendChild(Q.createElement("option"));e.type="checkbox",G.checkOn=""!==e.value,G.optSelected=n.selected,t.disabled=!0,G.optDisabled=!n.disabled,e=Q.createElement("input"),e.value="t",e.type="radio",G.radioValue="t"===e.value}();var on,an,sn=J.expr.attrHandle;J.fn.extend({attr:function(e,t){return bt(this,J.attr,e,t,arguments.length>1)},removeAttr:function(e){return this.each(function(){J.removeAttr(this,e)})}}),J.extend({attr:function(e,t,n){var o,i,a=e.nodeType;return e&&3!==a&&8!==a&&2!==a?typeof e.getAttribute===jt?J.prop(e,t,n):(1===a&&J.isXMLDoc(e)||(t=t.toLowerCase(),o=J.attrHooks[t]||(J.expr.match.bool.test(t)?an:on)),void 0===n?o&&"get"in o&&null!==(i=o.get(e,t))?i:(i=J.find.attr(e,t),null==i?void 0:i):null!==n?o&&"set"in o&&void 0!==(i=o.set(e,n,t))?i:(e.setAttribute(t,n+""),n):void J.removeAttr(e,t)):void 0},removeAttr:function(e,t){var n,o,i=0,a=t&&t.match(ht);if(a&&1===e.nodeType)for(;n=a[i++];)o=J.propFix[n]||n,J.expr.match.bool.test(n)&&(e[o]=!1),e.removeAttribute(n)},attrHooks:{type:{set:function(e,t){if(!G.radioValue&&"radio"===t&&J.nodeName(e,"input")){var n=e.value;return e.setAttribute("type",t),n&&(e.value=n),t}}}}}),an={set:function(e,t,n){return t===!1?J.removeAttr(e,n):e.setAttribute(n,n),n}},J.each(J.expr.match.bool.source.match(/\w+/g),function(e,t){var n=sn[t]||J.find.attr;sn[t]=function(e,t,o){var i,a;return o||(a=sn[t],sn[t]=i,i=null!=n(e,t,o)?t.toLowerCase():null,sn[t]=a),i}});var rn=/^(?:input|select|textarea|button)$/i;J.fn.extend({prop:function(e,t){return bt(this,J.prop,e,t,arguments.length>1)},removeProp:function(e){return this.each(function(){delete this[J.propFix[e]||e]})}}),J.extend({propFix:{"for":"htmlFor","class":"className"},prop:function(e,t,n){var o,i,a,s=e.nodeType;return e&&3!==s&&8!==s&&2!==s?(a=1!==s||!J.isXMLDoc(e),a&&(t=J.propFix[t]||t,i=J.propHooks[t]),void 0!==n?i&&"set"in i&&void 0!==(o=i.set(e,n,t))?o:e[t]=n:i&&"get"in i&&null!==(o=i.get(e,t))?o:e[t]):void 0},propHooks:{tabIndex:{get:function(e){return e.hasAttribute("tabindex")||rn.test(e.nodeName)||e.href?e.tabIndex:-1}}}}),G.optSelected||(J.propHooks.selected={get:function(e){var t=e.parentNode;return t&&t.parentNode&&t.parentNode.selectedIndex,null}}),J.each(["tabIndex","readOnly","maxLength","cellSpacing","cellPadding","rowSpan","colSpan","useMap","frameBorder","contentEditable"],function(){J.propFix[this.toLowerCase()]=this});var ln=/[\t\r\n\f]/g;J.fn.extend({addClass:function(e){var t,n,o,i,a,s,r="string"==typeof e&&e,l=0,c=this.length;if(J.isFunction(e))return this.each(function(t){J(this).addClass(e.call(this,t,this.className))});if(r)for(t=(e||"").match(ht)||[];c>l;l++)if(n=this[l],o=1===n.nodeType&&(n.className?(" "+n.className+" ").replace(ln," "):" ")){for(a=0;i=t[a++];)o.indexOf(" "+i+" ")<0&&(o+=i+" ");s=J.trim(o),n.className!==s&&(n.className=s)}return this},remo
2015-02-27 21:14:19 +00:00
return t=$(this).attr("data-name"),n=$(this).val(),e[t]=n}),basicModal._dom(".basicModal__dropdown").each(function(){var t,n;return t=$(this).attr("data-name"),n=$(this).attr("data-value"),e[t]=n})),e},_bind:function(e){var t,n,o,i,a;return null!=(null!=(n=e.buttons)&&null!=(o=n.cancel)?o.fn:void 0)&&basicModal._dom("#basicModal__cancel").click(function(){return $(this).hasClass("basicModal__button--active")?!1:($(this).addClass("basicModal__button--active"),e.buttons.cancel.fn())}),null!=(null!=(i=e.buttons)&&null!=(a=i.action)?a.fn:void 0)&&basicModal._dom("#basicModal__action").click(function(){return $(this).hasClass("basicModal__button--active")?!1:($(this).addClass("basicModal__button--active"),e.buttons.action.fn(basicModal._getValues()))}),basicModal._dom("input").keydown(function(){return $(this).removeClass("error")}),t=null,basicModal._dom(".basicModal__dropdown .front").click(function(){var e;return e=$(this).parent(),clearTimeout(t),e.find(".back").show(),e.addClass("flip")}),basicModal._dom('.basicModal__dropdown .back ul li[class!="separator"]').click(function(){var e,n;return e=$(this).parent().parent().parent(),n=$(this).clone(),n.find("span").remove(),n=n.html().trim(),e.find(".front span").html(n),e.attr("data-value",$(this).data("value")),e.removeClass("flip"),t=setTimeout(function(){return e.find(".back").hide()},3e3)})},show:function(e){return basicModal._valid(e)?(basicModal._lastFocus=document.activeElement,0!==basicModal._dom().parent().length?(basicModal.close(!0),setTimeout(function(){return basicModal.show(e)},301),!1):($("body").append(basicModal._build(e)),basicModal._bind(e),0!==basicModal._dom("input").length&&basicModal._dom("input")[0].focus(),null!=e.callback&&e.callback(),!0)):!1},error:function(e){return basicModal.reset(),basicModal._dom("input[data-name='"+e+"'], .basicModal__dropdown[data-name='"+e+"']").addClass("error").focus().select(),basicModal._dom().removeClass("basicModal--fadeIn basicModal--shake"),setTimeout(function(){return basicModal._dom().addClass("basicModal--shake")},1)},visible:function(){return 0===basicModal._dom().parent().length?!1:!0},action:function(){return 0!==basicModal._dom("#basicModal__action").length?(basicModal._dom("#basicModal__action").click(),!0):!1},cancel:function(){return 0!==basicModal._dom("#basicModal__cancel").length?(basicModal._dom("#basicModal__cancel").click(),!0):!1},reset:function(){return basicModal._dom(".basicModal__button").removeClass("basicModal__button--active"),basicModal._dom(".input, .basicModal__dropdown").removeClass("error"),!0},close:function(e){var t;return t=basicModal._dom().parent(),null==e||e===!0?"true"!==t.attr("data-closable")&&e!==!0?!1:(t.removeClass("basicModalContainer--fadeIn").addClass("basicModalContainer--fadeOut"),setTimeout(function(){return t.remove()},300),null!=basicModal._lastFocus&&(basicModal._lastFocus.focus(),basicModal._lastFocus=null),!0):!1}},function(e){e.fn.retina=function(t){var n={"retina-background":!1,"retina-suffix":"@2x"};t&&e.extend(n,t);var o=function(e,t){var n=new Image;n.onload=function(){t(n)},n.src=e};window.devicePixelRatio>1&&this.each(function(){var t=e(this);if("img"==this.tagName.toLowerCase()&&t.attr("src")){var i=t.attr("src").replace(/\.(?!.*\.)/,n["retina-suffix"]+".");o(i,function(n){t.attr("src",n.src);var o=e("<div>").append(t.clone()).remove().html();/(width|height)=["']\d+["']/.test(o)||t.attr("width",n.width/2)})}if(n["retina-background"]){var a=t.css("background-image");if(/^url\(.*\)$/.test(a)){var i=a.substring(4,a.length-1).replace(/\.(?!.*\.)/,n["retina-suffix"]+".");o(i,function(e){t.css("background-image","url("+e.src+")"),"auto auto"==t.css("background-size")&&t.css("background-size",e.width/2+"px auto")})}}})}}(jQuery),function(e){var t=function(t){var n=this;this.el=e(t),this.pos={start:{x:0,y:0},end:{x:0,y:0}},this.startTime,t.on("touchstart",function(e){n.touchStart(e)}),t.on("touchmove",function(e){n.touchMove(e)}),t.on("touchend",function(){n.swipeEnd()}),t.on("mousedown",function(e){n.mouseDown(e)})};t.prototype={touchStart:function(e){var t=e.or
}),header.dom("#button_move").on(e,function(e){contextMenu.move([photo.getID()],e)}),header.dom("#hostedwith").on(e,function(){window.open(lychee.website)}),header.dom("#button_trash_album").on(e,function(){album["delete"]([album.getID()])}),header.dom("#button_trash").on(e,function(){photo["delete"]([photo.getID()])}),header.dom("#button_archive").on(e,function(){album.getArchive(album.getID())}),header.dom("#button_star").on(e,function(){photo.setStar([photo.getID()])}),header.dom("#button_back_home").on(e,function(){lychee["goto"]("")}),header.dom("#button_back").on(e,function(){lychee["goto"](album.getID())}),header.dom("#search").on("keyup click",function(){search.find($(this).val())}),header.dom("#clearSearch").on(e,function(){header.dom("#search").focus(),search.reset()}),lychee.infobox.find(".header .close").on(e,view.infobox.hide),lychee.imageview.on(e,".arrow_wrapper--previous",photo.previous).on(e,".arrow_wrapper--next",photo.next),lychee.infobox.on(e,"#edit_title_album",function(){album.setTitle([album.getID()])}).on(e,"#edit_description_album",function(){album.setDescription(album.getID())}).on(e,"#edit_title",function(){photo.setTitle([photo.getID()])}).on(e,"#edit_description",function(){photo.setDescription(photo.getID())}).on(e,"#edit_tags",function(){photo.editTags([photo.getID()])}).on(e,"#tags .tag span",function(){photo.deleteTag(photo.getID(),$(this).data("index"))}),Mousetrap.bind("left",function(){visible.photo()&&$("#imageview a#previous").click()}).bind("right",function(){visible.photo()&&$("#imageview a#next").click()}).bind("u",function(){$("#upload_files").click()}).bind(["s","f"],function(e){visible.photo()?header.dom("#button_star").click():visible.albums()&&(e.preventDefault(),header.dom("#search").focus())}).bind("r",function(e){e.preventDefault(),visible.album()?album.setTitle(album.getID()):visible.photo()&&photo.setTitle([photo.getID()])}).bind("d",function(e){e.preventDefault(),visible.photo()?photo.setDescription(photo.getID()):visible.album()&&album.setDescription(album.getID())}).bind("t",function(e){visible.photo()&&(e.preventDefault(),photo.editTags([photo.getID()]))}).bind("i",function(){if(visible.infobox())view.infobox.hide();else{if(visible.multiselect())return!1;visible.infoboxbutton()&&view.infobox.show()}}).bind(["command+backspace","ctrl+backspace"],function(){visible.photo()&&!visible.message()?photo["delete"]([photo.getID()]):visible.album()&&!visible.message()&&album["delete"]([album.getID()])}).bind(["command+a","ctrl+a"],function(){visible.album()&&!visible.message()?multiselect.selectAll():visible.albums()&&!visible.message()&&multiselect.selectAll()}),Mousetrap.bindGlobal("enter",function(){basicModal.visible()===!0&&basicModal.action()}),Mousetrap.bindGlobal(["esc","command+up"],function(e){e.preventDefault(),basicModal.visible()===!0?basicModal.cancel():visible.contextMenu()?contextMenu.close():visible.infobox()?view.infobox.hide():visible.photo()?lychee["goto"](album.getID()):visible.album()?lychee["goto"](""):visible.albums()&&0!==$("#search").val().length&&search.reset()}),"ontouchend"in document.documentElement&&$(document).on("touchend","#image",function(e){(null===swipe.obj||swipe.offset>=-5&&swipe.offset<=5)&&(visible.controls()?header.hide(e,0):header.show())}).swipe().on("swipeStart",function(){visible.photo()&&swipe.start($("#image"))}).swipe().on("swipeMove",function(e){visible.photo()&&swipe.move(e.swipe)}).swipe().on("swipeEnd",function(e){visible.photo()&&swipe.stop(e.swipe,photo.previous,photo.next)}),$(document).on("keyup","#password",function(){$(this).val().length>0&&$(this).removeClass("error")}).on("click",".album",function(){lychee["goto"]($(this).attr("data-id"))}).on("click",".photo",function(){lychee["goto"](album.getID()+"/"+$(this).attr("data-id"))}).on("contextmenu",".photo",function(e){contextMenu.photo(photo.getID(),e)}).on("contextmenu",".album",function(e){contextMenu.album(album.getID(),e)}).on(e,"#infobox_overlay",view.infobox.hide).on("change","#upload_files",function(){basicModal.close(),upload.start.local(this.files)}).on("dra
},swipe={obj:null,tolerance:150,offset:0},swipe.start=function(e,t){return e&&(swipe.obj=e),t&&(swipe.tolerance=t),!0},swipe.move=function(e){return null===swipe.obj?!1:(swipe.offset=-1*e.x,void swipe.obj.css({WebkitTransform:"translateX("+swipe.offset+"px)",MozTransform:"translateX("+swipe.offset+"px)",transform:"translateX("+swipe.offset+"px)"}))},swipe.stop=function(e,t,n){e.x<=-swipe.tolerance?t(!0):e.x>=swipe.tolerance?n(!0):null!==swipe.obj&&swipe.obj.css({WebkitTransform:"translateX(0px)",MozTransform:"translateX(0px)",transform:"translateX(0px)"}),swipe.obj=null,swipe.offset=0},upload={},upload.show=function(e,t,n){basicModal.show({body:build.uploadModal(e,t),buttons:{action:{title:"Close","class":"hidden",fn:basicModal.close}},callback:n})},upload.notify=function(e,t){var n;return t&&""!==t||(t="You can now manage your new photo(s)."),window.webkitNotifications?(0!==window.webkitNotifications.checkPermission()&&window.webkitNotifications.requestPermission(),void(0===window.webkitNotifications.checkPermission()&&e&&(n=window.webkitNotifications.createNotification("",e,t),n.show()))):!1},upload.start={local:function(e){var t=album.getID(),n=!1,o=function(e,i){var a=new FormData,s=new XMLHttpRequest,r=0,l=0,c=function(){window.onbeforeunload=null,$("#upload_files").val(""),n===!1?(basicModal.close(),upload.notify("Upload complete")):($(".basicModal #basicModal__action.hidden").show(),upload.notify("Upload complete","Failed to upload one or more photos.")),albums.refresh(),album.getID()===!1?lychee["goto"]("0"):album.load(t)};if(i.supported===!1){if(null!==i.next)o(e,i.next);else{for(var u=!1,d=0;d<e.length;d++)if(e[d].supported===!0){u=!0;break}u===!1&&setTimeout(c,2e3)}return!1}a.append("function","Photo::add"),a.append("albumID",t),a.append("tags",""),a.append(0,i),s.open("POST",api.path),s.onload=function(){var t=!1,o="";i.ready=!0,200===s.status&&"1"===s.responseText?$(".basicModal .rows .row:nth-child("+(i.num+1)+") .status").html("Finished").addClass("success"):($(".basicModal .rows .row:nth-child("+(i.num+1)+") .status").html("Error").addClass("error"),o="Error:"===s.responseText.substr(0,6)?s.responseText.substr(6)+" Please take a look at the console of your browser for further details.":"Server returned an unknown response. Please take a look at the console of your browser for further details.",$(".basicModal .rows .row:nth-child("+(i.num+1)+") p.notice").html(o).show(),n=!0,lychee.error("Upload failed. Server returned the status code "+s.status+"!",s,s.responseText));for(var a=0;a<e.length;a++)if(e[a].ready===!1){t=!0;break}t===!1&&c()},s.upload.onprogress=function(t){if(t.lengthComputable&&(l=t.loaded/t.total*100|0,l>r&&($(".basicModal .rows .row:nth-child("+(i.num+1)+") .status").html(l+"%"),r=l),l>=100)){var n=0;i.num+1>4&&(n=40*(i.num+1-4)),$(".basicModal .rows").scrollTop(n),$(".basicModal .rows .row:nth-child("+(i.num+1)+") .status").html("Processing"),null!==i.next&&o(e,i.next)}},s.send(a)};if(e.length<=0)return!1;(t===!1||visible.albums()===!0)&&(t=0);for(var i=0;i<e.length;i++)e[i].num=i,e[i].ready=!1,e[i].supported=!0,e[i].next=i<e.length-1?e[i+1]:null,"image/jpeg"!==e[i].type&&"image/jpg"!==e[i].type&&"image/png"!==e[i].type&&"image/gif"!==e[i].type&&(e[i].ready=!0,e[i].supported=!1);window.onbeforeunload=function(){return"Lychee is currently uploading!"},upload.show("Uploading",e,function(){o(e,e[0])})},url:function(){var e,t=album.getID();t===!1&&(t=0),e=function(e){var n,o=[];if(e.link&&e.link.length>3){if(basicModal.close(),n=e.link.split(".").pop(),"jpeg"!==n&&"jpg"!==n&&"png"!==n&&"gif"!==n&&"webp"!==n)return loadingBar.show("error","The file format of this link is not supported."),!1;o[0]={name:e.link,supported:!0},upload.show("Importing URL",o,function(){var n;$(".basicModal .rows .row .status").html("Importing"),n={url:e.link,albumID:t},api.post("Import::url",n,function(e){basicModal.close(),upload.notify("Import complete"),albums.refresh(),album.getID()===!1?lychee["goto"]("0"):album.load(t),e!==!0&&lychee.error(null,n,e)})})}else basicModal.error("link")},basicModal.show({body:"<p>P