right-rails 1.2.1 → 1.2.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (79) hide show
  1. data/CHANGELOG +4 -0
  2. data/README.rdoc +10 -18
  3. data/Rakefile +2 -2
  4. data/init.rb +9 -2
  5. data/lib/right_rails.rb +1 -1
  6. data/vendor/assets/images/rightjs-ui/colorpicker.png +0 -0
  7. data/vendor/assets/images/rightjs-ui/resizable.png +0 -0
  8. data/vendor/assets/images/rightjs-ui/rte.png +0 -0
  9. data/vendor/assets/javascripts/right-olds-src.js +652 -0
  10. data/vendor/assets/javascripts/right-olds.js +9 -0
  11. data/vendor/assets/javascripts/right-safe-src.js +68 -0
  12. data/vendor/assets/javascripts/right-safe.js +7 -0
  13. data/vendor/assets/javascripts/right-src.js +6014 -0
  14. data/vendor/assets/javascripts/right.js +7 -0
  15. data/vendor/assets/javascripts/right/autocompleter-src.js +625 -0
  16. data/vendor/assets/javascripts/right/autocompleter.js +7 -0
  17. data/vendor/assets/javascripts/right/billboard-src.js +564 -0
  18. data/vendor/assets/javascripts/right/billboard.js +7 -0
  19. data/vendor/assets/javascripts/right/calendar-src.js +1464 -0
  20. data/vendor/assets/javascripts/right/calendar.js +7 -0
  21. data/vendor/assets/javascripts/right/casting-src.js +183 -0
  22. data/vendor/assets/javascripts/right/casting.js +7 -0
  23. data/vendor/assets/javascripts/right/colorpicker-src.js +981 -0
  24. data/vendor/assets/javascripts/right/colorpicker.js +7 -0
  25. data/vendor/assets/javascripts/right/dialog-src.js +768 -0
  26. data/vendor/assets/javascripts/right/dialog.js +7 -0
  27. data/vendor/assets/javascripts/right/dnd-src.js +591 -0
  28. data/vendor/assets/javascripts/right/dnd.js +7 -0
  29. data/vendor/assets/javascripts/right/effects-src.js +508 -0
  30. data/vendor/assets/javascripts/right/effects.js +7 -0
  31. data/vendor/assets/javascripts/right/i18n/de.js +95 -0
  32. data/vendor/assets/javascripts/right/i18n/en-us.js +11 -0
  33. data/vendor/assets/javascripts/right/i18n/es.js +95 -0
  34. data/vendor/assets/javascripts/right/i18n/fi.js +96 -0
  35. data/vendor/assets/javascripts/right/i18n/fr.js +95 -0
  36. data/vendor/assets/javascripts/right/i18n/hu.js +100 -0
  37. data/vendor/assets/javascripts/right/i18n/it.js +95 -0
  38. data/vendor/assets/javascripts/right/i18n/jp.js +99 -0
  39. data/vendor/assets/javascripts/right/i18n/nl.js +95 -0
  40. data/vendor/assets/javascripts/right/i18n/pt-br.js +95 -0
  41. data/vendor/assets/javascripts/right/i18n/ru.js +95 -0
  42. data/vendor/assets/javascripts/right/i18n/ua.js +99 -0
  43. data/vendor/assets/javascripts/right/in-edit-src.js +373 -0
  44. data/vendor/assets/javascripts/right/in-edit.js +7 -0
  45. data/vendor/assets/javascripts/right/jquerysh-src.js +362 -0
  46. data/vendor/assets/javascripts/right/jquerysh.js +7 -0
  47. data/vendor/assets/javascripts/right/json-src.js +147 -0
  48. data/vendor/assets/javascripts/right/json.js +7 -0
  49. data/vendor/assets/javascripts/right/keys-src.js +87 -0
  50. data/vendor/assets/javascripts/right/keys.js +7 -0
  51. data/vendor/assets/javascripts/right/lightbox-src.js +931 -0
  52. data/vendor/assets/javascripts/right/lightbox.js +7 -0
  53. data/vendor/assets/javascripts/right/rails-src.js +402 -0
  54. data/vendor/assets/javascripts/right/rails.js +7 -0
  55. data/vendor/assets/javascripts/right/rater-src.js +384 -0
  56. data/vendor/assets/javascripts/right/rater.js +7 -0
  57. data/vendor/assets/javascripts/right/resizable-src.js +465 -0
  58. data/vendor/assets/javascripts/right/resizable.js +7 -0
  59. data/vendor/assets/javascripts/right/rte-src.js +2685 -0
  60. data/vendor/assets/javascripts/right/rte.js +7 -0
  61. data/vendor/assets/javascripts/right/selectable-src.js +725 -0
  62. data/vendor/assets/javascripts/right/selectable.js +7 -0
  63. data/vendor/assets/javascripts/right/sizzle-src.js +1132 -0
  64. data/vendor/assets/javascripts/right/sizzle.js +7 -0
  65. data/vendor/assets/javascripts/right/slider-src.js +395 -0
  66. data/vendor/assets/javascripts/right/slider.js +7 -0
  67. data/vendor/assets/javascripts/right/sortable-src.js +430 -0
  68. data/vendor/assets/javascripts/right/sortable.js +7 -0
  69. data/vendor/assets/javascripts/right/table-src.js +176 -0
  70. data/vendor/assets/javascripts/right/table.js +7 -0
  71. data/vendor/assets/javascripts/right/tabs-src.js +1157 -0
  72. data/vendor/assets/javascripts/right/tabs.js +7 -0
  73. data/vendor/assets/javascripts/right/tags-src.js +745 -0
  74. data/vendor/assets/javascripts/right/tags.js +7 -0
  75. data/vendor/assets/javascripts/right/tooltips-src.js +331 -0
  76. data/vendor/assets/javascripts/right/tooltips.js +7 -0
  77. data/vendor/assets/javascripts/right/uploader-src.js +302 -0
  78. data/vendor/assets/javascripts/right/uploader.js +7 -0
  79. metadata +78 -14
@@ -0,0 +1,7 @@
1
+ /**
2
+ * RightJS-UI Calendar v2.2.0
3
+ * http://rightjs.org/ui/calendar
4
+ *
5
+ * Copyright (C) 2009-2011 Nikolay Nemshilov
6
+ */
7
+ var Calendar=RightJS.Calendar=function(a,b,c){function j(a){return(a<10?"0":"")+a}function h(a,d,e){var f=this.reAnchor||(this.reAnchor=new c.Element("div",{"class":"rui-re-anchor"})).insert(this),g=f.insertTo(a,"after").position(),h=a.dimensions(),i=this,j=b(a.getStyle("borderTopWidth")),k=b(a.getStyle("borderLeftWidth")),l=b(a.getStyle("borderRightWidth")),m=b(a.getStyle("borderBottomWidth")),n=h.top-g.y+j,o=h.left-g.x+k,p=h.width-k-l,q=h.height-j-m;i.setStyle("visibility:hidden").show(null),d==="right"?o+=p-i.size().x:n+=q,i.moveTo(o,n),e&&(d==="left"||d==="right"?i.setHeight(q):i.setWidth(p)),i.setStyle("visibility:visible").hide(null)}function g(a,b,d,e){c.Fx&&(d===undefined&&(d=a.options.fxName,e===undefined&&(e={duration:a.options.fxDuration,onFinish:c(a.fire).bind(a,b)},b==="hide"&&(e.duration=(c.Fx.Durations[e.duration]||e.duration)/2)))),(!c.Fx||!d)&&a.fire(b);return a.$super(d,e)}function d(a,b){b||(b=a,a="DIV");var d=new c.Class(c.Element.Wrappers[a]||c.Element,{initialize:function(b,d){this.key=b;var e=[{"class":"rui-"+b}];this instanceof c.Input||this instanceof c.Form||e.unshift(a),this.$super.apply(this,e),c.isString(d)&&(d=c.$(d)),d instanceof c.Element&&(this._=d._,"$listeners"in d&&(d.$listeners=d.$listeners),d={}),this.setOptions(d,this);return c.Wrapper.Cache[c.$uid(this._)]=this},setOptions:function(a,b){b&&(a=c.Object.merge(a,(new Function("return "+(b.get("data-"+this.key)||"{}")))())),a&&c.Options.setOptions.call(this,c.Object.merge(this.options,a));return this}}),e=new c.Class(d,b);c.Observer.createShortcuts(e.prototype,e.EVENTS||c([]));return e}var e=new c.Class(c.Element,{initialize:function(a,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}}),f={show:function(a,b){this.constructor.current=this;return g(this,"show",a,b)},hide:function(a,b){this.constructor.current=null;return g(this,"show",a,b)},showAt:function(a,b,d){this.hide(null).shownAt=a=c.$(a),h.call(this,a,b,d);return this.show()},toggleAt:function(a,b,c){return this.hidden()?this.showAt(a,b,c):this.hide()}},i={assignTo:function(a,b){a=c.$(a),b=c.$(b),b?(b[this.key]=this,b.assignedInput=a):a[this.key]=this;var d=c(function(){this.visible()&&(!this.showAt||this.shownAt===a)&&this.setValue(a.value())}).bind(this);a.on({keyup:d,change:d}),this.onChange(function(){(!this.showAt||this.shownAt===a)&&a.setValue(this.getValue())});return this}},k=c,l=c.$,m=c.$$,n=c.$w,o=c.$ext,p=c.$uid,q=c.isString,r=c.isArray,s=c.isFunction,t=c.Class,u=c.Element,v=c.Input,w=c.RegExp,x=c.Browser,y=new d({include:[f,i],extend:{version:"2.2.0",EVENTS:n("show hide change done"),Options:{format:"ISO",showTime:null,showButtons:!1,minDate:!1,maxDate:!1,fxName:"fade",fxDuration:"short",firstDay:1,numberOfMonths:1,timePeriod:1,twentyFourHour:null,listYears:!1,hideOnPick:!1,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:n("Sunday Monday Tuesday Wednesday Thursday Friday Saturday"),dayNamesShort:n("Sun Mon Tue Wed Thu Fri Sat"),dayNamesMin:n("Su Mo Tu We Th Fr Sa"),monthNames:n("January February March April May June July August September October November December"),monthNamesShort:n("Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec")},current:null,hideAll:function(a){m("div.rui-calendar").each(function(b){b instanceof y&&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 z(a),this.greed=new B(a)]),a.showTime&&this.insert(this.timepicker=new C(a)),a.showButtons&&this.insert(this.buttons=new D(a)),this.setDate(new Date).initEvents()},setDate:function(a,b){if(a=this.parse(a)){var c=this.options;c.minDate&&c.minDate>a&&(a=new Date(c.minDate)),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),(c.minDate||c.maxDate)&&this.swaps.setDate(a),this.timepicker&&!b&&this.timepicker.setDate(a),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)},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,l(a.trigger||a.update));var b=this.constructor,c=this.options;c.i18n={};for(var d in b.i18n)c.i18n[d]=r(b.i18n[d])?b.i18n[d].clone():b.i18n[d];o(c.i18n,a.i18n),c.dayNames=c.i18n.dayNamesMin,c.firstDay&&c.dayNames.push(c.dayNames.shift()),r(c.numberOfMonths)||(c.numberOfMonths=[c.numberOfMonths,1]),c.minDate&&(c.minDate=this.parse(c.minDate)),c.maxDate&&(c.maxDate=this.parse(c.maxDate),c.maxDate.setDate(c.maxDate.getDate()+1)),c.format=k(b.Formats[c.format]||c.format).trim(),c.showTime===null&&(c.showTime=c.format.search(/%[HkIl]/)>-1),c.twentyFourHour===null&&(c.twentyFourHour=c.format.search(/%[Il]/)<0),c.timePeriod>60&&12%Math.ceil(c.timePeriod/60)&&(c.twentyFourHour=!0),c.update&&this.assignTo(c.update,c.trigger);return this},hideOthers:function(){y.hideAll(this);return this}}),z=new t(u,{initialize:function(a){this.$super("div",{"class":"swaps"}),this.options=a;var b=a.i18n;this.insert([this.prevMonth=new e("&lsaquo;",{title:b.PrevMonth,"class":"prev-month"}),this.nextMonth=new e("&rsaquo;",{title:b.NextMonth,"class":"next-month"})]),a.listYears&&this.insert([this.prevYear=new e("&laquo;",{title:b.PrevYear,"class":"prev-year"}),this.nextYear=new e("&raquo;",{title:b.NextYear,"class":"next-year"})]),this.buttons=k([this.prevMonth,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],d=!0,e=!0,f=!0,g=!0;if(b.minDate){var h=new Date(a.getFullYear(),0,1,0,0,0),i=new Date(b.minDate.getFullYear(),0,1,0,0,0);d=h>i,h.setMonth(a.getMonth()-Math.ceil(c-c/2)),i.setMonth(b.minDate.getMonth()),f=h>=i}if(b.maxDate){var j=new Date(a),l=new Date(b.maxDate),m=k([j,l]);m.each(function(a){a.setDate(32),a.setMonth(a.getMonth()-1),a.setDate(32-a.getDate()),a.setHours(0),a.setMinutes(0),a.setSeconds(0),a.setMilliseconds(0)}),g=j<l,m.each("setMonth",0),e=j<l}this.nextMonth[g?"enable":"disable"](),this.prevMonth[f?"enable":"disable"](),this.nextYear&&(this.nextYear[e?"enable":"disable"](),this.prevYear[d?"enable":"disable"]())},clicked:function(a){var b=a.target;b&&this.buttons.include(b)&&(b.enabled()&&this.fire(b.get("className").split(/\s+/)[0]))}}),A=new t(u,{initialize:function(a){this.$super("table",{"class":"month"}),this.options=a,this.insert(this.caption=new u("caption")),this.insert("<thead><tr>"+a.dayNames.map(function(a){return"<th>"+a+"</th>"}).join("")+"</tr></thead>"),this.days=[];var b=(new u("tbody")).insertTo(this),c,d,e;for(d=0;d<6;d++){e=(new u("tr")).insertTo(b);for(c=0;c<7;c++)this.days.push((new u("td")).insertTo(e))}this.onClick(this.clicked)},setDate:function(b,c){b.setDate(32);var d=32-b.getDate();b.setMonth(b.getMonth()-1);var e=Math.ceil(c.getTime()/864e5),f=this.options,g=f.i18n,h=this.days;for(var i=0,j=h.length-1,k,l,m;i<7;i++)k=h[i]._,l=h[j-i]._,m=h[j-i-7]._,k.innerHTML=l.innerHTML=m.innerHTML="",k.className=l.className=m.className="blank";for(var i=1,n=0,o,p;i<=d;i++){b.setDate(i);var q=b.getDay();f.firstDay===1&&(q=q>0?q-1:6);if(i===1||q===0)o=h.slice(n*7,n*7+7),n++;p=o[q]._,x.OLD?(p.innerHTML="",p.appendChild(a.createTextNode(i))):p.innerHTML=""+i,p.className=e===Math.ceil(b.getTime()/864e5)?"selected":"";if(f.minDate&&f.minDate>b||f.maxDate&&f.maxDate<b)p.className="disabled";o[q].date=new Date(b)}var r=(f.listYears?g.monthNamesShort[b.getMonth()]+",":g.monthNames[b.getMonth()])+" "+b.getFullYear(),s=this.caption._;x.OLD?(s.innerHTML="",s.appendChild(a.createTextNode(r))):s.innerHTML=r},clicked:function(a){var b=a.target,c=b.date;b&&c&&!b.hasClass("disabled")&&!b.hasClass("blank")&&(b.addClass("selected"),this.fire("date-set",{date:c.getDate(),month:c.getMonth(),year:c.getFullYear()}))}}),B=new t(u,{initialize:function(a){this.$super("table",{"class":"greed"}),this.months=[];var b=(new u("tbody")).insertTo(this),c;for(var d=0;d<a.numberOfMonths[1];d++){var e=(new u("tr")).insertTo(b);for(var f=0;f<a.numberOfMonths[0];f++)this.months.push(c=new A(a)),(new u("td")).insertTo(e).insert(c)}},setDate:function(a,b){var c=this.months,d=c.length;b=b||a;for(var e=-Math.ceil(d-d/2)+1,f=0;e<Math.floor(d-d/2)+1;e++,f++){var g=new Date(a);g.setMonth(a.getMonth()+e),c[f].setDate(g,b)}}}),C=new t(u,{initialize:function(a){this.$super("div",{"class":"timepicker"}),this.options=a;var b=k(this.timeChanged).bind(this);this.insert([this.hours=(new u("select")).onChange(b),this.minutes=(new u("select")).onChange(b)]);var c=a.timePeriod<60?a.timePeriod:60,d=a.timePeriod<60?1:Math.ceil(a.timePeriod/60);for(var e=0;e<60;e++){var f=j(e);e<24&&e%d==0&&(a.twentyFourHour?this.hours.insert(new u("option",{value:e,html:f})):e<12&&this.hours.insert(new u("option",{value:e,html:e==0?12:e}))),e%c==0&&this.minutes.insert(new u("option",{value:e,html:f}))}a.twentyFourHour||(this.meridian=(new u("select")).onChange(b).insertTo(this),k(k(a.format).includes(/%P/)?["am","pm"]:["AM","PM"]).each(function(a){this.meridian.insert(new u("option",{value:a.toLowerCase(),html:a}))},this))},setDate:function(a){var b=this.options,c=b.timePeriod<60?a.getHours():Math.round(a.getHours()/(b.timePeriod/60))*(b.timePeriod/60),d=Math.round(a.getMinutes()/(b.timePeriod%60))*b.timePeriod;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(d)},timeChanged:function(a){a.stopPropagation();var c=b(this.hours.value()),d=b(this.minutes.value());this.meridian&&(c==12&&(c=0),this.meridian.value()=="pm"&&(c+=12)),this.fire("time-set",{hours:c,minutes:d})}}),D=new t(u,{initialize:function(a){this.$super("div",{"class":"buttons"}),this.insert([(new e(a.i18n.Now,{"class":"now"})).onClick("fire","now-clicked"),(new e(a.i18n.Done,{"class":"done"})).onClick("fire","done-clicked")])}});y.include({parse:function(a){var c;if(q(a)&&a){var d=w.escape(this.options.format),e=k(d.match(/%[a-z]/ig)).map("match",/[a-z]$/i).map("first").without("%"),f=new w("^"+d.replace(/%p/i,"(pm|PM|am|AM)").replace(/(%[a-z])/ig,"(.+?)")+"$"),g=k(a).trim().match(f);if(g){g.shift();var h=null,i=null,j=null,l=null,m=null,n;while(g.length){var o=g.shift(),p=e.shift();if(p.toLowerCase()=="b")i=this.options.i18n[p=="b"?"monthNamesShort":"monthNames"].indexOf(o);else if(p.toLowerCase()=="p")n=o.toLowerCase();else{o=b(o,10);switch(p){case"d":case"e":c=o;break;case"m":i=o-1;break;case"y":case"Y":h=o;break;case"H":case"k":case"I":case"l":j=o;break;case"M":l=o;break;case"S":m=o}}}n&&(j=j==12?0:j,j=n=="pm"?j+12:j),c=new Date(h,i,c,j,l,m)}}else if(a instanceof Date||Date.parse(a))c=new Date(a);return!c||isNaN(c.getTime())?null:c},format:function(a){var b=this.options.i18n,c=this.date.getDay(),d=this.date.getMonth(),e=this.date.getDate(),f=this.date.getFullYear(),g=this.date.getHours(),h=this.date.getMinutes(),i=this.date.getSeconds(),k=g==0?12:g<13?g:g-12,l={a:b.dayNamesShort[c],A:b.dayNames[c],b:b.monthNamesShort[d],B:b.monthNames[d],d:j(e),e:""+e,m:(d<9?"0":"")+(d+1),y:(""+f).substring(2,4),Y:""+f,H:j(g),k:""+g,I:(g>0&&(g<10||g>12&&g<22)?"0":"")+k,l:""+k,p:g<12?"AM":"PM",P:g<12?"am":"pm",M:j(h),S:j(i),"%":"%"},m=a||this.options.format;for(var n in l)m=m.replace("%"+n,l[n]);return m}}),y.include({initEvents:function(){var a="_shiftDate",b=this._terminate;this.on({"prev-day":[a,{Date:-1}],"next-day":[a,{Date:1}],"prev-week":[a,{Date:-7}],"next-week":[a,{Date:7}],"prev-month":[a,{Month:-1}],"next-month":[a,{Month:1}],"prev-year":[a,{FullYear:-1}],"next-year":[a,{FullYear:1}],"date-set":this._changeDate,"time-set":this._changeTime,"now-clicked":this._setNow,"done-clicked":this.done,click:b,mousedown:b,focus:b,blur:b})},_shiftDate:function(a){var b=new Date(this.date),c=this.options;for(var d in a)b["set"+d](b["get"+d]()+a[d]);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,!0),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(),this._hide_delay&&(this._hide_delay.cancel(),this._hide_delay=null)}}),l(a).on({focus:function(a){var b=a.target instanceof v&&a.target.get("type")=="text"?a.target:null;y.hideAll(),b&&(b.calendar||b.match(y.Options.cssRule))&&(b.calendar||new y({update:b})).setValue(b.value()).showAt(b)},blur:function(a){var b=a.target,c=b.calendar;c&&(c._hide_delay=k(function(){c.hide()}).delay(200))},click:function(a){var b=a.target instanceof u?a.target:null;if(b&&(b.calendar||b.match(y.Options.cssRule))){if(!(b instanceof v)||b.get("type")!="text")a.stop(),(b.calendar||new y({trigger:b})).hide(null).toggleAt(b.assignedInput)}else a.find("div.rui-calendar")||y.hideAll()},keydown:function(a){var b=y.current,c=({27:"hide",37:"prev-day",39:"next-day",38:"prev-week",40:"next-week",33:"prev-month",34:"next-month",13:"done"})[a.keyCode];c&&b&&b.visible()&&(a.stop(),s(b[c])?b[c]():b.fire(c))}});var E=a.createElement("style"),F=a.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}");E.type="text/css",a.getElementsByTagName("head")[0].appendChild(E),E.styleSheet?E.styleSheet.cssText=F.nodeValue:E.appendChild(F);return y}(document,parseInt,RightJS)
@@ -0,0 +1,183 @@
1
+ /**
2
+ * Dynamic Elements Casting v2.2.0
3
+ * http://rightjs.org/plugins/casting
4
+ *
5
+ * Copyright (C) 2010-2011 Nikolay Nemshilov
6
+ */
7
+ (function(RightJS) {
8
+ /**
9
+ * Casting plugin initialization script
10
+ *
11
+ * Copyright (C) 2010-2011 Nikolay Nemshilov
12
+ */
13
+
14
+ RightJS.Casting = {
15
+ version: '2.2.0'
16
+ };
17
+
18
+
19
+
20
+ /**
21
+ * Advanced Elements typecasting feature.
22
+ * Basically it allows you to handle all sorts of css-rules with dom-wrappers
23
+ *
24
+ * USAGE:
25
+ *
26
+ * var MyClass = Element.Wrappers.add('div#boo', new Class(Element, {
27
+ * // some methods in here
28
+ * }));
29
+ * var MyClass = Element.Wrappers.add('div.hoo', new Class(Input, {
30
+ * // some methods in here
31
+ * }));
32
+ *
33
+ * Element.Wrappers.remove('div#boo');
34
+ * Element.Wrappers.remove(MyClass);
35
+ *
36
+ *
37
+ * Copyright (C) 2010-2011 Alexey Dubinin <LemmingKing at ya dot ru>
38
+ * Copyright (C) 2010-2011 Nikolay Nemshilov
39
+ */
40
+
41
+ var id_matchers = null,
42
+ class_matchers = null,
43
+ Wrappers = RightJS.Element.Wrappers;
44
+
45
+ RightJS.$ext(Wrappers, {
46
+
47
+ /**
48
+ * Register a new wrapper for given css-rule
49
+ *
50
+ * @param String css-rule
51
+ * @param RightJS.Element subclass
52
+ * @return Element.Wrappers object
53
+ */
54
+ set: function(css_rule, klass) {
55
+ var match = css_rule.match(/^[a-z]+$/i);
56
+
57
+ if (match) { // Tag-name
58
+ Wrappers[css_rule.toUpperCase()] = klass;
59
+ } else if ((match = css_rule.match(/^([a-z]*)\#[a-z0-9_\-]+$/i))) {
60
+ if (id_matchers === null) { id_matchers = {}; }
61
+ id_matchers[css_rule] = klass;
62
+ } else if ((match = css_rule.match(/^([a-z]*)\.[a-z0-9_\-]+$/i))) {
63
+ if (class_matchers === null) { class_matchers = {}; }
64
+ class_matchers[css_rule] = klass;
65
+ }
66
+
67
+ return klass;
68
+ },
69
+
70
+ /**
71
+ * Returns a registered wrapper by a css-rule
72
+ *
73
+ * @param String css_rule
74
+ * @return RightJS.Element or null
75
+ */
76
+ get: function(css_rule) {
77
+ var result = null;
78
+
79
+ if (typeof css_rule === 'string') {
80
+ if (css_rule.toUpperCase() in Wrappers) {
81
+ result = Wrappers[css_rule.toUpperCase()];
82
+ } else if (id_matchers !== null && css_rule in id_matchers) {
83
+ result = id_matchers[css_rule];
84
+ } else if (class_matchers !== null && css_rule in class_matchers) {
85
+ result = class_matchers[css_rule];
86
+ }
87
+ } else {
88
+ result = RightJS([]);
89
+ RightJS([Wrappers, id_matchers || {}, class_matchers || {}]).each(function(hash) {
90
+ for (var key in hash) {
91
+ if (hash[key] === css_rule) {
92
+ result.push(key);
93
+ }
94
+ }
95
+ });
96
+
97
+ result = result.compact();
98
+
99
+ if (result.empty()) {
100
+ result = null;
101
+ }
102
+ }
103
+
104
+ return result;
105
+ },
106
+
107
+ /**
108
+ * Checks if the css-rule is registered
109
+ *
110
+ * @param String css_rule
111
+ * @return Boolean check result
112
+ */
113
+ has: function(css_rule) {
114
+ return Wrappers.get(css_rule) !== null;
115
+ },
116
+
117
+ /**
118
+ * Removes the dom-wrapper
119
+ *
120
+ * @param String css-rule or RightJS.Element class
121
+ * @return Element.Wrappers object
122
+ */
123
+ remove: function(css_rule) {
124
+ RightJS([Wrappers, id_matchers || {}, class_matchers || {}]).each(function(object) {
125
+ for (var key in object) {
126
+ if (css_rule === key.toLowerCase() || object[key] === css_rule) {
127
+ delete(object[key]);
128
+ }
129
+ }
130
+ });
131
+
132
+ return Wrappers;
133
+ }
134
+ });
135
+
136
+
137
+ /**
138
+ * Replacing the original casting method
139
+ * with a new one that supporst all the other types of casting
140
+ *
141
+ * @param HTMLElement raw dom-element
142
+ * @return Function wrapper class or undefined
143
+ */
144
+ RightJS.Wrapper.Cast = function(element) {
145
+ var key, tag = element.tagName;
146
+
147
+ if (id_matchers !== null && element.id) {
148
+ key = tag.toLowerCase() + '#'+ element.id;
149
+ if (key in id_matchers) {
150
+ return id_matchers[key];
151
+ }
152
+
153
+ key = '#'+ element.id;
154
+ if (key in id_matchers) {
155
+ return id_matchers[key];
156
+ }
157
+ }
158
+
159
+ if (class_matchers !== null && element.className) {
160
+ var classes = element.className.split(/\s+/), i=0,
161
+ l_tag = tag.toLowerCase();
162
+
163
+ for (; i < classes.length; i++) {
164
+ key = l_tag + "." + classes[i];
165
+ if (key in class_matchers) {
166
+ return class_matchers[key];
167
+ }
168
+
169
+ key = "." + classes[i];
170
+ if (key in class_matchers) {
171
+ return class_matchers[key];
172
+ }
173
+ }
174
+ }
175
+
176
+ if (tag in Wrappers) {
177
+ return Wrappers[tag];
178
+ }
179
+
180
+ return undefined;
181
+ };
182
+
183
+ })(RightJS);
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Dynamic Elements Casting v2.2.0
3
+ * http://rightjs.org/plugins/casting
4
+ *
5
+ * Copyright (C) 2010-2011 Nikolay Nemshilov
6
+ */
7
+ (function(a){a.Casting={version:"2.2.0"};var b=null,c=null,d=a.Element.Wrappers;a.$ext(d,{set:function(a,e){var f=a.match(/^[a-z]+$/i);if(f)d[a.toUpperCase()]=e;else if(f=a.match(/^([a-z]*)\#[a-z0-9_\-]+$/i))b===null&&(b={}),b[a]=e;else if(f=a.match(/^([a-z]*)\.[a-z0-9_\-]+$/i))c===null&&(c={}),c[a]=e;return e},get:function(e){var f=null;typeof e==="string"?e.toUpperCase()in d?f=d[e.toUpperCase()]:b!==null&&e in b?f=b[e]:c!==null&&e in c&&(f=c[e]):(f=a([]),a([d,b||{},c||{}]).each(function(a){for(var b in a)a[b]===e&&f.push(b)}),f=f.compact(),f.empty()&&(f=null));return f},has:function(a){return d.get(a)!==null},remove:function(e){a([d,b||{},c||{}]).each(function(a){for(var b in a)(e===b.toLowerCase()||a[b]===e)&&delete a[b]});return d}}),a.Wrapper.Cast=function(a){var e,f=a.tagName;if(b!==null&&a.id){e=f.toLowerCase()+"#"+a.id;if(e in b)return b[e];e="#"+a.id;if(e in b)return b[e]}if(c!==null&&a.className){var g=a.className.split(/\s+/),h=0,i=f.toLowerCase();for(;h<g.length;h++){e=i+"."+g[h];if(e in c)return c[e];e="."+g[h];if(e in c)return c[e]}}if(f in d)return d[f];return undefined}})(RightJS)
@@ -0,0 +1,981 @@
1
+ /**
2
+ * RightJS-UI Colorpicker v2.2.0
3
+ * http://rightjs.org/ui/colorpicker
4
+ *
5
+ * Copyright (C) 2010-2011 Nikolay Nemshilov
6
+ */
7
+ var Colorpicker = RightJS.Colorpicker = (function(document, Math, parseInt, 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 widget units constructor
18
+ *
19
+ * @param String tag-name or Object methods
20
+ * @param Object methods
21
+ * @return Widget wrapper
22
+ */
23
+ function Widget(tag_name, methods) {
24
+ if (!methods) {
25
+ methods = tag_name;
26
+ tag_name = 'DIV';
27
+ }
28
+
29
+ /**
30
+ * An Abstract Widget Unit
31
+ *
32
+ * Copyright (C) 2010 Nikolay Nemshilov
33
+ */
34
+ var AbstractWidget = new RightJS.Class(RightJS.Element.Wrappers[tag_name] || RightJS.Element, {
35
+ /**
36
+ * The common constructor
37
+ *
38
+ * @param Object options
39
+ * @param String optional tag name
40
+ * @return void
41
+ */
42
+ initialize: function(key, options) {
43
+ this.key = key;
44
+ var args = [{'class': 'rui-' + key}];
45
+
46
+ // those two have different constructors
47
+ if (!(this instanceof RightJS.Input || this instanceof RightJS.Form)) {
48
+ args.unshift(tag_name);
49
+ }
50
+ this.$super.apply(this, args);
51
+
52
+ if (RightJS.isString(options)) {
53
+ options = RightJS.$(options);
54
+ }
55
+
56
+ // if the options is another element then
57
+ // try to dynamically rewrap it with our widget
58
+ if (options instanceof RightJS.Element) {
59
+ this._ = options._;
60
+ if ('$listeners' in options) {
61
+ options.$listeners = options.$listeners;
62
+ }
63
+ options = {};
64
+ }
65
+ this.setOptions(options, this);
66
+
67
+ return (RightJS.Wrapper.Cache[RightJS.$uid(this._)] = this);
68
+ },
69
+
70
+ // protected
71
+
72
+ /**
73
+ * Catches the options
74
+ *
75
+ * @param Object user-options
76
+ * @param Element element with contextual options
77
+ * @return void
78
+ */
79
+ setOptions: function(options, element) {
80
+ if (element) {
81
+ options = RightJS.Object.merge(options, new Function("return "+(
82
+ element.get('data-'+ this.key) || '{}'
83
+ ))());
84
+ }
85
+
86
+ if (options) {
87
+ RightJS.Options.setOptions.call(this, RightJS.Object.merge(this.options, options));
88
+ }
89
+
90
+ return this;
91
+ }
92
+ });
93
+
94
+ /**
95
+ * Creating the actual widget class
96
+ *
97
+ */
98
+ var Klass = new RightJS.Class(AbstractWidget, methods);
99
+
100
+ // creating the widget related shortcuts
101
+ RightJS.Observer.createShortcuts(Klass.prototype, Klass.EVENTS || RightJS([]));
102
+
103
+ return Klass;
104
+ }
105
+
106
+
107
+ /**
108
+ * A shared button unit.
109
+ * NOTE: we use the DIV units instead of INPUTS
110
+ * so those buttons didn't interfere with
111
+ * the user's tab-index on his page
112
+ *
113
+ * Copyright (C) 2010-2011 Nikolay Nemshilov
114
+ */
115
+ var Button = new RightJS.Class(RightJS.Element, {
116
+ /**
117
+ * Constructor
118
+ *
119
+ * @param String caption
120
+ * @param Object options
121
+ * @return void
122
+ */
123
+ initialize: function(caption, options) {
124
+ this.$super('div', options);
125
+ this._.innerHTML = caption;
126
+ this.addClass('rui-button');
127
+ this.on('selectstart', 'stopEvent');
128
+ },
129
+
130
+ /**
131
+ * Disasbles the button
132
+ *
133
+ * @return Button this
134
+ */
135
+ disable: function() {
136
+ return this.addClass('rui-button-disabled');
137
+ },
138
+
139
+ /**
140
+ * Enables the button
141
+ *
142
+ * @return Button this
143
+ */
144
+ enable: function() {
145
+ return this.removeClass('rui-button-disabled');
146
+ },
147
+
148
+ /**
149
+ * Checks if the button is disabled
150
+ *
151
+ * @return Button this
152
+ */
153
+ disabled: function() {
154
+ return this.hasClass('rui-button-disabled');
155
+ },
156
+
157
+ /**
158
+ * Checks if the button is enabled
159
+ *
160
+ * @return Button this
161
+ */
162
+ enabled: function() {
163
+ return !this.disabled();
164
+ },
165
+
166
+ /**
167
+ * Overloading the method, so it fired the events
168
+ * only when the button is active
169
+ *
170
+ * @return Button this
171
+ */
172
+ fire: function() {
173
+ if (this.enabled()) {
174
+ this.$super.apply(this, arguments);
175
+ }
176
+ return this;
177
+ }
178
+ });
179
+
180
+
181
+ /**
182
+ * A shared module that toggles a widget visibility status
183
+ * in a uniformed way according to the options settings
184
+ *
185
+ * Copyright (C) 2010-2011 Nikolay Nemshilov
186
+ */
187
+ var Toggler = {
188
+ /**
189
+ * Shows the element
190
+ *
191
+ * @param String fx-name
192
+ * @param Object fx-options
193
+ * @return Element this
194
+ */
195
+ show: function(fx_name, fx_options) {
196
+ this.constructor.current = this;
197
+ return Toggler_toggle(this, 'show', fx_name, fx_options);
198
+ },
199
+
200
+ /**
201
+ * Hides the element
202
+ *
203
+ * @param String fx-name
204
+ * @param Object fx-options
205
+ * @return Element this
206
+ */
207
+ hide: function(fx_name, fx_options) {
208
+ this.constructor.current = null;
209
+ return Toggler_toggle(this, 'show', fx_name, fx_options);
210
+ },
211
+
212
+ /**
213
+ * Toggles the widget at the given element
214
+ *
215
+ * @param Element the related element
216
+ * @param String position right/bottom (bottom is the default)
217
+ * @param Boolean marker if the element should be resized to the element size
218
+ * @return Widget this
219
+ */
220
+ showAt: function(element, where, resize) {
221
+ this.hide(null).shownAt = element = RightJS.$(element);
222
+
223
+ // moves this element at the given one
224
+ Toggler_re_position.call(this, element, where, resize);
225
+
226
+ return this.show();
227
+ },
228
+
229
+ /**
230
+ * Toggles the widget at the given element
231
+ *
232
+ * @param Element the related element
233
+ * @param String position top/left/right/bottom (bottom is the default)
234
+ * @param Boolean marker if the element should be resized to the element size
235
+ * @return Widget this
236
+ */
237
+ toggleAt: function(element, where, resize) {
238
+ return this.hidden() ? this.showAt(element, where, resize) : this.hide();
239
+ }
240
+ };
241
+
242
+
243
+ /**
244
+ * toggles the element's state according to the current settings
245
+ *
246
+ * @param event String 'show' or 'hide' the event name
247
+ * @param String an optional fx-name
248
+ * @param Object an optional fx-options hash
249
+ * @return void
250
+ */
251
+ function Toggler_toggle(element, event, fx_name, fx_options) {
252
+ if (RightJS.Fx) {
253
+ if (fx_name === undefined) {
254
+ fx_name = element.options.fxName;
255
+
256
+ if (fx_options === undefined) {
257
+ fx_options = {
258
+ duration: element.options.fxDuration,
259
+ onFinish: RightJS(element.fire).bind(element, event)
260
+ };
261
+
262
+ // hide on double time
263
+ if (event === 'hide') {
264
+ fx_options.duration = (RightJS.Fx.Durations[fx_options.duration] ||
265
+ fx_options.duration) / 2;
266
+ }
267
+ }
268
+ }
269
+ }
270
+
271
+ // manually trigger the event if no fx were specified
272
+ if (!RightJS.Fx || !fx_name) { element.fire(event); }
273
+
274
+ return element.$super(fx_name, fx_options);
275
+ }
276
+
277
+ /**
278
+ * Relatively positions the current element
279
+ * against the specified one
280
+ *
281
+ * NOTE: this function is called in a context
282
+ * of another element
283
+ *
284
+ * @param Element the target element
285
+ * @param String position 'right' or 'bottom'
286
+ * @param Boolean if `true` then the element size will be adjusted
287
+ * @return void
288
+ */
289
+ function Toggler_re_position(element, where, resize) {
290
+ var anchor = this.reAnchor || (this.reAnchor =
291
+ new RightJS.Element('div', {'class': 'rui-re-anchor'}))
292
+ .insert(this),
293
+
294
+ pos = anchor.insertTo(element, 'after').position(),
295
+ dims = element.dimensions(), target = this,
296
+
297
+ border_top = parseInt(element.getStyle('borderTopWidth')),
298
+ border_left = parseInt(element.getStyle('borderLeftWidth')),
299
+ border_right = parseInt(element.getStyle('borderRightWidth')),
300
+ border_bottom = parseInt(element.getStyle('borderBottomWidth')),
301
+
302
+ top = dims.top - pos.y + border_top,
303
+ left = dims.left - pos.x + border_left,
304
+ width = dims.width - border_left - border_right,
305
+ height = dims.height - border_top - border_bottom;
306
+
307
+ // making the element to appear so we could read it's sizes
308
+ target.setStyle('visibility:hidden').show(null);
309
+
310
+ if (where === 'right') {
311
+ left += width - target.size().x;
312
+ } else { // bottom
313
+ top += height;
314
+ }
315
+
316
+ target.moveTo(left, top);
317
+
318
+ if (resize) {
319
+ if (where === 'left' || where === 'right') {
320
+ target.setHeight(height);
321
+ } else {
322
+ target.setWidth(width);
323
+ }
324
+ }
325
+
326
+ // rolling the invisibility back
327
+ target.setStyle('visibility:visible').hide(null);
328
+ }
329
+
330
+ /**
331
+ * A shared module that provides for the widgets an ability
332
+ * to be assigned to an input element and work in pair with it
333
+ *
334
+ * NOTE: this module works in pair with the 'RePosition' module!
335
+ *
336
+ * Copyright (C) 2010 Nikolay Nemshilov
337
+ */
338
+ var Assignable = {
339
+ /**
340
+ * Assigns the widget to serve the given input element
341
+ *
342
+ * Basically it puts the references of the current widget
343
+ * to the input and trigger objects so they could be recognized
344
+ * later, and it also synchronizes the changes between the input
345
+ * element and the widget
346
+ *
347
+ * @param {Element} input field
348
+ * @param {Element} optional trigger
349
+ * @return Widget this
350
+ */
351
+ assignTo: function(input, trigger) {
352
+ input = RightJS.$(input);
353
+ trigger = RightJS.$(trigger);
354
+
355
+ if (trigger) {
356
+ trigger[this.key] = this;
357
+ trigger.assignedInput = input;
358
+ } else {
359
+ input[this.key] = this;
360
+ }
361
+
362
+ var on_change = RightJS(function() {
363
+ if (this.visible() && (!this.showAt || this.shownAt === input)) {
364
+ this.setValue(input.value());
365
+ }
366
+ }).bind(this);
367
+
368
+ input.on({
369
+ keyup: on_change,
370
+ change: on_change
371
+ });
372
+
373
+ this.onChange(function() {
374
+ if (!this.showAt || this.shownAt === input) {
375
+ input.setValue(this.getValue());
376
+ }
377
+ });
378
+
379
+ return this;
380
+ }
381
+ };
382
+
383
+
384
+ /**
385
+ * The initialization files list
386
+ *
387
+ * Copyright (C) 2010 Nikolay Nemshilov
388
+ */
389
+
390
+ var R = RightJS,
391
+ $ = RightJS.$,
392
+ $w = RightJS.$w,
393
+ $$ = RightJS.$$,
394
+ $E = RightJS.$E,
395
+ $A = RightJS.$A,
396
+ isArray = RightJS.isArray,
397
+ Class = RightJS.Class,
398
+ Element = RightJS.Element,
399
+ Input = RightJS.Input;
400
+
401
+
402
+
403
+
404
+
405
+
406
+
407
+
408
+ /**
409
+ * The basic file for Colorpicker
410
+ *
411
+ * Copyright (C) 2010-2011 Nikolay Nemshilov
412
+ */
413
+ var Colorpicker = new Widget({
414
+ include: [Toggler, Assignable],
415
+
416
+ extend: {
417
+ version: '2.2.0',
418
+
419
+ EVENTS: $w('change show hide done'),
420
+
421
+ Options: {
422
+ format: 'hex', // hex or rgb
423
+
424
+ update: null, // an element to update with the color text
425
+ updateBg: null, // an element to update it's background color
426
+ trigger: null, // a trigger element for the popup
427
+
428
+ fxName: 'fade', // popup displaying fx
429
+ fxDuration: 'short',
430
+
431
+ cssRule: '*[data-colorpicker]'
432
+ },
433
+
434
+ i18n: {
435
+ Done: 'Done'
436
+ },
437
+
438
+ // hides all the popup colorpickers on the page
439
+ hideAll: function() {
440
+ $$('div.rui-colorpicker').each(function(picker) {
441
+ if (picker instanceof Colorpicker && !picker.inlined()) {
442
+ picker.hide();
443
+ }
444
+ });
445
+ }
446
+ },
447
+
448
+ /**
449
+ * basic constructor
450
+ *
451
+ * @param Object options
452
+ */
453
+ initialize: function(options) {
454
+ this
455
+ .$super('colorpicker', options)
456
+ .addClass('rui-panel')
457
+ .insert([
458
+ this.field = new Field(),
459
+ this.colors = new Colors(),
460
+ this.controls = new Controls()
461
+ ])
462
+ .on({
463
+ mousedown: this.startTrack,
464
+
465
+ keyup: this.recalc,
466
+ blur: this.update,
467
+ focus: this.cancelTimer,
468
+
469
+ done: this.done
470
+ });
471
+
472
+ // hooking up the elements to update
473
+ if (this.options.update) { this.assignTo(this.options.update, this.options.trigger); }
474
+ if (this.options.updateBg) { this.updateBg(this.options.updateBg); }
475
+
476
+ // setting up the initial values
477
+ this.tint = R([1, 0, 0]);
478
+ this.satur = 0;
479
+ this.bright = 1;
480
+ this.color = R([255, 255, 255]);
481
+
482
+ this.recalc().update();
483
+ },
484
+
485
+ /**
486
+ * Sets the color of the widget
487
+ *
488
+ * @param mixed value, Array or HEX or RGB value
489
+ * @return Colorpicker this
490
+ */
491
+ setValue: function(value) {
492
+ var color = isArray(value) ? value : this.toColor(value);
493
+ if (color && color.length === 3) {
494
+
495
+ // normalizing the data
496
+ color = color.map(function(value) {
497
+ return this.bound(parseInt(''+value), 0, 255);
498
+ }, this);
499
+
500
+ this.color = color;
501
+ this.color2tint().update();
502
+
503
+ // reupdating the popup-state a bit later when we have the sizes
504
+ if (!this.colors.size().y) {
505
+ this.update.bind(this).delay(20);
506
+ }
507
+ }
508
+ return this;
509
+ },
510
+
511
+ /**
512
+ * Returns the value of the widget
513
+ * formatted according to the options
514
+ *
515
+ * @param Boolean if you need a clean RGB values array
516
+ * @return mixed value
517
+ */
518
+ getValue: function(array) {
519
+ return array ? this.color : this[this.options.format === 'rgb' ? 'toRgb' : 'toHex']();
520
+ },
521
+
522
+ /**
523
+ * Assigns the colorpicer to automatically update
524
+ * given element's background on changes
525
+ *
526
+ * @param mixed element reference
527
+ * @return Colorpicker this
528
+ */
529
+ updateBg: function(element_ref) {
530
+ var element = $(element_ref);
531
+ if (element) {
532
+ this.onChange(R(function(color) {
533
+ element._.style.backgroundColor = this.toRgb();
534
+ }).bind(this));
535
+ }
536
+ return this;
537
+ },
538
+
539
+ /**
540
+ * Inlines the widget into the given element
541
+ *
542
+ * @param Element reference
543
+ * @param String optional position
544
+ * @return Colorpicker this
545
+ */
546
+ insertTo: function(element, position) {
547
+ return this
548
+ .$super(element, position)
549
+ .addClass('rui-colorpicker-inline');
550
+ },
551
+
552
+ /**
553
+ * Checks if that's an inlined version of the widget
554
+ *
555
+ * @return Boolean check result
556
+ */
557
+ inlined: function() {
558
+ return this.hasClass('rui-colorpicker-inline');
559
+ },
560
+
561
+ /**
562
+ * Finalizes the action
563
+ *
564
+ * @return Colorpicker this
565
+ */
566
+ done: function() {
567
+ if (!this.inlined()) {
568
+ this.hide();
569
+ }
570
+ return this;
571
+ },
572
+
573
+ // protected
574
+
575
+ // catching up the user options
576
+ setOptions: function(user_options) {
577
+ user_options = user_options || {};
578
+ this.$super(user_options, $(user_options.trigger || user_options.update));
579
+ },
580
+
581
+ // updates the preview and pointer positions
582
+ update: function() {
583
+ this.field._.style.backgroundColor = 'rgb('+ this.tint.map(function(c) { return Math.round(c*255); }) +')';
584
+
585
+ // updating the input fields
586
+ var color = this.color, controls = this.controls;
587
+
588
+ controls.preview._.style.backgroundColor = controls.display._.value = this.toHex();
589
+
590
+ controls.rDisplay._.value = color[0];
591
+ controls.gDisplay._.value = color[1];
592
+ controls.bDisplay._.value = color[2];
593
+
594
+ // adjusting the field pointer position
595
+ var pointer = this.field.pointer._.style,
596
+ field = this.field.size(),
597
+ top = field.y - this.bright * field.y - 2,
598
+ left = this.satur * field.x - 2;
599
+
600
+ pointer.top = this.bound(top, 0, field.y - 5) + 'px';
601
+ pointer.left = this.bound(left, 0, field.x - 5) + 'px';
602
+
603
+ // adjusting the ting pointer position
604
+ var tint = this.tint, position;
605
+ field = this.colors.size();
606
+
607
+ if (tint[1] == 0) { // the red-blue section
608
+ position = tint[0] == 1 ? tint[2] : (2 - tint[0]);
609
+ } else if (tint[0] == 0) { // the blue-green section
610
+ position = 2 + (tint[2] == 1 ? tint[1] : (2 - tint[2]));
611
+ } else { // the green-red section
612
+ position = 4 + (tint[1] == 1 ? tint[0] : (2 - tint[1]));
613
+ }
614
+
615
+ position = position / 6 * field.y;
616
+
617
+ this.colors.pointer._.style.top = this.bound(position, 0, field.y - 4) + 'px';
618
+
619
+ // tracking the color change events
620
+ if (this.prevColor !== ''+this.color) {
621
+ this.fire('change', {value: this.color});
622
+ this.prevColor = ''+ this.color;
623
+ }
624
+
625
+ return this;
626
+ },
627
+
628
+ // recalculates the state after the input field changes
629
+ recalc: function(event) {
630
+ if (event) {
631
+ var field = event.target, value = field._.value, color = $A(this.color), changed=false;
632
+
633
+ if (field === this.controls.display && /#\w{6}/.test(value)) {
634
+ // using the hex values
635
+ changed = color = this.toColor(value);
636
+ } else if (/^\d+$/.test(value)) {
637
+ // using the rgb values
638
+ color[field._.cIndex] = value;
639
+ changed = true;
640
+ }
641
+
642
+ if (changed) { this.setValue(color); }
643
+
644
+ } else {
645
+ this.tint2color();
646
+ }
647
+
648
+ return this;
649
+ },
650
+
651
+ // starts the mousemoves tracking
652
+ startTrack: function(event) {
653
+ this.stopTrack();
654
+ this.cancelTimer();
655
+
656
+ if (event.target === this.field.pointer) {
657
+ event.target = this.field;
658
+ } else if (event.target === this.colors.pointer) {
659
+ event.target = this.colors;
660
+ }
661
+
662
+ if (event.target === this.field || event.target === this.colors) {
663
+ event.stop();
664
+ Colorpicker.tracking = this;
665
+ event.target.tracking = true;
666
+ this.trackMove(event); // jumping over there
667
+ }
668
+ },
669
+
670
+ // stops tracking the mousemoves
671
+ stopTrack: function() {
672
+ Colorpicker.tracking = false;
673
+ this.field.tracking = false;
674
+ this.colors.tracking = false;
675
+ },
676
+
677
+ // tracks the cursor moves over the fields
678
+ trackMove: function(event) {
679
+ var field, pos = event.position(), top, left;
680
+
681
+ if (this.field.tracking) {
682
+ field = this.field.dimensions();
683
+ } else if (this.colors.tracking) {
684
+ field = this.colors.dimensions();
685
+ }
686
+
687
+ if (field) {
688
+ top = this.bound(pos.y - field.top, 0, field.height);
689
+ left = this.bound(pos.x - field.left, 0, field.width);
690
+
691
+ if (this.field.tracking) {
692
+ this.satur = left / field.width;
693
+ this.bright = 1 - top / field.height;
694
+
695
+ } else if (this.colors.tracking) {
696
+ // preventing it from jumping to the top
697
+ if (top == field.height) { top = field.height - 0.1; }
698
+
699
+ var step = field.height / 6,
700
+ tint = this.tint = [0, 0, 0],
701
+ stright = top % step / step,
702
+ reverse = 1 - stright;
703
+
704
+ if (top < step) {
705
+ tint[0] = 1;
706
+ tint[2] = stright;
707
+ } else if (top < step * 2) {
708
+ tint[0] = reverse;
709
+ tint[2] = 1;
710
+ } else if (top < step * 3) {
711
+ tint[2] = 1;
712
+ tint[1] = stright;
713
+ } else if (top < step * 4) {
714
+ tint[2] = reverse;
715
+ tint[1] = 1;
716
+ } else if (top < step * 5) {
717
+ tint[1] = 1;
718
+ tint[0] = stright;
719
+ } else {
720
+ tint[1] = reverse;
721
+ tint[0] = 1;
722
+ }
723
+ }
724
+
725
+ this.recalc().update();
726
+ }
727
+ },
728
+
729
+ cancelTimer: function(event) {
730
+ R(function() { // IE has a lack of sync in here
731
+ if (this._hide_delay) {
732
+ this._hide_delay.cancel();
733
+ this._hide_delay = null;
734
+ }
735
+ }).bind(this).delay(10);
736
+ }
737
+ });
738
+
739
+
740
+ /**
741
+ * The colors field element
742
+ *
743
+ * Copyright (C) 2010-2011
744
+ */
745
+ var Field = new Class(Element, {
746
+ initialize: function(options) {
747
+ this.$super('div', {'class': 'field'});
748
+ this.insert(this.pointer = $E('div', {'class': 'pointer'}));
749
+ }
750
+ });
751
+
752
+
753
+ /**
754
+ * The tint picker block
755
+ *
756
+ * Copyright (C) 2010-2011 Nikolay Nemshilov
757
+ */
758
+ var Colors = new Class(Element, {
759
+ initialize: function() {
760
+ this.$super('div', {'class': 'colors'});
761
+ this.insert(this.pointer = $E('div', {'class': 'pointer'}));
762
+ }
763
+ });
764
+
765
+
766
+ /**
767
+ * The controls block unit
768
+ *
769
+ * Copyright (C) 2010-2011 Nikolay Nemshilov
770
+ */
771
+ var Controls = new Class(Element, {
772
+ initialize: function() {
773
+ this.$super('div', {'class': 'controls'});
774
+ this.insert([
775
+ this.preview = $E('div', {'class': 'preview', 'html': '&nbsp;'}),
776
+ this.display = $E('input', {'type': 'text', 'class': 'display', maxlength: 7}),
777
+ $E('div', {'class': 'rgb-display'}).insert([
778
+ $E('div').insert([$E('label', {html: 'R:'}), this.rDisplay = $E('input', {maxlength: 3, cIndex: 0})]),
779
+ $E('div').insert([$E('label', {html: 'G:'}), this.gDisplay = $E('input', {maxlength: 3, cIndex: 1})]),
780
+ $E('div').insert([$E('label', {html: 'B:'}), this.bDisplay = $E('input', {maxlength: 3, cIndex: 2})])
781
+ ]),
782
+ this.button = new Button(Colorpicker.i18n.Done).onClick('fire', 'done')
783
+ ]);
784
+ }
785
+ });
786
+
787
+
788
+ /**
789
+ * This module contains various caluculations logic for
790
+ * the Colorpicker widget
791
+ *
792
+ * Copyright (C) 2010 Nikolay Nemshilov
793
+ */
794
+ Colorpicker.include({
795
+ /**
796
+ * Converts the color to a RGB string value
797
+ *
798
+ * @param Array optional color
799
+ * @return String RGB value
800
+ */
801
+ toRgb: function(color) {
802
+ return 'rgb('+ this.color.join(',') +')';
803
+ },
804
+
805
+ /**
806
+ * Converts the color to a HEX string value
807
+ *
808
+ * @param Array optional color
809
+ * @return String HEX value
810
+ */
811
+ toHex: function(color) {
812
+ return '#'+ this.color.map(function(c) { return (c < 16 ? '0' : '') + c.toString(16); }).join('');
813
+ },
814
+
815
+ /**
816
+ * Converts a string value into an Array of color
817
+ *
818
+ * @param String value
819
+ * @return Array of color or null
820
+ */
821
+ toColor: function(in_value) {
822
+ var value = in_value.toLowerCase(), match;
823
+
824
+ if ((match = /rgb\((\d+),(\d+),(\d+)\)/.exec(value))) {
825
+ return [match[1], match[2], match[3]].map(parseInt);
826
+
827
+ } else if (/#[\da-f]+/.test(value)) {
828
+ // converting the shortified hex in to the full-length version
829
+ if ((match = /^#([\da-f])([\da-f])([\da-f])$/.exec(value))) {
830
+ value = '#'+match[1]+match[1]+match[2]+match[2]+match[3]+match[3];
831
+ }
832
+
833
+ if ((match = /#([\da-f]{2})([\da-f]{2})([\da-f]{2})/.exec(value))) {
834
+ return [match[1], match[2], match[3]].map(function(n) { return parseInt(n, 16); });
835
+ }
836
+ }
837
+ },
838
+
839
+ /**
840
+ * converts color into the tint, saturation and brightness values
841
+ *
842
+ * @return Colorpicker this
843
+ */
844
+ color2tint: function() {
845
+ var color = $A(this.color).sort(function(a,b) { return a-b; }),
846
+ min = color[0], max = color[2];
847
+
848
+ this.bright = max / 255;
849
+ this.satur = 1 - min / (max || 1);
850
+
851
+ this.tint.each(function(value, i) {
852
+ this.tint[i] = ((!min && !max) || min == max) ? i == 0 ? 1 : 0 :
853
+ (this.color[i] - min) / (max - min);
854
+ return this.tint[i];
855
+ }, this);
856
+
857
+ return this;
858
+ },
859
+
860
+ /**
861
+ * Converts tint, saturation and brightness into the actual RGB color
862
+ *
863
+ * @return Colorpicker this
864
+ */
865
+ tint2color: function() {
866
+ var tint = this.tint, color = this.color;
867
+
868
+ for (var i=0; i < 3; i++) {
869
+ color[i] = 1 + this.satur * (tint[i] - 1);
870
+ color[i] = Math.round(255 * color[i] * this.bright);
871
+ }
872
+
873
+ return this;
874
+ },
875
+
876
+ /**
877
+ * bounds the value to the given limits
878
+ *
879
+ * @param {Number} value
880
+ * @param {Number} min value
881
+ * @param {Number} max value
882
+ * @return {Number} the value in bounds
883
+ */
884
+ bound: function(in_value, min, max) {
885
+ var value = in_value;
886
+
887
+ if (min < max) {
888
+ value = value < min ? min : value > max ? max : value;
889
+ } else {
890
+ if (value > max) { value = max; }
891
+ if (value < min) { value = min; }
892
+ }
893
+
894
+ return value;
895
+ }
896
+ });
897
+
898
+
899
+ /**
900
+ * The document level hooks for colorpicker
901
+ *
902
+ * Copyright (C) 2010 Nikolay Nemshilov
903
+ */
904
+ $(document).on({
905
+ mouseup: function() {
906
+ if (Colorpicker.tracking) {
907
+ Colorpicker.tracking.stopTrack();
908
+ }
909
+ },
910
+
911
+ mousemove: function(event) {
912
+ if (Colorpicker.tracking) {
913
+ Colorpicker.tracking.trackMove(event);
914
+ }
915
+ },
916
+
917
+ focus: function(event) {
918
+ var target = event.target instanceof Input ? event.target : null;
919
+
920
+ Colorpicker.hideAll();
921
+
922
+ if (target && (target.colorpicker || target.match(Colorpicker.Options.cssRule))) {
923
+ (target.colorpicker || new Colorpicker({update: target}))
924
+ .setValue(target.value()).showAt(target);
925
+ }
926
+ },
927
+
928
+ blur: function(event) {
929
+ var target = event.target, colorpicker = target.colorpicker;
930
+
931
+ if (colorpicker) {
932
+ // we use the delay so it didn't get hidden when the user clicks the calendar itself
933
+ colorpicker._hide_delay = R(function() {
934
+ colorpicker.hide();
935
+ }).delay(200);
936
+ }
937
+ },
938
+
939
+ click: function(event) {
940
+ var target = (event.target instanceof Element) ? event.target : null;
941
+
942
+ if (target && (target.colorpicker || target.match(Colorpicker.Options.cssRule))) {
943
+ if (!(target instanceof Input)) {
944
+ event.stop();
945
+ (target.colorpicker || new Colorpicker({trigger: target}))
946
+ .hide(null).toggleAt(target.assignedInput);
947
+ }
948
+ } else if (!event.find('div.rui-colorpicker')){
949
+ Colorpicker.hideAll();
950
+ }
951
+ },
952
+
953
+ keydown: function(event) {
954
+ var colorpicker = Colorpicker.current, name = ({
955
+ 27: 'hide', // Escape
956
+ 13: 'done' // Enter
957
+ })[event.keyCode];
958
+
959
+ if (name && colorpicker && colorpicker.visible()) {
960
+ event.stop();
961
+ colorpicker[name]();
962
+ }
963
+ }
964
+ });
965
+
966
+
967
+ var embed_style = document.createElement('style'),
968
+ embed_rules = document.createTextNode("*.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}.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}div.rui-colorpicker .field,div.rui-colorpicker .field *,div.rui-colorpicker .colors,div.rui-colorpicker .colors *{border:none;background:none;width:auto;height:auto;position:static;float:none;top:none;left:none;right:none;bottom:none;margin:0;padding:0;display:block;font-weight:normal;vertical-align:center}div.rui-colorpicker div.field,div.rui-colorpicker div.field div.pointer,div.rui-colorpicker div.colors,div.rui-colorpicker div.colors div.pointer{background:url(/assets/rightjs-ui/colorpicker.png) no-repeat 0 0}div.rui-colorpicker div.field,div.rui-colorpicker div.colors,div.rui-colorpicker div.controls{display:inline-block; *display:inline; *zoom:1;position:relative;vertical-align:top;height:150px}div.rui-colorpicker div.field div.pointer,div.rui-colorpicker div.colors div.pointer{position:absolute;top:0px;left:0;width:9px;height:9px}div.rui-colorpicker input.display,div.rui-colorpicker div.preview,div.rui-colorpicker div.rgb-display,div.rui-colorpicker input.rui-ui-button{font-size:100%;display:block;width:auto;padding:0 .2em}div.rui-colorpicker input.display,div.rui-colorpicker div.preview,div.rui-colorpicker div.rgb-display input,div.rui-colorpicker input.rui-ui-button{border:1px solid #AAA;-moz-border-radius:.2em;-webkit-border-radius:.2em}div.rui-colorpicker div.field{width:150px;background-color:red;cursor:crosshair;margin-right:1.2em}div.rui-colorpicker div.field div.pointer{background-position:-170px 0;margin-left:-2px;margin-top:-2px}div.rui-colorpicker div.colors{width:16px;background-position:-150px 0;border-color:#EEE;cursor:pointer;margin-right:.6em}div.rui-colorpicker div.colors div.pointer{cursor:default;background-position:-170px -20px;margin-left:-8px;margin-top:-3px}div.rui-colorpicker div.controls{width:5em}div.rui-colorpicker div.preview{height:2em;background:white;border-color:#BBB}div.rui-colorpicker input.display{margin-top:.5em;background:#FFF;width:4.5em}div.rui-colorpicker div.rgb-display{padding:0;text-align:right;margin-top:.5em}div.rui-colorpicker div.rgb-display label{display:inline}div.rui-colorpicker div.rgb-display label:after{content:none}div.rui-colorpicker div.rgb-display input{vertical-align:top;font-size:100%;width:2em;text-align:right;margin-left:.2em;padding:0 .2em;background:#FFF;margin-bottom:1px;display:inline}div.rui-colorpicker div.rui-button{cursor:pointer;position:absolute;bottom:0;right:0;width:4em}div.rui-colorpicker-inline{display:inline-block; *display:inline; *zoom:1;position:relative;box-shadow:none;-moz-box-shadow:none;-webkit-box-shadow:none;z-index:auto}");
969
+
970
+ embed_style.type = 'text/css';
971
+ document.getElementsByTagName('head')[0].appendChild(embed_style);
972
+
973
+ if(embed_style.styleSheet) {
974
+ embed_style.styleSheet.cssText = embed_rules.nodeValue;
975
+ } else {
976
+ embed_style.appendChild(embed_rules);
977
+ }
978
+
979
+
980
+ return Colorpicker;
981
+ })(document, Math, parseInt, RightJS);