puffer 0.0.5 → 0.0.6

Sign up to get free protection for your applications and to get access to all the features.
Files changed (105) hide show
  1. data/.rspec +1 -0
  2. data/Gemfile +2 -1
  3. data/Gemfile.lock +12 -0
  4. data/VERSION +1 -1
  5. data/app/cells/puffer/base/additional.html.erb +17 -0
  6. data/app/cells/puffer/base_cell.rb +25 -0
  7. data/app/controllers/admin/dashboard_controller.rb +12 -0
  8. data/app/views/admin/dashboard/index.html.erb +1 -0
  9. data/app/views/layouts/puffer.html.erb +41 -23
  10. data/app/views/puffer/_form.html.erb +3 -11
  11. data/app/views/puffer/edit.html.erb +6 -4
  12. data/app/views/puffer/index.html.erb +11 -38
  13. data/app/views/puffer/new.html.erb +5 -2
  14. data/app/views/puffer/show.html.erb +4 -4
  15. data/config/routes.rb +7 -0
  16. data/lib/generators/puffer/controller/controller_generator.rb +1 -1
  17. data/lib/generators/puffer/install/templates/puffer/javascripts/rails-src.js +399 -0
  18. data/lib/generators/puffer/install/templates/puffer/javascripts/rails.js +14 -175
  19. data/lib/generators/puffer/install/templates/puffer/javascripts/right-calendar-src.js +1461 -0
  20. data/lib/generators/puffer/install/templates/puffer/javascripts/right-calendar.js +36 -0
  21. data/lib/generators/puffer/install/templates/puffer/javascripts/right-calendar.js.gz +0 -0
  22. data/lib/generators/puffer/install/templates/puffer/javascripts/right-in-edit-src.js +369 -0
  23. data/lib/generators/puffer/install/templates/puffer/javascripts/right-in-edit.js +13 -0
  24. data/lib/generators/puffer/install/templates/puffer/javascripts/right-in-edit.js.gz +0 -0
  25. data/lib/generators/puffer/install/templates/puffer/javascripts/right-lightbox-src.js +905 -0
  26. data/lib/generators/puffer/install/templates/puffer/javascripts/right-lightbox.js +24 -0
  27. data/lib/generators/puffer/install/templates/puffer/javascripts/right-lightbox.js.gz +0 -0
  28. data/lib/generators/puffer/install/templates/puffer/javascripts/right-sortable-src.js +428 -0
  29. data/lib/generators/puffer/install/templates/puffer/javascripts/right-sortable.js +17 -0
  30. data/lib/generators/puffer/install/templates/puffer/javascripts/right-sortable.js.gz +0 -0
  31. data/lib/generators/puffer/install/templates/puffer/javascripts/right-src.js +5892 -0
  32. data/lib/generators/puffer/install/templates/puffer/javascripts/right-tabs-src.js +1145 -0
  33. data/lib/generators/puffer/install/templates/puffer/javascripts/right-tabs.js +29 -0
  34. data/lib/generators/puffer/install/templates/puffer/javascripts/right-tabs.js.gz +0 -0
  35. data/lib/generators/puffer/install/templates/puffer/javascripts/right.js +95 -0
  36. data/lib/generators/puffer/install/templates/puffer/javascripts/right.js.gz +0 -0
  37. data/lib/generators/puffer/install/templates/puffer/stylesheets/puffer.css +168 -0
  38. data/lib/generators/puffer/install/templates/puffer/stylesheets/reset.css +60 -0
  39. data/lib/puffer.rb +2 -1
  40. data/lib/puffer/base.rb +15 -14
  41. data/lib/puffer/controller/config.rb +52 -16
  42. data/lib/puffer/controller/dsl.rb +27 -29
  43. data/lib/puffer/controller/helpers.rb +54 -9
  44. data/lib/puffer/controller/mutate.rb +4 -22
  45. data/lib/puffer/engine.rb +9 -0
  46. data/lib/puffer/extensions/controller.rb +5 -3
  47. data/lib/puffer/extensions/form.rb +14 -0
  48. data/lib/puffer/extensions/mapper.rb +36 -0
  49. data/lib/puffer/fields.rb +21 -0
  50. data/lib/puffer/fields/field.rb +8 -3
  51. data/lib/puffer/inputs.rb +23 -0
  52. data/lib/puffer/inputs/association.rb +11 -0
  53. data/lib/puffer/inputs/base.rb +39 -0
  54. data/lib/puffer/inputs/boolean.rb +19 -0
  55. data/lib/puffer/inputs/collection_association.rb +11 -0
  56. data/lib/puffer/inputs/date_time.rb +16 -0
  57. data/lib/puffer/inputs/file.rb +11 -0
  58. data/lib/puffer/inputs/password.rb +11 -0
  59. data/lib/puffer/inputs/select.rb +11 -0
  60. data/lib/puffer/inputs/text.rb +11 -0
  61. data/lib/puffer/path_set.rb +17 -0
  62. data/lib/puffer/resource.rb +14 -14
  63. data/puffer.gemspec +75 -8
  64. data/spec/dummy/app/controllers/admin/categories_controller.rb +4 -0
  65. data/spec/dummy/app/controllers/admin/posts_controller.rb +4 -0
  66. data/spec/dummy/app/controllers/admin/profiles_controller.rb +5 -0
  67. data/spec/dummy/app/controllers/admin/users_controller.rb +4 -0
  68. data/spec/dummy/app/models/friendship.rb +4 -0
  69. data/spec/dummy/app/models/profile.rb +2 -0
  70. data/spec/dummy/app/models/user.rb +7 -0
  71. data/spec/dummy/app/views/admin/users/index.html.erb +1 -0
  72. data/spec/dummy/config/puffer.rb +0 -0
  73. data/spec/dummy/db/migrate/20110107082706_create_friendships.rb +15 -0
  74. data/spec/dummy/db/schema.rb +9 -1
  75. data/spec/dummy/public/puffer/javascripts/rails-src.js +399 -0
  76. data/spec/dummy/public/puffer/javascripts/rails.js +14 -0
  77. data/spec/dummy/public/puffer/javascripts/right-calendar-src.js +1461 -0
  78. data/spec/dummy/public/puffer/javascripts/right-calendar.js +36 -0
  79. data/spec/dummy/public/puffer/javascripts/right-calendar.js.gz +0 -0
  80. data/spec/dummy/public/puffer/javascripts/right-in-edit-src.js +369 -0
  81. data/spec/dummy/public/puffer/javascripts/right-in-edit.js +13 -0
  82. data/spec/dummy/public/puffer/javascripts/right-in-edit.js.gz +0 -0
  83. data/spec/dummy/public/puffer/javascripts/right-lightbox-src.js +905 -0
  84. data/spec/dummy/public/puffer/javascripts/right-lightbox.js +24 -0
  85. data/spec/dummy/public/puffer/javascripts/right-lightbox.js.gz +0 -0
  86. data/spec/dummy/public/puffer/javascripts/right-sortable-src.js +428 -0
  87. data/spec/dummy/public/puffer/javascripts/right-sortable.js +17 -0
  88. data/spec/dummy/public/puffer/javascripts/right-sortable.js.gz +0 -0
  89. data/spec/dummy/public/puffer/javascripts/right-src.js +5892 -0
  90. data/spec/dummy/public/puffer/javascripts/right-tabs-src.js +1145 -0
  91. data/spec/dummy/public/puffer/javascripts/right-tabs.js +29 -0
  92. data/spec/dummy/public/puffer/javascripts/right-tabs.js.gz +0 -0
  93. data/spec/dummy/public/puffer/javascripts/right.js +95 -0
  94. data/spec/dummy/public/puffer/javascripts/right.js.gz +0 -0
  95. data/spec/dummy/public/puffer/stylesheets/puffer.css +168 -0
  96. data/spec/dummy/public/puffer/stylesheets/reset.css +60 -0
  97. data/spec/lib/fields_spec.rb +2 -0
  98. data/spec/lib/params_spec.rb +55 -54
  99. metadata +114 -23
  100. data/lib/generators/puffer/install/templates/puffer/javascripts/application.js +0 -2
  101. data/lib/generators/puffer/install/templates/puffer/javascripts/controls.js +0 -965
  102. data/lib/generators/puffer/install/templates/puffer/javascripts/dragdrop.js +0 -974
  103. data/lib/generators/puffer/install/templates/puffer/javascripts/effects.js +0 -1123
  104. data/lib/generators/puffer/install/templates/puffer/javascripts/prototype.js +0 -6001
  105. data/lib/puffer/railtie.rb +0 -5
@@ -0,0 +1,36 @@
1
+ /**
2
+ * The calendar widget implemented with RightJS
3
+ *
4
+ * Home page: http://rightjs.org/ui/calendar
5
+ *
6
+ * @copyright (C) 2009-2010 Nikolay Nemshilov
7
+ */
8
+ var Calendar=RightJS.Calendar=function(q,p,f){function x(a,b,c,e){if(f.Fx)if(c===undefined){c=a.options.fxName;if(e===undefined){e={duration:a.options.fxDuration,onFinish:f(a.fire).bind(a,b)};if(b==="hide")e.duration=(f.Fx.Durations[e.duration]||e.duration)/2}}if(!f.Fx||!c)a.fire(b);return a.$super(c,e)}function t(a){return(a<10?"0":"")+a}var o=f,y=f.$,D=f.$$,r=f.$w,E=f.$ext,F=f.isString,z=f.isArray,G=f.isFunction,u=f.Class,l=f.Element,A=f.Input,B=f.RegExp,C=f.Browser,s=new f.Class(f.Element,{initialize:function(a,
9
+ b){this.$super("div",b);this._.innerHTML=a;this.addClass("rui-button");this.on("selectstart","stopEvent")},disable:function(){return this.addClass("rui-button-disabled")},enable:function(){return this.removeClass("rui-button-disabled")},disabled:function(){return this.hasClass("rui-button-disabled")},enabled:function(){return!this.disabled()},fire:function(){this.enabled()&&this.$super.apply(this,arguments);return this}}),n=new (function(a,b){if(!b){b=a;a="DIV"}var c=new f.Class(f.Element.Wrappers[a]||
10
+ f.Element,{initialize:function(e,d){this.key=e;var g=[{"class":"rui-"+e}];this instanceof f.Input||this instanceof f.Form||g.unshift(a);this.$super.apply(this,g);if(f.isString(d))d=f.$(d);if(d instanceof f.Element){this._=d._;if("$listeners"in d)d.$listeners=d.$listeners;d={}}this.setOptions(d,this);return f.Wrapper.Cache[f.$uid(this._)]=this},setOptions:function(e,d){d=d||this;f.Options.setOptions.call(this,f.Object.merge(e,eval("("+(d.get("data-"+this.key)||"{}")+")")));return this}});c=new f.Class(c,
11
+ b);f.Observer.createShortcuts(c.prototype,c.EVENTS||[]);return c})({include:[{show:function(a,b){this.constructor.current=this;return x(this,"show",a,b)},hide:function(a,b){this.constructor.current=null;return x(this,"show",a,b)},showAt:function(a,b,c){var e=this.hide(null).shownAt=a=f.$(a),d=(this.reAnchor||(this.reAnchor=new f.Element("div",{"class":"rui-re-anchor"})).insert(this)).insertTo(e,"after").position();a=e.dimensions();var g=p(e.getStyle("borderTopWidth")),h=p(e.getStyle("borderLeftWidth")),
12
+ j=p(e.getStyle("borderRightWidth")),i=p(e.getStyle("borderBottomWidth"));e=a.top-d.y+g;d=a.left-d.x+h;h=a.width-h-j;a=a.height-g-i;this.setStyle("visibility:hidden").show(null);if(b==="right")d+=h-this.size().x;else e+=a;this.moveTo(d,e);if(c)b==="left"||b==="right"?this.setHeight(a):this.setWidth(h);this.setStyle("visibility:visible").hide(null);return this.show()},toggleAt:function(a,b,c){return this.hidden()?this.showAt(a,b,c):this.hide()}},{assignTo:function(a,b){a=f.$(a);if(b=f.$(b)){b[this.key]=
13
+ this;b.assignedInput=a}else a[this.key]=this;var c=f(function(){if(this.visible()&&(!this.showAt||this.shownAt===a))this.setValue(a.value())}).bind(this);a.on({keyup:c,change:c});this.onChange(function(){if(!this.showAt||this.shownAt===a)a.setValue(this.getValue())});return this}}],extend:{version:"2.2.0",EVENTS:r("show hide change done"),Options:{format:"ISO",showTime:null,showButtons:false,minDate:false,maxDate:false,fxName:"fade",fxDuration:"short",firstDay:1,numberOfMonths:1,timePeriod:1,twentyFourHour:null,
14
+ listYears:false,hideOnPick:false,update:null,trigger:null,cssRule:"*[data-calendar]"},Formats:{ISO:"%Y-%m-%d",POSIX:"%Y/%m/%d",EUR:"%d-%m-%Y",US:"%m/%d/%Y"},i18n:{Done:"Done",Now:"Now",NextMonth:"Next Month",PrevMonth:"Previous Month",NextYear:"Next Year",PrevYear:"Previous Year",dayNames:r("Sunday Monday Tuesday Wednesday Thursday Friday Saturday"),dayNamesShort:r("Sun Mon Tue Wed Thu Fri Sat"),dayNamesMin:r("Su Mo Tu We Th Fr Sa"),monthNames:r("January February March April May June July August September October November December"),
15
+ monthNamesShort:r("Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec")},current:null,hideAll:function(a){D("div.rui-calendar").each(function(b){b instanceof n&&b!==a&&b.visible()&&!b.inlined()&&b.hide()})}},initialize:function(a){this.$super("calendar",a);this.addClass("rui-panel");a=this.options;this.insert([this.swaps=new H(a),this.greed=new I(a)]);if(a.showTime)this.insert(this.timepicker=new J(a));if(a.showButtons)this.insert(this.buttons=new K(a));this.setDate(new Date).initEvents()},setDate:function(a,
16
+ b){if(a=this.parse(a)){var c=this.options;if(c.minDate&&c.minDate>a)a=new Date(c.minDate);if(c.maxDate&&c.maxDate<a){a=new Date(c.maxDate);a.setDate(a.getDate()-1)}this._date=b?new Date(this._date||this.date):null;this.greed.setDate(this._date||a,a);if(c.minDate||c.maxDate)this.swaps.setDate(a);this.timepicker&&!b&&this.timepicker.setDate(a);if(a!=this.date)this.fire("change",{date:this.date=a})}return this},getDate:function(){return this.date},setValue:function(a){return this.setDate(a)},getValue:function(a){return this.format(a)},
17
+ insertTo:function(a,b){this.addClass("rui-calendar-inline");return this.$super(a,b)},done:function(){this.inlined()||this.hide();this.fire("done",{date:this.date})},inlined:function(){return this.hasClass("rui-calendar-inline")},setOptions:function(a){a=a||{};this.$super(a,y(a.trigger||a.update));var b=this.constructor,c=this.options;c.i18n={};for(var e in b.i18n)c.i18n[e]=z(b.i18n[e])?b.i18n[e].clone():b.i18n[e];E(c.i18n,a.i18n);c.dayNames=c.i18n.dayNamesMin;c.firstDay&&c.dayNames.push(c.dayNames.shift());
18
+ if(!z(c.numberOfMonths))c.numberOfMonths=[c.numberOfMonths,1];if(c.minDate)c.minDate=this.parse(c.minDate);if(c.maxDate){c.maxDate=this.parse(c.maxDate);c.maxDate.setDate(c.maxDate.getDate()+1)}c.format=o(b.Formats[c.format]||c.format).trim();if(c.showTime===null)c.showTime=c.format.search(/%[HkIl]/)>-1;if(c.twentyFourHour===null)c.twentyFourHour=c.format.search(/%[Il]/)<0;if(c.timePeriod>60&&12%Math.ceil(c.timePeriod/60))c.twentyFourHour=true;c.update&&this.assignTo(c.update,c.trigger);return this},
19
+ hideOthers:function(){n.hideAll(this);return this}}),H=new u(l,{initialize:function(a){this.$super("div",{"class":"swaps"});this.options=a;var b=a.i18n;this.insert([this.prevMonth=new s("&lsaquo;",{title:b.PrevMonth,"class":"prev-month"}),this.nextMonth=new s("&rsaquo;",{title:b.NextMonth,"class":"next-month"})]);if(a.listYears)this.insert([this.prevYear=new s("&laquo;",{title:b.PrevYear,"class":"prev-year"}),this.nextYear=new s("&raquo;",{title:b.NextYear,"class":"next-year"})]);this.buttons=o([this.prevMonth,
20
+ this.nextMonth,this.prevYear,this.nextYear]).compact();this.onClick(this.clicked)},setDate:function(a){var b=this.options,c=b.numberOfMonths[0]*b.numberOfMonths[1],e=true,d=true,g=true,h=true;if(b.minDate){g=new Date(a.getFullYear(),0,1,0,0,0);var j=new Date(b.minDate.getFullYear(),0,1,0,0,0);e=g>j;g.setMonth(a.getMonth()-Math.ceil(c-c/2));j.setMonth(b.minDate.getMonth());g=g>=j}if(b.maxDate){a=new Date(a);b=new Date(b.maxDate);c=o([a,b]);c.each(function(i){i.setDate(32);i.setMonth(i.getMonth()-1);
21
+ i.setDate(32-i.getDate());i.setHours(0);i.setMinutes(0);i.setSeconds(0);i.setMilliseconds(0)});h=a<b;c.each("setMonth",0);d=a<b}this.nextMonth[h?"enable":"disable"]();this.prevMonth[g?"enable":"disable"]();if(this.nextYear){this.nextYear[d?"enable":"disable"]();this.prevYear[e?"enable":"disable"]()}},clicked:function(a){(a=a.target)&&this.buttons.include(a)&&a.enabled()&&this.fire(a.get("className").split(/\s+/)[0])}}),L=new u(l,{initialize:function(a){this.$super("table",{"class":"month"});this.options=
22
+ a;this.insert(this.caption=new l("caption"));this.insert("<thead><tr>"+a.dayNames.map(function(d){return"<th>"+d+"</th>"}).join("")+"</tr></thead>");this.days=[];a=(new l("tbody")).insertTo(this);var b,c,e;for(c=0;c<6;c++){e=(new l("tr")).insertTo(a);for(b=0;b<7;b++)this.days.push((new l("td")).insertTo(e))}this.onClick(this.clicked)},setDate:function(a,b){a.setDate(32);var c=32-a.getDate();a.setMonth(a.getMonth()-1);for(var e=Math.ceil(b.getTime()/864E5),d=this.options,g=d.i18n,h=this.days,j=0,i=
23
+ h.length-1,k,m,v;j<7;j++){k=h[j]._;m=h[i-j]._;v=h[i-j-7]._;k.innerHTML=m.innerHTML=v.innerHTML="";k.className=m.className=v.className="blank"}j=1;i=0;for(var w;j<=c;j++){a.setDate(j);m=a.getDay();if(d.firstDay===1)m=m>0?m-1:6;if(j===1||m===0){w=h.slice(i*7,i*7+7);i++}k=w[m]._;if(C.OLD){k.innerHTML="";k.appendChild(q.createTextNode(j))}else k.innerHTML=""+j;k.className=e===Math.ceil(a.getTime()/864E5)?"selected":"";if(d.minDate&&d.minDate>a||d.maxDate&&d.maxDate<a)k.className="disabled";w[m].date=
24
+ new Date(a)}c=(d.listYears?g.monthNamesShort[a.getMonth()]+",":g.monthNames[a.getMonth()])+" "+a.getFullYear();e=this.caption._;if(C.OLD){e.innerHTML="";e.appendChild(q.createTextNode(c))}else e.innerHTML=c},clicked:function(a){a=a.target;var b=a.date;if(a&&b&&!a.hasClass("disabled")&&!a.hasClass("blank")){a.addClass("selected");this.fire("date-set",{date:b.getDate(),month:b.getMonth(),year:b.getFullYear()})}}}),I=new u(l,{initialize:function(a){this.$super("table",{"class":"greed"});this.months=
25
+ [];for(var b=(new l("tbody")).insertTo(this),c,e=0;e<a.numberOfMonths[1];e++)for(var d=(new l("tr")).insertTo(b),g=0;g<a.numberOfMonths[0];g++){this.months.push(c=new L(a));(new l("td")).insertTo(d).insert(c)}},setDate:function(a,b){var c=this.months,e=c.length;b=b||a;for(var d=-Math.ceil(e-e/2)+1,g=0;d<Math.floor(e-e/2)+1;d++,g++){var h=new Date(a);h.setMonth(a.getMonth()+d);c[g].setDate(h,b)}}}),J=new u(l,{initialize:function(a){this.$super("div",{"class":"timepicker"});this.options=a;var b=o(this.timeChanged).bind(this);
26
+ this.insert([this.hours=(new l("select")).onChange(b),this.minutes=(new l("select")).onChange(b)]);for(var c=a.timePeriod<60?a.timePeriod:60,e=a.timePeriod<60?1:Math.ceil(a.timePeriod/60),d=0;d<60;d++){var g=t(d);if(d<24&&d%e==0)if(a.twentyFourHour)this.hours.insert(new l("option",{value:d,html:g}));else if(d<12)this.hours.insert(new l("option",{value:d,html:d==0?12:d}));d%c==0&&this.minutes.insert(new l("option",{value:d,html:g}))}if(!a.twentyFourHour){this.meridian=(new l("select")).onChange(b).insertTo(this);
27
+ o(o(a.format).includes(/%P/)?["am","pm"]:["AM","PM"]).each(function(h){this.meridian.insert(new l("option",{value:h.toLowerCase(),html:h}))},this)}},setDate:function(a){var b=this.options,c=b.timePeriod<60?a.getHours():Math.round(a.getHours()/(b.timePeriod/60))*(b.timePeriod/60);a=Math.round(a.getMinutes()/(b.timePeriod%60))*b.timePeriod;if(this.meridian){this.meridian.setValue(c<12?"am":"pm");c=c==0||c==12?12:c>12?c-12:c}this.hours.setValue(c);this.minutes.setValue(a)},timeChanged:function(a){a.stopPropagation();
28
+ a=p(this.hours.value());var b=p(this.minutes.value());if(this.meridian){if(a==12)a=0;if(this.meridian.value()=="pm")a+=12}this.fire("time-set",{hours:a,minutes:b})}}),K=new u(l,{initialize:function(a){this.$super("div",{"class":"buttons"});this.insert([(new s(a.i18n.Now,{"class":"now"})).onClick("fire","now-clicked"),(new s(a.i18n.Done,{"class":"done"})).onClick("fire","done-clicked")])}});n.include({parse:function(a){var b;if(F(a)&&a){var c=B.escape(this.options.format),e=o(c.match(/%[a-z]/ig)).map("match",
29
+ /[a-z]$/i).map("first").without("%");c=new B("^"+c.replace(/%p/i,"(pm|PM|am|AM)").replace(/(%[a-z])/ig,"(.+?)")+"$");if(a=o(a).trim().match(c)){a.shift();for(var d=c=null,g=null,h=null,j=null,i;a.length;){var k=a.shift(),m=e.shift();if(m.toLowerCase()=="b")d=this.options.i18n[m=="b"?"monthNamesShort":"monthNames"].indexOf(k);else if(m.toLowerCase()=="p")i=k.toLowerCase();else{k=p(k,10);switch(m){case "d":case "e":b=k;break;case "m":d=k-1;break;case "y":case "Y":c=k;break;case "H":case "k":case "I":case "l":g=
30
+ k;break;case "M":h=k;break;case "S":j=k;break}}}if(i){g=g==12?0:g;g=i=="pm"?g+12:g}b=new Date(c,d,b,g,h,j)}}else if(a instanceof Date||Date.parse(a))b=new Date(a);return!b||isNaN(b.getTime())?null:b},format:function(a){var b=this.options.i18n,c=this.date.getDay(),e=this.date.getMonth(),d=this.date.getDate(),g=this.date.getFullYear(),h=this.date.getHours(),j=this.date.getMinutes(),i=this.date.getSeconds(),k=h==0?12:h<13?h:h-12;b={a:b.dayNamesShort[c],A:b.dayNames[c],b:b.monthNamesShort[e],B:b.monthNames[e],
31
+ d:t(d),e:""+d,m:(e<9?"0":"")+(e+1),y:(""+g).substring(2,4),Y:""+g,H:t(h),k:""+h,I:(h>0&&(h<10||h>12&&h<22)?"0":"")+k,l:""+k,p:h<12?"AM":"PM",P:h<12?"am":"pm",M:t(j),S:t(i),"%":"%"};a=a||this.options.format;for(var m in b)a=a.replace("%"+m,b[m]);return a}});n.include({initEvents:function(){var a=this._terminate;this.on({"prev-day":["_shiftDate",{Date:-1}],"next-day":["_shiftDate",{Date:1}],"prev-week":["_shiftDate",{Date:-7}],"next-week":["_shiftDate",{Date:7}],"prev-month":["_shiftDate",{Month:-1}],
32
+ "next-month":["_shiftDate",{Month:1}],"prev-year":["_shiftDate",{FullYear:-1}],"next-year":["_shiftDate",{FullYear:1}],"date-set":this._changeDate,"time-set":this._changeTime,"now-clicked":this._setNow,"done-clicked":this.done,click:a,mousedown:a,focus:a,blur:a})},_shiftDate:function(a){var b=new Date(this.date);for(var c in a)b["set"+c](b["get"+c]()+a[c]);this.setDate(b)},_changeDate:function(a){var b=new Date(this.date);b.setDate(a.date);b.setMonth(a.month);b.setFullYear(a.year);this.setDate(b,
33
+ true);this.options.hideOnPick&&this.done()},_changeTime:function(a){var b=new Date(this.date);b.setHours(a.hours);b.setMinutes(a.minutes);this.setDate(b)},_setNow:function(){this.setDate(new Date)},_terminate:function(a){a.stopPropagation();if(this._hide_delay){this._hide_delay.cancel();this._hide_delay=null}}});y(q).on({focus:function(a){a=a.target instanceof A&&a.target.get("type")=="text"?a.target:null;n.hideAll();if(a&&(a.calendar||a.match(n.Options.cssRule)))(a.calendar||new n({update:a})).setValue(a.value()).showAt(a)},
34
+ blur:function(a){var b=a.target.calendar;if(b)b._hide_delay=o(function(){b.hide()}).delay(200)},click:function(a){var b=a.target instanceof l?a.target:null;if(b&&(b.calendar||b.match(n.Options.cssRule))){if(!(b instanceof A)||b.get("type")!="text"){a.stop();(b.calendar||new n({trigger:b})).hide(null).toggleAt(b.assignedInput)}}else a.find("div.rui-calendar")||n.hideAll()},keydown:function(a){var b=n.current,c={27:"hide",37:"prev-day",39:"next-day",38:"prev-week",40:"next-week",33:"prev-month",34:"next-month",
35
+ 13:"done"}[a.keyCode];if(c&&b&&b.visible()){a.stop();G(b[c])?b[c]():b.fire(c)}}});(function(){var a=q.createElement("style"),b=q.createTextNode(".rui-panel{margin:0;padding:.5em;position:relative;background-color:#EEE;border:1px solid #BBB;border-radius:.3em;-moz-border-radius:.3em;-webkit-border-radius:.3em;box-shadow:.15em .3em .5em #BBB;-moz-box-shadow:.15em .3em .5em #BBB;-webkit-box-shadow:.15em .3em .5em #BBB;cursor:default} *.rui-button{display:inline-block; *display:inline; *zoom:1;height:1em;line-height:1em;margin:0;padding:.2em .5em;text-align:center;border:1px solid #CCC;border-radius:.2em;-moz-border-radius:.2em;-webkit-border-radius:.2em;cursor:pointer;color:#333;background-color:#FFF;user-select:none;-moz-user-select:none;-webkit-user-select:none} *.rui-button:hover{color:#111;border-color:#999;background-color:#DDD;box-shadow:#888 0 0 .1em;-moz-box-shadow:#888 0 0 .1em;-webkit-box-shadow:#888 0 0 .1em} *.rui-button:active{color:#000;border-color:#777;text-indent:1px;box-shadow:none;-moz-box-shadow:none;-webkit-box-shadow:none} *.rui-button-disabled, *.rui-button-disabled:hover, *.rui-button-disabled:active{color:#888;background:#DDD;border-color:#CCC;cursor:default;text-indent:0;box-shadow:none;-moz-box-shadow:none;-webkit-box-shadow:none}div.rui-re-anchor{margin:0;padding:0;background:none;border:none;float:none;display:inline;position:absolute;z-index:9999}div.rui-calendar .swaps,div.rui-calendar .greed,div.rui-calendar .timepicker,div.rui-calendar .buttons,div.rui-calendar table,div.rui-calendar table tr,div.rui-calendar table th,div.rui-calendar table td,div.rui-calendar table tbody,div.rui-calendar table thead,div.rui-calendar table caption{background:none;border:none;width:auto;height:auto;margin:0;padding:0}div.rui-calendar-inline{position:relative;display:inline-block; *display:inline; *zoom:1;box-shadow:none;-moz-box-shadow:none;-webkit-box-shadow:none}div.rui-calendar .swaps{position:relative}div.rui-calendar .swaps .rui-button{position:absolute;float:left;width:1em;padding:.15em .4em}div.rui-calendar .swaps .next-month{right:0em;_right:.5em}div.rui-calendar .swaps .prev-year{left:2.05em}div.rui-calendar .swaps .next-year{right:2.05em;_right:2.52em}div.rui-calendar .greed{border-spacing:0px;border-collapse:collapse;border-size:0}div.rui-calendar .greed td{vertical-align:top;padding-left:.4em}div.rui-calendar .greed>tbody>tr>td:first-child{padding:0}div.rui-calendar .month{margin-top:.2em;border-spacing:1px;border-collapse:separate}div.rui-calendar .month caption{text-align:center}div.rui-calendar .month th{color:#666;text-align:center}div.rui-calendar .month td{text-align:right;padding:.1em .3em;background-color:#FFF;border:1px solid #CCC;cursor:pointer;color:#555;border-radius:.2em;-moz-border-radius:.2em;-webkit-border-radius:.2em}div.rui-calendar .month td:hover{background-color:#CCC;border-color:#AAA;color:#000}div.rui-calendar .month td.blank{background:transparent;cursor:default;border:none}div.rui-calendar .month td.selected{background-color:#BBB;border-color:#AAA;color:#222;font-weight:bold;padding:.1em .2em}div.rui-calendar .month td.disabled{color:#888;background:#EEE;border-color:#CCC;cursor:default}div.rui-calendar .timepicker{border-top:1px solid #ccc;margin-top:.3em;padding-top:.5em;text-align:center}div.rui-calendar .timepicker select{margin:0 .4em}div.rui-calendar .buttons{position:relative;margin-top:.5em}div.rui-calendar .buttons div.rui-button{width:4em;padding:.25em .5em}div.rui-calendar .buttons .done{position:absolute;right:0em;top:0}");
36
+ a.type="text/css";if(a.styleSheet)a.styleSheet.cssText=b.nodeValue;else a.appendChild(b);q.getElementsByTagName("head")[0].appendChild(a)})();return n}(document,parseInt,RightJS);
@@ -0,0 +1,369 @@
1
+ /**
2
+ * Inline editor feature for RightJS
3
+ * http://rightjs.org/ui/in-edit
4
+ *
5
+ * Copyright (C) 2009-2010 Nikolay Nemshilov
6
+ */
7
+ var InEdit = RightJS.InEdit = (function(document, RightJS) {
8
+ /**
9
+ * This module defines the basic widgets constructor
10
+ * it creates an abstract proxy with the common functionality
11
+ * which then we reuse and override in the actual widgets
12
+ *
13
+ * Copyright (C) 2010-2011 Nikolay Nemshilov
14
+ */
15
+
16
+ /**
17
+ * In-Edit plugin initalization
18
+ *
19
+ * Copyright (C) 2010 Nikolay Nemshilov
20
+ */
21
+ var R = RightJS,
22
+ $ = RightJS.$,
23
+ $w = RightJS.$w,
24
+ Xhr = RightJS.Xhr,
25
+ Object = RightJS.Object,
26
+ Element = RightJS.Element,
27
+ Input = RightJS.Input;
28
+
29
+
30
+
31
+
32
+
33
+
34
+
35
+
36
+
37
+ /**
38
+ * The widget units constructor
39
+ *
40
+ * @param String tag-name or Object methods
41
+ * @param Object methods
42
+ * @return Widget wrapper
43
+ */
44
+ function Widget(tag_name, methods) {
45
+ if (!methods) {
46
+ methods = tag_name;
47
+ tag_name = 'DIV';
48
+ }
49
+
50
+ /**
51
+ * An Abstract Widget Unit
52
+ *
53
+ * Copyright (C) 2010 Nikolay Nemshilov
54
+ */
55
+ var AbstractWidget = new RightJS.Class(RightJS.Element.Wrappers[tag_name] || RightJS.Element, {
56
+ /**
57
+ * The common constructor
58
+ *
59
+ * @param Object options
60
+ * @param String optional tag name
61
+ * @return void
62
+ */
63
+ initialize: function(key, options) {
64
+ this.key = key;
65
+ var args = [{'class': 'rui-' + key}];
66
+
67
+ // those two have different constructors
68
+ if (!(this instanceof RightJS.Input || this instanceof RightJS.Form)) {
69
+ args.unshift(tag_name);
70
+ }
71
+ this.$super.apply(this, args);
72
+
73
+ if (RightJS.isString(options)) {
74
+ options = RightJS.$(options);
75
+ }
76
+
77
+ // if the options is another element then
78
+ // try to dynamically rewrap it with our widget
79
+ if (options instanceof RightJS.Element) {
80
+ this._ = options._;
81
+ if ('$listeners' in options) {
82
+ options.$listeners = options.$listeners;
83
+ }
84
+ options = {};
85
+ }
86
+ this.setOptions(options, this);
87
+
88
+ return (RightJS.Wrapper.Cache[RightJS.$uid(this._)] = this);
89
+ },
90
+
91
+ // protected
92
+
93
+ /**
94
+ * Catches the options
95
+ *
96
+ * @param Object user-options
97
+ * @param Element element with contextual options
98
+ * @return void
99
+ */
100
+ setOptions: function(options, element) {
101
+ element = element || this;
102
+ RightJS.Options.setOptions.call(this,
103
+ RightJS.Object.merge(options, eval("("+(
104
+ element.get('data-'+ this.key) || '{}'
105
+ )+")"))
106
+ );
107
+ return this;
108
+ }
109
+ });
110
+
111
+ /**
112
+ * Creating the actual widget class
113
+ *
114
+ */
115
+ var Klass = new RightJS.Class(AbstractWidget, methods);
116
+
117
+ // creating the widget related shortcuts
118
+ RightJS.Observer.createShortcuts(Klass.prototype, Klass.EVENTS || []);
119
+
120
+ return Klass;
121
+ }
122
+
123
+
124
+ /**
125
+ * A shared module to create textual spinners
126
+ *
127
+ * Copyright (C) 2010-2011 Nikolay Nemshilov
128
+ */
129
+ var Spinner = new RightJS.Class(RightJS.Element, {
130
+ /**
131
+ * Constructor
132
+ *
133
+ * @param Number optional spinner size (4 by default)
134
+ * @return void
135
+ */
136
+ initialize: function(size) {
137
+ this.$super('div', {'class': 'rui-spinner'});
138
+ this.dots = [];
139
+
140
+ for (var i=0; i < (size || 4); i++) {
141
+ this.dots.push(new RightJS.Element('div'));
142
+ }
143
+
144
+ this.dots[0].addClass('glowing');
145
+ this.insert(this.dots);
146
+ RightJS(this.shift).bind(this).periodical(300);
147
+ },
148
+
149
+ /**
150
+ * Shifts the spinner elements
151
+ *
152
+ * @return void
153
+ */
154
+ shift: function() {
155
+ if (this.visible()) {
156
+ var dot = this.dots.pop();
157
+ this.dots.unshift(dot);
158
+ this.insert(dot, 'top');
159
+ }
160
+ }
161
+ });
162
+
163
+
164
+ /**
165
+ * An inline editor feature
166
+ *
167
+ * Copyright (C) 2009-2011 Nikolay Nemshilov
168
+ */
169
+ var InEdit = new Widget('FORM', {
170
+ extend: {
171
+ version: '2.2.0',
172
+
173
+ EVENTS: $w('show hide send update'),
174
+
175
+ Options: {
176
+ url: null, // the url address where to send the stuff
177
+ name: 'text', // the field name
178
+ method: 'put', // the method
179
+
180
+ type: 'text', // the input type, 'text', 'file', 'password' or 'textarea'
181
+
182
+ toggle: null, // a reference to an element that should get hidden when the editor is active
183
+
184
+ update: true, // a marker if the element should be updated with the response-text
185
+
186
+ Xhr: {} // additional Xhr options
187
+ },
188
+
189
+ i18n: {
190
+ Save: 'Save',
191
+ Cancel: 'Cancel'
192
+ },
193
+
194
+ current: null // currently opened editor
195
+ },
196
+
197
+ /**
198
+ * Constructor
199
+ *
200
+ * @param mixed an element reference
201
+ * @param Object options
202
+ * @return void
203
+ */
204
+ initialize: function(element, options) {
205
+ this.element = $(element);
206
+
207
+ this
208
+ .$super('in-edit', options)
209
+ .set('action', this.options.url)
210
+ .insert([
211
+ this.field = new Input({type: this.options.type, name: this.options.name, 'class': 'field'}),
212
+ this.spinner = new Spinner(4),
213
+ this.submit = new Input({type: 'submit', 'class': 'submit', value: InEdit.i18n.Save}),
214
+ this.cancel = new Element('a', {'class': 'cancel', href: '#', html: InEdit.i18n.Cancel})
215
+ ])
216
+ .onClick(this.clicked)
217
+ .onSubmit(this.send);
218
+ },
219
+
220
+ /**
221
+ * Shows the inline-editor form
222
+ *
223
+ * @return InEdit this
224
+ */
225
+ show: function() {
226
+ if (InEdit.current !== this) {
227
+ if (InEdit.current) { InEdit.current.hide(); }
228
+
229
+ this.oldContent = this.element.html();
230
+
231
+ if (!R(['file', 'password']).include(this.options.type)) {
232
+ this.field.setValue(this.oldContent);
233
+ }
234
+
235
+ this.element.update(this);
236
+
237
+ this.spinner.hide();
238
+ this.submit.show();
239
+
240
+ if (this.options.toggle) {
241
+ $(this.options.toggle).hide();
242
+ }
243
+ }
244
+
245
+ if (this.options.type !== 'file') {
246
+ this.field.focus();
247
+ }
248
+
249
+ InEdit.current = this;
250
+ return this.fire('show');
251
+ },
252
+
253
+ /**
254
+ * Hides the form and brings the content back
255
+ *
256
+ * @param String optional new content
257
+ * @return InEdit this
258
+ */
259
+ hide: function() {
260
+ this.element._.innerHTML = this.oldContent;
261
+
262
+ if (this.xhr) {
263
+ this.xhr.cancel();
264
+ }
265
+
266
+ return this.finish();
267
+ },
268
+
269
+ /**
270
+ * Triggers the form remote submit
271
+ *
272
+ * @return InEdit this
273
+ */
274
+ send: function(event) {
275
+ if (event) { event.stop(); }
276
+
277
+ this.spinner.show().resize(this.submit.size());
278
+ this.submit.hide();
279
+
280
+ this.xhr = new Xhr(this.options.url, Object.merge(this.options.Xhr, {
281
+ method: this.options.method,
282
+ spinner: this.spinner,
283
+ onComplete: R(this.receive).bind(this)
284
+ })).send(this);
285
+
286
+ return this.fire('send');
287
+ },
288
+
289
+ // protected
290
+
291
+ // finishes up with the form
292
+ finish: function() {
293
+ if (this.options.toggle) {
294
+ $(this.options.toggle).show();
295
+ }
296
+
297
+ InEdit.current = null;
298
+ return this.fire('hide');
299
+ },
300
+
301
+ // the xhr callback
302
+ receive: function() {
303
+ if (this.options.update) {
304
+ this.element.update(this.xhr.text);
305
+ this.fire('update');
306
+ }
307
+
308
+ this.xhr = null;
309
+
310
+ this.finish();
311
+ },
312
+
313
+ // catches clicks on the element
314
+ clicked: function(event) {
315
+ if (event.target === this.cancel) {
316
+ event.stop();
317
+ this.hide();
318
+ }
319
+ }
320
+
321
+ });
322
+
323
+
324
+ /**
325
+ * The document hooks for in-edit form
326
+ *
327
+ * Copyright (C) 2010 Nikolay Nemshilov
328
+ */
329
+ $(document).onKeydown(function(event) {
330
+ // processing the `ESC` button
331
+ if (event.keyCode === 27 && InEdit.current) {
332
+ InEdit.current.hide();
333
+ }
334
+ });
335
+
336
+
337
+ /**
338
+ * The element level inline editor extension
339
+ *
340
+ * Copyright (C) 2009-2010 Nikolay Nemshilov
341
+ */
342
+ Element.include({
343
+ /**
344
+ * Triggers an inline-editor feature on the element
345
+ *
346
+ * @param Object options for the InEdit class
347
+ * @return InEdit object
348
+ */
349
+ inEdit: function(options) {
350
+ return new InEdit(this, options).show();
351
+ }
352
+ });
353
+ (function() {
354
+ var style = document.createElement('style'),
355
+ rules = document.createTextNode("div.rui-spinner,div.rui-spinner div{margin:0;padding:0;border:none;background:none;list-style:none;font-weight:normal;float:none;display:inline-block; *display:inline; *zoom:1;border-radius:.12em;-moz-border-radius:.12em;-webkit-border-radius:.12em}div.rui-spinner{text-align:center;white-space:nowrap;background:#EEE;border:1px solid #DDD;height:1.2em;padding:0 .2em}div.rui-spinner div{width:.4em;height:70%;background:#BBB;margin-left:1px}div.rui-spinner div:first-child{margin-left:0}div.rui-spinner div.glowing{background:#777}form.rui-in-edit,form.rui-in-edit .cancel{margin:0;padding:0;float:none;position:static}form.rui-in-edit{display:inline-block; *display:inline; *zoom:1;border:none;background:none}form.rui-in-edit div.rui-spinner{margin-right:.2em}form.rui-in-edit div.rui-spinner div{margin-top:.2em}form.rui-in-edit textarea.field{width:100%;margin-bottom:.5em}form.rui-in-edit .field,form.rui-in-edit .submit{margin-right:.2em}form.rui-in-edit,form.rui-in-edit .field,form.rui-in-edit .submit,form.rui-in-edit div.rui-spinner,form.rui-in-edit .cancel{vertical-align:middle}");
356
+
357
+ style.type = 'text/css';
358
+
359
+ if(style.styleSheet) {
360
+ style.styleSheet.cssText = rules.nodeValue;
361
+ } else {
362
+ style.appendChild(rules);
363
+ }
364
+
365
+ document.getElementsByTagName('head')[0].appendChild(style);
366
+ })();
367
+
368
+ return InEdit;
369
+ })(document, RightJS);
@@ -0,0 +1,13 @@
1
+ /**
2
+ * Inline editor feature for RightJS
3
+ * http://rightjs.org/ui/in-edit
4
+ *
5
+ * Copyright (C) 2009-2010 Nikolay Nemshilov
6
+ */
7
+ var InEdit=RightJS.InEdit=function(g,b){var h=b.$,m=b.$w,n=b.Xhr,o=b.Object,j=b.Element,k=b.Input,p=new b.Class(b.Element,{initialize:function(a){this.$super("div",{"class":"rui-spinner"});this.dots=[];for(var d=0;d<(a||4);d++)this.dots.push(new b.Element("div"));this.dots[0].addClass("glowing");this.insert(this.dots);b(this.shift).bind(this).periodical(300)},shift:function(){if(this.visible()){var a=this.dots.pop();this.dots.unshift(a);this.insert(a,"top")}}}),e=new (function(a,d){if(!d){d=a;a="DIV"}var f=
8
+ new b.Class(b.Element.Wrappers[a]||b.Element,{initialize:function(i,c){this.key=i;var l=[{"class":"rui-"+i}];this instanceof b.Input||this instanceof b.Form||l.unshift(a);this.$super.apply(this,l);if(b.isString(c))c=b.$(c);if(c instanceof b.Element){this._=c._;if("$listeners"in c)c.$listeners=c.$listeners;c={}}this.setOptions(c,this);return b.Wrapper.Cache[b.$uid(this._)]=this},setOptions:function(i,c){c=c||this;b.Options.setOptions.call(this,b.Object.merge(i,eval("("+(c.get("data-"+this.key)||"{}")+
9
+ ")")));return this}});f=new b.Class(f,d);b.Observer.createShortcuts(f.prototype,f.EVENTS||[]);return f})("FORM",{extend:{version:"2.2.0",EVENTS:m("show hide send update"),Options:{url:null,name:"text",method:"put",type:"text",toggle:null,update:true,Xhr:{}},i18n:{Save:"Save",Cancel:"Cancel"},current:null},initialize:function(a,d){this.element=h(a);this.$super("in-edit",d).set("action",this.options.url).insert([this.field=new k({type:this.options.type,name:this.options.name,"class":"field"}),this.spinner=
10
+ new p(4),this.submit=new k({type:"submit","class":"submit",value:e.i18n.Save}),this.cancel=new j("a",{"class":"cancel",href:"#",html:e.i18n.Cancel})]).onClick(this.clicked).onSubmit(this.send)},show:function(){if(e.current!==this){e.current&&e.current.hide();this.oldContent=this.element.html();b(["file","password"]).include(this.options.type)||this.field.setValue(this.oldContent);this.element.update(this);this.spinner.hide();this.submit.show();this.options.toggle&&h(this.options.toggle).hide()}this.options.type!==
11
+ "file"&&this.field.focus();e.current=this;return this.fire("show")},hide:function(){this.element._.innerHTML=this.oldContent;this.xhr&&this.xhr.cancel();return this.finish()},send:function(a){a&&a.stop();this.spinner.show().resize(this.submit.size());this.submit.hide();this.xhr=(new n(this.options.url,o.merge(this.options.Xhr,{method:this.options.method,spinner:this.spinner,onComplete:b(this.receive).bind(this)}))).send(this);return this.fire("send")},finish:function(){this.options.toggle&&h(this.options.toggle).show();
12
+ e.current=null;return this.fire("hide")},receive:function(){if(this.options.update){this.element.update(this.xhr.text);this.fire("update")}this.xhr=null;this.finish()},clicked:function(a){if(a.target===this.cancel){a.stop();this.hide()}}});h(g).onKeydown(function(a){a.keyCode===27&&e.current&&e.current.hide()});j.include({inEdit:function(a){return(new e(this,a)).show()}});(function(){var a=g.createElement("style"),d=g.createTextNode("div.rui-spinner,div.rui-spinner div{margin:0;padding:0;border:none;background:none;list-style:none;font-weight:normal;float:none;display:inline-block; *display:inline; *zoom:1;border-radius:.12em;-moz-border-radius:.12em;-webkit-border-radius:.12em}div.rui-spinner{text-align:center;white-space:nowrap;background:#EEE;border:1px solid #DDD;height:1.2em;padding:0 .2em}div.rui-spinner div{width:.4em;height:70%;background:#BBB;margin-left:1px}div.rui-spinner div:first-child{margin-left:0}div.rui-spinner div.glowing{background:#777}form.rui-in-edit,form.rui-in-edit .cancel{margin:0;padding:0;float:none;position:static}form.rui-in-edit{display:inline-block; *display:inline; *zoom:1;border:none;background:none}form.rui-in-edit div.rui-spinner{margin-right:.2em}form.rui-in-edit div.rui-spinner div{margin-top:.2em}form.rui-in-edit textarea.field{width:100%;margin-bottom:.5em}form.rui-in-edit .field,form.rui-in-edit .submit{margin-right:.2em}form.rui-in-edit,form.rui-in-edit .field,form.rui-in-edit .submit,form.rui-in-edit div.rui-spinner,form.rui-in-edit .cancel{vertical-align:middle}");
13
+ a.type="text/css";if(a.styleSheet)a.styleSheet.cssText=d.nodeValue;else a.appendChild(d);g.getElementsByTagName("head")[0].appendChild(a)})();return e}(document,RightJS);
@@ -0,0 +1,905 @@
1
+ /**
2
+ * Lightbox feature for RightJS
3
+ * http://rightjs.org/ui/lightbox
4
+ *
5
+ * Copyright (C) 2009-2010 Nikolay Nemshilov
6
+ */
7
+ var Lightbox = RightJS.Lightbox = (function(document, RightJS) {
8
+ /**
9
+ * This module defines the basic widgets constructor
10
+ * it creates an abstract proxy with the common functionality
11
+ * which then we reuse and override in the actual widgets
12
+ *
13
+ * Copyright (C) 2010-2011 Nikolay Nemshilov
14
+ */
15
+
16
+ /**
17
+ * The filenames to include
18
+ *
19
+ * Copyright (C) 2010-2011 Nikolay Nemshilov
20
+ */
21
+ var R = RightJS,
22
+ $ = RightJS.$,
23
+ $$ = RightJS.$$,
24
+ $w = RightJS.$w,
25
+ $E = RightJS.$E,
26
+ $ext = RightJS.$ext,
27
+ Xhr = RightJS.Xhr,
28
+ Class = RightJS.Class,
29
+ Object = RightJS.Object,
30
+ Element = RightJS.Element,
31
+ Browser = RightJS.Browser;
32
+
33
+ // IE6 doesn't support position:fixed so it needs a crunch
34
+ Browser.IE6 = Browser.OLD && navigator.userAgent.indexOf("MSIE 6") > 0;
35
+
36
+
37
+
38
+
39
+
40
+
41
+
42
+
43
+ /**
44
+ * The widget units constructor
45
+ *
46
+ * @param String tag-name or Object methods
47
+ * @param Object methods
48
+ * @return Widget wrapper
49
+ */
50
+ function Widget(tag_name, methods) {
51
+ if (!methods) {
52
+ methods = tag_name;
53
+ tag_name = 'DIV';
54
+ }
55
+
56
+ /**
57
+ * An Abstract Widget Unit
58
+ *
59
+ * Copyright (C) 2010 Nikolay Nemshilov
60
+ */
61
+ var AbstractWidget = new RightJS.Class(RightJS.Element.Wrappers[tag_name] || RightJS.Element, {
62
+ /**
63
+ * The common constructor
64
+ *
65
+ * @param Object options
66
+ * @param String optional tag name
67
+ * @return void
68
+ */
69
+ initialize: function(key, options) {
70
+ this.key = key;
71
+ var args = [{'class': 'rui-' + key}];
72
+
73
+ // those two have different constructors
74
+ if (!(this instanceof RightJS.Input || this instanceof RightJS.Form)) {
75
+ args.unshift(tag_name);
76
+ }
77
+ this.$super.apply(this, args);
78
+
79
+ if (RightJS.isString(options)) {
80
+ options = RightJS.$(options);
81
+ }
82
+
83
+ // if the options is another element then
84
+ // try to dynamically rewrap it with our widget
85
+ if (options instanceof RightJS.Element) {
86
+ this._ = options._;
87
+ if ('$listeners' in options) {
88
+ options.$listeners = options.$listeners;
89
+ }
90
+ options = {};
91
+ }
92
+ this.setOptions(options, this);
93
+
94
+ return (RightJS.Wrapper.Cache[RightJS.$uid(this._)] = this);
95
+ },
96
+
97
+ // protected
98
+
99
+ /**
100
+ * Catches the options
101
+ *
102
+ * @param Object user-options
103
+ * @param Element element with contextual options
104
+ * @return void
105
+ */
106
+ setOptions: function(options, element) {
107
+ element = element || this;
108
+ RightJS.Options.setOptions.call(this,
109
+ RightJS.Object.merge(options, eval("("+(
110
+ element.get('data-'+ this.key) || '{}'
111
+ )+")"))
112
+ );
113
+ return this;
114
+ }
115
+ });
116
+
117
+ /**
118
+ * Creating the actual widget class
119
+ *
120
+ */
121
+ var Klass = new RightJS.Class(AbstractWidget, methods);
122
+
123
+ // creating the widget related shortcuts
124
+ RightJS.Observer.createShortcuts(Klass.prototype, Klass.EVENTS || []);
125
+
126
+ return Klass;
127
+ }
128
+
129
+
130
+ /**
131
+ * A shared module to create textual spinners
132
+ *
133
+ * Copyright (C) 2010-2011 Nikolay Nemshilov
134
+ */
135
+ var Spinner = new RightJS.Class(RightJS.Element, {
136
+ /**
137
+ * Constructor
138
+ *
139
+ * @param Number optional spinner size (4 by default)
140
+ * @return void
141
+ */
142
+ initialize: function(size) {
143
+ this.$super('div', {'class': 'rui-spinner'});
144
+ this.dots = [];
145
+
146
+ for (var i=0; i < (size || 4); i++) {
147
+ this.dots.push(new RightJS.Element('div'));
148
+ }
149
+
150
+ this.dots[0].addClass('glowing');
151
+ this.insert(this.dots);
152
+ RightJS(this.shift).bind(this).periodical(300);
153
+ },
154
+
155
+ /**
156
+ * Shifts the spinner elements
157
+ *
158
+ * @return void
159
+ */
160
+ shift: function() {
161
+ if (this.visible()) {
162
+ var dot = this.dots.pop();
163
+ this.dots.unshift(dot);
164
+ this.insert(dot, 'top');
165
+ }
166
+ }
167
+ });
168
+
169
+
170
+ /**
171
+ * The lightbox widget
172
+ *
173
+ * Copyright (C) 2009-2011 Nikolay Nemshilov
174
+ */
175
+ var Lightbox = new Widget({
176
+
177
+ extend: {
178
+ version: '2.2.0',
179
+
180
+ EVENTS: $w('show hide load'),
181
+
182
+ Options: {
183
+ fxName: 'fade',
184
+ fxDuration: 300,
185
+
186
+ group: null, // a group marker
187
+
188
+ hideOnEsc: true,
189
+ hideOnOutClick: true,
190
+ showCloseButton: true,
191
+
192
+ cssRule: "a[data-lightbox]", // all lightbox links css-rule
193
+
194
+ // video links default size
195
+ mediaWidth: 425,
196
+ mediaHeight: 350
197
+ },
198
+
199
+ i18n: {
200
+ Close: 'Close',
201
+ Prev: 'Previous Image',
202
+ Next: 'Next Image'
203
+ },
204
+
205
+ // the supported image-urls regexp
206
+ Images: /\.(jpg|jpeg|gif|png|bmp)/,
207
+
208
+ // media content sources
209
+ Medias: [
210
+ [/(http:\/\/.*?youtube\.[a-z]+)\/watch\?v=([^&]+)/, '$1/v/$2', 'swf'],
211
+ [/(http:\/\/video.google.com)\/videoplay\?docid=([^&]+)/, '$1/googleplayer.swf?docId=$2', 'swf'],
212
+ [/(http:\/\/vimeo\.[a-z]+)\/([0-9]+).*?/, '$1/moogaloop.swf?clip_id=$2', 'swf']
213
+ ]
214
+ },
215
+
216
+ /**
217
+ * basic constructor
218
+ *
219
+ * @param Object options override
220
+ * @param Element optional options holder
221
+ * @return void
222
+ */
223
+ initialize: function(options, context) {
224
+ this
225
+ .$super('lightbox', {})
226
+ .setOptions(options, context)
227
+ .insert([
228
+ this.locker = new Locker(this.options),
229
+ this.dialog = new Dialog(this.options)
230
+ ])
231
+ .on({
232
+ close: this._close,
233
+ next: this._next,
234
+ prev: this._prev
235
+ });
236
+ },
237
+
238
+ /**
239
+ * Extracting the rel="lightboux[groupname]" attributes
240
+ *
241
+ * @param Object options
242
+ * @param Element link with options
243
+ * @return Dialog this
244
+ */
245
+ setOptions: function(options, context) {
246
+ this.$super(options, context);
247
+
248
+ if (context) {
249
+ var rel = context.get('rel');
250
+ if (rel && (rel = rel.match(/lightbox\[(.+?)\]/))) {
251
+ this.options.group = rel[1];
252
+ }
253
+ }
254
+
255
+ return this;
256
+ },
257
+
258
+ /**
259
+ * Sets the popup's title
260
+ *
261
+ * @param mixed string or element or somethin'
262
+ * @return Lighbox self
263
+ */
264
+ setTitle: function(text) {
265
+ this.dialog.setTitle(text);
266
+
267
+ return this;
268
+ },
269
+
270
+ /**
271
+ * Shows the lightbox
272
+ *
273
+ * @param String/Array... content
274
+ * @return Lightbox this
275
+ */
276
+ show: function(content) {
277
+ return this._showAnd(function() {
278
+ this.dialog.show(content, !content);
279
+ });
280
+ },
281
+
282
+ /**
283
+ * Hides the lightbox
284
+ *
285
+ * @return Lightbox this
286
+ */
287
+ hide: function() {
288
+ Lightbox.current = null;
289
+
290
+ return this.$super(this.options.fxName, {
291
+ duration: this.options.fxDuration/3,
292
+ onFinish: R(function() {
293
+ this.fire('hide');
294
+ this.remove();
295
+ }).bind(this)
296
+ });
297
+ },
298
+
299
+ /**
300
+ * Loads up the data from url or a link
301
+ *
302
+ * @param String address or a link element
303
+ * @param Object Xhr options
304
+ * @return Lightbox this
305
+ */
306
+ load: function(link, options) {
307
+ return this._showAnd(function() {
308
+ this.dialog.load(link, options);
309
+ });
310
+ },
311
+
312
+ /**
313
+ * Resizes the content block to the given size
314
+ *
315
+ * @param Hash size
316
+ * @return Lightbox this
317
+ */
318
+ resize: function(size) {
319
+ this.dialog.resize(size);
320
+ return this;
321
+ },
322
+
323
+ // protected
324
+
325
+ // handles the 'close' event
326
+ _close: function(event) {
327
+ event.stop();
328
+ this.hide();
329
+ },
330
+
331
+ // handles the 'prev' event
332
+ _prev: function(event) {
333
+ event.stop();
334
+ Pager.prev();
335
+ },
336
+
337
+ // handles the 'next' event
338
+ _next: function(event) {
339
+ event.stop();
340
+ Pager.next();
341
+ },
342
+
343
+ // shows the lightbox element and then calls back
344
+ _showAnd: function(callback) {
345
+ if (Lightbox.current !== this) {
346
+ Lightbox.current = this;
347
+
348
+ // hidding all the hanging around lightboxes
349
+ $$('div.rui-lightbox').each('remove');
350
+
351
+ this.insertTo(document.body);
352
+ this.dialog.show('', true);
353
+
354
+ if (Browser.OLD) { // IE's get screwed by the transparency tricks
355
+ this.reposition();
356
+ Element.prototype.show.call(this);
357
+ callback.call(this);
358
+ } else {
359
+ this.setStyle('display:none');
360
+ Element.prototype.show.call(this, this.options.fxName, {
361
+ duration: this.options.fxDuration/2,
362
+ onFinish: R(function() {
363
+ callback.call(this);
364
+ this.fire('show');
365
+ }).bind(this)
366
+ });
367
+ }
368
+ } else {
369
+ callback.call(this);
370
+ }
371
+
372
+ return this;
373
+ },
374
+
375
+ // manually repositioning under IE6 browser
376
+ reposition: function() {
377
+ if (Browser.IE6) {
378
+ var win = $(window);
379
+
380
+ this.setStyle({
381
+ top: win.scrolls().y + 'px',
382
+ width: win.size().x + 'px',
383
+ height: win.size().y + 'px',
384
+ position: "absolute"
385
+ });
386
+ }
387
+ }
388
+ });
389
+
390
+
391
+ /**
392
+ * The class level interface
393
+ *
394
+ * @copyright (C) 2009 Nikolay Nemshilov
395
+ */
396
+ Lightbox.extend({
397
+ hide: function() {
398
+ if (Lightbox.current) {
399
+ Lightbox.current.hide();
400
+ }
401
+ },
402
+
403
+ show: function() {
404
+ return this.inst('show', arguments);
405
+ },
406
+
407
+ load: function() {
408
+ return this.inst('load', arguments);
409
+ },
410
+
411
+ // private
412
+
413
+ inst: function(name, args) {
414
+ var inst = new Lightbox();
415
+ return inst[name].apply(inst, args);
416
+ }
417
+ });
418
+
419
+
420
+ /**
421
+ * Lightbox background locker element
422
+ *
423
+ * Copyright (C) 2010-2011 Nikolay Nemshilov
424
+ */
425
+ var Locker = new Class(Element, {
426
+ initialize: function(options) {
427
+ this.$super('div', {'class': 'rui-lightbox-locker'});
428
+
429
+ if (options.hideOnOutClick) {
430
+ this.onClick('fire', 'close');
431
+ }
432
+ }
433
+ });
434
+
435
+
436
+ /**
437
+ * The dialog element wrapper
438
+ *
439
+ * Copyright (C) 2010-2011 Nikolay Nemshilov
440
+ */
441
+ var Dialog = new Class(Element, {
442
+ /**
443
+ * Constructor
444
+ *
445
+ * @param Object options
446
+ * @return void
447
+ */
448
+ initialize: function(options) {
449
+ var i18n = Lightbox.i18n;
450
+
451
+ this.options = options;
452
+ this.$super('div', {'class': 'rui-lightbox-dialog'});
453
+
454
+ // building up the
455
+ this.insert([
456
+ this.title = $E('div', {'class': 'rui-lightbox-title'}),
457
+
458
+ $E('div', {'class': 'rui-lightbox-body'}).insert(
459
+ $E('div', {'class': 'rui-lightbox-body-inner'}).insert([
460
+ this.locker = $E('div', {'class': 'rui-lightbox-body-locker'}).insert(new Spinner(4)),
461
+ this.scroller = $E('div', {'class': 'rui-lightbox-scroller'}).insert(
462
+ this.content = $E('div', {'class': 'rui-lightbox-content'})
463
+ )
464
+ ])
465
+ ),
466
+
467
+ $E('div', {'class': 'rui-lightbox-navigation'}).insert([
468
+ this.closeButton = $E('div', {'class': 'close', html: '&times;', title: i18n.Close}).onClick('fire', 'close'),
469
+ this.prevLink = $E('div', {'class': 'prev', html: '&larr;', title: i18n.Prev}).onClick('fire', 'prev'),
470
+ this.nextLink = $E('div', {'class': 'next', html: '&rarr;', title: i18n.Next}).onClick('fire', 'next')
471
+ ])
472
+ ]);
473
+
474
+ // presetting the navigation state
475
+ this.prevLink.hide();
476
+ this.nextLink.hide();
477
+
478
+ if (!options.showCloseButton) {
479
+ this.closeButton.hide();
480
+ }
481
+ },
482
+
483
+ /**
484
+ * Sets the dialogue caption
485
+ *
486
+ * @param String title
487
+ * @return Dialog this
488
+ */
489
+ setTitle: function(title) {
490
+ this.title.update(title||'');
491
+ },
492
+
493
+ /**
494
+ * Nicely resize the dialog box
495
+ *
496
+ * @param Object the end size
497
+ * @param Boolean use fx (false by default)
498
+ * @return Dialog this
499
+ */
500
+ resize: function(end_size, with_fx) {
501
+ var win_size = this.parent().size(),
502
+ cur_size = this.scroller.size(),
503
+ cur_top = (win_size.y - this.size().y)/2,
504
+ dlg_diff = this.size().x - cur_size.x; // <- use for IE6 fixes
505
+
506
+ if (end_size) {
507
+ // getting the actual end-size
508
+ end_size = this.scroller.setStyle(end_size).size();
509
+
510
+ this.scroller.setStyle({
511
+ width: cur_size.x + 'px',
512
+ height: cur_size.y + 'px'
513
+ });
514
+ } else {
515
+ // using the content block size
516
+ end_size = this.content.size();
517
+ }
518
+
519
+ // checking the constraints
520
+ var threshold = 100; // px
521
+ if ((end_size.x + threshold) > win_size.x) { end_size.x = win_size.x - threshold; }
522
+ if ((end_size.y + threshold) > win_size.y) { end_size.y = win_size.y - threshold; }
523
+
524
+ // the actual resize and reposition
525
+ var end_top = (cur_top * 2 + cur_size.y - end_size.y) / 2;
526
+ var dialog = this._.style, content = this.scroller._.style;
527
+
528
+ if (RightJS.Fx && with_fx && (end_size.x != cur_size.x || end_size.y != cur_size.y)) {
529
+
530
+ $ext(new RightJS.Fx(this, {duration: this.options.fxDuration}), {
531
+ render: function(delta) {
532
+ content.width = (cur_size.x + (end_size.x - cur_size.x) * delta) + 'px';
533
+ content.height = (cur_size.y + (end_size.y - cur_size.y) * delta) + 'px';
534
+ dialog.top = (cur_top + (end_top - cur_top) * delta) + 'px';
535
+
536
+ if (Browser.IE6) {
537
+ dialog.width = (dlg_diff + cur_size.y + (end_size.y - cur_size.y) * delta) + 'px';
538
+ }
539
+ }
540
+ }).onFinish(R(this.unlock).bind(this)).start();
541
+
542
+ } else {
543
+ // no-fx direct assignment
544
+ content.width = end_size.x + 'px';
545
+ content.height = end_size.y + 'px';
546
+ dialog.top = end_top + 'px';
547
+
548
+ if (Browser.IE6) {
549
+ dialog.width = (dlg_diff + end_size.x) + 'px';
550
+ }
551
+
552
+ if (!this.request) { this.unlock(); }
553
+ }
554
+
555
+ return this;
556
+ },
557
+
558
+ /**
559
+ * Shows the content
560
+ *
561
+ * @param mixed content String/Element/Array and so one
562
+ * @return Dialog this
563
+ */
564
+ show: function(content, no_fx) {
565
+ this.content.update(content || '');
566
+ this.resize(null, !no_fx);
567
+ },
568
+
569
+ /**
570
+ * Loads up the data from the link
571
+ *
572
+ * @param mixed String url address or a link element
573
+ * @param Object xhr-options
574
+ * @return void
575
+ */
576
+ load: function(url, options) {
577
+ if (url instanceof Element) {
578
+ this.setTitle(url.get('title'));
579
+ url = url.get('href');
580
+ }
581
+
582
+ Pager.show(this, url);
583
+ this.lock().cancel();
584
+
585
+ // defined in the loader.js file
586
+ this.request = new Loader(url, options, R(function(content, no_fx) {
587
+ this.request = null;
588
+ this.show(content, no_fx);
589
+ }).bind(this));
590
+
591
+ return this.resize(); // the look might be changed for a media-type
592
+ },
593
+
594
+ /**
595
+ * Cancels a currently loading request
596
+ *
597
+ * @return Dialog this
598
+ */
599
+ cancel: function() {
600
+ if (this.request) {
601
+ this.request.cancel();
602
+ }
603
+
604
+ return this;
605
+ },
606
+
607
+ /**
608
+ * Shows the loading lock
609
+ *
610
+ * @return Dialog this
611
+ */
612
+ lock: function() {
613
+ this.locker.setStyle('opacity:1;display:block').insertTo(this.scroller, 'before');
614
+ return this;
615
+ },
616
+
617
+ /**
618
+ * Hides the loading lock
619
+ *
620
+ * @return Dialog this
621
+ */
622
+ unlock: function() {
623
+ this.locker.remove(R(this.content.html()).blank() ? null : 'fade', {
624
+ duration: this.options.fxDuration * 2/3
625
+ });
626
+
627
+ return this;
628
+ }
629
+ });
630
+
631
+
632
+ /**
633
+ * Xhr/images/medias loading module
634
+ *
635
+ * Copyright (C) 2009-2010 Nikolay Nemshilov
636
+ */
637
+ var Loader = new Class({
638
+ /**
639
+ * Constructor
640
+ *
641
+ * @param String url address
642
+ * @param Object Xhr options
643
+ * @param Function on-finish callback
644
+ */
645
+ initialize: function(url, options, on_finish) {
646
+ // adjusting the dialog look for different media-types
647
+ if (this.isImage(url, on_finish)) {
648
+ Lightbox.current.addClass('rui-lightbox-image');
649
+ } else if (this.isMedia(url, on_finish)) {
650
+ Lightbox.current.addClass('rui-lightbox-media');
651
+ } else {
652
+ this.xhr = new Xhr(url,
653
+ Object.merge({method: 'get'}, options)
654
+ ).onComplete(function() {
655
+ on_finish(this.text);
656
+ }).send();
657
+ }
658
+ },
659
+
660
+ /**
661
+ * Cancels the request
662
+ *
663
+ * @return Loader this
664
+ */
665
+ cancel: function() {
666
+ if (this.xhr) {
667
+ this.xhr.cancel();
668
+ } else if (this.img) {
669
+ this.img.onload = function() {};
670
+ }
671
+ },
672
+
673
+ // protected
674
+
675
+ // tries to initialize it as an image loading
676
+ isImage: function(url, on_finish) {
677
+ if (url.match(Lightbox.Images)) {
678
+ var img = this.img = $E('img')._;
679
+ img.onload = function() {
680
+ on_finish(img);
681
+ };
682
+ img.src = url;
683
+ return true;
684
+ }
685
+ },
686
+
687
+ // tries to initialize it as a flash-element
688
+ isMedia: function(url, on_finish) {
689
+ var media = R(Lightbox.Medias).map(function(desc) {
690
+ return url.match(desc[0]) ? this.buildEmbed(
691
+ url.replace(desc[0], desc[1]), desc[2]) : null;
692
+ }, this).compact()[0];
693
+
694
+ if (media) {
695
+ on_finish(media, true);
696
+ return true;
697
+ }
698
+ },
699
+
700
+ // builds an embedded media block
701
+ buildEmbed: function(url, type) {
702
+ var media_types = {
703
+ swf: [
704
+ 'D27CDB6E-AE6D-11cf-96B8-444553540000',
705
+ 'http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0',
706
+ 'application/x-shockwave-flash'
707
+ ]
708
+ },
709
+ options = Lightbox.current ? Lightbox.current.options : Lightbox.Options,
710
+ sizes = ' width="'+ options.mediaWidth + '" height="'+ options.mediaHeight + '"';
711
+
712
+ return '<object classid="clsid:' + media_types[type][0] +
713
+ '" codebase="' + media_types[type][1] + '"'+ sizes + '>' +
714
+ '<param name="src" value="'+ url +'" />'+
715
+ '<embed src="'+ url +'" type="'+ media_types[type][2]+'"'+ sizes + ' />' +
716
+ '</object>';
717
+ }
718
+
719
+ });
720
+
721
+
722
+ /**
723
+ * Processes the link-groups showing things in a single Lightbox
724
+ *
725
+ * Copyright (C) 2010 Nikolay Nemshilov
726
+ */
727
+ var Pager = {
728
+ /**
729
+ * Checks and shows the pager links on the dialog
730
+ *
731
+ * @param Dialog dialog
732
+ * @param String url-address
733
+ * @return void
734
+ */
735
+ show: function(dialog, url) {
736
+ if (dialog.options.group) {
737
+ this.dialog = dialog;
738
+ this.links = this.find(dialog.options.group);
739
+ this.link = this.links.first(function(link) {
740
+ return link.get('href') === url;
741
+ });
742
+
743
+ var index = this.links.indexOf(this.link), size = this.links.length;
744
+
745
+ dialog.prevLink[size && index > 0 ? 'show' : 'hide']();
746
+ dialog.nextLink[size && index < size - 1 ? 'show' : 'hide']();
747
+ } else {
748
+ this.dialog = null;
749
+ }
750
+ },
751
+
752
+ /**
753
+ * Shows the prev link
754
+ *
755
+ * @return void
756
+ */
757
+ prev: function() {
758
+ if (this.dialog && !this.timer) {
759
+ var id = this.links.indexOf(this.link),
760
+ link = this.links[id - 1];
761
+
762
+ if (link) {
763
+ this.dialog.load(link);
764
+ this.timeout();
765
+ }
766
+ }
767
+ },
768
+
769
+ /**
770
+ * Shows the next link
771
+ *
772
+ * @return void
773
+ */
774
+ next: function() {
775
+ if (this.dialog && !this.timer) {
776
+ var id = this.links.indexOf(this.link),
777
+ link = this.links[id + 1];
778
+
779
+ if (link) {
780
+ this.dialog.load(link);
781
+ this.timeout();
782
+ }
783
+ }
784
+ },
785
+
786
+ // private
787
+
788
+ // finding the links list
789
+ find: function(group) {
790
+ return $$('a').filter(function(link) {
791
+ var data = link.get('data-lightbox');
792
+ var rel = link.get('rel');
793
+
794
+ return (data && eval("("+ data + ")").group === group) ||
795
+ (rel && rel.indexOf('lightbox['+ group + ']') > -1);
796
+ });
797
+ },
798
+
799
+ // having a little nap to prevent ugly quick scrolling
800
+ timeout: function() {
801
+ this.timer = R(function() {
802
+ Pager.timer = null;
803
+ }).delay(300);
804
+ }
805
+ };
806
+
807
+
808
+ /**
809
+ * document level hooks
810
+ *
811
+ * Copyright (C) 2009-2010 Nikolay Nemshilov
812
+ */
813
+
814
+ $(document).on({
815
+ /**
816
+ * Catches clicks on the target links
817
+ *
818
+ * @param Event click
819
+ * @return void
820
+ */
821
+ click: function(event) {
822
+ var target = event.find(Lightbox.Options.cssRule) || event.find('a[rel^=lightbox]');
823
+
824
+ if (target) {
825
+ event.stop();
826
+ new Lightbox({}, target).load(target);
827
+ }
828
+ },
829
+
830
+ /**
831
+ * Catches the mousewheel event and tries to scroll
832
+ * the list of objects on the lightbox
833
+ *
834
+ * @param Event mousewheel
835
+ * @return void
836
+ */
837
+ mousewheel: function(event) {
838
+ if (Lightbox.current) {
839
+ var target = event.target, box = target.parent('div.rui-lightbox-content');
840
+
841
+ if (!box || target.getStyle('overflow') === 'visible') {
842
+ event.stop();
843
+ }
844
+
845
+ Lightbox.current.fire((event._.detail || -event._.wheelDelta) < 0 ? 'prev' : 'next');
846
+ }
847
+ },
848
+
849
+ /**
850
+ * Handles the navigation form a keyboard
851
+ *
852
+ * @param Event keydown
853
+ * @return void
854
+ */
855
+ keydown: function(event) {
856
+ var lightbox = Lightbox.current, name = ({
857
+ 27: 'close', // Esc
858
+ 33: 'prev', // PageUp
859
+ 37: 'prev', // Left
860
+ 38: 'prev', // Up
861
+ 39: 'next', // Right
862
+ 40: 'next', // Down
863
+ 34: 'next' // PageDown
864
+ })[event.keyCode];
865
+
866
+ if (lightbox && name) {
867
+ if (name !== 'close' || lightbox.options.hideOnEsc) {
868
+ event.stop();
869
+ lightbox.fire(name);
870
+ }
871
+ }
872
+ }
873
+ });
874
+
875
+ $(window).on({
876
+ resize: function() {
877
+ if (Lightbox.current) {
878
+ Lightbox.current.reposition();
879
+ Lightbox.current.dialog.resize();
880
+ }
881
+ },
882
+
883
+ scroll: function(event) {
884
+ if (Lightbox.current && Browser.IE6) {
885
+ Lightbox.current.reposition();
886
+ }
887
+ }
888
+ });
889
+ (function() {
890
+ var style = document.createElement('style'),
891
+ rules = document.createTextNode("div.rui-spinner,div.rui-spinner div{margin:0;padding:0;border:none;background:none;list-style:none;font-weight:normal;float:none;display:inline-block; *display:inline; *zoom:1;border-radius:.12em;-moz-border-radius:.12em;-webkit-border-radius:.12em}div.rui-spinner{text-align:center;white-space:nowrap;background:#EEE;border:1px solid #DDD;height:1.2em;padding:0 .2em}div.rui-spinner div{width:.4em;height:70%;background:#BBB;margin-left:1px}div.rui-spinner div:first-child{margin-left:0}div.rui-spinner div.glowing{background:#777}div.rui-lightbox{position:fixed;top:0;left:0;float:none;width:100%;height:100%;margin:0;padding:0;background:none;border:none;text-align:center;z-index:9999;z-index/*\\**/:auto\\9;}div.rui-lightbox-locker{position:absolute;top:0px;left:0px;width:100%;height:100%;background-color:#000;opacity:0.8;filter:alpha(opacity=80);cursor:default;z-index/*\\**/:9990\\9;}div.rui-lightbox-dialog{display:inline-block; *display:inline; *zoom:1;position:relative;text-align:left;z-index/*\\**/:9999\\9;}div.rui-lightbox-title{height:1.2em;margin-bottom:.1em;white-space:nowrap;color:#DDD;font-weight:bold;font-size:1.6em;font-family:Helvetica}div.rui-lightbox-body{background-color:#FFF;padding:1em;border-radius:.5em;-moz-border-radius:.5em;-webkit-border-radius:.5em}div.rui-lightbox-body-inner{position:relative}div.rui-lightbox-scroller{overflow:hidden}div.rui-lightbox-content{display:inline-block; *display:inline; *zoom:1;min-height:10em;min-width:10em;_height:10em;_width:10em}div.rui-lightbox-body-locker{background-color:white;position:absolute;left:0px;top:0px;width:100%;height:100%;opacity:0;filter:alpha(opacity=0)}div.rui-lightbox-body-locker div.rui-spinner{position:absolute;right:0;bottom:0;border:none;background:none;font-size:150%}div.rui-lightbox-navigation{color:#888;font-size:160%;font-family:Arial;height:1em;user-select:none;-moz-user-select:none;-webkit-user-select:none}div.rui-lightbox-navigation div{cursor:pointer;position:absolute}div.rui-lightbox-navigation div:hover{color:white}div.rui-lightbox-navigation div.next{left:2em}div.rui-lightbox-navigation div.close{right:0}div.rui-lightbox-image div.rui-lightbox-body,div.rui-lightbox-media div.rui-lightbox-body{padding:0;border:1px solid #777;border-radius:0px;-moz-border-radius:0px;-webkit-border-radius:0px}div.rui-lightbox-image div.rui-lightbox-content,div.rui-lightbox-media div.rui-lightbox-content{min-height:12em;min-width:12em;_height:12em;_width:12em}div.rui-lightbox-image div.rui-lightbox-content img{vertical-align:middle}div.rui-lightbox-image div.rui-lightbox-body,div.rui-lightbox-image div.rui-lightbox-body-locker,div.rui-lightbox-media div.rui-lightbox-body,div.rui-lightbox-media div.rui-lightbox-body-locker{background-color:#D8D8D8}div.rui-lightbox-image div.rui-lightbox-body-locker div.rui-spinner,div.rui-lightbox-media div.rui-lightbox-body-locker div.rui-spinner{bottom:.5em;right:.5em}");
892
+
893
+ style.type = 'text/css';
894
+
895
+ if(style.styleSheet) {
896
+ style.styleSheet.cssText = rules.nodeValue;
897
+ } else {
898
+ style.appendChild(rules);
899
+ }
900
+
901
+ document.getElementsByTagName('head')[0].appendChild(style);
902
+ })();
903
+
904
+ return Lightbox;
905
+ })(document, RightJS);