diff options
Diffstat (limited to 'app')
152 files changed, 1476 insertions, 2032 deletions
diff --git a/app/assets/images/icon_application_octet-stream_large.png b/app/assets/images/icon_application_octet-stream_large.png Binary files differindex a239862e1..a23916e9c 100644 --- a/app/assets/images/icon_application_octet-stream_large.png +++ b/app/assets/images/icon_application_octet-stream_large.png diff --git a/app/assets/images/icon_application_pdf_large.png b/app/assets/images/icon_application_pdf_large.png Binary files differindex 9a38ca33c..990b96c0a 100644 --- a/app/assets/images/icon_application_pdf_large.png +++ b/app/assets/images/icon_application_pdf_large.png diff --git a/app/assets/images/icon_application_rtf_large.png b/app/assets/images/icon_application_rtf_large.png Binary files differindex 2ad990608..977972124 100644 --- a/app/assets/images/icon_application_rtf_large.png +++ b/app/assets/images/icon_application_rtf_large.png diff --git a/app/assets/images/icon_application_vnd.ms-excel_large.png b/app/assets/images/icon_application_vnd.ms-excel_large.png Binary files differindex 3f346f5ef..acca5d92c 100644 --- a/app/assets/images/icon_application_vnd.ms-excel_large.png +++ b/app/assets/images/icon_application_vnd.ms-excel_large.png diff --git a/app/assets/images/icon_application_vnd.ms-powerpoint_large.png b/app/assets/images/icon_application_vnd.ms-powerpoint_large.png Binary files differindex 82c225059..9a1582930 100644 --- a/app/assets/images/icon_application_vnd.ms-powerpoint_large.png +++ b/app/assets/images/icon_application_vnd.ms-powerpoint_large.png diff --git a/app/assets/images/icon_application_vnd.ms-word_large.png b/app/assets/images/icon_application_vnd.ms-word_large.png Binary files differindex 91a696ab5..2f3cb8efa 100644 --- a/app/assets/images/icon_application_vnd.ms-word_large.png +++ b/app/assets/images/icon_application_vnd.ms-word_large.png diff --git a/app/assets/images/icon_application_zip_large.png b/app/assets/images/icon_application_zip_large.png Binary files differindex 0a14e978e..c52d6d5aa 100644 --- a/app/assets/images/icon_application_zip_large.png +++ b/app/assets/images/icon_application_zip_large.png diff --git a/app/assets/images/icon_image_bmp_large.png b/app/assets/images/icon_image_bmp_large.png Binary files differindex f6e8dbaed..347bdaaf1 100644..120000 --- a/app/assets/images/icon_image_bmp_large.png +++ b/app/assets/images/icon_image_bmp_large.png diff --git a/app/assets/images/icon_image_gif_large.png b/app/assets/images/icon_image_gif_large.png Binary files differindex 424d1e0fd..347bdaaf1 100644..120000 --- a/app/assets/images/icon_image_gif_large.png +++ b/app/assets/images/icon_image_gif_large.png diff --git a/app/assets/images/icon_image_img_large.png b/app/assets/images/icon_image_img_large.png Binary files differnew file mode 100644 index 000000000..e19e7553c --- /dev/null +++ b/app/assets/images/icon_image_img_large.png diff --git a/app/assets/images/icon_image_jpeg_large.png b/app/assets/images/icon_image_jpeg_large.png Binary files differindex fd50a889d..347bdaaf1 100644..120000 --- a/app/assets/images/icon_image_jpeg_large.png +++ b/app/assets/images/icon_image_jpeg_large.png diff --git a/app/assets/images/icon_image_png_large.png b/app/assets/images/icon_image_png_large.png Binary files differindex f16edb08e..347bdaaf1 100644..120000 --- a/app/assets/images/icon_image_png_large.png +++ b/app/assets/images/icon_image_png_large.png diff --git a/app/assets/images/icon_image_tiff_large.png b/app/assets/images/icon_image_tiff_large.png Binary files differindex 356f63478..000bd0318 100644 --- a/app/assets/images/icon_image_tiff_large.png +++ b/app/assets/images/icon_image_tiff_large.png diff --git a/app/assets/images/icon_message_delivery-status_large.png b/app/assets/images/icon_message_delivery-status_large.png Binary files differindex a239862e1..dccdbbccd 100644 --- a/app/assets/images/icon_message_delivery-status_large.png +++ b/app/assets/images/icon_message_delivery-status_large.png diff --git a/app/assets/images/icon_text_html_large.png b/app/assets/images/icon_text_html_large.png Binary files differindex 914502cf4..3813d2582 100644 --- a/app/assets/images/icon_text_html_large.png +++ b/app/assets/images/icon_text_html_large.png diff --git a/app/assets/images/icon_text_plain_large.png b/app/assets/images/icon_text_plain_large.png Binary files differindex f74a997ba..f15b0dbdc 100644 --- a/app/assets/images/icon_text_plain_large.png +++ b/app/assets/images/icon_text_plain_large.png diff --git a/app/assets/images/icon_text_x-vcard_large.png b/app/assets/images/icon_text_x-vcard_large.png Binary files differindex cc44d3edc..804066af8 100644 --- a/app/assets/images/icon_text_x-vcard_large.png +++ b/app/assets/images/icon_text_x-vcard_large.png diff --git a/app/assets/images/icon_unknown.png b/app/assets/images/icon_unknown.png Binary files differindex 992c646c0..9a06d9baa 100644 --- a/app/assets/images/icon_unknown.png +++ b/app/assets/images/icon_unknown.png diff --git a/app/assets/images/widget-base.png b/app/assets/images/widget-base.png Binary files differnew file mode 100644 index 000000000..872244543 --- /dev/null +++ b/app/assets/images/widget-base.png diff --git a/app/assets/javascripts/admin/admin.js.coffee b/app/assets/javascripts/admin/admin.js.coffee index 3d39369a4..85981f065 100644 --- a/app/assets/javascripts/admin/admin.js.coffee +++ b/app/assets/javascripts/admin/admin.js.coffee @@ -5,10 +5,10 @@ jQuery -> ) $('.accordion-body').on('shown', -> $(@).prev().find('i').first().removeClass().addClass('icon-chevron-down')) - $('.toggle-hidden').live('click', -> + $('body').on('.toggle-hidden', 'click', -> $(@).parents('td').find('div:hidden').show() false) - $('#request_hidden_user_explanation_reasons input').live('click', -> + $('#request_hidden_user_explanation_reasons').on('click', 'input', -> $('#request_hidden_user_subject, #request_hidden_user_explanation, #request_hide_button').show() info_request_id = $('#hide_request_form').attr('data-info-request-id') reason = $(this).val() diff --git a/app/assets/javascripts/general.js b/app/assets/javascripts/general.js index 002eef760..639a6917b 100644 --- a/app/assets/javascripts/general.js +++ b/app/assets/javascripts/general.js @@ -34,12 +34,12 @@ $(document).ready(function() { box.width(location.length + " em"); box.find('input').val(location).attr('size', location.length + " em"); box.show(); - box.find('input').select(); box.position({ my: "right center", at: "left bottom", of: this, collision: "fit" }); + box.find('input').select(); return false; }); @@ -57,4 +57,12 @@ $(document).ready(function() { $('#everypage').hide(); } + // "Create widget" page + $("#widgetbox").select() + // Chrome workaround + $("widgetbox").mouseup(function() { + // Prevent further mouseup intervention + $this.unbind("mouseup"); + return false; + }); }) diff --git a/app/assets/javascripts/jquery.Jcrop.js b/app/assets/javascripts/jquery.Jcrop.js deleted file mode 100644 index 9002b9787..000000000 --- a/app/assets/javascripts/jquery.Jcrop.js +++ /dev/null @@ -1,163 +0,0 @@ -/** - * Jcrop v.0.9.8 (minimized) - * (c) 2008 Kelly Hallman and DeepLiquid.com - * More information: http://deepliquid.com/content/Jcrop.html - * Released under MIT License - this header must remain with code - */ - - -(function($){$.Jcrop=function(obj,opt) -{var obj=obj,opt=opt;if(typeof(obj)!=='object')obj=$(obj)[0];if(typeof(opt)!=='object')opt={};if(!('trackDocument'in opt)) -{opt.trackDocument=$.browser.msie?false:true;if($.browser.msie&&$.browser.version.split('.')[0]=='8') -opt.trackDocument=true;} -if(!('keySupport'in opt)) -opt.keySupport=$.browser.msie?false:true;var defaults={trackDocument:false,baseClass:'jcrop',addClass:null,bgColor:'black',bgOpacity:.6,borderOpacity:.4,handleOpacity:.5,handlePad:5,handleSize:9,handleOffset:5,edgeMargin:14,aspectRatio:0,keySupport:true,cornerHandles:true,sideHandles:true,drawBorders:true,dragEdges:true,boxWidth:0,boxHeight:0,boundary:8,animationDelay:20,swingSpeed:3,allowSelect:true,allowMove:true,allowResize:true,minSelect:[0,0],maxSize:[0,0],minSize:[0,0],onChange:function(){},onSelect:function(){}};var options=defaults;setOptions(opt);var $origimg=$(obj);var $img=$origimg.clone().removeAttr('id').css({position:'absolute'});$img.width($origimg.width());$img.height($origimg.height());$origimg.after($img).hide();presize($img,options.boxWidth,options.boxHeight);var boundx=$img.width(),boundy=$img.height(),$div=$('<div />').width(boundx).height(boundy).addClass(cssClass('holder')).css({position:'relative',backgroundColor:options.bgColor}).insertAfter($origimg).append($img);;if(options.addClass)$div.addClass(options.addClass);var $img2=$('<img />').attr('src',$img.attr('src')).css('position','absolute').width(boundx).height(boundy);var $img_holder=$('<div />').width(pct(100)).height(pct(100)).css({zIndex:310,position:'absolute',overflow:'hidden'}).append($img2);var $hdl_holder=$('<div />').width(pct(100)).height(pct(100)).css('zIndex',320);var $sel=$('<div />').css({position:'absolute',zIndex:300}).insertBefore($img).append($img_holder,$hdl_holder);var bound=options.boundary;var $trk=newTracker().width(boundx+(bound*2)).height(boundy+(bound*2)).css({position:'absolute',top:px(-bound),left:px(-bound),zIndex:290}).mousedown(newSelection);var xlimit,ylimit,xmin,ymin;var xscale,yscale,enabled=true;var docOffset=getPos($img),btndown,lastcurs,dimmed,animating,shift_down;var Coords=function() -{var x1=0,y1=0,x2=0,y2=0,ox,oy;function setPressed(pos) -{var pos=rebound(pos);x2=x1=pos[0];y2=y1=pos[1];};function setCurrent(pos) -{var pos=rebound(pos);ox=pos[0]-x2;oy=pos[1]-y2;x2=pos[0];y2=pos[1];};function getOffset() -{return[ox,oy];};function moveOffset(offset) -{var ox=offset[0],oy=offset[1];if(0>x1+ox)ox-=ox+x1;if(0>y1+oy)oy-=oy+y1;if(boundy<y2+oy)oy+=boundy-(y2+oy);if(boundx<x2+ox)ox+=boundx-(x2+ox);x1+=ox;x2+=ox;y1+=oy;y2+=oy;};function getCorner(ord) -{var c=getFixed();switch(ord) -{case'ne':return[c.x2,c.y];case'nw':return[c.x,c.y];case'se':return[c.x2,c.y2];case'sw':return[c.x,c.y2];}};function getFixed() -{if(!options.aspectRatio)return getRect();var aspect=options.aspectRatio,min_x=options.minSize[0]/xscale,min_y=options.minSize[1]/yscale,max_x=options.maxSize[0]/xscale,max_y=options.maxSize[1]/yscale,rw=x2-x1,rh=y2-y1,rwa=Math.abs(rw),rha=Math.abs(rh),real_ratio=rwa/rha,xx,yy;if(max_x==0){max_x=boundx*10} -if(max_y==0){max_y=boundy*10} -if(real_ratio<aspect) -{yy=y2;w=rha*aspect;xx=rw<0?x1-w:w+x1;if(xx<0) -{xx=0;h=Math.abs((xx-x1)/aspect);yy=rh<0?y1-h:h+y1;} -else if(xx>boundx) -{xx=boundx;h=Math.abs((xx-x1)/aspect);yy=rh<0?y1-h:h+y1;}} -else -{xx=x2;h=rwa/aspect;yy=rh<0?y1-h:y1+h;if(yy<0) -{yy=0;w=Math.abs((yy-y1)*aspect);xx=rw<0?x1-w:w+x1;} -else if(yy>boundy) -{yy=boundy;w=Math.abs(yy-y1)*aspect;xx=rw<0?x1-w:w+x1;}} -if(xx>x1){if(xx-x1<min_x){xx=x1+min_x;}else if(xx-x1>max_x){xx=x1+max_x;} -if(yy>y1){yy=y1+(xx-x1)/aspect;}else{yy=y1-(xx-x1)/aspect;}}else if(xx<x1){if(x1-xx<min_x){xx=x1-min_x}else if(x1-xx>max_x){xx=x1-max_x;} -if(yy>y1){yy=y1+(x1-xx)/aspect;}else{yy=y1-(x1-xx)/aspect;}} -if(xx<0){x1-=xx;xx=0;}else if(xx>boundx){x1-=xx-boundx;xx=boundx;} -if(yy<0){y1-=yy;yy=0;}else if(yy>boundy){y1-=yy-boundy;yy=boundy;} -return last=makeObj(flipCoords(x1,y1,xx,yy));};function rebound(p) -{if(p[0]<0)p[0]=0;if(p[1]<0)p[1]=0;if(p[0]>boundx)p[0]=boundx;if(p[1]>boundy)p[1]=boundy;return[p[0],p[1]];};function flipCoords(x1,y1,x2,y2) -{var xa=x1,xb=x2,ya=y1,yb=y2;if(x2<x1) -{xa=x2;xb=x1;} -if(y2<y1) -{ya=y2;yb=y1;} -return[Math.round(xa),Math.round(ya),Math.round(xb),Math.round(yb)];};function getRect() -{var xsize=x2-x1;var ysize=y2-y1;if(xlimit&&(Math.abs(xsize)>xlimit)) -x2=(xsize>0)?(x1+xlimit):(x1-xlimit);if(ylimit&&(Math.abs(ysize)>ylimit)) -y2=(ysize>0)?(y1+ylimit):(y1-ylimit);if(ymin&&(Math.abs(ysize)<ymin)) -y2=(ysize>0)?(y1+ymin):(y1-ymin);if(xmin&&(Math.abs(xsize)<xmin)) -x2=(xsize>0)?(x1+xmin):(x1-xmin);if(x1<0){x2-=x1;x1-=x1;} -if(y1<0){y2-=y1;y1-=y1;} -if(x2<0){x1-=x2;x2-=x2;} -if(y2<0){y1-=y2;y2-=y2;} -if(x2>boundx){var delta=x2-boundx;x1-=delta;x2-=delta;} -if(y2>boundy){var delta=y2-boundy;y1-=delta;y2-=delta;} -if(x1>boundx){var delta=x1-boundy;y2-=delta;y1-=delta;} -if(y1>boundy){var delta=y1-boundy;y2-=delta;y1-=delta;} -return makeObj(flipCoords(x1,y1,x2,y2));};function makeObj(a) -{return{x:a[0],y:a[1],x2:a[2],y2:a[3],w:a[2]-a[0],h:a[3]-a[1]};};return{flipCoords:flipCoords,setPressed:setPressed,setCurrent:setCurrent,getOffset:getOffset,moveOffset:moveOffset,getCorner:getCorner,getFixed:getFixed};}();var Selection=function() -{var start,end,dragmode,awake,hdep=370;var borders={};var handle={};var seehandles=false;var hhs=options.handleOffset;if(options.drawBorders){borders={top:insertBorder('hline').css('top',$.browser.msie?px(-1):px(0)),bottom:insertBorder('hline'),left:insertBorder('vline'),right:insertBorder('vline')};} -if(options.dragEdges){handle.t=insertDragbar('n');handle.b=insertDragbar('s');handle.r=insertDragbar('e');handle.l=insertDragbar('w');} -options.sideHandles&&createHandles(['n','s','e','w']);options.cornerHandles&&createHandles(['sw','nw','ne','se']);function insertBorder(type) -{var jq=$('<div />').css({position:'absolute',opacity:options.borderOpacity}).addClass(cssClass(type));$img_holder.append(jq);return jq;};function dragDiv(ord,zi) -{var jq=$('<div />').mousedown(createDragger(ord)).css({cursor:ord+'-resize',position:'absolute',zIndex:zi});$hdl_holder.append(jq);return jq;};function insertHandle(ord) -{return dragDiv(ord,hdep++).css({top:px(-hhs+1),left:px(-hhs+1),opacity:options.handleOpacity}).addClass(cssClass('handle'));};function insertDragbar(ord) -{var s=options.handleSize,o=hhs,h=s,w=s,t=o,l=o;switch(ord) -{case'n':case's':w=pct(100);break;case'e':case'w':h=pct(100);break;} -return dragDiv(ord,hdep++).width(w).height(h).css({top:px(-t+1),left:px(-l+1)});};function createHandles(li) -{for(i in li)handle[li[i]]=insertHandle(li[i]);};function moveHandles(c) -{var midvert=Math.round((c.h/2)-hhs),midhoriz=Math.round((c.w/2)-hhs),north=west=-hhs+1,east=c.w-hhs,south=c.h-hhs,x,y;'e'in handle&&handle.e.css({top:px(midvert),left:px(east)})&&handle.w.css({top:px(midvert)})&&handle.s.css({top:px(south),left:px(midhoriz)})&&handle.n.css({left:px(midhoriz)});'ne'in handle&&handle.ne.css({left:px(east)})&&handle.se.css({top:px(south),left:px(east)})&&handle.sw.css({top:px(south)});'b'in handle&&handle.b.css({top:px(south)})&&handle.r.css({left:px(east)});};function moveto(x,y) -{$img2.css({top:px(-y),left:px(-x)});$sel.css({top:px(y),left:px(x)});};function resize(w,h) -{$sel.width(w).height(h);};function refresh() -{var c=Coords.getFixed();Coords.setPressed([c.x,c.y]);Coords.setCurrent([c.x2,c.y2]);updateVisible();};function updateVisible() -{if(awake)return update();};function update() -{var c=Coords.getFixed();resize(c.w,c.h);moveto(c.x,c.y);options.drawBorders&&borders['right'].css({left:px(c.w-1)})&&borders['bottom'].css({top:px(c.h-1)});seehandles&&moveHandles(c);awake||show();options.onChange(unscale(c));};function show() -{$sel.show();$img.css('opacity',options.bgOpacity);awake=true;};function release() -{disableHandles();$sel.hide();$img.css('opacity',1);awake=false;};function showHandles() -{if(seehandles) -{moveHandles(Coords.getFixed());$hdl_holder.show();}};function enableHandles() -{seehandles=true;if(options.allowResize) -{moveHandles(Coords.getFixed());$hdl_holder.show();return true;}};function disableHandles() -{seehandles=false;$hdl_holder.hide();};function animMode(v) -{(animating=v)?disableHandles():enableHandles();};function done() -{animMode(false);refresh();};var $track=newTracker().mousedown(createDragger('move')).css({cursor:'move',position:'absolute',zIndex:360}) -$img_holder.append($track);disableHandles();return{updateVisible:updateVisible,update:update,release:release,refresh:refresh,setCursor:function(cursor){$track.css('cursor',cursor);},enableHandles:enableHandles,enableOnly:function(){seehandles=true;},showHandles:showHandles,disableHandles:disableHandles,animMode:animMode,done:done};}();var Tracker=function() -{var onMove=function(){},onDone=function(){},trackDoc=options.trackDocument;if(!trackDoc) -{$trk.mousemove(trackMove).mouseup(trackUp).mouseout(trackUp);} -function toFront() -{$trk.css({zIndex:450});if(trackDoc) -{$(document).mousemove(trackMove).mouseup(trackUp);}} -function toBack() -{$trk.css({zIndex:290});if(trackDoc) -{$(document).unbind('mousemove',trackMove).unbind('mouseup',trackUp);}} -function trackMove(e) -{onMove(mouseAbs(e));};function trackUp(e) -{e.preventDefault();e.stopPropagation();if(btndown) -{btndown=false;onDone(mouseAbs(e));options.onSelect(unscale(Coords.getFixed()));toBack();onMove=function(){};onDone=function(){};} -return false;};function activateHandlers(move,done) -{btndown=true;onMove=move;onDone=done;toFront();return false;};function setCursor(t){$trk.css('cursor',t);};$img.before($trk);return{activateHandlers:activateHandlers,setCursor:setCursor};}();var KeyManager=function() -{var $keymgr=$('<input type="radio" />').css({position:'absolute',left:'-30px'}).keypress(parseKey).blur(onBlur),$keywrap=$('<div />').css({position:'absolute',overflow:'hidden'}).append($keymgr);function watchKeys() -{if(options.keySupport) -{$keymgr.show();$keymgr.focus();}};function onBlur(e) -{$keymgr.hide();};function doNudge(e,x,y) -{if(options.allowMove){Coords.moveOffset([x,y]);Selection.updateVisible();};e.preventDefault();e.stopPropagation();};function parseKey(e) -{if(e.ctrlKey)return true;shift_down=e.shiftKey?true:false;var nudge=shift_down?10:1;switch(e.keyCode) -{case 37:doNudge(e,-nudge,0);break;case 39:doNudge(e,nudge,0);break;case 38:doNudge(e,0,-nudge);break;case 40:doNudge(e,0,nudge);break;case 27:Selection.release();break;case 9:return true;} -return nothing(e);};if(options.keySupport)$keywrap.insertBefore($img);return{watchKeys:watchKeys};}();function px(n){return''+parseInt(n)+'px';};function pct(n){return''+parseInt(n)+'%';};function cssClass(cl){return options.baseClass+'-'+cl;};function getPos(obj) -{var pos=$(obj).offset();return[pos.left,pos.top];};function mouseAbs(e) -{return[(e.pageX-docOffset[0]),(e.pageY-docOffset[1])];};function myCursor(type) -{if(type!=lastcurs) -{Tracker.setCursor(type);lastcurs=type;}};function startDragMode(mode,pos) -{docOffset=getPos($img);Tracker.setCursor(mode=='move'?mode:mode+'-resize');if(mode=='move') -return Tracker.activateHandlers(createMover(pos),doneSelect);var fc=Coords.getFixed();var opp=oppLockCorner(mode);var opc=Coords.getCorner(oppLockCorner(opp));Coords.setPressed(Coords.getCorner(opp));Coords.setCurrent(opc);Tracker.activateHandlers(dragmodeHandler(mode,fc),doneSelect);};function dragmodeHandler(mode,f) -{return function(pos){if(!options.aspectRatio)switch(mode) -{case'e':pos[1]=f.y2;break;case'w':pos[1]=f.y2;break;case'n':pos[0]=f.x2;break;case's':pos[0]=f.x2;break;} -else switch(mode) -{case'e':pos[1]=f.y+1;break;case'w':pos[1]=f.y+1;break;case'n':pos[0]=f.x+1;break;case's':pos[0]=f.x+1;break;} -Coords.setCurrent(pos);Selection.update();};};function createMover(pos) -{var lloc=pos;KeyManager.watchKeys();return function(pos) -{Coords.moveOffset([pos[0]-lloc[0],pos[1]-lloc[1]]);lloc=pos;Selection.update();};};function oppLockCorner(ord) -{switch(ord) -{case'n':return'sw';case's':return'nw';case'e':return'nw';case'w':return'ne';case'ne':return'sw';case'nw':return'se';case'se':return'nw';case'sw':return'ne';};};function createDragger(ord) -{return function(e){if(options.disabled)return false;if((ord=='move')&&!options.allowMove)return false;btndown=true;startDragMode(ord,mouseAbs(e));e.stopPropagation();e.preventDefault();return false;};};function presize($obj,w,h) -{var nw=$obj.width(),nh=$obj.height();if((nw>w)&&w>0) -{nw=w;nh=(w/$obj.width())*$obj.height();} -if((nh>h)&&h>0) -{nh=h;nw=(h/$obj.height())*$obj.width();} -xscale=$obj.width()/nw;yscale=$obj.height()/nh;$obj.width(nw).height(nh);};function unscale(c) -{return{x:parseInt(c.x*xscale),y:parseInt(c.y*yscale),x2:parseInt(c.x2*xscale),y2:parseInt(c.y2*yscale),w:parseInt(c.w*xscale),h:parseInt(c.h*yscale)};};function doneSelect(pos) -{var c=Coords.getFixed();if(c.w>options.minSelect[0]&&c.h>options.minSelect[1]) -{Selection.enableHandles();Selection.done();} -else -{Selection.release();} -Tracker.setCursor(options.allowSelect?'crosshair':'default');};function newSelection(e) -{if(options.disabled)return false;if(!options.allowSelect)return false;btndown=true;docOffset=getPos($img);Selection.disableHandles();myCursor('crosshair');var pos=mouseAbs(e);Coords.setPressed(pos);Tracker.activateHandlers(selectDrag,doneSelect);KeyManager.watchKeys();Selection.update();e.stopPropagation();e.preventDefault();return false;};function selectDrag(pos) -{Coords.setCurrent(pos);Selection.update();};function newTracker() -{var trk=$('<div></div>').addClass(cssClass('tracker'));$.browser.msie&&trk.css({opacity:0,backgroundColor:'white'});return trk;};function animateTo(a) -{var x1=a[0]/xscale,y1=a[1]/yscale,x2=a[2]/xscale,y2=a[3]/yscale;if(animating)return;var animto=Coords.flipCoords(x1,y1,x2,y2);var c=Coords.getFixed();var animat=initcr=[c.x,c.y,c.x2,c.y2];var interv=options.animationDelay;var x=animat[0];var y=animat[1];var x2=animat[2];var y2=animat[3];var ix1=animto[0]-initcr[0];var iy1=animto[1]-initcr[1];var ix2=animto[2]-initcr[2];var iy2=animto[3]-initcr[3];var pcent=0;var velocity=options.swingSpeed;Selection.animMode(true);var animator=function() -{return function() -{pcent+=(100-pcent)/velocity;animat[0]=x+((pcent/100)*ix1);animat[1]=y+((pcent/100)*iy1);animat[2]=x2+((pcent/100)*ix2);animat[3]=y2+((pcent/100)*iy2);if(pcent<100)animateStart();else Selection.done();if(pcent>=99.8)pcent=100;setSelectRaw(animat);};}();function animateStart() -{window.setTimeout(animator,interv);};animateStart();};function setSelect(rect) -{setSelectRaw([rect[0]/xscale,rect[1]/yscale,rect[2]/xscale,rect[3]/yscale]);};function setSelectRaw(l) -{Coords.setPressed([l[0],l[1]]);Coords.setCurrent([l[2],l[3]]);Selection.update();};function setOptions(opt) -{if(typeof(opt)!='object')opt={};options=$.extend(options,opt);if(typeof(options.onChange)!=='function') -options.onChange=function(){};if(typeof(options.onSelect)!=='function') -options.onSelect=function(){};};function tellSelect() -{return unscale(Coords.getFixed());};function tellScaled() -{return Coords.getFixed();};function setOptionsNew(opt) -{setOptions(opt);interfaceUpdate();};function disableCrop() -{options.disabled=true;Selection.disableHandles();Selection.setCursor('default');Tracker.setCursor('default');};function enableCrop() -{options.disabled=false;interfaceUpdate();};function cancelCrop() -{Selection.done();Tracker.activateHandlers(null,null);};function destroy() -{$div.remove();$origimg.show();};function interfaceUpdate(alt) -{options.allowResize?alt?Selection.enableOnly():Selection.enableHandles():Selection.disableHandles();Tracker.setCursor(options.allowSelect?'crosshair':'default');Selection.setCursor(options.allowMove?'move':'default');$div.css('backgroundColor',options.bgColor);if('setSelect'in options){setSelect(opt.setSelect);Selection.done();delete(options.setSelect);} -if('trueSize'in options){xscale=options.trueSize[0]/boundx;yscale=options.trueSize[1]/boundy;} -xlimit=options.maxSize[0]||0;ylimit=options.maxSize[1]||0;xmin=options.minSize[0]||0;ymin=options.minSize[1]||0;if('outerImage'in options) -{$img.attr('src',options.outerImage);delete(options.outerImage);} -Selection.refresh();};$hdl_holder.hide();interfaceUpdate(true);var api={animateTo:animateTo,setSelect:setSelect,setOptions:setOptionsNew,tellSelect:tellSelect,tellScaled:tellScaled,disable:disableCrop,enable:enableCrop,cancel:cancelCrop,focus:KeyManager.watchKeys,getBounds:function(){return[boundx*xscale,boundy*yscale];},getWidgetSize:function(){return[boundx,boundy];},release:Selection.release,destroy:destroy};$origimg.data('Jcrop',api);return api;};$.fn.Jcrop=function(options) -{function attachWhenDone(from) -{var loadsrc=options.useImg||from.src;var img=new Image();img.onload=function(){$.Jcrop(from,options);};img.src=loadsrc;};if(typeof(options)!=='object')options={};this.each(function() -{if($(this).data('Jcrop')) -{if(options=='api')return $(this).data('Jcrop');else $(this).data('Jcrop').setOptions(options);} -else attachWhenDone(this);});return this;};})(jQuery);
\ No newline at end of file diff --git a/app/assets/javascripts/jquery.Jcrop.min.js b/app/assets/javascripts/jquery.Jcrop.min.js new file mode 100644 index 000000000..d9ae1adfc --- /dev/null +++ b/app/assets/javascripts/jquery.Jcrop.min.js @@ -0,0 +1,7 @@ +/** + * jquery.Jcrop.min.js v0.9.12 (build:20140524) + * jQuery Image Cropping Plugin - released under MIT License + * Copyright (c) 2008-2013 Tapmodo Interactive LLC + * https://github.com/tapmodo/Jcrop + */ +!function($){$.Jcrop=function(obj,opt){function px(n){return Math.round(n)+"px"}function cssClass(cl){return options.baseClass+"-"+cl}function supportsColorFade(){return $.fx.step.hasOwnProperty("backgroundColor")}function getPos(obj){var pos=$(obj).offset();return[pos.left,pos.top]}function mouseAbs(e){return[e.pageX-docOffset[0],e.pageY-docOffset[1]]}function setOptions(opt){"object"!=typeof opt&&(opt={}),options=$.extend(options,opt),$.each(["onChange","onSelect","onRelease","onDblClick"],function(i,e){"function"!=typeof options[e]&&(options[e]=function(){})})}function startDragMode(mode,pos,touch){if(docOffset=getPos($img),Tracker.setCursor("move"===mode?mode:mode+"-resize"),"move"===mode)return Tracker.activateHandlers(createMover(pos),doneSelect,touch);var fc=Coords.getFixed(),opp=oppLockCorner(mode),opc=Coords.getCorner(oppLockCorner(opp));Coords.setPressed(Coords.getCorner(opp)),Coords.setCurrent(opc),Tracker.activateHandlers(dragmodeHandler(mode,fc),doneSelect,touch)}function dragmodeHandler(mode,f){return function(pos){if(options.aspectRatio)switch(mode){case"e":pos[1]=f.y+1;break;case"w":pos[1]=f.y+1;break;case"n":pos[0]=f.x+1;break;case"s":pos[0]=f.x+1}else switch(mode){case"e":pos[1]=f.y2;break;case"w":pos[1]=f.y2;break;case"n":pos[0]=f.x2;break;case"s":pos[0]=f.x2}Coords.setCurrent(pos),Selection.update()}}function createMover(pos){var lloc=pos;return KeyManager.watchKeys(),function(pos){Coords.moveOffset([pos[0]-lloc[0],pos[1]-lloc[1]]),lloc=pos,Selection.update()}}function oppLockCorner(ord){switch(ord){case"n":return"sw";case"s":return"nw";case"e":return"nw";case"w":return"ne";case"ne":return"sw";case"nw":return"se";case"se":return"nw";case"sw":return"ne"}}function createDragger(ord){return function(e){return options.disabled?!1:"move"!==ord||options.allowMove?(docOffset=getPos($img),btndown=!0,startDragMode(ord,mouseAbs(e)),e.stopPropagation(),e.preventDefault(),!1):!1}}function presize($obj,w,h){var nw=$obj.width(),nh=$obj.height();nw>w&&w>0&&(nw=w,nh=w/$obj.width()*$obj.height()),nh>h&&h>0&&(nh=h,nw=h/$obj.height()*$obj.width()),xscale=$obj.width()/nw,yscale=$obj.height()/nh,$obj.width(nw).height(nh)}function unscale(c){return{x:c.x*xscale,y:c.y*yscale,x2:c.x2*xscale,y2:c.y2*yscale,w:c.w*xscale,h:c.h*yscale}}function doneSelect(){var c=Coords.getFixed();c.w>options.minSelect[0]&&c.h>options.minSelect[1]?(Selection.enableHandles(),Selection.done()):Selection.release(),Tracker.setCursor(options.allowSelect?"crosshair":"default")}function newSelection(e){if(!options.disabled&&options.allowSelect){btndown=!0,docOffset=getPos($img),Selection.disableHandles(),Tracker.setCursor("crosshair");var pos=mouseAbs(e);return Coords.setPressed(pos),Selection.update(),Tracker.activateHandlers(selectDrag,doneSelect,"touch"===e.type.substring(0,5)),KeyManager.watchKeys(),e.stopPropagation(),e.preventDefault(),!1}}function selectDrag(pos){Coords.setCurrent(pos),Selection.update()}function newTracker(){var trk=$("<div></div>").addClass(cssClass("tracker"));return is_msie&&trk.css({opacity:0,backgroundColor:"white"}),trk}function setClass(cname){$div.removeClass().addClass(cssClass("holder")).addClass(cname)}function animateTo(a,callback){function queueAnimator(){window.setTimeout(animator,interv)}var x1=a[0]/xscale,y1=a[1]/yscale,x2=a[2]/xscale,y2=a[3]/yscale;if(!animating){var animto=Coords.flipCoords(x1,y1,x2,y2),c=Coords.getFixed(),initcr=[c.x,c.y,c.x2,c.y2],animat=initcr,interv=options.animationDelay,ix1=animto[0]-initcr[0],iy1=animto[1]-initcr[1],ix2=animto[2]-initcr[2],iy2=animto[3]-initcr[3],pcent=0,velocity=options.swingSpeed;x1=animat[0],y1=animat[1],x2=animat[2],y2=animat[3],Selection.animMode(!0);var animator=function(){return function(){pcent+=(100-pcent)/velocity,animat[0]=Math.round(x1+pcent/100*ix1),animat[1]=Math.round(y1+pcent/100*iy1),animat[2]=Math.round(x2+pcent/100*ix2),animat[3]=Math.round(y2+pcent/100*iy2),pcent>=99.8&&(pcent=100),100>pcent?(setSelectRaw(animat),queueAnimator()):(Selection.done(),Selection.animMode(!1),"function"==typeof callback&&callback.call(api))}}();queueAnimator()}}function setSelect(rect){setSelectRaw([rect[0]/xscale,rect[1]/yscale,rect[2]/xscale,rect[3]/yscale]),options.onSelect.call(api,unscale(Coords.getFixed())),Selection.enableHandles()}function setSelectRaw(l){Coords.setPressed([l[0],l[1]]),Coords.setCurrent([l[2],l[3]]),Selection.update()}function tellSelect(){return unscale(Coords.getFixed())}function tellScaled(){return Coords.getFixed()}function setOptionsNew(opt){setOptions(opt),interfaceUpdate()}function disableCrop(){options.disabled=!0,Selection.disableHandles(),Selection.setCursor("default"),Tracker.setCursor("default")}function enableCrop(){options.disabled=!1,interfaceUpdate()}function cancelCrop(){Selection.done(),Tracker.activateHandlers(null,null)}function destroy(){$div.remove(),$origimg.show(),$origimg.css("visibility","visible"),$(obj).removeData("Jcrop")}function setImage(src,callback){Selection.release(),disableCrop();var img=new Image;img.onload=function(){var iw=img.width,ih=img.height,bw=options.boxWidth,bh=options.boxHeight;$img.width(iw).height(ih),$img.attr("src",src),$img2.attr("src",src),presize($img,bw,bh),boundx=$img.width(),boundy=$img.height(),$img2.width(boundx).height(boundy),$trk.width(boundx+2*bound).height(boundy+2*bound),$div.width(boundx).height(boundy),Shade.resize(boundx,boundy),enableCrop(),"function"==typeof callback&&callback.call(api)},img.src=src}function colorChangeMacro($obj,color,now){var mycolor=color||options.bgColor;options.bgFade&&supportsColorFade()&&options.fadeTime&&!now?$obj.animate({backgroundColor:mycolor},{queue:!1,duration:options.fadeTime}):$obj.css("backgroundColor",mycolor)}function interfaceUpdate(alt){options.allowResize?alt?Selection.enableOnly():Selection.enableHandles():Selection.disableHandles(),Tracker.setCursor(options.allowSelect?"crosshair":"default"),Selection.setCursor(options.allowMove?"move":"default"),options.hasOwnProperty("trueSize")&&(xscale=options.trueSize[0]/boundx,yscale=options.trueSize[1]/boundy),options.hasOwnProperty("setSelect")&&(setSelect(options.setSelect),Selection.done(),delete options.setSelect),Shade.refresh(),options.bgColor!=bgcolor&&(colorChangeMacro(options.shade?Shade.getShades():$div,options.shade?options.shadeColor||options.bgColor:options.bgColor),bgcolor=options.bgColor),bgopacity!=options.bgOpacity&&(bgopacity=options.bgOpacity,options.shade?Shade.refresh():Selection.setBgOpacity(bgopacity)),xlimit=options.maxSize[0]||0,ylimit=options.maxSize[1]||0,xmin=options.minSize[0]||0,ymin=options.minSize[1]||0,options.hasOwnProperty("outerImage")&&($img.attr("src",options.outerImage),delete options.outerImage),Selection.refresh()}var docOffset,options=$.extend({},$.Jcrop.defaults),_ua=navigator.userAgent.toLowerCase(),is_msie=/msie/.test(_ua),ie6mode=/msie [1-6]\./.test(_ua);"object"!=typeof obj&&(obj=$(obj)[0]),"object"!=typeof opt&&(opt={}),setOptions(opt);var img_css={border:"none",visibility:"visible",margin:0,padding:0,position:"absolute",top:0,left:0},$origimg=$(obj),img_mode=!0;if("IMG"==obj.tagName){if(0!=$origimg[0].width&&0!=$origimg[0].height)$origimg.width($origimg[0].width),$origimg.height($origimg[0].height);else{var tempImage=new Image;tempImage.src=$origimg[0].src,$origimg.width(tempImage.width),$origimg.height(tempImage.height)}var $img=$origimg.clone().removeAttr("id").css(img_css).show();$img.width($origimg.width()),$img.height($origimg.height()),$origimg.after($img).hide()}else $img=$origimg.css(img_css).show(),img_mode=!1,null===options.shade&&(options.shade=!0);presize($img,options.boxWidth,options.boxHeight);var boundx=$img.width(),boundy=$img.height(),$div=$("<div />").width(boundx).height(boundy).addClass(cssClass("holder")).css({position:"relative",backgroundColor:options.bgColor}).insertAfter($origimg).append($img);options.addClass&&$div.addClass(options.addClass);var $img2=$("<div />"),$img_holder=$("<div />").width("100%").height("100%").css({zIndex:310,position:"absolute",overflow:"hidden"}),$hdl_holder=$("<div />").width("100%").height("100%").css("zIndex",320),$sel=$("<div />").css({position:"absolute",zIndex:600}).dblclick(function(){var c=Coords.getFixed();options.onDblClick.call(api,c)}).insertBefore($img).append($img_holder,$hdl_holder);img_mode&&($img2=$("<img />").attr("src",$img.attr("src")).css(img_css).width(boundx).height(boundy),$img_holder.append($img2)),ie6mode&&$sel.css({overflowY:"hidden"});var xlimit,ylimit,xmin,ymin,xscale,yscale,btndown,animating,shift_down,bound=options.boundary,$trk=newTracker().width(boundx+2*bound).height(boundy+2*bound).css({position:"absolute",top:px(-bound),left:px(-bound),zIndex:290}).mousedown(newSelection),bgcolor=options.bgColor,bgopacity=options.bgOpacity;docOffset=getPos($img);var Touch=function(){function hasTouchSupport(){var i,support={},events=["touchstart","touchmove","touchend"],el=document.createElement("div");try{for(i=0;i<events.length;i++){var eventName=events[i];eventName="on"+eventName;var isSupported=eventName in el;isSupported||(el.setAttribute(eventName,"return;"),isSupported="function"==typeof el[eventName]),support[events[i]]=isSupported}return support.touchstart&&support.touchend&&support.touchmove}catch(err){return!1}}function detectSupport(){return options.touchSupport===!0||options.touchSupport===!1?options.touchSupport:hasTouchSupport()}return{createDragger:function(ord){return function(e){return options.disabled?!1:"move"!==ord||options.allowMove?(docOffset=getPos($img),btndown=!0,startDragMode(ord,mouseAbs(Touch.cfilter(e)),!0),e.stopPropagation(),e.preventDefault(),!1):!1}},newSelection:function(e){return newSelection(Touch.cfilter(e))},cfilter:function(e){return e.pageX=e.originalEvent.changedTouches[0].pageX,e.pageY=e.originalEvent.changedTouches[0].pageY,e},isSupported:hasTouchSupport,support:detectSupport()}}(),Coords=function(){function setPressed(pos){pos=rebound(pos),x2=x1=pos[0],y2=y1=pos[1]}function setCurrent(pos){pos=rebound(pos),ox=pos[0]-x2,oy=pos[1]-y2,x2=pos[0],y2=pos[1]}function getOffset(){return[ox,oy]}function moveOffset(offset){var ox=offset[0],oy=offset[1];0>x1+ox&&(ox-=ox+x1),0>y1+oy&&(oy-=oy+y1),y2+oy>boundy&&(oy+=boundy-(y2+oy)),x2+ox>boundx&&(ox+=boundx-(x2+ox)),x1+=ox,x2+=ox,y1+=oy,y2+=oy}function getCorner(ord){var c=getFixed();switch(ord){case"ne":return[c.x2,c.y];case"nw":return[c.x,c.y];case"se":return[c.x2,c.y2];case"sw":return[c.x,c.y2]}}function getFixed(){if(!options.aspectRatio)return getRect();var xx,yy,w,h,aspect=options.aspectRatio,min_x=options.minSize[0]/xscale,max_x=options.maxSize[0]/xscale,max_y=options.maxSize[1]/yscale,rw=x2-x1,rh=y2-y1,rwa=Math.abs(rw),rha=Math.abs(rh),real_ratio=rwa/rha;return 0===max_x&&(max_x=10*boundx),0===max_y&&(max_y=10*boundy),aspect>real_ratio?(yy=y2,w=rha*aspect,xx=0>rw?x1-w:w+x1,0>xx?(xx=0,h=Math.abs((xx-x1)/aspect),yy=0>rh?y1-h:h+y1):xx>boundx&&(xx=boundx,h=Math.abs((xx-x1)/aspect),yy=0>rh?y1-h:h+y1)):(xx=x2,h=rwa/aspect,yy=0>rh?y1-h:y1+h,0>yy?(yy=0,w=Math.abs((yy-y1)*aspect),xx=0>rw?x1-w:w+x1):yy>boundy&&(yy=boundy,w=Math.abs(yy-y1)*aspect,xx=0>rw?x1-w:w+x1)),xx>x1?(min_x>xx-x1?xx=x1+min_x:xx-x1>max_x&&(xx=x1+max_x),yy=yy>y1?y1+(xx-x1)/aspect:y1-(xx-x1)/aspect):x1>xx&&(min_x>x1-xx?xx=x1-min_x:x1-xx>max_x&&(xx=x1-max_x),yy=yy>y1?y1+(x1-xx)/aspect:y1-(x1-xx)/aspect),0>xx?(x1-=xx,xx=0):xx>boundx&&(x1-=xx-boundx,xx=boundx),0>yy?(y1-=yy,yy=0):yy>boundy&&(y1-=yy-boundy,yy=boundy),makeObj(flipCoords(x1,y1,xx,yy))}function rebound(p){return p[0]<0&&(p[0]=0),p[1]<0&&(p[1]=0),p[0]>boundx&&(p[0]=boundx),p[1]>boundy&&(p[1]=boundy),[Math.round(p[0]),Math.round(p[1])]}function flipCoords(x1,y1,x2,y2){var xa=x1,xb=x2,ya=y1,yb=y2;return x1>x2&&(xa=x2,xb=x1),y1>y2&&(ya=y2,yb=y1),[xa,ya,xb,yb]}function getRect(){var delta,xsize=x2-x1,ysize=y2-y1;return xlimit&&Math.abs(xsize)>xlimit&&(x2=xsize>0?x1+xlimit:x1-xlimit),ylimit&&Math.abs(ysize)>ylimit&&(y2=ysize>0?y1+ylimit:y1-ylimit),ymin/yscale&&Math.abs(ysize)<ymin/yscale&&(y2=ysize>0?y1+ymin/yscale:y1-ymin/yscale),xmin/xscale&&Math.abs(xsize)<xmin/xscale&&(x2=xsize>0?x1+xmin/xscale:x1-xmin/xscale),0>x1&&(x2-=x1,x1-=x1),0>y1&&(y2-=y1,y1-=y1),0>x2&&(x1-=x2,x2-=x2),0>y2&&(y1-=y2,y2-=y2),x2>boundx&&(delta=x2-boundx,x1-=delta,x2-=delta),y2>boundy&&(delta=y2-boundy,y1-=delta,y2-=delta),x1>boundx&&(delta=x1-boundy,y2-=delta,y1-=delta),y1>boundy&&(delta=y1-boundy,y2-=delta,y1-=delta),makeObj(flipCoords(x1,y1,x2,y2))}function makeObj(a){return{x:a[0],y:a[1],x2:a[2],y2:a[3],w:a[2]-a[0],h:a[3]-a[1]}}var ox,oy,x1=0,y1=0,x2=0,y2=0;return{flipCoords:flipCoords,setPressed:setPressed,setCurrent:setCurrent,getOffset:getOffset,moveOffset:moveOffset,getCorner:getCorner,getFixed:getFixed}}(),Shade=function(){function resizeShades(w,h){shades.left.css({height:px(h)}),shades.right.css({height:px(h)})}function updateAuto(){return updateShade(Coords.getFixed())}function updateShade(c){shades.top.css({left:px(c.x),width:px(c.w),height:px(c.y)}),shades.bottom.css({top:px(c.y2),left:px(c.x),width:px(c.w),height:px(boundy-c.y2)}),shades.right.css({left:px(c.x2),width:px(boundx-c.x2)}),shades.left.css({width:px(c.x)})}function createShade(){return $("<div />").css({position:"absolute",backgroundColor:options.shadeColor||options.bgColor}).appendTo(holder)}function enableShade(){enabled||(enabled=!0,holder.insertBefore($img),updateAuto(),Selection.setBgOpacity(1,0,1),$img2.hide(),setBgColor(options.shadeColor||options.bgColor,1),Selection.isAwake()?setOpacity(options.bgOpacity,1):setOpacity(1,1))}function setBgColor(color,now){colorChangeMacro(getShades(),color,now)}function disableShade(){enabled&&(holder.remove(),$img2.show(),enabled=!1,Selection.isAwake()?Selection.setBgOpacity(options.bgOpacity,1,1):(Selection.setBgOpacity(1,1,1),Selection.disableHandles()),colorChangeMacro($div,0,1))}function setOpacity(opacity,now){enabled&&(options.bgFade&&!now?holder.animate({opacity:1-opacity},{queue:!1,duration:options.fadeTime}):holder.css({opacity:1-opacity}))}function refreshAll(){options.shade?enableShade():disableShade(),Selection.isAwake()&&setOpacity(options.bgOpacity)}function getShades(){return holder.children()}var enabled=!1,holder=$("<div />").css({position:"absolute",zIndex:240,opacity:0}),shades={top:createShade(),left:createShade().height(boundy),right:createShade().height(boundy),bottom:createShade()};return{update:updateAuto,updateRaw:updateShade,getShades:getShades,setBgColor:setBgColor,enable:enableShade,disable:disableShade,resize:resizeShades,refresh:refreshAll,opacity:setOpacity}}(),Selection=function(){function insertBorder(type){var jq=$("<div />").css({position:"absolute",opacity:options.borderOpacity}).addClass(cssClass(type));return $img_holder.append(jq),jq}function dragDiv(ord,zi){var jq=$("<div />").mousedown(createDragger(ord)).css({cursor:ord+"-resize",position:"absolute",zIndex:zi}).addClass("ord-"+ord);return Touch.support&&jq.bind("touchstart.jcrop",Touch.createDragger(ord)),$hdl_holder.append(jq),jq}function insertHandle(ord){var hs=options.handleSize,div=dragDiv(ord,hdep++).css({opacity:options.handleOpacity}).addClass(cssClass("handle"));return hs&&div.width(hs).height(hs),div}function insertDragbar(ord){return dragDiv(ord,hdep++).addClass("jcrop-dragbar")}function createDragbars(li){var i;for(i=0;i<li.length;i++)dragbar[li[i]]=insertDragbar(li[i])}function createBorders(li){var cl,i;for(i=0;i<li.length;i++){switch(li[i]){case"n":cl="hline";break;case"s":cl="hline bottom";break;case"e":cl="vline right";break;case"w":cl="vline"}borders[li[i]]=insertBorder(cl)}}function createHandles(li){var i;for(i=0;i<li.length;i++)handle[li[i]]=insertHandle(li[i])}function moveto(x,y){options.shade||$img2.css({top:px(-y),left:px(-x)}),$sel.css({top:px(y),left:px(x)})}function resize(w,h){$sel.width(Math.round(w)).height(Math.round(h))}function refresh(){var c=Coords.getFixed();Coords.setPressed([c.x,c.y]),Coords.setCurrent([c.x2,c.y2]),updateVisible()}function updateVisible(select){return awake?update(select):void 0}function update(select){var c=Coords.getFixed();resize(c.w,c.h),moveto(c.x,c.y),options.shade&&Shade.updateRaw(c),awake||show(),select?options.onSelect.call(api,unscale(c)):options.onChange.call(api,unscale(c))}function setBgOpacity(opacity,force,now){(awake||force)&&(options.bgFade&&!now?$img.animate({opacity:opacity},{queue:!1,duration:options.fadeTime}):$img.css("opacity",opacity))}function show(){$sel.show(),options.shade?Shade.opacity(bgopacity):setBgOpacity(bgopacity,!0),awake=!0}function release(){disableHandles(),$sel.hide(),options.shade?Shade.opacity(1):setBgOpacity(1),awake=!1,options.onRelease.call(api)}function showHandles(){seehandles&&$hdl_holder.show()}function enableHandles(){return seehandles=!0,options.allowResize?($hdl_holder.show(),!0):void 0}function disableHandles(){seehandles=!1,$hdl_holder.hide()}function animMode(v){v?(animating=!0,disableHandles()):(animating=!1,enableHandles())}function done(){animMode(!1),refresh()}var awake,hdep=370,borders={},handle={},dragbar={},seehandles=!1;options.dragEdges&&$.isArray(options.createDragbars)&&createDragbars(options.createDragbars),$.isArray(options.createHandles)&&createHandles(options.createHandles),options.drawBorders&&$.isArray(options.createBorders)&&createBorders(options.createBorders),$(document).bind("touchstart.jcrop-ios",function(e){$(e.currentTarget).hasClass("jcrop-tracker")&&e.stopPropagation()});var $track=newTracker().mousedown(createDragger("move")).css({cursor:"move",position:"absolute",zIndex:360});return Touch.support&&$track.bind("touchstart.jcrop",Touch.createDragger("move")),$img_holder.append($track),disableHandles(),{updateVisible:updateVisible,update:update,release:release,refresh:refresh,isAwake:function(){return awake},setCursor:function(cursor){$track.css("cursor",cursor)},enableHandles:enableHandles,enableOnly:function(){seehandles=!0},showHandles:showHandles,disableHandles:disableHandles,animMode:animMode,setBgOpacity:setBgOpacity,done:done}}(),Tracker=function(){function toFront(touch){$trk.css({zIndex:450}),touch?$(document).bind("touchmove.jcrop",trackTouchMove).bind("touchend.jcrop",trackTouchEnd):trackDoc&&$(document).bind("mousemove.jcrop",trackMove).bind("mouseup.jcrop",trackUp)}function toBack(){$trk.css({zIndex:290}),$(document).unbind(".jcrop")}function trackMove(e){return onMove(mouseAbs(e)),!1}function trackUp(e){return e.preventDefault(),e.stopPropagation(),btndown&&(btndown=!1,onDone(mouseAbs(e)),Selection.isAwake()&&options.onSelect.call(api,unscale(Coords.getFixed())),toBack(),onMove=function(){},onDone=function(){}),!1}function activateHandlers(move,done,touch){return btndown=!0,onMove=move,onDone=done,toFront(touch),!1}function trackTouchMove(e){return onMove(mouseAbs(Touch.cfilter(e))),!1}function trackTouchEnd(e){return trackUp(Touch.cfilter(e))}function setCursor(t){$trk.css("cursor",t)}var onMove=function(){},onDone=function(){},trackDoc=options.trackDocument;return trackDoc||$trk.mousemove(trackMove).mouseup(trackUp).mouseout(trackUp),$img.before($trk),{activateHandlers:activateHandlers,setCursor:setCursor}}(),KeyManager=function(){function watchKeys(){options.keySupport&&($keymgr.show(),$keymgr.focus())}function onBlur(){$keymgr.hide()}function doNudge(e,x,y){options.allowMove&&(Coords.moveOffset([x,y]),Selection.updateVisible(!0)),e.preventDefault(),e.stopPropagation()}function parseKey(e){if(e.ctrlKey||e.metaKey)return!0;shift_down=e.shiftKey?!0:!1;var nudge=shift_down?10:1;switch(e.keyCode){case 37:doNudge(e,-nudge,0);break;case 39:doNudge(e,nudge,0);break;case 38:doNudge(e,0,-nudge);break;case 40:doNudge(e,0,nudge);break;case 27:options.allowSelect&&Selection.release();break;case 9:return!0}return!1}var $keymgr=$('<input type="radio" />').css({position:"fixed",left:"-120px",width:"12px"}).addClass("jcrop-keymgr"),$keywrap=$("<div />").css({position:"absolute",overflow:"hidden"}).append($keymgr);return options.keySupport&&($keymgr.keydown(parseKey).blur(onBlur),ie6mode||!options.fixedSupport?($keymgr.css({position:"absolute",left:"-20px"}),$keywrap.append($keymgr).insertBefore($img)):$keymgr.insertBefore($img)),{watchKeys:watchKeys}}();Touch.support&&$trk.bind("touchstart.jcrop",Touch.newSelection),$hdl_holder.hide(),interfaceUpdate(!0);var api={setImage:setImage,animateTo:animateTo,setSelect:setSelect,setOptions:setOptionsNew,tellSelect:tellSelect,tellScaled:tellScaled,setClass:setClass,disable:disableCrop,enable:enableCrop,cancel:cancelCrop,release:Selection.release,destroy:destroy,focus:KeyManager.watchKeys,getBounds:function(){return[boundx*xscale,boundy*yscale]},getWidgetSize:function(){return[boundx,boundy]},getScaleFactor:function(){return[xscale,yscale]},getOptions:function(){return options},ui:{holder:$div,selection:$sel}};return is_msie&&$div.bind("selectstart",function(){return!1}),$origimg.data("Jcrop",api),api},$.fn.Jcrop=function(options,callback){var api;return this.each(function(){if($(this).data("Jcrop")){if("api"===options)return $(this).data("Jcrop");$(this).data("Jcrop").setOptions(options)}else"IMG"==this.tagName?$.Jcrop.Loader(this,function(){$(this).css({display:"block",visibility:"hidden"}),api=$.Jcrop(this,options),$.isFunction(callback)&&callback.call(api)}):($(this).css({display:"block",visibility:"hidden"}),api=$.Jcrop(this,options),$.isFunction(callback)&&callback.call(api))}),this},$.Jcrop.Loader=function(imgobj,success,error){function completeCheck(){img.complete?($img.unbind(".jcloader"),$.isFunction(success)&&success.call(img)):window.setTimeout(completeCheck,50)}var $img=$(imgobj),img=$img[0];$img.bind("load.jcloader",completeCheck).bind("error.jcloader",function(){$img.unbind(".jcloader"),$.isFunction(error)&&error.call(img)}),img.complete&&$.isFunction(success)&&($img.unbind(".jcloader"),success.call(img))},$.Jcrop.defaults={allowSelect:!0,allowMove:!0,allowResize:!0,trackDocument:!0,baseClass:"jcrop",addClass:null,bgColor:"black",bgOpacity:.6,bgFade:!1,borderOpacity:.4,handleOpacity:.5,handleSize:null,aspectRatio:0,keySupport:!0,createHandles:["n","s","e","w","nw","ne","se","sw"],createDragbars:["n","s","e","w"],createBorders:["n","s","e","w"],drawBorders:!0,dragEdges:!0,fixedSupport:!0,touchSupport:null,shade:null,boxWidth:0,boxHeight:0,boundary:2,fadeTime:400,animationDelay:20,swingSpeed:3,minSelect:[0,0],maxSize:[0,0],minSize:[0,0],onChange:function(){},onSelect:function(){},onDblClick:function(){},onRelease:function(){}}}(jQuery);
\ No newline at end of file diff --git a/app/assets/javascripts/jquery.js b/app/assets/javascripts/jquery.js deleted file mode 100644 index 16ad06c5a..000000000 --- a/app/assets/javascripts/jquery.js +++ /dev/null @@ -1,4 +0,0 @@ -/*! jQuery v1.7.2 jquery.com | jquery.org/license */ -(function(a,b){function cy(a){return f.isWindow(a)?a:a.nodeType===9?a.defaultView||a.parentWindow:!1}function cu(a){if(!cj[a]){var b=c.body,d=f("<"+a+">").appendTo(b),e=d.css("display");d.remove();if(e==="none"||e===""){ck||(ck=c.createElement("iframe"),ck.frameBorder=ck.width=ck.height=0),b.appendChild(ck);if(!cl||!ck.createElement)cl=(ck.contentWindow||ck.contentDocument).document,cl.write((f.support.boxModel?"<!doctype html>":"")+"<html><body>"),cl.close();d=cl.createElement(a),cl.body.appendChild(d),e=f.css(d,"display"),b.removeChild(ck)}cj[a]=e}return cj[a]}function ct(a,b){var c={};f.each(cp.concat.apply([],cp.slice(0,b)),function(){c[this]=a});return c}function cs(){cq=b}function cr(){setTimeout(cs,0);return cq=f.now()}function ci(){try{return new a.ActiveXObject("Microsoft.XMLHTTP")}catch(b){}}function ch(){try{return new a.XMLHttpRequest}catch(b){}}function cb(a,c){a.dataFilter&&(c=a.dataFilter(c,a.dataType));var d=a.dataTypes,e={},g,h,i=d.length,j,k=d[0],l,m,n,o,p;for(g=1;g<i;g++){if(g===1)for(h in a.converters)typeof h=="string"&&(e[h.toLowerCase()]=a.converters[h]);l=k,k=d[g];if(k==="*")k=l;else if(l!=="*"&&l!==k){m=l+" "+k,n=e[m]||e["* "+k];if(!n){p=b;for(o in e){j=o.split(" ");if(j[0]===l||j[0]==="*"){p=e[j[1]+" "+k];if(p){o=e[o],o===!0?n=p:p===!0&&(n=o);break}}}}!n&&!p&&f.error("No conversion from "+m.replace(" "," to ")),n!==!0&&(c=n?n(c):p(o(c)))}}return c}function ca(a,c,d){var e=a.contents,f=a.dataTypes,g=a.responseFields,h,i,j,k;for(i in g)i in d&&(c[g[i]]=d[i]);while(f[0]==="*")f.shift(),h===b&&(h=a.mimeType||c.getResponseHeader("content-type"));if(h)for(i in e)if(e[i]&&e[i].test(h)){f.unshift(i);break}if(f[0]in d)j=f[0];else{for(i in d){if(!f[0]||a.converters[i+" "+f[0]]){j=i;break}k||(k=i)}j=j||k}if(j){j!==f[0]&&f.unshift(j);return d[j]}}function b_(a,b,c,d){if(f.isArray(b))f.each(b,function(b,e){c||bD.test(a)?d(a,e):b_(a+"["+(typeof e=="object"?b:"")+"]",e,c,d)});else if(!c&&f.type(b)==="object")for(var e in b)b_(a+"["+e+"]",b[e],c,d);else d(a,b)}function b$(a,c){var d,e,g=f.ajaxSettings.flatOptions||{};for(d in c)c[d]!==b&&((g[d]?a:e||(e={}))[d]=c[d]);e&&f.extend(!0,a,e)}function bZ(a,c,d,e,f,g){f=f||c.dataTypes[0],g=g||{},g[f]=!0;var h=a[f],i=0,j=h?h.length:0,k=a===bS,l;for(;i<j&&(k||!l);i++)l=h[i](c,d,e),typeof l=="string"&&(!k||g[l]?l=b:(c.dataTypes.unshift(l),l=bZ(a,c,d,e,l,g)));(k||!l)&&!g["*"]&&(l=bZ(a,c,d,e,"*",g));return l}function bY(a){return function(b,c){typeof b!="string"&&(c=b,b="*");if(f.isFunction(c)){var d=b.toLowerCase().split(bO),e=0,g=d.length,h,i,j;for(;e<g;e++)h=d[e],j=/^\+/.test(h),j&&(h=h.substr(1)||"*"),i=a[h]=a[h]||[],i[j?"unshift":"push"](c)}}}function bB(a,b,c){var d=b==="width"?a.offsetWidth:a.offsetHeight,e=b==="width"?1:0,g=4;if(d>0){if(c!=="border")for(;e<g;e+=2)c||(d-=parseFloat(f.css(a,"padding"+bx[e]))||0),c==="margin"?d+=parseFloat(f.css(a,c+bx[e]))||0:d-=parseFloat(f.css(a,"border"+bx[e]+"Width"))||0;return d+"px"}d=by(a,b);if(d<0||d==null)d=a.style[b];if(bt.test(d))return d;d=parseFloat(d)||0;if(c)for(;e<g;e+=2)d+=parseFloat(f.css(a,"padding"+bx[e]))||0,c!=="padding"&&(d+=parseFloat(f.css(a,"border"+bx[e]+"Width"))||0),c==="margin"&&(d+=parseFloat(f.css(a,c+bx[e]))||0);return d+"px"}function bo(a){var b=c.createElement("div");bh.appendChild(b),b.innerHTML=a.outerHTML;return b.firstChild}function bn(a){var b=(a.nodeName||"").toLowerCase();b==="input"?bm(a):b!=="script"&&typeof a.getElementsByTagName!="undefined"&&f.grep(a.getElementsByTagName("input"),bm)}function bm(a){if(a.type==="checkbox"||a.type==="radio")a.defaultChecked=a.checked}function bl(a){return typeof a.getElementsByTagName!="undefined"?a.getElementsByTagName("*"):typeof a.querySelectorAll!="undefined"?a.querySelectorAll("*"):[]}function bk(a,b){var c;b.nodeType===1&&(b.clearAttributes&&b.clearAttributes(),b.mergeAttributes&&b.mergeAttributes(a),c=b.nodeName.toLowerCase(),c==="object"?b.outerHTML=a.outerHTML:c!=="input"||a.type!=="checkbox"&&a.type!=="radio"?c==="option"?b.selected=a.defaultSelected:c==="input"||c==="textarea"?b.defaultValue=a.defaultValue:c==="script"&&b.text!==a.text&&(b.text=a.text):(a.checked&&(b.defaultChecked=b.checked=a.checked),b.value!==a.value&&(b.value=a.value)),b.removeAttribute(f.expando),b.removeAttribute("_submit_attached"),b.removeAttribute("_change_attached"))}function bj(a,b){if(b.nodeType===1&&!!f.hasData(a)){var c,d,e,g=f._data(a),h=f._data(b,g),i=g.events;if(i){delete h.handle,h.events={};for(c in i)for(d=0,e=i[c].length;d<e;d++)f.event.add(b,c,i[c][d])}h.data&&(h.data=f.extend({},h.data))}}function bi(a,b){return f.nodeName(a,"table")?a.getElementsByTagName("tbody")[0]||a.appendChild(a.ownerDocument.createElement("tbody")):a}function U(a){var b=V.split("|"),c=a.createDocumentFragment();if(c.createElement)while(b.length)c.createElement(b.pop());return c}function T(a,b,c){b=b||0;if(f.isFunction(b))return f.grep(a,function(a,d){var e=!!b.call(a,d,a);return e===c});if(b.nodeType)return f.grep(a,function(a,d){return a===b===c});if(typeof b=="string"){var d=f.grep(a,function(a){return a.nodeType===1});if(O.test(b))return f.filter(b,d,!c);b=f.filter(b,d)}return f.grep(a,function(a,d){return f.inArray(a,b)>=0===c})}function S(a){return!a||!a.parentNode||a.parentNode.nodeType===11}function K(){return!0}function J(){return!1}function n(a,b,c){var d=b+"defer",e=b+"queue",g=b+"mark",h=f._data(a,d);h&&(c==="queue"||!f._data(a,e))&&(c==="mark"||!f._data(a,g))&&setTimeout(function(){!f._data(a,e)&&!f._data(a,g)&&(f.removeData(a,d,!0),h.fire())},0)}function m(a){for(var b in a){if(b==="data"&&f.isEmptyObject(a[b]))continue;if(b!=="toJSON")return!1}return!0}function l(a,c,d){if(d===b&&a.nodeType===1){var e="data-"+c.replace(k,"-$1").toLowerCase();d=a.getAttribute(e);if(typeof d=="string"){try{d=d==="true"?!0:d==="false"?!1:d==="null"?null:f.isNumeric(d)?+d:j.test(d)?f.parseJSON(d):d}catch(g){}f.data(a,c,d)}else d=b}return d}function h(a){var b=g[a]={},c,d;a=a.split(/\s+/);for(c=0,d=a.length;c<d;c++)b[a[c]]=!0;return b}var c=a.document,d=a.navigator,e=a.location,f=function(){function J(){if(!e.isReady){try{c.documentElement.doScroll("left")}catch(a){setTimeout(J,1);return}e.ready()}}var e=function(a,b){return new e.fn.init(a,b,h)},f=a.jQuery,g=a.$,h,i=/^(?:[^#<]*(<[\w\W]+>)[^>]*$|#([\w\-]*)$)/,j=/\S/,k=/^\s+/,l=/\s+$/,m=/^<(\w+)\s*\/?>(?:<\/\1>)?$/,n=/^[\],:{}\s]*$/,o=/\\(?:["\\\/bfnrt]|u[0-9a-fA-F]{4})/g,p=/"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g,q=/(?:^|:|,)(?:\s*\[)+/g,r=/(webkit)[ \/]([\w.]+)/,s=/(opera)(?:.*version)?[ \/]([\w.]+)/,t=/(msie) ([\w.]+)/,u=/(mozilla)(?:.*? rv:([\w.]+))?/,v=/-([a-z]|[0-9])/ig,w=/^-ms-/,x=function(a,b){return(b+"").toUpperCase()},y=d.userAgent,z,A,B,C=Object.prototype.toString,D=Object.prototype.hasOwnProperty,E=Array.prototype.push,F=Array.prototype.slice,G=String.prototype.trim,H=Array.prototype.indexOf,I={};e.fn=e.prototype={constructor:e,init:function(a,d,f){var g,h,j,k;if(!a)return this;if(a.nodeType){this.context=this[0]=a,this.length=1;return this}if(a==="body"&&!d&&c.body){this.context=c,this[0]=c.body,this.selector=a,this.length=1;return this}if(typeof a=="string"){a.charAt(0)!=="<"||a.charAt(a.length-1)!==">"||a.length<3?g=i.exec(a):g=[null,a,null];if(g&&(g[1]||!d)){if(g[1]){d=d instanceof e?d[0]:d,k=d?d.ownerDocument||d:c,j=m.exec(a),j?e.isPlainObject(d)?(a=[c.createElement(j[1])],e.fn.attr.call(a,d,!0)):a=[k.createElement(j[1])]:(j=e.buildFragment([g[1]],[k]),a=(j.cacheable?e.clone(j.fragment):j.fragment).childNodes);return e.merge(this,a)}h=c.getElementById(g[2]);if(h&&h.parentNode){if(h.id!==g[2])return f.find(a);this.length=1,this[0]=h}this.context=c,this.selector=a;return this}return!d||d.jquery?(d||f).find(a):this.constructor(d).find(a)}if(e.isFunction(a))return f.ready(a);a.selector!==b&&(this.selector=a.selector,this.context=a.context);return e.makeArray(a,this)},selector:"",jquery:"1.7.2",length:0,size:function(){return this.length},toArray:function(){return F.call(this,0)},get:function(a){return a==null?this.toArray():a<0?this[this.length+a]:this[a]},pushStack:function(a,b,c){var d=this.constructor();e.isArray(a)?E.apply(d,a):e.merge(d,a),d.prevObject=this,d.context=this.context,b==="find"?d.selector=this.selector+(this.selector?" ":"")+c:b&&(d.selector=this.selector+"."+b+"("+c+")");return d},each:function(a,b){return e.each(this,a,b)},ready:function(a){e.bindReady(),A.add(a);return this},eq:function(a){a=+a;return a===-1?this.slice(a):this.slice(a,a+1)},first:function(){return this.eq(0)},last:function(){return this.eq(-1)},slice:function(){return this.pushStack(F.apply(this,arguments),"slice",F.call(arguments).join(","))},map:function(a){return this.pushStack(e.map(this,function(b,c){return a.call(b,c,b)}))},end:function(){return this.prevObject||this.constructor(null)},push:E,sort:[].sort,splice:[].splice},e.fn.init.prototype=e.fn,e.extend=e.fn.extend=function(){var a,c,d,f,g,h,i=arguments[0]||{},j=1,k=arguments.length,l=!1;typeof i=="boolean"&&(l=i,i=arguments[1]||{},j=2),typeof i!="object"&&!e.isFunction(i)&&(i={}),k===j&&(i=this,--j);for(;j<k;j++)if((a=arguments[j])!=null)for(c in a){d=i[c],f=a[c];if(i===f)continue;l&&f&&(e.isPlainObject(f)||(g=e.isArray(f)))?(g?(g=!1,h=d&&e.isArray(d)?d:[]):h=d&&e.isPlainObject(d)?d:{},i[c]=e.extend(l,h,f)):f!==b&&(i[c]=f)}return i},e.extend({noConflict:function(b){a.$===e&&(a.$=g),b&&a.jQuery===e&&(a.jQuery=f);return e},isReady:!1,readyWait:1,holdReady:function(a){a?e.readyWait++:e.ready(!0)},ready:function(a){if(a===!0&&!--e.readyWait||a!==!0&&!e.isReady){if(!c.body)return setTimeout(e.ready,1);e.isReady=!0;if(a!==!0&&--e.readyWait>0)return;A.fireWith(c,[e]),e.fn.trigger&&e(c).trigger("ready").off("ready")}},bindReady:function(){if(!A){A=e.Callbacks("once memory");if(c.readyState==="complete")return setTimeout(e.ready,1);if(c.addEventListener)c.addEventListener("DOMContentLoaded",B,!1),a.addEventListener("load",e.ready,!1);else if(c.attachEvent){c.attachEvent("onreadystatechange",B),a.attachEvent("onload",e.ready);var b=!1;try{b=a.frameElement==null}catch(d){}c.documentElement.doScroll&&b&&J()}}},isFunction:function(a){return e.type(a)==="function"},isArray:Array.isArray||function(a){return e.type(a)==="array"},isWindow:function(a){return a!=null&&a==a.window},isNumeric:function(a){return!isNaN(parseFloat(a))&&isFinite(a)},type:function(a){return a==null?String(a):I[C.call(a)]||"object"},isPlainObject:function(a){if(!a||e.type(a)!=="object"||a.nodeType||e.isWindow(a))return!1;try{if(a.constructor&&!D.call(a,"constructor")&&!D.call(a.constructor.prototype,"isPrototypeOf"))return!1}catch(c){return!1}var d;for(d in a);return d===b||D.call(a,d)},isEmptyObject:function(a){for(var b in a)return!1;return!0},error:function(a){throw new Error(a)},parseJSON:function(b){if(typeof b!="string"||!b)return null;b=e.trim(b);if(a.JSON&&a.JSON.parse)return a.JSON.parse(b);if(n.test(b.replace(o,"@").replace(p,"]").replace(q,"")))return(new Function("return "+b))();e.error("Invalid JSON: "+b)},parseXML:function(c){if(typeof c!="string"||!c)return null;var d,f;try{a.DOMParser?(f=new DOMParser,d=f.parseFromString(c,"text/xml")):(d=new ActiveXObject("Microsoft.XMLDOM"),d.async="false",d.loadXML(c))}catch(g){d=b}(!d||!d.documentElement||d.getElementsByTagName("parsererror").length)&&e.error("Invalid XML: "+c);return d},noop:function(){},globalEval:function(b){b&&j.test(b)&&(a.execScript||function(b){a.eval.call(a,b)})(b)},camelCase:function(a){return a.replace(w,"ms-").replace(v,x)},nodeName:function(a,b){return a.nodeName&&a.nodeName.toUpperCase()===b.toUpperCase()},each:function(a,c,d){var f,g=0,h=a.length,i=h===b||e.isFunction(a);if(d){if(i){for(f in a)if(c.apply(a[f],d)===!1)break}else for(;g<h;)if(c.apply(a[g++],d)===!1)break}else if(i){for(f in a)if(c.call(a[f],f,a[f])===!1)break}else for(;g<h;)if(c.call(a[g],g,a[g++])===!1)break;return a},trim:G?function(a){return a==null?"":G.call(a)}:function(a){return a==null?"":(a+"").replace(k,"").replace(l,"")},makeArray:function(a,b){var c=b||[];if(a!=null){var d=e.type(a);a.length==null||d==="string"||d==="function"||d==="regexp"||e.isWindow(a)?E.call(c,a):e.merge(c,a)}return c},inArray:function(a,b,c){var d;if(b){if(H)return H.call(b,a,c);d=b.length,c=c?c<0?Math.max(0,d+c):c:0;for(;c<d;c++)if(c in b&&b[c]===a)return c}return-1},merge:function(a,c){var d=a.length,e=0;if(typeof c.length=="number")for(var f=c.length;e<f;e++)a[d++]=c[e];else while(c[e]!==b)a[d++]=c[e++];a.length=d;return a},grep:function(a,b,c){var d=[],e;c=!!c;for(var f=0,g=a.length;f<g;f++)e=!!b(a[f],f),c!==e&&d.push(a[f]);return d},map:function(a,c,d){var f,g,h=[],i=0,j=a.length,k=a instanceof e||j!==b&&typeof j=="number"&&(j>0&&a[0]&&a[j-1]||j===0||e.isArray(a));if(k)for(;i<j;i++)f=c(a[i],i,d),f!=null&&(h[h.length]=f);else for(g in a)f=c(a[g],g,d),f!=null&&(h[h.length]=f);return h.concat.apply([],h)},guid:1,proxy:function(a,c){if(typeof c=="string"){var d=a[c];c=a,a=d}if(!e.isFunction(a))return b;var f=F.call(arguments,2),g=function(){return a.apply(c,f.concat(F.call(arguments)))};g.guid=a.guid=a.guid||g.guid||e.guid++;return g},access:function(a,c,d,f,g,h,i){var j,k=d==null,l=0,m=a.length;if(d&&typeof d=="object"){for(l in d)e.access(a,c,l,d[l],1,h,f);g=1}else if(f!==b){j=i===b&&e.isFunction(f),k&&(j?(j=c,c=function(a,b,c){return j.call(e(a),c)}):(c.call(a,f),c=null));if(c)for(;l<m;l++)c(a[l],d,j?f.call(a[l],l,c(a[l],d)):f,i);g=1}return g?a:k?c.call(a):m?c(a[0],d):h},now:function(){return(new Date).getTime()},uaMatch:function(a){a=a.toLowerCase();var b=r.exec(a)||s.exec(a)||t.exec(a)||a.indexOf("compatible")<0&&u.exec(a)||[];return{browser:b[1]||"",version:b[2]||"0"}},sub:function(){function a(b,c){return new a.fn.init(b,c)}e.extend(!0,a,this),a.superclass=this,a.fn=a.prototype=this(),a.fn.constructor=a,a.sub=this.sub,a.fn.init=function(d,f){f&&f instanceof e&&!(f instanceof a)&&(f=a(f));return e.fn.init.call(this,d,f,b)},a.fn.init.prototype=a.fn;var b=a(c);return a},browser:{}}),e.each("Boolean Number String Function Array Date RegExp Object".split(" "),function(a,b){I["[object "+b+"]"]=b.toLowerCase()}),z=e.uaMatch(y),z.browser&&(e.browser[z.browser]=!0,e.browser.version=z.version),e.browser.webkit&&(e.browser.safari=!0),j.test(" ")&&(k=/^[\s\xA0]+/,l=/[\s\xA0]+$/),h=e(c),c.addEventListener?B=function(){c.removeEventListener("DOMContentLoaded",B,!1),e.ready()}:c.attachEvent&&(B=function(){c.readyState==="complete"&&(c.detachEvent("onreadystatechange",B),e.ready())});return e}(),g={};f.Callbacks=function(a){a=a?g[a]||h(a):{};var c=[],d=[],e,i,j,k,l,m,n=function(b){var d,e,g,h,i;for(d=0,e=b.length;d<e;d++)g=b[d],h=f.type(g),h==="array"?n(g):h==="function"&&(!a.unique||!p.has(g))&&c.push(g)},o=function(b,f){f=f||[],e=!a.memory||[b,f],i=!0,j=!0,m=k||0,k=0,l=c.length;for(;c&&m<l;m++)if(c[m].apply(b,f)===!1&&a.stopOnFalse){e=!0;break}j=!1,c&&(a.once?e===!0?p.disable():c=[]:d&&d.length&&(e=d.shift(),p.fireWith(e[0],e[1])))},p={add:function(){if(c){var a=c.length;n(arguments),j?l=c.length:e&&e!==!0&&(k=a,o(e[0],e[1]))}return this},remove:function(){if(c){var b=arguments,d=0,e=b.length;for(;d<e;d++)for(var f=0;f<c.length;f++)if(b[d]===c[f]){j&&f<=l&&(l--,f<=m&&m--),c.splice(f--,1);if(a.unique)break}}return this},has:function(a){if(c){var b=0,d=c.length;for(;b<d;b++)if(a===c[b])return!0}return!1},empty:function(){c=[];return this},disable:function(){c=d=e=b;return this},disabled:function(){return!c},lock:function(){d=b,(!e||e===!0)&&p.disable();return this},locked:function(){return!d},fireWith:function(b,c){d&&(j?a.once||d.push([b,c]):(!a.once||!e)&&o(b,c));return this},fire:function(){p.fireWith(this,arguments);return this},fired:function(){return!!i}};return p};var i=[].slice;f.extend({Deferred:function(a){var b=f.Callbacks("once memory"),c=f.Callbacks("once memory"),d=f.Callbacks("memory"),e="pending",g={resolve:b,reject:c,notify:d},h={done:b.add,fail:c.add,progress:d.add,state:function(){return e},isResolved:b.fired,isRejected:c.fired,then:function(a,b,c){i.done(a).fail(b).progress(c);return this},always:function(){i.done.apply(i,arguments).fail.apply(i,arguments);return this},pipe:function(a,b,c){return f.Deferred(function(d){f.each({done:[a,"resolve"],fail:[b,"reject"],progress:[c,"notify"]},function(a,b){var c=b[0],e=b[1],g;f.isFunction(c)?i[a](function(){g=c.apply(this,arguments),g&&f.isFunction(g.promise)?g.promise().then(d.resolve,d.reject,d.notify):d[e+"With"](this===i?d:this,[g])}):i[a](d[e])})}).promise()},promise:function(a){if(a==null)a=h;else for(var b in h)a[b]=h[b];return a}},i=h.promise({}),j;for(j in g)i[j]=g[j].fire,i[j+"With"]=g[j].fireWith;i.done(function(){e="resolved"},c.disable,d.lock).fail(function(){e="rejected"},b.disable,d.lock),a&&a.call(i,i);return i},when:function(a){function m(a){return function(b){e[a]=arguments.length>1?i.call(arguments,0):b,j.notifyWith(k,e)}}function l(a){return function(c){b[a]=arguments.length>1?i.call(arguments,0):c,--g||j.resolveWith(j,b)}}var b=i.call(arguments,0),c=0,d=b.length,e=Array(d),g=d,h=d,j=d<=1&&a&&f.isFunction(a.promise)?a:f.Deferred(),k=j.promise();if(d>1){for(;c<d;c++)b[c]&&b[c].promise&&f.isFunction(b[c].promise)?b[c].promise().then(l(c),j.reject,m(c)):--g;g||j.resolveWith(j,b)}else j!==a&&j.resolveWith(j,d?[a]:[]);return k}}),f.support=function(){var b,d,e,g,h,i,j,k,l,m,n,o,p=c.createElement("div"),q=c.documentElement;p.setAttribute("className","t"),p.innerHTML=" <link/><table></table><a href='/a' style='top:1px;float:left;opacity:.55;'>a</a><input type='checkbox'/>",d=p.getElementsByTagName("*"),e=p.getElementsByTagName("a")[0];if(!d||!d.length||!e)return{};g=c.createElement("select"),h=g.appendChild(c.createElement("option")),i=p.getElementsByTagName("input")[0],b={leadingWhitespace:p.firstChild.nodeType===3,tbody:!p.getElementsByTagName("tbody").length,htmlSerialize:!!p.getElementsByTagName("link").length,style:/top/.test(e.getAttribute("style")),hrefNormalized:e.getAttribute("href")==="/a",opacity:/^0.55/.test(e.style.opacity),cssFloat:!!e.style.cssFloat,checkOn:i.value==="on",optSelected:h.selected,getSetAttribute:p.className!=="t",enctype:!!c.createElement("form").enctype,html5Clone:c.createElement("nav").cloneNode(!0).outerHTML!=="<:nav></:nav>",submitBubbles:!0,changeBubbles:!0,focusinBubbles:!1,deleteExpando:!0,noCloneEvent:!0,inlineBlockNeedsLayout:!1,shrinkWrapBlocks:!1,reliableMarginRight:!0,pixelMargin:!0},f.boxModel=b.boxModel=c.compatMode==="CSS1Compat",i.checked=!0,b.noCloneChecked=i.cloneNode(!0).checked,g.disabled=!0,b.optDisabled=!h.disabled;try{delete p.test}catch(r){b.deleteExpando=!1}!p.addEventListener&&p.attachEvent&&p.fireEvent&&(p.attachEvent("onclick",function(){b.noCloneEvent=!1}),p.cloneNode(!0).fireEvent("onclick")),i=c.createElement("input"),i.value="t",i.setAttribute("type","radio"),b.radioValue=i.value==="t",i.setAttribute("checked","checked"),i.setAttribute("name","t"),p.appendChild(i),j=c.createDocumentFragment(),j.appendChild(p.lastChild),b.checkClone=j.cloneNode(!0).cloneNode(!0).lastChild.checked,b.appendChecked=i.checked,j.removeChild(i),j.appendChild(p);if(p.attachEvent)for(n in{submit:1,change:1,focusin:1})m="on"+n,o=m in p,o||(p.setAttribute(m,"return;"),o=typeof p[m]=="function"),b[n+"Bubbles"]=o;j.removeChild(p),j=g=h=p=i=null,f(function(){var d,e,g,h,i,j,l,m,n,q,r,s,t,u=c.getElementsByTagName("body")[0];!u||(m=1,t="padding:0;margin:0;border:",r="position:absolute;top:0;left:0;width:1px;height:1px;",s=t+"0;visibility:hidden;",n="style='"+r+t+"5px solid #000;",q="<div "+n+"display:block;'><div style='"+t+"0;display:block;overflow:hidden;'></div></div>"+"<table "+n+"' cellpadding='0' cellspacing='0'>"+"<tr><td></td></tr></table>",d=c.createElement("div"),d.style.cssText=s+"width:0;height:0;position:static;top:0;margin-top:"+m+"px",u.insertBefore(d,u.firstChild),p=c.createElement("div"),d.appendChild(p),p.innerHTML="<table><tr><td style='"+t+"0;display:none'></td><td>t</td></tr></table>",k=p.getElementsByTagName("td"),o=k[0].offsetHeight===0,k[0].style.display="",k[1].style.display="none",b.reliableHiddenOffsets=o&&k[0].offsetHeight===0,a.getComputedStyle&&(p.innerHTML="",l=c.createElement("div"),l.style.width="0",l.style.marginRight="0",p.style.width="2px",p.appendChild(l),b.reliableMarginRight=(parseInt((a.getComputedStyle(l,null)||{marginRight:0}).marginRight,10)||0)===0),typeof p.style.zoom!="undefined"&&(p.innerHTML="",p.style.width=p.style.padding="1px",p.style.border=0,p.style.overflow="hidden",p.style.display="inline",p.style.zoom=1,b.inlineBlockNeedsLayout=p.offsetWidth===3,p.style.display="block",p.style.overflow="visible",p.innerHTML="<div style='width:5px;'></div>",b.shrinkWrapBlocks=p.offsetWidth!==3),p.style.cssText=r+s,p.innerHTML=q,e=p.firstChild,g=e.firstChild,i=e.nextSibling.firstChild.firstChild,j={doesNotAddBorder:g.offsetTop!==5,doesAddBorderForTableAndCells:i.offsetTop===5},g.style.position="fixed",g.style.top="20px",j.fixedPosition=g.offsetTop===20||g.offsetTop===15,g.style.position=g.style.top="",e.style.overflow="hidden",e.style.position="relative",j.subtractsBorderForOverflowNotVisible=g.offsetTop===-5,j.doesNotIncludeMarginInBodyOffset=u.offsetTop!==m,a.getComputedStyle&&(p.style.marginTop="1%",b.pixelMargin=(a.getComputedStyle(p,null)||{marginTop:0}).marginTop!=="1%"),typeof d.style.zoom!="undefined"&&(d.style.zoom=1),u.removeChild(d),l=p=d=null,f.extend(b,j))});return b}();var j=/^(?:\{.*\}|\[.*\])$/,k=/([A-Z])/g;f.extend({cache:{},uuid:0,expando:"jQuery"+(f.fn.jquery+Math.random()).replace(/\D/g,""),noData:{embed:!0,object:"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000",applet:!0},hasData:function(a){a=a.nodeType?f.cache[a[f.expando]]:a[f.expando];return!!a&&!m(a)},data:function(a,c,d,e){if(!!f.acceptData(a)){var g,h,i,j=f.expando,k=typeof c=="string",l=a.nodeType,m=l?f.cache:a,n=l?a[j]:a[j]&&j,o=c==="events";if((!n||!m[n]||!o&&!e&&!m[n].data)&&k&&d===b)return;n||(l?a[j]=n=++f.uuid:n=j),m[n]||(m[n]={},l||(m[n].toJSON=f.noop));if(typeof c=="object"||typeof c=="function")e?m[n]=f.extend(m[n],c):m[n].data=f.extend(m[n].data,c);g=h=m[n],e||(h.data||(h.data={}),h=h.data),d!==b&&(h[f.camelCase(c)]=d);if(o&&!h[c])return g.events;k?(i=h[c],i==null&&(i=h[f.camelCase(c)])):i=h;return i}},removeData:function(a,b,c){if(!!f.acceptData(a)){var d,e,g,h=f.expando,i=a.nodeType,j=i?f.cache:a,k=i?a[h]:h;if(!j[k])return;if(b){d=c?j[k]:j[k].data;if(d){f.isArray(b)||(b in d?b=[b]:(b=f.camelCase(b),b in d?b=[b]:b=b.split(" ")));for(e=0,g=b.length;e<g;e++)delete d[b[e]];if(!(c?m:f.isEmptyObject)(d))return}}if(!c){delete j[k].data;if(!m(j[k]))return}f.support.deleteExpando||!j.setInterval?delete j[k]:j[k]=null,i&&(f.support.deleteExpando?delete a[h]:a.removeAttribute?a.removeAttribute(h):a[h]=null)}},_data:function(a,b,c){return f.data(a,b,c,!0)},acceptData:function(a){if(a.nodeName){var b=f.noData[a.nodeName.toLowerCase()];if(b)return b!==!0&&a.getAttribute("classid")===b}return!0}}),f.fn.extend({data:function(a,c){var d,e,g,h,i,j=this[0],k=0,m=null;if(a===b){if(this.length){m=f.data(j);if(j.nodeType===1&&!f._data(j,"parsedAttrs")){g=j.attributes;for(i=g.length;k<i;k++)h=g[k].name,h.indexOf("data-")===0&&(h=f.camelCase(h.substring(5)),l(j,h,m[h]));f._data(j,"parsedAttrs",!0)}}return m}if(typeof a=="object")return this.each(function(){f.data(this,a)});d=a.split(".",2),d[1]=d[1]?"."+d[1]:"",e=d[1]+"!";return f.access(this,function(c){if(c===b){m=this.triggerHandler("getData"+e,[d[0]]),m===b&&j&&(m=f.data(j,a),m=l(j,a,m));return m===b&&d[1]?this.data(d[0]):m}d[1]=c,this.each(function(){var b=f(this);b.triggerHandler("setData"+e,d),f.data(this,a,c),b.triggerHandler("changeData"+e,d)})},null,c,arguments.length>1,null,!1)},removeData:function(a){return this.each(function(){f.removeData(this,a)})}}),f.extend({_mark:function(a,b){a&&(b=(b||"fx")+"mark",f._data(a,b,(f._data(a,b)||0)+1))},_unmark:function(a,b,c){a!==!0&&(c=b,b=a,a=!1);if(b){c=c||"fx";var d=c+"mark",e=a?0:(f._data(b,d)||1)-1;e?f._data(b,d,e):(f.removeData(b,d,!0),n(b,c,"mark"))}},queue:function(a,b,c){var d;if(a){b=(b||"fx")+"queue",d=f._data(a,b),c&&(!d||f.isArray(c)?d=f._data(a,b,f.makeArray(c)):d.push(c));return d||[]}},dequeue:function(a,b){b=b||"fx";var c=f.queue(a,b),d=c.shift(),e={};d==="inprogress"&&(d=c.shift()),d&&(b==="fx"&&c.unshift("inprogress"),f._data(a,b+".run",e),d.call(a,function(){f.dequeue(a,b)},e)),c.length||(f.removeData(a,b+"queue "+b+".run",!0),n(a,b,"queue"))}}),f.fn.extend({queue:function(a,c){var d=2;typeof a!="string"&&(c=a,a="fx",d--);if(arguments.length<d)return f.queue(this[0],a);return c===b?this:this.each(function(){var b=f.queue(this,a,c);a==="fx"&&b[0]!=="inprogress"&&f.dequeue(this,a)})},dequeue:function(a){return this.each(function(){f.dequeue(this,a)})},delay:function(a,b){a=f.fx?f.fx.speeds[a]||a:a,b=b||"fx";return this.queue(b,function(b,c){var d=setTimeout(b,a);c.stop=function(){clearTimeout(d)}})},clearQueue:function(a){return this.queue(a||"fx",[])},promise:function(a,c){function m(){--h||d.resolveWith(e,[e])}typeof a!="string"&&(c=a,a=b),a=a||"fx";var d=f.Deferred(),e=this,g=e.length,h=1,i=a+"defer",j=a+"queue",k=a+"mark",l;while(g--)if(l=f.data(e[g],i,b,!0)||(f.data(e[g],j,b,!0)||f.data(e[g],k,b,!0))&&f.data(e[g],i,f.Callbacks("once memory"),!0))h++,l.add(m);m();return d.promise(c)}});var o=/[\n\t\r]/g,p=/\s+/,q=/\r/g,r=/^(?:button|input)$/i,s=/^(?:button|input|object|select|textarea)$/i,t=/^a(?:rea)?$/i,u=/^(?:autofocus|autoplay|async|checked|controls|defer|disabled|hidden|loop|multiple|open|readonly|required|scoped|selected)$/i,v=f.support.getSetAttribute,w,x,y;f.fn.extend({attr:function(a,b){return f.access(this,f.attr,a,b,arguments.length>1)},removeAttr:function(a){return this.each(function(){f.removeAttr(this,a)})},prop:function(a,b){return f.access(this,f.prop,a,b,arguments.length>1)},removeProp:function(a){a=f.propFix[a]||a;return this.each(function(){try{this[a]=b,delete this[a]}catch(c){}})},addClass:function(a){var b,c,d,e,g,h,i;if(f.isFunction(a))return this.each(function(b){f(this).addClass(a.call(this,b,this.className))});if(a&&typeof a=="string"){b=a.split(p);for(c=0,d=this.length;c<d;c++){e=this[c];if(e.nodeType===1)if(!e.className&&b.length===1)e.className=a;else{g=" "+e.className+" ";for(h=0,i=b.length;h<i;h++)~g.indexOf(" "+b[h]+" ")||(g+=b[h]+" ");e.className=f.trim(g)}}}return this},removeClass:function(a){var c,d,e,g,h,i,j;if(f.isFunction(a))return this.each(function(b){f(this).removeClass(a.call(this,b,this.className))});if(a&&typeof a=="string"||a===b){c=(a||"").split(p);for(d=0,e=this.length;d<e;d++){g=this[d];if(g.nodeType===1&&g.className)if(a){h=(" "+g.className+" ").replace(o," ");for(i=0,j=c.length;i<j;i++)h=h.replace(" "+c[i]+" "," ");g.className=f.trim(h)}else g.className=""}}return this},toggleClass:function(a,b){var c=typeof a,d=typeof b=="boolean";if(f.isFunction(a))return this.each(function(c){f(this).toggleClass(a.call(this,c,this.className,b),b)});return this.each(function(){if(c==="string"){var e,g=0,h=f(this),i=b,j=a.split(p);while(e=j[g++])i=d?i:!h.hasClass(e),h[i?"addClass":"removeClass"](e)}else if(c==="undefined"||c==="boolean")this.className&&f._data(this,"__className__",this.className),this.className=this.className||a===!1?"":f._data(this,"__className__")||""})},hasClass:function(a){var b=" "+a+" ",c=0,d=this.length;for(;c<d;c++)if(this[c].nodeType===1&&(" "+this[c].className+" ").replace(o," ").indexOf(b)>-1)return!0;return!1},val:function(a){var c,d,e,g=this[0];{if(!!arguments.length){e=f.isFunction(a);return this.each(function(d){var g=f(this),h;if(this.nodeType===1){e?h=a.call(this,d,g.val()):h=a,h==null?h="":typeof h=="number"?h+="":f.isArray(h)&&(h=f.map(h,function(a){return a==null?"":a+""})),c=f.valHooks[this.type]||f.valHooks[this.nodeName.toLowerCase()];if(!c||!("set"in c)||c.set(this,h,"value")===b)this.value=h}})}if(g){c=f.valHooks[g.type]||f.valHooks[g.nodeName.toLowerCase()];if(c&&"get"in c&&(d=c.get(g,"value"))!==b)return d;d=g.value;return typeof d=="string"?d.replace(q,""):d==null?"":d}}}}),f.extend({valHooks:{option:{get:function(a){var b=a.attributes.value;return!b||b.specified?a.value:a.text}},select:{get:function(a){var b,c,d,e,g=a.selectedIndex,h=[],i=a.options,j=a.type==="select-one";if(g<0)return null;c=j?g:0,d=j?g+1:i.length;for(;c<d;c++){e=i[c];if(e.selected&&(f.support.optDisabled?!e.disabled:e.getAttribute("disabled")===null)&&(!e.parentNode.disabled||!f.nodeName(e.parentNode,"optgroup"))){b=f(e).val();if(j)return b;h.push(b)}}if(j&&!h.length&&i.length)return f(i[g]).val();return h},set:function(a,b){var c=f.makeArray(b);f(a).find("option").each(function(){this.selected=f.inArray(f(this).val(),c)>=0}),c.length||(a.selectedIndex=-1);return c}}},attrFn:{val:!0,css:!0,html:!0,text:!0,data:!0,width:!0,height:!0,offset:!0},attr:function(a,c,d,e){var g,h,i,j=a.nodeType;if(!!a&&j!==3&&j!==8&&j!==2){if(e&&c in f.attrFn)return f(a)[c](d);if(typeof a.getAttribute=="undefined")return f.prop(a,c,d);i=j!==1||!f.isXMLDoc(a),i&&(c=c.toLowerCase(),h=f.attrHooks[c]||(u.test(c)?x:w));if(d!==b){if(d===null){f.removeAttr(a,c);return}if(h&&"set"in h&&i&&(g=h.set(a,d,c))!==b)return g;a.setAttribute(c,""+d);return d}if(h&&"get"in h&&i&&(g=h.get(a,c))!==null)return g;g=a.getAttribute(c);return g===null?b:g}},removeAttr:function(a,b){var c,d,e,g,h,i=0;if(b&&a.nodeType===1){d=b.toLowerCase().split(p),g=d.length;for(;i<g;i++)e=d[i],e&&(c=f.propFix[e]||e,h=u.test(e),h||f.attr(a,e,""),a.removeAttribute(v?e:c),h&&c in a&&(a[c]=!1))}},attrHooks:{type:{set:function(a,b){if(r.test(a.nodeName)&&a.parentNode)f.error("type property can't be changed");else if(!f.support.radioValue&&b==="radio"&&f.nodeName(a,"input")){var c=a.value;a.setAttribute("type",b),c&&(a.value=c);return b}}},value:{get:function(a,b){if(w&&f.nodeName(a,"button"))return w.get(a,b);return b in a?a.value:null},set:function(a,b,c){if(w&&f.nodeName(a,"button"))return w.set(a,b,c);a.value=b}}},propFix:{tabindex:"tabIndex",readonly:"readOnly","for":"htmlFor","class":"className",maxlength:"maxLength",cellspacing:"cellSpacing",cellpadding:"cellPadding",rowspan:"rowSpan",colspan:"colSpan",usemap:"useMap",frameborder:"frameBorder",contenteditable:"contentEditable"},prop:function(a,c,d){var e,g,h,i=a.nodeType;if(!!a&&i!==3&&i!==8&&i!==2){h=i!==1||!f.isXMLDoc(a),h&&(c=f.propFix[c]||c,g=f.propHooks[c]);return d!==b?g&&"set"in g&&(e=g.set(a,d,c))!==b?e:a[c]=d:g&&"get"in g&&(e=g.get(a,c))!==null?e:a[c]}},propHooks:{tabIndex:{get:function(a){var c=a.getAttributeNode("tabindex");return c&&c.specified?parseInt(c.value,10):s.test(a.nodeName)||t.test(a.nodeName)&&a.href?0:b}}}}),f.attrHooks.tabindex=f.propHooks.tabIndex,x={get:function(a,c){var d,e=f.prop(a,c);return e===!0||typeof e!="boolean"&&(d=a.getAttributeNode(c))&&d.nodeValue!==!1?c.toLowerCase():b},set:function(a,b,c){var d;b===!1?f.removeAttr(a,c):(d=f.propFix[c]||c,d in a&&(a[d]=!0),a.setAttribute(c,c.toLowerCase()));return c}},v||(y={name:!0,id:!0,coords:!0},w=f.valHooks.button={get:function(a,c){var d;d=a.getAttributeNode(c);return d&&(y[c]?d.nodeValue!=="":d.specified)?d.nodeValue:b},set:function(a,b,d){var e=a.getAttributeNode(d);e||(e=c.createAttribute(d),a.setAttributeNode(e));return e.nodeValue=b+""}},f.attrHooks.tabindex.set=w.set,f.each(["width","height"],function(a,b){f.attrHooks[b]=f.extend(f.attrHooks[b],{set:function(a,c){if(c===""){a.setAttribute(b,"auto");return c}}})}),f.attrHooks.contenteditable={get:w.get,set:function(a,b,c){b===""&&(b="false"),w.set(a,b,c)}}),f.support.hrefNormalized||f.each(["href","src","width","height"],function(a,c){f.attrHooks[c]=f.extend(f.attrHooks[c],{get:function(a){var d=a.getAttribute(c,2);return d===null?b:d}})}),f.support.style||(f.attrHooks.style={get:function(a){return a.style.cssText.toLowerCase()||b},set:function(a,b){return a.style.cssText=""+b}}),f.support.optSelected||(f.propHooks.selected=f.extend(f.propHooks.selected,{get:function(a){var b=a.parentNode;b&&(b.selectedIndex,b.parentNode&&b.parentNode.selectedIndex);return null}})),f.support.enctype||(f.propFix.enctype="encoding"),f.support.checkOn||f.each(["radio","checkbox"],function(){f.valHooks[this]={get:function(a){return a.getAttribute("value")===null?"on":a.value}}}),f.each(["radio","checkbox"],function(){f.valHooks[this]=f.extend(f.valHooks[this],{set:function(a,b){if(f.isArray(b))return a.checked=f.inArray(f(a).val(),b)>=0}})});var z=/^(?:textarea|input|select)$/i,A=/^([^\.]*)?(?:\.(.+))?$/,B=/(?:^|\s)hover(\.\S+)?\b/,C=/^key/,D=/^(?:mouse|contextmenu)|click/,E=/^(?:focusinfocus|focusoutblur)$/,F=/^(\w*)(?:#([\w\-]+))?(?:\.([\w\-]+))?$/,G=function( -a){var b=F.exec(a);b&&(b[1]=(b[1]||"").toLowerCase(),b[3]=b[3]&&new RegExp("(?:^|\\s)"+b[3]+"(?:\\s|$)"));return b},H=function(a,b){var c=a.attributes||{};return(!b[1]||a.nodeName.toLowerCase()===b[1])&&(!b[2]||(c.id||{}).value===b[2])&&(!b[3]||b[3].test((c["class"]||{}).value))},I=function(a){return f.event.special.hover?a:a.replace(B,"mouseenter$1 mouseleave$1")};f.event={add:function(a,c,d,e,g){var h,i,j,k,l,m,n,o,p,q,r,s;if(!(a.nodeType===3||a.nodeType===8||!c||!d||!(h=f._data(a)))){d.handler&&(p=d,d=p.handler,g=p.selector),d.guid||(d.guid=f.guid++),j=h.events,j||(h.events=j={}),i=h.handle,i||(h.handle=i=function(a){return typeof f!="undefined"&&(!a||f.event.triggered!==a.type)?f.event.dispatch.apply(i.elem,arguments):b},i.elem=a),c=f.trim(I(c)).split(" ");for(k=0;k<c.length;k++){l=A.exec(c[k])||[],m=l[1],n=(l[2]||"").split(".").sort(),s=f.event.special[m]||{},m=(g?s.delegateType:s.bindType)||m,s=f.event.special[m]||{},o=f.extend({type:m,origType:l[1],data:e,handler:d,guid:d.guid,selector:g,quick:g&&G(g),namespace:n.join(".")},p),r=j[m];if(!r){r=j[m]=[],r.delegateCount=0;if(!s.setup||s.setup.call(a,e,n,i)===!1)a.addEventListener?a.addEventListener(m,i,!1):a.attachEvent&&a.attachEvent("on"+m,i)}s.add&&(s.add.call(a,o),o.handler.guid||(o.handler.guid=d.guid)),g?r.splice(r.delegateCount++,0,o):r.push(o),f.event.global[m]=!0}a=null}},global:{},remove:function(a,b,c,d,e){var g=f.hasData(a)&&f._data(a),h,i,j,k,l,m,n,o,p,q,r,s;if(!!g&&!!(o=g.events)){b=f.trim(I(b||"")).split(" ");for(h=0;h<b.length;h++){i=A.exec(b[h])||[],j=k=i[1],l=i[2];if(!j){for(j in o)f.event.remove(a,j+b[h],c,d,!0);continue}p=f.event.special[j]||{},j=(d?p.delegateType:p.bindType)||j,r=o[j]||[],m=r.length,l=l?new RegExp("(^|\\.)"+l.split(".").sort().join("\\.(?:.*\\.)?")+"(\\.|$)"):null;for(n=0;n<r.length;n++)s=r[n],(e||k===s.origType)&&(!c||c.guid===s.guid)&&(!l||l.test(s.namespace))&&(!d||d===s.selector||d==="**"&&s.selector)&&(r.splice(n--,1),s.selector&&r.delegateCount--,p.remove&&p.remove.call(a,s));r.length===0&&m!==r.length&&((!p.teardown||p.teardown.call(a,l)===!1)&&f.removeEvent(a,j,g.handle),delete o[j])}f.isEmptyObject(o)&&(q=g.handle,q&&(q.elem=null),f.removeData(a,["events","handle"],!0))}},customEvent:{getData:!0,setData:!0,changeData:!0},trigger:function(c,d,e,g){if(!e||e.nodeType!==3&&e.nodeType!==8){var h=c.type||c,i=[],j,k,l,m,n,o,p,q,r,s;if(E.test(h+f.event.triggered))return;h.indexOf("!")>=0&&(h=h.slice(0,-1),k=!0),h.indexOf(".")>=0&&(i=h.split("."),h=i.shift(),i.sort());if((!e||f.event.customEvent[h])&&!f.event.global[h])return;c=typeof c=="object"?c[f.expando]?c:new f.Event(h,c):new f.Event(h),c.type=h,c.isTrigger=!0,c.exclusive=k,c.namespace=i.join("."),c.namespace_re=c.namespace?new RegExp("(^|\\.)"+i.join("\\.(?:.*\\.)?")+"(\\.|$)"):null,o=h.indexOf(":")<0?"on"+h:"";if(!e){j=f.cache;for(l in j)j[l].events&&j[l].events[h]&&f.event.trigger(c,d,j[l].handle.elem,!0);return}c.result=b,c.target||(c.target=e),d=d!=null?f.makeArray(d):[],d.unshift(c),p=f.event.special[h]||{};if(p.trigger&&p.trigger.apply(e,d)===!1)return;r=[[e,p.bindType||h]];if(!g&&!p.noBubble&&!f.isWindow(e)){s=p.delegateType||h,m=E.test(s+h)?e:e.parentNode,n=null;for(;m;m=m.parentNode)r.push([m,s]),n=m;n&&n===e.ownerDocument&&r.push([n.defaultView||n.parentWindow||a,s])}for(l=0;l<r.length&&!c.isPropagationStopped();l++)m=r[l][0],c.type=r[l][1],q=(f._data(m,"events")||{})[c.type]&&f._data(m,"handle"),q&&q.apply(m,d),q=o&&m[o],q&&f.acceptData(m)&&q.apply(m,d)===!1&&c.preventDefault();c.type=h,!g&&!c.isDefaultPrevented()&&(!p._default||p._default.apply(e.ownerDocument,d)===!1)&&(h!=="click"||!f.nodeName(e,"a"))&&f.acceptData(e)&&o&&e[h]&&(h!=="focus"&&h!=="blur"||c.target.offsetWidth!==0)&&!f.isWindow(e)&&(n=e[o],n&&(e[o]=null),f.event.triggered=h,e[h](),f.event.triggered=b,n&&(e[o]=n));return c.result}},dispatch:function(c){c=f.event.fix(c||a.event);var d=(f._data(this,"events")||{})[c.type]||[],e=d.delegateCount,g=[].slice.call(arguments,0),h=!c.exclusive&&!c.namespace,i=f.event.special[c.type]||{},j=[],k,l,m,n,o,p,q,r,s,t,u;g[0]=c,c.delegateTarget=this;if(!i.preDispatch||i.preDispatch.call(this,c)!==!1){if(e&&(!c.button||c.type!=="click")){n=f(this),n.context=this.ownerDocument||this;for(m=c.target;m!=this;m=m.parentNode||this)if(m.disabled!==!0){p={},r=[],n[0]=m;for(k=0;k<e;k++)s=d[k],t=s.selector,p[t]===b&&(p[t]=s.quick?H(m,s.quick):n.is(t)),p[t]&&r.push(s);r.length&&j.push({elem:m,matches:r})}}d.length>e&&j.push({elem:this,matches:d.slice(e)});for(k=0;k<j.length&&!c.isPropagationStopped();k++){q=j[k],c.currentTarget=q.elem;for(l=0;l<q.matches.length&&!c.isImmediatePropagationStopped();l++){s=q.matches[l];if(h||!c.namespace&&!s.namespace||c.namespace_re&&c.namespace_re.test(s.namespace))c.data=s.data,c.handleObj=s,o=((f.event.special[s.origType]||{}).handle||s.handler).apply(q.elem,g),o!==b&&(c.result=o,o===!1&&(c.preventDefault(),c.stopPropagation()))}}i.postDispatch&&i.postDispatch.call(this,c);return c.result}},props:"attrChange attrName relatedNode srcElement altKey bubbles cancelable ctrlKey currentTarget eventPhase metaKey relatedTarget shiftKey target timeStamp view which".split(" "),fixHooks:{},keyHooks:{props:"char charCode key keyCode".split(" "),filter:function(a,b){a.which==null&&(a.which=b.charCode!=null?b.charCode:b.keyCode);return a}},mouseHooks:{props:"button buttons clientX clientY fromElement offsetX offsetY pageX pageY screenX screenY toElement".split(" "),filter:function(a,d){var e,f,g,h=d.button,i=d.fromElement;a.pageX==null&&d.clientX!=null&&(e=a.target.ownerDocument||c,f=e.documentElement,g=e.body,a.pageX=d.clientX+(f&&f.scrollLeft||g&&g.scrollLeft||0)-(f&&f.clientLeft||g&&g.clientLeft||0),a.pageY=d.clientY+(f&&f.scrollTop||g&&g.scrollTop||0)-(f&&f.clientTop||g&&g.clientTop||0)),!a.relatedTarget&&i&&(a.relatedTarget=i===a.target?d.toElement:i),!a.which&&h!==b&&(a.which=h&1?1:h&2?3:h&4?2:0);return a}},fix:function(a){if(a[f.expando])return a;var d,e,g=a,h=f.event.fixHooks[a.type]||{},i=h.props?this.props.concat(h.props):this.props;a=f.Event(g);for(d=i.length;d;)e=i[--d],a[e]=g[e];a.target||(a.target=g.srcElement||c),a.target.nodeType===3&&(a.target=a.target.parentNode),a.metaKey===b&&(a.metaKey=a.ctrlKey);return h.filter?h.filter(a,g):a},special:{ready:{setup:f.bindReady},load:{noBubble:!0},focus:{delegateType:"focusin"},blur:{delegateType:"focusout"},beforeunload:{setup:function(a,b,c){f.isWindow(this)&&(this.onbeforeunload=c)},teardown:function(a,b){this.onbeforeunload===b&&(this.onbeforeunload=null)}}},simulate:function(a,b,c,d){var e=f.extend(new f.Event,c,{type:a,isSimulated:!0,originalEvent:{}});d?f.event.trigger(e,null,b):f.event.dispatch.call(b,e),e.isDefaultPrevented()&&c.preventDefault()}},f.event.handle=f.event.dispatch,f.removeEvent=c.removeEventListener?function(a,b,c){a.removeEventListener&&a.removeEventListener(b,c,!1)}:function(a,b,c){a.detachEvent&&a.detachEvent("on"+b,c)},f.Event=function(a,b){if(!(this instanceof f.Event))return new f.Event(a,b);a&&a.type?(this.originalEvent=a,this.type=a.type,this.isDefaultPrevented=a.defaultPrevented||a.returnValue===!1||a.getPreventDefault&&a.getPreventDefault()?K:J):this.type=a,b&&f.extend(this,b),this.timeStamp=a&&a.timeStamp||f.now(),this[f.expando]=!0},f.Event.prototype={preventDefault:function(){this.isDefaultPrevented=K;var a=this.originalEvent;!a||(a.preventDefault?a.preventDefault():a.returnValue=!1)},stopPropagation:function(){this.isPropagationStopped=K;var a=this.originalEvent;!a||(a.stopPropagation&&a.stopPropagation(),a.cancelBubble=!0)},stopImmediatePropagation:function(){this.isImmediatePropagationStopped=K,this.stopPropagation()},isDefaultPrevented:J,isPropagationStopped:J,isImmediatePropagationStopped:J},f.each({mouseenter:"mouseover",mouseleave:"mouseout"},function(a,b){f.event.special[a]={delegateType:b,bindType:b,handle:function(a){var c=this,d=a.relatedTarget,e=a.handleObj,g=e.selector,h;if(!d||d!==c&&!f.contains(c,d))a.type=e.origType,h=e.handler.apply(this,arguments),a.type=b;return h}}}),f.support.submitBubbles||(f.event.special.submit={setup:function(){if(f.nodeName(this,"form"))return!1;f.event.add(this,"click._submit keypress._submit",function(a){var c=a.target,d=f.nodeName(c,"input")||f.nodeName(c,"button")?c.form:b;d&&!d._submit_attached&&(f.event.add(d,"submit._submit",function(a){a._submit_bubble=!0}),d._submit_attached=!0)})},postDispatch:function(a){a._submit_bubble&&(delete a._submit_bubble,this.parentNode&&!a.isTrigger&&f.event.simulate("submit",this.parentNode,a,!0))},teardown:function(){if(f.nodeName(this,"form"))return!1;f.event.remove(this,"._submit")}}),f.support.changeBubbles||(f.event.special.change={setup:function(){if(z.test(this.nodeName)){if(this.type==="checkbox"||this.type==="radio")f.event.add(this,"propertychange._change",function(a){a.originalEvent.propertyName==="checked"&&(this._just_changed=!0)}),f.event.add(this,"click._change",function(a){this._just_changed&&!a.isTrigger&&(this._just_changed=!1,f.event.simulate("change",this,a,!0))});return!1}f.event.add(this,"beforeactivate._change",function(a){var b=a.target;z.test(b.nodeName)&&!b._change_attached&&(f.event.add(b,"change._change",function(a){this.parentNode&&!a.isSimulated&&!a.isTrigger&&f.event.simulate("change",this.parentNode,a,!0)}),b._change_attached=!0)})},handle:function(a){var b=a.target;if(this!==b||a.isSimulated||a.isTrigger||b.type!=="radio"&&b.type!=="checkbox")return a.handleObj.handler.apply(this,arguments)},teardown:function(){f.event.remove(this,"._change");return z.test(this.nodeName)}}),f.support.focusinBubbles||f.each({focus:"focusin",blur:"focusout"},function(a,b){var d=0,e=function(a){f.event.simulate(b,a.target,f.event.fix(a),!0)};f.event.special[b]={setup:function(){d++===0&&c.addEventListener(a,e,!0)},teardown:function(){--d===0&&c.removeEventListener(a,e,!0)}}}),f.fn.extend({on:function(a,c,d,e,g){var h,i;if(typeof a=="object"){typeof c!="string"&&(d=d||c,c=b);for(i in a)this.on(i,c,d,a[i],g);return this}d==null&&e==null?(e=c,d=c=b):e==null&&(typeof c=="string"?(e=d,d=b):(e=d,d=c,c=b));if(e===!1)e=J;else if(!e)return this;g===1&&(h=e,e=function(a){f().off(a);return h.apply(this,arguments)},e.guid=h.guid||(h.guid=f.guid++));return this.each(function(){f.event.add(this,a,e,d,c)})},one:function(a,b,c,d){return this.on(a,b,c,d,1)},off:function(a,c,d){if(a&&a.preventDefault&&a.handleObj){var e=a.handleObj;f(a.delegateTarget).off(e.namespace?e.origType+"."+e.namespace:e.origType,e.selector,e.handler);return this}if(typeof a=="object"){for(var g in a)this.off(g,c,a[g]);return this}if(c===!1||typeof c=="function")d=c,c=b;d===!1&&(d=J);return this.each(function(){f.event.remove(this,a,d,c)})},bind:function(a,b,c){return this.on(a,null,b,c)},unbind:function(a,b){return this.off(a,null,b)},live:function(a,b,c){f(this.context).on(a,this.selector,b,c);return this},die:function(a,b){f(this.context).off(a,this.selector||"**",b);return this},delegate:function(a,b,c,d){return this.on(b,a,c,d)},undelegate:function(a,b,c){return arguments.length==1?this.off(a,"**"):this.off(b,a,c)},trigger:function(a,b){return this.each(function(){f.event.trigger(a,b,this)})},triggerHandler:function(a,b){if(this[0])return f.event.trigger(a,b,this[0],!0)},toggle:function(a){var b=arguments,c=a.guid||f.guid++,d=0,e=function(c){var e=(f._data(this,"lastToggle"+a.guid)||0)%d;f._data(this,"lastToggle"+a.guid,e+1),c.preventDefault();return b[e].apply(this,arguments)||!1};e.guid=c;while(d<b.length)b[d++].guid=c;return this.click(e)},hover:function(a,b){return this.mouseenter(a).mouseleave(b||a)}}),f.each("blur focus focusin focusout load resize scroll unload click dblclick mousedown mouseup mousemove mouseover mouseout mouseenter mouseleave change select submit keydown keypress keyup error contextmenu".split(" "),function(a,b){f.fn[b]=function(a,c){c==null&&(c=a,a=null);return arguments.length>0?this.on(b,null,a,c):this.trigger(b)},f.attrFn&&(f.attrFn[b]=!0),C.test(b)&&(f.event.fixHooks[b]=f.event.keyHooks),D.test(b)&&(f.event.fixHooks[b]=f.event.mouseHooks)}),function(){function x(a,b,c,e,f,g){for(var h=0,i=e.length;h<i;h++){var j=e[h];if(j){var k=!1;j=j[a];while(j){if(j[d]===c){k=e[j.sizset];break}if(j.nodeType===1){g||(j[d]=c,j.sizset=h);if(typeof b!="string"){if(j===b){k=!0;break}}else if(m.filter(b,[j]).length>0){k=j;break}}j=j[a]}e[h]=k}}}function w(a,b,c,e,f,g){for(var h=0,i=e.length;h<i;h++){var j=e[h];if(j){var k=!1;j=j[a];while(j){if(j[d]===c){k=e[j.sizset];break}j.nodeType===1&&!g&&(j[d]=c,j.sizset=h);if(j.nodeName.toLowerCase()===b){k=j;break}j=j[a]}e[h]=k}}}var a=/((?:\((?:\([^()]+\)|[^()]+)+\)|\[(?:\[[^\[\]]*\]|['"][^'"]*['"]|[^\[\]'"]+)+\]|\\.|[^ >+~,(\[\\]+)+|[>+~])(\s*,\s*)?((?:.|\r|\n)*)/g,d="sizcache"+(Math.random()+"").replace(".",""),e=0,g=Object.prototype.toString,h=!1,i=!0,j=/\\/g,k=/\r\n/g,l=/\W/;[0,0].sort(function(){i=!1;return 0});var m=function(b,d,e,f){e=e||[],d=d||c;var h=d;if(d.nodeType!==1&&d.nodeType!==9)return[];if(!b||typeof b!="string")return e;var i,j,k,l,n,q,r,t,u=!0,v=m.isXML(d),w=[],x=b;do{a.exec(""),i=a.exec(x);if(i){x=i[3],w.push(i[1]);if(i[2]){l=i[3];break}}}while(i);if(w.length>1&&p.exec(b))if(w.length===2&&o.relative[w[0]])j=y(w[0]+w[1],d,f);else{j=o.relative[w[0]]?[d]:m(w.shift(),d);while(w.length)b=w.shift(),o.relative[b]&&(b+=w.shift()),j=y(b,j,f)}else{!f&&w.length>1&&d.nodeType===9&&!v&&o.match.ID.test(w[0])&&!o.match.ID.test(w[w.length-1])&&(n=m.find(w.shift(),d,v),d=n.expr?m.filter(n.expr,n.set)[0]:n.set[0]);if(d){n=f?{expr:w.pop(),set:s(f)}:m.find(w.pop(),w.length===1&&(w[0]==="~"||w[0]==="+")&&d.parentNode?d.parentNode:d,v),j=n.expr?m.filter(n.expr,n.set):n.set,w.length>0?k=s(j):u=!1;while(w.length)q=w.pop(),r=q,o.relative[q]?r=w.pop():q="",r==null&&(r=d),o.relative[q](k,r,v)}else k=w=[]}k||(k=j),k||m.error(q||b);if(g.call(k)==="[object Array]")if(!u)e.push.apply(e,k);else if(d&&d.nodeType===1)for(t=0;k[t]!=null;t++)k[t]&&(k[t]===!0||k[t].nodeType===1&&m.contains(d,k[t]))&&e.push(j[t]);else for(t=0;k[t]!=null;t++)k[t]&&k[t].nodeType===1&&e.push(j[t]);else s(k,e);l&&(m(l,h,e,f),m.uniqueSort(e));return e};m.uniqueSort=function(a){if(u){h=i,a.sort(u);if(h)for(var b=1;b<a.length;b++)a[b]===a[b-1]&&a.splice(b--,1)}return a},m.matches=function(a,b){return m(a,null,null,b)},m.matchesSelector=function(a,b){return m(b,null,null,[a]).length>0},m.find=function(a,b,c){var d,e,f,g,h,i;if(!a)return[];for(e=0,f=o.order.length;e<f;e++){h=o.order[e];if(g=o.leftMatch[h].exec(a)){i=g[1],g.splice(1,1);if(i.substr(i.length-1)!=="\\"){g[1]=(g[1]||"").replace(j,""),d=o.find[h](g,b,c);if(d!=null){a=a.replace(o.match[h],"");break}}}}d||(d=typeof b.getElementsByTagName!="undefined"?b.getElementsByTagName("*"):[]);return{set:d,expr:a}},m.filter=function(a,c,d,e){var f,g,h,i,j,k,l,n,p,q=a,r=[],s=c,t=c&&c[0]&&m.isXML(c[0]);while(a&&c.length){for(h in o.filter)if((f=o.leftMatch[h].exec(a))!=null&&f[2]){k=o.filter[h],l=f[1],g=!1,f.splice(1,1);if(l.substr(l.length-1)==="\\")continue;s===r&&(r=[]);if(o.preFilter[h]){f=o.preFilter[h](f,s,d,r,e,t);if(!f)g=i=!0;else if(f===!0)continue}if(f)for(n=0;(j=s[n])!=null;n++)j&&(i=k(j,f,n,s),p=e^i,d&&i!=null?p?g=!0:s[n]=!1:p&&(r.push(j),g=!0));if(i!==b){d||(s=r),a=a.replace(o.match[h],"");if(!g)return[];break}}if(a===q)if(g==null)m.error(a);else break;q=a}return s},m.error=function(a){throw new Error("Syntax error, unrecognized expression: "+a)};var n=m.getText=function(a){var b,c,d=a.nodeType,e="";if(d){if(d===1||d===9||d===11){if(typeof a.textContent=="string")return a.textContent;if(typeof a.innerText=="string")return a.innerText.replace(k,"");for(a=a.firstChild;a;a=a.nextSibling)e+=n(a)}else if(d===3||d===4)return a.nodeValue}else for(b=0;c=a[b];b++)c.nodeType!==8&&(e+=n(c));return e},o=m.selectors={order:["ID","NAME","TAG"],match:{ID:/#((?:[\w\u00c0-\uFFFF\-]|\\.)+)/,CLASS:/\.((?:[\w\u00c0-\uFFFF\-]|\\.)+)/,NAME:/\[name=['"]*((?:[\w\u00c0-\uFFFF\-]|\\.)+)['"]*\]/,ATTR:/\[\s*((?:[\w\u00c0-\uFFFF\-]|\\.)+)\s*(?:(\S?=)\s*(?:(['"])(.*?)\3|(#?(?:[\w\u00c0-\uFFFF\-]|\\.)*)|)|)\s*\]/,TAG:/^((?:[\w\u00c0-\uFFFF\*\-]|\\.)+)/,CHILD:/:(only|nth|last|first)-child(?:\(\s*(even|odd|(?:[+\-]?\d+|(?:[+\-]?\d*)?n\s*(?:[+\-]\s*\d+)?))\s*\))?/,POS:/:(nth|eq|gt|lt|first|last|even|odd)(?:\((\d*)\))?(?=[^\-]|$)/,PSEUDO:/:((?:[\w\u00c0-\uFFFF\-]|\\.)+)(?:\((['"]?)((?:\([^\)]+\)|[^\(\)]*)+)\2\))?/},leftMatch:{},attrMap:{"class":"className","for":"htmlFor"},attrHandle:{href:function(a){return a.getAttribute("href")},type:function(a){return a.getAttribute("type")}},relative:{"+":function(a,b){var c=typeof b=="string",d=c&&!l.test(b),e=c&&!d;d&&(b=b.toLowerCase());for(var f=0,g=a.length,h;f<g;f++)if(h=a[f]){while((h=h.previousSibling)&&h.nodeType!==1);a[f]=e||h&&h.nodeName.toLowerCase()===b?h||!1:h===b}e&&m.filter(b,a,!0)},">":function(a,b){var c,d=typeof b=="string",e=0,f=a.length;if(d&&!l.test(b)){b=b.toLowerCase();for(;e<f;e++){c=a[e];if(c){var g=c.parentNode;a[e]=g.nodeName.toLowerCase()===b?g:!1}}}else{for(;e<f;e++)c=a[e],c&&(a[e]=d?c.parentNode:c.parentNode===b);d&&m.filter(b,a,!0)}},"":function(a,b,c){var d,f=e++,g=x;typeof b=="string"&&!l.test(b)&&(b=b.toLowerCase(),d=b,g=w),g("parentNode",b,f,a,d,c)},"~":function(a,b,c){var d,f=e++,g=x;typeof b=="string"&&!l.test(b)&&(b=b.toLowerCase(),d=b,g=w),g("previousSibling",b,f,a,d,c)}},find:{ID:function(a,b,c){if(typeof b.getElementById!="undefined"&&!c){var d=b.getElementById(a[1]);return d&&d.parentNode?[d]:[]}},NAME:function(a,b){if(typeof b.getElementsByName!="undefined"){var c=[],d=b.getElementsByName(a[1]);for(var e=0,f=d.length;e<f;e++)d[e].getAttribute("name")===a[1]&&c.push(d[e]);return c.length===0?null:c}},TAG:function(a,b){if(typeof b.getElementsByTagName!="undefined")return b.getElementsByTagName(a[1])}},preFilter:{CLASS:function(a,b,c,d,e,f){a=" "+a[1].replace(j,"")+" ";if(f)return a;for(var g=0,h;(h=b[g])!=null;g++)h&&(e^(h.className&&(" "+h.className+" ").replace(/[\t\n\r]/g," ").indexOf(a)>=0)?c||d.push(h):c&&(b[g]=!1));return!1},ID:function(a){return a[1].replace(j,"")},TAG:function(a,b){return a[1].replace(j,"").toLowerCase()},CHILD:function(a){if(a[1]==="nth"){a[2]||m.error(a[0]),a[2]=a[2].replace(/^\+|\s*/g,"");var b=/(-?)(\d*)(?:n([+\-]?\d*))?/.exec(a[2]==="even"&&"2n"||a[2]==="odd"&&"2n+1"||!/\D/.test(a[2])&&"0n+"+a[2]||a[2]);a[2]=b[1]+(b[2]||1)-0,a[3]=b[3]-0}else a[2]&&m.error(a[0]);a[0]=e++;return a},ATTR:function(a,b,c,d,e,f){var g=a[1]=a[1].replace(j,"");!f&&o.attrMap[g]&&(a[1]=o.attrMap[g]),a[4]=(a[4]||a[5]||"").replace(j,""),a[2]==="~="&&(a[4]=" "+a[4]+" ");return a},PSEUDO:function(b,c,d,e,f){if(b[1]==="not")if((a.exec(b[3])||"").length>1||/^\w/.test(b[3]))b[3]=m(b[3],null,null,c);else{var g=m.filter(b[3],c,d,!0^f);d||e.push.apply(e,g);return!1}else if(o.match.POS.test(b[0])||o.match.CHILD.test(b[0]))return!0;return b},POS:function(a){a.unshift(!0);return a}},filters:{enabled:function(a){return a.disabled===!1&&a.type!=="hidden"},disabled:function(a){return a.disabled===!0},checked:function(a){return a.checked===!0},selected:function(a){a.parentNode&&a.parentNode.selectedIndex;return a.selected===!0},parent:function(a){return!!a.firstChild},empty:function(a){return!a.firstChild},has:function(a,b,c){return!!m(c[3],a).length},header:function(a){return/h\d/i.test(a.nodeName)},text:function(a){var b=a.getAttribute("type"),c=a.type;return a.nodeName.toLowerCase()==="input"&&"text"===c&&(b===c||b===null)},radio:function(a){return a.nodeName.toLowerCase()==="input"&&"radio"===a.type},checkbox:function(a){return a.nodeName.toLowerCase()==="input"&&"checkbox"===a.type},file:function(a){return a.nodeName.toLowerCase()==="input"&&"file"===a.type},password:function(a){return a.nodeName.toLowerCase()==="input"&&"password"===a.type},submit:function(a){var b=a.nodeName.toLowerCase();return(b==="input"||b==="button")&&"submit"===a.type},image:function(a){return a.nodeName.toLowerCase()==="input"&&"image"===a.type},reset:function(a){var b=a.nodeName.toLowerCase();return(b==="input"||b==="button")&&"reset"===a.type},button:function(a){var b=a.nodeName.toLowerCase();return b==="input"&&"button"===a.type||b==="button"},input:function(a){return/input|select|textarea|button/i.test(a.nodeName)},focus:function(a){return a===a.ownerDocument.activeElement}},setFilters:{first:function(a,b){return b===0},last:function(a,b,c,d){return b===d.length-1},even:function(a,b){return b%2===0},odd:function(a,b){return b%2===1},lt:function(a,b,c){return b<c[3]-0},gt:function(a,b,c){return b>c[3]-0},nth:function(a,b,c){return c[3]-0===b},eq:function(a,b,c){return c[3]-0===b}},filter:{PSEUDO:function(a,b,c,d){var e=b[1],f=o.filters[e];if(f)return f(a,c,b,d);if(e==="contains")return(a.textContent||a.innerText||n([a])||"").indexOf(b[3])>=0;if(e==="not"){var g=b[3];for(var h=0,i=g.length;h<i;h++)if(g[h]===a)return!1;return!0}m.error(e)},CHILD:function(a,b){var c,e,f,g,h,i,j,k=b[1],l=a;switch(k){case"only":case"first":while(l=l.previousSibling)if(l.nodeType===1)return!1;if(k==="first")return!0;l=a;case"last":while(l=l.nextSibling)if(l.nodeType===1)return!1;return!0;case"nth":c=b[2],e=b[3];if(c===1&&e===0)return!0;f=b[0],g=a.parentNode;if(g&&(g[d]!==f||!a.nodeIndex)){i=0;for(l=g.firstChild;l;l=l.nextSibling)l.nodeType===1&&(l.nodeIndex=++i);g[d]=f}j=a.nodeIndex-e;return c===0?j===0:j%c===0&&j/c>=0}},ID:function(a,b){return a.nodeType===1&&a.getAttribute("id")===b},TAG:function(a,b){return b==="*"&&a.nodeType===1||!!a.nodeName&&a.nodeName.toLowerCase()===b},CLASS:function(a,b){return(" "+(a.className||a.getAttribute("class"))+" ").indexOf(b)>-1},ATTR:function(a,b){var c=b[1],d=m.attr?m.attr(a,c):o.attrHandle[c]?o.attrHandle[c](a):a[c]!=null?a[c]:a.getAttribute(c),e=d+"",f=b[2],g=b[4];return d==null?f==="!=":!f&&m.attr?d!=null:f==="="?e===g:f==="*="?e.indexOf(g)>=0:f==="~="?(" "+e+" ").indexOf(g)>=0:g?f==="!="?e!==g:f==="^="?e.indexOf(g)===0:f==="$="?e.substr(e.length-g.length)===g:f==="|="?e===g||e.substr(0,g.length+1)===g+"-":!1:e&&d!==!1},POS:function(a,b,c,d){var e=b[2],f=o.setFilters[e];if(f)return f(a,c,b,d)}}},p=o.match.POS,q=function(a,b){return"\\"+(b-0+1)};for(var r in o.match)o.match[r]=new RegExp(o.match[r].source+/(?![^\[]*\])(?![^\(]*\))/.source),o.leftMatch[r]=new RegExp(/(^(?:.|\r|\n)*?)/.source+o.match[r].source.replace(/\\(\d+)/g,q));o.match.globalPOS=p;var s=function(a,b){a=Array.prototype.slice.call(a,0);if(b){b.push.apply(b,a);return b}return a};try{Array.prototype.slice.call(c.documentElement.childNodes,0)[0].nodeType}catch(t){s=function(a,b){var c=0,d=b||[];if(g.call(a)==="[object Array]")Array.prototype.push.apply(d,a);else if(typeof a.length=="number")for(var e=a.length;c<e;c++)d.push(a[c]);else for(;a[c];c++)d.push(a[c]);return d}}var u,v;c.documentElement.compareDocumentPosition?u=function(a,b){if(a===b){h=!0;return 0}if(!a.compareDocumentPosition||!b.compareDocumentPosition)return a.compareDocumentPosition?-1:1;return a.compareDocumentPosition(b)&4?-1:1}:(u=function(a,b){if(a===b){h=!0;return 0}if(a.sourceIndex&&b.sourceIndex)return a.sourceIndex-b.sourceIndex;var c,d,e=[],f=[],g=a.parentNode,i=b.parentNode,j=g;if(g===i)return v(a,b);if(!g)return-1;if(!i)return 1;while(j)e.unshift(j),j=j.parentNode;j=i;while(j)f.unshift(j),j=j.parentNode;c=e.length,d=f.length;for(var k=0;k<c&&k<d;k++)if(e[k]!==f[k])return v(e[k],f[k]);return k===c?v(a,f[k],-1):v(e[k],b,1)},v=function(a,b,c){if(a===b)return c;var d=a.nextSibling;while(d){if(d===b)return-1;d=d.nextSibling}return 1}),function(){var a=c.createElement("div"),d="script"+(new Date).getTime(),e=c.documentElement;a.innerHTML="<a name='"+d+"'/>",e.insertBefore(a,e.firstChild),c.getElementById(d)&&(o.find.ID=function(a,c,d){if(typeof c.getElementById!="undefined"&&!d){var e=c.getElementById(a[1]);return e?e.id===a[1]||typeof e.getAttributeNode!="undefined"&&e.getAttributeNode("id").nodeValue===a[1]?[e]:b:[]}},o.filter.ID=function(a,b){var c=typeof a.getAttributeNode!="undefined"&&a.getAttributeNode("id");return a.nodeType===1&&c&&c.nodeValue===b}),e.removeChild(a),e=a=null}(),function(){var a=c.createElement("div");a.appendChild(c.createComment("")),a.getElementsByTagName("*").length>0&&(o.find.TAG=function(a,b){var c=b.getElementsByTagName(a[1]);if(a[1]==="*"){var d=[];for(var e=0;c[e];e++)c[e].nodeType===1&&d.push(c[e]);c=d}return c}),a.innerHTML="<a href='#'></a>",a.firstChild&&typeof a.firstChild.getAttribute!="undefined"&&a.firstChild.getAttribute("href")!=="#"&&(o.attrHandle.href=function(a){return a.getAttribute("href",2)}),a=null}(),c.querySelectorAll&&function(){var a=m,b=c.createElement("div"),d="__sizzle__";b.innerHTML="<p class='TEST'></p>";if(!b.querySelectorAll||b.querySelectorAll(".TEST").length!==0){m=function(b,e,f,g){e=e||c;if(!g&&!m.isXML(e)){var h=/^(\w+$)|^\.([\w\-]+$)|^#([\w\-]+$)/.exec(b);if(h&&(e.nodeType===1||e.nodeType===9)){if(h[1])return s(e.getElementsByTagName(b),f);if(h[2]&&o.find.CLASS&&e.getElementsByClassName)return s(e.getElementsByClassName(h[2]),f)}if(e.nodeType===9){if(b==="body"&&e.body)return s([e.body],f);if(h&&h[3]){var i=e.getElementById(h[3]);if(!i||!i.parentNode)return s([],f);if(i.id===h[3])return s([i],f)}try{return s(e.querySelectorAll(b),f)}catch(j){}}else if(e.nodeType===1&&e.nodeName.toLowerCase()!=="object"){var k=e,l=e.getAttribute("id"),n=l||d,p=e.parentNode,q=/^\s*[+~]/.test(b);l?n=n.replace(/'/g,"\\$&"):e.setAttribute("id",n),q&&p&&(e=e.parentNode);try{if(!q||p)return s(e.querySelectorAll("[id='"+n+"'] "+b),f)}catch(r){}finally{l||k.removeAttribute("id")}}}return a(b,e,f,g)};for(var e in a)m[e]=a[e];b=null}}(),function(){var a=c.documentElement,b=a.matchesSelector||a.mozMatchesSelector||a.webkitMatchesSelector||a.msMatchesSelector;if(b){var d=!b.call(c.createElement("div"),"div"),e=!1;try{b.call(c.documentElement,"[test!='']:sizzle")}catch(f){e=!0}m.matchesSelector=function(a,c){c=c.replace(/\=\s*([^'"\]]*)\s*\]/g,"='$1']");if(!m.isXML(a))try{if(e||!o.match.PSEUDO.test(c)&&!/!=/.test(c)){var f=b.call(a,c);if(f||!d||a.document&&a.document.nodeType!==11)return f}}catch(g){}return m(c,null,null,[a]).length>0}}}(),function(){var a=c.createElement("div");a.innerHTML="<div class='test e'></div><div class='test'></div>";if(!!a.getElementsByClassName&&a.getElementsByClassName("e").length!==0){a.lastChild.className="e";if(a.getElementsByClassName("e").length===1)return;o.order.splice(1,0,"CLASS"),o.find.CLASS=function(a,b,c){if(typeof b.getElementsByClassName!="undefined"&&!c)return b.getElementsByClassName(a[1])},a=null}}(),c.documentElement.contains?m.contains=function(a,b){return a!==b&&(a.contains?a.contains(b):!0)}:c.documentElement.compareDocumentPosition?m.contains=function(a,b){return!!(a.compareDocumentPosition(b)&16)}:m.contains=function(){return!1},m.isXML=function(a){var b=(a?a.ownerDocument||a:0).documentElement;return b?b.nodeName!=="HTML":!1};var y=function(a,b,c){var d,e=[],f="",g=b.nodeType?[b]:b;while(d=o.match.PSEUDO.exec(a))f+=d[0],a=a.replace(o.match.PSEUDO,"");a=o.relative[a]?a+"*":a;for(var h=0,i=g.length;h<i;h++)m(a,g[h],e,c);return m.filter(f,e)};m.attr=f.attr,m.selectors.attrMap={},f.find=m,f.expr=m.selectors,f.expr[":"]=f.expr.filters,f.unique=m.uniqueSort,f.text=m.getText,f.isXMLDoc=m.isXML,f.contains=m.contains}();var L=/Until$/,M=/^(?:parents|prevUntil|prevAll)/,N=/,/,O=/^.[^:#\[\.,]*$/,P=Array.prototype.slice,Q=f.expr.match.globalPOS,R={children:!0,contents:!0,next:!0,prev:!0};f.fn.extend({find:function(a){var b=this,c,d;if(typeof a!="string")return f(a).filter(function(){for(c=0,d=b.length;c<d;c++)if(f.contains(b[c],this))return!0});var e=this.pushStack("","find",a),g,h,i;for(c=0,d=this.length;c<d;c++){g=e.length,f.find(a,this[c],e);if(c>0)for(h=g;h<e.length;h++)for(i=0;i<g;i++)if(e[i]===e[h]){e.splice(h--,1);break}}return e},has:function(a){var b=f(a);return this.filter(function(){for(var a=0,c=b.length;a<c;a++)if(f.contains(this,b[a]))return!0})},not:function(a){return this.pushStack(T(this,a,!1),"not",a)},filter:function(a){return this.pushStack(T(this,a,!0),"filter",a)},is:function(a){return!!a&&(typeof a=="string"?Q.test(a)?f(a,this.context).index(this[0])>=0:f.filter(a,this).length>0:this.filter(a).length>0)},closest:function(a,b){var c=[],d,e,g=this[0];if(f.isArray(a)){var h=1;while(g&&g.ownerDocument&&g!==b){for(d=0;d<a.length;d++)f(g).is(a[d])&&c.push({selector:a[d],elem:g,level:h});g=g.parentNode,h++}return c}var i=Q.test(a)||typeof a!="string"?f(a,b||this.context):0;for(d=0,e=this.length;d<e;d++){g=this[d];while(g){if(i?i.index(g)>-1:f.find.matchesSelector(g,a)){c.push(g);break}g=g.parentNode;if(!g||!g.ownerDocument||g===b||g.nodeType===11)break}}c=c.length>1?f.unique(c):c;return this.pushStack(c,"closest",a)},index:function(a){if(!a)return this[0]&&this[0].parentNode?this.prevAll().length:-1;if(typeof a=="string")return f.inArray(this[0],f(a));return f.inArray(a.jquery?a[0]:a,this)},add:function(a,b){var c=typeof a=="string"?f(a,b):f.makeArray(a&&a.nodeType?[a]:a),d=f.merge(this.get(),c);return this.pushStack(S(c[0])||S(d[0])?d:f.unique(d))},andSelf:function(){return this.add(this.prevObject)}}),f.each({parent:function(a){var b=a.parentNode;return b&&b.nodeType!==11?b:null},parents:function(a){return f.dir(a,"parentNode")},parentsUntil:function(a,b,c){return f.dir(a,"parentNode",c)},next:function(a){return f.nth(a,2,"nextSibling")},prev:function(a){return f.nth(a,2,"previousSibling")},nextAll:function(a){return f.dir(a,"nextSibling")},prevAll:function(a){return f.dir(a,"previousSibling")},nextUntil:function(a,b,c){return f.dir(a,"nextSibling",c)},prevUntil:function(a,b,c){return f.dir(a,"previousSibling",c)},siblings:function(a){return f.sibling((a.parentNode||{}).firstChild,a)},children:function(a){return f.sibling(a.firstChild)},contents:function(a){return f.nodeName(a,"iframe")?a.contentDocument||a.contentWindow.document:f.makeArray(a.childNodes)}},function(a,b){f.fn[a]=function(c,d){var e=f.map(this,b,c);L.test(a)||(d=c),d&&typeof d=="string"&&(e=f.filter(d,e)),e=this.length>1&&!R[a]?f.unique(e):e,(this.length>1||N.test(d))&&M.test(a)&&(e=e.reverse());return this.pushStack(e,a,P.call(arguments).join(","))}}),f.extend({filter:function(a,b,c){c&&(a=":not("+a+")");return b.length===1?f.find.matchesSelector(b[0],a)?[b[0]]:[]:f.find.matches(a,b)},dir:function(a,c,d){var e=[],g=a[c];while(g&&g.nodeType!==9&&(d===b||g.nodeType!==1||!f(g).is(d)))g.nodeType===1&&e.push(g),g=g[c];return e},nth:function(a,b,c,d){b=b||1;var e=0;for(;a;a=a[c])if(a.nodeType===1&&++e===b)break;return a},sibling:function(a,b){var c=[];for(;a;a=a.nextSibling)a.nodeType===1&&a!==b&&c.push(a);return c}});var V="abbr|article|aside|audio|bdi|canvas|data|datalist|details|figcaption|figure|footer|header|hgroup|mark|meter|nav|output|progress|section|summary|time|video",W=/ jQuery\d+="(?:\d+|null)"/g,X=/^\s+/,Y=/<(?!area|br|col|embed|hr|img|input|link|meta|param)(([\w:]+)[^>]*)\/>/ig,Z=/<([\w:]+)/,$=/<tbody/i,_=/<|&#?\w+;/,ba=/<(?:script|style)/i,bb=/<(?:script|object|embed|option|style)/i,bc=new RegExp("<(?:"+V+")[\\s/>]","i"),bd=/checked\s*(?:[^=]|=\s*.checked.)/i,be=/\/(java|ecma)script/i,bf=/^\s*<!(?:\[CDATA\[|\-\-)/,bg={option:[1,"<select multiple='multiple'>","</select>"],legend:[1,"<fieldset>","</fieldset>"],thead:[1,"<table>","</table>"],tr:[2,"<table><tbody>","</tbody></table>"],td:[3,"<table><tbody><tr>","</tr></tbody></table>"],col:[2,"<table><tbody></tbody><colgroup>","</colgroup></table>"],area:[1,"<map>","</map>"],_default:[0,"",""]},bh=U(c);bg.optgroup=bg.option,bg.tbody=bg.tfoot=bg.colgroup=bg.caption=bg.thead,bg.th=bg.td,f.support.htmlSerialize||(bg._default=[1,"div<div>","</div>"]),f.fn.extend({text:function(a){return f.access(this,function(a){return a===b?f.text(this):this.empty().append((this[0]&&this[0].ownerDocument||c).createTextNode(a))},null,a,arguments.length)},wrapAll:function(a){if(f.isFunction(a))return this.each(function(b){f(this).wrapAll(a.call(this,b))});if(this[0]){var b=f(a,this[0].ownerDocument).eq(0).clone(!0);this[0].parentNode&&b.insertBefore(this[0]),b.map(function(){var a=this;while(a.firstChild&&a.firstChild.nodeType===1)a=a.firstChild;return a}).append(this)}return this},wrapInner:function(a){if(f.isFunction(a))return this.each(function(b){f(this).wrapInner(a.call(this,b))});return this.each(function(){var b=f(this),c=b.contents();c.length?c.wrapAll(a):b.append(a)})},wrap:function(a){var b=f.isFunction(a);return this.each(function(c){f(this).wrapAll(b?a.call(this,c):a)})},unwrap:function(){return this.parent().each(function(){f.nodeName(this,"body")||f(this).replaceWith(this.childNodes)}).end()},append:function(){return this.domManip(arguments,!0,function(a){this.nodeType===1&&this.appendChild(a)})},prepend:function(){return this.domManip(arguments,!0,function(a){this.nodeType===1&&this.insertBefore(a,this.firstChild)})},before:function(){if(this[0]&&this[0].parentNode)return this.domManip(arguments,!1,function(a){this.parentNode.insertBefore(a,this)});if(arguments.length){var a=f -.clean(arguments);a.push.apply(a,this.toArray());return this.pushStack(a,"before",arguments)}},after:function(){if(this[0]&&this[0].parentNode)return this.domManip(arguments,!1,function(a){this.parentNode.insertBefore(a,this.nextSibling)});if(arguments.length){var a=this.pushStack(this,"after",arguments);a.push.apply(a,f.clean(arguments));return a}},remove:function(a,b){for(var c=0,d;(d=this[c])!=null;c++)if(!a||f.filter(a,[d]).length)!b&&d.nodeType===1&&(f.cleanData(d.getElementsByTagName("*")),f.cleanData([d])),d.parentNode&&d.parentNode.removeChild(d);return this},empty:function(){for(var a=0,b;(b=this[a])!=null;a++){b.nodeType===1&&f.cleanData(b.getElementsByTagName("*"));while(b.firstChild)b.removeChild(b.firstChild)}return this},clone:function(a,b){a=a==null?!1:a,b=b==null?a:b;return this.map(function(){return f.clone(this,a,b)})},html:function(a){return f.access(this,function(a){var c=this[0]||{},d=0,e=this.length;if(a===b)return c.nodeType===1?c.innerHTML.replace(W,""):null;if(typeof a=="string"&&!ba.test(a)&&(f.support.leadingWhitespace||!X.test(a))&&!bg[(Z.exec(a)||["",""])[1].toLowerCase()]){a=a.replace(Y,"<$1></$2>");try{for(;d<e;d++)c=this[d]||{},c.nodeType===1&&(f.cleanData(c.getElementsByTagName("*")),c.innerHTML=a);c=0}catch(g){}}c&&this.empty().append(a)},null,a,arguments.length)},replaceWith:function(a){if(this[0]&&this[0].parentNode){if(f.isFunction(a))return this.each(function(b){var c=f(this),d=c.html();c.replaceWith(a.call(this,b,d))});typeof a!="string"&&(a=f(a).detach());return this.each(function(){var b=this.nextSibling,c=this.parentNode;f(this).remove(),b?f(b).before(a):f(c).append(a)})}return this.length?this.pushStack(f(f.isFunction(a)?a():a),"replaceWith",a):this},detach:function(a){return this.remove(a,!0)},domManip:function(a,c,d){var e,g,h,i,j=a[0],k=[];if(!f.support.checkClone&&arguments.length===3&&typeof j=="string"&&bd.test(j))return this.each(function(){f(this).domManip(a,c,d,!0)});if(f.isFunction(j))return this.each(function(e){var g=f(this);a[0]=j.call(this,e,c?g.html():b),g.domManip(a,c,d)});if(this[0]){i=j&&j.parentNode,f.support.parentNode&&i&&i.nodeType===11&&i.childNodes.length===this.length?e={fragment:i}:e=f.buildFragment(a,this,k),h=e.fragment,h.childNodes.length===1?g=h=h.firstChild:g=h.firstChild;if(g){c=c&&f.nodeName(g,"tr");for(var l=0,m=this.length,n=m-1;l<m;l++)d.call(c?bi(this[l],g):this[l],e.cacheable||m>1&&l<n?f.clone(h,!0,!0):h)}k.length&&f.each(k,function(a,b){b.src?f.ajax({type:"GET",global:!1,url:b.src,async:!1,dataType:"script"}):f.globalEval((b.text||b.textContent||b.innerHTML||"").replace(bf,"/*$0*/")),b.parentNode&&b.parentNode.removeChild(b)})}return this}}),f.buildFragment=function(a,b,d){var e,g,h,i,j=a[0];b&&b[0]&&(i=b[0].ownerDocument||b[0]),i.createDocumentFragment||(i=c),a.length===1&&typeof j=="string"&&j.length<512&&i===c&&j.charAt(0)==="<"&&!bb.test(j)&&(f.support.checkClone||!bd.test(j))&&(f.support.html5Clone||!bc.test(j))&&(g=!0,h=f.fragments[j],h&&h!==1&&(e=h)),e||(e=i.createDocumentFragment(),f.clean(a,i,e,d)),g&&(f.fragments[j]=h?e:1);return{fragment:e,cacheable:g}},f.fragments={},f.each({appendTo:"append",prependTo:"prepend",insertBefore:"before",insertAfter:"after",replaceAll:"replaceWith"},function(a,b){f.fn[a]=function(c){var d=[],e=f(c),g=this.length===1&&this[0].parentNode;if(g&&g.nodeType===11&&g.childNodes.length===1&&e.length===1){e[b](this[0]);return this}for(var h=0,i=e.length;h<i;h++){var j=(h>0?this.clone(!0):this).get();f(e[h])[b](j),d=d.concat(j)}return this.pushStack(d,a,e.selector)}}),f.extend({clone:function(a,b,c){var d,e,g,h=f.support.html5Clone||f.isXMLDoc(a)||!bc.test("<"+a.nodeName+">")?a.cloneNode(!0):bo(a);if((!f.support.noCloneEvent||!f.support.noCloneChecked)&&(a.nodeType===1||a.nodeType===11)&&!f.isXMLDoc(a)){bk(a,h),d=bl(a),e=bl(h);for(g=0;d[g];++g)e[g]&&bk(d[g],e[g])}if(b){bj(a,h);if(c){d=bl(a),e=bl(h);for(g=0;d[g];++g)bj(d[g],e[g])}}d=e=null;return h},clean:function(a,b,d,e){var g,h,i,j=[];b=b||c,typeof b.createElement=="undefined"&&(b=b.ownerDocument||b[0]&&b[0].ownerDocument||c);for(var k=0,l;(l=a[k])!=null;k++){typeof l=="number"&&(l+="");if(!l)continue;if(typeof l=="string")if(!_.test(l))l=b.createTextNode(l);else{l=l.replace(Y,"<$1></$2>");var m=(Z.exec(l)||["",""])[1].toLowerCase(),n=bg[m]||bg._default,o=n[0],p=b.createElement("div"),q=bh.childNodes,r;b===c?bh.appendChild(p):U(b).appendChild(p),p.innerHTML=n[1]+l+n[2];while(o--)p=p.lastChild;if(!f.support.tbody){var s=$.test(l),t=m==="table"&&!s?p.firstChild&&p.firstChild.childNodes:n[1]==="<table>"&&!s?p.childNodes:[];for(i=t.length-1;i>=0;--i)f.nodeName(t[i],"tbody")&&!t[i].childNodes.length&&t[i].parentNode.removeChild(t[i])}!f.support.leadingWhitespace&&X.test(l)&&p.insertBefore(b.createTextNode(X.exec(l)[0]),p.firstChild),l=p.childNodes,p&&(p.parentNode.removeChild(p),q.length>0&&(r=q[q.length-1],r&&r.parentNode&&r.parentNode.removeChild(r)))}var u;if(!f.support.appendChecked)if(l[0]&&typeof (u=l.length)=="number")for(i=0;i<u;i++)bn(l[i]);else bn(l);l.nodeType?j.push(l):j=f.merge(j,l)}if(d){g=function(a){return!a.type||be.test(a.type)};for(k=0;j[k];k++){h=j[k];if(e&&f.nodeName(h,"script")&&(!h.type||be.test(h.type)))e.push(h.parentNode?h.parentNode.removeChild(h):h);else{if(h.nodeType===1){var v=f.grep(h.getElementsByTagName("script"),g);j.splice.apply(j,[k+1,0].concat(v))}d.appendChild(h)}}}return j},cleanData:function(a){var b,c,d=f.cache,e=f.event.special,g=f.support.deleteExpando;for(var h=0,i;(i=a[h])!=null;h++){if(i.nodeName&&f.noData[i.nodeName.toLowerCase()])continue;c=i[f.expando];if(c){b=d[c];if(b&&b.events){for(var j in b.events)e[j]?f.event.remove(i,j):f.removeEvent(i,j,b.handle);b.handle&&(b.handle.elem=null)}g?delete i[f.expando]:i.removeAttribute&&i.removeAttribute(f.expando),delete d[c]}}}});var bp=/alpha\([^)]*\)/i,bq=/opacity=([^)]*)/,br=/([A-Z]|^ms)/g,bs=/^[\-+]?(?:\d*\.)?\d+$/i,bt=/^-?(?:\d*\.)?\d+(?!px)[^\d\s]+$/i,bu=/^([\-+])=([\-+.\de]+)/,bv=/^margin/,bw={position:"absolute",visibility:"hidden",display:"block"},bx=["Top","Right","Bottom","Left"],by,bz,bA;f.fn.css=function(a,c){return f.access(this,function(a,c,d){return d!==b?f.style(a,c,d):f.css(a,c)},a,c,arguments.length>1)},f.extend({cssHooks:{opacity:{get:function(a,b){if(b){var c=by(a,"opacity");return c===""?"1":c}return a.style.opacity}}},cssNumber:{fillOpacity:!0,fontWeight:!0,lineHeight:!0,opacity:!0,orphans:!0,widows:!0,zIndex:!0,zoom:!0},cssProps:{"float":f.support.cssFloat?"cssFloat":"styleFloat"},style:function(a,c,d,e){if(!!a&&a.nodeType!==3&&a.nodeType!==8&&!!a.style){var g,h,i=f.camelCase(c),j=a.style,k=f.cssHooks[i];c=f.cssProps[i]||i;if(d===b){if(k&&"get"in k&&(g=k.get(a,!1,e))!==b)return g;return j[c]}h=typeof d,h==="string"&&(g=bu.exec(d))&&(d=+(g[1]+1)*+g[2]+parseFloat(f.css(a,c)),h="number");if(d==null||h==="number"&&isNaN(d))return;h==="number"&&!f.cssNumber[i]&&(d+="px");if(!k||!("set"in k)||(d=k.set(a,d))!==b)try{j[c]=d}catch(l){}}},css:function(a,c,d){var e,g;c=f.camelCase(c),g=f.cssHooks[c],c=f.cssProps[c]||c,c==="cssFloat"&&(c="float");if(g&&"get"in g&&(e=g.get(a,!0,d))!==b)return e;if(by)return by(a,c)},swap:function(a,b,c){var d={},e,f;for(f in b)d[f]=a.style[f],a.style[f]=b[f];e=c.call(a);for(f in b)a.style[f]=d[f];return e}}),f.curCSS=f.css,c.defaultView&&c.defaultView.getComputedStyle&&(bz=function(a,b){var c,d,e,g,h=a.style;b=b.replace(br,"-$1").toLowerCase(),(d=a.ownerDocument.defaultView)&&(e=d.getComputedStyle(a,null))&&(c=e.getPropertyValue(b),c===""&&!f.contains(a.ownerDocument.documentElement,a)&&(c=f.style(a,b))),!f.support.pixelMargin&&e&&bv.test(b)&&bt.test(c)&&(g=h.width,h.width=c,c=e.width,h.width=g);return c}),c.documentElement.currentStyle&&(bA=function(a,b){var c,d,e,f=a.currentStyle&&a.currentStyle[b],g=a.style;f==null&&g&&(e=g[b])&&(f=e),bt.test(f)&&(c=g.left,d=a.runtimeStyle&&a.runtimeStyle.left,d&&(a.runtimeStyle.left=a.currentStyle.left),g.left=b==="fontSize"?"1em":f,f=g.pixelLeft+"px",g.left=c,d&&(a.runtimeStyle.left=d));return f===""?"auto":f}),by=bz||bA,f.each(["height","width"],function(a,b){f.cssHooks[b]={get:function(a,c,d){if(c)return a.offsetWidth!==0?bB(a,b,d):f.swap(a,bw,function(){return bB(a,b,d)})},set:function(a,b){return bs.test(b)?b+"px":b}}}),f.support.opacity||(f.cssHooks.opacity={get:function(a,b){return bq.test((b&&a.currentStyle?a.currentStyle.filter:a.style.filter)||"")?parseFloat(RegExp.$1)/100+"":b?"1":""},set:function(a,b){var c=a.style,d=a.currentStyle,e=f.isNumeric(b)?"alpha(opacity="+b*100+")":"",g=d&&d.filter||c.filter||"";c.zoom=1;if(b>=1&&f.trim(g.replace(bp,""))===""){c.removeAttribute("filter");if(d&&!d.filter)return}c.filter=bp.test(g)?g.replace(bp,e):g+" "+e}}),f(function(){f.support.reliableMarginRight||(f.cssHooks.marginRight={get:function(a,b){return f.swap(a,{display:"inline-block"},function(){return b?by(a,"margin-right"):a.style.marginRight})}})}),f.expr&&f.expr.filters&&(f.expr.filters.hidden=function(a){var b=a.offsetWidth,c=a.offsetHeight;return b===0&&c===0||!f.support.reliableHiddenOffsets&&(a.style&&a.style.display||f.css(a,"display"))==="none"},f.expr.filters.visible=function(a){return!f.expr.filters.hidden(a)}),f.each({margin:"",padding:"",border:"Width"},function(a,b){f.cssHooks[a+b]={expand:function(c){var d,e=typeof c=="string"?c.split(" "):[c],f={};for(d=0;d<4;d++)f[a+bx[d]+b]=e[d]||e[d-2]||e[0];return f}}});var bC=/%20/g,bD=/\[\]$/,bE=/\r?\n/g,bF=/#.*$/,bG=/^(.*?):[ \t]*([^\r\n]*)\r?$/mg,bH=/^(?:color|date|datetime|datetime-local|email|hidden|month|number|password|range|search|tel|text|time|url|week)$/i,bI=/^(?:about|app|app\-storage|.+\-extension|file|res|widget):$/,bJ=/^(?:GET|HEAD)$/,bK=/^\/\//,bL=/\?/,bM=/<script\b[^<]*(?:(?!<\/script>)<[^<]*)*<\/script>/gi,bN=/^(?:select|textarea)/i,bO=/\s+/,bP=/([?&])_=[^&]*/,bQ=/^([\w\+\.\-]+:)(?:\/\/([^\/?#:]*)(?::(\d+))?)?/,bR=f.fn.load,bS={},bT={},bU,bV,bW=["*/"]+["*"];try{bU=e.href}catch(bX){bU=c.createElement("a"),bU.href="",bU=bU.href}bV=bQ.exec(bU.toLowerCase())||[],f.fn.extend({load:function(a,c,d){if(typeof a!="string"&&bR)return bR.apply(this,arguments);if(!this.length)return this;var e=a.indexOf(" ");if(e>=0){var g=a.slice(e,a.length);a=a.slice(0,e)}var h="GET";c&&(f.isFunction(c)?(d=c,c=b):typeof c=="object"&&(c=f.param(c,f.ajaxSettings.traditional),h="POST"));var i=this;f.ajax({url:a,type:h,dataType:"html",data:c,complete:function(a,b,c){c=a.responseText,a.isResolved()&&(a.done(function(a){c=a}),i.html(g?f("<div>").append(c.replace(bM,"")).find(g):c)),d&&i.each(d,[c,b,a])}});return this},serialize:function(){return f.param(this.serializeArray())},serializeArray:function(){return this.map(function(){return this.elements?f.makeArray(this.elements):this}).filter(function(){return this.name&&!this.disabled&&(this.checked||bN.test(this.nodeName)||bH.test(this.type))}).map(function(a,b){var c=f(this).val();return c==null?null:f.isArray(c)?f.map(c,function(a,c){return{name:b.name,value:a.replace(bE,"\r\n")}}):{name:b.name,value:c.replace(bE,"\r\n")}}).get()}}),f.each("ajaxStart ajaxStop ajaxComplete ajaxError ajaxSuccess ajaxSend".split(" "),function(a,b){f.fn[b]=function(a){return this.on(b,a)}}),f.each(["get","post"],function(a,c){f[c]=function(a,d,e,g){f.isFunction(d)&&(g=g||e,e=d,d=b);return f.ajax({type:c,url:a,data:d,success:e,dataType:g})}}),f.extend({getScript:function(a,c){return f.get(a,b,c,"script")},getJSON:function(a,b,c){return f.get(a,b,c,"json")},ajaxSetup:function(a,b){b?b$(a,f.ajaxSettings):(b=a,a=f.ajaxSettings),b$(a,b);return a},ajaxSettings:{url:bU,isLocal:bI.test(bV[1]),global:!0,type:"GET",contentType:"application/x-www-form-urlencoded; charset=UTF-8",processData:!0,async:!0,accepts:{xml:"application/xml, text/xml",html:"text/html",text:"text/plain",json:"application/json, text/javascript","*":bW},contents:{xml:/xml/,html:/html/,json:/json/},responseFields:{xml:"responseXML",text:"responseText"},converters:{"* text":a.String,"text html":!0,"text json":f.parseJSON,"text xml":f.parseXML},flatOptions:{context:!0,url:!0}},ajaxPrefilter:bY(bS),ajaxTransport:bY(bT),ajax:function(a,c){function w(a,c,l,m){if(s!==2){s=2,q&&clearTimeout(q),p=b,n=m||"",v.readyState=a>0?4:0;var o,r,u,w=c,x=l?ca(d,v,l):b,y,z;if(a>=200&&a<300||a===304){if(d.ifModified){if(y=v.getResponseHeader("Last-Modified"))f.lastModified[k]=y;if(z=v.getResponseHeader("Etag"))f.etag[k]=z}if(a===304)w="notmodified",o=!0;else try{r=cb(d,x),w="success",o=!0}catch(A){w="parsererror",u=A}}else{u=w;if(!w||a)w="error",a<0&&(a=0)}v.status=a,v.statusText=""+(c||w),o?h.resolveWith(e,[r,w,v]):h.rejectWith(e,[v,w,u]),v.statusCode(j),j=b,t&&g.trigger("ajax"+(o?"Success":"Error"),[v,d,o?r:u]),i.fireWith(e,[v,w]),t&&(g.trigger("ajaxComplete",[v,d]),--f.active||f.event.trigger("ajaxStop"))}}typeof a=="object"&&(c=a,a=b),c=c||{};var d=f.ajaxSetup({},c),e=d.context||d,g=e!==d&&(e.nodeType||e instanceof f)?f(e):f.event,h=f.Deferred(),i=f.Callbacks("once memory"),j=d.statusCode||{},k,l={},m={},n,o,p,q,r,s=0,t,u,v={readyState:0,setRequestHeader:function(a,b){if(!s){var c=a.toLowerCase();a=m[c]=m[c]||a,l[a]=b}return this},getAllResponseHeaders:function(){return s===2?n:null},getResponseHeader:function(a){var c;if(s===2){if(!o){o={};while(c=bG.exec(n))o[c[1].toLowerCase()]=c[2]}c=o[a.toLowerCase()]}return c===b?null:c},overrideMimeType:function(a){s||(d.mimeType=a);return this},abort:function(a){a=a||"abort",p&&p.abort(a),w(0,a);return this}};h.promise(v),v.success=v.done,v.error=v.fail,v.complete=i.add,v.statusCode=function(a){if(a){var b;if(s<2)for(b in a)j[b]=[j[b],a[b]];else b=a[v.status],v.then(b,b)}return this},d.url=((a||d.url)+"").replace(bF,"").replace(bK,bV[1]+"//"),d.dataTypes=f.trim(d.dataType||"*").toLowerCase().split(bO),d.crossDomain==null&&(r=bQ.exec(d.url.toLowerCase()),d.crossDomain=!(!r||r[1]==bV[1]&&r[2]==bV[2]&&(r[3]||(r[1]==="http:"?80:443))==(bV[3]||(bV[1]==="http:"?80:443)))),d.data&&d.processData&&typeof d.data!="string"&&(d.data=f.param(d.data,d.traditional)),bZ(bS,d,c,v);if(s===2)return!1;t=d.global,d.type=d.type.toUpperCase(),d.hasContent=!bJ.test(d.type),t&&f.active++===0&&f.event.trigger("ajaxStart");if(!d.hasContent){d.data&&(d.url+=(bL.test(d.url)?"&":"?")+d.data,delete d.data),k=d.url;if(d.cache===!1){var x=f.now(),y=d.url.replace(bP,"$1_="+x);d.url=y+(y===d.url?(bL.test(d.url)?"&":"?")+"_="+x:"")}}(d.data&&d.hasContent&&d.contentType!==!1||c.contentType)&&v.setRequestHeader("Content-Type",d.contentType),d.ifModified&&(k=k||d.url,f.lastModified[k]&&v.setRequestHeader("If-Modified-Since",f.lastModified[k]),f.etag[k]&&v.setRequestHeader("If-None-Match",f.etag[k])),v.setRequestHeader("Accept",d.dataTypes[0]&&d.accepts[d.dataTypes[0]]?d.accepts[d.dataTypes[0]]+(d.dataTypes[0]!=="*"?", "+bW+"; q=0.01":""):d.accepts["*"]);for(u in d.headers)v.setRequestHeader(u,d.headers[u]);if(d.beforeSend&&(d.beforeSend.call(e,v,d)===!1||s===2)){v.abort();return!1}for(u in{success:1,error:1,complete:1})v[u](d[u]);p=bZ(bT,d,c,v);if(!p)w(-1,"No Transport");else{v.readyState=1,t&&g.trigger("ajaxSend",[v,d]),d.async&&d.timeout>0&&(q=setTimeout(function(){v.abort("timeout")},d.timeout));try{s=1,p.send(l,w)}catch(z){if(s<2)w(-1,z);else throw z}}return v},param:function(a,c){var d=[],e=function(a,b){b=f.isFunction(b)?b():b,d[d.length]=encodeURIComponent(a)+"="+encodeURIComponent(b)};c===b&&(c=f.ajaxSettings.traditional);if(f.isArray(a)||a.jquery&&!f.isPlainObject(a))f.each(a,function(){e(this.name,this.value)});else for(var g in a)b_(g,a[g],c,e);return d.join("&").replace(bC,"+")}}),f.extend({active:0,lastModified:{},etag:{}});var cc=f.now(),cd=/(\=)\?(&|$)|\?\?/i;f.ajaxSetup({jsonp:"callback",jsonpCallback:function(){return f.expando+"_"+cc++}}),f.ajaxPrefilter("json jsonp",function(b,c,d){var e=typeof b.data=="string"&&/^application\/x\-www\-form\-urlencoded/.test(b.contentType);if(b.dataTypes[0]==="jsonp"||b.jsonp!==!1&&(cd.test(b.url)||e&&cd.test(b.data))){var g,h=b.jsonpCallback=f.isFunction(b.jsonpCallback)?b.jsonpCallback():b.jsonpCallback,i=a[h],j=b.url,k=b.data,l="$1"+h+"$2";b.jsonp!==!1&&(j=j.replace(cd,l),b.url===j&&(e&&(k=k.replace(cd,l)),b.data===k&&(j+=(/\?/.test(j)?"&":"?")+b.jsonp+"="+h))),b.url=j,b.data=k,a[h]=function(a){g=[a]},d.always(function(){a[h]=i,g&&f.isFunction(i)&&a[h](g[0])}),b.converters["script json"]=function(){g||f.error(h+" was not called");return g[0]},b.dataTypes[0]="json";return"script"}}),f.ajaxSetup({accepts:{script:"text/javascript, application/javascript, application/ecmascript, application/x-ecmascript"},contents:{script:/javascript|ecmascript/},converters:{"text script":function(a){f.globalEval(a);return a}}}),f.ajaxPrefilter("script",function(a){a.cache===b&&(a.cache=!1),a.crossDomain&&(a.type="GET",a.global=!1)}),f.ajaxTransport("script",function(a){if(a.crossDomain){var d,e=c.head||c.getElementsByTagName("head")[0]||c.documentElement;return{send:function(f,g){d=c.createElement("script"),d.async="async",a.scriptCharset&&(d.charset=a.scriptCharset),d.src=a.url,d.onload=d.onreadystatechange=function(a,c){if(c||!d.readyState||/loaded|complete/.test(d.readyState))d.onload=d.onreadystatechange=null,e&&d.parentNode&&e.removeChild(d),d=b,c||g(200,"success")},e.insertBefore(d,e.firstChild)},abort:function(){d&&d.onload(0,1)}}}});var ce=a.ActiveXObject?function(){for(var a in cg)cg[a](0,1)}:!1,cf=0,cg;f.ajaxSettings.xhr=a.ActiveXObject?function(){return!this.isLocal&&ch()||ci()}:ch,function(a){f.extend(f.support,{ajax:!!a,cors:!!a&&"withCredentials"in a})}(f.ajaxSettings.xhr()),f.support.ajax&&f.ajaxTransport(function(c){if(!c.crossDomain||f.support.cors){var d;return{send:function(e,g){var h=c.xhr(),i,j;c.username?h.open(c.type,c.url,c.async,c.username,c.password):h.open(c.type,c.url,c.async);if(c.xhrFields)for(j in c.xhrFields)h[j]=c.xhrFields[j];c.mimeType&&h.overrideMimeType&&h.overrideMimeType(c.mimeType),!c.crossDomain&&!e["X-Requested-With"]&&(e["X-Requested-With"]="XMLHttpRequest");try{for(j in e)h.setRequestHeader(j,e[j])}catch(k){}h.send(c.hasContent&&c.data||null),d=function(a,e){var j,k,l,m,n;try{if(d&&(e||h.readyState===4)){d=b,i&&(h.onreadystatechange=f.noop,ce&&delete cg[i]);if(e)h.readyState!==4&&h.abort();else{j=h.status,l=h.getAllResponseHeaders(),m={},n=h.responseXML,n&&n.documentElement&&(m.xml=n);try{m.text=h.responseText}catch(a){}try{k=h.statusText}catch(o){k=""}!j&&c.isLocal&&!c.crossDomain?j=m.text?200:404:j===1223&&(j=204)}}}catch(p){e||g(-1,p)}m&&g(j,k,m,l)},!c.async||h.readyState===4?d():(i=++cf,ce&&(cg||(cg={},f(a).unload(ce)),cg[i]=d),h.onreadystatechange=d)},abort:function(){d&&d(0,1)}}}});var cj={},ck,cl,cm=/^(?:toggle|show|hide)$/,cn=/^([+\-]=)?([\d+.\-]+)([a-z%]*)$/i,co,cp=[["height","marginTop","marginBottom","paddingTop","paddingBottom"],["width","marginLeft","marginRight","paddingLeft","paddingRight"],["opacity"]],cq;f.fn.extend({show:function(a,b,c){var d,e;if(a||a===0)return this.animate(ct("show",3),a,b,c);for(var g=0,h=this.length;g<h;g++)d=this[g],d.style&&(e=d.style.display,!f._data(d,"olddisplay")&&e==="none"&&(e=d.style.display=""),(e===""&&f.css(d,"display")==="none"||!f.contains(d.ownerDocument.documentElement,d))&&f._data(d,"olddisplay",cu(d.nodeName)));for(g=0;g<h;g++){d=this[g];if(d.style){e=d.style.display;if(e===""||e==="none")d.style.display=f._data(d,"olddisplay")||""}}return this},hide:function(a,b,c){if(a||a===0)return this.animate(ct("hide",3),a,b,c);var d,e,g=0,h=this.length;for(;g<h;g++)d=this[g],d.style&&(e=f.css(d,"display"),e!=="none"&&!f._data(d,"olddisplay")&&f._data(d,"olddisplay",e));for(g=0;g<h;g++)this[g].style&&(this[g].style.display="none");return this},_toggle:f.fn.toggle,toggle:function(a,b,c){var d=typeof a=="boolean";f.isFunction(a)&&f.isFunction(b)?this._toggle.apply(this,arguments):a==null||d?this.each(function(){var b=d?a:f(this).is(":hidden");f(this)[b?"show":"hide"]()}):this.animate(ct("toggle",3),a,b,c);return this},fadeTo:function(a,b,c,d){return this.filter(":hidden").css("opacity",0).show().end().animate({opacity:b},a,c,d)},animate:function(a,b,c,d){function g(){e.queue===!1&&f._mark(this);var b=f.extend({},e),c=this.nodeType===1,d=c&&f(this).is(":hidden"),g,h,i,j,k,l,m,n,o,p,q;b.animatedProperties={};for(i in a){g=f.camelCase(i),i!==g&&(a[g]=a[i],delete a[i]);if((k=f.cssHooks[g])&&"expand"in k){l=k.expand(a[g]),delete a[g];for(i in l)i in a||(a[i]=l[i])}}for(g in a){h=a[g],f.isArray(h)?(b.animatedProperties[g]=h[1],h=a[g]=h[0]):b.animatedProperties[g]=b.specialEasing&&b.specialEasing[g]||b.easing||"swing";if(h==="hide"&&d||h==="show"&&!d)return b.complete.call(this);c&&(g==="height"||g==="width")&&(b.overflow=[this.style.overflow,this.style.overflowX,this.style.overflowY],f.css(this,"display")==="inline"&&f.css(this,"float")==="none"&&(!f.support.inlineBlockNeedsLayout||cu(this.nodeName)==="inline"?this.style.display="inline-block":this.style.zoom=1))}b.overflow!=null&&(this.style.overflow="hidden");for(i in a)j=new f.fx(this,b,i),h=a[i],cm.test(h)?(q=f._data(this,"toggle"+i)||(h==="toggle"?d?"show":"hide":0),q?(f._data(this,"toggle"+i,q==="show"?"hide":"show"),j[q]()):j[h]()):(m=cn.exec(h),n=j.cur(),m?(o=parseFloat(m[2]),p=m[3]||(f.cssNumber[i]?"":"px"),p!=="px"&&(f.style(this,i,(o||1)+p),n=(o||1)/j.cur()*n,f.style(this,i,n+p)),m[1]&&(o=(m[1]==="-="?-1:1)*o+n),j.custom(n,o,p)):j.custom(n,h,""));return!0}var e=f.speed(b,c,d);if(f.isEmptyObject(a))return this.each(e.complete,[!1]);a=f.extend({},a);return e.queue===!1?this.each(g):this.queue(e.queue,g)},stop:function(a,c,d){typeof a!="string"&&(d=c,c=a,a=b),c&&a!==!1&&this.queue(a||"fx",[]);return this.each(function(){function h(a,b,c){var e=b[c];f.removeData(a,c,!0),e.stop(d)}var b,c=!1,e=f.timers,g=f._data(this);d||f._unmark(!0,this);if(a==null)for(b in g)g[b]&&g[b].stop&&b.indexOf(".run")===b.length-4&&h(this,g,b);else g[b=a+".run"]&&g[b].stop&&h(this,g,b);for(b=e.length;b--;)e[b].elem===this&&(a==null||e[b].queue===a)&&(d?e[b](!0):e[b].saveState(),c=!0,e.splice(b,1));(!d||!c)&&f.dequeue(this,a)})}}),f.each({slideDown:ct("show",1),slideUp:ct("hide",1),slideToggle:ct("toggle",1),fadeIn:{opacity:"show"},fadeOut:{opacity:"hide"},fadeToggle:{opacity:"toggle"}},function(a,b){f.fn[a]=function(a,c,d){return this.animate(b,a,c,d)}}),f.extend({speed:function(a,b,c){var d=a&&typeof a=="object"?f.extend({},a):{complete:c||!c&&b||f.isFunction(a)&&a,duration:a,easing:c&&b||b&&!f.isFunction(b)&&b};d.duration=f.fx.off?0:typeof d.duration=="number"?d.duration:d.duration in f.fx.speeds?f.fx.speeds[d.duration]:f.fx.speeds._default;if(d.queue==null||d.queue===!0)d.queue="fx";d.old=d.complete,d.complete=function(a){f.isFunction(d.old)&&d.old.call(this),d.queue?f.dequeue(this,d.queue):a!==!1&&f._unmark(this)};return d},easing:{linear:function(a){return a},swing:function(a){return-Math.cos(a*Math.PI)/2+.5}},timers:[],fx:function(a,b,c){this.options=b,this.elem=a,this.prop=c,b.orig=b.orig||{}}}),f.fx.prototype={update:function(){this.options.step&&this.options.step.call(this.elem,this.now,this),(f.fx.step[this.prop]||f.fx.step._default)(this)},cur:function(){if(this.elem[this.prop]!=null&&(!this.elem.style||this.elem.style[this.prop]==null))return this.elem[this.prop];var a,b=f.css(this.elem,this.prop);return isNaN(a=parseFloat(b))?!b||b==="auto"?0:b:a},custom:function(a,c,d){function h(a){return e.step(a)}var e=this,g=f.fx;this.startTime=cq||cr(),this.end=c,this.now=this.start=a,this.pos=this.state=0,this.unit=d||this.unit||(f.cssNumber[this.prop]?"":"px"),h.queue=this.options.queue,h.elem=this.elem,h.saveState=function(){f._data(e.elem,"fxshow"+e.prop)===b&&(e.options.hide?f._data(e.elem,"fxshow"+e.prop,e.start):e.options.show&&f._data(e.elem,"fxshow"+e.prop,e.end))},h()&&f.timers.push(h)&&!co&&(co=setInterval(g.tick,g.interval))},show:function(){var a=f._data(this.elem,"fxshow"+this.prop);this.options.orig[this.prop]=a||f.style(this.elem,this.prop),this.options.show=!0,a!==b?this.custom(this.cur(),a):this.custom(this.prop==="width"||this.prop==="height"?1:0,this.cur()),f(this.elem).show()},hide:function(){this.options.orig[this.prop]=f._data(this.elem,"fxshow"+this.prop)||f.style(this.elem,this.prop),this.options.hide=!0,this.custom(this.cur(),0)},step:function(a){var b,c,d,e=cq||cr(),g=!0,h=this.elem,i=this.options;if(a||e>=i.duration+this.startTime){this.now=this.end,this.pos=this.state=1,this.update(),i.animatedProperties[this.prop]=!0;for(b in i.animatedProperties)i.animatedProperties[b]!==!0&&(g=!1);if(g){i.overflow!=null&&!f.support.shrinkWrapBlocks&&f.each(["","X","Y"],function(a,b){h.style["overflow"+b]=i.overflow[a]}),i.hide&&f(h).hide();if(i.hide||i.show)for(b in i.animatedProperties)f.style(h,b,i.orig[b]),f.removeData(h,"fxshow"+b,!0),f.removeData(h,"toggle"+b,!0);d=i.complete,d&&(i.complete=!1,d.call(h))}return!1}i.duration==Infinity?this.now=e:(c=e-this.startTime,this.state=c/i.duration,this.pos=f.easing[i.animatedProperties[this.prop]](this.state,c,0,1,i.duration),this.now=this.start+(this.end-this.start)*this.pos),this.update();return!0}},f.extend(f.fx,{tick:function(){var a,b=f.timers,c=0;for(;c<b.length;c++)a=b[c],!a()&&b[c]===a&&b.splice(c--,1);b.length||f.fx.stop()},interval:13,stop:function(){clearInterval(co),co=null},speeds:{slow:600,fast:200,_default:400},step:{opacity:function(a){f.style(a.elem,"opacity",a.now)},_default:function(a){a.elem.style&&a.elem.style[a.prop]!=null?a.elem.style[a.prop]=a.now+a.unit:a.elem[a.prop]=a.now}}}),f.each(cp.concat.apply([],cp),function(a,b){b.indexOf("margin")&&(f.fx.step[b]=function(a){f.style(a.elem,b,Math.max(0,a.now)+a.unit)})}),f.expr&&f.expr.filters&&(f.expr.filters.animated=function(a){return f.grep(f.timers,function(b){return a===b.elem}).length});var cv,cw=/^t(?:able|d|h)$/i,cx=/^(?:body|html)$/i;"getBoundingClientRect"in c.documentElement?cv=function(a,b,c,d){try{d=a.getBoundingClientRect()}catch(e){}if(!d||!f.contains(c,a))return d?{top:d.top,left:d.left}:{top:0,left:0};var g=b.body,h=cy(b),i=c.clientTop||g.clientTop||0,j=c.clientLeft||g.clientLeft||0,k=h.pageYOffset||f.support.boxModel&&c.scrollTop||g.scrollTop,l=h.pageXOffset||f.support.boxModel&&c.scrollLeft||g.scrollLeft,m=d.top+k-i,n=d.left+l-j;return{top:m,left:n}}:cv=function(a,b,c){var d,e=a.offsetParent,g=a,h=b.body,i=b.defaultView,j=i?i.getComputedStyle(a,null):a.currentStyle,k=a.offsetTop,l=a.offsetLeft;while((a=a.parentNode)&&a!==h&&a!==c){if(f.support.fixedPosition&&j.position==="fixed")break;d=i?i.getComputedStyle(a,null):a.currentStyle,k-=a.scrollTop,l-=a.scrollLeft,a===e&&(k+=a.offsetTop,l+=a.offsetLeft,f.support.doesNotAddBorder&&(!f.support.doesAddBorderForTableAndCells||!cw.test(a.nodeName))&&(k+=parseFloat(d.borderTopWidth)||0,l+=parseFloat(d.borderLeftWidth)||0),g=e,e=a.offsetParent),f.support.subtractsBorderForOverflowNotVisible&&d.overflow!=="visible"&&(k+=parseFloat(d.borderTopWidth)||0,l+=parseFloat(d.borderLeftWidth)||0),j=d}if(j.position==="relative"||j.position==="static")k+=h.offsetTop,l+=h.offsetLeft;f.support.fixedPosition&&j.position==="fixed"&&(k+=Math.max(c.scrollTop,h.scrollTop),l+=Math.max(c.scrollLeft,h.scrollLeft));return{top:k,left:l}},f.fn.offset=function(a){if(arguments.length)return a===b?this:this.each(function(b){f.offset.setOffset(this,a,b)});var c=this[0],d=c&&c.ownerDocument;if(!d)return null;if(c===d.body)return f.offset.bodyOffset(c);return cv(c,d,d.documentElement)},f.offset={bodyOffset:function(a){var b=a.offsetTop,c=a.offsetLeft;f.support.doesNotIncludeMarginInBodyOffset&&(b+=parseFloat(f.css(a,"marginTop"))||0,c+=parseFloat(f.css(a,"marginLeft"))||0);return{top:b,left:c}},setOffset:function(a,b,c){var d=f.css(a,"position");d==="static"&&(a.style.position="relative");var e=f(a),g=e.offset(),h=f.css(a,"top"),i=f.css(a,"left"),j=(d==="absolute"||d==="fixed")&&f.inArray("auto",[h,i])>-1,k={},l={},m,n;j?(l=e.position(),m=l.top,n=l.left):(m=parseFloat(h)||0,n=parseFloat(i)||0),f.isFunction(b)&&(b=b.call(a,c,g)),b.top!=null&&(k.top=b.top-g.top+m),b.left!=null&&(k.left=b.left-g.left+n),"using"in b?b.using.call(a,k):e.css(k)}},f.fn.extend({position:function(){if(!this[0])return null;var a=this[0],b=this.offsetParent(),c=this.offset(),d=cx.test(b[0].nodeName)?{top:0,left:0}:b.offset();c.top-=parseFloat(f.css(a,"marginTop"))||0,c.left-=parseFloat(f.css(a,"marginLeft"))||0,d.top+=parseFloat(f.css(b[0],"borderTopWidth"))||0,d.left+=parseFloat(f.css(b[0],"borderLeftWidth"))||0;return{top:c.top-d.top,left:c.left-d.left}},offsetParent:function(){return this.map(function(){var a=this.offsetParent||c.body;while(a&&!cx.test(a.nodeName)&&f.css(a,"position")==="static")a=a.offsetParent;return a})}}),f.each({scrollLeft:"pageXOffset",scrollTop:"pageYOffset"},function(a,c){var d=/Y/.test(c);f.fn[a]=function(e){return f.access(this,function(a,e,g){var h=cy(a);if(g===b)return h?c in h?h[c]:f.support.boxModel&&h.document.documentElement[e]||h.document.body[e]:a[e];h?h.scrollTo(d?f(h).scrollLeft():g,d?g:f(h).scrollTop()):a[e]=g},a,e,arguments.length,null)}}),f.each({Height:"height",Width:"width"},function(a,c){var d="client"+a,e="scroll"+a,g="offset"+a;f.fn["inner"+a]=function(){var a=this[0];return a?a.style?parseFloat(f.css(a,c,"padding")):this[c]():null},f.fn["outer"+a]=function(a){var b=this[0];return b?b.style?parseFloat(f.css(b,c,a?"margin":"border")):this[c]():null},f.fn[c]=function(a){return f.access(this,function(a,c,h){var i,j,k,l;if(f.isWindow(a)){i=a.document,j=i.documentElement[d];return f.support.boxModel&&j||i.body&&i.body[d]||j}if(a.nodeType===9){i=a.documentElement;if(i[d]>=i[e])return i[d];return Math.max(a.body[e],i[e],a.body[g],i[g])}if(h===b){k=f.css(a,c),l=parseFloat(k);return f.isNumeric(l)?l:k}f(a).css(c,h)},c,a,arguments.length,null)}}),a.jQuery=a.$=f,typeof define=="function"&&define.amd&&define.amd.jQuery&&define("jquery",[],function(){return f})})(window);
\ No newline at end of file diff --git a/app/assets/javascripts/jquery_ujs.js b/app/assets/javascripts/jquery_ujs.js deleted file mode 100644 index 50121d6ed..000000000 --- a/app/assets/javascripts/jquery_ujs.js +++ /dev/null @@ -1,393 +0,0 @@ -(function($, undefined) { - -/** - * Unobtrusive scripting adapter for jQuery - * https://github.com/rails/jquery-ujs - * - * Requires jQuery 1.7.0 or later. - * - * Released under the MIT license - * - */ - - // Cut down on the number of issues from people inadvertently including jquery_ujs twice - // by detecting and raising an error when it happens. - if ( $.rails !== undefined ) { - $.error('jquery-ujs has already been loaded!'); - } - - // Shorthand to make it a little easier to call public rails functions from within rails.js - var rails; - - $.rails = rails = { - // Link elements bound by jquery-ujs - linkClickSelector: 'a[data-confirm], a[data-method], a[data-remote], a[data-disable-with]', - - // Button elements boud jquery-ujs - buttonClickSelector: 'button[data-remote]', - - // Select elements bound by jquery-ujs - inputChangeSelector: 'select[data-remote], input[data-remote], textarea[data-remote]', - - // Form elements bound by jquery-ujs - formSubmitSelector: 'form', - - // Form input elements bound by jquery-ujs - formInputClickSelector: 'form input[type=submit], form input[type=image], form button[type=submit], form button:not([type])', - - // Form input elements disabled during form submission - disableSelector: 'input[data-disable-with], button[data-disable-with], textarea[data-disable-with]', - - // Form input elements re-enabled after form submission - enableSelector: 'input[data-disable-with]:disabled, button[data-disable-with]:disabled, textarea[data-disable-with]:disabled', - - // Form required input elements - requiredInputSelector: 'input[name][required]:not([disabled]),textarea[name][required]:not([disabled])', - - // Form file input elements - fileInputSelector: 'input[type=file]', - - // Link onClick disable selector with possible reenable after remote submission - linkDisableSelector: 'a[data-disable-with]', - - // Make sure that every Ajax request sends the CSRF token - CSRFProtection: function(xhr) { - var token = $('meta[name="csrf-token"]').attr('content'); - if (token) xhr.setRequestHeader('X-CSRF-Token', token); - }, - - // Triggers an event on an element and returns false if the event result is false - fire: function(obj, name, data) { - var event = $.Event(name); - obj.trigger(event, data); - return event.result !== false; - }, - - // Default confirm dialog, may be overridden with custom confirm dialog in $.rails.confirm - confirm: function(message) { - return confirm(message); - }, - - // Default ajax function, may be overridden with custom function in $.rails.ajax - ajax: function(options) { - return $.ajax(options); - }, - - // Default way to get an element's href. May be overridden at $.rails.href. - href: function(element) { - return element.attr('href'); - }, - - // Submits "remote" forms and links with ajax - handleRemote: function(element) { - var method, url, data, elCrossDomain, crossDomain, withCredentials, dataType, options; - - if (rails.fire(element, 'ajax:before')) { - elCrossDomain = element.data('cross-domain'); - crossDomain = elCrossDomain === undefined ? null : elCrossDomain; - withCredentials = element.data('with-credentials') || null; - dataType = element.data('type') || ($.ajaxSettings && $.ajaxSettings.dataType); - - if (element.is('form')) { - method = element.attr('method'); - url = element.attr('action'); - data = element.serializeArray(); - // memoized value from clicked submit button - var button = element.data('ujs:submit-button'); - if (button) { - data.push(button); - element.data('ujs:submit-button', null); - } - } else if (element.is(rails.inputChangeSelector)) { - method = element.data('method'); - url = element.data('url'); - data = element.serialize(); - if (element.data('params')) data = data + "&" + element.data('params'); - } else if (element.is(rails.buttonClickSelector)) { - method = element.data('method') || 'get'; - url = element.data('url'); - data = element.serialize(); - if (element.data('params')) data = data + "&" + element.data('params'); - } else { - method = element.data('method'); - url = rails.href(element); - data = element.data('params') || null; - } - - options = { - type: method || 'GET', data: data, dataType: dataType, - // stopping the "ajax:beforeSend" event will cancel the ajax request - beforeSend: function(xhr, settings) { - if (settings.dataType === undefined) { - xhr.setRequestHeader('accept', '*/*;q=0.5, ' + settings.accepts.script); - } - return rails.fire(element, 'ajax:beforeSend', [xhr, settings]); - }, - success: function(data, status, xhr) { - element.trigger('ajax:success', [data, status, xhr]); - }, - complete: function(xhr, status) { - element.trigger('ajax:complete', [xhr, status]); - }, - error: function(xhr, status, error) { - element.trigger('ajax:error', [xhr, status, error]); - }, - crossDomain: crossDomain - }; - - // There is no withCredentials for IE6-8 when - // "Enable native XMLHTTP support" is disabled - if (withCredentials) { - options.xhrFields = { - withCredentials: withCredentials - }; - } - - // Only pass url to `ajax` options if not blank - if (url) { options.url = url; } - - var jqxhr = rails.ajax(options); - element.trigger('ajax:send', jqxhr); - return jqxhr; - } else { - return false; - } - }, - - // Handles "data-method" on links such as: - // <a href="/users/5" data-method="delete" rel="nofollow" data-confirm="Are you sure?">Delete</a> - handleMethod: function(link) { - var href = rails.href(link), - method = link.data('method'), - target = link.attr('target'), - csrf_token = $('meta[name=csrf-token]').attr('content'), - csrf_param = $('meta[name=csrf-param]').attr('content'), - form = $('<form method="post" action="' + href + '"></form>'), - metadata_input = '<input name="_method" value="' + method + '" type="hidden" />'; - - if (csrf_param !== undefined && csrf_token !== undefined) { - metadata_input += '<input name="' + csrf_param + '" value="' + csrf_token + '" type="hidden" />'; - } - - if (target) { form.attr('target', target); } - - form.hide().append(metadata_input).appendTo('body'); - form.submit(); - }, - - /* Disables form elements: - - Caches element value in 'ujs:enable-with' data store - - Replaces element text with value of 'data-disable-with' attribute - - Sets disabled property to true - */ - disableFormElements: function(form) { - form.find(rails.disableSelector).each(function() { - var element = $(this), method = element.is('button') ? 'html' : 'val'; - element.data('ujs:enable-with', element[method]()); - element[method](element.data('disable-with')); - element.prop('disabled', true); - }); - }, - - /* Re-enables disabled form elements: - - Replaces element text with cached value from 'ujs:enable-with' data store (created in `disableFormElements`) - - Sets disabled property to false - */ - enableFormElements: function(form) { - form.find(rails.enableSelector).each(function() { - var element = $(this), method = element.is('button') ? 'html' : 'val'; - if (element.data('ujs:enable-with')) element[method](element.data('ujs:enable-with')); - element.prop('disabled', false); - }); - }, - - /* For 'data-confirm' attribute: - - Fires `confirm` event - - Shows the confirmation dialog - - Fires the `confirm:complete` event - - Returns `true` if no function stops the chain and user chose yes; `false` otherwise. - Attaching a handler to the element's `confirm` event that returns a `falsy` value cancels the confirmation dialog. - Attaching a handler to the element's `confirm:complete` event that returns a `falsy` value makes this function - return false. The `confirm:complete` event is fired whether or not the user answered true or false to the dialog. - */ - allowAction: function(element) { - var message = element.data('confirm'), - answer = false, callback; - if (!message) { return true; } - - if (rails.fire(element, 'confirm')) { - answer = rails.confirm(message); - callback = rails.fire(element, 'confirm:complete', [answer]); - } - return answer && callback; - }, - - // Helper function which checks for blank inputs in a form that match the specified CSS selector - blankInputs: function(form, specifiedSelector, nonBlank) { - var inputs = $(), input, valueToCheck, - selector = specifiedSelector || 'input,textarea', - allInputs = form.find(selector); - - allInputs.each(function() { - input = $(this); - valueToCheck = input.is('input[type=checkbox],input[type=radio]') ? input.is(':checked') : input.val(); - // If nonBlank and valueToCheck are both truthy, or nonBlank and valueToCheck are both falsey - if (!valueToCheck === !nonBlank) { - - // Don't count unchecked required radio if other radio with same name is checked - if (input.is('input[type=radio]') && allInputs.filter('input[type=radio]:checked[name="' + input.attr('name') + '"]').length) { - return true; // Skip to next input - } - - inputs = inputs.add(input); - } - }); - return inputs.length ? inputs : false; - }, - - // Helper function which checks for non-blank inputs in a form that match the specified CSS selector - nonBlankInputs: function(form, specifiedSelector) { - return rails.blankInputs(form, specifiedSelector, true); // true specifies nonBlank - }, - - // Helper function, needed to provide consistent behavior in IE - stopEverything: function(e) { - $(e.target).trigger('ujs:everythingStopped'); - e.stopImmediatePropagation(); - return false; - }, - - // replace element's html with the 'data-disable-with' after storing original html - // and prevent clicking on it - disableElement: function(element) { - element.data('ujs:enable-with', element.html()); // store enabled state - element.html(element.data('disable-with')); // set to disabled state - element.bind('click.railsDisable', function(e) { // prevent further clicking - return rails.stopEverything(e); - }); - }, - - // restore element to its original state which was disabled by 'disableElement' above - enableElement: function(element) { - if (element.data('ujs:enable-with') !== undefined) { - element.html(element.data('ujs:enable-with')); // set to old enabled state - element.removeData('ujs:enable-with'); // clean up cache - } - element.unbind('click.railsDisable'); // enable element - } - - }; - - if (rails.fire($(document), 'rails:attachBindings')) { - - $.ajaxPrefilter(function(options, originalOptions, xhr){ if ( !options.crossDomain ) { rails.CSRFProtection(xhr); }}); - - $(document).delegate(rails.linkDisableSelector, 'ajax:complete', function() { - rails.enableElement($(this)); - }); - - $(document).delegate(rails.linkClickSelector, 'click.rails', function(e) { - var link = $(this), method = link.data('method'), data = link.data('params'); - if (!rails.allowAction(link)) return rails.stopEverything(e); - - if (link.is(rails.linkDisableSelector)) rails.disableElement(link); - - if (link.data('remote') !== undefined) { - if ( (e.metaKey || e.ctrlKey) && (!method || method === 'GET') && !data ) { return true; } - - var handleRemote = rails.handleRemote(link); - // response from rails.handleRemote() will either be false or a deferred object promise. - if (handleRemote === false) { - rails.enableElement(link); - } else { - handleRemote.error( function() { rails.enableElement(link); } ); - } - return false; - - } else if (link.data('method')) { - rails.handleMethod(link); - return false; - } - }); - - $(document).delegate(rails.buttonClickSelector, 'click.rails', function(e) { - var button = $(this); - if (!rails.allowAction(button)) return rails.stopEverything(e); - - rails.handleRemote(button); - return false; - }); - - $(document).delegate(rails.inputChangeSelector, 'change.rails', function(e) { - var link = $(this); - if (!rails.allowAction(link)) return rails.stopEverything(e); - - rails.handleRemote(link); - return false; - }); - - $(document).delegate(rails.formSubmitSelector, 'submit.rails', function(e) { - var form = $(this), - remote = form.data('remote') !== undefined, - blankRequiredInputs = rails.blankInputs(form, rails.requiredInputSelector), - nonBlankFileInputs = rails.nonBlankInputs(form, rails.fileInputSelector); - - if (!rails.allowAction(form)) return rails.stopEverything(e); - - // skip other logic when required values are missing or file upload is present - if (blankRequiredInputs && form.attr("novalidate") == undefined && rails.fire(form, 'ajax:aborted:required', [blankRequiredInputs])) { - return rails.stopEverything(e); - } - - if (remote) { - if (nonBlankFileInputs) { - // slight timeout so that the submit button gets properly serialized - // (make it easy for event handler to serialize form without disabled values) - setTimeout(function(){ rails.disableFormElements(form); }, 13); - var aborted = rails.fire(form, 'ajax:aborted:file', [nonBlankFileInputs]); - - // re-enable form elements if event bindings return false (canceling normal form submission) - if (!aborted) { setTimeout(function(){ rails.enableFormElements(form); }, 13); } - - return aborted; - } - - rails.handleRemote(form); - return false; - - } else { - // slight timeout so that the submit button gets properly serialized - setTimeout(function(){ rails.disableFormElements(form); }, 13); - } - }); - - $(document).delegate(rails.formInputClickSelector, 'click.rails', function(event) { - var button = $(this); - - if (!rails.allowAction(button)) return rails.stopEverything(event); - - // register the pressed submit button - var name = button.attr('name'), - data = name ? {name:name, value:button.val()} : null; - - button.closest('form').data('ujs:submit-button', data); - }); - - $(document).delegate(rails.formSubmitSelector, 'ajax:beforeSend.rails', function(event) { - if (this == event.target) rails.disableFormElements($(this)); - }); - - $(document).delegate(rails.formSubmitSelector, 'ajax:complete.rails', function(event) { - if (this == event.target) rails.enableFormElements($(this)); - }); - - $(function(){ - // making sure that all forms have actual up-to-date token(cached forms contain old one) - var csrf_token = $('meta[name=csrf-token]').attr('content'); - var csrf_param = $('meta[name=csrf-param]').attr('content'); - $('form input[name="' + csrf_param + '"]').val(csrf_token); - }); - } - -})( jQuery ); diff --git a/app/assets/javascripts/profile-photos.js b/app/assets/javascripts/profile-photos.js index c7ebe894d..2f6d067ee 100644 --- a/app/assets/javascripts/profile-photos.js +++ b/app/assets/javascripts/profile-photos.js @@ -1,3 +1,3 @@ // ... -//= require jquery.Jcrop +//= require jquery.Jcrop.min //= require profile_photo diff --git a/app/assets/javascripts/profile_photo.js b/app/assets/javascripts/profile_photo.js index 6d637b439..b0bb25e76 100644 --- a/app/assets/javascripts/profile_photo.js +++ b/app/assets/javascripts/profile_photo.js @@ -1,49 +1,59 @@ -// Remember to invoke within jQuery(window).load(...) -// If you don't, Jcrop may not initialize properly -jQuery(window).load(function(){ - // The size of the initial selection (largest, centreted rectangle) - var w = jQuery('#profile_photo_cropbox').width(); - var h = jQuery('#profile_photo_cropbox').height(); - var t = 0; - var l = 0; - var initial; - if (h < w) { - initial = h; - l = (w - initial) / 2; - } else { - initial = w; - t = (h - initial) / 2; - } - - jQuery('#profile_photo_cropbox').Jcrop({ - onChange: showPreview, - onSelect: showPreview, - aspectRatio: 1, - setSelect: [ l, t, initial, initial ] - }); +(function($) { + + $(function(){ + + // The size of the initial selection (largest, centreted rectangle) + var w = jQuery('#profile_photo_cropbox').width(); + var h = jQuery('#profile_photo_cropbox').height(); + var t = 0; + var l = 0; + var initial; + if (h < w) { + initial = h; + l = (w - initial) / 2; + } else { + initial = w; + t = (h - initial) / 2; + } -}); - -// Our simple event handler, called from onChange and onSelect -// event handlers, as per the Jcrop invocation above -function showPreview(coords) -{ - if (parseInt(coords.w) > 0) - { - var rx = 100 / coords.w; - var ry = 100 / coords.h; - - jQuery('#profile_photo_preview').css({ - width: Math.round(rx * jQuery('#profile_photo_cropbox').width()) + 'px', - height: Math.round(ry * jQuery('#profile_photo_cropbox').height()) + 'px', - marginLeft: '-' + Math.round(rx * coords.x) + 'px', - marginTop: '-' + Math.round(ry * coords.y) + 'px' + var jcrop_api; + var bounds, boundx, boundy; + + $('#profile_photo_cropbox').Jcrop({ + onChange: showPreview, + onSelect: showPreview, + aspectRatio: 1 + },function(){ + jcrop_api = this; + bounds = jcrop_api.getBounds(); + boundx = bounds[0]; + boundy = bounds[1]; }); - $('#x').val(coords.x); - $('#y').val(coords.y); - $('#w').val(coords.w); - $('#h').val(coords.h); - } -} + jcrop_api.setSelect([ l, t, initial, initial ]); + + function showPreview(coords) + { + if (parseInt(coords.w) > 0) + { + var rx = 100 / coords.w; + var ry = 100 / coords.h; + + $('#profile_photo_preview').css({ + width: Math.round(rx * boundx) + 'px', + height: Math.round(ry * boundy) + 'px', + marginLeft: '-' + Math.round(rx * coords.x) + 'px', + marginTop: '-' + Math.round(ry * coords.y) + 'px' + }); + + $('#x').val(coords.x); + $('#y').val(coords.y); + $('#w').val(coords.w); + $('#h').val(coords.h); + } + }; + + }); + +}(jQuery)); diff --git a/app/assets/stylesheets/jquery-ui-1.8.15.custom.css b/app/assets/stylesheets/jquery-ui-1.8.15.custom.css deleted file mode 100755 index 386d854ff..000000000 --- a/app/assets/stylesheets/jquery-ui-1.8.15.custom.css +++ /dev/null @@ -1,375 +0,0 @@ -/* - * jQuery UI CSS Framework 1.8.16 - * - * Copyright 2011, AUTHORS.txt (http://jqueryui.com/about) - * Dual licensed under the MIT or GPL Version 2 licenses. - * http://jquery.org/license - * - * http://docs.jquery.com/UI/Theming/API - */ - -/* Layout helpers -----------------------------------*/ -.ui-helper-hidden { display: none; } -.ui-helper-hidden-accessible { position: absolute !important; clip: rect(1px 1px 1px 1px); clip: rect(1px,1px,1px,1px); } -.ui-helper-reset { margin: 0; padding: 0; border: 0; outline: 0; line-height: 1.3; text-decoration: none; font-size: 100%; list-style: none; } -.ui-helper-clearfix:after { content: "."; display: block; height: 0; clear: both; visibility: hidden; } -.ui-helper-clearfix { display: inline-block; } -/* required comment for clearfix to work in Opera \*/ -* html .ui-helper-clearfix { height:1%; } -.ui-helper-clearfix { display:block; } -/* end clearfix */ -.ui-helper-zfix { width: 100%; height: 100%; top: 0; left: 0; position: absolute; opacity: 0; filter:Alpha(Opacity=0); } - - -/* Interaction Cues -----------------------------------*/ -.ui-state-disabled { cursor: default !important; } - - -/* Icons -----------------------------------*/ - -/* states and images */ -.ui-icon { display: block; text-indent: -99999px; overflow: hidden; background-repeat: no-repeat; } - - -/* Misc visuals -----------------------------------*/ - -/* Overlays */ -.ui-widget-overlay { position: absolute; top: 0; left: 0; width: 100%; height: 100%; } - - -/* - * jQuery UI CSS Framework 1.8.16 - * - * Copyright 2011, AUTHORS.txt (http://jqueryui.com/about) - * Dual licensed under the MIT or GPL Version 2 licenses. - * http://jquery.org/license - * - * http://docs.jquery.com/UI/Theming/API - * - * To view and modify this theme, visit http://jqueryui.com/themeroller/?ffDefault=Verdana,Arial,sans-serif&fwDefault=normal&fsDefault=&cornerRadius=4px&bgColorHeader=cccccc&bgTextureHeader=01_flat.png&bgImgOpacityHeader=75&borderColorHeader=aaaaaa&fcHeader=222222&iconColorHeader=222222&bgColorContent=ffffff&bgTextureContent=01_flat.png&bgImgOpacityContent=75&borderColorContent=aaaaaa&fcContent=222222&iconColorContent=222222&bgColorDefault=e6e6e6&bgTextureDefault=01_flat.png&bgImgOpacityDefault=75&borderColorDefault=d3d3d3&fcDefault=555555&iconColorDefault=888888&bgColorHover=dadada&bgTextureHover=01_flat.png&bgImgOpacityHover=75&borderColorHover=999999&fcHover=212121&iconColorHover=454545&bgColorActive=ffffff&bgTextureActive=01_flat.png&bgImgOpacityActive=65&borderColorActive=aaaaaa&fcActive=212121&iconColorActive=454545&bgColorHighlight=fbf9ee&bgTextureHighlight=01_flat.png&bgImgOpacityHighlight=55&borderColorHighlight=fcefa1&fcHighlight=363636&iconColorHighlight=2e83ff&bgColorError=fef1ec&bgTextureError=01_flat.png&bgImgOpacityError=95&borderColorError=cd0a0a&fcError=cd0a0a&iconColorError=cd0a0a&bgColorOverlay=aaaaaa&bgTextureOverlay=01_flat.png&bgImgOpacityOverlay=0&opacityOverlay=30&bgColorShadow=aaaaaa&bgTextureShadow=01_flat.png&bgImgOpacityShadow=0&opacityShadow=30&thicknessShadow=8px&offsetTopShadow=-8px&offsetLeftShadow=-8px&cornerRadiusShadow=8px - */ - - -/* Component containers -----------------------------------*/ -.ui-widget { font-family: Verdana,Arial,sans-serif; } -.ui-widget .ui-widget { font-size: 1em; } -.ui-widget input, .ui-widget select, .ui-widget textarea, .ui-widget button { font-family: Verdana,Arial,sans-serif; font-size: 1em; } -.ui-widget-content { border: 1px solid #aaaaaa; background: #ffffff url(images/ui-bg_flat_75_ffffff_40x100.png) 50% 50% repeat-x; color: #222222; } -.ui-widget-content a { color: #222222; } -.ui-widget-header { border: 1px solid #aaaaaa; background: #cccccc url(images/ui-bg_flat_75_cccccc_40x100.png) 50% 50% repeat-x; color: #222222; font-weight: bold; } -.ui-widget-header a { color: #222222; } - -/* Interaction states -----------------------------------*/ -.ui-state-default, .ui-widget-content .ui-state-default, .ui-widget-header .ui-state-default { border: 1px solid #d3d3d3; background: #e6e6e6 url(images/ui-bg_flat_75_e6e6e6_40x100.png) 50% 50% repeat-x; font-weight: normal; color: #555555; } -.ui-state-default a, .ui-state-default a:link, .ui-state-default a:visited { color: #555555; text-decoration: none; } -.ui-state-hover, .ui-widget-content .ui-state-hover, .ui-widget-header .ui-state-hover, .ui-state-focus, .ui-widget-content .ui-state-focus, .ui-widget-header .ui-state-focus { border: 1px solid #999999; background: #dadada url(images/ui-bg_flat_75_dadada_40x100.png) 50% 50% repeat-x; font-weight: normal; color: #212121; } -.ui-state-hover a, .ui-state-hover a:hover { color: #212121; text-decoration: none; } -.ui-state-active, .ui-widget-content .ui-state-active, .ui-widget-header .ui-state-active { border: 1px solid #aaaaaa; background: #ffffff url(images/ui-bg_flat_65_ffffff_40x100.png) 50% 50% repeat-x; font-weight: normal; color: #212121; } -.ui-state-active a, .ui-state-active a:link, .ui-state-active a:visited { color: #212121; text-decoration: none; } -.ui-widget :active { outline: none; } - -/* Interaction Cues -----------------------------------*/ -.ui-state-highlight, .ui-widget-content .ui-state-highlight, .ui-widget-header .ui-state-highlight {border: 1px solid #fcefa1; background: #fbf9ee url(images/ui-bg_flat_55_fbf9ee_40x100.png) 50% 50% repeat-x; color: #363636; } -.ui-state-highlight a, .ui-widget-content .ui-state-highlight a,.ui-widget-header .ui-state-highlight a { color: #363636; } -.ui-state-error, .ui-widget-content .ui-state-error, .ui-widget-header .ui-state-error {border: 1px solid #cd0a0a; background: #fef1ec url(images/ui-bg_flat_95_fef1ec_40x100.png) 50% 50% repeat-x; color: #cd0a0a; } -.ui-state-error a, .ui-widget-content .ui-state-error a, .ui-widget-header .ui-state-error a { color: #cd0a0a; } -.ui-state-error-text, .ui-widget-content .ui-state-error-text, .ui-widget-header .ui-state-error-text { color: #cd0a0a; } -.ui-priority-primary, .ui-widget-content .ui-priority-primary, .ui-widget-header .ui-priority-primary { font-weight: bold; } -.ui-priority-secondary, .ui-widget-content .ui-priority-secondary, .ui-widget-header .ui-priority-secondary { opacity: .7; filter:Alpha(Opacity=70); font-weight: normal; } -.ui-state-disabled, .ui-widget-content .ui-state-disabled, .ui-widget-header .ui-state-disabled { opacity: .35; filter:Alpha(Opacity=35); background-image: none; } - -/* Icons -----------------------------------*/ - -/* states and images */ -.ui-icon { width: 16px; height: 16px; background-image: url(images/ui-icons_222222_256x240.png); } -.ui-widget-content .ui-icon {background-image: url(images/ui-icons_222222_256x240.png); } -.ui-widget-header .ui-icon {background-image: url(images/ui-icons_222222_256x240.png); } -.ui-state-default .ui-icon { background-image: url(images/ui-icons_888888_256x240.png); } -.ui-state-hover .ui-icon, .ui-state-focus .ui-icon {background-image: url(images/ui-icons_454545_256x240.png); } -.ui-state-active .ui-icon {background-image: url(images/ui-icons_454545_256x240.png); } -.ui-state-highlight .ui-icon {background-image: url(images/ui-icons_2e83ff_256x240.png); } -.ui-state-error .ui-icon, .ui-state-error-text .ui-icon {background-image: url(images/ui-icons_cd0a0a_256x240.png); } - -/* positioning */ -.ui-icon-carat-1-n { background-position: 0 0; } -.ui-icon-carat-1-ne { background-position: -16px 0; } -.ui-icon-carat-1-e { background-position: -32px 0; } -.ui-icon-carat-1-se { background-position: -48px 0; } -.ui-icon-carat-1-s { background-position: -64px 0; } -.ui-icon-carat-1-sw { background-position: -80px 0; } -.ui-icon-carat-1-w { background-position: -96px 0; } -.ui-icon-carat-1-nw { background-position: -112px 0; } -.ui-icon-carat-2-n-s { background-position: -128px 0; } -.ui-icon-carat-2-e-w { background-position: -144px 0; } -.ui-icon-triangle-1-n { background-position: 0 -16px; } -.ui-icon-triangle-1-ne { background-position: -16px -16px; } -.ui-icon-triangle-1-e { background-position: -32px -16px; } -.ui-icon-triangle-1-se { background-position: -48px -16px; } -.ui-icon-triangle-1-s { background-position: -64px -16px; } -.ui-icon-triangle-1-sw { background-position: -80px -16px; } -.ui-icon-triangle-1-w { background-position: -96px -16px; } -.ui-icon-triangle-1-nw { background-position: -112px -16px; } -.ui-icon-triangle-2-n-s { background-position: -128px -16px; } -.ui-icon-triangle-2-e-w { background-position: -144px -16px; } -.ui-icon-arrow-1-n { background-position: 0 -32px; } -.ui-icon-arrow-1-ne { background-position: -16px -32px; } -.ui-icon-arrow-1-e { background-position: -32px -32px; } -.ui-icon-arrow-1-se { background-position: -48px -32px; } -.ui-icon-arrow-1-s { background-position: -64px -32px; } -.ui-icon-arrow-1-sw { background-position: -80px -32px; } -.ui-icon-arrow-1-w { background-position: -96px -32px; } -.ui-icon-arrow-1-nw { background-position: -112px -32px; } -.ui-icon-arrow-2-n-s { background-position: -128px -32px; } -.ui-icon-arrow-2-ne-sw { background-position: -144px -32px; } -.ui-icon-arrow-2-e-w { background-position: -160px -32px; } -.ui-icon-arrow-2-se-nw { background-position: -176px -32px; } -.ui-icon-arrowstop-1-n { background-position: -192px -32px; } -.ui-icon-arrowstop-1-e { background-position: -208px -32px; } -.ui-icon-arrowstop-1-s { background-position: -224px -32px; } -.ui-icon-arrowstop-1-w { background-position: -240px -32px; } -.ui-icon-arrowthick-1-n { background-position: 0 -48px; } -.ui-icon-arrowthick-1-ne { background-position: -16px -48px; } -.ui-icon-arrowthick-1-e { background-position: -32px -48px; } -.ui-icon-arrowthick-1-se { background-position: -48px -48px; } -.ui-icon-arrowthick-1-s { background-position: -64px -48px; } -.ui-icon-arrowthick-1-sw { background-position: -80px -48px; } -.ui-icon-arrowthick-1-w { background-position: -96px -48px; } -.ui-icon-arrowthick-1-nw { background-position: -112px -48px; } -.ui-icon-arrowthick-2-n-s { background-position: -128px -48px; } -.ui-icon-arrowthick-2-ne-sw { background-position: -144px -48px; } -.ui-icon-arrowthick-2-e-w { background-position: -160px -48px; } -.ui-icon-arrowthick-2-se-nw { background-position: -176px -48px; } -.ui-icon-arrowthickstop-1-n { background-position: -192px -48px; } -.ui-icon-arrowthickstop-1-e { background-position: -208px -48px; } -.ui-icon-arrowthickstop-1-s { background-position: -224px -48px; } -.ui-icon-arrowthickstop-1-w { background-position: -240px -48px; } -.ui-icon-arrowreturnthick-1-w { background-position: 0 -64px; } -.ui-icon-arrowreturnthick-1-n { background-position: -16px -64px; } -.ui-icon-arrowreturnthick-1-e { background-position: -32px -64px; } -.ui-icon-arrowreturnthick-1-s { background-position: -48px -64px; } -.ui-icon-arrowreturn-1-w { background-position: -64px -64px; } -.ui-icon-arrowreturn-1-n { background-position: -80px -64px; } -.ui-icon-arrowreturn-1-e { background-position: -96px -64px; } -.ui-icon-arrowreturn-1-s { background-position: -112px -64px; } -.ui-icon-arrowrefresh-1-w { background-position: -128px -64px; } -.ui-icon-arrowrefresh-1-n { background-position: -144px -64px; } -.ui-icon-arrowrefresh-1-e { background-position: -160px -64px; } -.ui-icon-arrowrefresh-1-s { background-position: -176px -64px; } -.ui-icon-arrow-4 { background-position: 0 -80px; } -.ui-icon-arrow-4-diag { background-position: -16px -80px; } -.ui-icon-extlink { background-position: -32px -80px; } -.ui-icon-newwin { background-position: -48px -80px; } -.ui-icon-refresh { background-position: -64px -80px; } -.ui-icon-shuffle { background-position: -80px -80px; } -.ui-icon-transfer-e-w { background-position: -96px -80px; } -.ui-icon-transferthick-e-w { background-position: -112px -80px; } -.ui-icon-folder-collapsed { background-position: 0 -96px; } -.ui-icon-folder-open { background-position: -16px -96px; } -.ui-icon-document { background-position: -32px -96px; } -.ui-icon-document-b { background-position: -48px -96px; } -.ui-icon-note { background-position: -64px -96px; } -.ui-icon-mail-closed { background-position: -80px -96px; } -.ui-icon-mail-open { background-position: -96px -96px; } -.ui-icon-suitcase { background-position: -112px -96px; } -.ui-icon-comment { background-position: -128px -96px; } -.ui-icon-person { background-position: -144px -96px; } -.ui-icon-print { background-position: -160px -96px; } -.ui-icon-trash { background-position: -176px -96px; } -.ui-icon-locked { background-position: -192px -96px; } -.ui-icon-unlocked { background-position: -208px -96px; } -.ui-icon-bookmark { background-position: -224px -96px; } -.ui-icon-tag { background-position: -240px -96px; } -.ui-icon-home { background-position: 0 -112px; } -.ui-icon-flag { background-position: -16px -112px; } -.ui-icon-calendar { background-position: -32px -112px; } -.ui-icon-cart { background-position: -48px -112px; } -.ui-icon-pencil { background-position: -64px -112px; } -.ui-icon-clock { background-position: -80px -112px; } -.ui-icon-disk { background-position: -96px -112px; } -.ui-icon-calculator { background-position: -112px -112px; } -.ui-icon-zoomin { background-position: -128px -112px; } -.ui-icon-zoomout { background-position: -144px -112px; } -.ui-icon-search { background-position: -160px -112px; } -.ui-icon-wrench { background-position: -176px -112px; } -.ui-icon-gear { background-position: -192px -112px; } -.ui-icon-heart { background-position: -208px -112px; } -.ui-icon-star { background-position: -224px -112px; } -.ui-icon-link { background-position: -240px -112px; } -.ui-icon-cancel { background-position: 0 -128px; } -.ui-icon-plus { background-position: -16px -128px; } -.ui-icon-plusthick { background-position: -32px -128px; } -.ui-icon-minus { background-position: -48px -128px; } -.ui-icon-minusthick { background-position: -64px -128px; } -.ui-icon-close { background-position: -80px -128px; } -.ui-icon-closethick { background-position: -96px -128px; } -.ui-icon-key { background-position: -112px -128px; } -.ui-icon-lightbulb { background-position: -128px -128px; } -.ui-icon-scissors { background-position: -144px -128px; } -.ui-icon-clipboard { background-position: -160px -128px; } -.ui-icon-copy { background-position: -176px -128px; } -.ui-icon-contact { background-position: -192px -128px; } -.ui-icon-image { background-position: -208px -128px; } -.ui-icon-video { background-position: -224px -128px; } -.ui-icon-script { background-position: -240px -128px; } -.ui-icon-alert { background-position: 0 -144px; } -.ui-icon-info { background-position: -16px -144px; } -.ui-icon-notice { background-position: -32px -144px; } -.ui-icon-help { background-position: -48px -144px; } -.ui-icon-check { background-position: -64px -144px; } -.ui-icon-bullet { background-position: -80px -144px; } -.ui-icon-radio-off { background-position: -96px -144px; } -.ui-icon-radio-on { background-position: -112px -144px; } -.ui-icon-pin-w { background-position: -128px -144px; } -.ui-icon-pin-s { background-position: -144px -144px; } -.ui-icon-play { background-position: 0 -160px; } -.ui-icon-pause { background-position: -16px -160px; } -.ui-icon-seek-next { background-position: -32px -160px; } -.ui-icon-seek-prev { background-position: -48px -160px; } -.ui-icon-seek-end { background-position: -64px -160px; } -.ui-icon-seek-start { background-position: -80px -160px; } -/* ui-icon-seek-first is deprecated, use ui-icon-seek-start instead */ -.ui-icon-seek-first { background-position: -80px -160px; } -.ui-icon-stop { background-position: -96px -160px; } -.ui-icon-eject { background-position: -112px -160px; } -.ui-icon-volume-off { background-position: -128px -160px; } -.ui-icon-volume-on { background-position: -144px -160px; } -.ui-icon-power { background-position: 0 -176px; } -.ui-icon-signal-diag { background-position: -16px -176px; } -.ui-icon-signal { background-position: -32px -176px; } -.ui-icon-battery-0 { background-position: -48px -176px; } -.ui-icon-battery-1 { background-position: -64px -176px; } -.ui-icon-battery-2 { background-position: -80px -176px; } -.ui-icon-battery-3 { background-position: -96px -176px; } -.ui-icon-circle-plus { background-position: 0 -192px; } -.ui-icon-circle-minus { background-position: -16px -192px; } -.ui-icon-circle-close { background-position: -32px -192px; } -.ui-icon-circle-triangle-e { background-position: -48px -192px; } -.ui-icon-circle-triangle-s { background-position: -64px -192px; } -.ui-icon-circle-triangle-w { background-position: -80px -192px; } -.ui-icon-circle-triangle-n { background-position: -96px -192px; } -.ui-icon-circle-arrow-e { background-position: -112px -192px; } -.ui-icon-circle-arrow-s { background-position: -128px -192px; } -.ui-icon-circle-arrow-w { background-position: -144px -192px; } -.ui-icon-circle-arrow-n { background-position: -160px -192px; } -.ui-icon-circle-zoomin { background-position: -176px -192px; } -.ui-icon-circle-zoomout { background-position: -192px -192px; } -.ui-icon-circle-check { background-position: -208px -192px; } -.ui-icon-circlesmall-plus { background-position: 0 -208px; } -.ui-icon-circlesmall-minus { background-position: -16px -208px; } -.ui-icon-circlesmall-close { background-position: -32px -208px; } -.ui-icon-squaresmall-plus { background-position: -48px -208px; } -.ui-icon-squaresmall-minus { background-position: -64px -208px; } -.ui-icon-squaresmall-close { background-position: -80px -208px; } -.ui-icon-grip-dotted-vertical { background-position: 0 -224px; } -.ui-icon-grip-dotted-horizontal { background-position: -16px -224px; } -.ui-icon-grip-solid-vertical { background-position: -32px -224px; } -.ui-icon-grip-solid-horizontal { background-position: -48px -224px; } -.ui-icon-gripsmall-diagonal-se { background-position: -64px -224px; } -.ui-icon-grip-diagonal-se { background-position: -80px -224px; } - - -/* Misc visuals -----------------------------------*/ - -/* Corner radius */ -.ui-corner-all, .ui-corner-top, .ui-corner-left, .ui-corner-tl { -moz-border-radius-topleft: 4px; -webkit-border-top-left-radius: 4px; -khtml-border-top-left-radius: 4px; border-top-left-radius: 4px; } -.ui-corner-all, .ui-corner-top, .ui-corner-right, .ui-corner-tr { -moz-border-radius-topright: 4px; -webkit-border-top-right-radius: 4px; -khtml-border-top-right-radius: 4px; border-top-right-radius: 4px; } -.ui-corner-all, .ui-corner-bottom, .ui-corner-left, .ui-corner-bl { -moz-border-radius-bottomleft: 4px; -webkit-border-bottom-left-radius: 4px; -khtml-border-bottom-left-radius: 4px; border-bottom-left-radius: 4px; } -.ui-corner-all, .ui-corner-bottom, .ui-corner-right, .ui-corner-br { -moz-border-radius-bottomright: 4px; -webkit-border-bottom-right-radius: 4px; -khtml-border-bottom-right-radius: 4px; border-bottom-right-radius: 4px; } - -/* Overlays */ -.ui-widget-overlay { background: #aaaaaa url(images/ui-bg_flat_0_aaaaaa_40x100.png) 50% 50% repeat-x; opacity: .30;filter:Alpha(Opacity=30); } -.ui-widget-shadow { margin: -8px 0 0 -8px; padding: 8px; background: #aaaaaa url(images/ui-bg_flat_0_aaaaaa_40x100.png) 50% 50% repeat-x; opacity: .30;filter:Alpha(Opacity=30); -moz-border-radius: 8px; -khtml-border-radius: 8px; -webkit-border-radius: 8px; border-radius: 8px; }/* - * jQuery UI Tabs 1.8.16 - * - * Copyright 2011, AUTHORS.txt (http://jqueryui.com/about) - * Dual licensed under the MIT or GPL Version 2 licenses. - * http://jquery.org/license - * - * http://docs.jquery.com/UI/Tabs#theming - */ -.ui-tabs { position: relative; padding: .2em; zoom: 1; } /* position: relative prevents IE scroll bug (element with position: relative inside container with overflow: auto appear as "fixed") */ -.ui-tabs .ui-tabs-nav { margin: 0; padding: .2em .2em 0; } -.ui-tabs .ui-tabs-nav li { list-style: none; float: left; position: relative; top: 1px; margin: 0 .2em 1px 0; border-bottom: 0 !important; padding: 0; white-space: nowrap; } -.ui-tabs .ui-tabs-nav li a { float: left; padding: .5em 1em; text-decoration: none; } -.ui-tabs .ui-tabs-nav li.ui-tabs-selected { margin-bottom: 0; padding-bottom: 1px; } -.ui-tabs .ui-tabs-nav li.ui-tabs-selected a, .ui-tabs .ui-tabs-nav li.ui-state-disabled a, .ui-tabs .ui-tabs-nav li.ui-state-processing a { cursor: text; } -.ui-tabs .ui-tabs-nav li a, .ui-tabs.ui-tabs-collapsible .ui-tabs-nav li.ui-tabs-selected a { cursor: pointer; } /* first selector in group seems obsolete, but required to overcome bug in Opera applying cursor: text overall if defined elsewhere... */ -.ui-tabs .ui-tabs-panel { display: block; border-width: 0; padding: 1em 1.4em; background: none; } -.ui-tabs .ui-tabs-hide { display: none !important; } -/* - * jQuery UI Datepicker 1.8.16 - * - * Copyright 2011, AUTHORS.txt (http://jqueryui.com/about) - * Dual licensed under the MIT or GPL Version 2 licenses. - * http://jquery.org/license - * - * http://docs.jquery.com/UI/Datepicker#theming - */ -.ui-datepicker { width: 17em; padding: .2em .2em 0; display: none; } -.ui-datepicker .ui-datepicker-header { position:relative; padding:.2em 0; } -.ui-datepicker .ui-datepicker-prev, .ui-datepicker .ui-datepicker-next { position:absolute; top: 2px; width: 1.8em; height: 1.8em; } -.ui-datepicker .ui-datepicker-prev-hover, .ui-datepicker .ui-datepicker-next-hover { top: 1px; } -.ui-datepicker .ui-datepicker-prev { left:2px; } -.ui-datepicker .ui-datepicker-next { right:2px; } -.ui-datepicker .ui-datepicker-prev-hover { left:1px; } -.ui-datepicker .ui-datepicker-next-hover { right:1px; } -.ui-datepicker .ui-datepicker-prev span, .ui-datepicker .ui-datepicker-next span { display: block; position: absolute; left: 50%; margin-left: -8px; top: 50%; margin-top: -8px; } -.ui-datepicker .ui-datepicker-title { margin: 0 2.3em; line-height: 1.8em; text-align: center; } -.ui-datepicker .ui-datepicker-title select { font-size:1em; margin:1px 0; } -.ui-datepicker select.ui-datepicker-month-year {width: 100%;} -.ui-datepicker select.ui-datepicker-month, -.ui-datepicker select.ui-datepicker-year { width: 49%;} -.ui-datepicker table {width: 100%; font-size: .9em; border-collapse: collapse; margin:0 0 .4em; } -.ui-datepicker th { padding: .7em .3em; text-align: center; font-weight: bold; border: 0; } -.ui-datepicker td { border: 0; padding: 1px; } -.ui-datepicker td span, .ui-datepicker td a { display: block; padding: .2em; text-align: right; text-decoration: none; } -.ui-datepicker .ui-datepicker-buttonpane { background-image: none; margin: .7em 0 0 0; padding:0 .2em; border-left: 0; border-right: 0; border-bottom: 0; } -.ui-datepicker .ui-datepicker-buttonpane button { float: right; margin: .5em .2em .4em; cursor: pointer; padding: .2em .6em .3em .6em; width:auto; overflow:visible; } -.ui-datepicker .ui-datepicker-buttonpane button.ui-datepicker-current { float:left; } - -/* with multiple calendars */ -.ui-datepicker.ui-datepicker-multi { width:auto; } -.ui-datepicker-multi .ui-datepicker-group { float:left; } -.ui-datepicker-multi .ui-datepicker-group table { width:95%; margin:0 auto .4em; } -.ui-datepicker-multi-2 .ui-datepicker-group { width:50%; } -.ui-datepicker-multi-3 .ui-datepicker-group { width:33.3%; } -.ui-datepicker-multi-4 .ui-datepicker-group { width:25%; } -.ui-datepicker-multi .ui-datepicker-group-last .ui-datepicker-header { border-left-width:0; } -.ui-datepicker-multi .ui-datepicker-group-middle .ui-datepicker-header { border-left-width:0; } -.ui-datepicker-multi .ui-datepicker-buttonpane { clear:left; } -.ui-datepicker-row-break { clear:both; width:100%; font-size:0em; } - -/* RTL support */ -.ui-datepicker-rtl { direction: rtl; } -.ui-datepicker-rtl .ui-datepicker-prev { right: 2px; left: auto; } -.ui-datepicker-rtl .ui-datepicker-next { left: 2px; right: auto; } -.ui-datepicker-rtl .ui-datepicker-prev:hover { right: 1px; left: auto; } -.ui-datepicker-rtl .ui-datepicker-next:hover { left: 1px; right: auto; } -.ui-datepicker-rtl .ui-datepicker-buttonpane { clear:right; } -.ui-datepicker-rtl .ui-datepicker-buttonpane button { float: left; } -.ui-datepicker-rtl .ui-datepicker-buttonpane button.ui-datepicker-current { float:right; } -.ui-datepicker-rtl .ui-datepicker-group { float:right; } -.ui-datepicker-rtl .ui-datepicker-group-last .ui-datepicker-header { border-right-width:0; border-left-width:1px; } -.ui-datepicker-rtl .ui-datepicker-group-middle .ui-datepicker-header { border-right-width:0; border-left-width:1px; } - -/* IE6 IFRAME FIX (taken from datepicker 1.5.3 */ -.ui-datepicker-cover { - display: none; /*sorry for IE5*/ - display/**/: block; /*sorry for IE5*/ - position: absolute; /*must have*/ - z-index: -1; /*must have*/ - filter: mask(); /*must have*/ - top: -4px; /*must have*/ - left: -4px; /*must have*/ - width: 200px; /*must have*/ - height: 200px; /*must have*/ -}
\ No newline at end of file diff --git a/app/assets/stylesheets/jquery.Jcrop.css b/app/assets/stylesheets/jquery.Jcrop.css deleted file mode 100644 index 24925dc94..000000000 --- a/app/assets/stylesheets/jquery.Jcrop.css +++ /dev/null @@ -1,35 +0,0 @@ -/* Fixes issue here http://code.google.com/p/jcrop/issues/detail?id=1 */ -.jcrop-holder { text-align: left; } - -.jcrop-vline, .jcrop-hline -{ - font-size: 0; - position: absolute; - background: white url('Jcrop.gif') top left repeat; -} -.jcrop-vline { height: 100%; width: 1px !important; } -.jcrop-hline { width: 100%; height: 1px !important; } -.jcrop-handle { - font-size: 1px; - width: 7px !important; - height: 7px !important; - border: 1px #eee solid; - background-color: #333; - *width: 9px; - *height: 9px; -} - -.jcrop-tracker { width: 100%; height: 100%; } - -.custom .jcrop-vline, -.custom .jcrop-hline -{ - background: yellow; -} -.custom .jcrop-handle -{ - border-color: black; - background-color: #C7BB00; - -moz-border-radius: 3px; - -webkit-border-radius: 3px; -} diff --git a/app/assets/stylesheets/jquery.Jcrop.min.css b/app/assets/stylesheets/jquery.Jcrop.min.css new file mode 100644 index 000000000..51ee2c8fd --- /dev/null +++ b/app/assets/stylesheets/jquery.Jcrop.min.css @@ -0,0 +1,2 @@ +/* jquery.Jcrop.min.css v0.9.12 (build:20140524) */ +.jcrop-holder{direction:ltr;text-align:left;-ms-touch-action:none}.jcrop-hline,.jcrop-vline{background:#fff url(Jcrop.gif);font-size:0;position:absolute}.jcrop-vline{height:100%;width:1px!important}.jcrop-vline.right{right:0}.jcrop-hline{height:1px!important;width:100%}.jcrop-hline.bottom{bottom:0}.jcrop-tracker{height:100%;width:100%;-webkit-tap-highlight-color:transparent;-webkit-touch-callout:none;-webkit-user-select:none}.jcrop-handle{background-color:#333;border:1px #eee solid;width:7px;height:7px;font-size:1px}.jcrop-handle.ord-n{left:50%;margin-left:-4px;margin-top:-4px;top:0}.jcrop-handle.ord-s{bottom:0;left:50%;margin-bottom:-4px;margin-left:-4px}.jcrop-handle.ord-e{margin-right:-4px;margin-top:-4px;right:0;top:50%}.jcrop-handle.ord-w{left:0;margin-left:-4px;margin-top:-4px;top:50%}.jcrop-handle.ord-nw{left:0;margin-left:-4px;margin-top:-4px;top:0}.jcrop-handle.ord-ne{margin-right:-4px;margin-top:-4px;right:0;top:0}.jcrop-handle.ord-se{bottom:0;margin-bottom:-4px;margin-right:-4px;right:0}.jcrop-handle.ord-sw{bottom:0;left:0;margin-bottom:-4px;margin-left:-4px}.jcrop-dragbar.ord-n,.jcrop-dragbar.ord-s{height:7px;width:100%}.jcrop-dragbar.ord-e,.jcrop-dragbar.ord-w{height:100%;width:7px}.jcrop-dragbar.ord-n{margin-top:-4px}.jcrop-dragbar.ord-s{bottom:0;margin-bottom:-4px}.jcrop-dragbar.ord-e{margin-right:-4px;right:0}.jcrop-dragbar.ord-w{margin-left:-4px}.jcrop-light .jcrop-hline,.jcrop-light .jcrop-vline{background:#fff;filter:alpha(opacity=70)!important;opacity:.7!important}.jcrop-light .jcrop-handle{-moz-border-radius:3px;-webkit-border-radius:3px;background-color:#000;border-color:#fff;border-radius:3px}.jcrop-dark .jcrop-hline,.jcrop-dark .jcrop-vline{background:#000;filter:alpha(opacity=70)!important;opacity:.7!important}.jcrop-dark .jcrop-handle{-moz-border-radius:3px;-webkit-border-radius:3px;background-color:#fff;border-color:#000;border-radius:3px}.solid-line .jcrop-hline,.solid-line .jcrop-vline{background:#fff}.jcrop-holder img,img.jcrop-preview{max-width:none}
\ No newline at end of file diff --git a/app/assets/stylesheets/responsive/_global_layout.scss b/app/assets/stylesheets/responsive/_global_layout.scss index d7b24df41..b34a6af74 100644 --- a/app/assets/stylesheets/responsive/_global_layout.scss +++ b/app/assets/stylesheets/responsive/_global_layout.scss @@ -98,3 +98,10 @@ textarea{ padding-right: 0.9375em; } } +.box { + padding: 1em; + + @include respond-min( $main_menu-mobile_menu_cutoff ){ + padding: 1.2em; + } +} diff --git a/app/assets/stylesheets/responsive/_global_style.scss b/app/assets/stylesheets/responsive/_global_style.scss index 24cddc0d9..27d238962 100644 --- a/app/assets/stylesheets/responsive/_global_style.scss +++ b/app/assets/stylesheets/responsive/_global_style.scss @@ -84,9 +84,6 @@ dd { dt + dd { margin-top: 0.5em; - > p { - margin-top: 0; - } } diff --git a/app/assets/stylesheets/responsive/_header_layout.scss b/app/assets/stylesheets/responsive/_header_layout.scss index b3103e3a9..7c7bdfe97 100644 --- a/app/assets/stylesheets/responsive/_header_layout.scss +++ b/app/assets/stylesheets/responsive/_header_layout.scss @@ -131,25 +131,25 @@ } form{ @include grid-row; - padding-right: 1em; + padding: 1em 1em 0; @include lte-ie7 { display: inline; } + @include respond-min( $main_menu-mobile_menu_cutoff ){ + padding-top: 0; + } } input{ - @include grid-column($columns:9); - margin:0; + @include grid-column($columns:10); + margin-right:0; @include lte-ie7 { width: 10.063em; } } - label{ + button[type="submit"]{ @include prefix-postfix-base; - @include grid-column($columns:3,$float:left); + @include grid-column($columns:2,$float:right); border:none; - img{ - max-width: 100%; - } @include lte-ie7 { width: 2.125em; } diff --git a/app/assets/stylesheets/responsive/_header_style.scss b/app/assets/stylesheets/responsive/_header_style.scss index 9008a73a7..ec1e8ea5c 100644 --- a/app/assets/stylesheets/responsive/_header_style.scss +++ b/app/assets/stylesheets/responsive/_header_style.scss @@ -2,3 +2,9 @@ #navigation { border-bottom: 1px solid #e9e9e9; } + +#navigation_search { + button[type="submit"] { + background:image-url('/assets/search.png') transparent no-repeat center center; + } +} diff --git a/app/assets/stylesheets/responsive/_request_style.scss b/app/assets/stylesheets/responsive/_request_style.scss index e6f36674a..44ca9a288 100644 --- a/app/assets/stylesheets/responsive/_request_style.scss +++ b/app/assets/stylesheets/responsive/_request_style.scss @@ -3,12 +3,9 @@ div.correspondence { border: 1px solid #ccc; margin: 0 0 1em; - padding: 1em; - @include respond-min( $main_menu-mobile_menu_cutoff ){ - padding: 1.5em; - } h2 { + margin-top: 0; text-align:right; font-size:1em; } @@ -31,7 +28,6 @@ div.correspondence { div.comment_in_request { border: 1px dotted #ccc; margin:0 0 1em 3em; - padding:0 0.5em; h2 { font-size:1em; @@ -42,13 +38,9 @@ div.comment_in_request { } .event_actions { + margin-bottom: 0; text-align:right; line-height: 1em; - margin-bottom: 1em; -} - -.comment_in_request_text { - margin:0 1.2em 0 0.9em; } .user_photo_on_request img { @@ -64,7 +56,6 @@ div.comment_in_request { height:36px; float:left; vertical-align:middle; - margin-top: 0.5em; margin-right:0.5em; } @@ -86,11 +77,9 @@ a img.attachment_image { } .describe_state_form,#other_recipients { - border-radius:3px; -moz-border-radius:3px; margin:1em 0; - padding:0.5em 1em; } .describe_state_form { diff --git a/app/assets/stylesheets/responsive/_utils.scss b/app/assets/stylesheets/responsive/_utils.scss index 68884fa7a..e19201475 100644 --- a/app/assets/stylesheets/responsive/_utils.scss +++ b/app/assets/stylesheets/responsive/_utils.scss @@ -33,3 +33,18 @@ $lte-ie7: false !default; @content; } } + +// Hide content visually, but keep it available to screen readers +// source: http://a11yproject.com/posts/how-to-hide-content/ +.visually-hidden { + // http://developer.yahoo.com/blogs/ydn/posts/2012/10/clip-your-hidden-content-for-better-accessibility/ + position: absolute !important; + clip: rect(1px 1px 1px 1px); /* IE6, IE7 */ + clip: rect(1px, 1px, 1px, 1px); + padding:0 !important; + border:0 !important; + height: 1px !important; + width: 1px !important; + overflow: hidden; +} +body:hover .visually-hidden a, body:hover .visually-hidden input, body:hover .visually-hidden button { display: none !important; } diff --git a/app/assets/stylesheets/widget.scss b/app/assets/stylesheets/widget.scss new file mode 100644 index 000000000..a67e1f3f0 --- /dev/null +++ b/app/assets/stylesheets/widget.scss @@ -0,0 +1,109 @@ +/* CSS Mini Reset */ + +html, body, div, form, fieldset, legend, label +{ + margin: 0; + padding: 0; +} + +table +{ + border-collapse: collapse; + border-spacing: 0; +} + +th, td +{ + text-align: left; + vertical-align: top; +} + +h1, h2, h3, h4, h5, h6, th, td, caption { font-weight:normal; } + +img { border: 0; } + +body { + background-color: #ffffff; + color: #333333; + padding: 0; + margin: 0; + font-family: "Helvetica Neue", Arial, Helvetica, Helmet, Freesans, sans-serif; + font-weight: normal; + font-style: normal; + line-height: 1.5em; + position: relative; + cursor: default; + font-size: 1em; +} + +a:hover, +a:focus, +a:active { + color: #333; +} + +.alaveteli-widget { + width: 318px; + height: 213px; + border: 1px solid #e9e9e9; + background: #e9e9e9 url("widget-base.png") top left no-repeat; + position: relative; + border: 1px solid #eee; +} + +.alaveteli-widget__title { + position: absolute; + top: 1em; + left: 16px; + width: 160px; + height: 75px; + overflow: hidden; +} + +.alaveteli-widget__status { + position: absolute; + top: 97px; + left: 16px; + font-weight: bold; + text-transform: uppercase; +} + +.alaveteli-widget__status__status-label { + margin: 0; + font-weight: normal; + font-size: 0.875em; + line-height: 1.1em; + color: #555; + text-transform: capitalize; +} + +.alaveteli-widget__left { + position: absolute; + width: 145px; +} + +.alaveteli-widget__people-count { + position: absolute; + left: 192px; + top: 44px; + width: 100px; + text-align: center; + line-height: 1.3em; +} +.alaveteli-widget__count { + font-size: 55px; + line-height: 55px; + text-align: center; +} + +.alaveteli-widget__bottom a { + text-decoration: none; +} + +.alaveteli-widget__button { + position: absolute; + top: 173px; + left: 16px; + text-align: center; +} + diff --git a/app/controllers/admin_censor_rule_controller.rb b/app/controllers/admin_censor_rule_controller.rb index 3387fd832..6c060a610 100644 --- a/app/controllers/admin_censor_rule_controller.rb +++ b/app/controllers/admin_censor_rule_controller.rb @@ -1,3 +1,4 @@ +# -*- encoding : utf-8 -*- # app/controllers/admin_censor_rule_controller.rb: # For modifying requests. # diff --git a/app/controllers/admin_comment_controller.rb b/app/controllers/admin_comment_controller.rb index 0aafb122a..030afb645 100644 --- a/app/controllers/admin_comment_controller.rb +++ b/app/controllers/admin_comment_controller.rb @@ -1,3 +1,4 @@ +# -*- encoding : utf-8 -*- # app/controllers/admin_comment_controller.rb: # Controller for editing comments from the admin interface. # @@ -15,12 +16,12 @@ class AdminCommentController < AdminController old_body = @comment.body old_visible = @comment.visible - @comment.visible = params[:comment][:visible] == "true" ? true : false + @comment.visible = params[:comment][:visible] == "true" if @comment.update_attributes(params[:comment]) @comment.info_request.log_event("edit_comment", { :comment_id => @comment.id, - :editor => admin_current_user(), + :editor => admin_current_user, :old_body => old_body, :body => @comment.body, :old_visible => old_visible, diff --git a/app/controllers/admin_controller.rb b/app/controllers/admin_controller.rb index 7760c372b..400047215 100644 --- a/app/controllers/admin_controller.rb +++ b/app/controllers/admin_controller.rb @@ -1,3 +1,4 @@ +# -*- encoding : utf-8 -*- # controllers/admin.rb: # All admin controllers are dervied from this. # diff --git a/app/controllers/admin_general_controller.rb b/app/controllers/admin_general_controller.rb index f2414eeab..8efe0c7b9 100644 --- a/app/controllers/admin_general_controller.rb +++ b/app/controllers/admin_general_controller.rb @@ -1,3 +1,4 @@ +# -*- encoding : utf-8 -*- # app/controllers/admin_controller.rb: # Controller for main admin pages. # @@ -7,29 +8,29 @@ class AdminGeneralController < AdminController def index - # Overview counts of things - @public_body_count = PublicBody.count - - @info_request_count = InfoRequest.count - @outgoing_message_count = OutgoingMessage.count - @incoming_message_count = IncomingMessage.count - - @user_count = User.count - @track_thing_count = TrackThing.count - - @comment_count = Comment.count - # Tasks to do @requires_admin_requests = InfoRequest.find_in_state('requires_admin') @error_message_requests = InfoRequest.find_in_state('error_message') @attention_requests = InfoRequest.find_in_state('attention_requested') - @blank_contacts = PublicBody.find(:all, :conditions => ["request_email = ''"], - :order => "updated_at") + @blank_contacts = PublicBody. + includes(:tags, :translations). + where(:request_email => ""). + order(:updated_at). + select { |pb| !pb.defunct? } @old_unclassified = InfoRequest.find_old_unclassified(:limit => 20, :conditions => ["prominence = 'normal'"]) - @holding_pen_messages = InfoRequest.holding_pen_request.incoming_messages - @new_body_requests = PublicBodyChangeRequest.new_body_requests.open - @body_update_requests = PublicBodyChangeRequest.body_update_requests.open + @holding_pen_messages = InfoRequest. + includes(:incoming_messages => :raw_email). + holding_pen_request. + incoming_messages + @new_body_requests = PublicBodyChangeRequest. + includes(:public_body, :user). + new_body_requests. + open + @body_update_requests = PublicBodyChangeRequest. + includes(:public_body, :user). + body_update_requests. + open end def timeline diff --git a/app/controllers/admin_holiday_imports_controller.rb b/app/controllers/admin_holiday_imports_controller.rb index 8596936f0..a740caa2b 100644 --- a/app/controllers/admin_holiday_imports_controller.rb +++ b/app/controllers/admin_holiday_imports_controller.rb @@ -1,3 +1,4 @@ +# -*- encoding : utf-8 -*- class AdminHolidayImportsController < AdminController def new diff --git a/app/controllers/admin_holidays_controller.rb b/app/controllers/admin_holidays_controller.rb index 9177ebd44..cd93a21b6 100644 --- a/app/controllers/admin_holidays_controller.rb +++ b/app/controllers/admin_holidays_controller.rb @@ -1,3 +1,4 @@ +# -*- encoding : utf-8 -*- class AdminHolidaysController < AdminController def index diff --git a/app/controllers/admin_incoming_message_controller.rb b/app/controllers/admin_incoming_message_controller.rb index bc653bf53..db7bed34c 100644 --- a/app/controllers/admin_incoming_message_controller.rb +++ b/app/controllers/admin_incoming_message_controller.rb @@ -1,3 +1,4 @@ +# -*- encoding : utf-8 -*- class AdminIncomingMessageController < AdminController def edit @@ -13,7 +14,7 @@ class AdminIncomingMessageController < AdminController if @incoming_message.save @incoming_message.info_request.log_event('edit_incoming', :incoming_message_id => @incoming_message.id, - :editor => admin_current_user(), + :editor => admin_current_user, :old_prominence => old_prominence, :prominence => @incoming_message.prominence, :old_prominence_reason => old_prominence_reason, @@ -33,7 +34,7 @@ class AdminIncomingMessageController < AdminController @incoming_message.fully_destroy @incoming_message.info_request.log_event("destroy_incoming", - { :editor => admin_current_user(), :deleted_incoming_message_id => incoming_message_id }) + { :editor => admin_current_user, :deleted_incoming_message_id => incoming_message_id }) # expire cached files expire_for_request(@info_request) flash[:notice] = 'Incoming message successfully destroyed.' @@ -63,7 +64,7 @@ class AdminIncomingMessageController < AdminController incoming_message_id = incoming_message.id incoming_message.info_request.log_event("redeliver_incoming", { - :editor => admin_current_user(), + :editor => admin_current_user, :destination_request => destination_request.id, :deleted_incoming_message_id => incoming_message_id }) diff --git a/app/controllers/admin_info_request_event_controller.rb b/app/controllers/admin_info_request_event_controller.rb index 17d147582..6862ff116 100644 --- a/app/controllers/admin_info_request_event_controller.rb +++ b/app/controllers/admin_info_request_event_controller.rb @@ -1,3 +1,4 @@ +# -*- encoding : utf-8 -*- # app/controllers/admin_info_request_event_controller.rb: # Controller for FOI request event manipulation from the admin interface. # diff --git a/app/controllers/admin_outgoing_message_controller.rb b/app/controllers/admin_outgoing_message_controller.rb index 2ee811dc0..56e27b108 100644 --- a/app/controllers/admin_outgoing_message_controller.rb +++ b/app/controllers/admin_outgoing_message_controller.rb @@ -1,3 +1,4 @@ +# -*- encoding : utf-8 -*- class AdminOutgoingMessageController < AdminController def edit @@ -11,7 +12,7 @@ class AdminOutgoingMessageController < AdminController @outgoing_message.fully_destroy @outgoing_message.info_request.log_event("destroy_outgoing", - { :editor => admin_current_user(), :deleted_outgoing_message_id => outgoing_message_id }) + { :editor => admin_current_user, :deleted_outgoing_message_id => outgoing_message_id }) flash[:notice] = 'Outgoing message successfully destroyed.' redirect_to admin_request_url(@info_request) @@ -29,7 +30,7 @@ class AdminOutgoingMessageController < AdminController if @outgoing_message.save @outgoing_message.info_request.log_event("edit_outgoing", { :outgoing_message_id => @outgoing_message.id, - :editor => admin_current_user(), + :editor => admin_current_user, :old_body => old_body, :body => @outgoing_message.body, :old_prominence => old_prominence, diff --git a/app/controllers/admin_public_body_categories_controller.rb b/app/controllers/admin_public_body_categories_controller.rb index a86171c76..e365255f8 100644 --- a/app/controllers/admin_public_body_categories_controller.rb +++ b/app/controllers/admin_public_body_categories_controller.rb @@ -1,3 +1,4 @@ +# -*- encoding : utf-8 -*- class AdminPublicBodyCategoriesController < AdminController def index @locale = self.locale_from_params diff --git a/app/controllers/admin_public_body_change_requests_controller.rb b/app/controllers/admin_public_body_change_requests_controller.rb index 6ff03a2bd..be632b6cd 100644 --- a/app/controllers/admin_public_body_change_requests_controller.rb +++ b/app/controllers/admin_public_body_change_requests_controller.rb @@ -1,3 +1,4 @@ +# -*- encoding : utf-8 -*- class AdminPublicBodyChangeRequestsController < AdminController def edit diff --git a/app/controllers/admin_public_body_controller.rb b/app/controllers/admin_public_body_controller.rb index 7de27121a..b3c2c1dfd 100644 --- a/app/controllers/admin_public_body_controller.rb +++ b/app/controllers/admin_public_body_controller.rb @@ -1,3 +1,4 @@ +# -*- encoding : utf-8 -*- # app/controllers/admin_public_body_controller.rb: # Controller for editing public bodies from the admin interface. # @@ -11,7 +12,7 @@ class AdminPublicBodyController < AdminController end def show - @locale = self.locale_from_params() + @locale = locale_from_params I18n.with_locale(@locale) do @public_body = PublicBody.find(params[:id]) @info_requests = @public_body.info_requests.paginate :order => "created_at desc", @@ -43,7 +44,7 @@ class AdminPublicBodyController < AdminController if params[:change_request_id] @change_request = PublicBodyChangeRequest.find(params[:change_request_id]) end - params[:public_body][:last_edit_editor] = admin_current_user() + params[:public_body][:last_edit_editor] = admin_current_user @public_body = PublicBody.new(params[:public_body]) if @public_body.save if @change_request @@ -84,7 +85,7 @@ class AdminPublicBodyController < AdminController @change_request = PublicBodyChangeRequest.find(params[:change_request_id]) end I18n.with_locale(I18n.default_locale) do - params[:public_body][:last_edit_editor] = admin_current_user() + params[:public_body][:last_edit_editor] = admin_current_user @public_body = PublicBody.find(params[:id]) if @public_body.update_attributes(params[:public_body]) if @change_request @@ -101,7 +102,7 @@ class AdminPublicBodyController < AdminController end def destroy - @locale = self.locale_from_params() + @locale = locale_from_params I18n.with_locale(@locale) do public_body = PublicBody.find(params[:id]) @@ -158,7 +159,7 @@ class AdminPublicBodyController < AdminController @notes = "" @errors = "" if request.post? - dry_run_only = (params['commit'] == 'Upload' ? false : true) + dry_run_only = params['commit'] != 'Upload' # (FIXME: both of these cases could now be changed to use # PublicBody.import_csv_from_file.) # Read file from params @@ -177,7 +178,7 @@ class AdminPublicBodyController < AdminController params[:tag], params[:tag_behaviour], true, - admin_current_user(), + admin_current_user, I18n.available_locales) if errors.size == 0 @@ -191,7 +192,7 @@ class AdminPublicBodyController < AdminController params[:tag], params[:tag_behaviour], false, - admin_current_user(), + admin_current_user, I18n.available_locales) if errors.size != 0 raise "dry run mismatched real run" @@ -234,7 +235,7 @@ class AdminPublicBodyController < AdminController end def lookup_query - @locale = self.locale_from_params() + @locale = locale_from_params underscore_locale = @locale.gsub '-', '_' I18n.with_locale(@locale) do @query = params[:query] diff --git a/app/controllers/admin_public_body_headings_controller.rb b/app/controllers/admin_public_body_headings_controller.rb index a7fe27390..f0568510a 100644 --- a/app/controllers/admin_public_body_headings_controller.rb +++ b/app/controllers/admin_public_body_headings_controller.rb @@ -1,3 +1,4 @@ +# -*- encoding : utf-8 -*- class AdminPublicBodyHeadingsController < AdminController def new @@ -84,7 +85,7 @@ class AdminPublicBodyHeadingsController < AdminController end end end - { :success => error.nil? ? true : false, :error => error } + { :success => error.nil?, :error => error } end def reorder_categories_for_heading(heading_id, categories) @@ -105,7 +106,7 @@ class AdminPublicBodyHeadingsController < AdminController end end end - { :success => error.nil? ? true : false, :error => error } + { :success => error.nil?, :error => error } end end diff --git a/app/controllers/admin_raw_email_controller.rb b/app/controllers/admin_raw_email_controller.rb index 1b3ee2871..7a802d914 100644 --- a/app/controllers/admin_raw_email_controller.rb +++ b/app/controllers/admin_raw_email_controller.rb @@ -1,3 +1,4 @@ +# -*- encoding : utf-8 -*- # app/controllers/admin_raw_email_controller.rb: # Controller for managing raw emails from the admin interface. # diff --git a/app/controllers/admin_request_controller.rb b/app/controllers/admin_request_controller.rb index 1e083f57e..eaf6c337d 100644 --- a/app/controllers/admin_request_controller.rb +++ b/app/controllers/admin_request_controller.rb @@ -1,3 +1,4 @@ +# -*- encoding : utf-8 -*- # app/controllers/admin_request_controller.rb: # Controller for viewing FOI requests from the admin interface. # @@ -47,16 +48,16 @@ class AdminRequestController < AdminController @info_request.title = params[:info_request][:title] @info_request.prominence = params[:info_request][:prominence] - @info_request.awaiting_description = params[:info_request][:awaiting_description] == "true" ? true : false + @info_request.awaiting_description = params[:info_request][:awaiting_description] == "true" @info_request.allow_new_responses_from = params[:info_request][:allow_new_responses_from] @info_request.handle_rejected_responses = params[:info_request][:handle_rejected_responses] @info_request.tag_string = params[:info_request][:tag_string] - @info_request.comments_allowed = params[:info_request][:comments_allowed] == "true" ? true : false + @info_request.comments_allowed = params[:info_request][:comments_allowed] == "true" if @info_request.valid? @info_request.save! @info_request.log_event("edit", - { :editor => admin_current_user(), + { :editor => admin_current_user, :old_title => old_title, :title => @info_request.title, :old_prominence => old_prominence, :prominence => @info_request.prominence, :old_described_state => old_described_state, :described_state => params[:info_request][:described_state], @@ -104,7 +105,7 @@ class AdminRequestController < AdminController info_request.user = destination_user info_request.save! info_request.log_event("move_request", { - :editor => admin_current_user(), + :editor => admin_current_user, :old_user_url_name => old_user.url_name, :user_url_name => destination_user.url_name }) @@ -114,21 +115,14 @@ class AdminRequestController < AdminController end redirect_to admin_request_url(info_request) elsif params[:commit] == 'Move request to authority' && !params[:public_body_url_name].blank? - old_public_body = info_request.public_body destination_public_body = PublicBody.find_by_url_name(params[:public_body_url_name]) - if destination_public_body.nil? - flash[:error] = "Couldn't find public body '" + params[:public_body_url_name] + "'" - else - info_request.public_body = destination_public_body - info_request.save! - info_request.log_event("move_request", { - :editor => admin_current_user(), - :old_public_body_url_name => old_public_body.url_name, - :public_body_url_name => destination_public_body.url_name - }) - info_request.reindex_request_events - flash[:notice] = "Request has been moved to new body" + if info_request.move_to_public_body(destination_public_body, + :editor => admin_current_user, + :reindex => true) + flash[:notice] = "Request has been moved to new body" + else + flash[:error] = "Couldn't find public body '#{ params[:public_body_url_name] }'" end redirect_to admin_request_url(info_request) @@ -182,7 +176,7 @@ class AdminRequestController < AdminController info_request.prominence = "requester_only" info_request.log_event("hide", { - :editor => admin_current_user(), + :editor => admin_current_user, :reason => params[:reason], :subject => subject, :explanation => explanation diff --git a/app/controllers/admin_spam_addresses_controller.rb b/app/controllers/admin_spam_addresses_controller.rb index fff7e2a4a..d8be52bc7 100644 --- a/app/controllers/admin_spam_addresses_controller.rb +++ b/app/controllers/admin_spam_addresses_controller.rb @@ -1,3 +1,4 @@ +# -*- encoding : utf-8 -*- class AdminSpamAddressesController < AdminController def index diff --git a/app/controllers/admin_track_controller.rb b/app/controllers/admin_track_controller.rb index 63ee5c12e..e6e5835e6 100644 --- a/app/controllers/admin_track_controller.rb +++ b/app/controllers/admin_track_controller.rb @@ -1,3 +1,4 @@ +# -*- encoding : utf-8 -*- # app/controllers/admin_track_controller.rb: # Show email alerts / RSS feeds from admin interface. # diff --git a/app/controllers/admin_user_controller.rb b/app/controllers/admin_user_controller.rb index 7ef461594..8ebc450f6 100644 --- a/app/controllers/admin_user_controller.rb +++ b/app/controllers/admin_user_controller.rb @@ -1,3 +1,4 @@ +# -*- encoding : utf-8 -*- # app/controllers/admin_user_controller.rb: # Controller for viewing user accounts from the admin interface. # @@ -85,8 +86,7 @@ class AdminUserController < AdminController end def modify_comment_visibility - @visibility_value = params.key?(:hide_selected) ? false : true - Comment.update_all(["visible=?", @visibility_value], :id => params[:comment_ids]) + Comment.update_all(["visible = ?", !params[:hide_selected]], :id => params[:comment_ids]) redirect_to :back end diff --git a/app/controllers/api_controller.rb b/app/controllers/api_controller.rb index 6f83d89d6..3b8991f28 100644 --- a/app/controllers/api_controller.rb +++ b/app/controllers/api_controller.rb @@ -1,3 +1,4 @@ +# -*- encoding : utf-8 -*- class ApiController < ApplicationController before_filter :check_api_key before_filter :check_external_request, @@ -41,7 +42,7 @@ class ApiController < ApplicationController :status => 'ready', :message_type => 'initial_request', :body => json["body"], - :last_sent_at => Time.now(), + :last_sent_at => Time.now, :what_doing => 'normal_sort', :info_request => request ) diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index e80c6a823..a76e6630a 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -1,4 +1,4 @@ -# -*- coding: utf-8 -*- +# -*- encoding : utf-8 -*- # controllers/application.rb: # Parent class of all controllers in FOI site. Filters added to this controller # apply to all controllers in the application. Likewise, all the methods added @@ -206,7 +206,7 @@ class ApplicationController < ActionController::Base def foi_fragment_cache_part_path(param) path = url_for(param) id = param['id'] || param[:id] - first_three_digits = id.to_s()[0..2] + first_three_digits = id.to_s[0..2] path = path.sub("/request/", "/request/" + first_three_digits + "/") return path end diff --git a/app/controllers/comment_controller.rb b/app/controllers/comment_controller.rb index 890e9faaa..b5c438c95 100644 --- a/app/controllers/comment_controller.rb +++ b/app/controllers/comment_controller.rb @@ -1,3 +1,4 @@ +# -*- encoding : utf-8 -*- # app/controllers/comment_controller.rb: # Show annotations upon a request or other object. # diff --git a/app/controllers/general_controller.rb b/app/controllers/general_controller.rb index 380da285e..53288c2f4 100644 --- a/app/controllers/general_controller.rb +++ b/app/controllers/general_controller.rb @@ -1,3 +1,4 @@ +# -*- encoding : utf-8 -*- # app/controllers/general_controller.rb: # For pages like front page, general search, that aren't specific to a # particular model. @@ -14,7 +15,7 @@ class GeneralController < ApplicationController # New, improved front page! def frontpage medium_cache - @locale = self.locale_from_params() + @locale = locale_from_params successful_query = InfoRequestEvent.make_query_from_params( :latest_status => ['successful'] ) @track_thing = TrackThing.create_track_for_search_query(successful_query) @feed_autodetect = [ { :url => do_track_url(@track_thing, 'feed'), @@ -32,7 +33,7 @@ class GeneralController < ApplicationController @feed_autodetect = [] @feed_url = AlaveteliConfiguration::blog_feed separator = @feed_url.include?('?') ? '&' : '?' - @feed_url = "#{@feed_url}#{separator}lang=#{self.locale_from_params()}" + @feed_url = "#{@feed_url}#{separator}lang=#{locale_from_params}" @blog_items = [] if not @feed_url.empty? content = quietly_try_to_open(@feed_url) diff --git a/app/controllers/health_checks_controller.rb b/app/controllers/health_checks_controller.rb index 473a1aacc..122a02193 100644 --- a/app/controllers/health_checks_controller.rb +++ b/app/controllers/health_checks_controller.rb @@ -1,3 +1,4 @@ +# -*- encoding : utf-8 -*- class HealthChecksController < ApplicationController def index diff --git a/app/controllers/help_controller.rb b/app/controllers/help_controller.rb index 93215ccad..cfe1b6ad5 100644 --- a/app/controllers/help_controller.rb +++ b/app/controllers/help_controller.rb @@ -1,3 +1,4 @@ +# -*- encoding : utf-8 -*- # app/controllers/help_controller.rb: # Show information about one particular request. # diff --git a/app/controllers/holiday_controller.rb b/app/controllers/holiday_controller.rb index efc20701d..422612fc7 100644 --- a/app/controllers/holiday_controller.rb +++ b/app/controllers/holiday_controller.rb @@ -1,3 +1,4 @@ +# -*- encoding : utf-8 -*- # app/controllers/holiday_controller.rb: # Calculate dates # diff --git a/app/controllers/info_request_batch_controller.rb b/app/controllers/info_request_batch_controller.rb index b66658757..e1b684f30 100644 --- a/app/controllers/info_request_batch_controller.rb +++ b/app/controllers/info_request_batch_controller.rb @@ -1,3 +1,4 @@ +# -*- encoding : utf-8 -*- class InfoRequestBatchController < ApplicationController def show diff --git a/app/controllers/public_body_change_requests_controller.rb b/app/controllers/public_body_change_requests_controller.rb index 773308546..d43f9398a 100644 --- a/app/controllers/public_body_change_requests_controller.rb +++ b/app/controllers/public_body_change_requests_controller.rb @@ -1,3 +1,4 @@ +# -*- encoding : utf-8 -*- class PublicBodyChangeRequestsController < ApplicationController before_filter :catch_spam, :only => [:create] diff --git a/app/controllers/public_body_controller.rb b/app/controllers/public_body_controller.rb index 854e79a19..376b2024a 100644 --- a/app/controllers/public_body_controller.rb +++ b/app/controllers/public_body_controller.rb @@ -1,4 +1,4 @@ -# -*- coding: utf-8 -*- +# -*- encoding : utf-8 -*- # app/controllers/public_body_controller.rb: # Show information about a public body. # @@ -16,22 +16,28 @@ class PublicBodyController < ApplicationController long_cache @page = get_search_page_from_params requests_per_page = 25 + # Later pages are very expensive to load if @page > MAX_RESULTS / requests_per_page raise ActiveRecord::RecordNotFound.new("Sorry. No pages after #{MAX_RESULTS / requests_per_page}.") end + if MySociety::Format.simplify_url_part(params[:url_name], 'body') != params[:url_name] redirect_to :url_name => MySociety::Format.simplify_url_part(params[:url_name], 'body'), :status => :moved_permanently return end - @locale = self.locale_from_params() + + @locale = locale_from_params + I18n.with_locale(@locale) do @public_body = PublicBody.find_by_url_name_with_historic(params[:url_name]) raise ActiveRecord::RecordNotFound.new("None found") if @public_body.nil? + if @public_body.url_name.nil? redirect_to :back return end + # If found by historic name, or alternate locale name, redirect to new name if @public_body.url_name != params[:url_name] redirect_to :url_name => @public_body.url_name @@ -40,22 +46,27 @@ class PublicBodyController < ApplicationController set_last_body(@public_body) - top_url = frontpage_url + @number_of_visible_requests = @public_body.info_requests.visible.count + @searched_to_send_request = false referrer = request.env['HTTP_REFERER'] - if !referrer.nil? && referrer.match(%r{^#{top_url}search/.*/bodies$}) + + if !referrer.nil? && referrer.match(%r{^#{frontpage_url}search/.*/bodies$}) @searched_to_send_request = true end + @view = params[:view] + query = InfoRequestEvent.make_query_from_params(params.merge(:latest_status => @view)) query += " requested_from:#{@public_body.url_name}" + # Use search query for this so can collapse and paginate easily # TODO: really should just use SQL query here rather than Xapian. sortby = "described" begin @xapian_requests = perform_search([InfoRequestEvent], query, sortby, 'request_collapse', requests_per_page) if (@page > 1) - @page_desc = " (page " + @page.to_s + ")" + @page_desc = " (page #{ @page })" else @page_desc = "" end @@ -66,10 +77,16 @@ class PublicBodyController < ApplicationController flash.keep(:search_params) @track_thing = TrackThing.create_track_for_public_body(@public_body) + if @user @existing_track = TrackThing.find_existing(@user, @track_thing) end - @feed_autodetect = [ { :url => do_track_url(@track_thing, 'feed'), :title => @track_thing.params[:title_in_rss], :has_json => true } ] + + @follower_count = TrackThing.where(:public_body_id => @public_body.id).count + + @feed_autodetect = [ { :url => do_track_url(@track_thing, 'feed'), + :title => @track_thing.params[:title_in_rss], + :has_json => true } ] respond_to do |format| format.html { @has_json = true; render :template => "public_body/show"} @@ -83,7 +100,7 @@ class PublicBodyController < ApplicationController @public_body = PublicBody.find_by_url_name_with_historic(params[:url_name]) raise ActiveRecord::RecordNotFound.new("None found") if @public_body.nil? - I18n.with_locale(self.locale_from_params()) do + I18n.with_locale(locale_from_params) do if params[:submitted_view_email] if verify_recaptcha flash.discard(:error) @@ -106,7 +123,7 @@ class PublicBodyController < ApplicationController @tag = params[:tag] - @locale = self.locale_from_params + @locale = locale_from_params underscore_locale = @locale.gsub '-', '_' underscore_default_locale = I18n.default_locale.to_s.gsub '-', '_' diff --git a/app/controllers/reports_controller.rb b/app/controllers/reports_controller.rb index a1dd53125..83474ad65 100644 --- a/app/controllers/reports_controller.rb +++ b/app/controllers/reports_controller.rb @@ -1,3 +1,4 @@ +# -*- encoding : utf-8 -*- class ReportsController < ApplicationController def create @info_request = InfoRequest.find_by_url_title!(params[:request_id]) diff --git a/app/controllers/request_controller.rb b/app/controllers/request_controller.rb index e847cae1e..26e3b350c 100644 --- a/app/controllers/request_controller.rb +++ b/app/controllers/request_controller.rb @@ -1,4 +1,4 @@ -# encoding: UTF-8 +# -*- encoding : utf-8 -*- # app/controllers/request_controller.rb: # Show information about one particular request. # @@ -75,7 +75,7 @@ class RequestController < ApplicationController else medium_cache end - @locale = self.locale_from_params() + @locale = locale_from_params I18n.with_locale(@locale) do # Look up by old style numeric identifiers @@ -96,12 +96,12 @@ class RequestController < ApplicationController set_last_request(@info_request) # assign variables from request parameters - @collapse_quotes = params[:unfold] ? false : true + @collapse_quotes = !params[:unfold] # Don't allow status update on external requests, otherwise accept param if @info_request.is_external? @update_status = false else - @update_status = params[:update_status] ? true : false + @update_status = params[:update_status] end assign_variables_for_show_template(@info_request) @@ -164,7 +164,7 @@ class RequestController < ApplicationController def list medium_cache @view = params[:view] - @locale = self.locale_from_params() + @locale = locale_from_params @page = get_search_page_from_params if !@page # used in cache case, as perform_search sets @page as side effect @per_page = PER_PAGE @max_results = MAX_RESULTS @@ -566,9 +566,9 @@ class RequestController < ApplicationController @info_request = InfoRequest.find(params[:id].to_i) set_last_request(@info_request) - @collapse_quotes = params[:unfold] ? false : true + @collapse_quotes = !params[:unfold] @is_owning_user = @info_request.is_owning_user?(authenticated_user) - @gone_postal = params[:gone_postal] ? true : false + @gone_postal = params[:gone_postal] if !@is_owning_user @gone_postal = false end @@ -763,12 +763,12 @@ class RequestController < ApplicationController # Prevent spam to magic request address. Note that the binary # subsitution method used depends on the content type - @incoming_message.apply_masks!(@attachment.body, @attachment.content_type) + body = @attachment.default_body + @incoming_message.apply_masks!(body, @attachment.content_type) if response.content_type == 'text/html' - @attachment.body = ActionController::Base.helpers.sanitize(@attachment.body) + body = ActionController::Base.helpers.sanitize(body) end - - render :text => @attachment.body + render :text => body end def get_attachment_as_html @@ -848,7 +848,7 @@ class RequestController < ApplicationController # FOI officers can upload a response def upload_response - @locale = self.locale_from_params() + @locale = locale_from_params I18n.with_locale(@locale) do @info_request = InfoRequest.find_by_url_title!(params[:url_title]) @@ -914,7 +914,7 @@ class RequestController < ApplicationController end def download_entire_request - @locale = self.locale_from_params() + @locale = locale_from_params I18n.with_locale(@locale) do @info_request = InfoRequest.find_by_url_title!(params[:url_title]) if authenticated?( diff --git a/app/controllers/request_game_controller.rb b/app/controllers/request_game_controller.rb index 7eadc1204..2915b5c2f 100644 --- a/app/controllers/request_game_controller.rb +++ b/app/controllers/request_game_controller.rb @@ -1,3 +1,4 @@ +# -*- encoding : utf-8 -*- # app/controllers/request_game_controller.rb: # The 'categorise old requests' game # @@ -22,7 +23,7 @@ class RequestGameController < ApplicationController :site_name => site_name) end - @league_table_28_days = RequestClassification.league_table(10, [ "created_at >= ?", Time.now() - 28.days ]) + @league_table_28_days = RequestClassification.league_table(10, [ "created_at >= ?", Time.now - 28.days ]) @league_table_all_time = RequestClassification.league_table(10) @play_urls = true end diff --git a/app/controllers/services_controller.rb b/app/controllers/services_controller.rb index 9b3a3396f..4d06072df 100644 --- a/app/controllers/services_controller.rb +++ b/app/controllers/services_controller.rb @@ -1,3 +1,4 @@ +# -*- encoding : utf-8 -*- # controllers/services_controller.rb: require 'open-uri' diff --git a/app/controllers/track_controller.rb b/app/controllers/track_controller.rb index 4b272797f..cbefb6291 100644 --- a/app/controllers/track_controller.rb +++ b/app/controllers/track_controller.rb @@ -1,3 +1,4 @@ +# -*- encoding : utf-8 -*- # app/controllers/track_controller.rb: # Publically visible email alerts and RSS - think an alert system crossed with # social bookmarking. @@ -214,6 +215,4 @@ class TrackController < ApplicationController redirect_to URI.parse(params[:r]).path end - end - diff --git a/app/controllers/user_controller.rb b/app/controllers/user_controller.rb index d66b4aa8e..bb4ba28d1 100644 --- a/app/controllers/user_controller.rb +++ b/app/controllers/user_controller.rb @@ -1,3 +1,4 @@ +# -*- encoding : utf-8 -*- # app/controllers/user_controller.rb: # Show information about a user. # @@ -176,7 +177,7 @@ class UserController < ApplicationController return else if !@post_redirect.nil? - @user_signin = User.authenticate_from_form(params[:user_signin], @post_redirect.reason_params[:user_name] ? true : false) + @user_signin = User.authenticate_from_form(params[:user_signin], @post_redirect.reason_params[:user_name]) end if @post_redirect.nil? || @user_signin.errors.size > 0 # Failed to authenticate @@ -372,7 +373,7 @@ class UserController < ApplicationController if (not session[:user_circumstance]) or (session[:user_circumstance] != "change_email") # don't store the password in the db params[:signchangeemail].delete(:password) - post_redirect = PostRedirect.new(:uri => signchangeemail_url(), + post_redirect = PostRedirect.new(:uri => signchangeemail_url, :post_params => params, :circumstance => "change_email" # special login that lets you change your email ) @@ -509,7 +510,7 @@ class UserController < ApplicationController else flash[:notice] = _("<p>Thanks for updating your profile photo.</p> <p><strong>Next...</strong> You can put some text about you and your research on your profile.</p>") - redirect_to set_profile_about_me_url() + redirect_to set_profile_about_me_url end else render :template => 'user/set_draft_profile_photo' @@ -595,7 +596,7 @@ class UserController < ApplicationController else flash[:notice] = _("<p>Thanks for changing the text about you on your profile.</p> <p><strong>Next...</strong> You can upload a profile photograph too.</p>") - redirect_to set_profile_photo_url() + redirect_to set_profile_photo_url end end diff --git a/app/controllers/widgets_controller.rb b/app/controllers/widgets_controller.rb new file mode 100644 index 000000000..333a38e86 --- /dev/null +++ b/app/controllers/widgets_controller.rb @@ -0,0 +1,64 @@ +# -*- encoding : utf-8 -*- +# app/controllers/widget_controller.rb: +# Handle widgets, if enabled +# +# Copyright (c) 2014 UK Citizens Online Democracy. All rights reserved. +# Email: hello@mysociety.org; WWW: http://www.mysociety.org/ + +require 'securerandom' + +class WidgetsController < ApplicationController + + before_filter :check_widget_config, :find_info_request, :check_prominence + skip_before_filter :set_x_frame_options_header, :only => [:show] + + def show + medium_cache + @track_thing = TrackThing.create_track_for_request(@info_request) + @status = @info_request.calculate_status + @count = @info_request.track_things.count + @info_request.widget_votes.count + 1 + + if @user + @existing_track = TrackThing.find_existing(@user, @track_thing) + end + unless @user || cookies[:widget_vote] + cookies.permanent[:widget_vote] = SecureRandom.hex(10) + end + render :action => 'show', :layout => false + end + + def new + long_cache + end + + # Track interest in a request from a non-logged in user + def update + if !@user && cookies[:widget_vote] + @info_request.widget_votes. + where(:cookie => cookies[:widget_vote]). + first_or_create + end + + track_thing = TrackThing.create_track_for_request(@info_request) + redirect_to do_track_path(track_thing), status => :temporary_redirect + end + + private + + def find_info_request + @info_request = InfoRequest.find(params[:request_id]) + end + + def check_widget_config + unless AlaveteliConfiguration::enable_widgets + raise ActiveRecord::RecordNotFound.new("Page not enabled") + end + end + + def check_prominence + unless @info_request.prominence == 'normal' + render :nothing => true, :status => :forbidden + end + end + +end diff --git a/app/helpers/admin_helper.rb b/app/helpers/admin_helper.rb index d13fea79b..9d63b1cad 100644 --- a/app/helpers/admin_helper.rb +++ b/app/helpers/admin_helper.rb @@ -1,3 +1,4 @@ +# -*- encoding : utf-8 -*- module AdminHelper def icon(name) content_tag(:i, "", :class => "icon-#{name}") diff --git a/app/helpers/admin_public_body_category_helper.rb b/app/helpers/admin_public_body_category_helper.rb index 9c5e5cc5e..2d8842562 100644 --- a/app/helpers/admin_public_body_category_helper.rb +++ b/app/helpers/admin_public_body_category_helper.rb @@ -1,3 +1,4 @@ +# -*- encoding : utf-8 -*- module AdminPublicBodyCategoryHelper def heading_is_selected?(heading) if params[:headings] diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 49ce94951..2f51f5684 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -1,3 +1,4 @@ +# -*- encoding : utf-8 -*- # app/helpers/application_helper.rb: # Methods added to this helper will be available to all views (i.e. templates) # in the application. diff --git a/app/helpers/config_helper.rb b/app/helpers/config_helper.rb index 026600ff1..9953c4fe0 100644 --- a/app/helpers/config_helper.rb +++ b/app/helpers/config_helper.rb @@ -1,3 +1,4 @@ +# -*- encoding : utf-8 -*- module ConfigHelper def site_name AlaveteliConfiguration::site_name diff --git a/app/helpers/date_time_helper.rb b/app/helpers/date_time_helper.rb index 5f129e590..09b5b2a76 100644 --- a/app/helpers/date_time_helper.rb +++ b/app/helpers/date_time_helper.rb @@ -1,3 +1,4 @@ +# -*- encoding : utf-8 -*- module DateTimeHelper # Public: Usually-correct format for a DateTime-ish object # To define a new new format define the `simple_date_{FORMAT}` method diff --git a/app/helpers/health_checks_helper.rb b/app/helpers/health_checks_helper.rb index f5769a9ba..b2f1f9de5 100644 --- a/app/helpers/health_checks_helper.rb +++ b/app/helpers/health_checks_helper.rb @@ -1,7 +1,8 @@ +# -*- encoding : utf-8 -*- module HealthChecksHelper def check_status(check) - style = check.ok? ? {} : "color: red" + style = check.ok? ? '' : 'color: red' content_tag(:b, check.message, :style => style) end diff --git a/app/helpers/link_to_helper.rb b/app/helpers/link_to_helper.rb index 44d6c6f5f..a47dd94ea 100755 --- a/app/helpers/link_to_helper.rb +++ b/app/helpers/link_to_helper.rb @@ -1,3 +1,4 @@ +# -*- encoding : utf-8 -*- # app/helpers/link_to_helper.rb: # This module is included into all controllers via controllers/application.rb # - @@ -240,32 +241,6 @@ module LinkToHelper link_to h(query), search_url(query) end - # Deprecated helper - # TODO: Remove in next release - def admin_url(relative_path) - warn "[DEPRECATION] admin_url is deprecated. Please remove it from your theme." - relative_path - end - - # Deprecated helper - # TODO: Remove in next release - def main_url(relative_path, append = nil) - warn "[DEPRECATION] main_url is deprecated. Please remove it from your theme." - url_prefix = "http://" + AlaveteliConfiguration::domain - url = url_prefix + relative_path - if !append.nil? - begin - env = Rack::MockRequest.env_for(url) - req = Rack::Request.new(env) - req.path_info += append - url = req.url - rescue URI::InvalidURIError - # don't append to it - end - end - return url - end - # About page URLs def about_url return help_general_url(:action => 'about') diff --git a/app/helpers/mailer_helper.rb b/app/helpers/mailer_helper.rb index 3d4bbac71..573f7d8a8 100644 --- a/app/helpers/mailer_helper.rb +++ b/app/helpers/mailer_helper.rb @@ -1,3 +1,4 @@ +# -*- encoding : utf-8 -*- module MailerHelper def contact_from_name_and_email "#{AlaveteliConfiguration::contact_name} <#{AlaveteliConfiguration::contact_email}>" diff --git a/app/helpers/public_body_helper.rb b/app/helpers/public_body_helper.rb index 57c90a9ba..b8e59a341 100644 --- a/app/helpers/public_body_helper.rb +++ b/app/helpers/public_body_helper.rb @@ -1,3 +1,4 @@ +# -*- encoding : utf-8 -*- module PublicBodyHelper # Public: The reasons a request can't be made to a PublicBody @@ -36,22 +37,19 @@ module PublicBodyHelper # # public_body - Instance of a PublicBody # - # Returns a string + # Returns a String def type_of_authority(public_body) - first = true - types = public_body.tags.each.map do |tag| - if PublicBodyCategory.get().by_tag().include?(tag.name) - desc = PublicBodyCategory.get().singular_by_tag()[tag.name] - if first - desc = desc.sub(/\S/) { |m| Unicode.upcase(m) } - first = false - end - link_to(desc, list_public_bodies_path(tag.name)) + categories = PublicBodyCategory. + where(:category_tag => public_body.tag_string.split) + + types = categories.each_with_index.map do |category, index| + desc = category.description + if index.zero? + desc = desc.sub(/\S/) { |m| Unicode.upcase(m) } end + link_to(desc, list_public_bodies_path(category.category_tag)) end - types.compact! - if types.any? types.to_sentence(:last_word_connector => ' and ').html_safe else diff --git a/app/helpers/track_helper.rb b/app/helpers/track_helper.rb index ca698926c..75ff784f3 100644 --- a/app/helpers/track_helper.rb +++ b/app/helpers/track_helper.rb @@ -1,3 +1,4 @@ +# -*- encoding : utf-8 -*- module TrackHelper def already_subscribed_notice(track_thing) diff --git a/app/helpers/widget_helper.rb b/app/helpers/widget_helper.rb new file mode 100644 index 000000000..70353ea7c --- /dev/null +++ b/app/helpers/widget_helper.rb @@ -0,0 +1,47 @@ +# -*- encoding : utf-8 -*- +module WidgetHelper + def status_description(info_request, status) + case status + when 'waiting_classification' + _('Awaiting classification') + when 'waiting_response' + _('Awaiting response') + when 'waiting_response_overdue' + _('Delayed') + when 'waiting_response_very_overdue' + _('Long overdue') + when 'not_held' + _('Not held') + when 'rejected' + _('Rejected') + when 'successful' + _('Successful') + when 'partially_successful' + _('Partial success') + when 'waiting_clarification' + _('Awaiting clarification') + when 'gone_postal' + _('Handled by post') + when 'internal_review' + _('Internal review') + when 'error_message' + _('Delivery error') + when 'requires_admin' + _('Unusual response') + when 'user_withdrawn' + _('Withdrawn') + when 'attention_requested' + _('Needs admin attention') + when 'vexatious' + _('Vexatious') + when 'not_foi' + _('Not an FOI request') + else + if info_request.respond_to?(:theme_display_status) + info_request.theme_display_status(status) + else + _('Unknown') + end + end + end +end diff --git a/app/mailers/application_mailer.rb b/app/mailers/application_mailer.rb index d2230bb82..cfa5603fe 100644 --- a/app/mailers/application_mailer.rb +++ b/app/mailers/application_mailer.rb @@ -1,3 +1,4 @@ +# -*- encoding : utf-8 -*- # models/application_mailer.rb: # Shared code between different mailers. # diff --git a/app/mailers/contact_mailer.rb b/app/mailers/contact_mailer.rb index 27e04ca4b..58e036d3b 100644 --- a/app/mailers/contact_mailer.rb +++ b/app/mailers/contact_mailer.rb @@ -1,3 +1,4 @@ +# -*- encoding : utf-8 -*- # models/contact_mailer.rb: # Sends contact form mails. # @@ -9,7 +10,7 @@ class ContactMailer < ApplicationMailer def to_admin_message(name, email, subject, message, logged_in_user, last_request, last_body) @message, @logged_in_user, @last_request, @last_body = message, logged_in_user, last_request, last_body - mail(:from => "#{name} <#{email}>", + mail(:from => MailHandler.address_from_name_and_email(name, email), :to => contact_from_name_and_email, :subject => subject) end diff --git a/app/mailers/info_request_batch_mailer.rb b/app/mailers/info_request_batch_mailer.rb index a2becfb24..ba853db95 100644 --- a/app/mailers/info_request_batch_mailer.rb +++ b/app/mailers/info_request_batch_mailer.rb @@ -1,3 +1,4 @@ +# -*- encoding : utf-8 -*- # models/info_request_batch_mailer.rb: # Emails relating to user accounts. e.g. Confirming a new account # diff --git a/app/mailers/outgoing_mailer.rb b/app/mailers/outgoing_mailer.rb index 19054b4e2..cc6190954 100644 --- a/app/mailers/outgoing_mailer.rb +++ b/app/mailers/outgoing_mailer.rb @@ -1,3 +1,4 @@ +# -*- encoding : utf-8 -*- # models/outgoing_mailer.rb: # Emails which go to public bodies on behalf of users. # @@ -40,7 +41,7 @@ class OutgoingMailer < ApplicationMailer # TODO: also OutgoingMessage.get_salutation # TODO: these look like they should be members of IncomingMessage, but logically they # need to work even when IncomingMessage is nil - def OutgoingMailer.name_and_email_for_followup(info_request, incoming_message_followup) + def self.name_and_email_for_followup(info_request, incoming_message_followup) if incoming_message_followup.nil? || !incoming_message_followup.valid_to_reply_to? return info_request.recipient_name_and_email else @@ -50,7 +51,7 @@ class OutgoingMailer < ApplicationMailer end end # Used in the preview of followup - def OutgoingMailer.name_for_followup(info_request, incoming_message_followup) + def self.name_for_followup(info_request, incoming_message_followup) if incoming_message_followup.nil? || !incoming_message_followup.valid_to_reply_to? return info_request.public_body.name else @@ -59,7 +60,7 @@ class OutgoingMailer < ApplicationMailer end end # Used when making list of followup places to remove duplicates - def OutgoingMailer.email_for_followup(info_request, incoming_message_followup) + def self.email_for_followup(info_request, incoming_message_followup) if incoming_message_followup.nil? || !incoming_message_followup.valid_to_reply_to? return info_request.recipient_email else @@ -67,16 +68,16 @@ class OutgoingMailer < ApplicationMailer end end # Subject to use for followup - def OutgoingMailer.subject_for_followup(info_request, outgoing_message, options = {}) + def self.subject_for_followup(info_request, outgoing_message, options = {}) if outgoing_message.what_doing == 'internal_review' - return "Internal review of " + info_request.email_subject_request(:html => options[:html]) + return _("Internal review of {{email_subject}}", :email_subject => info_request.email_subject_request(:html => options[:html])) else return info_request.email_subject_followup(:incoming_message => outgoing_message.incoming_message_followup, :html => options[:html]) end end # Whether we have a valid email address for a followup - def OutgoingMailer.is_followupable?(info_request, incoming_message_followup) + def self.is_followupable?(info_request, incoming_message_followup) if incoming_message_followup.nil? || !incoming_message_followup.valid_to_reply_to? return info_request.recipient_email_valid_for_followup? else @@ -85,7 +86,7 @@ class OutgoingMailer < ApplicationMailer end end # Message-ID to use - def OutgoingMailer.id_for_message(outgoing_message) + def self.id_for_message(outgoing_message) message_id = "ogm-" + outgoing_message.id.to_s t = Time.now message_id += "+" + '%08x%05x-%04x' % [t.to_i, t.tv_usec, rand(0xffff)] diff --git a/app/mailers/request_mailer.rb b/app/mailers/request_mailer.rb index 252df861c..f12b4a0d6 100644 --- a/app/mailers/request_mailer.rb +++ b/app/mailers/request_mailer.rb @@ -1,3 +1,4 @@ +# -*- encoding : utf-8 -*- # models/request_mailer.rb: # Alerts relating to requests. # @@ -64,7 +65,7 @@ class RequestMailer < ApplicationMailer mail(:from => user.name_and_email, :to => contact_from_name_and_email, - :subject => _("FOI response requires admin ({{reason}}) - {{title}}", :reason => info_request.described_state, :title => info_request.title).html_safe) + :subject => _("FOI response requires admin ({{reason}}) - {{title}}", :reason => info_request.described_state, :title => info_request.title.html_safe)) end # Tell the requester that a new response has arrived @@ -80,7 +81,7 @@ class RequestMailer < ApplicationMailer mail(:from => contact_from_name_and_email, :to => info_request.user.name_and_email, - :subject => (_("New response to your FOI request - ") + info_request.title).html_safe, + :subject => _("New response to your FOI request - ") + info_request.title.html_safe, :charset => "UTF-8", # not much we can do if the user's email is broken :reply_to => contact_from_name_and_email) @@ -99,13 +100,8 @@ class RequestMailer < ApplicationMailer @url = confirm_url(:email_token => post_redirect.email_token) @info_request = info_request - headers('Return-Path' => blackhole_email, 'Reply-To' => contact_from_name_and_email, # not much we can do if the user's email is broken - 'Auto-Submitted' => 'auto-generated', # http://tools.ietf.org/html/rfc3834 - 'X-Auto-Response-Suppress' => 'OOF') - - mail(:from => contact_from_name_and_email, - :to => user.name_and_email, - :subject => (_("Delayed response to your FOI request - ") + info_request.title).html_safe) + auto_generated_headers + mail_user_with_info_request_title(user, _("Delayed response to your FOI request - "), info_request) end # Tell the requester that the public body is very late in replying @@ -119,13 +115,8 @@ class RequestMailer < ApplicationMailer @url = confirm_url(:email_token => post_redirect.email_token) @info_request = info_request - headers('Return-Path' => blackhole_email, 'Reply-To' => contact_from_name_and_email, # not much we can do if the user's email is broken - 'Auto-Submitted' => 'auto-generated', # http://tools.ietf.org/html/rfc3834 - 'X-Auto-Response-Suppress' => 'OOF') - - mail(:from => contact_from_name_and_email, - :to => user.name_and_email, - :subject => (_("You're long overdue a response to your FOI request - ") + info_request.title).html_safe) + auto_generated_headers + mail_user_with_info_request_title(user, _("You're long overdue a response to your FOI request - "), info_request) end # Tell the requester that they need to say if the new response @@ -141,13 +132,8 @@ class RequestMailer < ApplicationMailer @incoming_message = incoming_message @info_request = info_request - headers('Return-Path' => blackhole_email, 'Reply-To' => contact_from_name_and_email, # not much we can do if the user's email is broken - 'Auto-Submitted' => 'auto-generated', # http://tools.ietf.org/html/rfc3834 - 'X-Auto-Response-Suppress' => 'OOF') - - mail(:from => contact_from_name_and_email, - :to => info_request.user.name_and_email, - :subject => _("Was the response you got to your FOI request any good?")) + auto_generated_headers + mail_user(info_request.user, _("Was the response you got to your FOI request any good?")) end # Tell the requester that someone updated their old unclassified request @@ -155,13 +141,8 @@ class RequestMailer < ApplicationMailer @url = request_url(info_request) @info_request = info_request - headers('Return-Path' => blackhole_email, 'Reply-To' => contact_from_name_and_email, # not much we can do if the user's email is broken - 'Auto-Submitted' => 'auto-generated', # http://tools.ietf.org/html/rfc3834 - 'X-Auto-Response-Suppress' => 'OOF') - - mail(:from => contact_from_name_and_email, - :to => info_request.user.name_and_email, - :subject => _("Someone has updated the status of your request")) + auto_generated_headers + mail_user(info_request.user, _("Someone has updated the status of your request")) end # Tell the requester that they need to clarify their request @@ -177,13 +158,8 @@ class RequestMailer < ApplicationMailer @incoming_message = incoming_message @info_request = info_request - headers('Return-Path' => blackhole_email, 'Reply-To' => contact_from_name_and_email, # not much we can do if the user's email is broken - 'Auto-Submitted' => 'auto-generated', # http://tools.ietf.org/html/rfc3834 - 'X-Auto-Response-Suppress' => 'OOF') - - mail(:from => contact_from_name_and_email, - :to => info_request.user.name_and_email, - :subject => (_("Clarify your FOI request - ") + info_request.title).html_safe) + auto_generated_headers + mail_user_with_info_request_title(info_request.user, _("Clarify your FOI request - "), info_request) end # Tell requester that somebody add an annotation to their request @@ -191,25 +167,15 @@ class RequestMailer < ApplicationMailer @comment, @info_request = comment, info_request @url = comment_url(comment) - headers('Return-Path' => blackhole_email, 'Reply-To' => contact_from_name_and_email, # not much we can do if the user's email is broken - 'Auto-Submitted' => 'auto-generated', # http://tools.ietf.org/html/rfc3834 - 'X-Auto-Response-Suppress' => 'OOF') - - mail(:from => contact_from_name_and_email, - :to => info_request.user.name_and_email, - :subject => (_("Somebody added a note to your FOI request - ") + info_request.title).html_safe) + auto_generated_headers + mail_user_with_info_request_title(info_request.user, _("Somebody added a note to your FOI request - "), info_request) end def comment_on_alert_plural(info_request, count, earliest_unalerted_comment) @count, @info_request = count, info_request @url = comment_url(earliest_unalerted_comment) - headers('Return-Path' => blackhole_email, 'Reply-To' => contact_from_name_and_email, # not much we can do if the user's email is broken - 'Auto-Submitted' => 'auto-generated', # http://tools.ietf.org/html/rfc3834 - 'X-Auto-Response-Suppress' => 'OOF') - - mail(:from => contact_from_name_and_email, - :to => info_request.user.name_and_email, - :subject => (_("Some notes have been added to your FOI request - ") + info_request.title).html_safe) + auto_generated_headers + mail_user_with_info_request_title(info_request.user, _("Some notes have been added to your FOI request - "), info_request) end # Class function, called by script/mailin with all incoming responses. @@ -268,7 +234,7 @@ class RequestMailer < ApplicationMailer end # Send email alerts for overdue requests - def self.alert_overdue_requests() + def self.alert_overdue_requests info_requests = InfoRequest.find(:all, :conditions => [ "described_state = 'waiting_response' @@ -372,8 +338,8 @@ class RequestMailer < ApplicationMailer # Send email alerts for requests which need clarification. Goes out 3 days # after last update of event. - def self.alert_not_clarified_request() - info_requests = InfoRequest.find(:all, :conditions => [ "awaiting_description = ? and described_state = 'waiting_clarification' and info_requests.updated_at < ?", false, Time.now() - 3.days ], :include => [ :user ], :order => "info_requests.id" ) + def self.alert_not_clarified_request + info_requests = InfoRequest.find(:all, :conditions => [ "awaiting_description = ? and described_state = 'waiting_clarification' and info_requests.updated_at < ?", false, Time.now - 3.days ], :include => [ :user ], :order => "info_requests.id" ) for info_request in info_requests alert_event_id = info_request.get_last_public_response_event_id last_response_message = info_request.get_last_public_response @@ -400,7 +366,7 @@ class RequestMailer < ApplicationMailer end # Send email alert to request submitter for new comments on the request. - def self.alert_comment_on_request() + def self.alert_comment_on_request # We only check comments made in the last month - this means if the # cron jobs broke for more than a month events would be lost, but no @@ -467,7 +433,27 @@ class RequestMailer < ApplicationMailer end end + private -end + def auto_generated_headers + headers({ + 'Return-Path' => blackhole_email, + 'Reply-To' => contact_from_name_and_email, # not much we can do if the user's email is broken + 'Auto-Submitted' => 'auto-generated', # http://tools.ietf.org/html/rfc3834 + 'X-Auto-Response-Suppress' => 'OOF', + }) + end + def mail_user_with_info_request_title(user, subject, info_request) + mail_user(user, subject + info_request.title.html_safe) + end + + def mail_user(user, subject) + mail({ + :from => contact_from_name_and_email, + :to => user.name_and_email, + :subject => subject, + }) + end +end diff --git a/app/mailers/track_mailer.rb b/app/mailers/track_mailer.rb index 8e9beded6..3f5de6a1b 100644 --- a/app/mailers/track_mailer.rb +++ b/app/mailers/track_mailer.rb @@ -1,3 +1,4 @@ +# -*- encoding : utf-8 -*- # models/track_mailer.rb: # Emails which go to users who are tracking things. # @@ -38,7 +39,7 @@ class TrackMailer < ApplicationMailer # User.find(:all, :conditions => [ "last_daily_track_email < ?", Time.now - 1.day ]).size def self.alert_tracks done_something = false - now = Time.now() + now = Time.now one_week_ago = now - 7.days User.find_each(:conditions => [ "last_daily_track_email < ?", now - 1.day ]) do |user| diff --git a/app/mailers/user_mailer.rb b/app/mailers/user_mailer.rb index a351147f9..a6fed693e 100644 --- a/app/mailers/user_mailer.rb +++ b/app/mailers/user_mailer.rb @@ -1,3 +1,4 @@ +# -*- encoding : utf-8 -*- # models/user_mailer.rb: # Emails relating to user accounts. e.g. Confirming a new account # diff --git a/app/models/about_me_validator.rb b/app/models/about_me_validator.rb index 8c24cfd67..8465b0716 100644 --- a/app/models/about_me_validator.rb +++ b/app/models/about_me_validator.rb @@ -1,3 +1,4 @@ +# -*- encoding : utf-8 -*- # models/about_me_validator.rb: # Validates editing about me text on user profile pages. # @@ -9,20 +10,11 @@ class AboutMeValidator attr_accessor :about_me - # TODO: Switch to built in validations - validate :length_of_about_me + validates_length_of :about_me, :maximum => 500, :message => _("Please keep it shorter than 500 characters") def initialize(attributes = {}) attributes.each do |name, value| send("#{name}=", value) end end - - private - - def length_of_about_me - if !about_me.blank? && about_me.size > 500 - errors.add(:about_me, _("Please keep it shorter than 500 characters")) - end - end end diff --git a/app/models/censor_rule.rb b/app/models/censor_rule.rb index 3b5c2d805..aec8a87cc 100644 --- a/app/models/censor_rule.rb +++ b/app/models/censor_rule.rb @@ -1,3 +1,4 @@ +# -*- encoding : utf-8 -*- # == Schema Information # # Table name: censor_rules @@ -22,6 +23,7 @@ # Email: hello@mysociety.org; WWW: http://www.mysociety.org/ class CensorRule < ActiveRecord::Base + include AdminColumn belongs_to :info_request belongs_to :user belongs_to :public_body @@ -42,20 +44,19 @@ class CensorRule < ActiveRecord::Base :user_id => nil, :public_body_id => nil } } + def apply_to_text(text_to_censor) + return nil if text_to_censor.nil? + text_to_censor.gsub(to_replace('UTF-8'), replacement) + end + def apply_to_text!(text_to_censor) return nil if text_to_censor.nil? - text_to_censor.gsub!(to_replace, replacement) + text_to_censor.gsub!(to_replace('UTF-8'), replacement) end def apply_to_binary!(binary_to_censor) return nil if binary_to_censor.nil? - binary_to_censor.gsub!(to_replace) { |match| match.gsub(/./, 'x') } - end - - def for_admin_column - self.class.content_columns.each do |column| - yield(column.human_name, send(column.name), column.type.to_s, column.name) - end + binary_to_censor.gsub!(to_replace('ASCII-8BIT')) { |match| match.gsub(single_char_regexp, 'x') } end def is_global? @@ -64,6 +65,14 @@ class CensorRule < ActiveRecord::Base private + def single_char_regexp + if String.method_defined?(:encode) + Regexp.new('.'.force_encoding('ASCII-8BIT')) + else + Regexp.new('.', nil, 'N') + end + end + def require_user_request_or_public_body if info_request.nil? && user.nil? && public_body.nil? [:info_request, :user, :public_body].each do |a| @@ -74,18 +83,22 @@ class CensorRule < ActiveRecord::Base def require_valid_regexp begin - make_regexp + make_regexp('UTF-8') rescue RegexpError => e errors.add(:text, e.message) end end - def make_regexp - Regexp.new(text, Regexp::MULTILINE) + def to_replace(encoding) + regexp? ? make_regexp(encoding) : encoded_text(encoding) + end + + def encoded_text(encoding) + String.method_defined?(:encode) ? text.dup.force_encoding(encoding) : text end - def to_replace - regexp? ? make_regexp : text + def make_regexp(encoding) + Regexp.new(encoded_text(encoding), Regexp::MULTILINE) end end diff --git a/app/models/change_email_validator.rb b/app/models/change_email_validator.rb index 65f2fd81c..f5b31f038 100644 --- a/app/models/change_email_validator.rb +++ b/app/models/change_email_validator.rb @@ -1,3 +1,4 @@ +# -*- encoding : utf-8 -*- # models/changeemail_validator.rb: # Validates email change form submissions. # diff --git a/app/models/comment.rb b/app/models/comment.rb index cc8d0e94b..59f91ffb7 100644 --- a/app/models/comment.rb +++ b/app/models/comment.rb @@ -1,3 +1,4 @@ +# -*- encoding : utf-8 -*- # == Schema Information # # Table name: comments @@ -20,6 +21,7 @@ # Email: hello@mysociety.org; WWW: http://www.mysociety.org/ class Comment < ActiveRecord::Base + include AdminColumn strip_attributes! belongs_to :user @@ -31,6 +33,8 @@ class Comment < ActiveRecord::Base validate :check_body_has_content, :check_body_uses_mixed_capitals + scope :visible, where(:visible => true) + after_save :event_xapian_update # When posting a new comment, use this to check user hasn't double @@ -57,10 +61,6 @@ class Comment < ActiveRecord::Base ret end - def raw_body - read_attribute(:body) - end - # So when takes changes it updates, or when made invisble it vanishes def event_xapian_update info_request_events.each { |event| event.xapian_mark_needs_index } @@ -75,12 +75,6 @@ class Comment < ActiveRecord::Base text.html_safe end - def for_admin_column - self.class.content_columns.each do |column| - yield(column.human_name, send(column.name), column.type.to_s, column.name) - end - end - private def check_body_has_content diff --git a/app/models/concerns/admin_column.rb b/app/models/concerns/admin_column.rb new file mode 100644 index 000000000..6e19f5aa5 --- /dev/null +++ b/app/models/concerns/admin_column.rb @@ -0,0 +1,17 @@ +module AdminColumn + extend ActiveSupport::Concern + + included do + class << self + attr_reader :non_admin_columns + end + + @non_admin_columns = [] + end + + def for_admin_column + self.class.content_columns.reject { |c| self.class.non_admin_columns.include?(c.name) }.each do |column| + yield(column.human_name, send(column.name), column.type.to_s, column.name) + end + end +end diff --git a/app/models/concerns/public_body_derived_fields.rb b/app/models/concerns/public_body_derived_fields.rb new file mode 100644 index 000000000..f389e3cbf --- /dev/null +++ b/app/models/concerns/public_body_derived_fields.rb @@ -0,0 +1,47 @@ +module PublicBodyDerivedFields + + extend ActiveSupport::Concern + + included do + before_save :set_first_letter + + # When name or short name is changed, also change the url name + def short_name=(short_name) + super + update_url_name + end + + def name=(name) + super + update_url_name + end + + end + + # Return the short name if present, or else long name + def short_or_long_name + if self.short_name.nil? || self.short_name.empty? + self.name.nil? ? "" : self.name + else + self.short_name + end + end + + # Set the first letter, which is used for faster queries + def set_first_letter + unless name.blank? + # we use a regex to ensure it works with utf-8/multi-byte + first_letter = Unicode.upcase name.scan(/^./mu)[0] + if first_letter != self.first_letter + self.first_letter = first_letter + end + end + end + + def update_url_name + if changed.include?('name') || changed.include?('short_name') + self.url_name = MySociety::Format.simplify_url_part(self.short_or_long_name, 'body') + end + end + +end diff --git a/app/models/concerns/translatable.rb b/app/models/concerns/translatable.rb new file mode 100644 index 000000000..2aa4620d0 --- /dev/null +++ b/app/models/concerns/translatable.rb @@ -0,0 +1,37 @@ +module Translatable + extend ActiveSupport::Concern + + included do + accepts_nested_attributes_for :translations, :reject_if => :empty_translation_in_params? + end + + def find_translation_by_locale(locale) + translations.find_by_locale(locale) + end + + def translated_versions + translations + end + + def ordered_translations + translations.select do |translation| + I18n.available_locales.include?(translation.locale) + end.sort_by do |translation| + I18n.available_locales.index(translation.locale) + end + end + + def build_all_translations + I18n.available_locales.each do |locale| + if translations.none? { |translation| translation.locale == locale } + translations.build(:locale => locale) + end + end + end + + private + + def empty_translation_in_params?(attributes) + attributes.select { |k, v| v.present? && k.to_s != 'locale' }.empty? + end +end diff --git a/app/models/contact_validator.rb b/app/models/contact_validator.rb index 8d7e4ff08..1d50bf603 100644 --- a/app/models/contact_validator.rb +++ b/app/models/contact_validator.rb @@ -1,3 +1,4 @@ +# -*- encoding : utf-8 -*- # models/contact_validator.rb: # Validates contact form submissions. # diff --git a/app/models/foi_attachment.rb b/app/models/foi_attachment.rb index a8d105f52..37a9c9827 100644 --- a/app/models/foi_attachment.rb +++ b/app/models/foi_attachment.rb @@ -1,4 +1,4 @@ -# encoding: UTF-8 +# -*- encoding : utf-8 -*- # == Schema Information # # Table name: foi_attachments @@ -62,19 +62,18 @@ class FoiAttachment < ActiveRecord::Base } update_display_size! @cached_body = d + if String.method_defined?(:encode) + @cached_body = @cached_body.force_encoding("ASCII-8BIT") + end end + # raw body, encoded as binary def body if @cached_body.nil? tries = 0 delay = 1 begin - binary_data = File.open(self.filepath, "rb" ){ |file| file.read } - if self.content_type =~ /^text/ - @cached_body = convert_string_to_utf8_or_binary(binary_data, 'UTF-8') - else - @cached_body = binary_data - end + @cached_body = File.open(filepath, "rb" ){ |file| file.read } rescue Errno::ENOENT # we've lost our cached attachments for some reason. Reparse them. if tries > BODY_MAX_TRIES @@ -93,6 +92,17 @@ class FoiAttachment < ActiveRecord::Base return @cached_body end + # body as UTF-8 text, with scrubbing of invalid chars if needed + def body_as_text + convert_string_to_utf8(body, 'UTF-8') + end + + # for text types, the scrubbed UTF-8 text. For all other types, the + # raw binary + def default_body + text_type? ? body_as_text.string : body + end + # List of DSN codes taken from RFC 3463 # http://tools.ietf.org/html/rfc3463 DsnToMessage = { @@ -244,36 +254,32 @@ class FoiAttachment < ActiveRecord::Base # The full list of supported types can be found at # https://docs.google.com/support/bin/answer.py?hl=en&answer=1189935 def has_google_docs_viewer? - return !! { - "application/pdf" => true, # .pdf - "image/tiff" => true, # .tiff - - "application/vnd.ms-word" => true, # .doc - "application/vnd.openxmlformats-officedocument.wordprocessingml.document" => true, # .docx + [ + "application/pdf", # .pdf + "image/tiff", # .tiff - "application/vnd.ms-powerpoint" => true, # .ppt - "application/vnd.openxmlformats-officedocument.presentationml.presentation" => true, # .pptx + "application/vnd.ms-word", # .doc + "application/vnd.openxmlformats-officedocument.wordprocessingml.document", # .docx - "application/vnd.ms-excel" => true, # .xls - "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet" => true, # .xlsx + "application/vnd.ms-powerpoint", # .ppt + "application/vnd.openxmlformats-officedocument.presentationml.presentation", # .pptx - } [self.content_type] + "application/vnd.ms-excel", # .xls + "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet", # .xlsx + ].include?(content_type) end # Whether this type has a "View as HTML" def has_body_as_html? - return ( - !!{ - "text/plain" => true, - "application/rtf" => true, - }[self.content_type] or - self.has_google_docs_viewer? - ) + [ + "text/plain", + "application/rtf", + ].include?(content_type) || has_google_docs_viewer? end # Name of type of attachment type - only valid for things that has_body_as_html? def name_of_content_type - return { + { "text/plain" => "Text file", 'application/rtf' => "RTF file", @@ -298,5 +304,11 @@ class FoiAttachment < ActiveRecord::Base AttachmentToHTML.to_html(self, to_html_opts) end + private + + def text_type? + AlaveteliTextMasker::TextMask.include?(content_type) + end + end diff --git a/app/models/holiday.rb b/app/models/holiday.rb index 34044683a..538e77051 100644 --- a/app/models/holiday.rb +++ b/app/models/holiday.rb @@ -1,3 +1,4 @@ +# -*- encoding : utf-8 -*- # == Schema Information # # Table name: holidays diff --git a/app/models/holiday_import.rb b/app/models/holiday_import.rb index 98a9b96fc..58ea0b1f7 100644 --- a/app/models/holiday_import.rb +++ b/app/models/holiday_import.rb @@ -1,3 +1,4 @@ +# -*- encoding : utf-8 -*- class HolidayImport include ActiveModel::Validations diff --git a/app/models/incoming_message.rb b/app/models/incoming_message.rb index 3606c39c2..71b081560 100644 --- a/app/models/incoming_message.rb +++ b/app/models/incoming_message.rb @@ -1,4 +1,4 @@ -# coding: utf-8 +# -*- encoding : utf-8 -*- # == Schema Information # # Table name: incoming_messages @@ -38,6 +38,7 @@ require 'zip/zip' require 'iconv' unless String.method_defined?(:encode) class IncomingMessage < ActiveRecord::Base + include AdminColumn extend MessageProminence belongs_to :info_request validates_presence_of :info_request @@ -371,41 +372,23 @@ class IncomingMessage < ActiveRecord::Base def _convert_part_body_to_text(part) if part.nil? text = "[ Email has no body, please see attachments ]" - source_charset = "utf-8" else - # by default, the body (coming from an foi_attachment) should have been converted to utf-8 - text = part.body - source_charset = part.charset + # whatever kind of attachment it is, get the UTF-8 encoded text + text = part.body_as_text.string if part.content_type == 'text/html' # e.g. http://www.whatdotheyknow.com/request/35/response/177 # TODO: This is a bit of a hack as it is calling a # convert to text routine. Could instead call a # sanitize HTML one. - - # If the text isn't UTF8, it means we had a problem - # converting it (invalid characters, etc), and we - # should instead tell elinks to respect the source - # charset - use_charset = "utf-8" - if String.method_defined?(:encode) - begin - text.encode('utf-8') - rescue Encoding::UndefinedConversionError, Encoding::InvalidByteSequenceError - use_charset = source_charset - end - else - begin - text = Iconv.conv('utf-8', 'utf-8', text) - rescue Iconv::IllegalSequence - use_charset = source_charset - end - end - text = MailHandler.get_attachment_text_one_file(part.content_type, text, use_charset) + text = MailHandler.get_attachment_text_one_file(part.content_type, text, "UTF-8") end end - # If text hasn't been converted, we sanitise it. - text = _sanitize_text(text) + # Add an annotation if the text had to be scrubbed + if part.body_as_text.scrubbed? + text += _("\n\n[ {{site_name}} note: The above text was badly encoded, and has had strange characters removed. ]", + :site_name => MySociety::Config.get('SITE_NAME', 'Alaveteli')) + end # Fix DOS style linefeeds to Unix style ones (or other later regexps won't work) text = text.gsub(/\r\n/, "\n") @@ -417,50 +400,6 @@ class IncomingMessage < ActiveRecord::Base return text end - def _sanitize_text(text) - if String.method_defined?(:encode) - begin - # Test if it's good UTF-8 - text.encode('utf-8') - rescue Encoding::UndefinedConversionError, Encoding::InvalidByteSequenceError - source_charset = 'utf-8' if source_charset.nil? - # strip out anything that isn't UTF-8 - begin - text = text.encode("utf-8", :invalid => :replace, - :undef => :replace, - :replace => "") + - _("\n\n[ {{site_name}} note: The above text was badly encoded, and has had strange characters removed. ]", - :site_name => MySociety::Config.get('SITE_NAME', 'Alaveteli')) - rescue Encoding::UndefinedConversionError, Encoding::InvalidByteSequenceError - if source_charset != "utf-8" - source_charset = "utf-8" - retry - end - end - end - else - begin - # Test if it's good UTF-8 - text = Iconv.conv('utf-8', 'utf-8', text) - rescue Iconv::IllegalSequence - # Text looks like unlabelled nonsense, - # strip out anything that isn't UTF-8 - begin - source_charset = 'utf-8' if source_charset.nil? - text = Iconv.conv('utf-8//IGNORE', source_charset, text) + - _("\n\n[ {{site_name}} note: The above text was badly encoded, and has had strange characters removed. ]", - :site_name => AlaveteliConfiguration::site_name) - rescue Iconv::InvalidEncoding, Iconv::IllegalSequence, Iconv::InvalidCharacter - if source_charset != "utf-8" - source_charset = "utf-8" - retry - end - end - end - end - text - end - # Returns part which contains main body text, or nil if there isn't one, # from a set of foi_attachments. If the leaves parameter is empty or not # supplied, uses its own foi_attachments. @@ -560,7 +499,7 @@ class IncomingMessage < ActiveRecord::Base # because the hexdigest of an attachment is identical. main_part = get_main_body_text_part(attachments) # we don't use get_main_body_text_internal, as we want to avoid charset - # conversions, since /usr/bin/uudecode needs to deal with those. + # conversions, since _uudecode_and_save_attachments needs to deal with those. # e.g. for https://secure.mysociety.org/admin/foi/request/show_raw_email/24550 if !main_part.nil? uudecoded_attachments = _uudecode_and_save_attachments(main_part.body) @@ -676,16 +615,7 @@ class IncomingMessage < ActiveRecord::Base end def _get_attachment_text_internal - text = self._extract_text - - # Remove any bad characters - if String.method_defined?(:encode) - # handle "problematic" encoding - text.encode!('UTF-16', 'UTF-8', :invalid => :replace, :undef => :replace, :replace => '') - text.encode('UTF-8', 'UTF-16') - else - Iconv.conv('utf-8//IGNORE', 'utf-8', text) - end + convert_string_to_utf8(_extract_text, 'UTF-8').string end # Returns text for indexing @@ -719,7 +649,7 @@ class IncomingMessage < ActiveRecord::Base end # Search all info requests for - def IncomingMessage.find_all_unknown_mime_types + def self.find_all_unknown_mime_types for incoming_message in IncomingMessage.find(:all) for attachment in incoming_message.get_attachments_for_display raise "internal error incoming_message " + incoming_message.id.to_s if attachment.content_type.nil? @@ -745,16 +675,9 @@ class IncomingMessage < ActiveRecord::Base return ret.keys.join(" ") end # Return space separated list of all file extensions known - def IncomingMessage.get_all_file_extensions + def self.get_all_file_extensions return AlaveteliFileTypes.all_extensions.join(" ") end - - def for_admin_column - self.class.content_columns.each do |column| - yield(column.human_name, self.send(column.name), column.type.to_s, column.name) - end - end - end diff --git a/app/models/info_request.rb b/app/models/info_request.rb index c203f75c3..3ce0e3cd2 100644 --- a/app/models/info_request.rb +++ b/app/models/info_request.rb @@ -1,4 +1,4 @@ -# encoding: utf-8 +# -*- encoding : utf-8 -*- # == Schema Information # Schema version: 20131024114346 # @@ -28,8 +28,11 @@ require 'digest/sha1' class InfoRequest < ActiveRecord::Base + include AdminColumn include Rails.application.routes.url_helpers + @non_admin_columns = %w(title url_title) + strip_attributes! validates_presence_of :title, :message => N_("Please enter a summary of your request") @@ -50,6 +53,7 @@ class InfoRequest < ActiveRecord::Base has_many :info_request_events, :order => 'created_at' has_many :user_info_request_sent_alerts has_many :track_things, :order => 'created_at desc' + has_many :widget_votes has_many :comments, :order => 'created_at' has_many :censor_rules, :order => 'created_at desc' has_many :mail_server_logs, :order => 'mail_server_log_done_id' @@ -193,23 +197,12 @@ class InfoRequest < ActiveRecord::Base rescue MissingSourceFile, NameError end - # only check on create, so existing models with mixed case are allowed - def validate_on_create - if !self.title.nil? && !MySociety::Validate.uses_mixed_capitals(self.title, 10) - errors.add(:title, _('Please write the summary using a mixture of capital and lower case letters. This makes it easier for others to read.')) - end - if !self.title.nil? && title.size > 200 - errors.add(:title, _('Please keep the summary short, like in the subject of an email. You can use a phrase, rather than a full sentence.')) - end - if !self.title.nil? && self.title =~ /^(FOI|Freedom of Information)\s*requests?$/i - errors.add(:title, _('Please describe more what the request is about in the subject. There is no need to say it is an FOI request, we add that on anyway.')) - end - end - OLD_AGE_IN_DAYS = 21.days def visible_comments - self.comments.find(:all, :conditions => 'visible') + warn %q([DEPRECATION] InfoRequest#visible_comments will be replaced with + InfoRequest#comments.visible as of 0.23).squish + comments.visible end # If the URL name has changed, then all request: queries will break unless @@ -345,7 +338,7 @@ public # only they are sent the email address with the has in it. (We don't check # the prefix and domain, as sometimes those change, or might be elided by # copying an email, and that doesn't matter) - def InfoRequest.find_by_incoming_email(incoming_email) + def self.find_by_incoming_email(incoming_email) id, hash = InfoRequest._extract_id_hash_from_email(incoming_email) if hash_from_id(id) == hash # Not using find(id) because we don't exception raised if nothing found @@ -355,7 +348,7 @@ public # Return list of info requests which *might* be right given email address # e.g. For the id-hash email addresses, don't match the hash. - def InfoRequest.guess_by_incoming_email(incoming_message) + def self.guess_by_incoming_email(incoming_message) guesses = [] # 1. Try to guess based on the email address(es) incoming_message.addresses.each do |address| @@ -367,7 +360,7 @@ public end # Internal function used by find_by_magic_email and guess_by_incoming_email - def InfoRequest._extract_id_hash_from_email(incoming_email) + def self._extract_id_hash_from_email(incoming_email) # Match case insensitively, FOI officers often write Request with capital R. incoming_email = incoming_email.downcase @@ -394,7 +387,7 @@ public # repeated requests, say once a quarter for time information, then might need to do that. # TODO: this *should* also check outgoing message joined to is an initial # request (rather than follow up) - def InfoRequest.find_existing(title, public_body_id, body) + def self.find_existing(title, public_body_id, body) return InfoRequest.find(:first, :conditions => [ "title = ? and public_body_id = ? and outgoing_messages.body = ?", title, public_body_id, body ], :include => [ :outgoing_messages ] ) end @@ -534,7 +527,7 @@ public # The "holding pen" is a special request which stores incoming emails whose # destination request is unknown. - def InfoRequest.holding_pen_request + def self.holding_pen_request ir = InfoRequest.find_by_url_title("holding_pen") if ir.nil? ir = InfoRequest.new( @@ -549,7 +542,7 @@ public :status => 'ready', :message_type => 'initial_request', :body => 'This is the holding pen request. It shows responses that were sent to invalid addresses, and need moving to the correct request by an adminstrator.', - :last_sent_at => Time.now(), + :last_sent_at => Time.now, :what_doing => 'normal_sort' }) @@ -564,7 +557,7 @@ public # states which require administrator action (hence email administrators # when they are entered, and offer state change dialog to them) - def InfoRequest.requires_admin_states + def self.requires_admin_states return ['requires_admin', 'error_message', 'attention_requested'] end @@ -665,11 +658,11 @@ public if !curr_state.nil? && event.event_type == 'response' if event.calculated_state != curr_state event.calculated_state = curr_state - event.last_described_at = Time.now() + event.last_described_at = Time.now event.save! end if event.last_described_at.nil? # TODO: actually maybe this isn't needed - event.last_described_at = Time.now() + event.last_described_at = Time.now event.save! end curr_state = nil @@ -681,7 +674,7 @@ public # indexed. if event.calculated_state != event.described_state event.calculated_state = event.described_state - event.last_described_at = Time.now() + event.last_described_at = Time.now event.save! end @@ -698,7 +691,7 @@ public # case there is a preceding response that the described state should be applied to. if event.calculated_state != event.described_state event.calculated_state = event.described_state - event.last_described_at = Time.now() + event.last_described_at = Time.now event.save! end end @@ -783,7 +776,14 @@ public end def public_response_events - self.info_request_events.select{|e| e.response? && e.incoming_message.all_can_view? } + condition = <<-SQL + info_request_events.event_type = ? + AND incoming_messages.prominence = ? + SQL + + info_request_events. + joins(:incoming_message). + where(condition, 'response', 'normal') end # The last public response is the default one people might want to reply to @@ -810,8 +810,9 @@ public # Text from the the initial request, for use in summary display def initial_request_text - return '' if outgoing_messages.empty? # mainly for use with incomplete fixtures - outgoing_messages.first.get_text_for_indexing + return '' if outgoing_messages.empty? + body_opts = { :censor_rules => applicable_censor_rules } + outgoing_messages.first.try(:get_text_for_indexing, true, body_opts) or '' end # Returns index of last event which is described or nil if none described. @@ -873,7 +874,7 @@ public # Display version of status - def InfoRequest.get_status_description(status) + def self.get_status_description(status) descriptions = { 'waiting_classification' => _("Awaiting classification."), 'waiting_response' => _("Awaiting response."), @@ -908,21 +909,24 @@ public # Completely delete this request and all objects depending on it def fully_destroy - self.track_things.each do |track_thing| + track_things.each do |track_thing| track_thing.track_things_sent_emails.each { |a| a.destroy } track_thing.destroy end - self.user_info_request_sent_alerts.each { |a| a.destroy } - self.info_request_events.each do |info_request_event| + user_info_request_sent_alerts.each { |a| a.destroy } + info_request_events.each do |info_request_event| info_request_event.track_things_sent_emails.each { |a| a.destroy } info_request_event.destroy end - self.mail_server_logs.each do |mail_server_log| + mail_server_logs.each do |mail_server_log| mail_server_log.destroy end - self.outgoing_messages.each { |a| a.destroy } - self.incoming_messages.each { |a| a.destroy } - self.destroy + outgoing_messages.each { |a| a.destroy } + incoming_messages.each { |a| a.destroy } + comments.each { |comment| comment.destroy } + censor_rules.each{ |censor_rule| censor_rule.destroy } + + destroy end # Called by incoming_email - and used to be called to generate separate @@ -932,7 +936,7 @@ public return InfoRequest.magic_email_for_id(prefix_part, self.id) end - def InfoRequest.magic_email_for_id(prefix_part, id) + def self.magic_email_for_id(prefix_part, id) magic_email = AlaveteliConfiguration::incoming_email_prefix magic_email += prefix_part + id.to_s magic_email += "-" + InfoRequest.hash_from_id(id) @@ -946,7 +950,7 @@ public self.idhash = InfoRequest.hash_from_id(self.id) end - def InfoRequest.create_from_attributes(info_request_atts, outgoing_message_atts, user=nil) + def self.create_from_attributes(info_request_atts, outgoing_message_atts, user=nil) info_request = new(info_request_atts) default_message_params = { :status => 'ready', @@ -960,12 +964,12 @@ public info_request end - def InfoRequest.hash_from_id(id) + def self.hash_from_id(id) return Digest::SHA1.hexdigest(id.to_s + AlaveteliConfiguration::incoming_email_secret)[0,8] end # Used to find when event last changed - def InfoRequest.last_event_time_clause(event_type=nil, join_table=nil, join_clause=nil) + def self.last_event_time_clause(event_type=nil, join_table=nil, join_clause=nil) event_type_clause = '' event_type_clause = " AND info_request_events.event_type = '#{event_type}'" if event_type tables = ['info_request_events'] @@ -980,20 +984,20 @@ public LIMIT 1)" end - def InfoRequest.last_public_response_clause() + def self.last_public_response_clause join_clause = "incoming_messages.id = info_request_events.incoming_message_id AND incoming_messages.prominence = 'normal'" last_event_time_clause('response', 'incoming_messages', join_clause) end - def InfoRequest.old_unclassified_params(extra_params, include_last_response_time=false) - last_response_created_at = last_public_response_clause() + def self.old_unclassified_params(extra_params, include_last_response_time=false) + last_response_created_at = last_public_response_clause age = extra_params[:age_in_days] ? extra_params[:age_in_days].days : OLD_AGE_IN_DAYS params = { :conditions => ["awaiting_description = ? AND #{last_response_created_at} < ? AND url_title != 'holding_pen' AND user_id IS NOT NULL", - true, Time.now() - age] } + true, Time.now - age] } if include_last_response_time params[:select] = "*, #{last_response_created_at} AS last_response_time" params[:order] = 'last_response_time' @@ -1001,29 +1005,21 @@ public return params end - def InfoRequest.count_old_unclassified(extra_params={}) + def self.count_old_unclassified(extra_params={}) params = old_unclassified_params(extra_params) - if extra_params[:conditions] - condition_string = extra_params[:conditions].shift - params[:conditions][0] += " AND #{condition_string}" - params[:conditions] += extra_params[:conditions] - end + add_conditions_from_extra_params(params, extra_params) count(:all, params) end - def InfoRequest.get_random_old_unclassified(limit, extra_params) + def self.get_random_old_unclassified(limit, extra_params) params = old_unclassified_params({}) - if extra_params[:conditions] - condition_string = extra_params[:conditions].shift - params[:conditions][0] += " AND #{condition_string}" - params[:conditions] += extra_params[:conditions] - end + add_conditions_from_extra_params(params, extra_params) params[:limit] = limit params[:order] = "random()" find(:all, params) end - def InfoRequest.find_old_unclassified(extra_params={}) + def self.find_old_unclassified(extra_params={}) params = old_unclassified_params(extra_params, include_last_response_time=true) [:limit, :include, :offset].each do |extra| params[extra] = extra_params[extra] if extra_params[extra] @@ -1032,15 +1028,11 @@ public params[:order] = extra_params[:order] params.delete(:select) end - if extra_params[:conditions] - condition_string = extra_params[:conditions].shift - params[:conditions][0] += " AND #{condition_string}" - params[:conditions] += extra_params[:conditions] - end + add_conditions_from_extra_params(params, extra_params) find(:all, params) end - def InfoRequest.download_zip_dir() + def self.download_zip_dir File.join(Rails.root, "cache", "zips", "#{Rails.env}") end @@ -1058,7 +1050,7 @@ public end def request_dirs - first_three_digits = id.to_s()[0..2] + first_three_digits = id.to_s[0..2] File.join(first_three_digits.to_s, id.to_s) end @@ -1067,7 +1059,7 @@ public end def make_zip_cache_path(user) - cache_file_dir = File.join(InfoRequest.download_zip_dir(), + cache_file_dir = File.join(InfoRequest.download_zip_dir, "download", request_dirs, last_update_hash) @@ -1191,7 +1183,7 @@ public end # This is called from cron regularly. - def InfoRequest.stop_new_responses_on_old_requests + def self.stop_new_responses_on_old_requests # 6 months since last change to request, only allow new incoming messages from authority domains InfoRequest.update_all "allow_new_responses_from = 'authority_only' where updated_at < (now() - interval '6 months') and allow_new_responses_from = 'anybody' and url_title <> 'holding_pen'" # 1 year since last change requests, don't allow any new incoming messages @@ -1240,7 +1232,7 @@ public :model => self.class.base_class.to_s, :model_id => self.id) end - req.save() + req.save end end @@ -1270,13 +1262,6 @@ public PublicBody.set_callback(:save, :after, :purge_in_cache) end - def for_admin_column - self.class.content_columns.map{|c| c unless %w(title url_title).include?(c.name) }.compact.each do |column| - yield(column.human_name, self.send(column.name), column.type.to_s, column.name) - end - end - - # Get requests that have similar important terms def similar_requests(limit=10) xapian_similar = nil @@ -1292,7 +1277,7 @@ public return [xapian_similar, xapian_similar_more] end - def InfoRequest.request_list(filters, page, per_page, max_results) + def self.request_list(filters, page, per_page, max_results) xapian_object = ActsAsXapian::Search.new([InfoRequestEvent], InfoRequestEvent.make_query_from_params(filters), :offset => (page - 1) * per_page, @@ -1309,7 +1294,7 @@ public :show_no_more_than => show_no_more_than } end - def InfoRequest.recent_requests + def self.recent_requests request_events = [] request_events_all_successful = false # Get some successful requests @@ -1356,12 +1341,45 @@ public return [request_events, request_events_all_successful] end - def InfoRequest.find_in_state(state) + def self.find_in_state(state) select("*, #{ last_event_time_clause } as last_event_time"). where(:described_state => state). order('last_event_time') end + def move_to_public_body(destination_public_body, opts = {}) + old_body = public_body + editor = opts.fetch(:editor) + + attrs = { :public_body => destination_public_body } + + if destination_public_body + attrs.merge!({ + :law_used => destination_public_body.law_only_short.downcase + }) + end + + if update_attributes(attrs) + log_event('move_request', + :editor => editor, + :public_body_url_name => public_body.url_name, + :old_public_body_url_name => old_body.url_name) + + reindex_request_events + + public_body + end + end + + # The DateTime of the last InfoRequestEvent belonging to the InfoRequest + # Only available if the last_event_time attribute has been set. This is + # currentlt only set through .find_in_state + # + # Returns a DateTime + def last_event_time + attributes['last_event_time'].try(:to_datetime) + end + private def set_defaults @@ -1370,11 +1388,12 @@ public self.described_state = 'waiting_response' end rescue ActiveModel::MissingAttributeError - # this should only happen on Model.exists?() call. It can be safely ignored. + # this should only happen on Model.exists? call. It can be safely ignored. # See http://www.tatvartha.com/2011/03/activerecordmissingattributeerror-missing-attribute-a-bug-or-a-features/ end + # FOI or EIR? - if !self.public_body.nil? && self.public_body.eir_only? + if new_record? && public_body && public_body.eir_only? self.law_used = 'eir' end end @@ -1390,5 +1409,13 @@ public errors.add(:title, _('Please describe more what the request is about in the subject. There is no need to say it is an FOI request, we add that on anyway.')) end end + + def self.add_conditions_from_extra_params(params, extra_params) + if extra_params[:conditions] + condition_string = extra_params[:conditions].shift + params[:conditions][0] += " AND #{condition_string}" + params[:conditions] += extra_params[:conditions] + end + end end diff --git a/app/models/info_request_batch.rb b/app/models/info_request_batch.rb index 8a5ebeaba..684467c61 100644 --- a/app/models/info_request_batch.rb +++ b/app/models/info_request_batch.rb @@ -1,3 +1,4 @@ +# -*- encoding : utf-8 -*- # == Schema Information # # Table name: info_request_batches @@ -21,7 +22,7 @@ class InfoRequestBatch < ActiveRecord::Base validates_presence_of :body # When constructing a new batch, use this to check user hasn't double submitted. - def InfoRequestBatch.find_existing(user, title, body, public_body_ids) + def self.find_existing(user, title, body, public_body_ids) find(:first, :conditions => ['user_id = ? AND title = ? AND body = ? @@ -69,7 +70,7 @@ class InfoRequestBatch < ActiveRecord::Base info_request end - def InfoRequestBatch.send_batches() + def self.send_batches find_each(:conditions => "sent_at IS NULL") do |info_request_batch| unrequestable = info_request_batch.create_batch! mail_message = InfoRequestBatchMailer.batch_sent(info_request_batch, diff --git a/app/models/info_request_event.rb b/app/models/info_request_event.rb index 635ba8f58..263de20a0 100644 --- a/app/models/info_request_event.rb +++ b/app/models/info_request_event.rb @@ -1,3 +1,4 @@ +# -*- encoding : utf-8 -*- # == Schema Information # # Table name: info_request_events @@ -21,7 +22,7 @@ # Email: hello@mysociety.org; WWW: http://www.mysociety.org/ class InfoRequestEvent < ActiveRecord::Base - + include AdminColumn extend XapianQueries belongs_to :info_request @@ -278,9 +279,15 @@ class InfoRequestEvent < ActiveRecord::Base end self.params_yaml = params.to_yaml end + def params - YAML.load(self.params_yaml) + param_hash = YAML.load(params_yaml) + param_hash.each do |key, value| + param_hash[key] = value.force_encoding('UTF-8') if value.respond_to?(:force_encoding) + end + param_hash end + def params_yaml_as_html ret = '' # split out parameters into old/new diffs, and other ones @@ -319,9 +326,17 @@ class InfoRequestEvent < ActiveRecord::Base end - def is_incoming_message?() not self.incoming_message_selective_columns("incoming_messages.id").nil? end - def is_outgoing_message?() not self.outgoing_message.nil? end - def is_comment?() not self.comment.nil? end + def is_incoming_message? + incoming_message_id? or (incoming_message if new_record?) + end + + def is_outgoing_message? + outgoing_message_id? or (outgoing_message if new_record?) + end + + def is_comment? + comment_id? or (comment if new_record?) + end # Display version of status def display_status @@ -412,11 +427,4 @@ class InfoRequestEvent < ActiveRecord::Base return ret end - - def for_admin_column - self.class.content_columns.each do |column| - yield(column.human_name, self.send(column.name), column.type.to_s, column.name) - end - end - end diff --git a/app/models/mail_server_log.rb b/app/models/mail_server_log.rb index 07d2fdac0..64a740e1d 100644 --- a/app/models/mail_server_log.rb +++ b/app/models/mail_server_log.rb @@ -1,3 +1,4 @@ +# -*- encoding : utf-8 -*- # == Schema Information # # Table name: mail_server_logs @@ -25,7 +26,7 @@ class MailServerLog < ActiveRecord::Base # Doesn't do anything if file hasn't been modified since it was last loaded. # Note: If you do use rotated log files (rather than files named by date), at some # point old loaded log lines will get deleted in the database. - def MailServerLog.load_file(file_name) + def self.load_file(file_name) is_gz = file_name.include?(".gz") file_name_db = is_gz ? file_name.gsub(".gz", "") : file_name @@ -62,23 +63,16 @@ class MailServerLog < ActiveRecord::Base end # Scan the file - def MailServerLog.load_exim_log_data(f, done) + def self.load_exim_log_data(f, done) order = 0 f.each do |line| order = order + 1 emails = email_addresses_on_line(line) - for email in emails - info_request = InfoRequest.find_by_incoming_email(email) - if info_request - info_request.mail_server_logs.create!(:line => line, :order => order, :mail_server_log_done => done) - else - puts "Warning: Could not find request with email #{email}" - end - end + create_mail_server_logs(emails, line, order, done) end end - def MailServerLog.load_postfix_log_data(f, done) + def self.load_postfix_log_data(f, done) order = 0 emails = scan_for_postfix_queue_ids(f) # Go back to the beginning of the file @@ -87,19 +81,12 @@ class MailServerLog < ActiveRecord::Base order = order + 1 queue_id = extract_postfix_queue_id_from_syslog_line(line) if emails.has_key?(queue_id) - emails[queue_id].each do |email| - info_request = InfoRequest.find_by_incoming_email(email) - if info_request - info_request.mail_server_logs.create!(:line => line, :order => order, :mail_server_log_done => done) - else - puts "Warning: Could not find request with email #{email}" - end - end + create_mail_server_logs(emails[queue_id], line, order, done) end end end - def MailServerLog.scan_for_postfix_queue_ids(f) + def self.scan_for_postfix_queue_ids(f) result = {} f.each do |line| emails = email_addresses_on_line(line) @@ -111,7 +98,7 @@ class MailServerLog < ActiveRecord::Base end # Retuns nil if there is no queue id - def MailServerLog.extract_postfix_queue_id_from_syslog_line(line) + def self.extract_postfix_queue_id_from_syslog_line(line) # Assume the log file was written using syslog and parse accordingly m = SyslogProtocol.parse("<13>" + line).content.match(/^\S+: (\S+):/) m[1] if m @@ -119,13 +106,13 @@ class MailServerLog < ActiveRecord::Base # We also check the email prefix so that we could, for instance, separately handle a staging and production # instance running on the same server with different email prefixes. - def MailServerLog.email_addresses_on_line(line) + def self.email_addresses_on_line(line) prefix = Regexp::quote(AlaveteliConfiguration::incoming_email_prefix) domain = Regexp::quote(AlaveteliConfiguration::incoming_email_domain) line.scan(/#{prefix}request-[^\s]+@#{domain}/).sort.uniq end - def MailServerLog.request_sent?(ir) + def self.request_sent?(ir) case(AlaveteliConfiguration::mta_log_type.to_sym) when :exim request_exim_sent?(ir) @@ -137,7 +124,7 @@ class MailServerLog < ActiveRecord::Base end # Look at the log for a request and check that an email was delivered - def MailServerLog.request_exim_sent?(ir) + def self.request_exim_sent?(ir) # Look for line showing request was sent found = false ir.mail_server_logs.each do |mail_server_log| @@ -156,7 +143,7 @@ class MailServerLog < ActiveRecord::Base found end - def MailServerLog.request_postfix_sent?(ir) + def self.request_postfix_sent?(ir) # dsn=2.0.0 is the magic word that says that postfix delivered the email # See http://tools.ietf.org/html/rfc3464 ir.mail_server_logs.any? { |l| l.line.include?("dsn=2.0.0") } @@ -173,11 +160,11 @@ class MailServerLog < ActiveRecord::Base # NB: There can be several emails involved in a request. This just checks that # at least one of them has been succesfully sent. # - def MailServerLog.check_recent_requests_have_been_sent + def self.check_recent_requests_have_been_sent # Get all requests sent for from 2 to 10 days ago. The 2 day gap is # because we load mail server log lines via cron at best an hour after they # are made) - irs = InfoRequest.find(:all, :conditions => [ "created_at < ? and created_at > ? and user_id is not null", Time.now() - 2.day, Time.now() - 10.days ] ) + irs = InfoRequest.find(:all, :conditions => [ "created_at < ? and created_at > ? and user_id is not null", Time.now - 2.day, Time.now - 10.days ] ) # Go through each request and check it ok = true @@ -192,7 +179,17 @@ class MailServerLog < ActiveRecord::Base ok end -end - + private + def self.create_mail_server_logs(emails, line, order, done) + emails.each do |email| + info_request = InfoRequest.find_by_incoming_email(email) + if info_request + info_request.mail_server_logs.create!(:line => line, :order => order, :mail_server_log_done => done) + else + puts "Warning: Could not find request with email #{email}" + end + end + end +end diff --git a/app/models/mail_server_log_done.rb b/app/models/mail_server_log_done.rb index 1bbb23ac4..542c3db3a 100644 --- a/app/models/mail_server_log_done.rb +++ b/app/models/mail_server_log_done.rb @@ -1,3 +1,4 @@ +# -*- encoding : utf-8 -*- # == Schema Information # # Table name: mail_server_log_dones diff --git a/app/models/outgoing_message.rb b/app/models/outgoing_message.rb index c2c8ef4f2..2e1b27fba 100644 --- a/app/models/outgoing_message.rb +++ b/app/models/outgoing_message.rb @@ -1,3 +1,4 @@ +# -*- encoding : utf-8 -*- # == Schema Information # Schema version: 20131024114346 # @@ -25,6 +26,7 @@ # Email: hello@mysociety.org; WWW: http://www.mysociety.org/ class OutgoingMessage < ActiveRecord::Base + include AdminColumn extend MessageProminence include Rails.application.routes.url_helpers include LinkToHelper @@ -140,22 +142,28 @@ class OutgoingMessage < ActiveRecord::Base end end - def body - ret = read_attribute(:body) - if ret.nil? - return ret + # Public: The body text of the OutgoingMessage. The text is cleaned and + # CensorRules are applied. + # + # options - Hash of options + # :censor_rules - Array of CensorRules to apply. Defaults to the + # applicable_censor_rules of the associated + # InfoRequest. (optional) + # + # Returns a String + def body(options = {}) + text = raw_body.dup + return text if text.nil? + + text = clean_text(text) + + # Use the given censor_rules; otherwise fetch them from the associated + # info_request + censor_rules = options.fetch(:censor_rules) do + info_request.try(:applicable_censor_rules) or [] end - ret = ret.dup - ret.strip! - ret.gsub!(/(?:\n\s*){2,}/, "\n\n") # remove excess linebreaks that unnecessarily space it out - - # Remove things from censor rules - unless info_request.nil? - self.info_request.apply_censor_rules_to_text!(ret) - end - - ret + censor_rules.reduce(text) { |text, rule| rule.apply_to_text(text) } end def raw_body @@ -227,8 +235,12 @@ class OutgoingMessage < ActiveRecord::Base end # Returns text for indexing / text display - def get_text_for_indexing(strip_salutation = true) - text = body.strip + def get_text_for_indexing(strip_salutation = true, opts = {}) + if opts.empty? + text = body.strip + else + text = body(opts).strip + end # Remove salutation text.sub!(/Dear .+,/, "") if strip_salutation @@ -272,12 +284,6 @@ class OutgoingMessage < ActiveRecord::Base info_request.purge_in_cache end - def for_admin_column - self.class.content_columns.each do |column| - yield(column.human_name, self.send(column.name), column.type.to_s, column.name) - end - end - def xapian_reindex_after_update if changes.include?('body') info_request_events.each do |event| @@ -332,6 +338,11 @@ class OutgoingMessage < ActiveRecord::Base errors.add(:what_doing_dummy, _('Please choose what sort of reply you are making.')) end end + + # remove excess linebreaks that unnecessarily space it out + def clean_text(text) + text.strip.gsub(/(?:\n\s*){2,}/, "\n\n") + end end diff --git a/app/models/post_redirect.rb b/app/models/post_redirect.rb index 8049349d0..3cdc69995 100644 --- a/app/models/post_redirect.rb +++ b/app/models/post_redirect.rb @@ -1,3 +1,4 @@ +# -*- encoding : utf-8 -*- # == Schema Information # # Table name: post_redirects @@ -71,7 +72,11 @@ class PostRedirect < ActiveRecord::Base end def reason_params - YAML.load(reason_params_yaml) + param_hash = YAML.load(reason_params_yaml) + param_hash.each do |key, value| + param_hash[key] = value.force_encoding('UTF-8') if value.respond_to?(:force_encoding) + end + param_hash end # Extract just local path part, without domain or # diff --git a/app/models/profile_photo.rb b/app/models/profile_photo.rb index 61f88faf3..94edc2967 100644 --- a/app/models/profile_photo.rb +++ b/app/models/profile_photo.rb @@ -1,3 +1,4 @@ +# -*- encoding : utf-8 -*- # == Schema Information # # Table name: profile_photos diff --git a/app/models/public_body.rb b/app/models/public_body.rb index 232c0ffa1..ac924a941 100644 --- a/app/models/public_body.rb +++ b/app/models/public_body.rb @@ -1,4 +1,4 @@ -# -*- coding: utf-8 -*- +# -*- encoding : utf-8 -*- # == Schema Information # Schema version: 20131024114346 # @@ -32,7 +32,32 @@ require 'securerandom' require 'set' class PublicBody < ActiveRecord::Base - strip_attributes! + include AdminColumn + + class ImportCSVDryRun < StandardError ; end + + @non_admin_columns = %w(name last_edit_comment) + + attr_accessor :no_xapian_reindex + + # Default fields available for importing from CSV, in the format + # [field_name, 'short description of field (basic html allowed)'] + cattr_accessor :csv_import_fields do + [ + ['name', '(i18n)<strong>Existing records cannot be renamed</strong>'], + ['short_name', '(i18n)'], + ['request_email', '(i18n)'], + ['notes', '(i18n)'], + ['publication_scheme', '(i18n)'], + ['disclosure_log', '(i18n)'], + ['home_page', ''], + ['tag_string', '(tags separated by spaces)'], + ] + end + + has_many :info_requests, :order => 'created_at desc' + has_many :track_things, :order => 'created_at desc' + has_many :censor_rules, :order => 'created_at desc' validates_presence_of :name, :message => N_("Name can't be blank") validates_presence_of :url_name, :message => N_("URL name can't be blank") @@ -43,19 +68,12 @@ class PublicBody < ActiveRecord::Base validate :request_email_if_requestable - has_many :info_requests, :order => 'created_at desc' - has_many :track_things, :order => 'created_at desc' - has_many :censor_rules, :order => 'created_at desc' - attr_accessor :no_xapian_reindex - - has_tag_string - - before_save :set_api_key, - :set_default_publication_scheme, - :set_first_letter + before_save :set_api_key!, :unless => :api_key + before_save :set_default_publication_scheme after_save :purge_in_cache after_update :reindex_requested_from + # Every public body except for the internal admin one is visible scope :visible, lambda { { @@ -63,39 +81,83 @@ class PublicBody < ActiveRecord::Base } } + acts_as_versioned + acts_as_xapian :texts => [:name, :short_name, :notes], + :values => [ + # for sorting + [:created_at_numeric, 1, "created_at", :number] + ], + :terms => [ + [:variety, 'V', "variety"], + [:tag_array_for_search, 'U', "tag"] + ] + has_tag_string + strip_attributes! translates :name, :short_name, :request_email, :url_name, :notes, :first_letter, :publication_scheme - accepts_nested_attributes_for :translations, :reject_if => :empty_translation_in_params? - # Default fields available for importing from CSV, in the format - # [field_name, 'short description of field (basic html allowed)'] - cattr_accessor :csv_import_fields do - [ - ['name', '(i18n)<strong>Existing records cannot be renamed</strong>'], - ['short_name', '(i18n)'], - ['request_email', '(i18n)'], - ['notes', '(i18n)'], - ['publication_scheme', '(i18n)'], - ['disclosure_log', '(i18n)'], - ['home_page', ''], - ['tag_string', '(tags separated by spaces)'], - ] - end + # Cannot be grouped at top as it depends on the `translates` macro + include Translatable - acts_as_xapian :texts => [ :name, :short_name, :notes ], - :values => [ - [ :created_at_numeric, 1, "created_at", :number ] # for sorting - ], - :terms => [ [ :variety, 'V', "variety" ], - [ :tag_array_for_search, 'U', "tag" ] - ] + # Cannot be grouped at top as it depends on the `translates` macro + include PublicBodyDerivedFields + + # Cannot be grouped at top as it depends on the `translates` macro + class Translation + include PublicBodyDerivedFields + end - acts_as_versioned self.non_versioned_columns << 'created_at' << 'updated_at' << 'first_letter' << 'api_key' self.non_versioned_columns << 'info_requests_count' << 'info_requests_successful_count' self.non_versioned_columns << 'info_requests_count' << 'info_requests_visible_classified_count' self.non_versioned_columns << 'info_requests_not_held_count' << 'info_requests_overdue' self.non_versioned_columns << 'info_requests_overdue_count' + # Cannot be defined directly under `include` statements as this is opening + # the PublicBody::Version class dynamically defined by the + # `acts_as_versioned` macro. + # + # TODO: acts_as_versioned accepts an extend parameter [1] so these methods + # could be extracted to a module: + # + # acts_as_versioned :extend => PublicBodyVersionExtensions + # + # This includes the module in both the parent class (PublicBody) and the + # Version class (PublicBody::Version), so the behaviour is slightly + # different to opening up PublicBody::Version. + # + # We could add an `extend_version_class` option pretty trivially by + # following the pattern for the existing `extend` option. + # + # [1] http://git.io/vIetK + class Version + def last_edit_comment_for_html_display + text = self.last_edit_comment.strip + text = CGI.escapeHTML(text) + text = MySociety::Format.make_clickable(text) + text = text.gsub(/\n/, '<br>') + return text + end + + def compare(previous = nil) + if previous.nil? + yield([]) + else + v = self + changes = self.class.content_columns.inject([]) {|memo, c| + unless %w(version last_edit_editor last_edit_comment updated_at).include?(c.name) + from = previous.send(c.name) + to = self.send(c.name) + memo << { :name => c.human_name, :from => from, :to => to } if from != to + end + memo + } + changes.each do |change| + yield(change) + end + end + end + end + # Public: Search for Public Bodies whose name, short_name, request_email or # tags contain the given query # @@ -124,97 +186,62 @@ class PublicBody < ActiveRecord::Base uniq end - # Convenience methods for creating/editing translations via forms - def find_translation_by_locale(locale) - self.translations.find_by_locale(locale) - end - - # TODO: - Don't like repeating this! - def calculate_cached_fields(t) - PublicBody.set_first_letter(t) - short_long_name = t.name - short_long_name = t.short_name if t.short_name and !t.short_name.empty? - t.url_name = MySociety::Format.simplify_url_part(short_long_name, 'body') - end - - # Set the first letter on a public body or translation - def PublicBody.set_first_letter(instance) - unless instance.name.nil? or instance.name.empty? - # we use a regex to ensure it works with utf-8/multi-byte - first_letter = Unicode.upcase instance.name.scan(/^./mu)[0] - if first_letter != instance.first_letter - instance.first_letter = first_letter - end - end - end - - def translated_versions - translations - end - - def ordered_translations - translations. - select { |t| I18n.available_locales.include?(t.locale) }. - sort_by { |t| I18n.available_locales.index(t.locale) } + def set_api_key + set_api_key! if api_key.nil? end - def build_all_translations - I18n.available_locales.each do |locale| - translations.build(:locale => locale) unless translations.detect{ |t| t.locale == locale } - end + def set_api_key! + self.api_key = SecureRandom.base64(33) end - def translated_versions=(translation_attrs) - warn "[DEPRECATION] PublicBody#translated_versions= will be replaced " \ - "by PublicBody#translations_attributes= as of release 0.22" - self.translations_attributes = translation_attrs - end + # like find_by_url_name but also search historic url_name if none found + def self.find_by_url_name_with_historic(name) + # If many bodies are found (usually because the url_name is the same + # across locales) return any of them. + found = joins(:translations). + where("public_body_translations.url_name = ?", name). + readonly(false). + first - def set_default_publication_scheme - # Make sure publication_scheme gets the correct default value. - # (This would work automatically, were publication_scheme not a translated attribute) - self.publication_scheme = "" if self.publication_scheme.nil? - end + return found if found - def set_api_key - self.api_key = SecureRandom.base64(33) if self.api_key.nil? - end + # If none found, then search the history of short names and find unique + # public bodies in it + old = PublicBody::Version. + where(:url_name => name). + pluck('DISTINCT public_body_id') - # like find_by_url_name but also search historic url_name if none found - def self.find_by_url_name_with_historic(name) - found = PublicBody.find(:all, - :conditions => ["public_body_translations.url_name=?", name], - :joins => :translations, - :readonly => false) - # If many bodies are found (usually because the url_name is the same across - # locales) return any of them - return found.first if found.size >= 1 - - # If none found, then search the history of short names - old = PublicBody::Version.find_all_by_url_name(name) - # Find unique public bodies in it - old = old.map { |x| x.public_body_id } - old = old.uniq # Maybe return the first one, so we show something relevant, # rather than throwing an error? raise "Two bodies with the same historical URL name: #{name}" if old.size > 1 return unless old.size == 1 # does acts_as_versioned provide a method that returns the current version? - return PublicBody.find(old.first) - end - - # Set the first letter, which is used for faster queries - def set_first_letter - PublicBody.set_first_letter(self) + PublicBody.find(old.first) end # If tagged "not_apply", then FOI/EIR no longer applies to authority at all def not_apply? - return self.has_tag?('not_apply') + has_tag?('not_apply') end + # If tagged "defunct", then the authority no longer exists at all def defunct? - return self.has_tag?('defunct') + has_tag?('defunct') + end + + # Are all requests to this body under the Environmental Information + # Regulations? + def eir_only? + has_tag?('eir_only') + end + + # Schools are allowed more time in holidays, so we change some wordings + def is_school? + has_tag?('school') + end + + def site_administration? + has_tag?('site_administration') end # Can an FOI (etc.) request be made to this body? @@ -233,102 +260,39 @@ class PublicBody < ActiveRecord::Base # Also used as not_followable_reason def not_requestable_reason - if self.defunct? - return 'defunct' - elsif self.not_apply? - return 'not_apply' + if defunct? + 'defunct' + elsif not_apply? + 'not_apply' elsif !has_request_email? - return 'bad_contact' + 'bad_contact' else raise "not_requestable_reason called with type that has no reason" end end def special_not_requestable_reason? - self.defunct? || self.not_apply? - end - - - class Version - - def last_edit_comment_for_html_display - text = self.last_edit_comment.strip - text = CGI.escapeHTML(text) - text = MySociety::Format.make_clickable(text) - text = text.gsub(/\n/, '<br>') - return text - end - - def compare(previous = nil) - if previous.nil? - yield([]) - else - v = self - changes = self.class.content_columns.inject([]) {|memo, c| - unless %w(version last_edit_editor last_edit_comment updated_at).include?(c.name) - from = previous.send(c.name) - to = self.send(c.name) - memo << { :name => c.human_name, :from => from, :to => to } if from != to - end - memo - } - changes.each do |change| - yield(change) - end - end - end + defunct? || not_apply? end def created_at_numeric # format it here as no datetime support in Xapian's value ranges - return self.created_at.strftime("%Y%m%d%H%M%S") - end - def variety - return "authority" - end - - # if the URL name has changed, then all requested_from: queries - # will break unless we update index for every event for every - # request linked to it - def reindex_requested_from - if self.changes.include?('url_name') - for info_request in self.info_requests - - for info_request_event in info_request.info_request_events - info_request_event.xapian_mark_needs_index - end - end - end - end - - # When name or short name is changed, also change the url name - def short_name=(short_name) - globalize.write(Globalize.locale, :short_name, short_name) - self[:short_name] = short_name - self.update_url_name - end - - def name=(name) - globalize.write(Globalize.locale, :name, name) - self[:name] = name - self.update_url_name + created_at.strftime("%Y%m%d%H%M%S") end - def update_url_name - self.url_name = MySociety::Format.simplify_url_part(self.short_or_long_name, 'body') + def variety + "authority" end - # Return the short name if present, or else long name - def short_or_long_name - if self.short_name.nil? || self.short_name.empty? # 'nil' can happen during construction - self.name.nil? ? "" : self.name - else - self.short_name - end + def law_only_short + eir_only? ? 'EIR' : 'FOI' end # Guess home page from the request email, or use explicit override, or nil # if not known. + # + # TODO: PublicBody#calculated_home_page would be a good candidate to cache + # in an instance variable def calculated_home_page if home_page && !home_page.empty? home_page[URI::regexp(%w(http https))] ? home_page : "http://#{home_page}" @@ -337,25 +301,8 @@ class PublicBody < ActiveRecord::Base end end - # Are all requests to this body under the Environmental Information Regulations? - def eir_only? - return self.has_tag?('eir_only') - end - def law_only_short - if self.eir_only? - return "EIR" - else - return "FOI" - end - end - - # Schools are allowed more time in holidays, so we change some wordings - def is_school? - return self.has_tag?('school') - end - # The "internal admin" is a special body for internal use. - def PublicBody.internal_admin_body + def self.internal_admin_body # Use find_by_sql to avoid the search being specific to a # locale, since url_name is a translated field: sql = "SELECT * FROM public_bodies WHERE url_name = 'internal_admin_authority'" @@ -379,13 +326,6 @@ class PublicBody < ActiveRecord::Base end end - def site_administration? - has_tag?('site_administration') - end - - class ImportCSVDryRun < StandardError - end - # Import from a string in CSV format. # Just tests things and returns messages if dry_run is true. # Returns an array of [array of errors, array of notes]. If there @@ -412,7 +352,7 @@ class PublicBody < ActiveRecord::Base # matching names won't work afterwards, and we'll create new bodies instead # of updating them bodies_by_name = {} - set_of_existing = Set.new() + set_of_existing = Set.new internal_admin_body_id = PublicBody.internal_admin_body.id I18n.with_locale(I18n.default_locale) do bodies = (tag.nil? || tag.empty?) ? PublicBody.find(:all, :include => :translations) : PublicBody.find_by_tag(tag) @@ -425,7 +365,7 @@ class PublicBody < ActiveRecord::Base end end - set_of_importing = Set.new() + set_of_importing = Set.new # Default values in case no field list is given field_names = { 'name' => 1, 'request_email' => 2 } line = 0 @@ -565,40 +505,32 @@ class PublicBody < ActiveRecord::Base # Does this user have the power of FOI officer for this body? def is_foi_officer?(user) user_domain = user.email_domain - our_domain = self.request_email_domain - - if user_domain.nil? or our_domain.nil? - return false - end - - return our_domain == user_domain - end - def foi_officer_domain_required - return self.request_email_domain - end + our_domain = request_email_domain - # Returns nil if configuration variable not set - def override_request_email - e = AlaveteliConfiguration::override_all_public_body_request_emails - e if e != "" + return false if user_domain.nil? or our_domain.nil? + our_domain == user_domain end def request_email - if override_request_email - override_request_email - else + if AlaveteliConfiguration::override_all_public_body_request_emails.blank? || read_attribute(:request_email).blank? read_attribute(:request_email) + else + AlaveteliConfiguration::override_all_public_body_request_emails end end # Domain name of the request email def request_email_domain - return PublicBody.extract_domain_from_email(self.request_email) + PublicBody.extract_domain_from_email(request_email) end + alias_method :foi_officer_domain_required, :request_email_domain + # Return the domain part of an email address, canonicalised and with common # extra UK Government server name parts removed. - def PublicBody.extract_domain_from_email(email) + # + # TODO: Extract to library class + def self.extract_domain_from_email(email) email =~ /@(.*)/ if $1.nil? return nil @@ -615,51 +547,53 @@ class PublicBody < ActiveRecord::Base return ret end + # TODO: Could this be defined as `sorted_versions.reverse`? def reverse_sorted_versions - self.versions.sort { |a,b| b.version <=> a.version } + versions.sort { |a,b| b.version <=> a.version } end + def sorted_versions - self.versions.sort { |a,b| a.version <=> b.version } + versions.sort { |a,b| a.version <=> b.version } end def has_notes? - return !self.notes.nil? && self.notes != "" + !notes.nil? && notes != "" end + + # TODO: Deprecate this method. Its only used in a couple of views so easy to + # update to just call PublicBody#notes def notes_as_html - self.notes + notes end def notes_without_html - # assume notes are reasonably behaved HTML, so just use simple regexp on this - @notes_without_html ||= (self.notes.nil? ? '' : self.notes.gsub(/<\/?[^>]*>/, "")) + # assume notes are reasonably behaved HTML, so just use simple regexp + # on this + @notes_without_html ||= (notes.nil? ? '' : notes.gsub(/<\/?[^>]*>/, "")) end def json_for_api - return { - :id => self.id, - :url_name => self.url_name, - :name => self.name, - :short_name => self.short_name, - # :request_email # we hide this behind a captcha, to stop people doing bulk requests easily - :created_at => self.created_at, - :updated_at => self.updated_at, - # don't add the history as some edit comments contain sensitive information + { + :id => id, + :url_name => url_name, + :name => name, + :short_name => short_name, + # :request_email # we hide this behind a captcha, to stop people + # doing bulk requests easily + :created_at => created_at, + :updated_at => updated_at, + # don't add the history as some edit comments contain sensitive + # information # :version, :last_edit_editor, :last_edit_comment - :home_page => self.calculated_home_page, - :notes => self.notes, - :publication_scheme => self.publication_scheme, - :tags => self.tag_array, + :home_page => calculated_home_page, + :notes => notes, + :publication_scheme => publication_scheme, + :tags => tag_array, } end def purge_in_cache - self.info_requests.each {|x| x.purge_in_cache} - end - - def for_admin_column - self.class.content_columns.map{|c| c unless %w(name last_edit_comment).include?(c.name)}.compact.each do |column| - yield(column.human_name, self.send(column.name), column.type.to_s, column.name) - end + info_requests.each { |x| x.purge_in_cache } end def self.where_clause_for_stats(minimum_requests, total_column) @@ -732,6 +666,7 @@ class PublicBody < ActiveRecord::Base 'y_max' => 100, 'totals' => original_totals} end + def self.popular_bodies(locale) # get some example searches and public bodies to display # either from config, or based on a (slow!) query if not set @@ -758,6 +693,70 @@ class PublicBody < ActiveRecord::Base return bodies end + # Methods to privatise + # -------------------------------------------------------------------------- + + # TODO: This could be removed by updating the default value (to '') of the + # `publication_scheme` column in the `public_body_translations` table. + # + # TODO: Can't actually deprecate this because spec/script/mailin_spec.rb:28 + # fails due to the deprecation notice output + def set_default_publication_scheme + # warn %q([DEPRECATION] PublicBody#set_default_publication_scheme will + # become a private method in 0.23).squish + + # Make sure publication_scheme gets the correct default value. + # (This would work automatically, were publication_scheme not a + # translated attribute) + self.publication_scheme = "" if publication_scheme.nil? + end + + # if the URL name has changed, then all requested_from: queries + # will break unless we update index for every event for every + # request linked to it + # + # TODO: Can't actually deprecate this because spec/script/mailin_spec.rb:28 + # fails due to the deprecation notice output + def reindex_requested_from + # warn %q([DEPRECATION] PublicBody#reindex_requested_from will become a + # private method in 0.23).squish + + if changes.include?('url_name') + info_requests.each do |info_request| + info_request.info_request_events.each do |info_request_event| + info_request_event.xapian_mark_needs_index + end + end + end + end + + # Methods to remove + # -------------------------------------------------------------------------- + + # Set the first letter on a public body or translation + def self.set_first_letter(instance) + warn %q([DEPRECATION] PublicBody.set_first_letter will be removed + in 0.23).squish + + unless instance.name.nil? or instance.name.empty? + # we use a regex to ensure it works with utf-8/multi-byte + first_letter = Unicode.upcase instance.name.scan(/^./mu)[0] + if first_letter != instance.first_letter + instance.first_letter = first_letter + end + end + end + + def calculate_cached_fields(t) + warn %q([DEPRECATION] PublicBody#calculate_cached_fields will be removed + in 0.23).squish + + PublicBody.set_first_letter(t) + short_long_name = t.name + short_long_name = t.short_name if t.short_name and !t.short_name.empty? + t.url_name = MySociety::Format.simplify_url_part(short_long_name, 'body') + end + private # Read an attribute value (without using locale fallbacks if the attribute is translated) @@ -773,13 +772,6 @@ class PublicBody < ActiveRecord::Base end end - def empty_translation_in_params?(attributes) - attrs_with_values = attributes.select do |key, value| - value != '' and key.to_s != 'locale' - end - attrs_with_values.empty? - end - def request_email_if_requestable # Request_email can be blank, meaning we don't have details if self.is_requestable? diff --git a/app/models/public_body_category.rb b/app/models/public_body_category.rb index b88c683de..0a64172c1 100644 --- a/app/models/public_body_category.rb +++ b/app/models/public_body_category.rb @@ -1,3 +1,4 @@ +# -*- encoding : utf-8 -*- # == Schema Information # # Table name: public_body_categories @@ -17,13 +18,14 @@ class PublicBodyCategory < ActiveRecord::Base has_many :public_body_headings, :through => :public_body_category_links translates :title, :description - accepts_nested_attributes_for :translations, :reject_if => :empty_translation_in_params? validates_uniqueness_of :category_tag, :message => 'Tag is already taken' validates_presence_of :title, :message => "Title can't be blank" validates_presence_of :category_tag, :message => "Tag can't be blank" validates_presence_of :description, :message => "Description can't be blank" + include Translatable + def self.get locale = I18n.locale.to_s || default_locale.to_s || "" categories = CategoryCollection.new @@ -51,43 +53,6 @@ class PublicBodyCategory < ActiveRecord::Base ) | PublicBodyCategory.find_by_sql(sql) end - - # Convenience methods for creating/editing translations via forms - def find_translation_by_locale(locale) - translations.find_by_locale(locale) - end - - def translated_versions - translations - end - - def translated_versions=(translation_attrs) - warn "[DEPRECATION] PublicBodyCategory#translated_versions= will be replaced " \ - "by PublicBodyCategory#translations_attributes= as of release 0.22" - self.translations_attributes = translation_attrs - end - - def ordered_translations - translations. - select { |t| I18n.available_locales.include?(t.locale) }. - sort_by { |t| I18n.available_locales.index(t.locale) } - end - - def build_all_translations - I18n.available_locales.each do |locale| - translations.build(:locale => locale) unless translations.detect{ |t| t.locale == locale } - end - end - - private - - def empty_translation_in_params?(attributes) - attrs_with_values = attributes.select do |key, value| - value != '' and key.to_s != 'locale' - end - attrs_with_values.empty? - end - end PublicBodyCategory::Translation.class_eval do diff --git a/app/models/public_body_category/category_collection.rb b/app/models/public_body_category/category_collection.rb index 8286e2710..7d5732a82 100644 --- a/app/models/public_body_category/category_collection.rb +++ b/app/models/public_body_category/category_collection.rb @@ -1,3 +1,4 @@ +# -*- encoding : utf-8 -*- # replicate original file-based PublicBodyCategories functionality class PublicBodyCategory::CategoryCollection include Enumerable @@ -13,19 +14,19 @@ class PublicBodyCategory::CategoryCollection end def with_description - @categories.select() { |a| a.instance_of?(Array) } + @categories.select { |a| a.instance_of?(Array) } end def tags - tags = with_description.map() { |a| a[0] } + tags = with_description.map { |a| a[0] } end def by_tag - Hash[*with_description.map() { |a| a[0..1] }.flatten] + Hash[*with_description.map { |a| a[0..1] }.flatten] end def singular_by_tag - Hash[*with_description.map() { |a| [a[0],a[2]] }.flatten] + Hash[*with_description.map { |a| [a[0],a[2]] }.flatten] end def by_heading diff --git a/app/models/public_body_category_link.rb b/app/models/public_body_category_link.rb index 8c3eb8060..be73a9afa 100644 --- a/app/models/public_body_category_link.rb +++ b/app/models/public_body_category_link.rb @@ -1,3 +1,4 @@ +# -*- encoding : utf-8 -*- # == Schema Information # # Table name: public_body_category_links diff --git a/app/models/public_body_change_request.rb b/app/models/public_body_change_request.rb index 0e59cbecc..88a24dbd9 100644 --- a/app/models/public_body_change_request.rb +++ b/app/models/public_body_change_request.rb @@ -1,3 +1,4 @@ +# -*- encoding : utf-8 -*- # == Schema Information # # Table name: public_body_change_requests diff --git a/app/models/public_body_heading.rb b/app/models/public_body_heading.rb index 8c160ba8b..d49b388bb 100644 --- a/app/models/public_body_heading.rb +++ b/app/models/public_body_heading.rb @@ -1,3 +1,4 @@ +# -*- encoding : utf-8 -*- # == Schema Information # # Table name: public_body_headings @@ -15,7 +16,6 @@ class PublicBodyHeading < ActiveRecord::Base default_scope order('display_order ASC') translates :name - accepts_nested_attributes_for :translations, :reject_if => :empty_translation_in_params? validates_uniqueness_of :name, :message => 'Name is already taken' validates_presence_of :name, :message => 'Name can\'t be blank' @@ -28,32 +28,7 @@ class PublicBodyHeading < ActiveRecord::Base end end - # Convenience methods for creating/editing translations via forms - def find_translation_by_locale(locale) - translations.find_by_locale(locale) - end - - def translated_versions - translations - end - - def translated_versions=(translation_attrs) - warn "[DEPRECATION] PublicBodyHeading#translated_versions= will be replaced " \ - "by PublicBodyHeading#translations_attributes= as of release 0.22" - self.translations_attributes = translation_attrs - end - - def ordered_translations - translations. - select { |t| I18n.available_locales.include?(t.locale) }. - sort_by { |t| I18n.available_locales.index(t.locale) } - end - - def build_all_translations - I18n.available_locales.each do |locale| - translations.build(:locale => locale) unless translations.detect{ |t| t.locale == locale } - end - end + include Translatable def add_category(category) unless public_body_categories.include?(category) @@ -68,14 +43,4 @@ class PublicBodyHeading < ActiveRecord::Base 0 end end - - private - - def empty_translation_in_params?(attributes) - attrs_with_values = attributes.select do |key, value| - value != '' and key.to_s != 'locale' - end - attrs_with_values.empty? - end - end diff --git a/app/models/purge_request.rb b/app/models/purge_request.rb index 81980188d..39dae6a74 100644 --- a/app/models/purge_request.rb +++ b/app/models/purge_request.rb @@ -1,3 +1,4 @@ +# -*- encoding : utf-8 -*- # == Schema Information # # Table name: purge_requests diff --git a/app/models/raw_email.rb b/app/models/raw_email.rb index 907d3c7a0..58ae29a3b 100644 --- a/app/models/raw_email.rb +++ b/app/models/raw_email.rb @@ -1,3 +1,4 @@ +# -*- encoding : utf-8 -*- # == Schema Information # # Table name: raw_emails diff --git a/app/models/request_classification.rb b/app/models/request_classification.rb index 478a543d3..ab0cd1f21 100644 --- a/app/models/request_classification.rb +++ b/app/models/request_classification.rb @@ -1,3 +1,4 @@ +# -*- encoding : utf-8 -*- # == Schema Information # # Table name: request_classifications @@ -15,7 +16,7 @@ class RequestClassification < ActiveRecord::Base # return classification instances representing the top n # users, with a 'cnt' attribute representing the number # of classifications the user has made. - def RequestClassification.league_table(size, conditions=[]) + def self.league_table(size, conditions=[]) find(:all, :select => 'user_id, count(*) as cnt', :conditions => conditions, :group => 'user_id', diff --git a/app/models/spam_address.rb b/app/models/spam_address.rb index 2c84beaa0..893826a96 100644 --- a/app/models/spam_address.rb +++ b/app/models/spam_address.rb @@ -1,3 +1,4 @@ +# -*- encoding : utf-8 -*- # == Schema Information # # Table name: spam_addresses diff --git a/app/models/track_thing.rb b/app/models/track_thing.rb index cd90c4a9e..aad7cc51b 100644 --- a/app/models/track_thing.rb +++ b/app/models/track_thing.rb @@ -1,3 +1,4 @@ +# -*- encoding : utf-8 -*- # == Schema Information # # Table name: track_things diff --git a/app/models/track_things_sent_email.rb b/app/models/track_things_sent_email.rb index 072d3bdea..d4f3f3f04 100644 --- a/app/models/track_things_sent_email.rb +++ b/app/models/track_things_sent_email.rb @@ -1,3 +1,4 @@ +# -*- encoding : utf-8 -*- # == Schema Information # # Table name: track_things_sent_emails diff --git a/app/models/user.rb b/app/models/user.rb index 8fd7851e0..8c9e3c453 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -39,6 +39,7 @@ class User < ActiveRecord::Base has_one :profile_photo has_many :censor_rules, :order => 'created_at desc' has_many :info_request_batches, :order => 'created_at desc' + has_many :request_classifications validates_presence_of :email, :message => _("Please enter your email address") validates_presence_of :name, :message => _("Please enter your name") @@ -197,7 +198,9 @@ class User < ActiveRecord::Base end def visible_comments - comments.find(:all, :conditions => 'visible') + warn %q([DEPRECATION] User#visible_comments will be replaced with + User#comments.visible as of 0.23).squish + comments.visible end # Don't display any leading/trailing spaces @@ -301,12 +304,6 @@ class User < ActiveRecord::Base !ban_text.empty? end - def public_banned? - warn %q([DEPRECATION] User#public_banned? will be replaced with - User#banned? as of 0.22).squish - banned? - end - # Various ways the user can be banned, and text to describe it if failed def can_file_requests? ban_text.empty? && !exceeded_limit? diff --git a/app/models/user_info_request_sent_alert.rb b/app/models/user_info_request_sent_alert.rb index cd163d14b..e6a6405ef 100644 --- a/app/models/user_info_request_sent_alert.rb +++ b/app/models/user_info_request_sent_alert.rb @@ -1,3 +1,4 @@ +# -*- encoding : utf-8 -*- # == Schema Information # # Table name: user_info_request_sent_alerts diff --git a/app/models/widget_vote.rb b/app/models/widget_vote.rb new file mode 100644 index 000000000..dda77007f --- /dev/null +++ b/app/models/widget_vote.rb @@ -0,0 +1,20 @@ +# -*- encoding : utf-8 -*- +# == Schema Information +# +# Table name: widget_votes +# +# id :integer not null, primary key +# cookie :string(255) +# info_request_id :integer not null +# created_at :datetime not null +# updated_at :datetime not null +# + +class WidgetVote < ActiveRecord::Base + belongs_to :info_request + validates :info_request, :presence => true + + attr_accessible :cookie + validates :cookie, :length => { :is => 20 } + validates_uniqueness_of :cookie, :scope => :info_request_id +end diff --git a/app/views/admin_general/index.html.erb b/app/views/admin_general/index.html.erb index ba0563bb6..8840bce74 100644 --- a/app/views/admin_general/index.html.erb +++ b/app/views/admin_general/index.html.erb @@ -2,17 +2,10 @@ <div class="row"> <div class="span12"> - <h1><%=@title%></h1> - - <ul> - <li><%=@public_body_count%> public authorities</li> - <li> - <%=@info_request_count%> requests, <%=@outgoing_message_count%> outgoing messages, - <%=@incoming_message_count%> incoming messages - </li> - <li><%=@user_count%> users, <%=@track_thing_count%> tracked things</li> - <li><%=@comment_count%> annotations</li> - </ul> + <h1><%= @title %></h1> + <p> + <%= link_to 'Summary stats have moved →', admin_stats_path %> + </p> </div> </div> @@ -28,8 +21,14 @@ <% if @holding_pen_messages.size > 0 %> <div class="accordion-group"> <div class="accordion-heading"> - <a class="accordion-toggle" href="#holding-pen" data-toggle="collapse" data-parent="things-to-do"><span class="label label-important"><%=@holding_pen_messages.size%></span><%= chevron_right %> Put misdelivered responses with the right request</a> + <a class="accordion-toggle" href="#holding-pen" data-toggle="collapse" data-parent="things-to-do"> + <span class="label label-important"> + <%= @holding_pen_messages.size %> + </span> + <%= chevron_right %> Put misdelivered responses with the right request + </a> </div> + <div id="holding-pen" class="accordion-body collapse"> <table class="table table-striped table-condensed"> <tbody> @@ -39,11 +38,13 @@ <% if message.get_body_for_quoting.strip.size == 0 %> <%= link_to "(no body)", admin_raw_email_path(message.raw_email_id) %> <% else %> - <%= link_to excerpt(message.get_body_for_quoting, "", :radius => 60), admin_raw_email_path(message.raw_email_id) %> + <%= link_to admin_raw_email_path(message.raw_email_id) do %> + <%= excerpt(message.get_body_for_quoting, "", :radius => 60) %> + <% end %> <% end %> </td> <td class="span2"> - <%=simple_date(message.sent_at)%> + <%= simple_date(message.sent_at) %> </td> </tr> <% end %> @@ -67,7 +68,7 @@ <%= request_both_links(@request) %> </td> <td class="span2"> - <%=simple_date(@request.info_request_events.last.created_at)%> + <%= simple_date(@request.last_event_time) %> </td> </tr> <% end %> @@ -92,7 +93,7 @@ <%= request_both_links(@request) %> </td> <td class="span2"> - <%=simple_date(@request.info_request_events.last.created_at)%> + <%= simple_date(@request.last_event_time) %> </td> </tr> <% end %> @@ -116,7 +117,7 @@ <%= request_both_links(@request) %> </td> <td class="span2"> - <%=simple_date(@request.info_request_events.last.created_at)%> + <%= simple_date(@request.last_event_time) %> </td> </tr> <% end %> @@ -178,18 +179,33 @@ <% if @new_body_requests.size > 0 %> <div class="accordion-group"> <div class="accordion-heading"> - <a class="accordion-toggle" href="#new-authorities" data-toggle="collapse" data-parent="things-to-do"><span class="label label-important"><%= @new_body_requests.size %></span><%= chevron_right %> Add new authorities</a> + <a class="accordion-toggle" href="#new-authorities" data-toggle="collapse" data-parent="things-to-do"> + <span class="label label-important"> + <%= @new_body_requests.size %> + </span> + <%= chevron_right %> Add new authorities + </a> </div> + <div id="new-authorities" class="accordion-body collapse"> - <% for @change_request in @new_body_requests %> - <%= render :partial => 'change_request_summary'%> - <%= form_tag admin_change_request_path(@change_request), :method => 'put', :class => "form form-horizontal" do %> - <%= submit_tag 'Close', :class => "btn btn-danger" %> - <%= link_to("Close and respond", edit_admin_change_request_path(@change_request), :class => 'btn') %> - <%= link_to("Add authority", new_admin_body_path(:change_request_id => @change_request.id), :class => 'btn btn-primary') %> - <% end %> + <% for @change_request in @new_body_requests %> + <%= render :partial => 'change_request_summary'%> - <% end %> + <%= form_tag admin_change_request_path(@change_request), + :method => 'put', + :class => "form form-horizontal" do %> + + <%= submit_tag 'Close', :class => "btn btn-danger" %> + + <%= link_to "Close and respond", + edit_admin_change_request_path(@change_request), + :class => 'btn' %> + + <%= link_to "Add authority", + new_admin_body_path(:change_request_id => @change_request.id), + :class => 'btn btn-primary' %> + <% end %> + <% end %> </div> </div> <% end %> @@ -197,17 +213,34 @@ <% if @body_update_requests.size > 0 %> <div class="accordion-group"> <div class="accordion-heading"> - <a class="accordion-toggle" href="#update-authorities" data-toggle="collapse" data-parent="things-to-do"><span class="label label-important"><%= @body_update_requests.size %></span><%= chevron_right %> Update authorities</a> + <a class="accordion-toggle" href="#update-authorities" data-toggle="collapse" data-parent="things-to-do"> + <span class="label label-important"> + <%= @body_update_requests.size %> + </span> + <%= chevron_right %> Update authorities + </a> </div> + <div id="update-authorities" class="accordion-body collapse"> <% for @change_request in @body_update_requests %> - <%= render :partial => 'change_request_summary' %> - <%= form_tag admin_change_request_path(@change_request), :class => "form form-horizontal", :method => 'put' do %> - <%= submit_tag 'Close', :class => "btn btn-danger" %> - <%= link_to("Close and respond", edit_admin_change_request_path(@change_request), :class => 'btn') %> - <%= link_to("Make update", edit_admin_body_path(@change_request.public_body, :change_request_id => @change_request.id), :class => 'btn btn-primary') %> - <% end %> + <%= render :partial => 'change_request_summary' %> + + <%= form_tag admin_change_request_path(@change_request), + :class => "form form-horizontal", + :method => 'put' do %> + + <%= submit_tag 'Close', :class => "btn btn-danger" %> + + <%= link_to "Close and respond", + edit_admin_change_request_path(@change_request), + :class => 'btn' %> + + <%= link_to "Make update", + edit_admin_body_path(@change_request.public_body, + :change_request_id => @change_request.id), + :class => 'btn btn-primary' %> <% end %> + <% end %> </div> </div> <% end %> diff --git a/app/views/admin_public_body/edit.html.erb b/app/views/admin_public_body/edit.html.erb index dcafbd270..fc9c25e8f 100644 --- a/app/views/admin_public_body/edit.html.erb +++ b/app/views/admin_public_body/edit.html.erb @@ -13,7 +13,7 @@ <div class="row"> <div class="span8"> <div class="well"> - <%= link_to 'Show', admin_bodies_path(@public_body), :class => "btn" %> + <%= link_to 'Show', admin_body_path(@public_body), :class => "btn" %> <%= link_to 'List all', admin_bodies_path, :class => "btn" %> </div> </div> diff --git a/app/views/comment/_comment_form.html.erb b/app/views/comment/_comment_form.html.erb index 6ca3f4c9f..0a6712af5 100644 --- a/app/views/comment/_comment_form.html.erb +++ b/app/views/comment/_comment_form.html.erb @@ -5,7 +5,7 @@ <% if !TrackThing.find_existing(@user, track_thing) && (!@user || @info_request.user != @user) %> <p> - <%= check_box_tag 'subscribe_to_request', "1", params[:subscribe_to_request] ? true : false %> <label for="subscribe_to_request"><%= _('Email me future updates to this request') %></label> + <%= check_box_tag 'subscribe_to_request', "1", params[:subscribe_to_request] %> <label for="subscribe_to_request"><%= _('Email me future updates to this request') %></label> </p> <% end %> diff --git a/app/views/comment/_single_comment.html.erb b/app/views/comment/_single_comment.html.erb index 07017dabf..badc39d9a 100644 --- a/app/views/comment/_single_comment.html.erb +++ b/app/views/comment/_single_comment.html.erb @@ -1,4 +1,4 @@ -<div class="comment_in_request" id="comment-<%=comment.id.to_s%>"> +<div class="comment_in_request box" id="comment-<%=comment.id.to_s%>"> <% if comment.user && comment.user.profile_photo && !@render_to_file %> <div class="user_photo_on_comment"> <img src="<%= get_profile_photo_url(:url_name => comment.user.url_name) %>" alt=""> diff --git a/app/views/general/_responsive_topnav.html.erb b/app/views/general/_responsive_topnav.html.erb index 0af6629c8..c99864cab 100644 --- a/app/views/general/_responsive_topnav.html.erb +++ b/app/views/general/_responsive_topnav.html.erb @@ -21,11 +21,16 @@ </li> <li id="navigation_search"> - <form id="navigation_search_form" method="get" action="<%= search_redirect_path %>"> - <label for="navigation_search_button"> - <img src="/assets/search.png" alt="Search:"> + <form id="navigation_search_form" method="get" action="<%= search_redirect_path %>" role="search"> + <label class="visually-hidden" for="navigation_search_button"> + <%= _("Search") %> </label> - <%= text_field_tag 'query', params[:query], { :id => "navigation_search_button", :title => "type your search term here" } %> + <%= text_field_tag 'query', params[:query], { :id => "navigation_search_button", :type => "search", :placeholder => _("Search"), :title => _("type your search term here") } %> + <button type="submit"> + <span class="visually-hidden"> + <%= _("Submit Search") %> + </span> + </button> </form> </li> </ul> diff --git a/app/views/help/unhappy.html.erb b/app/views/help/unhappy.html.erb index 79e3f8273..c0444fb54 100644 --- a/app/views/help/unhappy.html.erb +++ b/app/views/help/unhappy.html.erb @@ -101,9 +101,8 @@ contact any registered user from their page. There may be an Internet forum or group that they hang out in. If it is a local matter, use <a href="http://www.groupsnearyou.com">GroupsNearYou</a> to find such a forum.</li> -<li><strong>Start a pledge</strong> on <a href="http://www.pledgebank.com">PledgeBank</a> to get -others to act together with you. For example, you could arrange a meeting with -staff from the authority. Or you could form a small local campaigns group. +<li>You could form a small local campaign group and arrange a meeting +with staff from the authority.</li> </ul> diff --git a/app/views/layouts/default.html.erb b/app/views/layouts/default.html.erb index 56e6b3362..39f3241c6 100644 --- a/app/views/layouts/default.html.erb +++ b/app/views/layouts/default.html.erb @@ -23,7 +23,7 @@ <% if @profile_photo_javascript %> <%= javascript_include_tag "profile-photos" %> - <%= stylesheet_link_tag "jquery.Jcrop.css" %> + <%= stylesheet_link_tag "jquery.Jcrop.min.css" %> <% end %> <% if is_admin? %> <%= javascript_include_tag "bootstrap-dropdown" %> diff --git a/app/views/public_body/show.html.erb b/app/views/public_body/show.html.erb index 016c2460d..546db681e 100644 --- a/app/views/public_body/show.html.erb +++ b/app/views/public_body/show.html.erb @@ -11,43 +11,45 @@ <% end %> <div class="authority__header"> - <h1><%=h(@public_body.name)%></h1> + <h1><%= h(@public_body.name) %></h1> <p class="authority__header__subtitle"> - <%= type_of_authority(@public_body) %><% if not @public_body.short_name.empty? %>, - <%= _('also called {{public_body_short_name}}', :public_body_short_name => h(@public_body.short_name))%><% end %> - <% if !@user.nil? && @user.admin_page_links? %> - (<%= link_to _("admin"), admin_body_path(@public_body) %>) + <%= type_of_authority(@public_body) %><% unless @public_body.short_name.empty? %>, + <%= _('also called {{public_body_short_name}}', :public_body_short_name => h(@public_body.short_name)) %> + <% end %> + + <% if @user && @user.admin_page_links? %> + (<%= link_to _("admin"), admin_body_path(@public_body) %>) <% end %> </p> <% if @public_body.has_notes? || @public_body.eir_only? || @public_body.special_not_requestable_reason? %> - <div id="stepwise_make_request"> - <% if @public_body.has_notes? %> - <p class="authority__header__notes"> - <%= @public_body.notes_as_html.html_safe %> - </p> - <% end %> + <div id="stepwise_make_request"> + <% if @public_body.has_notes? %> + <p class="authority__header__notes"> + <%= @public_body.notes_as_html.html_safe %> + </p> + <% end %> - <% if @public_body.is_requestable? %> - <% if @public_body.eir_only? %> + <% if @public_body.is_requestable? %> + <% if @public_body.eir_only? %> + <p class="authority__header__notes"> + <%= _('You can only request information about the environment from this authority.')%> + </p> + <% end %> + <% elsif @public_body.special_not_requestable_reason? %> <p class="authority__header__notes"> - <%= _('You can only request information about the environment from this authority.')%> + <%= public_body_not_requestable_reasons(@public_body).first %> </p> <% end %> - <% elsif @public_body.special_not_requestable_reason? %> - <p class="authority__header__notes"> - <%= public_body_not_requestable_reasons(@public_body).first %> - </p> - <% end %> - </div> + </div> <% end %> - <% if @public_body.info_requests.size > 0 %> + <% if @number_of_visible_requests > 0 %> <div class="authority__header__stats"> <%= n_('{{count}} request', '{{count}} requests', - @public_body.info_requests.size, - :count => @public_body.info_requests.size) %> + @number_of_visible_requests, + :count => @number_of_visible_requests) %> </div> <% end %> @@ -55,25 +57,25 @@ <div class="action-bar__make-request"> <% if @public_body.is_requestable? || @public_body.not_requestable_reason == 'bad_contact' %> <%= link_to _("Make a request to this authority"), new_request_to_body_path(:url_name => @public_body.url_name), :class => "link_button_green" %> - <% end %> + <% end %> </div> + <div class="action-bar__follow"> - <% follower_count = TrackThing.count(:all, :conditions => ["public_body_id = ?", @public_body.id]) %> - <div class="action-bar__follow-button"> - <% if @existing_track %> - <%= (link_to _("Unsubscribe"), {:controller => 'track', :action => 'update', :track_id => @existing_track.id, :track_medium => "delete", :r => request.fullpath}, :class => "link_button_green") %> - <% else %> - <div class="feed_link"> - <%= link_to _("Follow"), do_track_path(@track_thing), :class => "link_button_green" %> - </div> - <% end %> - </div> + <div class="action-bar__follow-button"> + <% if @existing_track %> + <%= link_to _("Unsubscribe"), {:controller => 'track', :action => 'update', :track_id => @existing_track.id, :track_medium => "delete", :r => request.fullpath}, :class => "link_button_green" %> + <% else %> + <div class="feed_link"> + <%= link_to _("Follow"), do_track_path(@track_thing), :class => "link_button_green" %> + </div> + <% end %> + </div> <div class="action-bar__follower-count"> <%= n_("{{count}} follower", "{{count}} followers", - follower_count, - :count => content_tag(:span, follower_count, :id => "follow_count")) %> + @follower_count, + :count => content_tag(:span, @follower_count, :id => "follow_count")) %> </div> </div> </div> @@ -81,7 +83,7 @@ <div class="authority__body"> <div class="authority__body__foi-results"> - <% if @public_body.info_requests.size == 0 %> + <% if @number_of_visible_requests.zero? %> <% if @public_body.is_requestable? or @public_body.not_requestable_reason != 'defunct' %> <% if @public_body.eir_only? %> <h2><%= _('Environmental Information Regulations requests made using this site') %></h2> @@ -99,14 +101,13 @@ <% end %> <a name="results"></a> - <% if @public_body.info_requests.size > 4 %> + <% if @number_of_visible_requests > 4 %> <%= render :partial => 'request/request_filter_form' %> <% end %> <% end %> - <% if !@xapian_requests.nil? %> - - <% for result in @xapian_requests.results %> + <% if @xapian_requests %> + <% @xapian_requests.results.each do |result| %> <%= render :partial => 'request/request_listing_via_event', :locals => { :event => result[:model] } %> <% end %> @@ -132,11 +133,17 @@ </div> <div class="authority__body__sidebar"> - <% if @public_body.info_requests.size > 4 %> + <% if @number_of_visible_requests > 4 %> <%= render :partial => 'request/request_search_form' %> <% end %> + <%= render :partial => 'more_info', :locals => { :public_body => @public_body } %> - <%= render :partial => 'track/tracking_links', :locals => { :track_thing => @track_thing, :own_request => false, :location => 'sidebar' } %> + + <%= render :partial => 'track/tracking_links', + :locals => { :track_thing => @track_thing, + :existing_track => @existing_track, + :own_request => false, + :location => 'sidebar' } %> </div> </div> diff --git a/app/views/public_body_change_requests/new.html.erb b/app/views/public_body_change_requests/new.html.erb index b52d583be..9abe03732 100644 --- a/app/views/public_body_change_requests/new.html.erb +++ b/app/views/public_body_change_requests/new.html.erb @@ -12,7 +12,7 @@ <p> <label class="form_label" for="user_email"> - <%= ("Your email:") %> + <%= _("Your email:") %> </label> <%= f.text_field :user_email %> </p> diff --git a/app/views/request/_act.html.erb b/app/views/request/_act.html.erb index 878cdf4ff..c7bbd287f 100644 --- a/app/views/request/_act.html.erb +++ b/app/views/request/_act.html.erb @@ -20,3 +20,8 @@ <% end %> <%= link_to _("Start your own blog"), "http://wordpress.com/"%> </div> +<% if AlaveteliConfiguration::enable_widgets %> + <div class="act_link"> + <%= link_to _("Create a widget for this request"), new_request_widget_path(@info_request) %> + </div> +<% end %> diff --git a/app/views/request/_followup.html.erb b/app/views/request/_followup.html.erb index 2643b767f..24cede824 100644 --- a/app/views/request/_followup.html.erb +++ b/app/views/request/_followup.html.erb @@ -20,7 +20,7 @@ </h2> <% end %> <% if @info_request.who_can_followup_to(incoming_message).count > 0 %> -<div id="other_recipients"> +<div id="other_recipients" class="box"> <%= _("Don't want to address your message to {{person_or_body}}? You can also write to:", :person_or_body => name_for_followup) %> <ul> <% @info_request.who_can_followup_to(incoming_message).each do |name, email, id| %> diff --git a/app/views/request/_incoming_correspondence.html.erb b/app/views/request/_incoming_correspondence.html.erb index 70bd25c7f..9d205204e 100644 --- a/app/views/request/_incoming_correspondence.html.erb +++ b/app/views/request/_incoming_correspondence.html.erb @@ -1,4 +1,4 @@ -<div class="incoming correspondence <%= incoming_message.prominence %>" id="incoming-<%=incoming_message.id.to_s%>"> +<div class="incoming correspondence box <%= incoming_message.prominence %>" id="incoming-<%=incoming_message.id.to_s%>"> <%- if not incoming_message.user_can_view?(@user) %> <%= render :partial => 'request/hidden_correspondence', :locals => { :message => incoming_message }%> <%- else %> diff --git a/app/views/request/_outgoing_correspondence.html.erb b/app/views/request/_outgoing_correspondence.html.erb index dced5c94c..3b85cae7f 100644 --- a/app/views/request/_outgoing_correspondence.html.erb +++ b/app/views/request/_outgoing_correspondence.html.erb @@ -1,4 +1,4 @@ -<div class="outgoing correspondence" id="outgoing-<%=outgoing_message.id.to_s%>"> +<div class="outgoing correspondence box" id="outgoing-<%=outgoing_message.id.to_s%>"> <%- if not outgoing_message.user_can_view?(@user) %> <%= render :partial => 'request/hidden_correspondence', :locals => { :message => outgoing_message }%> <%- else %> diff --git a/app/views/request/_request_listing_via_event.html.erb b/app/views/request/_request_listing_via_event.html.erb index 20bc5b2c8..7ad568829 100644 --- a/app/views/request/_request_listing_via_event.html.erb +++ b/app/views/request/_request_listing_via_event.html.erb @@ -6,8 +6,8 @@ end %> <div class="request_left"> <span class="head"> <% if event.is_incoming_message? %> - <%= link_to highlight_words(event.info_request.title, @highlight_words), incoming_message_path(event.incoming_message_selective_columns("incoming_messages.id")) %> - <% elsif event.is_outgoing_message? and event.event_type == 'followup_sent' %> + <%= link_to highlight_words(event.info_request.title, @highlight_words), incoming_message_path(event.incoming_message) %> + <% elsif event.is_outgoing_message? && event.event_type == 'followup_sent' %> <%= link_to highlight_words(event.info_request.title, @highlight_words), outgoing_message_path(event.outgoing_message) %> <% elsif event.is_comment? %> <%= link_to highlight_words(event.info_request.title, @highlight_words), comment_path(event.comment) %> diff --git a/app/views/request/_request_search_form.html.erb b/app/views/request/_request_search_form.html.erb index 3f2f66950..795070337 100644 --- a/app/views/request/_request_search_form.html.erb +++ b/app/views/request/_request_search_form.html.erb @@ -2,34 +2,22 @@ <div id="list-filter"> <%= form_tag(request.path, :method => "get", :id=>"filter_requests_form") do %> - <div class="list-filter-item"> - <%= label_tag(:query, _("Keywords"), :class=>"form_label title") %> - <%= text_field_tag(:query, params[:query]) %> - </div> -<% if false # don't think we want this, but leaving as an example %> - <div class="list-filter-item"> - <%= _("Search for words in:") %> <br/> - <% [["sent", _("messages from users")], - ["response", _("messages from authorities")], - ["comment", _("comments")]].each_with_index do |item, index| - variety, title = item %> - - <%= check_box_tag "request_variety[]", variety, params[:request_variety].nil? ? true : params[:request_variety].include?(variety), :id => "request_variety_#{index}" %> - <%= label_tag("request_variety_#{index}", title) %> <br/> - <% end %> - </div> -<% end %> - <div class="list-filter-item"> - <%= label_tag(:query, _("Made between"), :class=>"form_label title") %> - <%= text_field_tag(:request_date_after, params[:request_date_after], {:class => "use-datepicker", :size => 10}) %> - <%= label_tag(:query, _("and"), :class=>"form_label") %> - <%= text_field_tag(:request_date_before, params[:request_date_before], {:class => "use-datepicker", :size => 10}) %> - </div> + <div class="list-filter-item"> + <%= label_tag(:query, _("Keywords"), :class=>"form_label title") %> + <%= text_field_tag(:query, params[:query]) %> + </div> + + <div class="list-filter-item"> + <%= label_tag(:query, _("Made between"), :class=>"form_label title") %> + <%= text_field_tag(:request_date_after, params[:request_date_after], {:class => "use-datepicker", :size => 10}) %> + <%= label_tag(:query, _("and"), :class=>"form_label") %> + <%= text_field_tag(:request_date_before, params[:request_date_before], {:class => "use-datepicker", :size => 10}) %> + </div> - <%= after_form_fields if defined?(after_form_fields) -%> + <%= after_form_fields if defined?(after_form_fields) -%> - <div class="list-filter-item"> - <%= submit_tag(_("Search")) %> - </div> -<% end %> + <div class="list-filter-item"> + <%= submit_tag(_("Search")) %> + </div> + <% end %> </div> diff --git a/app/views/request/_resent_outgoing_correspondence.html.erb b/app/views/request/_resent_outgoing_correspondence.html.erb index 17b6b635b..287a5cac5 100644 --- a/app/views/request/_resent_outgoing_correspondence.html.erb +++ b/app/views/request/_resent_outgoing_correspondence.html.erb @@ -1,4 +1,4 @@ -<div class="outgoing correspondence" id="outgoing-<%=outgoing_message.id.to_s%>"> +<div class="outgoing correspondence box" id="outgoing-<%=outgoing_message.id.to_s%>"> <h2> <%= simple_date(info_request_event.created_at) %> </h2> diff --git a/app/views/request/new.html.erb b/app/views/request/new.html.erb index 486a89d45..23f7ad76a 100644 --- a/app/views/request/new.html.erb +++ b/app/views/request/new.html.erb @@ -144,7 +144,7 @@ <% if @info_request.public_body.info_requests.size > 0 %> <%= _("Browse <a href='{{url}}'>other requests</a> to '{{public_body_name}}' for examples of how to word your request.", :public_body_name=>h(@info_request.public_body.name), :url=>public_body_path(@info_request.public_body)) %> <% else %> - <%= _("Browse <a href='{{url}}'>other requests</a> for examples of how to word your request.", :url=>request_list_url) %> + <%= _("Browse <a href='{{url}}'>other requests</a> for examples of how to word your request.", :url=>request_list_successful_url) %> <% end %> </p> <% end %> @@ -156,7 +156,7 @@ this website <a href="{{url}}">forever</a>', :url => (help_privacy_path+"#public_request").html_safe)) %>. </p> <p> - <%= raw(_('<a href="{{url}}">Thinking of using a pseudonym?</a>.', :url => (help_privacy_path+"#real_name").html_safe)) %> + <%= raw(_('<a href="{{url}}">Thinking of using a pseudonym?</a>', :url => (help_privacy_path+"#real_name").html_safe)) %> </p> <% else %> <p> diff --git a/app/views/request/new_bad_contact.html.erb b/app/views/request/new_bad_contact.html.erb index 56f3f4168..f9881b62b 100644 --- a/app/views/request/new_bad_contact.html.erb +++ b/app/views/request/new_bad_contact.html.erb @@ -5,6 +5,6 @@ <p><%= _('Unfortunately, we do not have a working {{info_request_law_used_full}} address for', :info_request_law_used_full => @info_request.law_used_full) %> <%=h @info_request.public_body.name %>. <%= _('You may be able to find one on their website, or by phoning them up and asking. If you manage -to find one, then please <a href="{{help_url}}">send it to us</a>.', :help_url => help_contact_path) %> +to find one, then please <a href="{{help_url}}">send it to us</a>.', :help_url => new_change_request_path(:body => @info_request.public_body.url_name)) %> </p> diff --git a/app/views/request/select_authorities.html.erb b/app/views/request/select_authorities.html.erb index cfbc21a28..861fc6068 100644 --- a/app/views/request/select_authorities.html.erb +++ b/app/views/request/select_authorities.html.erb @@ -74,4 +74,4 @@ </div> </div> </div> -<%= javascript_include_tag 'jquery_ujs.js', 'select-authorities.js' %> +<%= javascript_include_tag 'select-authorities.js' %> diff --git a/app/views/request/show.html.erb b/app/views/request/show.html.erb index 78e022aa9..5862413de 100644 --- a/app/views/request/show.html.erb +++ b/app/views/request/show.html.erb @@ -22,7 +22,7 @@ <% if ( @update_status || @info_request.awaiting_description ) && ! @info_request.is_external? %> - <div class="describe_state_form" id="describe_state_form_1"> + <div class="describe_state_form box" id="describe_state_form_1"> <%= render :partial => 'describe_state', :locals => { :id_suffix => "1" } %> </div> <% end %> @@ -146,7 +146,7 @@ <% end %> <% if @info_request.awaiting_description && ! @info_request.is_external? %> - <div class="describe_state_form" id="describe_state_form_2"> + <div class="describe_state_form box" id="describe_state_form_2"> <%= render :partial => 'describe_state', :locals => { :id_suffix => "2" } %> </div> <% end %> diff --git a/app/views/request_game/play.html.erb b/app/views/request_game/play.html.erb index 471a0e09e..44fe641f9 100644 --- a/app/views/request_game/play.html.erb +++ b/app/views/request_game/play.html.erb @@ -2,7 +2,12 @@ <div id="game_sidebar"> <p style="text-align: center"> - <img width=250 height=125 src="http://chart.apis.google.com/chart?chs=250x125&cht=gom&chd=t:<%=@percentage%>" alt="<%=@percentage%>% of requests have been categorised"> + <%= + image_tag "https://chart.googleapis.com/chart?chs=250x125&cht=gom&chd=t:#{@percentage}", + :size => "250x125", + :alt => "A chart showing #{@percentage}% of requests have been categorised", + :title => "#{@percentage}% of requests have been categorised" + %> <br><%=pluralize(@missing, 'request')%> left to categorise / <%=@total %> total </p> diff --git a/app/views/track/_tracking_links.html.erb b/app/views/track/_tracking_links.html.erb index c027e9732..d94d3be13 100644 --- a/app/views/track/_tracking_links.html.erb +++ b/app/views/track/_tracking_links.html.erb @@ -1,25 +1,23 @@ <% - if @user - existing_track = TrackThing.find_existing(@user, track_thing) - end + existing_track = local_assigns.fetch(:existing_track) do + TrackThing.find_existing(@user, track_thing) if @user + end %> <% if own_request %> - <p><%= _('This is your own request, so you will be automatically emailed when new responses arrive.')%></p> + <p><%= _('This is your own request, so you will be automatically emailed when new responses arrive.')%></p> <% elsif existing_track %> - <p><%= track_thing.params[:verb_on_page_already] %></p> - <div class="feed_link feed_link_<%=location%>"> - <%= link_to _("Unsubscribe"), {:controller => 'track', :action => 'update', :track_id => existing_track.id, :track_medium => "delete", :r => request.fullpath}, :class => "link_button_green" %> - </div> + <p><%= track_thing.params[:verb_on_page_already] %></p> + + <div class="feed_link feed_link_<%= location %>"> + <%= link_to _("Unsubscribe"), { :controller => 'track', :action => 'update', :track_id => existing_track.id, :track_medium => "delete", :r => request.fullpath }, :class => "link_button_green" %> + </div> <% elsif track_thing %> - <div class="feed_link feed_link_<%=location%>"> - <% if defined?(follower_count) && follower_count > 0 %> - <%= link_to _("I like this request"), do_track_path(track_thing), :class => "link_button_green" %> - <% else %> - <%= link_to _("Follow"), do_track_path(track_thing), :class => "link_button_green" %> - <% end %> - </div> + <div class="feed_link feed_link_<%= location %>"> + <% if defined?(follower_count) && follower_count > 0 %> + <%= link_to _("I like this request"), do_track_path(track_thing), :class => "link_button_green" %> + <% else %> + <%= link_to _("Follow"), do_track_path(track_thing), :class => "link_button_green" %> + <% end %> + </div> <% end %> - - - diff --git a/app/views/user/_user_listing_single.html.erb b/app/views/user/_user_listing_single.html.erb index 3cb0d283f..03ac7347b 100644 --- a/app/views/user/_user_listing_single.html.erb +++ b/app/views/user/_user_listing_single.html.erb @@ -17,7 +17,7 @@ end %> <span class="bottomline"> <%= pluralize(display_user.info_requests.size, "request") %> <%= _('made.')%> - <%= pluralize(display_user.visible_comments.size, "annotation") %> <%= _('made.')%> + <%= pluralize(display_user.comments.visible.size, "annotation") %> <%= _('made.')%> <%= _('Joined in')%> <%= display_user.created_at.year %>. </span> diff --git a/app/views/user/set_crop_profile_photo.html.erb b/app/views/user/set_crop_profile_photo.html.erb index 0a22d36dc..7aa8f61a4 100644 --- a/app/views/user/set_crop_profile_photo.html.erb +++ b/app/views/user/set_crop_profile_photo.html.erb @@ -18,7 +18,7 @@ </td> <td> <div style="width:96px;height:96px;overflow:hidden;"> - <img src="<%= get_draft_profile_photo_url(:id => @draft_profile_photo.id) %>" id="profile_photo_preview" /> + <img src="<%= get_draft_profile_photo_url(:id => @draft_profile_photo.id) %>" id="profile_photo_preview" class="jcrop-preview" /> </div> </td> diff --git a/app/views/user/show.html.erb b/app/views/user/show.html.erb index 78b513d6a..a67663389 100644 --- a/app/views/user/show.html.erb +++ b/app/views/user/show.html.erb @@ -173,7 +173,7 @@ <% end %> <% else %> <h2 id="annotations"> - <%= @is_you ? n_('Your {{count}} annotation', 'Your {{count}} annotations', @display_user.visible_comments.size, :count => @display_user.visible_comments.size) : n_("This person's {{count}} annotation", "This person's {{count}} annotations", @display_user.visible_comments.size, :count => @display_user.visible_comments.size) %> + <%= @is_you ? n_('Your {{count}} annotation', 'Your {{count}} annotations', @display_user.comments.visible.size, :count => @display_user.comments.visible.size) : n_("This person's {{count}} annotation", "This person's {{count}} annotations", @display_user.comments.visible.size, :count => @display_user.comments.visible.size) %> <!-- matches_estimated <%=@xapian_comments.matches_estimated%> --> <%= @page_desc %> </h2> @@ -182,7 +182,7 @@ <%= render :partial => 'request/request_listing_via_event', :locals => { :event => result[:model] } %> <% end %> - <%= will_paginate WillPaginate::Collection.new(@page, @per_page, @display_user.visible_comments.size) %> + <%= will_paginate WillPaginate::Collection.new(@page, @per_page, @display_user.comments.visible.size) %> <% end %> <% end %> diff --git a/app/views/widgets/new.html.erb b/app/views/widgets/new.html.erb new file mode 100644 index 000000000..c706155a5 --- /dev/null +++ b/app/views/widgets/new.html.erb @@ -0,0 +1,15 @@ +<h1>Add a widget</h1> + +<p> +To add a widget for <b><%= @info_request.title %></b>, copy and paste the +following code to your web page: +<textarea autofocus readonly rows='4' cols='60' id='widgetbox'> +<iframe src='<%= request_widget_url(@info_request) %>' width='320' height='215' frameborder='0' marginwidth='0' marginheight='0'></iframe> +</textarea> +</p> + +<p> +The widget will look like this: +<br> +<iframe src='<%= request_widget_url(@info_request) %>' width='320' height='215' frameborder='0' marginwidth='0' marginheight='0'></iframe> +</p> diff --git a/app/views/widgets/show.html.erb b/app/views/widgets/show.html.erb new file mode 100644 index 000000000..07c7b1908 --- /dev/null +++ b/app/views/widgets/show.html.erb @@ -0,0 +1,48 @@ +<head> + <%= stylesheet_link_tag "widget" %> +</head> +<body> + <div class="alaveteli-widget"> + <div class="alaveteli-widget__top"> + <div class="alaveteli-widget__left"> + <div class="alaveteli-widget__title"> + <%= link_to @info_request.title, request_path(@info_request), :target => "_top" %> + </div> + <div class="alaveteli-widget__status <%= @status %>"> + <p class="alaveteli-widget__status__status-label">Status</p> + <%= status_description(@info_request, @status) %> + </div> + </div> + <div class="alaveteli-widget__people-count"> + <%= n_('<div class="alaveteli-widget__count">{{count}}</div> person wants to know', '<div class="alaveteli-widget__count">{{count}}</div> people want to know', @count, :count => @count) %> + </div> + </div> + + + <div class="alaveteli-widget__bottom"> + <% if @info_request.user && @info_request.user == @user %> + <div class="alaveteli-widget__button alaveteli-widget__button--down"> + <%= _('This is your request') %> + </div> + <% elsif @existing_track %> + <a href="<%= url_for :controller => 'track', :action => 'update', :track_id => @existing_track.id, :track_medium => "delete", :r => request.fullpath %>"> + <div class="alaveteli-widget__button--down"> + <%= _('You are tracking this request') %> + </div> + </a> + <% else %> + <% if @user %> + <a href="<%= url_for do_track_path(@track_thing) %>" target="_blank"> + <div class="alaveteli-widget__button"> + <%= _('I also want to know!') %> + </div> + </a> + <% else %> + <%= form_tag request_widget_url(@info_request), :method => 'put', :target => '_blank' do %> + <%= submit_tag _('I also want to know!'), :class => 'alaveteli-widget__button' %> + <% end %> + <% end %> + <% end %> + </div> + </div> +</body> |