mails_viewer 0.0.3 → 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/README.md +1 -1
- data/app/assets/javascripts/jquery.colorbox-min.js +6 -4
- data/app/assets/javascripts/mails_viewer.js +17 -12
- data/app/assets/stylesheets/mails_viewer.css +1 -12
- data/app/assets/stylesheets/table.css +6 -15
- data/app/views/mails_viewer/home/index.html.erb +18 -23
- data/lib/mails_viewer/engine.rb +1 -0
- data/lib/mails_viewer/file_delivery.rb +1 -1
- data/lib/mails_viewer/mail.rb +3 -2
- data/lib/mails_viewer/version.rb +1 -1
- metadata +34 -13
- data/app/assets/images/tablesorter/asc.gif +0 -0
- data/app/assets/images/tablesorter/bg.gif +0 -0
- data/app/assets/images/tablesorter/desc.gif +0 -0
- data/app/assets/images/tablesorter/first.png +0 -0
- data/app/assets/images/tablesorter/last.png +0 -0
- data/app/assets/images/tablesorter/next.png +0 -0
- data/app/assets/images/tablesorter/prev.png +0 -0
- data/app/assets/javascripts/jquery.livequery.js +0 -226
- data/app/assets/javascripts/jquery.tablesorter.min.js +0 -4
- data/app/assets/javascripts/jquery.tablesorter.pager.js +0 -184
- data/app/assets/stylesheets/jquery.tablesorter.pager.css +0 -25
data/README.md
CHANGED
@@ -55,7 +55,7 @@ config.action_mailer.file_settings = {
|
|
55
55
|
authentication: nil,
|
56
56
|
enable_starttls_auto: true
|
57
57
|
},
|
58
|
-
send_if: lambda { |mail| mail.destinations.select { |address| ["yedingding@gmail.com"].include?(address) }.any?
|
58
|
+
send_if: lambda { |mail| mail.destinations.select { |address| ["yedingding@gmail.com"].include?(address) }.any? }
|
59
59
|
}
|
60
60
|
```
|
61
61
|
|
@@ -1,4 +1,6 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
1
|
+
/*!
|
2
|
+
jQuery ColorBox v1.4.5 - 2013-03-15
|
3
|
+
(c) 2013 Jack Moore - jacklmoore.com/colorbox
|
4
|
+
license: http://www.opensource.org/licenses/mit-license.php
|
5
|
+
*/
|
6
|
+
(function(e,t,i){function o(i,o,n){var r=t.createElement(i);return o&&(r.id=et+o),n&&(r.style.cssText=n),e(r)}function n(){return i.innerHeight?i.innerHeight:e(i).height()}function r(e){var t=E.length,i=(j+e)%t;return 0>i?t+i:i}function h(e,t){return Math.round((/%/.test(e)?("x"===t?H.width():n())/100:1)*parseInt(e,10))}function s(e,t){return e.photo||e.photoRegex.test(t)}function l(e,t){return e.retinaUrl&&i.devicePixelRatio>1?t.replace(e.photoRegex,e.retinaSuffix):t}function a(e){"contains"in v[0]&&!v[0].contains(e.target)&&(e.stopPropagation(),v.focus())}function d(){var t,i=e.data(O,Z);null==i?(z=e.extend({},Y),console&&console.log&&console.log("Error: cboxElement missing settings object")):z=e.extend({},i);for(t in z)e.isFunction(z[t])&&"on"!==t.slice(0,2)&&(z[t]=z[t].call(O));z.rel=z.rel||O.rel||e(O).data("rel")||"nofollow",z.href=z.href||e(O).attr("href"),z.title=z.title||O.title,"string"==typeof z.href&&(z.href=e.trim(z.href))}function c(i,o){e(t).trigger(i),ct.trigger(i),e.isFunction(o)&&o.call(O)}function u(){var e,t,i,o,n,r=et+"Slideshow_",h="click."+et;z.slideshow&&E[1]?(t=function(){clearTimeout(e)},i=function(){(z.loop||E[j+1])&&(e=setTimeout(X.next,z.slideshowSpeed))},o=function(){F.html(z.slideshowStop).unbind(h).one(h,n),ct.bind(nt,i).bind(ot,t).bind(rt,n),v.removeClass(r+"off").addClass(r+"on")},n=function(){t(),ct.unbind(nt,i).unbind(ot,t).unbind(rt,n),F.html(z.slideshowStart).unbind(h).one(h,function(){X.next(),o()}),v.removeClass(r+"on").addClass(r+"off")},z.slideshowAuto?o():n()):v.removeClass(r+"off "+r+"on")}function f(i){G||(O=i,d(),E=e(O),j=0,"nofollow"!==z.rel&&(E=e("."+tt).filter(function(){var t,i=e.data(this,Z);return i&&(t=e(this).data("rel")||i.rel||this.rel),t===z.rel}),j=E.index(O),-1===j&&(E=E.add(O),j=E.length-1)),g.css({opacity:parseFloat(z.opacity),cursor:z.overlayClose?"pointer":"auto",visibility:"visible"}).show(),J&&v.add(g).removeClass(J),z.className&&v.add(g).addClass(z.className),J=z.className,K.html(z.close).show(),U||(U=$=!0,v.css({visibility:"hidden",display:"block"}),I=o(ut,"LoadedContent","width:0; height:0; overflow:hidden").appendTo(y),D=b.height()+k.height()+y.outerHeight(!0)-y.height(),B=C.width()+T.width()+y.outerWidth(!0)-y.width(),N=I.outerHeight(!0),A=I.outerWidth(!0),z.w=h(z.initialWidth,"x"),z.h=h(z.initialHeight,"y"),X.position(),at&&H.bind("resize."+dt+" scroll."+dt,function(){g.css({width:H.width(),height:n(),top:H.scrollTop(),left:H.scrollLeft()})}).trigger("resize."+dt),u(),c(it,z.onOpen),_.add(M).hide(),v.focus(),t.addEventListener&&(t.addEventListener("focus",a,!0),ct.one(ht,function(){t.removeEventListener("focus",a,!0)})),z.returnFocus&&ct.one(ht,function(){e(O).focus()})),w())}function p(){!v&&t.body&&(V=!1,H=e(i),v=o(ut).attr({id:Z,"class":lt?et+(at?"IE6":"IE"):"",role:"dialog",tabindex:"-1"}).hide(),g=o(ut,"Overlay",at?"position:absolute":"").hide(),W=o(ut,"LoadingOverlay").add(o(ut,"LoadingGraphic")),x=o(ut,"Wrapper"),y=o(ut,"Content").append(M=o(ut,"Title"),S=o(ut,"Current"),P=o("button","Previous"),R=o("button","Next"),F=o("button","Slideshow"),W,K=o("button","Close")),x.append(o(ut).append(o(ut,"TopLeft"),b=o(ut,"TopCenter"),o(ut,"TopRight")),o(ut,!1,"clear:left").append(C=o(ut,"MiddleLeft"),y,T=o(ut,"MiddleRight")),o(ut,!1,"clear:left").append(o(ut,"BottomLeft"),k=o(ut,"BottomCenter"),o(ut,"BottomRight"))).find("div div").css({"float":"left"}),L=o(ut,!1,"position:absolute; width:9999px; visibility:hidden; display:none"),_=R.add(P).add(S).add(F),e(t.body).append(g,v.append(x,L)))}function m(){function i(e){e.which>1||e.shiftKey||e.altKey||e.metaKey||(e.preventDefault(),f(this))}return v?(V||(V=!0,R.click(function(){X.next()}),P.click(function(){X.prev()}),K.click(function(){X.close()}),g.click(function(){z.overlayClose&&X.close()}),e(t).bind("keydown."+et,function(e){var t=e.keyCode;U&&z.escKey&&27===t&&(e.preventDefault(),X.close()),U&&z.arrowKey&&E[1]&&!e.altKey&&(37===t?(e.preventDefault(),P.click()):39===t&&(e.preventDefault(),R.click()))}),e.isFunction(e.fn.on)?e(t).on("click."+et,"."+tt,i):e("."+tt).live("click."+et,i)),!0):!1}function w(){var t,n,r,a=X.prep,u=++ft;$=!0,q=!1,O=E[j],d(),c(st),c(ot,z.onLoad),z.h=z.height?h(z.height,"y")-N-D:z.innerHeight&&h(z.innerHeight,"y"),z.w=z.width?h(z.width,"x")-A-B:z.innerWidth&&h(z.innerWidth,"x"),z.mw=z.w,z.mh=z.h,z.maxWidth&&(z.mw=h(z.maxWidth,"x")-A-B,z.mw=z.w&&z.w<z.mw?z.w:z.mw),z.maxHeight&&(z.mh=h(z.maxHeight,"y")-N-D,z.mh=z.h&&z.h<z.mh?z.h:z.mh),t=z.href,Q=setTimeout(function(){W.show()},100),z.inline?(r=o(ut).hide().insertBefore(e(t)[0]),ct.one(st,function(){r.replaceWith(I.children())}),a(e(t))):z.iframe?a(" "):z.html?a(z.html):s(z,t)?(t=l(z,t),e(q=new Image).addClass(et+"Photo").bind("error",function(){z.title=!1,a(o(ut,"Error").html(z.imgError))}).one("load",function(){var e;u===ft&&(z.retinaImage&&i.devicePixelRatio>1&&(q.height=q.height/i.devicePixelRatio,q.width=q.width/i.devicePixelRatio),z.scalePhotos&&(n=function(){q.height-=q.height*e,q.width-=q.width*e},z.mw&&q.width>z.mw&&(e=(q.width-z.mw)/q.width,n()),z.mh&&q.height>z.mh&&(e=(q.height-z.mh)/q.height,n())),z.h&&(q.style.marginTop=Math.max(z.mh-q.height,0)/2+"px"),E[1]&&(z.loop||E[j+1])&&(q.style.cursor="pointer",q.onclick=function(){X.next()}),lt&&(q.style.msInterpolationMode="bicubic"),setTimeout(function(){a(q)},1))}),setTimeout(function(){q.src=t},1)):t&&L.load(t,z.data,function(t,i){u===ft&&a("error"===i?o(ut,"Error").html(z.xhrError):e(this).contents())})}var g,v,x,y,b,C,T,k,E,H,I,L,W,M,S,F,R,P,K,_,z,D,B,N,A,O,j,q,U,$,G,Q,X,J,V,Y={transition:"elastic",speed:300,width:!1,initialWidth:"600",innerWidth:!1,maxWidth:!1,height:!1,initialHeight:"450",innerHeight:!1,maxHeight:!1,scalePhotos:!0,scrolling:!0,inline:!1,html:!1,iframe:!1,fastIframe:!0,photo:!1,href:!1,title:!1,rel:!1,opacity:.9,preloading:!0,className:!1,retinaImage:!1,retinaUrl:!1,retinaSuffix:"@2x.$1",current:"image {current} of {total}",previous:"previous",next:"next",close:"close",xhrError:"This content failed to load.",imgError:"This image failed to load.",open:!1,returnFocus:!0,reposition:!0,loop:!0,slideshow:!1,slideshowAuto:!0,slideshowSpeed:2500,slideshowStart:"start slideshow",slideshowStop:"stop slideshow",photoRegex:/\.(gif|png|jp(e|g|eg)|bmp|ico)((#|\?).*)?$/i,onOpen:!1,onLoad:!1,onComplete:!1,onCleanup:!1,onClosed:!1,overlayClose:!0,escKey:!0,arrowKey:!0,top:!1,bottom:!1,left:!1,right:!1,fixed:!1,data:void 0},Z="colorbox",et="cbox",tt=et+"Element",it=et+"_open",ot=et+"_load",nt=et+"_complete",rt=et+"_cleanup",ht=et+"_closed",st=et+"_purge",lt=!e.support.leadingWhitespace,at=lt&&!i.XMLHttpRequest,dt=et+"_IE6",ct=e({}),ut="div",ft=0;e.colorbox||(e(p),X=e.fn[Z]=e[Z]=function(t,i){var o=this;if(t=t||{},p(),m()){if(e.isFunction(o))o=e("<a/>"),t.open=!0;else if(!o[0])return o;i&&(t.onComplete=i),o.each(function(){e.data(this,Z,e.extend({},e.data(this,Z)||Y,t))}).addClass(tt),(e.isFunction(t.open)&&t.open.call(o)||t.open)&&f(o[0])}return o},X.position=function(e,t){function i(e){b[0].style.width=k[0].style.width=y[0].style.width=parseInt(e.style.width,10)-B+"px",y[0].style.height=C[0].style.height=T[0].style.height=parseInt(e.style.height,10)-D+"px"}var o,r,s,l=0,a=0,d=v.offset();H.unbind("resize."+et),v.css({top:-9e4,left:-9e4}),r=H.scrollTop(),s=H.scrollLeft(),z.fixed&&!at?(d.top-=r,d.left-=s,v.css({position:"fixed"})):(l=r,a=s,v.css({position:"absolute"})),a+=z.right!==!1?Math.max(H.width()-z.w-A-B-h(z.right,"x"),0):z.left!==!1?h(z.left,"x"):Math.round(Math.max(H.width()-z.w-A-B,0)/2),l+=z.bottom!==!1?Math.max(n()-z.h-N-D-h(z.bottom,"y"),0):z.top!==!1?h(z.top,"y"):Math.round(Math.max(n()-z.h-N-D,0)/2),v.css({top:d.top,left:d.left,visibility:"visible"}),e=v.width()===z.w+A&&v.height()===z.h+N?0:e||0,x[0].style.width=x[0].style.height="9999px",o={width:z.w+A+B,height:z.h+N+D,top:l,left:a},0===e&&v.css(o),v.dequeue().animate(o,{duration:e,complete:function(){i(this),$=!1,x[0].style.width=z.w+A+B+"px",x[0].style.height=z.h+N+D+"px",z.reposition&&setTimeout(function(){H.bind("resize."+et,X.position)},1),t&&t()},step:function(){i(this)}})},X.resize=function(e){U&&(e=e||{},e.width&&(z.w=h(e.width,"x")-A-B),e.innerWidth&&(z.w=h(e.innerWidth,"x")),I.css({width:z.w}),e.height&&(z.h=h(e.height,"y")-N-D),e.innerHeight&&(z.h=h(e.innerHeight,"y")),e.innerHeight||e.height||(I.css({height:"auto"}),z.h=I.height()),I.css({height:z.h}),X.position("none"===z.transition?0:z.speed))},X.prep=function(t){function i(){return z.w=z.w||I.width(),z.w=z.mw&&z.mw<z.w?z.mw:z.w,z.w}function n(){return z.h=z.h||I.height(),z.h=z.mh&&z.mh<z.h?z.mh:z.h,z.h}if(U){var h,a="none"===z.transition?0:z.speed;I.empty().remove(),I=o(ut,"LoadedContent").append(t),I.hide().appendTo(L.show()).css({width:i(),overflow:z.scrolling?"auto":"hidden"}).css({height:n()}).prependTo(y),L.hide(),e(q).css({"float":"none"}),h=function(){function t(){lt&&v[0].style.removeAttribute("filter")}var i,n,h=E.length,d="frameBorder",u="allowTransparency";U&&(n=function(){clearTimeout(Q),W.hide(),c(nt,z.onComplete)},lt&&q&&I.fadeIn(100),M.html(z.title).add(I).show(),h>1?("string"==typeof z.current&&S.html(z.current.replace("{current}",j+1).replace("{total}",h)).show(),R[z.loop||h-1>j?"show":"hide"]().html(z.next),P[z.loop||j?"show":"hide"]().html(z.previous),z.slideshow&&F.show(),z.preloading&&e.each([r(-1),r(1)],function(){var t,i,o=E[this],n=e.data(o,Z);n&&n.href?(t=n.href,e.isFunction(t)&&(t=t.call(o))):t=e(o).attr("href"),t&&s(n,t)&&(t=l(n,t),i=new Image,i.src=t)})):_.hide(),z.iframe?(i=o("iframe")[0],d in i&&(i[d]=0),u in i&&(i[u]="true"),z.scrolling||(i.scrolling="no"),e(i).attr({src:z.href,name:(new Date).getTime(),"class":et+"Iframe",allowFullScreen:!0,webkitAllowFullScreen:!0,mozallowfullscreen:!0}).one("load",n).appendTo(I),ct.one(st,function(){i.src="//about:blank"}),z.fastIframe&&e(i).trigger("load")):n(),"fade"===z.transition?v.fadeTo(a,1,t):t())},"fade"===z.transition?v.fadeTo(a,0,function(){X.position(0,h)}):X.position(a,h)}},X.next=function(){!$&&E[1]&&(z.loop||E[j+1])&&(j=r(1),f(E[j]))},X.prev=function(){!$&&E[1]&&(z.loop||j)&&(j=r(-1),f(E[j]))},X.close=function(){U&&!G&&(G=!0,U=!1,c(rt,z.onCleanup),H.unbind("."+et+" ."+dt),g.fadeTo(200,0),v.stop().fadeTo(300,0,function(){v.add(g).css({opacity:1,cursor:"auto"}).hide(),c(st),I.empty().remove(),setTimeout(function(){G=!1,c(ht,z.onClosed)},1)}))},X.remove=function(){e([]).add(v).add(g).remove(),v=null,e("."+tt).removeData(Z).removeClass(tt),e(t).unbind("click."+et)},X.element=function(){return e(O)},X.settings=Y)})(jQuery,document,window);
|
@@ -1,25 +1,30 @@
|
|
1
1
|
//= require jquery
|
2
|
+
//= require dataTables/jquery.dataTables
|
2
3
|
//= require_tree .
|
3
4
|
|
4
5
|
$(function() {
|
5
|
-
|
6
|
-
|
7
|
-
$('.mail a.preview').livequery(function() {
|
8
|
-
console.log(this);
|
6
|
+
$('#mails').on('click', 'a.preview', function() {
|
9
7
|
$(this).colorbox({width:"80%", height:"80%", iframe:true});
|
10
8
|
});
|
11
9
|
|
12
|
-
$('
|
13
|
-
|
10
|
+
$('#mails').on('click', 'a.raw', function(e) {
|
11
|
+
e.preventDefault();
|
12
|
+
e.stopPropagation();
|
13
|
+
$.get($(this).attr('href'), function(data) {
|
14
14
|
$('#raw div').text(data);
|
15
15
|
});
|
16
|
-
return false;
|
17
16
|
});
|
18
17
|
|
19
|
-
$("
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
18
|
+
$("#mails").dataTable({
|
19
|
+
"aaSorting": [[3, "desc"]],
|
20
|
+
"aoColumns": [
|
21
|
+
null,
|
22
|
+
null,
|
23
|
+
null,
|
24
|
+
null,
|
25
|
+
{ "bSortable": false }
|
26
|
+
]
|
24
27
|
});
|
28
|
+
|
29
|
+
|
25
30
|
});
|
@@ -3,21 +3,10 @@
|
|
3
3
|
* and any sub-directories. You're free to add application-wide styles to this file and they'll appear at
|
4
4
|
* the top of the compiled file, but it's generally better to create a new file per style scope.
|
5
5
|
*= require_self
|
6
|
+
*= require dataTables/jquery.dataTables
|
6
7
|
*= require_tree .
|
7
8
|
*/
|
8
9
|
|
9
|
-
#pager {
|
10
|
-
margin-top: 10px;
|
11
|
-
}
|
12
|
-
|
13
|
-
.pagedisplay {
|
14
|
-
width: 56px;
|
15
|
-
}
|
16
|
-
|
17
|
-
.pagesize {
|
18
|
-
width: 56px;
|
19
|
-
}
|
20
|
-
|
21
10
|
#raw{
|
22
11
|
width: 906px;
|
23
12
|
margin-top: 40px;
|
@@ -1,5 +1,5 @@
|
|
1
1
|
/* tables */
|
2
|
-
|
2
|
+
#mails {
|
3
3
|
font-family:arial;
|
4
4
|
background-color: #CDCDCD;
|
5
5
|
margin:10px 0pt 15px;
|
@@ -7,34 +7,25 @@ table.tablesorter {
|
|
7
7
|
width: 100%;
|
8
8
|
text-align: left;
|
9
9
|
}
|
10
|
-
|
10
|
+
#mails thead tr th, #mails tfoot tr th {
|
11
11
|
background-color: #e6EEEE;
|
12
12
|
border: 1px solid #FFF;
|
13
13
|
font-size: 12px;
|
14
14
|
padding: 4px;
|
15
15
|
}
|
16
|
-
|
17
|
-
background-image: url(tablesorter/bg.gif);
|
18
|
-
background-repeat: no-repeat;
|
19
|
-
background-position: center right;
|
16
|
+
#mails thead tr .header {
|
20
17
|
cursor: pointer;
|
21
18
|
}
|
22
|
-
|
19
|
+
#mails tbody td {
|
23
20
|
color: #3D3D3D;
|
24
21
|
padding: 4px;
|
25
22
|
background-color: #FFF;
|
26
23
|
vertical-align: top;
|
27
24
|
}
|
28
|
-
|
25
|
+
#mails tbody tr.odd td {
|
29
26
|
background-color:#F0F0F6;
|
30
27
|
}
|
31
|
-
|
32
|
-
background-image: url(tablesorter/asc.gif);
|
33
|
-
}
|
34
|
-
table.tablesorter thead tr .headerSortDown {
|
35
|
-
background-image: url(tablesorter/desc.gif);
|
36
|
-
}
|
37
|
-
table.tablesorter thead tr .headerSortDown, table.tablesorter thead tr .headerSortUp {
|
28
|
+
#mails thead tr .headerSortDown, #mails thead tr .headerSortUp {
|
38
29
|
background-color: #8dbdd8;
|
39
30
|
}
|
40
31
|
|
@@ -10,8 +10,16 @@
|
|
10
10
|
|
11
11
|
<div class="container">
|
12
12
|
<div id="list">
|
13
|
-
<table class="
|
14
|
-
<thead
|
13
|
+
<table id="mails" class="datatable">
|
14
|
+
<thead>
|
15
|
+
<tr>
|
16
|
+
<th>From</th>
|
17
|
+
<th>To</th>
|
18
|
+
<th>Subject</th>
|
19
|
+
<th>Date</th>
|
20
|
+
<th></th>
|
21
|
+
</tr>
|
22
|
+
</thead>
|
15
23
|
<tbody>
|
16
24
|
<% @mails.each do |mail, filename| %>
|
17
25
|
<tr class="mail">
|
@@ -19,6 +27,9 @@
|
|
19
27
|
<td><%= mail.to.join(', ') %></td>
|
20
28
|
<td>
|
21
29
|
<%= mail.subject %>
|
30
|
+
</td>
|
31
|
+
<td><%= mail.date.to_s(:long) %></td>
|
32
|
+
<td>
|
22
33
|
<% if mail.html_part || mail.content_type =~ /html/ %>
|
23
34
|
<a href="<%= email_path(filename, :html) %>" class="html preview">html</a>
|
24
35
|
<% end %>
|
@@ -31,33 +42,17 @@
|
|
31
42
|
<% end %>
|
32
43
|
<a href="<%= email_path(filename, :raw) %>" class="raw">raw</a>
|
33
44
|
</td>
|
34
|
-
<td><%= mail.date.to_s(:long) %></td>
|
35
45
|
</tr>
|
36
46
|
<% end %>
|
37
47
|
</tbody>
|
38
48
|
</table>
|
39
49
|
|
40
|
-
|
41
|
-
<
|
42
|
-
|
43
|
-
|
44
|
-
<option selected="selected" value="10">10</option>
|
45
|
-
<option value="20">20</option>
|
46
|
-
<option value="30">30</option>
|
47
|
-
<option value="40">40</option>
|
48
|
-
</select>
|
49
|
-
<img src="/assets/tablesorter/first.png" class="first"/>
|
50
|
-
<img src="/assets/tablesorter/prev.png" class="prev"/>
|
51
|
-
<img src="/assets/tablesorter/next.png" class="next"/>
|
52
|
-
<img src="/assets/tablesorter/last.png" class="last"/>
|
53
|
-
</form>
|
54
|
-
</div>
|
55
|
-
</div>
|
50
|
+
<pre id='raw'>
|
51
|
+
<h3>Click link above to view original email content here!</h3>
|
52
|
+
<div></div>
|
53
|
+
</pre>
|
56
54
|
|
57
|
-
|
58
|
-
<h3>Click link above to view original email content here!</h3>
|
59
|
-
<div></div>
|
60
|
-
</pre>
|
55
|
+
</div>
|
61
56
|
</div>
|
62
57
|
</body>
|
63
58
|
</html>
|
data/lib/mails_viewer/engine.rb
CHANGED
@@ -8,6 +8,7 @@ module MailsViewer
|
|
8
8
|
|
9
9
|
# Enabling assets precompiling under rails 3.1
|
10
10
|
if Rails.version >= '3.1' && Rails.env != 'production'
|
11
|
+
require 'jquery-datatables-rails'
|
11
12
|
initializer "MailsViewer precompile hook", :group => :all do |app|
|
12
13
|
app.config.assets.precompile += %w(mails_viewer.js mails_viewer.css)
|
13
14
|
end
|
@@ -1,5 +1,5 @@
|
|
1
1
|
Mail::FileDelivery.class_eval do
|
2
|
-
# We need to save the mail to
|
2
|
+
# We need to save the mail to separate files when have several destination addresses
|
3
3
|
# So we generate different file name and save them.
|
4
4
|
def deliver!(mail)
|
5
5
|
if ::File.respond_to?(:makedirs)
|
data/lib/mails_viewer/mail.rb
CHANGED
@@ -1,9 +1,10 @@
|
|
1
1
|
module Mail
|
2
2
|
class Message
|
3
|
-
# Save the mail to
|
3
|
+
# Save the mail to separate files when have several destination addresses
|
4
4
|
# This function used to return a filename by mail's date and destination address
|
5
5
|
def filename_for(to)
|
6
|
-
|
6
|
+
timestamp = (date && date.to_time) || Time.now
|
7
|
+
"#{timestamp.to_i}.#{to}.txt"
|
7
8
|
end
|
8
9
|
end
|
9
10
|
end
|
data/lib/mails_viewer/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mails_viewer
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
4
|
+
version: 0.1.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date:
|
13
|
+
date: 2013-03-21 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: rails
|
@@ -28,6 +28,38 @@ dependencies:
|
|
28
28
|
- - ! '>='
|
29
29
|
- !ruby/object:Gem::Version
|
30
30
|
version: 3.1.0
|
31
|
+
- !ruby/object:Gem::Dependency
|
32
|
+
name: jquery-rails
|
33
|
+
requirement: !ruby/object:Gem::Requirement
|
34
|
+
none: false
|
35
|
+
requirements:
|
36
|
+
- - ! '>='
|
37
|
+
- !ruby/object:Gem::Version
|
38
|
+
version: 2.0.1
|
39
|
+
type: :runtime
|
40
|
+
prerelease: false
|
41
|
+
version_requirements: !ruby/object:Gem::Requirement
|
42
|
+
none: false
|
43
|
+
requirements:
|
44
|
+
- - ! '>='
|
45
|
+
- !ruby/object:Gem::Version
|
46
|
+
version: 2.0.1
|
47
|
+
- !ruby/object:Gem::Dependency
|
48
|
+
name: jquery-datatables-rails
|
49
|
+
requirement: !ruby/object:Gem::Requirement
|
50
|
+
none: false
|
51
|
+
requirements:
|
52
|
+
- - ! '>='
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
type: :runtime
|
56
|
+
prerelease: false
|
57
|
+
version_requirements: !ruby/object:Gem::Requirement
|
58
|
+
none: false
|
59
|
+
requirements:
|
60
|
+
- - ! '>='
|
61
|
+
- !ruby/object:Gem::Version
|
62
|
+
version: '0'
|
31
63
|
- !ruby/object:Gem::Dependency
|
32
64
|
name: mail
|
33
65
|
requirement: !ruby/object:Gem::Requirement
|
@@ -74,20 +106,9 @@ files:
|
|
74
106
|
- app/assets/images/colorbox/loading.gif
|
75
107
|
- app/assets/images/colorbox/loading_background.png
|
76
108
|
- app/assets/images/colorbox/overlay.png
|
77
|
-
- app/assets/images/tablesorter/asc.gif
|
78
|
-
- app/assets/images/tablesorter/bg.gif
|
79
|
-
- app/assets/images/tablesorter/desc.gif
|
80
|
-
- app/assets/images/tablesorter/first.png
|
81
|
-
- app/assets/images/tablesorter/last.png
|
82
|
-
- app/assets/images/tablesorter/next.png
|
83
|
-
- app/assets/images/tablesorter/prev.png
|
84
109
|
- app/assets/javascripts/jquery.colorbox-min.js
|
85
|
-
- app/assets/javascripts/jquery.livequery.js
|
86
|
-
- app/assets/javascripts/jquery.tablesorter.min.js
|
87
|
-
- app/assets/javascripts/jquery.tablesorter.pager.js
|
88
110
|
- app/assets/javascripts/mails_viewer.js
|
89
111
|
- app/assets/stylesheets/colorbox.css
|
90
|
-
- app/assets/stylesheets/jquery.tablesorter.pager.css
|
91
112
|
- app/assets/stylesheets/mails_viewer.css
|
92
113
|
- app/assets/stylesheets/table.css
|
93
114
|
- app/controllers/mails_viewer/home_controller.rb
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
@@ -1,226 +0,0 @@
|
|
1
|
-
/*! Copyright (c) 2010 Brandon Aaron (http://brandonaaron.net)
|
2
|
-
* Dual licensed under the MIT (MIT_LICENSE.txt)
|
3
|
-
* and GPL Version 2 (GPL_LICENSE.txt) licenses.
|
4
|
-
*
|
5
|
-
* Version: 1.1.1
|
6
|
-
* Requires jQuery 1.3+
|
7
|
-
* Docs: http://docs.jquery.com/Plugins/livequery
|
8
|
-
*/
|
9
|
-
|
10
|
-
(function($) {
|
11
|
-
|
12
|
-
$.extend($.fn, {
|
13
|
-
livequery: function(type, fn, fn2) {
|
14
|
-
var self = this, q;
|
15
|
-
|
16
|
-
// Handle different call patterns
|
17
|
-
if ($.isFunction(type))
|
18
|
-
fn2 = fn, fn = type, type = undefined;
|
19
|
-
|
20
|
-
// See if Live Query already exists
|
21
|
-
$.each( $.livequery.queries, function(i, query) {
|
22
|
-
if ( self.selector == query.selector && self.context == query.context &&
|
23
|
-
type == query.type && (!fn || fn.$lqguid == query.fn.$lqguid) && (!fn2 || fn2.$lqguid == query.fn2.$lqguid) )
|
24
|
-
// Found the query, exit the each loop
|
25
|
-
return (q = query) && false;
|
26
|
-
});
|
27
|
-
|
28
|
-
// Create new Live Query if it wasn't found
|
29
|
-
q = q || new $.livequery(this.selector, this.context, type, fn, fn2);
|
30
|
-
|
31
|
-
// Make sure it is running
|
32
|
-
q.stopped = false;
|
33
|
-
|
34
|
-
// Run it immediately for the first time
|
35
|
-
q.run();
|
36
|
-
|
37
|
-
// Contnue the chain
|
38
|
-
return this;
|
39
|
-
},
|
40
|
-
|
41
|
-
expire: function(type, fn, fn2) {
|
42
|
-
var self = this;
|
43
|
-
|
44
|
-
// Handle different call patterns
|
45
|
-
if ($.isFunction(type))
|
46
|
-
fn2 = fn, fn = type, type = undefined;
|
47
|
-
|
48
|
-
// Find the Live Query based on arguments and stop it
|
49
|
-
$.each( $.livequery.queries, function(i, query) {
|
50
|
-
if ( self.selector == query.selector && self.context == query.context &&
|
51
|
-
(!type || type == query.type) && (!fn || fn.$lqguid == query.fn.$lqguid) && (!fn2 || fn2.$lqguid == query.fn2.$lqguid) && !this.stopped )
|
52
|
-
$.livequery.stop(query.id);
|
53
|
-
});
|
54
|
-
|
55
|
-
// Continue the chain
|
56
|
-
return this;
|
57
|
-
}
|
58
|
-
});
|
59
|
-
|
60
|
-
$.livequery = function(selector, context, type, fn, fn2) {
|
61
|
-
this.selector = selector;
|
62
|
-
this.context = context;
|
63
|
-
this.type = type;
|
64
|
-
this.fn = fn;
|
65
|
-
this.fn2 = fn2;
|
66
|
-
this.elements = [];
|
67
|
-
this.stopped = false;
|
68
|
-
|
69
|
-
// The id is the index of the Live Query in $.livequery.queries
|
70
|
-
this.id = $.livequery.queries.push(this)-1;
|
71
|
-
|
72
|
-
// Mark the functions for matching later on
|
73
|
-
fn.$lqguid = fn.$lqguid || $.livequery.guid++;
|
74
|
-
if (fn2) fn2.$lqguid = fn2.$lqguid || $.livequery.guid++;
|
75
|
-
|
76
|
-
// Return the Live Query
|
77
|
-
return this;
|
78
|
-
};
|
79
|
-
|
80
|
-
$.livequery.prototype = {
|
81
|
-
stop: function() {
|
82
|
-
var query = this;
|
83
|
-
|
84
|
-
if ( this.type )
|
85
|
-
// Unbind all bound events
|
86
|
-
this.elements.unbind(this.type, this.fn);
|
87
|
-
else if (this.fn2)
|
88
|
-
// Call the second function for all matched elements
|
89
|
-
this.elements.each(function(i, el) {
|
90
|
-
query.fn2.apply(el);
|
91
|
-
});
|
92
|
-
|
93
|
-
// Clear out matched elements
|
94
|
-
this.elements = [];
|
95
|
-
|
96
|
-
// Stop the Live Query from running until restarted
|
97
|
-
this.stopped = true;
|
98
|
-
},
|
99
|
-
|
100
|
-
run: function() {
|
101
|
-
// Short-circuit if stopped
|
102
|
-
if ( this.stopped ) return;
|
103
|
-
var query = this;
|
104
|
-
|
105
|
-
var oEls = this.elements,
|
106
|
-
els = $(this.selector, this.context),
|
107
|
-
nEls = els.not(oEls);
|
108
|
-
|
109
|
-
// Set elements to the latest set of matched elements
|
110
|
-
this.elements = els;
|
111
|
-
|
112
|
-
if (this.type) {
|
113
|
-
// Bind events to newly matched elements
|
114
|
-
nEls.bind(this.type, this.fn);
|
115
|
-
|
116
|
-
// Unbind events to elements no longer matched
|
117
|
-
if (oEls.length > 0)
|
118
|
-
$.each(oEls, function(i, el) {
|
119
|
-
if ( $.inArray(el, els) < 0 )
|
120
|
-
$.event.remove(el, query.type, query.fn);
|
121
|
-
});
|
122
|
-
}
|
123
|
-
else {
|
124
|
-
// Call the first function for newly matched elements
|
125
|
-
nEls.each(function() {
|
126
|
-
query.fn.apply(this);
|
127
|
-
});
|
128
|
-
|
129
|
-
// Call the second function for elements no longer matched
|
130
|
-
if ( this.fn2 && oEls.length > 0 )
|
131
|
-
$.each(oEls, function(i, el) {
|
132
|
-
if ( $.inArray(el, els) < 0 )
|
133
|
-
query.fn2.apply(el);
|
134
|
-
});
|
135
|
-
}
|
136
|
-
}
|
137
|
-
};
|
138
|
-
|
139
|
-
$.extend($.livequery, {
|
140
|
-
guid: 0,
|
141
|
-
queries: [],
|
142
|
-
queue: [],
|
143
|
-
running: false,
|
144
|
-
timeout: null,
|
145
|
-
|
146
|
-
checkQueue: function() {
|
147
|
-
if ( $.livequery.running && $.livequery.queue.length ) {
|
148
|
-
var length = $.livequery.queue.length;
|
149
|
-
// Run each Live Query currently in the queue
|
150
|
-
while ( length-- )
|
151
|
-
$.livequery.queries[ $.livequery.queue.shift() ].run();
|
152
|
-
}
|
153
|
-
},
|
154
|
-
|
155
|
-
pause: function() {
|
156
|
-
// Don't run anymore Live Queries until restarted
|
157
|
-
$.livequery.running = false;
|
158
|
-
},
|
159
|
-
|
160
|
-
play: function() {
|
161
|
-
// Restart Live Queries
|
162
|
-
$.livequery.running = true;
|
163
|
-
// Request a run of the Live Queries
|
164
|
-
$.livequery.run();
|
165
|
-
},
|
166
|
-
|
167
|
-
registerPlugin: function() {
|
168
|
-
$.each( arguments, function(i,n) {
|
169
|
-
// Short-circuit if the method doesn't exist
|
170
|
-
if (!$.fn[n]) return;
|
171
|
-
|
172
|
-
// Save a reference to the original method
|
173
|
-
var old = $.fn[n];
|
174
|
-
|
175
|
-
// Create a new method
|
176
|
-
$.fn[n] = function() {
|
177
|
-
// Call the original method
|
178
|
-
var r = old.apply(this, arguments);
|
179
|
-
|
180
|
-
// Request a run of the Live Queries
|
181
|
-
$.livequery.run();
|
182
|
-
|
183
|
-
// Return the original methods result
|
184
|
-
return r;
|
185
|
-
}
|
186
|
-
});
|
187
|
-
},
|
188
|
-
|
189
|
-
run: function(id) {
|
190
|
-
if (id != undefined) {
|
191
|
-
// Put the particular Live Query in the queue if it doesn't already exist
|
192
|
-
if ( $.inArray(id, $.livequery.queue) < 0 )
|
193
|
-
$.livequery.queue.push( id );
|
194
|
-
}
|
195
|
-
else
|
196
|
-
// Put each Live Query in the queue if it doesn't already exist
|
197
|
-
$.each( $.livequery.queries, function(id) {
|
198
|
-
if ( $.inArray(id, $.livequery.queue) < 0 )
|
199
|
-
$.livequery.queue.push( id );
|
200
|
-
});
|
201
|
-
|
202
|
-
// Clear timeout if it already exists
|
203
|
-
if ($.livequery.timeout) clearTimeout($.livequery.timeout);
|
204
|
-
// Create a timeout to check the queue and actually run the Live Queries
|
205
|
-
$.livequery.timeout = setTimeout($.livequery.checkQueue, 20);
|
206
|
-
},
|
207
|
-
|
208
|
-
stop: function(id) {
|
209
|
-
if (id != undefined)
|
210
|
-
// Stop are particular Live Query
|
211
|
-
$.livequery.queries[ id ].stop();
|
212
|
-
else
|
213
|
-
// Stop all Live Queries
|
214
|
-
$.each( $.livequery.queries, function(id) {
|
215
|
-
$.livequery.queries[ id ].stop();
|
216
|
-
});
|
217
|
-
}
|
218
|
-
});
|
219
|
-
|
220
|
-
// Register core DOM manipulation methods
|
221
|
-
$.livequery.registerPlugin('append', 'prepend', 'after', 'before', 'wrap', 'attr', 'removeAttr', 'addClass', 'removeClass', 'toggleClass', 'empty', 'remove', 'html');
|
222
|
-
|
223
|
-
// Run Live Queries when the Document is ready
|
224
|
-
$(function() { $.livequery.play(); });
|
225
|
-
|
226
|
-
})(jQuery);
|
@@ -1,4 +0,0 @@
|
|
1
|
-
|
2
|
-
(function($){$.extend({tablesorter:new
|
3
|
-
function(){var parsers=[],widgets=[];this.defaults={cssHeader:"header",cssAsc:"headerSortUp",cssDesc:"headerSortDown",cssChildRow:"expand-child",sortInitialOrder:"asc",sortMultiSortKey:"shiftKey",sortForce:null,sortAppend:null,sortLocaleCompare:true,textExtraction:"simple",parsers:{},widgets:[],widgetZebra:{css:["even","odd"]},headers:{},widthFixed:false,cancelSelection:true,sortList:[],headerList:[],dateFormat:"us",decimal:'/\.|\,/g',onRenderHeader:null,selectorHeaders:'thead th',debug:false};function benchmark(s,d){log(s+","+(new Date().getTime()-d.getTime())+"ms");}this.benchmark=benchmark;function log(s){if(typeof console!="undefined"&&typeof console.debug!="undefined"){console.log(s);}else{alert(s);}}function buildParserCache(table,$headers){if(table.config.debug){var parsersDebug="";}if(table.tBodies.length==0)return;var rows=table.tBodies[0].rows;if(rows[0]){var list=[],cells=rows[0].cells,l=cells.length;for(var i=0;i<l;i++){var p=false;if($.metadata&&($($headers[i]).metadata()&&$($headers[i]).metadata().sorter)){p=getParserById($($headers[i]).metadata().sorter);}else if((table.config.headers[i]&&table.config.headers[i].sorter)){p=getParserById(table.config.headers[i].sorter);}if(!p){p=detectParserForColumn(table,rows,-1,i);}if(table.config.debug){parsersDebug+="column:"+i+" parser:"+p.id+"\n";}list.push(p);}}if(table.config.debug){log(parsersDebug);}return list;};function detectParserForColumn(table,rows,rowIndex,cellIndex){var l=parsers.length,node=false,nodeValue=false,keepLooking=true;while(nodeValue==''&&keepLooking){rowIndex++;if(rows[rowIndex]){node=getNodeFromRowAndCellIndex(rows,rowIndex,cellIndex);nodeValue=trimAndGetNodeText(table.config,node);if(table.config.debug){log('Checking if value was empty on row:'+rowIndex);}}else{keepLooking=false;}}for(var i=1;i<l;i++){if(parsers[i].is(nodeValue,table,node)){return parsers[i];}}return parsers[0];}function getNodeFromRowAndCellIndex(rows,rowIndex,cellIndex){return rows[rowIndex].cells[cellIndex];}function trimAndGetNodeText(config,node){return $.trim(getElementText(config,node));}function getParserById(name){var l=parsers.length;for(var i=0;i<l;i++){if(parsers[i].id.toLowerCase()==name.toLowerCase()){return parsers[i];}}return false;}function buildCache(table){if(table.config.debug){var cacheTime=new Date();}var totalRows=(table.tBodies[0]&&table.tBodies[0].rows.length)||0,totalCells=(table.tBodies[0].rows[0]&&table.tBodies[0].rows[0].cells.length)||0,parsers=table.config.parsers,cache={row:[],normalized:[]};for(var i=0;i<totalRows;++i){var c=$(table.tBodies[0].rows[i]),cols=[];if(c.hasClass(table.config.cssChildRow)){cache.row[cache.row.length-1]=cache.row[cache.row.length-1].add(c);continue;}cache.row.push(c);for(var j=0;j<totalCells;++j){cols.push(parsers[j].format(getElementText(table.config,c[0].cells[j]),table,c[0].cells[j]));}cols.push(cache.normalized.length);cache.normalized.push(cols);cols=null;};if(table.config.debug){benchmark("Building cache for "+totalRows+" rows:",cacheTime);}return cache;};function getElementText(config,node){var text="";if(!node)return"";if(!config.supportsTextContent)config.supportsTextContent=node.textContent||false;if(config.textExtraction=="simple"){if(config.supportsTextContent){text=node.textContent;}else{if(node.childNodes[0]&&node.childNodes[0].hasChildNodes()){text=node.childNodes[0].innerHTML;}else{text=node.innerHTML;}}}else{if(typeof(config.textExtraction)=="function"){text=config.textExtraction(node);}else{text=$(node).text();}}return text;}function appendToTable(table,cache){if(table.config.debug){var appendTime=new Date()}var c=cache,r=c.row,n=c.normalized,totalRows=n.length,checkCell=(n[0].length-1),tableBody=$(table.tBodies[0]),rows=[];for(var i=0;i<totalRows;i++){var pos=n[i][checkCell];rows.push(r[pos]);if(!table.config.appender){var l=r[pos].length;for(var j=0;j<l;j++){tableBody[0].appendChild(r[pos][j]);}}}if(table.config.appender){table.config.appender(table,rows);}rows=null;if(table.config.debug){benchmark("Rebuilt table:",appendTime);}applyWidget(table);setTimeout(function(){$(table).trigger("sortEnd");},0);};function buildHeaders(table){if(table.config.debug){var time=new Date();}var meta=($.metadata)?true:false;var header_index=computeTableHeaderCellIndexes(table);$tableHeaders=$(table.config.selectorHeaders,table).each(function(index){this.column=header_index[this.parentNode.rowIndex+"-"+this.cellIndex];this.order=formatSortingOrder(table.config.sortInitialOrder);this.count=this.order;if(checkHeaderMetadata(this)||checkHeaderOptions(table,index))this.sortDisabled=true;if(checkHeaderOptionsSortingLocked(table,index))this.order=this.lockedOrder=checkHeaderOptionsSortingLocked(table,index);if(!this.sortDisabled){var $th=$(this).addClass(table.config.cssHeader);if(table.config.onRenderHeader)table.config.onRenderHeader.apply($th);}table.config.headerList[index]=this;});if(table.config.debug){benchmark("Built headers:",time);log($tableHeaders);}return $tableHeaders;};function computeTableHeaderCellIndexes(t){var matrix=[];var lookup={};var thead=t.getElementsByTagName('THEAD')[0];var trs=thead.getElementsByTagName('TR');for(var i=0;i<trs.length;i++){var cells=trs[i].cells;for(var j=0;j<cells.length;j++){var c=cells[j];var rowIndex=c.parentNode.rowIndex;var cellId=rowIndex+"-"+c.cellIndex;var rowSpan=c.rowSpan||1;var colSpan=c.colSpan||1
|
4
|
-
var firstAvailCol;if(typeof(matrix[rowIndex])=="undefined"){matrix[rowIndex]=[];}for(var k=0;k<matrix[rowIndex].length+1;k++){if(typeof(matrix[rowIndex][k])=="undefined"){firstAvailCol=k;break;}}lookup[cellId]=firstAvailCol;for(var k=rowIndex;k<rowIndex+rowSpan;k++){if(typeof(matrix[k])=="undefined"){matrix[k]=[];}var matrixrow=matrix[k];for(var l=firstAvailCol;l<firstAvailCol+colSpan;l++){matrixrow[l]="x";}}}}return lookup;}function checkCellColSpan(table,rows,row){var arr=[],r=table.tHead.rows,c=r[row].cells;for(var i=0;i<c.length;i++){var cell=c[i];if(cell.colSpan>1){arr=arr.concat(checkCellColSpan(table,headerArr,row++));}else{if(table.tHead.length==1||(cell.rowSpan>1||!r[row+1])){arr.push(cell);}}}return arr;};function checkHeaderMetadata(cell){if(($.metadata)&&($(cell).metadata().sorter===false)){return true;};return false;}function checkHeaderOptions(table,i){if((table.config.headers[i])&&(table.config.headers[i].sorter===false)){return true;};return false;}function checkHeaderOptionsSortingLocked(table,i){if((table.config.headers[i])&&(table.config.headers[i].lockedOrder))return table.config.headers[i].lockedOrder;return false;}function applyWidget(table){var c=table.config.widgets;var l=c.length;for(var i=0;i<l;i++){getWidgetById(c[i]).format(table);}}function getWidgetById(name){var l=widgets.length;for(var i=0;i<l;i++){if(widgets[i].id.toLowerCase()==name.toLowerCase()){return widgets[i];}}};function formatSortingOrder(v){if(typeof(v)!="Number"){return(v.toLowerCase()=="desc")?1:0;}else{return(v==1)?1:0;}}function isValueInArray(v,a){var l=a.length;for(var i=0;i<l;i++){if(a[i][0]==v){return true;}}return false;}function setHeadersCss(table,$headers,list,css){$headers.removeClass(css[0]).removeClass(css[1]);var h=[];$headers.each(function(offset){if(!this.sortDisabled){h[this.column]=$(this);}});var l=list.length;for(var i=0;i<l;i++){h[list[i][0]].addClass(css[list[i][1]]);}}function fixColumnWidth(table,$headers){var c=table.config;if(c.widthFixed){var colgroup=$('<colgroup>');$("tr:first td",table.tBodies[0]).each(function(){colgroup.append($('<col>').css('width',$(this).width()));});$(table).prepend(colgroup);};}function updateHeaderSortCount(table,sortList){var c=table.config,l=sortList.length;for(var i=0;i<l;i++){var s=sortList[i],o=c.headerList[s[0]];o.count=s[1];o.count++;}}function multisort(table,sortList,cache){if(table.config.debug){var sortTime=new Date();}var dynamicExp="var sortWrapper = function(a,b) {",l=sortList.length;for(var i=0;i<l;i++){var c=sortList[i][0];var order=sortList[i][1];var s=(table.config.parsers[c].type=="text")?((order==0)?makeSortFunction("text","asc",c):makeSortFunction("text","desc",c)):((order==0)?makeSortFunction("numeric","asc",c):makeSortFunction("numeric","desc",c));var e="e"+i;dynamicExp+="var "+e+" = "+s;dynamicExp+="if("+e+") { return "+e+"; } ";dynamicExp+="else { ";}var orgOrderCol=cache.normalized[0].length-1;dynamicExp+="return a["+orgOrderCol+"]-b["+orgOrderCol+"];";for(var i=0;i<l;i++){dynamicExp+="}; ";}dynamicExp+="return 0; ";dynamicExp+="}; ";if(table.config.debug){benchmark("Evaling expression:"+dynamicExp,new Date());}eval(dynamicExp);cache.normalized.sort(sortWrapper);if(table.config.debug){benchmark("Sorting on "+sortList.toString()+" and dir "+order+" time:",sortTime);}return cache;};function makeSortFunction(type,direction,index){var a="a["+index+"]",b="b["+index+"]";if(type=='text'&&direction=='asc'){return"("+a+" == "+b+" ? 0 : ("+a+" === null ? Number.POSITIVE_INFINITY : ("+b+" === null ? Number.NEGATIVE_INFINITY : ("+a+" < "+b+") ? -1 : 1 )));";}else if(type=='text'&&direction=='desc'){return"("+a+" == "+b+" ? 0 : ("+a+" === null ? Number.POSITIVE_INFINITY : ("+b+" === null ? Number.NEGATIVE_INFINITY : ("+b+" < "+a+") ? -1 : 1 )));";}else if(type=='numeric'&&direction=='asc'){return"("+a+" === null && "+b+" === null) ? 0 :("+a+" === null ? Number.POSITIVE_INFINITY : ("+b+" === null ? Number.NEGATIVE_INFINITY : "+a+" - "+b+"));";}else if(type=='numeric'&&direction=='desc'){return"("+a+" === null && "+b+" === null) ? 0 :("+a+" === null ? Number.POSITIVE_INFINITY : ("+b+" === null ? Number.NEGATIVE_INFINITY : "+b+" - "+a+"));";}};function makeSortText(i){return"((a["+i+"] < b["+i+"]) ? -1 : ((a["+i+"] > b["+i+"]) ? 1 : 0));";};function makeSortTextDesc(i){return"((b["+i+"] < a["+i+"]) ? -1 : ((b["+i+"] > a["+i+"]) ? 1 : 0));";};function makeSortNumeric(i){return"a["+i+"]-b["+i+"];";};function makeSortNumericDesc(i){return"b["+i+"]-a["+i+"];";};function sortText(a,b){if(table.config.sortLocaleCompare)return a.localeCompare(b);return((a<b)?-1:((a>b)?1:0));};function sortTextDesc(a,b){if(table.config.sortLocaleCompare)return b.localeCompare(a);return((b<a)?-1:((b>a)?1:0));};function sortNumeric(a,b){return a-b;};function sortNumericDesc(a,b){return b-a;};function getCachedSortType(parsers,i){return parsers[i].type;};this.construct=function(settings){return this.each(function(){if(!this.tHead||!this.tBodies)return;var $this,$document,$headers,cache,config,shiftDown=0,sortOrder;this.config={};config=$.extend(this.config,$.tablesorter.defaults,settings);$this=$(this);$.data(this,"tablesorter",config);$headers=buildHeaders(this);this.config.parsers=buildParserCache(this,$headers);cache=buildCache(this);var sortCSS=[config.cssDesc,config.cssAsc];fixColumnWidth(this);$headers.click(function(e){var totalRows=($this[0].tBodies[0]&&$this[0].tBodies[0].rows.length)||0;if(!this.sortDisabled&&totalRows>0){$this.trigger("sortStart");var $cell=$(this);var i=this.column;this.order=this.count++%2;if(this.lockedOrder)this.order=this.lockedOrder;if(!e[config.sortMultiSortKey]){config.sortList=[];if(config.sortForce!=null){var a=config.sortForce;for(var j=0;j<a.length;j++){if(a[j][0]!=i){config.sortList.push(a[j]);}}}config.sortList.push([i,this.order]);}else{if(isValueInArray(i,config.sortList)){for(var j=0;j<config.sortList.length;j++){var s=config.sortList[j],o=config.headerList[s[0]];if(s[0]==i){o.count=s[1];o.count++;s[1]=o.count%2;}}}else{config.sortList.push([i,this.order]);}};setTimeout(function(){setHeadersCss($this[0],$headers,config.sortList,sortCSS);appendToTable($this[0],multisort($this[0],config.sortList,cache));},1);return false;}}).mousedown(function(){if(config.cancelSelection){this.onselectstart=function(){return false};return false;}});$this.bind("update",function(){var me=this;setTimeout(function(){me.config.parsers=buildParserCache(me,$headers);cache=buildCache(me);},1);}).bind("updateCell",function(e,cell){var config=this.config;var pos=[(cell.parentNode.rowIndex-1),cell.cellIndex];cache.normalized[pos[0]][pos[1]]=config.parsers[pos[1]].format(getElementText(config,cell),cell);}).bind("sorton",function(e,list){$(this).trigger("sortStart");config.sortList=list;var sortList=config.sortList;updateHeaderSortCount(this,sortList);setHeadersCss(this,$headers,sortList,sortCSS);appendToTable(this,multisort(this,sortList,cache));}).bind("appendCache",function(){appendToTable(this,cache);}).bind("applyWidgetId",function(e,id){getWidgetById(id).format(this);}).bind("applyWidgets",function(){applyWidget(this);});if($.metadata&&($(this).metadata()&&$(this).metadata().sortlist)){config.sortList=$(this).metadata().sortlist;}if(config.sortList.length>0){$this.trigger("sorton",[config.sortList]);}applyWidget(this);});};this.addParser=function(parser){var l=parsers.length,a=true;for(var i=0;i<l;i++){if(parsers[i].id.toLowerCase()==parser.id.toLowerCase()){a=false;}}if(a){parsers.push(parser);};};this.addWidget=function(widget){widgets.push(widget);};this.formatFloat=function(s){var i=parseFloat(s);return(isNaN(i))?0:i;};this.formatInt=function(s){var i=parseInt(s);return(isNaN(i))?0:i;};this.isDigit=function(s,config){return/^[-+]?\d*$/.test($.trim(s.replace(/[,.']/g,'')));};this.clearTableBody=function(table){if($.browser.msie){function empty(){while(this.firstChild)this.removeChild(this.firstChild);}empty.apply(table.tBodies[0]);}else{table.tBodies[0].innerHTML="";}};}});$.fn.extend({tablesorter:$.tablesorter.construct});var ts=$.tablesorter;ts.addParser({id:"text",is:function(s){return true;},format:function(s){return $.trim(s.toLocaleLowerCase());},type:"text"});ts.addParser({id:"digit",is:function(s,table){var c=table.config;return $.tablesorter.isDigit(s,c);},format:function(s){return $.tablesorter.formatFloat(s);},type:"numeric"});ts.addParser({id:"currency",is:function(s){return/^[£$€?.]/.test(s);},format:function(s){return $.tablesorter.formatFloat(s.replace(new RegExp(/[£$€]/g),""));},type:"numeric"});ts.addParser({id:"ipAddress",is:function(s){return/^\d{2,3}[\.]\d{2,3}[\.]\d{2,3}[\.]\d{2,3}$/.test(s);},format:function(s){var a=s.split("."),r="",l=a.length;for(var i=0;i<l;i++){var item=a[i];if(item.length==2){r+="0"+item;}else{r+=item;}}return $.tablesorter.formatFloat(r);},type:"numeric"});ts.addParser({id:"url",is:function(s){return/^(https?|ftp|file):\/\/$/.test(s);},format:function(s){return jQuery.trim(s.replace(new RegExp(/(https?|ftp|file):\/\//),''));},type:"text"});ts.addParser({id:"isoDate",is:function(s){return/^\d{4}[\/-]\d{1,2}[\/-]\d{1,2}$/.test(s);},format:function(s){return $.tablesorter.formatFloat((s!="")?new Date(s.replace(new RegExp(/-/g),"/")).getTime():"0");},type:"numeric"});ts.addParser({id:"percent",is:function(s){return/\%$/.test($.trim(s));},format:function(s){return $.tablesorter.formatFloat(s.replace(new RegExp(/%/g),""));},type:"numeric"});ts.addParser({id:"usLongDate",is:function(s){return s.match(new RegExp(/^[A-Za-z]{3,10}\.? [0-9]{1,2}, ([0-9]{4}|'?[0-9]{2}) (([0-2]?[0-9]:[0-5][0-9])|([0-1]?[0-9]:[0-5][0-9]\s(AM|PM)))$/));},format:function(s){return $.tablesorter.formatFloat(new Date(s).getTime());},type:"numeric"});ts.addParser({id:"shortDate",is:function(s){return/\d{1,2}[\/\-]\d{1,2}[\/\-]\d{2,4}/.test(s);},format:function(s,table){var c=table.config;s=s.replace(/\-/g,"/");if(c.dateFormat=="us"){s=s.replace(/(\d{1,2})[\/\-](\d{1,2})[\/\-](\d{4})/,"$3/$1/$2");}else if(c.dateFormat=="uk"){s=s.replace(/(\d{1,2})[\/\-](\d{1,2})[\/\-](\d{4})/,"$3/$2/$1");}else if(c.dateFormat=="dd/mm/yy"||c.dateFormat=="dd-mm-yy"){s=s.replace(/(\d{1,2})[\/\-](\d{1,2})[\/\-](\d{2})/,"$1/$2/$3");}return $.tablesorter.formatFloat(new Date(s).getTime());},type:"numeric"});ts.addParser({id:"time",is:function(s){return/^(([0-2]?[0-9]:[0-5][0-9])|([0-1]?[0-9]:[0-5][0-9]\s(am|pm)))$/.test(s);},format:function(s){return $.tablesorter.formatFloat(new Date("2000/01/01 "+s).getTime());},type:"numeric"});ts.addParser({id:"metadata",is:function(s){return false;},format:function(s,table,cell){var c=table.config,p=(!c.parserMetadataName)?'sortValue':c.parserMetadataName;return $(cell).metadata()[p];},type:"numeric"});ts.addWidget({id:"zebra",format:function(table){if(table.config.debug){var time=new Date();}var $tr,row=-1,odd;$("tr:visible",table.tBodies[0]).each(function(i){$tr=$(this);if(!$tr.hasClass(table.config.cssChildRow))row++;odd=(row%2==0);$tr.removeClass(table.config.widgetZebra.css[odd?0:1]).addClass(table.config.widgetZebra.css[odd?1:0])});if(table.config.debug){$.tablesorter.benchmark("Applying Zebra widget",time);}}});})(jQuery);
|
@@ -1,184 +0,0 @@
|
|
1
|
-
(function($) {
|
2
|
-
$.extend({
|
3
|
-
tablesorterPager: new function() {
|
4
|
-
|
5
|
-
function updatePageDisplay(c) {
|
6
|
-
var s = $(c.cssPageDisplay,c.container).val((c.page+1) + c.seperator + c.totalPages);
|
7
|
-
}
|
8
|
-
|
9
|
-
function setPageSize(table,size) {
|
10
|
-
var c = table.config;
|
11
|
-
c.size = size;
|
12
|
-
c.totalPages = Math.ceil(c.totalRows / c.size);
|
13
|
-
c.pagerPositionSet = false;
|
14
|
-
moveToPage(table);
|
15
|
-
fixPosition(table);
|
16
|
-
}
|
17
|
-
|
18
|
-
function fixPosition(table) {
|
19
|
-
var c = table.config;
|
20
|
-
if(!c.pagerPositionSet && c.positionFixed) {
|
21
|
-
var c = table.config, o = $(table);
|
22
|
-
if(o.offset) {
|
23
|
-
c.container.css({
|
24
|
-
top: o.offset().top + o.height() + 'px',
|
25
|
-
position: 'absolute'
|
26
|
-
});
|
27
|
-
}
|
28
|
-
c.pagerPositionSet = true;
|
29
|
-
}
|
30
|
-
}
|
31
|
-
|
32
|
-
function moveToFirstPage(table) {
|
33
|
-
var c = table.config;
|
34
|
-
c.page = 0;
|
35
|
-
moveToPage(table);
|
36
|
-
}
|
37
|
-
|
38
|
-
function moveToLastPage(table) {
|
39
|
-
var c = table.config;
|
40
|
-
c.page = (c.totalPages-1);
|
41
|
-
moveToPage(table);
|
42
|
-
}
|
43
|
-
|
44
|
-
function moveToNextPage(table) {
|
45
|
-
var c = table.config;
|
46
|
-
c.page++;
|
47
|
-
if(c.page >= (c.totalPages-1)) {
|
48
|
-
c.page = (c.totalPages-1);
|
49
|
-
}
|
50
|
-
moveToPage(table);
|
51
|
-
}
|
52
|
-
|
53
|
-
function moveToPrevPage(table) {
|
54
|
-
var c = table.config;
|
55
|
-
c.page--;
|
56
|
-
if(c.page <= 0) {
|
57
|
-
c.page = 0;
|
58
|
-
}
|
59
|
-
moveToPage(table);
|
60
|
-
}
|
61
|
-
|
62
|
-
|
63
|
-
function moveToPage(table) {
|
64
|
-
var c = table.config;
|
65
|
-
if(c.page < 0 || c.page > (c.totalPages-1)) {
|
66
|
-
c.page = 0;
|
67
|
-
}
|
68
|
-
|
69
|
-
renderTable(table,c.rowsCopy);
|
70
|
-
}
|
71
|
-
|
72
|
-
function renderTable(table,rows) {
|
73
|
-
|
74
|
-
var c = table.config;
|
75
|
-
var l = rows.length;
|
76
|
-
var s = (c.page * c.size);
|
77
|
-
var e = (s + c.size);
|
78
|
-
if(e > rows.length ) {
|
79
|
-
e = rows.length;
|
80
|
-
}
|
81
|
-
|
82
|
-
|
83
|
-
var tableBody = $(table.tBodies[0]);
|
84
|
-
|
85
|
-
// clear the table body
|
86
|
-
|
87
|
-
$.tablesorter.clearTableBody(table);
|
88
|
-
|
89
|
-
for(var i = s; i < e; i++) {
|
90
|
-
|
91
|
-
//tableBody.append(rows[i]);
|
92
|
-
|
93
|
-
var o = rows[i];
|
94
|
-
var l = o.length;
|
95
|
-
for(var j=0; j < l; j++) {
|
96
|
-
|
97
|
-
tableBody[0].appendChild(o[j]);
|
98
|
-
|
99
|
-
}
|
100
|
-
}
|
101
|
-
|
102
|
-
fixPosition(table,tableBody);
|
103
|
-
|
104
|
-
$(table).trigger("applyWidgets");
|
105
|
-
|
106
|
-
if( c.page >= c.totalPages ) {
|
107
|
-
moveToLastPage(table);
|
108
|
-
}
|
109
|
-
|
110
|
-
updatePageDisplay(c);
|
111
|
-
}
|
112
|
-
|
113
|
-
this.appender = function(table,rows) {
|
114
|
-
|
115
|
-
var c = table.config;
|
116
|
-
|
117
|
-
c.rowsCopy = rows;
|
118
|
-
c.totalRows = rows.length;
|
119
|
-
c.totalPages = Math.ceil(c.totalRows / c.size);
|
120
|
-
|
121
|
-
renderTable(table,rows);
|
122
|
-
};
|
123
|
-
|
124
|
-
this.defaults = {
|
125
|
-
size: 10,
|
126
|
-
offset: 0,
|
127
|
-
page: 0,
|
128
|
-
totalRows: 0,
|
129
|
-
totalPages: 0,
|
130
|
-
container: null,
|
131
|
-
cssNext: '.next',
|
132
|
-
cssPrev: '.prev',
|
133
|
-
cssFirst: '.first',
|
134
|
-
cssLast: '.last',
|
135
|
-
cssPageDisplay: '.pagedisplay',
|
136
|
-
cssPageSize: '.pagesize',
|
137
|
-
seperator: "/",
|
138
|
-
positionFixed: true,
|
139
|
-
appender: this.appender
|
140
|
-
};
|
141
|
-
|
142
|
-
this.construct = function(settings) {
|
143
|
-
|
144
|
-
return this.each(function() {
|
145
|
-
|
146
|
-
config = $.extend(this.config, $.tablesorterPager.defaults, settings);
|
147
|
-
|
148
|
-
var table = this, pager = config.container;
|
149
|
-
|
150
|
-
$(this).trigger("appendCache");
|
151
|
-
|
152
|
-
config.size = parseInt($(".pagesize",pager).val());
|
153
|
-
|
154
|
-
$(config.cssFirst,pager).click(function() {
|
155
|
-
moveToFirstPage(table);
|
156
|
-
return false;
|
157
|
-
});
|
158
|
-
$(config.cssNext,pager).click(function() {
|
159
|
-
moveToNextPage(table);
|
160
|
-
return false;
|
161
|
-
});
|
162
|
-
$(config.cssPrev,pager).click(function() {
|
163
|
-
moveToPrevPage(table);
|
164
|
-
return false;
|
165
|
-
});
|
166
|
-
$(config.cssLast,pager).click(function() {
|
167
|
-
moveToLastPage(table);
|
168
|
-
return false;
|
169
|
-
});
|
170
|
-
$(config.cssPageSize,pager).change(function() {
|
171
|
-
setPageSize(table,parseInt($(this).val()));
|
172
|
-
return false;
|
173
|
-
});
|
174
|
-
});
|
175
|
-
};
|
176
|
-
|
177
|
-
}
|
178
|
-
});
|
179
|
-
// extend plugin scope
|
180
|
-
$.fn.extend({
|
181
|
-
tablesorterPager: $.tablesorterPager.construct
|
182
|
-
});
|
183
|
-
|
184
|
-
})(jQuery);
|
@@ -1,25 +0,0 @@
|
|
1
|
-
div.tablesorterPager {
|
2
|
-
padding: 10px 0 10px 0;
|
3
|
-
background-color: #D6D2C2;
|
4
|
-
text-align: center;
|
5
|
-
}
|
6
|
-
div.tablesorterPager span {
|
7
|
-
padding: 0 5px 0 5px;
|
8
|
-
}
|
9
|
-
div.tablesorterPager input.prev {
|
10
|
-
width: auto;
|
11
|
-
margin-right: 10px;
|
12
|
-
}
|
13
|
-
div.tablesorterPager input.next {
|
14
|
-
width: auto;
|
15
|
-
margin-left: 10px;
|
16
|
-
}
|
17
|
-
div.tablesorterPager input {
|
18
|
-
font-size: 8px;
|
19
|
-
width: 50px;
|
20
|
-
border: 1px solid #330000;
|
21
|
-
text-align: center;
|
22
|
-
}
|
23
|
-
|
24
|
-
|
25
|
-
|