mirror of
https://github.com/the-djmaze/snappymail.git
synced 2025-01-08 07:48:02 +08:00
333c063cf1
Remove attachments on reply (Closes #195) Do not show deleted (flag \Deleted) messages (Closes #185) Release commit
2 lines
No EOL
10 KiB
JavaScript
2 lines
No EOL
10 KiB
JavaScript
/*! nanoScrollerJS v0.7 (c) 2013 James Florentino; modified by RainLoop Team | MIT */
|
|
!function(t,i,e){"use strict";var s,l,o,n,r,h,a,c,d,p,v,g,f,u,m,S,b,w,T,y,$;y={paneClass:"pane",sliderClass:"slider",contentClass:"content",iOSNativeScrolling:!1,preventPageScrolling:!1,disableResize:!1,alwaysVisible:!1,flashDelay:1500,sliderMinHeight:20,sliderMaxHeight:null},S="scrollbar",m="scroll",c="mousedown",d="mousemove",v="mousewheel",p="mouseup",u="resize",r="drag",w="up",f="panedown",o="DOMMouseScroll",n="down",T="wheel",h="keydown",a="keyup",b="touchmove",s="Microsoft Internet Explorer"===i.navigator.appName&&/msie 7./i.test(i.navigator.appVersion)&&i.ActiveXObject,l=null,$=function(){var t,i,s;return t=e.createElement("div"),i=t.style,i.position="absolute",i.width="100px",i.height="100px",i.overflow=m,i.top="-9999px",t.className="nano-visibility-hidden",e.body.appendChild(t),s=t.offsetWidth-t.clientWidth,e.body.removeChild(t),s},g=function(){function h(s,o){this.el=s,this.options=o,l||(l=$()),this.$el=t(this.el),this.doc=t(e),this.win=t(i),this.$content=this.$el.children("."+o.contentClass),this.$content.attr("tabindex",0),this.content=this.$content[0],this.options.iOSNativeScrolling&&null!=this.el.style.WebkitOverflowScrolling?this.nativeScrolling():this.generate(),this.createEvents(),this.addEvents(),this.reset()}return h.prototype.preventScrolling=function(t,i){if(this.isActive||this.isActive2)if(t.type===o)(i===n&&t.originalEvent.detail>0||i===w&&t.originalEvent.detail<0)&&t.preventDefault();else if(t.type===v){if(!t.originalEvent||!t.originalEvent.wheelDelta)return;(i===n&&t.originalEvent.wheelDelta<0||i===w&&t.originalEvent.wheelDelta>0)&&t.preventDefault()}},h.prototype.scrollClassTimer=0,h.prototype.scrollClassTrigger=function(){i.clearTimeout(this.scrollClassTimer);var t=this;t.$el.addClass("nano-scrollevent"),t.pane.addClass("activescroll"),t.pane2.addClass("activescroll"),this.scrollClassTimer=i.setTimeout(function(){t.$el.removeClass("nano-scrollevent"),t.pane.removeClass("activescroll"),t.pane2.removeClass("activescroll")},1e3)},h.prototype.nativeScrolling=function(){this.$content.css({WebkitOverflowScrolling:"touch"}),this.iOSNativeScrolling=!0,this.isActive=!0,this.isActive2=!0},h.prototype.updateScrollValues=function(){var t,i=8;t=this.content,this.maxScrollTop=t.scrollHeight-t.clientHeight,this.maxScroll2Left=t.scrollWidth-t.clientWidth,this.contentScrollTop=t.scrollTop,this.contentScroll2Left=t.scrollLeft,this.iOSNativeScrolling||(this.maxSliderTop=this.paneHeight-this.sliderHeight,this.maxSlider2Left=this.pane2Width-this.slider2Width,this.sliderTop=this.contentScrollTop*this.maxSliderTop/this.maxScrollTop,this.slider2Left=this.contentScroll2Left*this.maxSlider2Left/this.maxScroll2Left,i<this.sliderTop?this.$el.addClass("nano-scrolllimit-top"):this.$el.removeClass("nano-scrolllimit-top"),this.contentScrollTop+i>=this.maxScrollTop?this.$el.removeClass("nano-scrolllimit-bottom"):this.$el.addClass("nano-scrolllimit-bottom"))},h.prototype.createEvents=function(){var t=this;this.events={down:function(i){return t.isBeingDragged=!0,t.offsetY=i.pageY-t.slider.offset().top,t.pane.addClass("active"),t.doc.bind(d,t.events[r]).bind(p,t.events[w]),!1},down2:function(i){return t.isBeingDragged2=!0,t.offsetX=i.pageX-t.slider2.offset().left,t.pane2.addClass("active"),t.doc.bind(d,t.events.drag2).bind(p,t.events.up2),!1},drag:function(i){return t.sliderY=i.pageY-t.$el.offset().top-t.offsetY,t.scroll(),t.updateScrollValues(),t.contentScrollTop>=t.maxScrollTop?t.$el.trigger("scrollend"):0===t.contentScrollTop&&t.$el.trigger("scrolltop"),!1},drag2:function(i){return t.slider2X=i.pageX-t.$el.offset().left-t.offsetX,t.scroll(),t.updateScrollValues(),!1},up:function(){return t.isBeingDragged=!1,t.pane.removeClass("active"),t.doc.unbind(d,t.events[r]).unbind(p,t.events[w]),!1},up2:function(){return t.isBeingDragged2=!1,t.pane2.removeClass("active"),t.doc.unbind(d,t.events.drag2).unbind(p,t.events.up2),!1},resize:function(){t.reset()},panedown:function(i){return t.sliderY=(i.offsetY||i.originalEvent.layerY)-.5*t.sliderHeight,t.scroll(),t.events.down(i),!1},panedown2:function(i){return t.slider2X=(i.offsetX||i.originalEvent.layerX)-.5*t.slider2Width,t.scroll(),t.events.down2(i),!1},scroll:function(i){t.isBeingDragged||t.isBeingDragged2||(t.updateScrollValues(),t.iOSNativeScrolling||(t.sliderY=t.sliderTop,t.slider.css({top:t.sliderTop}),t.slider2X=t.slider2Left,t.slider2.css({left:t.slider2Left})),i&&(t.contentScrollTop>=t.maxScrollTop?(t.options.preventPageScrolling&&t.preventScrolling(i,n),t.$el.trigger("scrollend")):0===t.contentScrollTop&&(t.options.preventPageScrolling&&t.preventScrolling(i,w),t.$el.trigger("scrolltop")),t.iOSNativeScrolling||t.scrollClassTrigger()))},wheel:function(i){return i&&void 0!==i.wheelDeltaY&&void 0!==i.delta?(t.sliderY+=-i.wheelDeltaY||-i.delta,t.scroll(),!1):void 0}}},h.prototype.addEvents=function(){var t;this.removeEvents(),t=this.events,this.options.disableResize||this.win.bind(u,t[u]),this.iOSNativeScrolling||(this.slider.bind(c,t[n]),this.slider2.bind(c,t.down2),this.pane.bind(c,t[f]),this.pane2.bind(c,t.panedown2)),this.$content.bind(""+m+" "+v+" "+o+" "+b,t[m])},h.prototype.removeEvents=function(){var t;t=this.events,this.win.unbind(u,t[u]),this.iOSNativeScrolling||(this.slider.unbind(),this.pane.unbind(),this.slider2.unbind(),this.pane2.unbind()),this.$content.unbind(""+m+" "+v+" "+o+" "+b,t[m])},h.prototype.generate=function(){var t,i,e,s,o;return e=this.options,s=e.paneClass,o=e.sliderClass,t=e.contentClass,this.$el.find("."+s).length||this.$el.find("."+o).length||this.$el.append('<div class="'+s+'"><div class="'+o+'" /></div>'),this.$el.find(".pane2").length||this.$el.find(".slider2").length||this.$el.append('<div class="pane2"><div class="slider2" /></div>'),this.slider=this.$el.find("."+o),this.slider2=this.$el.find(".slider2"),this.pane=this.$el.find("."+s),this.pane2=this.$el.find(".pane2"),l&&(i="rtl"===this.$el.css("direction")?{left:-l,bottom:-l}:{right:-l,bottom:-l},this.$el.addClass("has-scrollbar")),null!=i&&this.$content.css(i),this},h.prototype.restore=function(){this.stopped=!1,this.pane.show(),this.pane2.show(),this.addEvents()},h.prototype.reset=function(){var t,i,e,o,n,r,h,a,c,d,p,v,g,f,u,S;return this.iOSNativeScrolling?(this.contentHeight=this.content.scrollHeight,void(this.contentWidth=this.content.scrollWidth)):(this.$el.find("."+this.options.paneClass).length||this.generate().stop(),this.$el.find(".pane2").length||this.generate().stop(),this.stopped&&this.restore(),t=this.content,e=t.style,o=e.overflowY,d=e.overflowX,s&&this.$content.css({height:this.$content.height()}),i=t.scrollHeight+l,p=t.scrollWidth+l,r=this.pane.outerHeight(),v=this.pane2.outerWidth(),a=parseInt(this.pane.css("top"),10),f=parseInt(this.pane2.css("left"),10),n=parseInt(this.pane.css("bottom"),10),g=parseInt(this.pane2.css("right"),10),h=r+a+n,u=v+f+g,c=Math.round(h/i*h),S=Math.round(u/p*u),c<this.options.sliderMinHeight?c=this.options.sliderMinHeight:null!=this.options.sliderMaxHeight&&c>this.options.sliderMaxHeight&&(c=this.options.sliderMaxHeight),S<this.options.sliderMinHeight?S=this.options.sliderMinHeight:null!=this.options.sliderMaxHeight&&S>this.options.sliderMaxHeight&&(S=this.options.sliderMaxHeight),o===m&&e.overflowX!==m&&(c+=l),d===m&&e.overflowY!==m&&(S+=l),this.maxSliderTop=h-c,this.maxSlider2Left=u-S,this.contentHeight=i,this.contentWidth=p,this.paneHeight=r,this.pane2Width=v,this.paneOuterHeight=h,this.pane2OuterWidth=u,this.sliderHeight=c,this.slider2Width=S,this.slider.height(c),this.slider2.width(S),this.events.scroll(),this.pane.show(),this.pane2.show(),this.isActive=!0,t.scrollHeight===t.clientHeight||this.pane.outerHeight(!0)>=t.scrollHeight&&o!==m?(this.pane.hide(),this.isActive=!1):this.el.clientHeight===t.scrollHeight&&o===m?this.slider.hide():this.slider.show(),this.isActive2=!0,t.scrollWidth===t.clientWidth||this.pane2.outerWidth(!0)>=t.scrollWidth-30&&d!==m?(this.pane2.hide(),this.isActive2=!1):this.el.clientWidth===t.scrollWidth&&d===m?this.slider2.hide():this.slider2.show(),this.pane.css({opacity:this.options.alwaysVisible?1:"",visibility:this.options.alwaysVisible?"visible":""}),this.pane2.css({opacity:this.options.alwaysVisible?1:"",visibility:this.options.alwaysVisible?"visible":""}),this)},h.prototype.scroll=function(){return this.isActive||this.isActive2?(this.isActive&&(this.sliderY=Math.max(0,this.sliderY),this.sliderY=Math.min(this.maxSliderTop,this.sliderY),this.$content.scrollTop((this.paneHeight-this.contentHeight+l)*this.sliderY/this.maxSliderTop*-1)),this.isActive2&&(this.slider2X=Math.max(0,this.slider2X),this.slider2X=Math.min(this.maxSlider2Left,this.slider2X),this.$content.scrollLeft((this.pane2Width-this.contentWidth+l)*this.slider2X/this.maxSlider2Left*-1)),this.iOSNativeScrolling||(this.isActive&&this.slider.css({top:this.sliderY}),this.isActive2&&this.slider2.css({left:this.slider2X})),this):void 0},h.prototype.scrollBottom=function(t){return this.isActive||this.isActive2?(this.reset(),this.$content.scrollTop(this.contentHeight-this.$content.height()-t).trigger(v),this):void 0},h.prototype.scrollTop=function(t){return this.isActive||this.isActive2?(this.reset(),this.$content.scrollTop(+t).trigger(v),this):void 0},h.prototype.scrollTo=function(i){return this.isActive||this.isActive2?(this.reset(),this.scrollTop(t(i).get(0).offsetTop),this):void 0},h.prototype.stop=function(){return this.stopped=!0,this.removeEvents(),this.pane.hide(),this},h.prototype.flash=function(){var t=this;if(this.isActive||this.isActive2)return this.reset(),this.pane.addClass("flashed"),setTimeout(function(){t.pane.removeClass("flashed")},this.options.flashDelay),this},h}(),t.fn.nanoScroller=function(i){return this.each(function(){var e,s;if((s=this.nanoscroller)||(e=t.extend({},y,i),this.nanoscroller=s=new g(this,e)),i&&"object"==typeof i){if(t.extend(s.options,i),i.scrollBottom)return s.scrollBottom(i.scrollBottom);if(i.scrollTop)return s.scrollTop(i.scrollTop);if(i.scrollTo)return s.scrollTo(i.scrollTo);if("bottom"===i.scroll)return s.scrollBottom(0);if("top"===i.scroll)return s.scrollTop(0);if(i.scroll&&i.scroll instanceof t)return s.scrollTo(i.scroll);if(i.stop)return s.stop();if(i.flash)return s.flash()}return s.reset()})}}(jQuery,window,document); |