right-rails 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (74) hide show
  1. data/MIT-LICENSE +20 -0
  2. data/README.textile +50 -0
  3. data/Rakefile +23 -0
  4. data/generators/right_rails/right_rails_generator.rb +41 -0
  5. data/generators/right_rails/templates/iframed.html.erb +10 -0
  6. data/generators/right_scaffold/right_scaffold_generator.rb +53 -0
  7. data/generators/right_scaffold/templates/controller.rb +99 -0
  8. data/generators/right_scaffold/templates/helper.rb +2 -0
  9. data/generators/right_scaffold/templates/layout.html.erb +18 -0
  10. data/generators/right_scaffold/templates/style.css +54 -0
  11. data/generators/right_scaffold/templates/view__form.html.erb +16 -0
  12. data/generators/right_scaffold/templates/view__item.html.erb +13 -0
  13. data/generators/right_scaffold/templates/view_edit.html.erb +6 -0
  14. data/generators/right_scaffold/templates/view_index.html.erb +9 -0
  15. data/generators/right_scaffold/templates/view_new.html.erb +5 -0
  16. data/generators/right_scaffold/templates/view_show.html.erb +10 -0
  17. data/init.rb +12 -0
  18. data/javascripts/right-autocompleter-src.js +303 -0
  19. data/javascripts/right-autocompleter.js +9 -0
  20. data/javascripts/right-behavior-src.js +240 -0
  21. data/javascripts/right-behavior.js +8 -0
  22. data/javascripts/right-calendar-src.js +855 -0
  23. data/javascripts/right-calendar.js +9 -0
  24. data/javascripts/right-dnd-src.js +555 -0
  25. data/javascripts/right-dnd.js +9 -0
  26. data/javascripts/right-effects-src.js +425 -0
  27. data/javascripts/right-effects.js +6 -0
  28. data/javascripts/right-events-src.js +369 -0
  29. data/javascripts/right-events.js +6 -0
  30. data/javascripts/right-json-src.js +176 -0
  31. data/javascripts/right-json.js +6 -0
  32. data/javascripts/right-lightbox-src.js +597 -0
  33. data/javascripts/right-lightbox.js +9 -0
  34. data/javascripts/right-rails-src.js +269 -0
  35. data/javascripts/right-rails.js +9 -0
  36. data/javascripts/right-rater-src.js +248 -0
  37. data/javascripts/right-rater.js +9 -0
  38. data/javascripts/right-selectable-src.js +507 -0
  39. data/javascripts/right-selectable.js +7 -0
  40. data/javascripts/right-slider-src.js +291 -0
  41. data/javascripts/right-slider.js +7 -0
  42. data/javascripts/right-sortable-src.js +221 -0
  43. data/javascripts/right-sortable.js +9 -0
  44. data/javascripts/right-src.js +4939 -0
  45. data/javascripts/right-tabs-src.js +776 -0
  46. data/javascripts/right-tabs.js +6 -0
  47. data/javascripts/right-tooltips-src.js +130 -0
  48. data/javascripts/right-tooltips.js +9 -0
  49. data/javascripts/right-ui-i18n-de.js +29 -0
  50. data/javascripts/right-ui-i18n-en-us.js +11 -0
  51. data/javascripts/right-ui-i18n-es.js +29 -0
  52. data/javascripts/right-ui-i18n-fr.js +29 -0
  53. data/javascripts/right-ui-i18n-jp.js +33 -0
  54. data/javascripts/right-ui-i18n-ru.js +29 -0
  55. data/javascripts/right-ui-i18n-uk.js +29 -0
  56. data/javascripts/right.js +10 -0
  57. data/lib/right-rails.rb +11 -0
  58. data/lib/right_rails/controller_extensions.rb +85 -0
  59. data/lib/right_rails/helpers/basic.rb +111 -0
  60. data/lib/right_rails/helpers/forms.rb +239 -0
  61. data/lib/right_rails/helpers/misc.rb +164 -0
  62. data/lib/right_rails/helpers/rails.rb +166 -0
  63. data/lib/right_rails/helpers.rb +5 -0
  64. data/lib/right_rails/java_script_generator.rb +313 -0
  65. data/lib/right_rails.rb +6 -0
  66. data/spec/lib/right_rails/controller_extensions_spec.rb +60 -0
  67. data/spec/lib/right_rails/helpers/basic_spec.rb +74 -0
  68. data/spec/lib/right_rails/helpers/forms_spec.rb +51 -0
  69. data/spec/lib/right_rails/helpers/misc_spec.rb +120 -0
  70. data/spec/lib/right_rails/helpers/rails_spec.rb +149 -0
  71. data/spec/lib/right_rails/java_script_generator_spec.rb +317 -0
  72. data/spec/spec.opts +5 -0
  73. data/spec/spec_helper.rb +15 -0
  74. metadata +128 -0
@@ -0,0 +1,9 @@
1
+ /**
2
+ * The calendar widget implemented with RightJS
3
+ *
4
+ * Home page: http://rightjs.org/ui/calendar
5
+ *
6
+ * @copyright (C) 2009 Nikolay V. Nemshilov aka St.
7
+ */
8
+ if (!RightJS) { throw "Gimme RightJS. Please." };
9
+ eval((function(s,d){for(var i=d.length-1;i>-1;i--)if(d[i])s=s.replace(new RegExp(i,'g'),d[i]);return s})("19 36=71 Class(Observer,{extend:{EVENTS:$w('show 102 44 100'),163:{67:'ISO',104:73,166:false,min47:73,max47:73,151:1,178:'fade',129:200,52:1,41:1,checkTags:'*',rel186:'14',43:73,135:false},Formats:{ISO:'%Y-%m-%d',POSIX:'%Y/%m/%d',EUR:'%d-%m-%Y',US:'%m/%d/%Y'},57:{Done:'Done',Now:'Now',Next:'Next 169',184:'184ious 169',Next181:'Next 181',184181:'184 181',91:$w('Sun121 Mon121 Tues121 Wednes121 Thurs121 Fri121 Satur121'),91183:$w('Sun Mon Tue Wed Thu Fri Sat'),91Min:$w('Su Mo Tu We Th Fr Sa'),59182:$w('January February March April May June July August September October November December'),59182183:$w('Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec')},rescan:16(){19 k=36.163.rel186;19 a=71 177(k+'\\\\[(.+?)\\\\]');$$(36.163.checkTags+'[rel*='+k+']').127(16(e){19 d=e.get('data-'+k+'-21');19 c=71 36(eval('('+d+')')||{});19 r=e.get('rel').159(a);if(r){19 i=$(r[1]);if(i)c.153(i,e)}92 c.153(e)})}},initialize:16(o){11.$super(o);11.29=$E('30',{'69':'17-14'});11.build().143().set47(71 47())},set163:16(u){11.$super(u);19 a=11.constructor;19 o=11.21;with(11.21){o.57={};146(19 k in a.57)57[k]=isArray(a.57[k])?a.57[k].clone():a.57[k];$ext(57,(u||{}).57);o.91=57.91Min;if(151)91.push(91.112());if(!isArray(52))52=[52,1];if(min47)min47=11.119(min47);if(max47){max47=11.119(max47);max47.set47(max47.get47()+1)}67=(a.Formats[67]||67).trim();if(104===73)104=67.search(/%[HkIl]/)>-1;if(43===73)43=67.search(/%[Il]/)<0;if(41>60&&12 %(41/60).134())43=true}25 11},set47:16(d){11.42=11.15547=11.119(d);25 11.up42()},get47:16(){25 11.42},102:16(){11.29.102(11.21.178,{duration:11.21.129});36.95=73;25 11},show:16(p){11.29.show(11.21.178,{duration:11.21.129});36.95=11;25 11},31:16(e,p){11.29.89('17-14-83').31(e,p);25 11}});36.131({up42:16(d){19 d=71 47(d||11.42),o=11.21;19 a=11.29.44('30.17-14-59');19 b=a.length;146(19 i=-(b-b/2).134()+1;i<(b-b/2).floor()+1;i++){19 m=71 47(d);m.76(d.61()+i);11.up42169(a.112(),m)}11.up42Next184169185s(d,b);if(o.104){11.94.72=o.41<60?d.152():(d.152()/(o.41/60)).round()*(o.41/60);11.113.72=(d.173()/(o.41 % 60)).round()*o.41}25 11},up42169:16(g,d){d.set47(32);19 f=32-d.get47();d.76(d.61()-1);19 b=(11.42.getTime()/86400000).134();19 r=g.44('90 tr');19 a=r.112().44('td');g.44('90 td').127(16(t){t.139='';t.69186='17-14-121-blank'});19 o=11.21;146(19 i=1;i<=f;i++){d.set47(i);19 e=d.get187();if(11.21.151)e=e?e-1:6;a[e].139=''+i;a[e].69186=b==(d.getTime()/86400000).134()?'17-14-121-44ed':'';if((o.min47&&o.min47>d)||(o.max47&&o.max47<d))a[e].69186='17-14-121-70';a[e].42=71 47(d);if(e==6)a=r.112().44('td')}19 c=(o.135?o.57.59182183[d.61()]+',':o.57.59182[d.61()])+' '+d.79();g.first('30.17-14-59-162').up42(c)},up42Next184169185s:16(a,f){19 o=11.21;if(o.min47){19 b=71 47(a.79(),0,1,0,0,0);19 c=71 47(o.min47.79(),0,1,0,0,0);11.122=b>c;b.76(a.61()-(f-f/2).134());c.76(o.min47.61());11.118=b>=c}92 11.118=11.122=true;if(o.max47){19 e=71 47(a);19 m=71 47(o.max47);[e,m].127(16(d){d.set47(32);d.76(d.61()-1);d.set47(32-d.get47());d.setHours(0);d.175(0);d.setSeconds(0);d.setMilliseconds(0)});11.117=e<m;[e,m].127('76',0);11.125=e<m}92 11.117=11.125=true;11.105[11.117?'78':'89']('17-ui-26-70');11.108[11.118?'78':'89']('17-ui-26-70');if(11.68){11.68[11.125?'78':'89']('17-ui-26-70');11.98[11.122?'78':'89']('17-ui-26-70')}},build:16(){11.174();19 g=90=$E('51',{'69':'17-14-157'}).31(11.29);19 o=11.21;if(Browser.OLD)90=$E('90').31(g);146(19 y=0;y<o.52[1];y++){19 r=$E('tr').31(90);146(19 x=0;x<o.52[0];x++)$E('td').31(r).93(11.build169())}if(o.104)11.buildTime();11.154();25 11},174:16(){19 i=11.21.57;11.108=$E('30',{'69':'17-ui-26 17-14-155-26',84:'&lsaquo;',156:i.184}).31(11.29);11.105=$E('30',{'69':'17-ui-26 17-14-136-26',84:'&rsaquo;',156:i.Next}).31(11.29);if(11.21.135){11.98=$E('30',{'69':'17-ui-26 17-14-155-138-26',84:'&laquo;',156:i.184181}).31(11.108,'after');11.68=$E('30',{'69':'17-ui-26 17-14-136-138-26',84:'&raquo;',156:i.Next181}).31(11.105,'be146e')}},build169:16(){25 $E('30',{'69':'17-14-59'}).93('<30 69=\"17-14-59-162\"></30>'+'<51><thead><tr>'+11.21.91.map(16(n){25 '<th>'+n+'</th>'}).join('')+'</tr></thead><90>'+'123456'.split('').map(16(){25 '<tr><td><td><td><td><td><td><td></tr>'}).join('')+'</90></51>')},buildTime:16(){19 o=11.21;19 t=$E('30',{'69':'17-14-time',84:':'}).31(11.29);11.94=$E('44').31(t,'116');11.113=$E('44').31(t);19 m=o.41<60?o.41:60;19 h=o.41<60?1:(o.41/60).134();(60).times(16(a){19 c=(a<10?'0':'')+a;if(a<24&&a % h==0){if(o.43)11.94.93($E('145',{72:a,84:c}));92 if(a<12)11.94.93($E('145',{72:a,84:a==0?12:a}))}if(a % m==0)11.113.93($E('145',{72:a,84:c}))},11);if(!o.43){11.124=$E('44').31(t);(o.67.131s(/%P/)?['am','pm']:['AM','PM']).127(16(v){11.124.93($E('145',{72:v.96(),84:v}))},11)}},154:16(){if(!11.21.166)25;11.115=$E('30',{'69':'17-ui-26 17-14-now-26',84:11.21.57.Now});11.100185=$E('30',{'69':'17-ui-26 17-14-100-26',84:11.21.57.Done});$E('30',{'69':'17-ui-26s 17-14-26s'}).93([11.100185,11.115]).31(11.29)}});101.onKeydown(16(e){if(36.95){19 n;switch(e.keyCode){50 27:n='102';58;50 37:n='155187';58;50 39:n='136187';58;50 38:n='155Week';58;50 40:n='136Week';58;50 34:n='136169';58;50 33:n='141';58;50 13:36.95.44(36.95.42);n='100';58}if(n){36.95[n]();e.s116()}}});36.131({44:16(d){11.42=d;25 11.fire('44',d)},100:16(){if(!11.29.hasClass('17-14-83'))11.102();25 11.fire('100',11.42)},136187:16(){25 11.17647({'47':1})},155187:16(){25 11.17647({'47':-1})},136Week:16(){25 11.17647({'47':7})},155Week:16(){25 11.17647({'47':-7})},136169:16(){25 11.17647({169:1})},141:16(){25 11.17647({169:-1})},136181:16(){25 11.17647({Full181:1})},155181:16(){25 11.17647({Full181:-1})},17647:16(h){19 d=71 47(11.42);146(19 k in h)d['set'+k](d['get'+k]()+h[k]);if(!((11.21.min47&&11.21.min47>d)||(11.21.max47&&11.21.max47<d)))11.42=d;25 11.up42(11.42)},143:16(){11.108.63(11.141.65(11));11.105.63(11.136169.65(11));if(11.68){11.98.63(11.155181.65(11));11.68.63(11.136181.65(11))}11.29.44('30.17-14-59 51 90 td').127(16(c){c.63(16(){if(c.139!=''){19 p=11.29.first('.17-14-121-44ed');if(p)p.78('17-14-121-44ed');c.89('17-14-121-44ed');11.114(c.42)}}.65(11))},11);if(11.94){11.94.on('176',11.114.65(11));11.113.on('176',11.114.65(11));if(!11.21.43)11.124.on('176',11.114.65(11))}if(11.115){11.115.63(11.set47.65(11,71 47()));11.100185.63(11.100.65(11))}11.29.63(16(a){a.s116()});25 11},114:16(d){if(d 172 47){11.42.set181(d.79());11.42.76(d.61());11.42.set47(d.get47())}if(11.94){11.42.setHours(11.94.72.toInt()+(!11.21.43&&11.124.72=='pm'?12:0));11.42.175(11.113.72)}25 11.44(11.42)}});36.131({153:16(i,t){19 i=$(i),t=$(t);if(t)t.63(16(a){a.s116();11.128(i.focus())}.65(11));92 i.on({focus:11.128.65(11,i),click:16(a){a.s116();if(11.29.hidden())11.128(i)}.65(11),keyDown:16(a){if(a.keyCode==9&&11.29.visible())11.102()}.65(11)});101.63(11.102.65(11));25 11},128:16(e){19 e=$(e),d=e.dimensions();11.set47(11.119(e.72));11.29.setStyle({87:'120',81:'0',left:(d.left)+'px',116:(d.116+d.111)+'px'}).31(101.body);11.s116Observing('44').s116Observing('100');11.on(11.100185?'100':'44',16(){e.72=11.67()}.65(11));25 11.102Others().show()},toggleAt:16(i){if(11.29.parentNode&&11.29.visible())11.102();92 11.128(i);25 11},102Others:16(){$$('30.17-14').127(16(e){if(!e.hasClass('17-14-83')){if(e!=11.29)e.102()}});25 11}});36.131({119:16(g){19 d;if(g 172 47||47.119(g))d=71 47(g);92 if(isString(g)&&g){19 t=177.escape(11.21.67);19 h=t.159(/%[a-z]/ig).map('159',/[a-z]$/i).map('first').without('%');19 r=71 177('^'+t.161(/%p/i,'(pm|PM|am|AM)').161(/(%[a-z])/ig,'(.+?)')+'$');19 m=g.trim().159(r);if(m){m.112();19 y=73,f=73,d=73,b=73,e=73,s=73,c;while(m.length){19 v=m.112();19 k=h.112();if(k.96()=='b')f=11.21.57[k=='b'?'59182183':'59182'].indexOf(v);92 if(k.96()=='p')c=v.96();92{v=v.toInt();switch(k){50 'd':50 'e':d=v;58;50 'm':f=v-1;58;50 'y':50 'Y':y=v;58;50 'H':50 'k':50 'I':50 'l':b=v;58;50 'M':e=v;58;50 'S':s=v;58}}}if(c){b=b==12?0:b;b=(c=='pm'?b+12:b)}d=71 47(y,f,d,b,e,s)}}92 d=71 47();25 d},67:16(g){19 j=11.21.57;19 f=11.42.get187();19 q=11.42.61();19 c=11.42.get47();19 t=11.42.79();19 h=11.42.152();19 o=11.42.173();19 s=11.42.getSeconds();19 i=(h==0?12:h<13?h:h-12);19 v={a:j.91183[f],A:j.91[f],b:j.59182183[q],B:j.59182[q],d:(c<10?'0':'')+c,e:''+c,m:(q<9?'0':'')+(q+1),y:(''+t).substring(2,4),Y:''+t,H:(h<10?'0':'')+h,k:''+h,I:(h>0&&(h<10||(h>12&&h<22))?'0':'')+i,l:''+i,p:h<12?'AM':'PM',P:h<12?'am':'pm',M:(o<10?'0':'')+o,S:(s<10?'0':'')+s,'%':'%'};19 r=g||11.21.67;146(19 n in v)r=r.161('%'+n,v[n]);25 r}});101.onReady(36.rescan);101.write(\"<style type=\\\"137/css\\\">*.17-ui-26{132:83-block;*132:83;*zoom:1;111:1em;line-111:1em;53:.82 .160;137-109:149;28:1px 168 #164;28-75:.82;-180-28-75:.82;-126-28-75:.82;110:pointer;46:#555;35-46:#FFF}*.17-ui-26:hover{46:#222;28-46:#999;35-46:#164}*.17-ui-26-70,*.17-ui-26-70:hover{46:#888;35:#EEE;28-46:#164;110:130}*.17-ui-26s{81-116:.160}30.17-14{87:120;111:auto;28:1px 168 #BBB;87:relative;53:.160;28-75:.179;-180-28-75:.179;-126-28-75:.179;110:130;35-46:#EEE;-180-box-150:.82 .4em .8em #666;-126-box-150:.82 .4em .8em #666}30.17-14-83{87:relative;132:83-block;vertical-109:116;*132:83;*zoom:1;-180-box-150:80;-126-box-150:80}30.17-14-155-26,30.17-14-136-26,30.17-14-155-138-26,30.17-14-136-138-26{87:120;float:left;158:1em;53:.1160 .4em}30.17-14-136-26{17:.160}30.17-14-155-138-26{left:2.5160}30.17-14-136-138-26{17:2.5160}30.17-14-59-162{137-109:149;111:1.82;line-111:1.82}51.17-14-157{28-spacing:0px;28:80;35:80;158:auto}51.17-14-157 td{vertical-109:116;28:80;35:80;81:0;53:0;53-17:.4em}51.17-14-157 td:last-child{53:0}30.17-14-59 51{81:0;53:0;28:80;158:auto;81-116:.82;28-spacing:1px;28-collapse:separate;28:80;35:80}30.17-14-59 51 th{46:#777;137-109:149;28:80;35:80;53:0;81:0}30.17-14-59 51 td,30.17-14-59 51 td:last-child{137-109:17;53:.1em .179;35-46:#FFF;28:1px 168 #164;110:pointer;46:#555;28-75:.82;-180-28-75:.82;-126-28-75:.82}30.17-14-59 51 td:hover{35-46:#164;28-46:#AAA;46:#000}30.17-14-59 51 td.17-14-121-blank{35:transparent;110:130;28:80}30.17-14-59 51 td.17-14-121-44ed{35-46:#BBB;28-46:#AAA;46:#222;font-weight:bold;53:.1em .82}30.17-14-59 51 td.17-14-121-70{46:#888;35:#EEE;28-46:#164;110:130}30.17-14-time{28-116:1px 168 #ccc;81-116:.179;53-116:.160;137-109:149}30.17-14-time 44{81:0 .4em}30.17-14-26s 30.17-ui-26{158:3.82}30.17-14-100-26{87:120;17:.160}</style>\");",",,,,,,,,,,,this,,,calendar,,function,right,,var,,options,,,,return,button,,border,element,div,insertTo,,,,background,Calendar,,,,,timePeriod,date,twentyFourHour,select,,color,Date,changeDate,maxDate,case,table,numberOfMonths,padding,minDate,,,i18n,break,month,,getMonth,setDate,onClick,,bind,,format,nextYearButton,class,disabled,new,value,null,monthNamesShort,radius,setMonth,,removeClass,getFullYear,none,margin,2em,inline,html,updateNextPrevMonthButtons,,position,,addClass,tbody,dayNames,else,insert,hours,current,toLowerCase,getDate,prevYearButton,,done,document,hide,selected,showTime,nextButton,monthNames,doneButton,prevButton,align,cursor,height,shift,minutes,setTime,nowButton,top,hasNextMonth,hasPrevMonth,parse,absolute,day,hasPrevYear,,meridian,hasNextYear,webkit,each,showAt,fxDuration,default,include,display,buttons,ceil,listYears,next,text,year,innerHTML,className,prevMonth,nextMonth,connectEvents,stopObserving,option,for,update,dayNamesShort,center,shadow,firstDay,getHours,assignTo,buildButtons,prev,title,greed,width,match,5em,replace,caption,Options,CCC,updateMonth,showButtons,dayNamesMin,solid,Month,buildMonth,hideOthers,instanceof,getMinutes,buildSwaps,setMinutes,change,RegExp,fxName,3em,moz,Year,Names,Short,Prev,Button,Name,Day".split(",")));
@@ -0,0 +1,555 @@
1
+ /**
2
+ * Drag'n'Drop module for RightJS
3
+ *
4
+ * See http://rightjs.org/goods/drag-n-drop
5
+ *
6
+ * Copyright (C) Nikolay V. Nemshilov aka St.
7
+ */
8
+ if (!RightJS) throw "Gimme RightJS";
9
+
10
+ /**
11
+ * Draggable unit
12
+ *
13
+ * Copyright (C) Nikolay V. Nemshilov aka St.
14
+ */
15
+ var Draggable = new Class(Observer, {
16
+ extend: {
17
+ EVENTS: $w('before start drag stop drop'),
18
+
19
+ Options: {
20
+ handle: null, // a handle element that will start the drag
21
+
22
+ snap: 0, // a number in pixels or [x,y]
23
+ axis: null, // null or 'x' or 'y' or 'vertical' or 'horizontal'
24
+ range: null, // {x: [min, max], y:[min, max]} or reference to another element
25
+
26
+ dragClass: 'dragging', // the in-process class name
27
+
28
+ clone: false, // if should keep a clone in place
29
+ revert: false, // marker if the object should be moved back on finish
30
+ revertDuration: 'normal', // the moving back fx duration
31
+
32
+ scroll: true, // if it should automatically scroll
33
+ scrollSensitivity: 32, // the scrolling area size in pixels
34
+
35
+ zIndex: 10000000, // the element's z-index
36
+ moveOut: false, // marker if the draggable should be moved out of it's context (for overflown elements)
37
+
38
+ relName: 'draggable' // the audodiscovery feature key
39
+ },
40
+
41
+ // referenece to the currently active draggable
42
+ current: null,
43
+
44
+ // scans the document for auto-processed draggables with the rel="draggable" attribute
45
+ rescan: function() {
46
+ var key = this.Options.relName;
47
+ $$('*[rel^="'+key+'"]').each(function(element) {
48
+ if (!element._draggable) {
49
+ var data = element.get('data-'+key+'-options');
50
+ new this(element, eval('('+data+')') || {});
51
+ }
52
+ }, this);
53
+ }
54
+ },
55
+
56
+ /**
57
+ * Basic controller
58
+ *
59
+ * @param mixed element reference
60
+ * @param Object options
61
+ */
62
+ initialize: function(element, options) {
63
+ this.element = $(element);
64
+ this.$super(options);
65
+
66
+ this.element._draggable = this.init();
67
+ },
68
+
69
+ /**
70
+ * detaches the mouse observers out of the draggable element
71
+ *
72
+ * @return this
73
+ */
74
+ destroy: function() {
75
+ this.handle.stopObserving('mousedown', this._dragStart);
76
+ delete(this.element._draggable);
77
+
78
+ return this;
79
+ },
80
+
81
+ // additional options processing
82
+ setOptions: function(options) {
83
+ this.$super(options);
84
+
85
+ // checking the handle
86
+ this.handle = this.options.handle ? $(this.options.handle) : this.element;
87
+
88
+ // checking the spappings
89
+ if (isArray(this.options.snap)) {
90
+ this.snapX = this.options.snap[0];
91
+ this.snapY = this.options.snap[1];
92
+ } else {
93
+ this.snapX = this.snapY = this.options.snap;
94
+ }
95
+
96
+ return this;
97
+ },
98
+
99
+ /**
100
+ * Moves the element back to the original position
101
+ *
102
+ * @return this
103
+ */
104
+ revert: function() {
105
+ var position = this.clone.position();
106
+ var end_style = {
107
+ top: (position.y + this.ryDiff) + 'px',
108
+ left: (position.x + this.rxDiff) + 'px'
109
+ };
110
+
111
+ if (this.options.revertDuration && this.element.morph) {
112
+ this.element.morph(end_style, {
113
+ duration: this.options.revertDuration,
114
+ onFinish: this.swapBack.bind(this)
115
+ });
116
+ } else {
117
+ this.element.setStyle(end_style);
118
+ this.swapBack();
119
+ }
120
+
121
+ return this;
122
+ },
123
+
124
+ // protected
125
+
126
+ init: function() {
127
+ // caching the callback so that we could detach it later
128
+ this._dragStart = this.dragStart.bind(this);
129
+
130
+ this.handle.onMousedown(this._dragStart);
131
+
132
+ return this;
133
+ },
134
+
135
+ // handles the event start
136
+ dragStart: function(event) {
137
+ this.fire('before', this, event.stop());
138
+
139
+ // calculating the positions diff
140
+ var position = position = this.element.position();
141
+
142
+ this.xDiff = event.pageX - position.x;
143
+ this.yDiff = event.pageY - position.y;
144
+
145
+ // grabbing the relative position diffs
146
+ var relative_position = {
147
+ y: this.element.getStyle('top').toFloat(),
148
+ x: this.element.getStyle('left').toFloat()
149
+ };
150
+
151
+ this.rxDiff = isNaN(relative_position.x) ? 0 : (relative_position.x - position.x);
152
+ this.ryDiff = isNaN(relative_position.y) ? 0 : (relative_position.y - position.y);
153
+
154
+ // preserving the element sizes
155
+ var size = {
156
+ x: this.element.getStyle('width'),
157
+ y: this.element.getStyle('height')
158
+ };
159
+
160
+ if (size.x == 'auto') size.x = this.element.offsetWidth + 'px';
161
+ if (size.y == 'auto') size.y = this.element.offsetHeight + 'px';
162
+
163
+ // building a clone element if necessary
164
+ if (this.options.clone || this.options.revert) {
165
+ this.clone = $(this.element.cloneNode(true)).setStyle({
166
+ visibility: this.options.clone ? 'visible' : 'hidden'
167
+ }).insertTo(this.element, 'before');
168
+ }
169
+
170
+ // reinserting the element to the body so it was over all the other elements
171
+ this.element.setStyle({
172
+ position: 'absolute',
173
+ zIndex: Draggable.Options.zIndex++,
174
+ top: (position.y + this.ryDiff) + 'px',
175
+ left: (position.x + this.rxDiff) + 'px',
176
+ width: size.x,
177
+ height: size.y
178
+ }).addClass(this.options.dragClass);
179
+
180
+ if (this.options.moveOut) this.element.insertTo(document.body);
181
+
182
+
183
+ // caching the window scrolls
184
+ this.winScrolls = window.scrolls();
185
+ this.winSizes = window.sizes();
186
+
187
+ Draggable.current = this.calcConstraints().fire('start', this, event);
188
+ },
189
+
190
+ // catches the mouse move event
191
+ dragProcess: function(event) {
192
+ var page_x = event.pageX, page_y = event.pageY, x = page_x - this.xDiff, y = page_y - this.yDiff;
193
+
194
+ // checking the range
195
+ if (this.ranged) {
196
+ if (this.minX > x) x = this.minX;
197
+ if (this.maxX < x) x = this.maxX;
198
+ if (this.minY > y) y = this.minY;
199
+ if (this.maxY < y) y = this.maxY;
200
+ }
201
+
202
+ // checking the scrolls
203
+ if (this.options.scroll) {
204
+ var scrolls = {x: this.winScrolls.x, y: this.winScrolls.y},
205
+ sensitivity = this.options.scrollSensitivity;
206
+
207
+ if ((page_y - scrolls.y) < sensitivity) {
208
+ scrolls.y = page_y - sensitivity;
209
+ } else if ((scrolls.y + this.winSizes.y - page_y) < sensitivity){
210
+ scrolls.y = page_y - this.winSizes.y + sensitivity;
211
+ }
212
+
213
+ if ((page_x - scrolls.x) < sensitivity) {
214
+ scrolls.x = page_x - sensitivity;
215
+ } else if ((scrolls.x + this.winSizes.x - page_x) < sensitivity){
216
+ scrolls.x = page_x - this.winSizes.x + sensitivity;
217
+ }
218
+
219
+ if (scrolls.y < 0) scrolls.y = 0;
220
+ if (scrolls.x < 0) scrolls.x = 0;
221
+
222
+ if (scrolls.y < this.winScrolls.y || scrolls.y > this.winScrolls.y ||
223
+ scrolls.x < this.winScrolls.x || scrolls.x > this.winScrolls.x) {
224
+
225
+ window.scrollTo(this.winScrolls = scrolls);
226
+ }
227
+ }
228
+
229
+ // checking the snaps
230
+ if (this.snapX) x = x - x % this.snapX;
231
+ if (this.snapY) y = y - y % this.snapY;
232
+
233
+ // checking the constraints
234
+ if (!this.axisY) this.element.style.left = (x + this.rxDiff) + 'px';
235
+ if (!this.axisX) this.element.style.top = (y + this.ryDiff) + 'px';
236
+
237
+ this.fire('drag', this, event);
238
+ },
239
+
240
+ // handles the event stop
241
+ dragStop: function(event) {
242
+ this.element.removeClass(this.options.dragClass);
243
+
244
+ // notifying the droppables for the drop
245
+ Droppable.checkDrop(event, this);
246
+
247
+ if (this.options.revert) {
248
+ this.revert();
249
+ }
250
+
251
+ Draggable.current = null;
252
+
253
+ this.fire('stop', this, event);
254
+ },
255
+
256
+ // swaps the clone element to the actual element back
257
+ swapBack: function() {
258
+ if (this.clone) {
259
+ this.clone.insert(
260
+ this.element.setStyle({
261
+ width: this.clone.getStyle('width'),
262
+ height: this.clone.getStyle('height'),
263
+ position: this.clone.getStyle('position'),
264
+ zIndex: this.clone.getStyle('zIndex')
265
+ }), 'before'
266
+ ).remove();
267
+ }
268
+ },
269
+
270
+ // calculates the constraints
271
+ calcConstraints: function() {
272
+ var axis = this.options.axis;
273
+ this.axisX = ['x', 'horizontal'].include(axis);
274
+ this.axisY = ['y', 'vertical'].include(axis);
275
+
276
+ this.ranged = false;
277
+ var range = this.options.range;
278
+ if (range) {
279
+ this.ranged = true;
280
+
281
+ // if the range is defined by another element
282
+ var element = $(range);
283
+ if (isElement(element)) {
284
+ var dims = element.dimensions();
285
+
286
+ range = {
287
+ x: [dims.left, dims.left + dims.width],
288
+ y: [dims.top, dims.top + dims.height]
289
+ };
290
+ }
291
+
292
+ if (isHash(range)) {
293
+ var size = this.element.sizes();
294
+
295
+ if (range.x) {
296
+ this.minX = range.x[0];
297
+ this.maxX = range.x[1] - size.x;
298
+ }
299
+ if (range.y) {
300
+ this.minY = range.y[0];
301
+ this.maxY = range.y[1] - size.y;
302
+ }
303
+ }
304
+ }
305
+
306
+ return this;
307
+ }
308
+ });
309
+ /**
310
+ * Droppable unit
311
+ *
312
+ * Copyright (C) Nikolay V. Nemshilov aka St.
313
+ */
314
+ var Droppable = new Class(Observer, {
315
+ extend: {
316
+ EVENTS: $w('drop hover leave'),
317
+
318
+ Options: {
319
+ accept: '*',
320
+ containment: null, // the list of elements (or ids) that should to be accepted
321
+
322
+ overlap: null, // 'x', 'y', 'horizontal', 'vertical', 'both' makes it respond only if the draggable overlaps the droppable
323
+ overlapSize: 0.5, // the overlapping level 0 for nothing 1 for the whole thing
324
+
325
+ allowClass: 'droppable-allow',
326
+ denyClass: 'droppable-deny',
327
+
328
+ relName: 'droppable' // automatically discovered feature key
329
+ },
330
+
331
+ // See the Draggable rescan method, case we're kinda hijacking it in here
332
+ rescan: eval('({f:'+Draggable.rescan.toString().replace(/\._draggable/g, '._droppable')+'})').f,
333
+
334
+ /**
335
+ * Checks for hoverting draggable
336
+ *
337
+ * @param Event mouse event
338
+ * @param Draggable draggable
339
+ */
340
+ checkHover: function(event, draggable) {
341
+ for (var i=0, length = this.active.length; i < length; i++)
342
+ this.active[i].checkHover(event, draggable);
343
+ },
344
+
345
+ /**
346
+ * Checks for a drop
347
+ *
348
+ * @param Event mouse event
349
+ * @param Draggable draggable
350
+ */
351
+ checkDrop: function(event, draggable) {
352
+ for (var i=0, length = this.active.length; i < length; i++)
353
+ this.active[i].checkDrop(event, draggable);
354
+ },
355
+
356
+ active: []
357
+ },
358
+
359
+ /**
360
+ * Basic cosntructor
361
+ *
362
+ * @param mixed the draggable element reference
363
+ * @param Object options
364
+ */
365
+ initialize: function(element, options) {
366
+ this.element = $(element);
367
+ this.$super(options);
368
+
369
+ Droppable.active.push(this.element._droppable = this);
370
+ },
371
+
372
+ /**
373
+ * Detaches the attached events
374
+ *
375
+ * @return self
376
+ */
377
+ destroy: function() {
378
+ Droppable.active = Droppable.active.without(this);
379
+ delete(this.element._droppable);
380
+ return this;
381
+ },
382
+
383
+ /**
384
+ * checks the event for hovering
385
+ *
386
+ * @param Event mouse event
387
+ * @param Draggable the draggable object
388
+ */
389
+ checkHover: function(event, draggable) {
390
+ if (this.hoveredBy(event, draggable)) {
391
+ if (!this._hovered) {
392
+ this._hovered = true;
393
+ this.element.addClass(this.options[this.allows(draggable) ? 'allowClass' : 'denyClass']);
394
+ this.fire('hover', draggable, this, event);
395
+ }
396
+ } else if (this._hovered) {
397
+ this._hovered = false;
398
+ this.reset().fire('leave', draggable, this, event);
399
+ }
400
+ },
401
+
402
+ /**
403
+ * Checks if it should process the drop from draggable
404
+ *
405
+ * @param Event mouse event
406
+ * @param Draggable draggable
407
+ */
408
+ checkDrop: function(event, draggable) {
409
+ this.reset();
410
+ if (this.hoveredBy(event, draggable) && this.allows(draggable)) {
411
+ draggable.fire('drop', this, draggable, event);
412
+ this.fire('drop', draggable, this, event);
413
+ }
414
+ },
415
+
416
+ /**
417
+ * resets the element state
418
+ *
419
+ * @return self
420
+ */
421
+ reset: function() {
422
+ this.element.removeClass(this.options.allowClass).removeClass(this.options.denyClass);
423
+ return this;
424
+ },
425
+
426
+ // protected
427
+
428
+ // checks if the element is hovered by the event
429
+ hoveredBy: function(event, draggable) {
430
+ var dims = this.element.dimensions(),
431
+ t_top = dims.top,
432
+ t_left = dims.left,
433
+ t_right = dims.left + dims.width,
434
+ t_bottom = dims.top + dims.height,
435
+ event_x = event.pageX,
436
+ event_y = event.pageY;
437
+
438
+ // checking the overlapping
439
+ if (this.options.overlap) {
440
+ var drag_dims = draggable.element.dimensions(),
441
+ level = this.options.overlapSize,
442
+ top = drag_dims.top,
443
+ left = drag_dims.left,
444
+ right = drag_dims.left + drag_dims.width,
445
+ bottom = drag_dims.top + drag_dims.height;
446
+
447
+
448
+ switch (this.options.overlap) {
449
+ // horizontal overlapping only check
450
+ case 'x':
451
+ case 'horizontal':
452
+ return (
453
+ (top > t_top && top < t_bottom) ||
454
+ (bottom > t_top && bottom < t_bottom)
455
+ ) && (
456
+ (left > t_left && left < (t_right - dims.width * level)) ||
457
+ (right < t_right && right > (t_left + dims.width * level))
458
+ );
459
+
460
+ // vertical overlapping only check
461
+ case 'y':
462
+ case 'vertical':
463
+ return (
464
+ (left > t_left && left < t_right) ||
465
+ (right > t_left && right < t_right)
466
+ ) && (
467
+ (top > t_top && top < (t_bottom - dims.height * level)) ||
468
+ (bottom < t_bottom && bottom > (t_top + dims.height * level))
469
+ );
470
+
471
+ // both overlaps check
472
+ default:
473
+ return (
474
+ (left > t_left && left < (t_right - dims.width * level)) ||
475
+ (right < t_right && right > (t_left + dims.width * level))
476
+ ) && (
477
+ (top > t_top && top < (t_bottom - dims.height * level)) ||
478
+ (bottom < t_bottom && bottom > (t_top + dims.height * level))
479
+ );
480
+ }
481
+
482
+ } else {
483
+ // simple check agains the event position
484
+ return event_x > t_left && event_x < t_right && event_y > t_top && event_y < t_bottom;
485
+ }
486
+ },
487
+
488
+ // checks if the object accepts the draggable
489
+ allows: function(draggable) {
490
+ if (this.options.containment && !this._scanned) {
491
+ this.options.containment.walk($);
492
+ this._scanned = true;
493
+ }
494
+
495
+ // checking the invitations list
496
+ var welcomed = this.options.containment ? this.options.containment.includes(draggable.element) : true;
497
+
498
+ return welcomed && (this.options.accept == '*' ? true : draggable.element.match(this.options.accept));
499
+ }
500
+
501
+ });
502
+ /**
503
+ * The document events hooker
504
+ *
505
+ * Copyright (C) 2009 Nikolay V. Nemshilov aka St.
506
+ */
507
+ document.on({
508
+ // parocesses the automatically discovered elements
509
+ ready: function() {
510
+ Draggable.rescan();
511
+ Droppable.rescan();
512
+ },
513
+
514
+ // watch the draggables moving arond
515
+ mousemove: function(event) {
516
+ if (Draggable.current) {
517
+ Draggable.current.dragProcess(event);
518
+ Droppable.checkHover(event, Draggable.current);
519
+ }
520
+ },
521
+
522
+ // releases the current draggable on mouse up
523
+ mouseup: function(event) {
524
+ if (Draggable.current) {
525
+ Draggable.current.dragStop(event);
526
+ }
527
+ }
528
+ });
529
+ /**
530
+ * Element level hooks for drag'n'drops
531
+ *
532
+ * Copyright (C) Nikolay V. Nemshilov aka St.
533
+ */
534
+ Element.addMethods({
535
+
536
+ makeDraggable: function(options) {
537
+ new Draggable(this, options);
538
+ return this;
539
+ },
540
+
541
+ undoDraggable: function() {
542
+ if (this._draggable) this._draggable.destroy();
543
+ return this;
544
+ },
545
+
546
+ makeDroppable: function(options) {
547
+ new Droppable(this, options);
548
+ return this;
549
+ },
550
+
551
+ undoDroppable: function() {
552
+ if (this._droppable) this._droppable.destroy();
553
+ return this;
554
+ }
555
+ });
@@ -0,0 +1,9 @@
1
+ /**
2
+ * Drag'n'Drop module for RightJS
3
+ *
4
+ * See http://rightjs.org/goods/drag-n-drop
5
+ *
6
+ * Copyright (C) Nikolay V. Nemshilov aka St.
7
+ */
8
+ if (!RightJS) throw "Gimme RightJS";
9
+ eval((function(s,d){for(var i=d.length-1;i>-1;i--)if(d[i])s=s.replace(new RegExp(i,'g'),d[i]);return s})("13 9=73 111(83,{97:{96:$w('57 110 118 s31 76'),46:{29:38,59:0,114:38,108:38,53:'118ging',18:54,42:54,27:'normal',95:39,36:32,41:10000000,89:54,62:'118gable'},20:38,40:8(){13 k=4.46.62;$$('*[rel^=\"'+k+'\"]').each(8(e){if(!e.19){13 d=e.get('data-'+k+'-7');73 4(e,116('('+d+')')||{})}},4)}},67:8(e,o){4.6=$(e);4.69(o);4.6.19=4.119()},47:8(){4.29.s31Observing('mousedown',4.44);99(4.6.19);11 4},set46:8(o){4.69(o);4.29=4.7.29?$(4.7.29):4.6;if(isArray(4.7.59)){4.59X=4.7.59[0];4.59Y=4.7.59[1]}50 4.59X=4.59Y=4.7.59;11 4},42:8(){13 p=4.18.25();13 e={31:(p.y+4.56)+'px',24:(p.x+4.55)+'px'};if(4.7.27&&4.6.109)4.6.109(e,{duration:4.7.27,onFinish:4.58.115(4)});50{4.6.34(e);4.58()}11 4},119:8(){4.44=4.75.115(4);4.29.onMousedown(4.44);11 4},75:8(e){4.30('57',4,e.s31());13 p=p=4.6.25();4.103=e.77-p.x;4.113=e.78-p.y;13 r={y:4.6.16('31').88(),x:4.6.16('24').88()};4.55=104(r.x)?0:(r.x-p.x);4.56=104(r.y)?0:(r.y-p.y);13 s={x:4.6.16('17'),y:4.6.16('15')};if(s.x=='117')s.x=4.6.offsetWidth+'px';if(s.y=='117')s.y=4.6.offsetHeight+'px';if(4.7.18||4.7.42)4.18=$(4.6.18Node(39)).34({visibility:4.7.18?'visible':'hidden'}).84(4.6,'57');4.6.34({25:'absolute',41:9.46.41++,31:(p.y+4.56)+'px',24:(p.x+4.55)+'px',17:s.x,15:s.y}).86(4.7.53);if(4.7.89)4.6.84(79.body);4.12=72.95s();4.26=72.106();9.20=4.48().30('110',4,e)},63:8(e){13 p=e.77,a=e.78,x=p-4.103,y=a-4.113;if(4.68){if(4.92>x)x=4.92;if(4.94<x)x=4.94;if(4.91>y)y=4.91;if(4.93<y)y=4.93}if(4.7.95){13 s={x:4.12.x,y:4.12.y},b=4.7.36;if((a-s.y)<b)s.y=a-b;50 if((s.y+4.26.y-a)<b)s.y=a-4.26.y+b;if((p-s.x)<b)s.x=p-b;50 if((s.x+4.26.x-p)<b)s.x=p-4.26.x+b;if(s.y<0)s.y=0;if(s.x<0)s.x=0;if(s.y<4.12.y||s.y>4.12.y||s.x<4.12.x||s.x>4.12.x)72.95To(4.12=s)}if(4.59X)x=x-x % 4.59X;if(4.59Y)y=y-y % 4.59Y;if(!4.105)4.6.101.24=(x+4.55)+'px';if(!4.112)4.6.101.31=(y+4.56)+'px';4.30('118',4,e)},118S31:8(e){4.6.37(4.7.53);14.33(e,4);if(4.7.42)4.42();9.20=38;4.30('s31',4,e)},58:8(){if(4.18)4.18.insert(4.6.34({17:4.18.16('17'),15:4.18.16('15'),25:4.18.16('25'),41:4.18.16('41')}),'57').remove()},48:8(){13 a=4.7.114;4.112=['x','66'].87(a);4.105=['y','85'].87(a);4.68=54;13 r=4.7.108;if(r){4.68=39;13 e=$(r);if(is121(e)){13 d=e.45();r={x:[d.24,d.24+d.17],y:[d.31,d.31+d.15]}}if(isHash(r)){13 s=4.6.106();if(r.x){4.92=r.x[0];4.94=r.x[1]-s.x}if(r.y){4.91=r.y[0];4.93=r.y[1]-s.y}}}11 4}});13 14=73 111(83,{97:{96:$w('76 102 107'),46:{71:'*',21:38,61:38,60:0.5,43:'49-allow',51:'49-deny',62:'49'},40:116('({f:'+9.40.toString().replace(/\\.19/g,'.23')+'})').f,28:8(e,d){120(13 i=0,l=4.22.98;i<l;i++)4.22[i].28(e,d)},33:8(e,d){120(13 i=0,l=4.22.98;i<l;i++)4.22[i].33(e,d)},22:[]},67:8(e,o){4.6=$(e);4.69(o);14.22.push(4.6.23=4)},47:8(){14.22=14.22.without(4);99(4.6.23);11 4},28:8(e,d){if(4.52(e,d)){if(!4.35){4.35=39;4.6.86(4.7[4.70(d)?'43':'51']);4.30('102',d,4,e)}}50 if(4.35){4.35=54;4.80().30('107',d,4,e)}},33:8(e,d){4.80();if(4.52(e,d)&&4.70(d)){d.30('76',4,d,e);4.30('76',d,4,e)}},80:8(){4.6.37(4.7.43).37(4.7.51);11 4},52:8(e,c){13 d=4.6.45(),k=d.31,i=d.24,j=d.24+d.17,t=d.31+d.15,f=e.77,g=e.78;if(4.7.61){13 a=c.6.45(),h=4.7.60,m=a.31,l=a.24,r=a.24+a.17,b=a.31+a.15;switch(4.7.61){74 'x':74 '66':11((m>k&&m<t)||(b>k&&b<t))&&((l>i&&l<(j-d.17*h))||(r<j&&r>(i+d.17*h)));74 'y':74 '85':11((l>i&&l<j)||(r>i&&r<j))&&((m>k&&m<(t-d.15*h))||(b<t&&b>(k+d.15*h)));default:11((l>i&&l<(j-d.17*h))||(r<j&&r>(i+d.17*h)))&&((m>k&&m<(t-d.15*h))||(b<t&&b>(k+d.15*h)))}}50 11 f>i&&f<j&&g>k&&g<t},70:8(d){if(4.7.21&&!4.81){4.7.21.walk($);4.81=39}13 w=4.7.21?4.7.21.87s(d.6):39;11 w&&(4.7.71=='*'?39:d.6.match(4.7.71))}});79.on({ready:8(){9.40();14.40()},mousemove:8(e){if(9.20){9.20.63(e);14.28(e,9.20)}},mouseup:8(e){if(9.20)9.20.118S31(e)}});121.addMethods({make9:8(o){73 9(4,o);11 4},undo9:8(){if(4.19)4.19.47();11 4},make14:8(o){73 14(4,o);11 4},undo14:8(){if(4.23)4.23.47();11 4}});",",,,,this,,element,options,function,Draggable,,return,winScrolls,var,Droppable,height,getStyle,width,clone,_draggable,current,containment,active,_droppable,left,position,winSizes,revertDuration,checkHover,handle,fire,top,,checkDrop,setStyle,_hovered,scrollSensitivity,removeClass,null,true,rescan,zIndex,revert,allowClass,_dragStart,dimensions,Options,destroy,calcConstraints,droppable,else,denyClass,hoveredBy,dragClass,false,rxDiff,ryDiff,before,swapBack,snap,overlapSize,overlap,relName,dragProcess,snapY,snapX,horizontal,initialize,ranged,$super,allows,accept,window,new,case,dragStart,drop,pageX,pageY,document,reset,_scanned,dragStop,Observer,insertTo,vertical,addClass,include,toFloat,moveOut,stop,minY,minX,maxY,maxX,scroll,EVENTS,extend,length,delete,,style,hover,xDiff,isNaN,axisY,sizes,leave,range,morph,start,Class,axisX,yDiff,axis,bind,eval,auto,drag,init,for,Element".split(",")));