right-rails 1.0.3 → 1.0.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/CHANGELOG +8 -2
- data/Rakefile +28 -28
- data/lib/right_rails/java_script_generator.rb +59 -51
- data/public/images/{colorpicker.png → rightjs-ui/colorpicker.png} +0 -0
- data/public/images/{resizable.png → rightjs-ui/resizable.png} +0 -0
- data/public/javascripts/right-olds-src.js +47 -46
- data/public/javascripts/right-safe-src.js +103 -102
- data/public/javascripts/right-safe.js +1 -1
- data/public/javascripts/right-src.js +611 -541
- data/public/javascripts/right.js +86 -85
- data/public/javascripts/right/autocompleter-src.js +81 -77
- data/public/javascripts/right/autocompleter.js +1 -1
- data/public/javascripts/right/calendar-src.js +209 -197
- data/public/javascripts/right/calendar.js +6 -6
- data/public/javascripts/right/colorpicker-src.js +127 -117
- data/public/javascripts/right/colorpicker.js +6 -6
- data/public/javascripts/right/dnd-src.js +63 -63
- data/public/javascripts/right/dnd.js +2 -2
- data/public/javascripts/right/in-edit-src.js +53 -48
- data/public/javascripts/right/in-edit.js +2 -2
- data/public/javascripts/right/lightbox-src.js +107 -99
- data/public/javascripts/right/lightbox.js +2 -2
- data/public/javascripts/right/rater-src.js +48 -46
- data/public/javascripts/right/rater.js +3 -3
- data/public/javascripts/right/resizable-src.js +53 -61
- data/public/javascripts/right/resizable.js +4 -4
- data/public/javascripts/right/selectable-src.js +97 -95
- data/public/javascripts/right/selectable.js +2 -2
- data/public/javascripts/right/slider-src.js +47 -45
- data/public/javascripts/right/slider.js +8 -8
- data/public/javascripts/right/sortable-src.js +54 -52
- data/public/javascripts/right/tabs-src.js +181 -171
- data/public/javascripts/right/tooltip-src.js +39 -37
- data/public/javascripts/right/uploader-src.js +21 -19
- data/spec/lib/right_rails/java_script_generator_spec.rb +61 -56
- metadata +9 -7
@@ -13,8 +13,8 @@ i=p(e.getStyle("borderBottomWidth"));e=a.top-d.y+g;d=a.left-d.x+h;h=a.width-h-j;
|
|
13
13
|
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.0.0",EVENTS:q("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,listYears:false,hideOnPick:false,
|
14
14
|
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:q("Sunday Monday Tuesday Wednesday Thursday Friday Saturday"),dayNamesShort:q("Sun Mon Tue Wed Thu Fri Sat"),dayNamesMin:q("Su Mo Tu We Th Fr Sa"),monthNames:q("January February March April May June July August September October November December"),
|
15
15
|
monthNamesShort:q("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",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",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());
|
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
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
19
|
hideOthers:function(){n.hideAll(this);return this}}),H=new t(l,{initialize:function(a){this.$super("div",{"class":"swaps"});this.options=a;var b=a.i18n;this.insert([this.prevMonth=new r("‹",{title:b.PrevMonth,"class":"prev-month"}),this.nextMonth=new r("›",{title:b.NextMonth,"class":"next-month"})]);if(a.listYears)this.insert([this.prevYear=new r("«",{title:b.PrevYear,"class":"prev-year"}),this.nextYear=new r("»",{title:b.NextYear,"class":"next-year"})]);this.buttons=o([this.prevMonth,
|
20
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);
|
@@ -26,11 +26,11 @@ new Date(a)}c=(d.listYears?g.monthNamesShort[a.getMonth()]+",":g.monthNames[a.ge
|
|
26
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=s(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
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
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 t(l,{initialize:function(a){this.$super("div",{"class":"buttons"});this.insert([(new r(a.i18n.Now,{"class":"now"})).onClick("fire","now-clicked"),(new r(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);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=
|
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
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
31
|
d:s(d),e:""+d,m:(e<9?"0":"")+(e+1),y:(""+g).substring(2,4),Y:""+g,H:s(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:s(j),S:s(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
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(u).on({focus:function(a){a=a.target instanceof A?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)){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
|
-
if(c&&b&&b.visible()){a.stop();G(b[c])?b[c]():b.fire(c)}}});u.write('<style type="text/css">.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}</style>');
|
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(u).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)}}});u.write('<style type="text/css">.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}</style>');
|
36
36
|
return n}(document,parseInt,RightJS);
|
@@ -37,19 +37,20 @@ var R = RightJS,
|
|
37
37
|
|
38
38
|
|
39
39
|
|
40
|
+
|
40
41
|
/**
|
41
42
|
* The widget units constructor
|
42
43
|
*
|
43
44
|
* @param String tag-name or Object methods
|
44
45
|
* @param Object methods
|
45
46
|
* @return Widget wrapper
|
46
|
-
*/
|
47
|
+
*/
|
47
48
|
function Widget(tag_name, methods) {
|
48
49
|
if (!methods) {
|
49
50
|
methods = tag_name;
|
50
51
|
tag_name = 'DIV';
|
51
52
|
}
|
52
|
-
|
53
|
+
|
53
54
|
/**
|
54
55
|
* An Abstract Widget Unit
|
55
56
|
*
|
@@ -66,17 +67,17 @@ function Widget(tag_name, methods) {
|
|
66
67
|
initialize: function(key, options) {
|
67
68
|
this.key = key;
|
68
69
|
var args = [{'class': 'rui-' + key}];
|
69
|
-
|
70
|
+
|
70
71
|
// those two have different constructors
|
71
72
|
if (!(this instanceof RightJS.Input || this instanceof RightJS.Form)) {
|
72
73
|
args.unshift(tag_name);
|
73
74
|
}
|
74
75
|
this.$super.apply(this, args);
|
75
|
-
|
76
|
+
|
76
77
|
if (RightJS.isString(options)) {
|
77
78
|
options = RightJS.$(options);
|
78
79
|
}
|
79
|
-
|
80
|
+
|
80
81
|
// if the options is another element then
|
81
82
|
// try to dynamically rewrap it with our widget
|
82
83
|
if (options instanceof RightJS.Element) {
|
@@ -109,16 +110,16 @@ function Widget(tag_name, methods) {
|
|
109
110
|
return this;
|
110
111
|
}
|
111
112
|
});
|
112
|
-
|
113
|
+
|
113
114
|
/**
|
114
115
|
* Creating the actual widget class
|
115
116
|
*
|
116
117
|
*/
|
117
118
|
var Klass = new RightJS.Wrapper(AbstractWidget, methods);
|
118
|
-
|
119
|
+
|
119
120
|
// creating the widget related shortcuts
|
120
121
|
RightJS.Observer.createShortcuts(Klass.prototype, Klass.EVENTS || []);
|
121
|
-
|
122
|
+
|
122
123
|
return Klass;
|
123
124
|
}
|
124
125
|
|
@@ -144,7 +145,7 @@ var Button = new RightJS.Wrapper(RightJS.Element, {
|
|
144
145
|
this._.innerHTML = caption;
|
145
146
|
this.addClass('rui-button');
|
146
147
|
},
|
147
|
-
|
148
|
+
|
148
149
|
/**
|
149
150
|
* Disasbles the button
|
150
151
|
*
|
@@ -153,7 +154,7 @@ var Button = new RightJS.Wrapper(RightJS.Element, {
|
|
153
154
|
disable: function() {
|
154
155
|
return this.addClass('rui-button-disabled');
|
155
156
|
},
|
156
|
-
|
157
|
+
|
157
158
|
/**
|
158
159
|
* Enables the button
|
159
160
|
*
|
@@ -162,7 +163,7 @@ var Button = new RightJS.Wrapper(RightJS.Element, {
|
|
162
163
|
enable: function() {
|
163
164
|
return this.removeClass('rui-button-disabled');
|
164
165
|
},
|
165
|
-
|
166
|
+
|
166
167
|
/**
|
167
168
|
* Checks if the button is disabled
|
168
169
|
*
|
@@ -171,7 +172,7 @@ var Button = new RightJS.Wrapper(RightJS.Element, {
|
|
171
172
|
disabled: function() {
|
172
173
|
return this.hasClass('rui-button-disabled');
|
173
174
|
},
|
174
|
-
|
175
|
+
|
175
176
|
/**
|
176
177
|
* Checks if the button is enabled
|
177
178
|
*
|
@@ -180,7 +181,7 @@ var Button = new RightJS.Wrapper(RightJS.Element, {
|
|
180
181
|
enabled: function() {
|
181
182
|
return !this.disabled();
|
182
183
|
},
|
183
|
-
|
184
|
+
|
184
185
|
/**
|
185
186
|
* Overloading the method, so it fired the events
|
186
187
|
* only when the button is active
|
@@ -195,6 +196,7 @@ var Button = new RightJS.Wrapper(RightJS.Element, {
|
|
195
196
|
}
|
196
197
|
});
|
197
198
|
|
199
|
+
|
198
200
|
/**
|
199
201
|
* A shared module that toggles a widget visibility status
|
200
202
|
* in a uniformed way according to the options settings
|
@@ -218,7 +220,7 @@ function toggler(element, event, fx_name, fx_options) {
|
|
218
220
|
if (RightJS.Fx) {
|
219
221
|
if (fx_name === undefined) {
|
220
222
|
fx_name = this.options.fxName;
|
221
|
-
|
223
|
+
|
222
224
|
if (fx_options === undefined) {
|
223
225
|
fx_options = {
|
224
226
|
duration: this.options.fxDuration,
|
@@ -233,12 +235,12 @@ function toggler(element, event, fx_name, fx_options) {
|
|
233
235
|
}
|
234
236
|
}
|
235
237
|
}
|
236
|
-
|
238
|
+
|
237
239
|
RightJS.Element.prototype[event].call(element, fx_name, fx_options);
|
238
|
-
|
240
|
+
|
239
241
|
// manually trigger the event if no fx were specified
|
240
242
|
if (!RightJS.Fx || !fx_name) { this.fire(event); }
|
241
|
-
|
243
|
+
|
242
244
|
return this;
|
243
245
|
}
|
244
246
|
|
@@ -255,34 +257,34 @@ function toggler(element, event, fx_name, fx_options) {
|
|
255
257
|
* @return void
|
256
258
|
*/
|
257
259
|
function re_position(element, where, resize) {
|
258
|
-
var anchor = this.reAnchor || (this.reAnchor =
|
260
|
+
var anchor = this.reAnchor || (this.reAnchor =
|
259
261
|
new RightJS.Element('div', {'class': 'rui-re-anchor'}))
|
260
262
|
.insert(this),
|
261
|
-
|
263
|
+
|
262
264
|
pos = anchor.insertTo(element, 'after').position(),
|
263
265
|
dims = element.dimensions(), target = this,
|
264
|
-
|
266
|
+
|
265
267
|
border_top = parseInt(element.getStyle('borderTopWidth')),
|
266
268
|
border_left = parseInt(element.getStyle('borderLeftWidth')),
|
267
269
|
border_right = parseInt(element.getStyle('borderRightWidth')),
|
268
270
|
border_bottom = parseInt(element.getStyle('borderBottomWidth')),
|
269
|
-
|
271
|
+
|
270
272
|
top = dims.top - pos.y + border_top,
|
271
273
|
left = dims.left - pos.x + border_left,
|
272
274
|
width = dims.width - border_left - border_right,
|
273
275
|
height = dims.height - border_top - border_bottom;
|
274
|
-
|
276
|
+
|
275
277
|
// making the element to appear so we could read it's sizes
|
276
278
|
target.setStyle('visibility:hidden').show(null);
|
277
|
-
|
279
|
+
|
278
280
|
if (where === 'right') {
|
279
281
|
left += width - target.size().x;
|
280
282
|
} else { // bottom
|
281
283
|
top += height;
|
282
284
|
}
|
283
|
-
|
285
|
+
|
284
286
|
target.moveTo(left, top);
|
285
|
-
|
287
|
+
|
286
288
|
if (resize) {
|
287
289
|
if (['left', 'right'].include(where)) {
|
288
290
|
target.setHeight(height);
|
@@ -290,7 +292,7 @@ function re_position(element, where, resize) {
|
|
290
292
|
target.setWidth(width);
|
291
293
|
}
|
292
294
|
}
|
293
|
-
|
295
|
+
|
294
296
|
// rolling the invisibility back
|
295
297
|
target.setStyle('visibility:visible').hide(null);
|
296
298
|
}
|
@@ -312,7 +314,7 @@ var Toggler = {
|
|
312
314
|
this.constructor.current = this;
|
313
315
|
return toggler.call(this, this, 'show', fx_name, fx_options);
|
314
316
|
},
|
315
|
-
|
317
|
+
|
316
318
|
/**
|
317
319
|
* Hides the element
|
318
320
|
*
|
@@ -324,7 +326,7 @@ var Toggler = {
|
|
324
326
|
this.constructor.current = null;
|
325
327
|
return toggler.call(this, this, 'hide', fx_name, fx_options);
|
326
328
|
},
|
327
|
-
|
329
|
+
|
328
330
|
/**
|
329
331
|
* Toggles the widget at the given element
|
330
332
|
*
|
@@ -335,13 +337,13 @@ var Toggler = {
|
|
335
337
|
*/
|
336
338
|
showAt: function(element, where, resize) {
|
337
339
|
this.hide(null).shownAt = element = RightJS.$(element);
|
338
|
-
|
340
|
+
|
339
341
|
// moves this element at the given one
|
340
342
|
re_position.call(this, element, where, resize);
|
341
|
-
|
343
|
+
|
342
344
|
return this.show();
|
343
345
|
},
|
344
|
-
|
346
|
+
|
345
347
|
/**
|
346
348
|
* Toggles the widget at the given element
|
347
349
|
*
|
@@ -355,6 +357,7 @@ var Toggler = {
|
|
355
357
|
}
|
356
358
|
};
|
357
359
|
|
360
|
+
|
358
361
|
/**
|
359
362
|
* A shared module that provides for the widgets an ability
|
360
363
|
* to be assigned to an input element and work in pair with it
|
@@ -379,35 +382,36 @@ var Assignable = {
|
|
379
382
|
assignTo: function(input, trigger) {
|
380
383
|
input = RightJS.$(input);
|
381
384
|
trigger = RightJS.$(trigger);
|
382
|
-
|
385
|
+
|
383
386
|
if (trigger) {
|
384
387
|
trigger[this.key] = this;
|
385
388
|
trigger.assignedInput = input;
|
386
389
|
} else {
|
387
390
|
input[this.key] = this;
|
388
391
|
}
|
389
|
-
|
392
|
+
|
390
393
|
var on_change = RightJS(function() {
|
391
394
|
if (this.visible() && (!this.showAt || this.shownAt === input)) {
|
392
395
|
this.setValue(input.value());
|
393
396
|
}
|
394
397
|
}).bind(this);
|
395
|
-
|
398
|
+
|
396
399
|
input.on({
|
397
400
|
keyup: on_change,
|
398
401
|
change: on_change
|
399
402
|
});
|
400
|
-
|
403
|
+
|
401
404
|
this.onChange(function() {
|
402
405
|
if (!this.showAt || this.shownAt === input) {
|
403
406
|
input.setValue(this.getValue());
|
404
407
|
}
|
405
408
|
});
|
406
|
-
|
409
|
+
|
407
410
|
return this;
|
408
411
|
}
|
409
412
|
};
|
410
413
|
|
414
|
+
|
411
415
|
/**
|
412
416
|
* The basic file for Colorpicker
|
413
417
|
*
|
@@ -415,29 +419,29 @@ var Assignable = {
|
|
415
419
|
*/
|
416
420
|
var Colorpicker = new Widget({
|
417
421
|
include: [Toggler, Assignable],
|
418
|
-
|
422
|
+
|
419
423
|
extend: {
|
420
424
|
version: '2.0.0',
|
421
|
-
|
425
|
+
|
422
426
|
EVENTS: $w('change show hide done'),
|
423
|
-
|
427
|
+
|
424
428
|
Options: {
|
425
429
|
format: 'hex', // hex or rgb
|
426
|
-
|
430
|
+
|
427
431
|
update: null, // an element to update with the color text
|
428
432
|
updateBg: null, // an element to update it's background color
|
429
433
|
trigger: null, // a trigger element for the popup
|
430
|
-
|
434
|
+
|
431
435
|
fxName: 'fade', // popup displaying fx
|
432
436
|
fxDuration: 'short',
|
433
|
-
|
437
|
+
|
434
438
|
cssRule: '*[data-colorpicker]'
|
435
439
|
},
|
436
|
-
|
440
|
+
|
437
441
|
i18n: {
|
438
442
|
Done: 'Done'
|
439
443
|
},
|
440
|
-
|
444
|
+
|
441
445
|
// hides all the popup colorpickers on the page
|
442
446
|
hideAll: function() {
|
443
447
|
$$('div.rui-colorpicker').each(function(picker) {
|
@@ -447,7 +451,7 @@ var Colorpicker = new Widget({
|
|
447
451
|
});
|
448
452
|
}
|
449
453
|
},
|
450
|
-
|
454
|
+
|
451
455
|
/**
|
452
456
|
* basic constructor
|
453
457
|
*
|
@@ -464,27 +468,27 @@ var Colorpicker = new Widget({
|
|
464
468
|
])
|
465
469
|
.on({
|
466
470
|
mousedown: this.startTrack,
|
467
|
-
|
471
|
+
|
468
472
|
keyup: this.recalc,
|
469
473
|
blur: this.update,
|
470
474
|
focus: this.cancelTimer,
|
471
|
-
|
475
|
+
|
472
476
|
done: this.done
|
473
477
|
});
|
474
|
-
|
478
|
+
|
475
479
|
// hooking up the elements to update
|
476
480
|
if (this.options.update) { this.assignTo(this.options.update, this.options.trigger); }
|
477
481
|
if (this.options.updateBg) { this.updateBg(this.options.updateBg); }
|
478
|
-
|
482
|
+
|
479
483
|
// setting up the initial values
|
480
484
|
this.tint = R([1, 0, 0]);
|
481
485
|
this.satur = 0;
|
482
486
|
this.bright = 1;
|
483
487
|
this.color = R([255, 255, 255]);
|
484
|
-
|
488
|
+
|
485
489
|
this.recalc().update();
|
486
490
|
},
|
487
|
-
|
491
|
+
|
488
492
|
/**
|
489
493
|
* Sets the color of the widget
|
490
494
|
*
|
@@ -494,15 +498,15 @@ var Colorpicker = new Widget({
|
|
494
498
|
setValue: function(value) {
|
495
499
|
var color = isArray(value) ? value : this.toColor(value);
|
496
500
|
if (color && color.length === 3) {
|
497
|
-
|
501
|
+
|
498
502
|
// normalizing the data
|
499
503
|
color = color.map(function(value) {
|
500
504
|
return this.bound(parseInt(''+value), 0, 255);
|
501
505
|
}, this);
|
502
|
-
|
506
|
+
|
503
507
|
this.color = color;
|
504
508
|
this.color2tint().update();
|
505
|
-
|
509
|
+
|
506
510
|
// reupdating the popup-state a bit later when we have the sizes
|
507
511
|
if (!this.colors.size().y) {
|
508
512
|
this.update.bind(this).delay(20);
|
@@ -510,7 +514,7 @@ var Colorpicker = new Widget({
|
|
510
514
|
}
|
511
515
|
return this;
|
512
516
|
},
|
513
|
-
|
517
|
+
|
514
518
|
/**
|
515
519
|
* Returns the value of the widget
|
516
520
|
* formatted according to the options
|
@@ -521,7 +525,7 @@ var Colorpicker = new Widget({
|
|
521
525
|
getValue: function(array) {
|
522
526
|
return array ? this.color : this[this.options.format === 'rgb' ? 'toRgb' : 'toHex']();
|
523
527
|
},
|
524
|
-
|
528
|
+
|
525
529
|
/**
|
526
530
|
* Assigns the colorpicer to automatically update
|
527
531
|
* given element's background on changes
|
@@ -538,7 +542,7 @@ var Colorpicker = new Widget({
|
|
538
542
|
}
|
539
543
|
return this;
|
540
544
|
},
|
541
|
-
|
545
|
+
|
542
546
|
/**
|
543
547
|
* Inlines the widget into the given element
|
544
548
|
*
|
@@ -551,7 +555,7 @@ var Colorpicker = new Widget({
|
|
551
555
|
.$super(element, position)
|
552
556
|
.addClass('rui-colorpicker-inline');
|
553
557
|
},
|
554
|
-
|
558
|
+
|
555
559
|
/**
|
556
560
|
* Checks if that's an inlined version of the widget
|
557
561
|
*
|
@@ -560,7 +564,7 @@ var Colorpicker = new Widget({
|
|
560
564
|
inlined: function() {
|
561
565
|
return this.hasClass('rui-colorpicker-inline');
|
562
566
|
},
|
563
|
-
|
567
|
+
|
564
568
|
/**
|
565
569
|
* Finalizes the action
|
566
570
|
*
|
@@ -572,7 +576,7 @@ var Colorpicker = new Widget({
|
|
572
576
|
}
|
573
577
|
return this;
|
574
578
|
},
|
575
|
-
|
579
|
+
|
576
580
|
// protected
|
577
581
|
|
578
582
|
// catching up the user options
|
@@ -584,29 +588,29 @@ var Colorpicker = new Widget({
|
|
584
588
|
// updates the preview and pointer positions
|
585
589
|
update: function() {
|
586
590
|
this.field._.style.backgroundColor = 'rgb('+ this.tint.map(function(c) { return Math.round(c*255); }) +')';
|
587
|
-
|
591
|
+
|
588
592
|
// updating the input fields
|
589
593
|
var color = this.color, controls = this.controls;
|
590
|
-
|
594
|
+
|
591
595
|
controls.preview._.style.backgroundColor = controls.display._.value = this.toHex();
|
592
|
-
|
596
|
+
|
593
597
|
controls.rDisplay._.value = color[0];
|
594
598
|
controls.gDisplay._.value = color[1];
|
595
599
|
controls.bDisplay._.value = color[2];
|
596
|
-
|
600
|
+
|
597
601
|
// adjusting the field pointer position
|
598
602
|
var pointer = this.field.pointer._.style,
|
599
603
|
field = this.field.size(),
|
600
604
|
top = field.y - this.bright * field.y - 2,
|
601
605
|
left = this.satur * field.x - 2;
|
602
|
-
|
606
|
+
|
603
607
|
pointer.top = this.bound(top, 0, field.y - 5) + 'px';
|
604
608
|
pointer.left = this.bound(left, 0, field.x - 5) + 'px';
|
605
|
-
|
609
|
+
|
606
610
|
// adjusting the ting pointer position
|
607
611
|
var tint = this.tint, position;
|
608
612
|
field = this.colors.size();
|
609
|
-
|
613
|
+
|
610
614
|
if (tint[1] == 0) { // the red-blue section
|
611
615
|
position = tint[0] == 1 ? tint[2] : (2 - tint[0]);
|
612
616
|
} else if (tint[0] == 0) { // the blue-green section
|
@@ -614,25 +618,25 @@ var Colorpicker = new Widget({
|
|
614
618
|
} else { // the green-red section
|
615
619
|
position = 4 + (tint[1] == 1 ? tint[0] : (2 - tint[1]));
|
616
620
|
}
|
617
|
-
|
621
|
+
|
618
622
|
position = position / 6 * field.y;
|
619
|
-
|
623
|
+
|
620
624
|
this.colors.pointer._.style.top = this.bound(position, 0, field.y - 4) + 'px';
|
621
|
-
|
625
|
+
|
622
626
|
// tracking the color change events
|
623
627
|
if (this.prevColor !== ''+this.color) {
|
624
|
-
this.fire('change', this.color);
|
628
|
+
this.fire('change', {value: this.color});
|
625
629
|
this.prevColor = ''+ this.color;
|
626
630
|
}
|
627
|
-
|
631
|
+
|
628
632
|
return this;
|
629
633
|
},
|
630
|
-
|
634
|
+
|
631
635
|
// recalculates the state after the input field changes
|
632
636
|
recalc: function(event) {
|
633
637
|
if (event) {
|
634
638
|
var field = event.target, value = field._.value, color = $A(this.color), changed=false;
|
635
|
-
|
639
|
+
|
636
640
|
if (field === this.controls.display && /#\w{6}/.test(value)) {
|
637
641
|
// using the hex values
|
638
642
|
changed = color = this.toColor(value);
|
@@ -641,27 +645,27 @@ var Colorpicker = new Widget({
|
|
641
645
|
color[field._.cIndex] = value;
|
642
646
|
changed = true;
|
643
647
|
}
|
644
|
-
|
648
|
+
|
645
649
|
if (changed) { this.setValue(color); }
|
646
|
-
|
650
|
+
|
647
651
|
} else {
|
648
652
|
this.tint2color();
|
649
653
|
}
|
650
|
-
|
654
|
+
|
651
655
|
return this;
|
652
656
|
},
|
653
|
-
|
657
|
+
|
654
658
|
// starts the mousemoves tracking
|
655
659
|
startTrack: function(event) {
|
656
660
|
this.stopTrack();
|
657
661
|
this.cancelTimer();
|
658
|
-
|
662
|
+
|
659
663
|
if (event.target === this.field.pointer) {
|
660
664
|
event.target = this.field;
|
661
665
|
} else if (event.target === this.colors.pointer) {
|
662
666
|
event.target = this.colors;
|
663
667
|
}
|
664
|
-
|
668
|
+
|
665
669
|
if (event.target === this.field || event.target === this.colors) {
|
666
670
|
event.stop();
|
667
671
|
Colorpicker.tracking = this;
|
@@ -669,41 +673,41 @@ var Colorpicker = new Widget({
|
|
669
673
|
this.trackMove(event); // jumping over there
|
670
674
|
}
|
671
675
|
},
|
672
|
-
|
676
|
+
|
673
677
|
// stops tracking the mousemoves
|
674
678
|
stopTrack: function() {
|
675
679
|
Colorpicker.tracking = false;
|
676
680
|
this.field.tracking = false;
|
677
681
|
this.colors.tracking = false;
|
678
682
|
},
|
679
|
-
|
683
|
+
|
680
684
|
// tracks the cursor moves over the fields
|
681
685
|
trackMove: function(event) {
|
682
686
|
var field, pos = event.position(), top, left;
|
683
|
-
|
687
|
+
|
684
688
|
if (this.field.tracking) {
|
685
689
|
field = this.field.dimensions();
|
686
690
|
} else if (this.colors.tracking) {
|
687
691
|
field = this.colors.dimensions();
|
688
692
|
}
|
689
|
-
|
693
|
+
|
690
694
|
if (field) {
|
691
695
|
top = this.bound(pos.y - field.top, 0, field.height);
|
692
696
|
left = this.bound(pos.x - field.left, 0, field.width);
|
693
|
-
|
697
|
+
|
694
698
|
if (this.field.tracking) {
|
695
699
|
this.satur = left / field.width;
|
696
700
|
this.bright = 1 - top / field.height;
|
697
|
-
|
701
|
+
|
698
702
|
} else if (this.colors.tracking) {
|
699
703
|
// preventing it from jumping to the top
|
700
704
|
if (top == field.height) { top = field.height - 0.1; }
|
701
|
-
|
705
|
+
|
702
706
|
var step = field.height / 6,
|
703
707
|
tint = this.tint = [0, 0, 0],
|
704
708
|
stright = top % step / step,
|
705
709
|
reverse = 1 - stright;
|
706
|
-
|
710
|
+
|
707
711
|
if (top < step) {
|
708
712
|
tint[0] = 1;
|
709
713
|
tint[2] = stright;
|
@@ -724,11 +728,11 @@ var Colorpicker = new Widget({
|
|
724
728
|
tint[0] = 1;
|
725
729
|
}
|
726
730
|
}
|
727
|
-
|
731
|
+
|
728
732
|
this.recalc().update();
|
729
733
|
}
|
730
734
|
},
|
731
|
-
|
735
|
+
|
732
736
|
cancelTimer: function(event) {
|
733
737
|
R(function() { // IE has a lack of sync in here
|
734
738
|
if (this._hide_delay) {
|
@@ -739,6 +743,7 @@ var Colorpicker = new Widget({
|
|
739
743
|
}
|
740
744
|
});
|
741
745
|
|
746
|
+
|
742
747
|
/**
|
743
748
|
* The colors field element
|
744
749
|
*
|
@@ -751,6 +756,7 @@ var Field = new Wrapper(Element, {
|
|
751
756
|
}
|
752
757
|
});
|
753
758
|
|
759
|
+
|
754
760
|
/**
|
755
761
|
* The tint picker block
|
756
762
|
*
|
@@ -763,6 +769,7 @@ var Colors = new Wrapper(Element, {
|
|
763
769
|
}
|
764
770
|
});
|
765
771
|
|
772
|
+
|
766
773
|
/**
|
767
774
|
* The controls block unit
|
768
775
|
*
|
@@ -784,8 +791,9 @@ var Controls = new Wrapper(Element, {
|
|
784
791
|
}
|
785
792
|
});
|
786
793
|
|
794
|
+
|
787
795
|
/**
|
788
|
-
* This module contains various caluculations logic for
|
796
|
+
* This module contains various caluculations logic for
|
789
797
|
* the Colorpicker widget
|
790
798
|
*
|
791
799
|
* Copyright (C) 2010 Nikolay Nemshilov
|
@@ -800,7 +808,7 @@ Colorpicker.include({
|
|
800
808
|
toRgb: function(color) {
|
801
809
|
return 'rgb('+ this.color.join(',') +')';
|
802
810
|
},
|
803
|
-
|
811
|
+
|
804
812
|
/**
|
805
813
|
* Converts the color to a HEX string value
|
806
814
|
*
|
@@ -810,7 +818,7 @@ Colorpicker.include({
|
|
810
818
|
toHex: function(color) {
|
811
819
|
return '#'+ this.color.map(function(c) { return (c < 16 ? '0' : '') + c.toString(16); }).join('');
|
812
820
|
},
|
813
|
-
|
821
|
+
|
814
822
|
/**
|
815
823
|
* Converts a string value into an Array of color
|
816
824
|
*
|
@@ -819,22 +827,22 @@ Colorpicker.include({
|
|
819
827
|
*/
|
820
828
|
toColor: function(in_value) {
|
821
829
|
var value = in_value.toLowerCase(), match;
|
822
|
-
|
830
|
+
|
823
831
|
if ((match = /rgb\((\d+),(\d+),(\d+)\)/.exec(value))) {
|
824
832
|
return [match[1], match[2], match[3]].map(parseInt);
|
825
|
-
|
833
|
+
|
826
834
|
} else if (/#[\da-f]+/.test(value)) {
|
827
835
|
// converting the shortified hex in to the full-length version
|
828
836
|
if ((match = /^#([\da-f])([\da-f])([\da-f])$/.exec(value))) {
|
829
837
|
value = '#'+match[1]+match[1]+match[2]+match[2]+match[3]+match[3];
|
830
838
|
}
|
831
|
-
|
839
|
+
|
832
840
|
if ((match = /#([\da-f]{2})([\da-f]{2})([\da-f]{2})/.exec(value))) {
|
833
841
|
return [match[1], match[2], match[3]].map(function(n) { return parseInt(n, 16); });
|
834
842
|
}
|
835
843
|
}
|
836
844
|
},
|
837
|
-
|
845
|
+
|
838
846
|
/**
|
839
847
|
* converts color into the tint, saturation and brightness values
|
840
848
|
*
|
@@ -843,19 +851,19 @@ Colorpicker.include({
|
|
843
851
|
color2tint: function() {
|
844
852
|
var color = $A(this.color).sort(function(a,b) { return a-b; }),
|
845
853
|
min = color[0], max = color[2];
|
846
|
-
|
854
|
+
|
847
855
|
this.bright = max / 255;
|
848
856
|
this.satur = 1 - min / (max || 1);
|
849
|
-
|
857
|
+
|
850
858
|
this.tint.each(function(value, i) {
|
851
859
|
this.tint[i] = ((!min && !max) || min == max) ? i == 0 ? 1 : 0 :
|
852
860
|
(this.color[i] - min) / (max - min);
|
853
861
|
return this.tint[i];
|
854
862
|
}, this);
|
855
|
-
|
863
|
+
|
856
864
|
return this;
|
857
865
|
},
|
858
|
-
|
866
|
+
|
859
867
|
/**
|
860
868
|
* Converts tint, saturation and brightness into the actual RGB color
|
861
869
|
*
|
@@ -863,15 +871,15 @@ Colorpicker.include({
|
|
863
871
|
*/
|
864
872
|
tint2color: function() {
|
865
873
|
var tint = this.tint, color = this.color;
|
866
|
-
|
874
|
+
|
867
875
|
for (var i=0; i < 3; i++) {
|
868
876
|
color[i] = 1 + this.satur * (tint[i] - 1);
|
869
877
|
color[i] = Math.round(255 * color[i] * this.bright);
|
870
878
|
}
|
871
|
-
|
879
|
+
|
872
880
|
return this;
|
873
881
|
},
|
874
|
-
|
882
|
+
|
875
883
|
/**
|
876
884
|
* bounds the value to the given limits
|
877
885
|
*
|
@@ -882,18 +890,19 @@ Colorpicker.include({
|
|
882
890
|
*/
|
883
891
|
bound: function(in_value, min, max) {
|
884
892
|
var value = in_value;
|
885
|
-
|
893
|
+
|
886
894
|
if (min < max) {
|
887
895
|
value = value < min ? min : value > max ? max : value;
|
888
896
|
} else {
|
889
897
|
if (value > max) { value = max; }
|
890
898
|
if (value < min) { value = min; }
|
891
899
|
}
|
892
|
-
|
900
|
+
|
893
901
|
return value;
|
894
902
|
}
|
895
903
|
});
|
896
904
|
|
905
|
+
|
897
906
|
/**
|
898
907
|
* The document level hooks for colorpicker
|
899
908
|
*
|
@@ -905,27 +914,27 @@ $(document).on({
|
|
905
914
|
Colorpicker.tracking.stopTrack();
|
906
915
|
}
|
907
916
|
},
|
908
|
-
|
917
|
+
|
909
918
|
mousemove: function(event) {
|
910
919
|
if (Colorpicker.tracking) {
|
911
920
|
Colorpicker.tracking.trackMove(event);
|
912
921
|
}
|
913
922
|
},
|
914
|
-
|
923
|
+
|
915
924
|
focus: function(event) {
|
916
925
|
var target = event.target instanceof Input ? event.target : null;
|
917
|
-
|
926
|
+
|
918
927
|
Colorpicker.hideAll();
|
919
|
-
|
928
|
+
|
920
929
|
if (target && (target.colorpicker || target.match(Colorpicker.Options.cssRule))) {
|
921
930
|
(target.colorpicker || new Colorpicker({update: target}))
|
922
931
|
.setValue(target.value()).showAt(target);
|
923
932
|
}
|
924
933
|
},
|
925
|
-
|
934
|
+
|
926
935
|
blur: function(event) {
|
927
936
|
var target = event.target, colorpicker = target.colorpicker;
|
928
|
-
|
937
|
+
|
929
938
|
if (colorpicker) {
|
930
939
|
// we use the delay so it didn't get hidden when the user clicks the calendar itself
|
931
940
|
colorpicker._hide_delay = R(function() {
|
@@ -933,10 +942,10 @@ $(document).on({
|
|
933
942
|
}).delay(200);
|
934
943
|
}
|
935
944
|
},
|
936
|
-
|
945
|
+
|
937
946
|
click: function(event) {
|
938
947
|
var target = (event.target instanceof Element) ? event.target : null;
|
939
|
-
|
948
|
+
|
940
949
|
if (target && (target.colorpicker || target.match(Colorpicker.Options.cssRule))) {
|
941
950
|
if (!(target instanceof Input)) {
|
942
951
|
event.stop();
|
@@ -947,13 +956,13 @@ $(document).on({
|
|
947
956
|
Colorpicker.hideAll();
|
948
957
|
}
|
949
958
|
},
|
950
|
-
|
959
|
+
|
951
960
|
keydown: function(event) {
|
952
961
|
var colorpicker = Colorpicker.current, name = ({
|
953
962
|
27: 'hide', // Escape
|
954
963
|
13: 'done' // Enter
|
955
964
|
})[event.keyCode];
|
956
|
-
|
965
|
+
|
957
966
|
if (name && colorpicker && colorpicker.visible()) {
|
958
967
|
event.stop();
|
959
968
|
colorpicker[name]();
|
@@ -961,7 +970,8 @@ $(document).on({
|
|
961
970
|
}
|
962
971
|
});
|
963
972
|
|
973
|
+
|
964
974
|
document.write("<style type=\"text/css\"> *.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(/images/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}</style>");
|
965
975
|
|
966
976
|
return Colorpicker;
|
967
|
-
})(document, Math, parseInt, RightJS);
|
977
|
+
})(document, Math, parseInt, RightJS);
|