right-rails 0.6.0 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG +8 -0
- data/README.rdoc +71 -0
- data/Rakefile +144 -14
- data/generators/right_rails/right_rails_generator.rb +18 -21
- data/init.rb +11 -32
- data/lib/generators/right_rails/right_rails_generator.rb +27 -0
- data/lib/generators/right_rails/templates/iframed.html.erb +10 -0
- data/lib/right-rails.rb +1 -1
- data/lib/right_rails/config.rb +278 -0
- data/lib/right_rails/controller_extensions.rb +10 -5
- data/lib/right_rails/helpers/basic.rb +10 -66
- data/lib/right_rails/helpers/forms.rb +141 -139
- data/lib/right_rails/helpers/misc.rb +45 -67
- data/lib/right_rails/helpers/rails.rb +40 -105
- data/lib/right_rails/helpers.rb +364 -1
- data/lib/right_rails/java_script_generator.rb +34 -24
- data/lib/right_rails.rb +6 -1
- data/{images → public/images}/colorpicker.png +0 -0
- data/{images → public/images}/resizable.png +0 -0
- data/public/javascripts/right/autocompleter-src.js +612 -0
- data/public/javascripts/right/autocompleter.js +18 -0
- data/public/javascripts/right/calendar-src.js +1448 -0
- data/public/javascripts/right/calendar.js +36 -0
- data/public/javascripts/right/colorpicker-src.js +967 -0
- data/public/javascripts/right/colorpicker.js +26 -0
- data/{javascripts/right-dnd-src.js → public/javascripts/right/dnd-src.js} +86 -52
- data/public/javascripts/right/dnd.js +20 -0
- data/{javascripts/right-effects-src.js → public/javascripts/right/effects-src.js} +90 -45
- data/public/javascripts/right/effects.js +17 -0
- data/{javascripts/right-ui-i18n-de.js → public/javascripts/right/i18n/de.js} +7 -7
- data/{javascripts/right-ui-i18n-en-us.js → public/javascripts/right/i18n/en-us.js} +1 -1
- data/{javascripts/right-ui-i18n-es.js → public/javascripts/right/i18n/es.js} +7 -7
- data/{javascripts/right-ui-i18n-fr.js → public/javascripts/right/i18n/fr.js} +7 -7
- data/{javascripts/right-ui-i18n-hu.js → public/javascripts/right/i18n/hu.js} +7 -7
- data/{javascripts/right-ui-i18n-jp.js → public/javascripts/right/i18n/jp.js} +7 -7
- data/{javascripts/right-ui-i18n-nl.js → public/javascripts/right/i18n/nl.js} +7 -7
- data/{javascripts/right-ui-i18n-pt-br.js → public/javascripts/right/i18n/pt-br.js} +7 -7
- data/{javascripts/right-ui-i18n-ru.js → public/javascripts/right/i18n/ru.js} +7 -7
- data/{javascripts/right-ui-i18n-ua.js → public/javascripts/right/i18n/ua.js} +17 -12
- data/public/javascripts/right/in-edit-src.js +352 -0
- data/public/javascripts/right/in-edit.js +13 -0
- data/public/javascripts/right/json-src.js +160 -0
- data/public/javascripts/right/json.js +10 -0
- data/public/javascripts/right/lightbox-src.js +881 -0
- data/public/javascripts/right/lightbox.js +24 -0
- data/{javascripts/right-rails-src.js → public/javascripts/right/rails-src.js} +195 -171
- data/public/javascripts/right/rails.js +14 -0
- data/public/javascripts/right/rater-src.js +366 -0
- data/public/javascripts/right/rater.js +13 -0
- data/public/javascripts/right/resizable-src.js +420 -0
- data/public/javascripts/right/resizable.js +15 -0
- data/public/javascripts/right/selectable-src.js +687 -0
- data/public/javascripts/right/selectable.js +22 -0
- data/public/javascripts/right/slider-src.js +377 -0
- data/public/javascripts/right/slider.js +14 -0
- data/public/javascripts/right/sortable-src.js +392 -0
- data/public/javascripts/right/sortable.js +16 -0
- data/public/javascripts/right/tabs-src.js +1123 -0
- data/public/javascripts/right/tabs.js +29 -0
- data/public/javascripts/right/tooltip-src.js +307 -0
- data/public/javascripts/right/tooltip.js +12 -0
- data/public/javascripts/right/uploader-src.js +283 -0
- data/public/javascripts/right/uploader.js +13 -0
- data/{javascripts → public/javascripts}/right-olds-src.js +134 -186
- data/public/javascripts/right-olds.js +18 -0
- data/public/javascripts/right-safe-src.js +161 -0
- data/public/javascripts/right-safe.js +8 -0
- data/{javascripts → public/javascripts}/right-src.js +2558 -1750
- data/public/javascripts/right.js +92 -0
- data/spec/lib/right_rails/config_spec.rb +133 -0
- data/spec/lib/right_rails/controller_extensions_spec.rb +1 -1
- data/spec/lib/right_rails/helpers/basic_spec.rb +77 -66
- data/spec/lib/right_rails/helpers/forms_spec.rb +231 -33
- data/spec/lib/right_rails/helpers/misc_spec.rb +94 -26
- data/spec/lib/right_rails/helpers/rails_spec.rb +42 -7
- data/spec/lib/right_rails/helpers_spec.rb +125 -0
- data/spec/lib/right_rails/java_script_generator_spec.rb +30 -0
- data/spec/rcov.opts +3 -0
- data/spec/spec_helper.rb +12 -7
- metadata +70 -61
- data/README.textile +0 -69
- data/javascripts/right-autocompleter-src.js +0 -318
- data/javascripts/right-autocompleter.js +0 -9
- data/javascripts/right-behavior-src.js +0 -261
- data/javascripts/right-behavior.js +0 -8
- data/javascripts/right-calendar-src.js +0 -946
- data/javascripts/right-calendar.js +0 -9
- data/javascripts/right-colorpicker-src.js +0 -635
- data/javascripts/right-colorpicker.js +0 -9
- data/javascripts/right-dnd.js +0 -9
- data/javascripts/right-effects.js +0 -6
- data/javascripts/right-events-src.js +0 -321
- data/javascripts/right-events.js +0 -6
- data/javascripts/right-in-edit-src.js +0 -194
- data/javascripts/right-in-edit.js +0 -6
- data/javascripts/right-json-src.js +0 -141
- data/javascripts/right-json.js +0 -6
- data/javascripts/right-lightbox-src.js +0 -651
- data/javascripts/right-lightbox.js +0 -9
- data/javascripts/right-olds.js +0 -9
- data/javascripts/right-rails.js +0 -9
- data/javascripts/right-rater-src.js +0 -253
- data/javascripts/right-rater.js +0 -9
- data/javascripts/right-resizable-src.js +0 -336
- data/javascripts/right-resizable.js +0 -9
- data/javascripts/right-selectable-src.js +0 -565
- data/javascripts/right-selectable.js +0 -7
- data/javascripts/right-slider-src.js +0 -288
- data/javascripts/right-slider.js +0 -7
- data/javascripts/right-sortable-src.js +0 -225
- data/javascripts/right-sortable.js +0 -9
- data/javascripts/right-tabs-src.js +0 -937
- data/javascripts/right-tabs.js +0 -6
- data/javascripts/right-tooltips-src.js +0 -195
- data/javascripts/right-tooltips.js +0 -9
- data/javascripts/right-uploader-src.js +0 -167
- data/javascripts/right-uploader.js +0 -9
- data/javascripts/right.js +0 -7
@@ -1,9 +0,0 @@
|
|
1
|
-
/**
|
2
|
-
* The calendar widget implemented with RightJS
|
3
|
-
*
|
4
|
-
* Home page: http://rightjs.org/ui/calendar
|
5
|
-
*
|
6
|
-
* @copyright (C) 2009-2010 Nikolay V. Nemshilov
|
7
|
-
*/
|
8
|
-
if (!RightJS) { throw "Gimme RightJS. Please." };
|
9
|
-
eval((function(s,d){for(var i=d.length-1;i>-1;i--)if(d[i])s=s.replace(new RegExp(i,'g'),d[i]);return s})("19 28=68 Class(Observer,{extend:{EVENTS:$w('show 94 44 95'),169:{67:'ISO',101:70,178:false,min47:70,max47:70,138184:1,fx185:'fade',129:200,53:1,36:1,43:70,134:false,94OnPick:false,179:'[rel^=14]'},Formats:{ISO:'%Y-%m-%d',POSIX:'%Y/%m/%d',EUR:'%d-%m-%Y',US:'%m/%d/%Y'},57:{Done:'Done',Now:'Now',182:'182 173',186:'186ious 173',182180:'182 180',186180:'186ious 180',89:$w('Sun117 Mon117 Tues117 Wednes117 Thurs117 Fri117 Satur117'),89183:$w('Sun Mon Tue Wed Thu Fri Sat'),89Min:$w('Su Mo Tu We Th Fr Sa'),65181:$w('January February March April May June July August September October November December'),65181183:$w('Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec')},63:70,137:{},find:16(a){19 e=a.target;if(isElement(e)&&e.136(28.169.179)){19 u=$uid(e);21 28.137[u]=28.137[u]||68 28(eval('('+e.get('data-14-25')+')'))}},rescan:16(s){}},initialize:16(o){11.$super(o);11.31=$E('29',{'72':'17-14',14:11});11.build().150().set47(68 47())},set169:16(u){11.$super(u);19 a=11.constructor;19 o=11.25;with(11.25){o.57={};151(19 k in a.57)57[k]=isArray(a.57[k])?a.57[k].clone():a.57[k];$ext(57,(u||{}).57);o.89=57.89Min;if(138184)89.push(89.111());if(!isArray(53))53=[53,1];if(min47)min47=11.125(min47);if(max47){max47=11.125(max47);max47.set47(max47.get47()+1)}67=(a.Formats[67]||67).trim();if(101===70)101=67.search(/%[HkIl]/)>-1;if(43===70)43=67.search(/%[Il]/)<0;if(36>60&&12 %(36/60).139())43=162}21 11},set47:16(d){11.41=11.16347=11.125(d);21 11.up41()},get47:16(){21 11.41},94:16(){11.31.94(11.25.fx185,{duration:11.25.129});28.63=70;21 11},show:16(p){11.31.show(11.25.fx185,{duration:11.25.129});21 28.63=11},35:16(e,p){11.31.92('17-14-84').35(e,p);21 11},84d:16(){21 11.31.126('17-14-84')}});28.133({up41:16(d){19 d=68 47(d||11.41),o=11.25;19 a=11.31.44('29.17-14-65');19 b=a.length;151(19 i=-(b-b/2).139()+1;i<(b-b/2).floor()+1;i++){19 m=68 47(d);m.78(d.62()+i);11.up41173(a.111(),m)}11.up41182186173187s(d,b);if(o.101){11.100.75=o.36<60?d.159():(d.159()/(o.36/60)).round()*(o.36/60);11.114.75=(d.getMinutes()/(o.36 % 60)).round()*o.36}21 11},up41173:16(g,d){d.set47(32);19 f=32-d.get47();d.78(d.62()-1);19 b=(11.41.164()/86400000).139();19 r=g.44('74 tr');19 a=r.111().44('td');g.44('74 td').145(16(t){t.143='';t.72185='17-14-117-blank'});19 o=11.25;151(19 i=1;i<=f;i++){d.set47(i);19 e=d.get184();if(11.25.138184)e=e?e-1:6;a[e].143=''+i;a[e].72185=b==(d.164()/86400000).139()?'17-14-117-44ed':'';if((o.min47&&o.min47>d)||(o.max47&&o.max47<d))a[e].72185='17-14-117-61';a[e].41=68 47(d);if(e==6)a=r.111().44('td')}19 c=(o.134?o.57.65181183[d.62()]+',':o.57.65181[d.62()])+' '+d.81();g.138('29.17-14-65-177').up41(c)},up41182186173187s:16(a,f){19 o=11.25;if(o.min47){19 b=68 47(a.81(),0,1,0,0,0);19 c=68 47(o.min47.81(),0,1,0,0,0);11.124=b>c;b.78(a.62()-(f-f/2).139());c.78(o.min47.62());11.118=b>=c}93 11.118=11.124=162;if(o.max47){19 e=68 47(a);19 m=68 47(o.max47);[e,m].145(16(d){d.set47(32);d.78(d.62()-1);d.set47(32-d.get47());d.setHours(0);d.setMinutes(0);d.setSeconds(0);d.setMilliseconds(0)});11.119=e<m;[e,m].145('78',0);11.120=e<m}93 11.119=11.120=162;11.106[11.119?'82':'92']('17-ui-26-61');11.107[11.118?'82':'92']('17-ui-26-61');if(11.69){11.69[11.120?'82':'92']('17-ui-26-61');11.103[11.124?'82':'92']('17-ui-26-61')}},build:16(){11.buildSwaps();19 g=74=$E('42',{'72':'17-14-168'}).35(11.31);19 o=11.25;if(Browser.OLD)74=$E('74').35(g);151(19 y=0;y<o.53[1];y++){19 r=$E('tr').35(74);151(19 x=0;x<o.53[0];x++)$E('td').35(r).97(11.build173())}if(o.101)11.buildTime();11.160();21 11},buildSwaps:16(){19 i=11.25.57;11.107=$E('29',{'72':'17-ui-26 17-14-163-26',87:'‹',167:i.186}).35(11.31);11.106=$E('29',{'72':'17-ui-26 17-14-140-26',87:'›',167:i.182}).35(11.31);if(11.25.134){11.103=$E('29',{'72':'17-ui-26 17-14-163-141-26',87:'«',167:i.186180}).35(11.107,'after');11.69=$E('29',{'72':'17-ui-26 17-14-140-141-26',87:'»',167:i.182180}).35(11.106,'be151e')}},build173:16(){21 $E('29',{'72':'17-14-65'}).97('<29 72=\"17-14-65-177\"></29>'+'<42><thead><tr>'+11.25.89.map(16(n){21 '<th>'+n+'</th>'}).join('')+'</tr></thead><74>'+'123456'.146('').map(16(){21 '<tr><td><td><td><td><td><td><td></tr>'}).join('')+'</74></42>')},buildTime:16(){19 o=11.25;19 t=$E('29',{'72':'17-14-time',87:':'}).35(11.31);11.100=$E('44').35(t,'113');11.114=$E('44').35(t);19 m=o.36<60?o.36:60;19 h=o.36<60?1:(o.36/60).139();(60).times(16(a){19 c=(a<10?'0':'')+a;if(a<24&&a % h==0){if(o.43)11.100.97($E('154',{75:a,87:c}));93 if(a<12)11.100.97($E('154',{75:a,87:a==0?12:a}))}if(a % m==0)11.114.97($E('154',{75:a,87:c}))},11);if(!o.43){11.121=$E('44').35(t);(o.67.133s(/%P/)?['am','pm']:['AM','PM']).145(16(v){11.121.97($E('154',{75:v.98(),87:v}))},11)}},160:16(){if(!11.25.178)21;11.116=$E('29',{'72':'17-ui-26 17-14-now-26',87:11.25.57.Now});11.95187=$E('29',{'72':'17-ui-26 17-14-95-26',87:11.25.57.Done});$E('29',{'72':'17-ui-26s 17-14-26s'}).97([11.95187,11.116]).35(11.31)}});28.133({44:16(d){11.fire('44',11.41=d);if(11.25.94OnPick)11.95();21 11},95:16(){if(!11.84d())11.94();21 11.fire('95',11.41)},140184:16(){21 11.change47({'47':1})},163184:16(){21 11.change47({'47':-1})},140Week:16(){21 11.change47({'47':7})},163Week:16(){21 11.change47({'47':-7})},135:16(){21 11.change47({173:1})},144:16(){21 11.change47({173:-1})},140180:16(){21 11.change47({Full180:1})},163180:16(){21 11.change47({Full180:-1})},change47:16(h){19 d=68 47(11.41),o=11.25;151(19 k in h)d['set'+k](d['get'+k]()+h[k]);if(o.min47&&o.min47>d)d=68 47(o.min47);if(o.max47&&o.max47<d){d=68 47(o.max47);d.set47(d.get47()-1)}21 11.up41(11.41=d)},150:16(){11.107.71(11.144.58(11));11.106.71(11.135.58(11));if(11.69){11.103.71(11.163180.58(11));11.69.71(11.140180.58(11))}11.31.44('29.17-14-65 42 74 td').145(16(c){c.71(16(){if(c.143!=''&&!c.126('17-14-117-61')){19 p=11.31.138('.17-14-117-44ed');if(p)p.82('17-14-117-44ed');c.92('17-14-117-44ed');11.115(c.41)}}.58(11))},11);if(11.100){11.100.157(11.115.58(11));11.114.157(11.115.58(11));if(!11.25.43)11.121.157(11.115.58(11))}if(11.116){11.116.71(11.set47.58(11,68 47()));11.95187.71(11.95.58(11))}11.31.onMousedown(16(a){a.s113Propagation()}).71(16(e){e.s113();if(11.175){11.175.cancel();11.175=70}}.58(11));21 11},115:16(d){if(d instanceof 47){11.41.set180(d.81());11.41.78(d.62());11.41.set47(d.get47())}if(11.100){11.41.setHours(11.100.75.toInt()+(!11.25.43&&11.121.75=='pm'?12:0));11.41.setMinutes(11.114.75)}21 11.44(11.41)}});28.133({assignTo:16(i,t){19 i=$(i),t=$(t);if(t)t.71(16(a){a.s113();11.110(i.focus())}.58(11));93 i.on({focus:11.110.58(11,i),click:16(a){a.s113();if(11.31.hidden())11.110(i)}.58(11),keyDown:16(a){if(a.keyCode==9&&11.31.visible())11.94()}.58(11)});21 11},110:16(e){19 e=$(e),d=e.dimensions();11.set47(11.125(e.75));11.31.setStyle({90:'122',109:'0',left:(d.left)+'px',113:(d.113+d.96)+'px'}).35(79.body);11.s113Observing('44').s113Observing('95');11.on(11.95187?'95':'44',16(){e.75=11.67()}.58(11));21 11.94Others().show()},toggleAt:16(i){if(11.31.parentNode&&11.31.visible())11.94();93 11.110(i);21 11},94Others:16(){$$('29.17-14').145(16(e){if(!e.126('17-14-84')){if(e!=11.31)e.94()}});21 11}});28.133({125:16(g){19 d;if(isString(g)&&g){19 t=RegExp.escape(11.25.67);19 h=t.136(/%[a-z]/ig).map('136',/[a-z]$/i).map('138').without('%');19 r=68 RegExp('^'+t.171(/%p/i,'(pm|PM|am|AM)').171(/(%[a-z])/ig,'(.+?)')+'$');19 m=g.trim().136(r);if(m){m.111();19 y=70,f=70,d=70,b=70,e=70,s=70,c;while(m.length){19 v=m.111();19 k=h.111();if(k.98()=='b')f=11.25.57[k=='b'?'65181183':'65181'].indexOf(v);93 if(k.98()=='p')c=v.98();93{v=v.toInt();switch(k){52 'd':52 'e':d=v;59;52 'm':f=v-1;59;52 'y':52 'Y':y=v;59;52 'H':52 'k':52 'I':52 'l':b=v;59;52 'M':e=v;59;52 'S':s=v;59}}}if(c){b=b==12?0:b;b=(c=='pm'?b+12:b)}d=68 47(y,f,d,b,e,s)}}93 if(g instanceof 47||47.125(g))d=68 47(g);21(!d||isNaN(d.164()))?68 47:d},67:16(g){19 j=11.25.57;19 f=11.41.get184();19 q=11.41.62();19 c=11.41.get47();19 t=11.41.81();19 h=11.41.159();19 o=11.41.getMinutes();19 s=11.41.getSeconds();19 i=(h==0?12:h<13?h:h-12);19 v={a:j.89183[f],A:j.89[f],b:j.65181183[q],B:j.65181[q],d:(c<10?'0':'')+c,e:''+c,m:(q<9?'0':'')+(q+1),y:(''+t).substring(2,4),Y:''+t,H:(h<10?'0':'')+h,k:''+h,I:(h>0&&(h<10||(h>12&&h<22))?'0':'')+i,l:''+i,p:h<12?'AM':'PM',P:h<12?'am':'pm',M:(o<10?'0':'')+o,S:(s<10?'0':'')+s,'%':'%'};19 r=g||11.25.67;151(19 n in v)r=r.171('%'+n,v[n]);21 r}});(16(){19 s=16(e){19 c=28.find(Event.ext(e));if(c&&28.63!=c){19 i=e.target;19 b=28.169.179.146('[').last();19 k=b.146('=').last().146(']').138();19 a=68 RegExp(k+'\\\\[(.+?)\\\\]');19 r=i.get(b.146('^=')[0]);if(r&&(r=r.136(a))){i=$(r[1]);e.s113()}c.110(i)}};19 h=16(e){s(e)};19 d=16(e){19 t=e.target;if(28.find(e)){if(t.tag185=='A')e.s113()}93 if(28.63){if(![t].concat(t.parents()).138('126','17-14'))28.63.94()}};19 f=16(e){s(e)};19 o=16(e){19 c=28.find(Event.ext(e));if(c)c.175=(16(){11.94()}.58(c)).delay(200)};19 g=16(e){if(28.63){19 n;switch(e.keyCode){52 27:n='94';59;52 37:n='163184';59;52 39:n='140184';59;52 38:n='163Week';59;52 40:n='140Week';59;52 34:n='135';59;52 33:n='144';59;52 13:28.63.44(28.63.41);n='95';59}if(n){28.63[n]();e.s113()}}};79.on({mousedown:h,click:d,keydown:g});if(Browser.IE){79.170('onfocusin',f);79.170('onfocusout',o)}93{79.128('focus',f,162);79.128('blur',o,162)}})();79.write(\"<style type=\\\"147/css\\\">29.17-14,29.17-14 42,29.17-14 42 tr,29.17-14 42 th,29.17-14 42 td,29.17-14 42 74,29.17-14 42 thead{48:161;30:161;width:auto;96:auto;109:0;73:0}*.17-ui-26{130:84-block;*130:84;*zoom:1;96:1em;line-96:1em;73:.85 .176;147-108:153;30:1px 166 #172;30-80:.85;-moz-30-80:.85;-127-30-80:.85;112:pointer;46:#555;48-46:#FFF}*.17-ui-26:hover{46:#222;30-46:#999;48-46:#172}*.17-ui-26-61,*.17-ui-26-61:hover{46:#888;48:#EEE;30-46:#172;112:132}*.17-ui-26s{109-113:.176}29.17-14{90:122;96:auto;30:1px 166 #BBB;90:relative;73:.176;30-80:.3em;-moz-30-80:.3em;-127-30-80:.3em;112:132;48-46:#EEE;-moz-box-149:.85 .4em .8em #666;-127-box-149:.85 .4em .8em #666}29.17-14-84{90:relative;130:84-block;vertical-108:113;*130:84;*zoom:1;-moz-box-149:161;-127-box-149:161}29.17-14-163-26,29.17-14-140-26,29.17-14-163-141-26,29.17-14-140-141-26{90:122;float:left;width:1em;73:.1176 .4em}29.17-14-140-26{17:.176}29.17-14-163-141-26{left:2.5176}29.17-14-140-141-26{17:2.5176}29.17-14-65-177{147-108:153;96:1.85;line-96:1.85}42.17-14-168{30-spacing:0px}42.17-14-168 td{vertical-108:113;73-17:.4em}42.17-14-168>74>td:last-child{73:0}29.17-14-65 42{109-113:.85;30-spacing:1px;30-collapse:separate}29.17-14-65 42 th{46:#777;147-108:153}29.17-14-65 42 td{147-108:17;73:.1em .3em;48-46:#FFF;30:1px 166 #172;112:pointer;46:#555;30-80:.85;-moz-30-80:.85;-127-30-80:.85}29.17-14-65 42 td:hover{48-46:#172;30-46:#AAA;46:#000}29.17-14-65 42 td.17-14-117-blank{48:transparent;112:132;30:161}29.17-14-65 42 td.17-14-117-44ed{48-46:#BBB;30-46:#AAA;46:#222;font-weight:bold;73:.1em .85}29.17-14-65 42 td.17-14-117-61{46:#888;48:#EEE;30-46:#172;112:132}29.17-14-time{30-113:1px 166 #ccc;109-113:.3em;73-113:.176;147-108:153}29.17-14-time 44{109:0 .4em}29.17-14-26s 29.17-ui-26{width:3.85}29.17-14-95-26{90:122;17:.176}</style>\");",",,,,,,,,,,,this,,,calendar,,function,right,,var,,return,,,,options,button,,Calendar,div,border,element,,,,insertTo,timePeriod,,,,,date,table,twentyFourHour,select,,color,Date,background,maxDate,changeDate,minDate,case,numberOfMonths,setDate,,,i18n,bind,break,,disabled,getMonth,current,,month,,format,new,nextYearButton,null,onClick,class,padding,tbody,value,monthNamesShort,,setMonth,document,radius,getFullYear,removeClass,getDate,inline,2em,,html,,dayNames,position,updateNextPrevMonthButtons,addClass,else,hide,done,height,insert,toLowerCase,,hours,showTime,selected,prevYearButton,doneButton,monthNames,nextButton,prevButton,align,margin,showAt,shift,cursor,top,minutes,setTime,nowButton,day,hasPrevMonth,hasNextMonth,hasNextYear,meridian,absolute,,hasPrevYear,parse,hasClass,webkit,addEventListener,fxDuration,display,buttons,default,include,listYears,nextMonth,match,instances,first,ceil,next,year,stop,innerHTML,prevMonth,each,split,text,className,shadow,connectEvents,for,update,center,option,dayNamesShort,stopObserving,onChange,firstDay,getHours,buildButtons,none,true,prev,getTime,updateMonth,solid,title,greed,Options,attachEvent,replace,CCC,Month,dayNamesMin,timer,5em,caption,showButtons,cssRule,Year,Names,Next,Short,Day,Name,Prev,Button".split(",")));
|
@@ -1,635 +0,0 @@
|
|
1
|
-
/**
|
2
|
-
* RightJS UI Colorpicker widget
|
3
|
-
*
|
4
|
-
* See http://rightjs.org/ui/colorpicker
|
5
|
-
*
|
6
|
-
* Copyright (C) 2010 Nikolay Nemshilov
|
7
|
-
*/
|
8
|
-
if (!self.RightJS) throw "Gimme RightJS";
|
9
|
-
/**
|
10
|
-
* The basic file for Colorpicker
|
11
|
-
*
|
12
|
-
* Copyright (C) 2010 Nikolay Nemshilov
|
13
|
-
*/
|
14
|
-
var Colorpicker = new Class(Observer, {
|
15
|
-
extend: {
|
16
|
-
EVENTS: $w('change show hide done'),
|
17
|
-
|
18
|
-
Options: {
|
19
|
-
format: 'hex', // hex or rgb
|
20
|
-
|
21
|
-
update: null, // an element to update with the color text
|
22
|
-
updateBg: null, // an element to update it's background color
|
23
|
-
|
24
|
-
fxName: 'fade', // popup displaying fx
|
25
|
-
fxDuration: 'short',
|
26
|
-
|
27
|
-
cssRule: '*[rel^=colorpicker]'
|
28
|
-
},
|
29
|
-
|
30
|
-
i18n: {
|
31
|
-
Done: 'Done'
|
32
|
-
},
|
33
|
-
|
34
|
-
// builds or finds a colorpicker for the target element
|
35
|
-
find: function(element) {
|
36
|
-
var uid = $uid(element), instances = Colorpicker.instances;
|
37
|
-
|
38
|
-
if (!instances[uid]) {
|
39
|
-
var pick = instances[uid] = new Colorpicker(eval('('+ element.get('data-colorpicker-options') +')'));
|
40
|
-
|
41
|
-
if (element.tagName == 'INPUT')
|
42
|
-
pick.assignTo(element);
|
43
|
-
else {
|
44
|
-
var attr = Colorpicker.Options.cssRule.split('[').last().split('^=').first(),
|
45
|
-
match = /\[(.+?)\]/.exec(element.get(attr)), input;
|
46
|
-
|
47
|
-
if (match && (input = $(match[1]))) {
|
48
|
-
pick.assignTo(input, element);
|
49
|
-
}
|
50
|
-
}
|
51
|
-
}
|
52
|
-
|
53
|
-
return instances[uid];
|
54
|
-
},
|
55
|
-
|
56
|
-
instances: []
|
57
|
-
},
|
58
|
-
|
59
|
-
/**
|
60
|
-
* basic constructor
|
61
|
-
*
|
62
|
-
* @param Object options
|
63
|
-
*/
|
64
|
-
initialize: function(options) {
|
65
|
-
this.$super(options);
|
66
|
-
this.init();
|
67
|
-
},
|
68
|
-
|
69
|
-
/**
|
70
|
-
* Sets the color of the widget
|
71
|
-
*
|
72
|
-
* @param mixed value, Array or HEX or RGB value
|
73
|
-
* @return Colorpicker this
|
74
|
-
*/
|
75
|
-
setValue: function(value) {
|
76
|
-
var color = isArray(value) ? value : this.toColor(value);
|
77
|
-
if (color && color.length == 3) {
|
78
|
-
|
79
|
-
// normalizing the data
|
80
|
-
color = color.map(function(value) {
|
81
|
-
return this.bound((''+value).toInt(), 0, 255);
|
82
|
-
}, this);
|
83
|
-
|
84
|
-
this.color = color;
|
85
|
-
this.color2tint().update();
|
86
|
-
}
|
87
|
-
return this;
|
88
|
-
},
|
89
|
-
|
90
|
-
/**
|
91
|
-
* Returns the value of the widget
|
92
|
-
* formatted according to the options
|
93
|
-
*
|
94
|
-
* @param Boolean if you need a clean RGB values array
|
95
|
-
* @return mixed value
|
96
|
-
*/
|
97
|
-
getValue: function(array) {
|
98
|
-
return array ? this.color : this[this.options.format === 'rgb' ? 'toRgb' : 'toHex']();
|
99
|
-
},
|
100
|
-
|
101
|
-
/**
|
102
|
-
* Inlines the widget into the given element
|
103
|
-
*
|
104
|
-
* @param Element reference
|
105
|
-
* @param String optional position
|
106
|
-
* @return Colorpicker this
|
107
|
-
*/
|
108
|
-
insertTo: function(element, position) {
|
109
|
-
this.element
|
110
|
-
.addClass('right-colorpicker-inline')
|
111
|
-
.insertTo(element, position);
|
112
|
-
|
113
|
-
return this;
|
114
|
-
},
|
115
|
-
|
116
|
-
// protected
|
117
|
-
|
118
|
-
// initializes the widget
|
119
|
-
init: function() {
|
120
|
-
this.build();
|
121
|
-
|
122
|
-
// attaching the mouse-events to the fields
|
123
|
-
[this.field, this.colors].each(function(element) {
|
124
|
-
element.onMousedown(this.startTrack.bind(this));
|
125
|
-
}, this);
|
126
|
-
|
127
|
-
// tracking the changes on the input fields
|
128
|
-
[this.display, this.rDisplay, this.gDisplay, this.bDisplay].each('on', {
|
129
|
-
keyup: this.recalc.bind(this),
|
130
|
-
blur: this.update.bind(this),
|
131
|
-
focus: this.cancelTimer.bind(this)
|
132
|
-
});
|
133
|
-
|
134
|
-
// attaching the done button
|
135
|
-
this.button.onClick(this.fire.bind(this, 'done'));
|
136
|
-
|
137
|
-
// preventing the general body clicks
|
138
|
-
this.element.onMousedown(function(event) {
|
139
|
-
if (event.target.tagName !== 'INPUT') {
|
140
|
-
event.stop();
|
141
|
-
this.cancelTimer();
|
142
|
-
}
|
143
|
-
}.bind(this));
|
144
|
-
|
145
|
-
// attaching the picker own events
|
146
|
-
this
|
147
|
-
.onDone('hide')
|
148
|
-
.onChange(function(color) {
|
149
|
-
if (this.target) {
|
150
|
-
this.target[this.target.tagName == 'INPUT' ? 'value' : 'innerHTML'] =
|
151
|
-
this[this.options.format == 'rgb' ? 'toRgb' : 'toHex']();
|
152
|
-
}
|
153
|
-
}.bind(this));
|
154
|
-
|
155
|
-
// hooking up the elements to update
|
156
|
-
if (this.options.update) this.assignTo(this.options.update);
|
157
|
-
if (this.options.updateBg) this.updateBg(this.options.updateBg);
|
158
|
-
|
159
|
-
// setting up the initial value
|
160
|
-
// NOTE: to speed the things up a bit we use params
|
161
|
-
// for tint, saturation and brightness and
|
162
|
-
// normal RGB value to keep the current color
|
163
|
-
this.tint = [1, 0, 0];
|
164
|
-
this.satur = 0;
|
165
|
-
this.bright = 1;
|
166
|
-
this.color = [255, 255, 255];
|
167
|
-
|
168
|
-
this.recalc().update();
|
169
|
-
},
|
170
|
-
|
171
|
-
// builds the widget
|
172
|
-
build: function() {
|
173
|
-
var base = this.element = $E('div', {'class': 'right-colorpicker right-ui-panel'});
|
174
|
-
|
175
|
-
// the field block
|
176
|
-
this.field = $E('div', {'class': 'field'}).insertTo(base);
|
177
|
-
this.fieldPointer = $E('div', {'class': 'field-pointer'}).insertTo(this.field);
|
178
|
-
|
179
|
-
// the tint block
|
180
|
-
this.colors = $E('div', {'class': 'colors'}).insertTo(base);
|
181
|
-
this.colorsPointer = $E('div', {'class': 'colors-pointer'}).insertTo(this.colors);
|
182
|
-
|
183
|
-
// the controls block
|
184
|
-
$E('div', {'class': 'controls'}).insert([
|
185
|
-
this.preview = $E('div', {'class': 'preview', 'html': ' '}).insertTo(base),
|
186
|
-
this.display = $E('input', {'type': 'text', 'class': 'display', maxlength: 7}).insertTo(base),
|
187
|
-
$E('div', {'class': 'rgb-display'}).insert([
|
188
|
-
$E('div').insert([$E('label', {html: 'R:'}), this.rDisplay = $E('input', {maxlength: 3, cIndex: 0})]),
|
189
|
-
$E('div').insert([$E('label', {html: 'G:'}), this.gDisplay = $E('input', {maxlength: 3, cIndex: 1})]),
|
190
|
-
$E('div').insert([$E('label', {html: 'B:'}), this.bDisplay = $E('input', {maxlength: 3, cIndex: 2})])
|
191
|
-
]),
|
192
|
-
this.button = $E('input', {'type': 'button', 'class': 'right-ui-button', value: Colorpicker.i18n.Done})
|
193
|
-
]).insertTo(base);
|
194
|
-
},
|
195
|
-
|
196
|
-
// updates the preview and pointer positions
|
197
|
-
update: function() {
|
198
|
-
this.field.style.backgroundColor = 'rgb('+ this.tint.map(function(c) { return (c*255).round(); }) +')';
|
199
|
-
this.preview.style.backgroundColor = this.display.value = this.toHex();
|
200
|
-
|
201
|
-
// updating the input fields
|
202
|
-
var color = this.color;
|
203
|
-
this.rDisplay.value = color[0];
|
204
|
-
this.gDisplay.value = color[1];
|
205
|
-
this.bDisplay.value = color[2];
|
206
|
-
|
207
|
-
// adjusting the field pointer position
|
208
|
-
var pointer = this.fieldPointer.style,
|
209
|
-
field = this.field.sizes(),
|
210
|
-
top = field.y - this.bright * field.y - 2,
|
211
|
-
left = this.satur * field.x - 2;
|
212
|
-
|
213
|
-
pointer.top = this.bound(top, 0, field.y - 5) + 'px';
|
214
|
-
pointer.left = this.bound(left, 0, field.x - 5) + 'px';
|
215
|
-
|
216
|
-
// adjusting the ting pointer position
|
217
|
-
var field = this.colors.sizes(), tint = this.tint, position;
|
218
|
-
|
219
|
-
if (tint[1] == 0) { // the red-blue section
|
220
|
-
position = tint[0] == 1 ? tint[2] : (2 - tint[0]);
|
221
|
-
} else if (tint[0] == 0) { // the blue-green section
|
222
|
-
position = 2 + (tint[2] == 1 ? tint[1] : (2 - tint[2]));
|
223
|
-
} else { // the green-red section
|
224
|
-
position = 4 + (tint[1] == 1 ? tint[0] : (2 - tint[1]));
|
225
|
-
}
|
226
|
-
|
227
|
-
position = position / 6 * field.y;
|
228
|
-
|
229
|
-
this.colorsPointer.style.top = this.bound(position, 0, field.y - 4) + 'px';
|
230
|
-
|
231
|
-
// tracking the color change events
|
232
|
-
if (this.prevColor !== ''+this.color) {
|
233
|
-
this.fire('change', this.color);
|
234
|
-
this.prevColor = ''+ this.color;
|
235
|
-
}
|
236
|
-
|
237
|
-
return this;
|
238
|
-
},
|
239
|
-
|
240
|
-
// recalculates the state after the input field changes
|
241
|
-
recalc: function(event) {
|
242
|
-
if (event) {
|
243
|
-
var field = event.target, value = field.value, color = this.color.clone(), changed=false;
|
244
|
-
|
245
|
-
if (field == this.display && /#\w{6}/.test(value)) {
|
246
|
-
// using the hex values
|
247
|
-
changed = color = this.toColor(value);
|
248
|
-
} else if (/^\d+$/.test(value)) {
|
249
|
-
// using the rgb values
|
250
|
-
color[field.cIndex] = value;
|
251
|
-
changed = true;
|
252
|
-
}
|
253
|
-
|
254
|
-
if (changed) this.setValue(color);
|
255
|
-
|
256
|
-
} else {
|
257
|
-
this.tint2color();
|
258
|
-
}
|
259
|
-
|
260
|
-
return this;
|
261
|
-
},
|
262
|
-
|
263
|
-
// starts the mousemoves tracking
|
264
|
-
startTrack: function(event) {
|
265
|
-
event.stop();
|
266
|
-
this.stopTrack();
|
267
|
-
this.cancelTimer();
|
268
|
-
Colorpicker.tracking = this;
|
269
|
-
event.target.tracking = true;
|
270
|
-
this.trackMove(event); // jumping over there
|
271
|
-
},
|
272
|
-
|
273
|
-
// stops tracking the mousemoves
|
274
|
-
stopTrack: function() {
|
275
|
-
Colorpicker.tracking = false;
|
276
|
-
this.field.tracking = false;
|
277
|
-
this.colors.tracking = false;
|
278
|
-
},
|
279
|
-
|
280
|
-
// tracks the cursor moves over the fields
|
281
|
-
trackMove: function(event) {
|
282
|
-
var field, pos = event.position(), top, left;
|
283
|
-
|
284
|
-
if (this.field.tracking) {
|
285
|
-
field = this.field.dimensions();
|
286
|
-
} else if (this.colors.tracking) {
|
287
|
-
field = this.colors.dimensions();
|
288
|
-
}
|
289
|
-
|
290
|
-
if (field) {
|
291
|
-
top = this.bound(pos.y - field.top, 0, field.height);
|
292
|
-
left = this.bound(pos.x - field.left, 0, field.width);
|
293
|
-
|
294
|
-
if (this.field.tracking) {
|
295
|
-
this.satur = left / field.width;
|
296
|
-
this.bright = 1 - top / field.height;
|
297
|
-
|
298
|
-
} else if (this.colors.tracking) {
|
299
|
-
// preventing it from jumping to the top
|
300
|
-
if (top == field.height) top = field.height - 0.1;
|
301
|
-
|
302
|
-
var step = field.height / 6,
|
303
|
-
tint = this.tint = [0, 0, 0],
|
304
|
-
stright = top % step / step,
|
305
|
-
reverse = 1 - stright;
|
306
|
-
|
307
|
-
if (top < step) {
|
308
|
-
tint[0] = 1;
|
309
|
-
tint[2] = stright;
|
310
|
-
} else if (top < step * 2) {
|
311
|
-
tint[0] = reverse;
|
312
|
-
tint[2] = 1;
|
313
|
-
} else if (top < step * 3) {
|
314
|
-
tint[2] = 1;
|
315
|
-
tint[1] = stright;
|
316
|
-
} else if (top < step * 4) {
|
317
|
-
tint[2] = reverse;
|
318
|
-
tint[1] = 1;
|
319
|
-
} else if (top < step * 5) {
|
320
|
-
tint[1] = 1;
|
321
|
-
tint[0] = stright;
|
322
|
-
} else {
|
323
|
-
tint[1] = reverse;
|
324
|
-
tint[0] = 1;
|
325
|
-
}
|
326
|
-
}
|
327
|
-
|
328
|
-
this.recalc().update();
|
329
|
-
}
|
330
|
-
}
|
331
|
-
});
|
332
|
-
|
333
|
-
/**
|
334
|
-
* This module contains various caluculations logic for
|
335
|
-
* the Colorpicker widget
|
336
|
-
*
|
337
|
-
* Copyright (C) 2010 Nikolay Nemshilov
|
338
|
-
*/
|
339
|
-
Colorpicker.include({
|
340
|
-
/**
|
341
|
-
* Converts the color to a RGB string value
|
342
|
-
*
|
343
|
-
* @param Array optional color
|
344
|
-
* @return String RGB value
|
345
|
-
*/
|
346
|
-
toRgb: function(color) {
|
347
|
-
return 'rgb('+ this.color.join(',') +')';
|
348
|
-
},
|
349
|
-
|
350
|
-
/**
|
351
|
-
* Converts the color to a HEX string value
|
352
|
-
*
|
353
|
-
* @param Array optional color
|
354
|
-
* @return String HEX value
|
355
|
-
*/
|
356
|
-
toHex: function(color) {
|
357
|
-
return '#'+ this.color.map(function(c) { return (c < 16 ? '0' : '') + c.toString(16); }).join('');
|
358
|
-
},
|
359
|
-
|
360
|
-
/**
|
361
|
-
* Converts a string value into an Array of color
|
362
|
-
*
|
363
|
-
* @param String value
|
364
|
-
* @return Array of color or null
|
365
|
-
*/
|
366
|
-
toColor: function(in_value) {
|
367
|
-
var value = in_value.toLowerCase(), match;
|
368
|
-
|
369
|
-
if (match = /rgb\((\d+),(\d+),(\d+)\)/.exec(value)) {
|
370
|
-
return [match[1], match[2], match[3]].map('toInt');
|
371
|
-
|
372
|
-
} else if (/#[\da-f]+/.test(value)) {
|
373
|
-
// converting the shortified hex in to the full-length version
|
374
|
-
if (match = /^#([\da-f])([\da-f])([\da-f])$/.exec(value))
|
375
|
-
value = '#'+match[1]+match[1]+match[2]+match[2]+match[3]+match[3];
|
376
|
-
|
377
|
-
if (match = /#([\da-f]{2})([\da-f]{2})([\da-f]{2})/.exec(value)) {
|
378
|
-
return [match[1], match[2], match[3]].map('toInt', 16);
|
379
|
-
}
|
380
|
-
}
|
381
|
-
},
|
382
|
-
|
383
|
-
/**
|
384
|
-
* converts color into the tint, saturation and brightness values
|
385
|
-
*
|
386
|
-
* @return Colorpicker this
|
387
|
-
*/
|
388
|
-
color2tint: function() {
|
389
|
-
var color = this.color.clone().sort(function(a,b) { return a-b; }),
|
390
|
-
min = color[0], max = color[2];
|
391
|
-
|
392
|
-
this.bright = max / 255;
|
393
|
-
this.satur = 1 - min / (max || 1);
|
394
|
-
|
395
|
-
this.tint.each(function(value, i) {
|
396
|
-
return this.tint[i] = ((!min && !max) || min == max) ? i == 0 ? 1 : 0 :
|
397
|
-
(this.color[i] - min) / (max - min);
|
398
|
-
}, this);
|
399
|
-
|
400
|
-
return this;
|
401
|
-
},
|
402
|
-
|
403
|
-
/**
|
404
|
-
* Converts tint, saturation and brightness into the actual RGB color
|
405
|
-
*
|
406
|
-
* @return Colorpicker this
|
407
|
-
*/
|
408
|
-
tint2color: function() {
|
409
|
-
var tint = this.tint, color = this.color;
|
410
|
-
|
411
|
-
for (var i=0; i < 3; i++) {
|
412
|
-
color[i] = 1 + this.satur * (tint[i] - 1);
|
413
|
-
color[i] = (255 * color[i] * this.bright).round();
|
414
|
-
}
|
415
|
-
|
416
|
-
return this;
|
417
|
-
},
|
418
|
-
|
419
|
-
/**
|
420
|
-
* bounds the value to the given limits
|
421
|
-
*
|
422
|
-
* @param Number value
|
423
|
-
* @param Number min value
|
424
|
-
* @param Number max value
|
425
|
-
* @return Number the value in bounds
|
426
|
-
*/
|
427
|
-
bound: function(in_value, min, max) {
|
428
|
-
var value = in_value;
|
429
|
-
|
430
|
-
if (min < max) {
|
431
|
-
value = value < min ? min : value > max ? max : value;
|
432
|
-
} else {
|
433
|
-
if (value > max) value = max;
|
434
|
-
if (value < min) value = min;
|
435
|
-
}
|
436
|
-
|
437
|
-
return value;
|
438
|
-
}
|
439
|
-
});
|
440
|
-
|
441
|
-
/**
|
442
|
-
* This module handles the colorpicker assignments
|
443
|
-
* to input fields
|
444
|
-
*
|
445
|
-
* Copyright (C) 2010 Nikolay Nemshilov
|
446
|
-
*/
|
447
|
-
Colorpicker.include({
|
448
|
-
/**
|
449
|
-
* Hides the pop up element
|
450
|
-
*
|
451
|
-
* @return Colorpicker this
|
452
|
-
*/
|
453
|
-
hide: function() {
|
454
|
-
if (!this.element.hasClass('right-colorpicker-inline')) {
|
455
|
-
this.target = null;
|
456
|
-
Colorpicker.current = null;
|
457
|
-
this.element.hide(this.options.fxName, {
|
458
|
-
duration: this.options.fxDuration
|
459
|
-
});
|
460
|
-
|
461
|
-
this.fire('hide');
|
462
|
-
}
|
463
|
-
|
464
|
-
return this;
|
465
|
-
},
|
466
|
-
|
467
|
-
/**
|
468
|
-
* Shows the element as a popup
|
469
|
-
*
|
470
|
-
* @param Element where to show the popup
|
471
|
-
* @return Colorpicker this
|
472
|
-
*/
|
473
|
-
show: function(target) {
|
474
|
-
// moving into the target position
|
475
|
-
if (target) {
|
476
|
-
var element = $(target).dimensions(), style = this.element.style;
|
477
|
-
|
478
|
-
if (element) {
|
479
|
-
style.left = element.left + 'px';
|
480
|
-
style.top = element.top + element.height + 'px';
|
481
|
-
|
482
|
-
this.target = $(target);
|
483
|
-
}
|
484
|
-
}
|
485
|
-
|
486
|
-
// hide the others
|
487
|
-
if (Colorpicker.current && Colorpicker.current !== this) {
|
488
|
-
Colorpicker.current.element.hide();
|
489
|
-
}
|
490
|
-
|
491
|
-
this.element.insertTo(document.body);
|
492
|
-
|
493
|
-
if (!this.element.visible()) {
|
494
|
-
this.element.show(this.options.fxName, {
|
495
|
-
duration: this.options.fxDuration
|
496
|
-
});
|
497
|
-
|
498
|
-
this.fire('show');
|
499
|
-
}
|
500
|
-
|
501
|
-
if (this.target) {
|
502
|
-
this.setValue(this.target.value);
|
503
|
-
}
|
504
|
-
|
505
|
-
return Colorpicker.current = this;
|
506
|
-
},
|
507
|
-
|
508
|
-
/**
|
509
|
-
* Toggles the visibility status
|
510
|
-
*
|
511
|
-
* @param Element target
|
512
|
-
* @return Colorpicker this
|
513
|
-
*/
|
514
|
-
toggle: function(target) {
|
515
|
-
return this[this.element.visible() ? 'hide' : 'show'](target);
|
516
|
-
},
|
517
|
-
|
518
|
-
/**
|
519
|
-
* Assigns the colorpicer to work in pair with an input of a content element
|
520
|
-
*
|
521
|
-
* @param Element reference
|
522
|
-
* @param Element optional trigger element
|
523
|
-
* @return Colorpicker this
|
524
|
-
*/
|
525
|
-
assignTo: function(input, trigger) {
|
526
|
-
var input = $(input), trigger = $(trigger);
|
527
|
-
|
528
|
-
if (trigger) {
|
529
|
-
trigger.onClick(function(e) {
|
530
|
-
e.stop();
|
531
|
-
this.toggle(input.focus());
|
532
|
-
}.bind(this));
|
533
|
-
} else {
|
534
|
-
input.onFocus(this.show.bind(this, input));
|
535
|
-
}
|
536
|
-
|
537
|
-
input.on({
|
538
|
-
blur: function() {
|
539
|
-
this.timer = (function() {
|
540
|
-
this.hide();
|
541
|
-
}).bind(this).delay(100);
|
542
|
-
}.bind(this),
|
543
|
-
|
544
|
-
keyUp: function() {
|
545
|
-
this.setValue(input.value);
|
546
|
-
}.bind(this)
|
547
|
-
});
|
548
|
-
|
549
|
-
this.element.hide();
|
550
|
-
|
551
|
-
return this;
|
552
|
-
},
|
553
|
-
|
554
|
-
/**
|
555
|
-
* Assigns the colorpicer to automatically update
|
556
|
-
* given element's background on changes
|
557
|
-
*
|
558
|
-
* @param mixed element reference
|
559
|
-
* @return Colorpicker this
|
560
|
-
*/
|
561
|
-
updateBg: function(element_ref) {
|
562
|
-
var element = $(element_ref);
|
563
|
-
if (element) {
|
564
|
-
this.onChange(function(color) {
|
565
|
-
element.style.backgroundColor = this.toRgb();
|
566
|
-
}.bind(this));
|
567
|
-
}
|
568
|
-
return this;
|
569
|
-
},
|
570
|
-
|
571
|
-
// protected
|
572
|
-
|
573
|
-
cancelTimer: function() {
|
574
|
-
(function() { // IE has a lack of sync in here
|
575
|
-
if (this.timer) {
|
576
|
-
this.timer.cancel();
|
577
|
-
this.timer = null;
|
578
|
-
}
|
579
|
-
}).bind(this).delay(10);
|
580
|
-
}
|
581
|
-
});
|
582
|
-
|
583
|
-
/**
|
584
|
-
* The document level hooks for colorpicker
|
585
|
-
*
|
586
|
-
* Copyright (C) 2010 Nikolay Nemshilov
|
587
|
-
*/
|
588
|
-
document.on({
|
589
|
-
mouseup: function() {
|
590
|
-
if (Colorpicker.tracking) {
|
591
|
-
Colorpicker.tracking.stopTrack();
|
592
|
-
}
|
593
|
-
},
|
594
|
-
|
595
|
-
mousemove: function(event) {
|
596
|
-
if (Colorpicker.tracking) {
|
597
|
-
Colorpicker.tracking.trackMove(event);
|
598
|
-
}
|
599
|
-
},
|
600
|
-
|
601
|
-
mousedown: function(event) {
|
602
|
-
var picker = Colorpicker.current, target = event.target;
|
603
|
-
|
604
|
-
if (picker && target != picker.target && ![target].concat(target.parents()).include(picker.element)) {
|
605
|
-
picker.hide();
|
606
|
-
}
|
607
|
-
}
|
608
|
-
});
|
609
|
-
|
610
|
-
window.on('blur', function() {
|
611
|
-
if (Colorpicker.tracking) {
|
612
|
-
Colorpicker.tracking.stopTrack();
|
613
|
-
}
|
614
|
-
});
|
615
|
-
|
616
|
-
// colorpickers autodiscovery feature
|
617
|
-
Colorpicker.Options.cssRule.on({
|
618
|
-
focus: function(event) {
|
619
|
-
if (this.tagName == 'INPUT') {
|
620
|
-
Colorpicker.find(this).show(this);
|
621
|
-
}
|
622
|
-
},
|
623
|
-
|
624
|
-
click: function(event) {
|
625
|
-
var attr = Colorpicker.Options.cssRule.split('[').last().split('^=').first(),
|
626
|
-
match = /\[(.+?)\]/.exec(this.get(attr)), input;
|
627
|
-
|
628
|
-
if (match && (input = $(match[1]))) {
|
629
|
-
event.stop();
|
630
|
-
|
631
|
-
Colorpicker.find(this).show(input);
|
632
|
-
}
|
633
|
-
}
|
634
|
-
});
|
635
|
-
document.write("<style type=\"text/css\">div.right-colorpicker,div.right-colorpicker*{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.right-colorpicker{position:absolute;padding:.6em;background:#EEE;border:1px solid #CCC;-moz-border-radius:.2em;-webkit-border-radius:.2em;-moz-box-shadow:#AAA .3em .3em .4em;-webkit-box-shadow:#AAA .3em .3em .4em;z-index:9999}div.right-colorpicker div.field,div.right-colorpicker div.field-pointer,div.right-colorpicker div.colors,div.right-colorpicker div.colors-pointer{background:url(/images/rightjs-ui/colorpicker.png) no-repeat 0 0}div.right-colorpicker div.field,div.right-colorpicker div.colors,div.right-colorpicker div.controls{display:inline-block;*display:inline;*zoom:1;position:relative;vertical-align:top;height:150px}div.right-colorpicker div.field-pointer,div.right-colorpicker div.colors-pointer{position:absolute;top:0px;left:0;width:9px;height:9px}div.right-colorpicker input.display,div.right-colorpicker div.preview,div.right-colorpicker div.rgb-display,div.right-colorpicker input.right-ui-button{font-size:100%;display:block;width:auto;padding:0 .2em}div.right-colorpicker input.display,div.right-colorpicker div.preview,div.right-colorpicker div.rgb-display input,div.right-colorpicker input.right-ui-button{border:1px solid #AAA;-moz-border-radius:.2em;-webkit-border-radius:.2em}div.right-colorpicker div.field{width:150px;background-color:red;cursor:crosshair;margin-right:1.2em}div.right-colorpicker div.field-pointer{background-position:-170px 0;margin-left:-2px;margin-top:-2px}div.right-colorpicker div.colors{width:16px;background-position:-150px 0;border-color:#EEE;cursor:pointer;margin-right:.6em}div.right-colorpicker div.colors-pointer{cursor:default;background-position:-170px -20px;margin-left:-8px;margin-top:-3px}div.right-colorpicker div.controls{width:5em}div.right-colorpicker div.preview{height:2em;background:white;border-color:#BBB}div.right-colorpicker input.display{margin-top:.5em;background:#FFF;width:4.5em}div.right-colorpicker div.rgb-display{padding:0;text-align:right;margin-top:.5em}div.right-colorpicker div.rgb-display label{display:inline}div.right-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.right-colorpicker input.right-ui-button{cursor:pointer;position:absolute;bottom:0;width:5em;background:#CCC}div.right-colorpicker-inline{display:inline-block;*display:inline;*zoom:1;position:relative;-moz-box-shadow:none;-webkit-box-shadow:none;z-index:auto}</style>");
|