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.
Files changed (36) hide show
  1. data/CHANGELOG +8 -2
  2. data/Rakefile +28 -28
  3. data/lib/right_rails/java_script_generator.rb +59 -51
  4. data/public/images/{colorpicker.png → rightjs-ui/colorpicker.png} +0 -0
  5. data/public/images/{resizable.png → rightjs-ui/resizable.png} +0 -0
  6. data/public/javascripts/right-olds-src.js +47 -46
  7. data/public/javascripts/right-safe-src.js +103 -102
  8. data/public/javascripts/right-safe.js +1 -1
  9. data/public/javascripts/right-src.js +611 -541
  10. data/public/javascripts/right.js +86 -85
  11. data/public/javascripts/right/autocompleter-src.js +81 -77
  12. data/public/javascripts/right/autocompleter.js +1 -1
  13. data/public/javascripts/right/calendar-src.js +209 -197
  14. data/public/javascripts/right/calendar.js +6 -6
  15. data/public/javascripts/right/colorpicker-src.js +127 -117
  16. data/public/javascripts/right/colorpicker.js +6 -6
  17. data/public/javascripts/right/dnd-src.js +63 -63
  18. data/public/javascripts/right/dnd.js +2 -2
  19. data/public/javascripts/right/in-edit-src.js +53 -48
  20. data/public/javascripts/right/in-edit.js +2 -2
  21. data/public/javascripts/right/lightbox-src.js +107 -99
  22. data/public/javascripts/right/lightbox.js +2 -2
  23. data/public/javascripts/right/rater-src.js +48 -46
  24. data/public/javascripts/right/rater.js +3 -3
  25. data/public/javascripts/right/resizable-src.js +53 -61
  26. data/public/javascripts/right/resizable.js +4 -4
  27. data/public/javascripts/right/selectable-src.js +97 -95
  28. data/public/javascripts/right/selectable.js +2 -2
  29. data/public/javascripts/right/slider-src.js +47 -45
  30. data/public/javascripts/right/slider.js +8 -8
  31. data/public/javascripts/right/sortable-src.js +54 -52
  32. data/public/javascripts/right/tabs-src.js +181 -171
  33. data/public/javascripts/right/tooltip-src.js +39 -37
  34. data/public/javascripts/right/uploader-src.js +21 -19
  35. data/spec/lib/right_rails/java_script_generator_spec.rb +61 -56
  36. metadata +9 -7
@@ -14,12 +14,12 @@ d=a.top-f.y+k;f=a.left-f.x+l;l=a.width-l-y;a=a.height-k-z;this.setStyle("visibil
14
14
  initialize:function(a){this.$super("colorpicker",a).addClass("rui-panel").insert([this.field=new A,this.colors=new B,this.controls=new C]).on({mousedown:this.startTrack,keyup:this.recalc,blur:this.update,focus:this.cancelTimer,done:this.done});this.options.update&&this.assignTo(this.options.update,this.options.trigger);this.options.updateBg&&this.updateBg(this.options.updateBg);this.tint=j([1,0,0]);this.satur=0;this.bright=1;this.color=j([255,255,255]);this.recalc().update()},setValue:function(a){if((a=
15
15
  w(a)?a:this.toColor(a))&&a.length===3){this.color=a=a.map(function(b){return this.bound(i(""+b),0,255)},this);this.color2tint().update();this.colors.size().y||this.update.bind(this).delay(20)}return this},getValue:function(a){return a?this.color:this[this.options.format==="rgb"?"toRgb":"toHex"]()},updateBg:function(a){var b=n(a);b&&this.onChange(j(function(){b._.style.backgroundColor=this.toRgb()}).bind(this));return this},insertTo:function(a,b){return this.$super(a,b).addClass("rui-colorpicker-inline")},
16
16
  inlined:function(){return this.hasClass("rui-colorpicker-inline")},done:function(){this.inlined()||this.hide();return this},setOptions:function(a){a=a||{};this.$super(a,n(a.trigger||a.update))},update:function(){this.field._.style.backgroundColor="rgb("+this.tint.map(function(d){return q.round(d*255)})+")";var a=this.color,b=this.controls;b.preview._.style.backgroundColor=b.display._.value=this.toHex();b.rDisplay._.value=a[0];b.gDisplay._.value=a[1];b.bDisplay._.value=a[2];b=this.field.pointer._.style;
17
- a=this.field.size();var c=this.satur*a.x-2;b.top=this.bound(a.y-this.bright*a.y-2,0,a.y-5)+"px";b.left=this.bound(c,0,a.x-5)+"px";b=this.tint;a=this.colors.size();b=b[1]==0?b[0]==1?b[2]:2-b[0]:b[0]==0?2+(b[2]==1?b[1]:2-b[2]):4+(b[1]==1?b[0]:2-b[1]);b=b/6*a.y;this.colors.pointer._.style.top=this.bound(b,0,a.y-4)+"px";if(this.prevColor!==""+this.color){this.fire("change",this.color);this.prevColor=""+this.color}return this},recalc:function(a){if(a){a=a.target;var b=a._.value,c=s(this.color),d=false;
18
- if(a===this.controls.display&&/#\w{6}/.test(b))d=c=this.toColor(b);else if(/^\d+$/.test(b)){c[a._.cIndex]=b;d=true}d&&this.setValue(c)}else this.tint2color();return this},startTrack:function(a){this.stopTrack();this.cancelTimer();if(a.target===this.field.pointer)a.target=this.field;else if(a.target===this.colors.pointer)a.target=this.colors;if(a.target===this.field||a.target===this.colors){a.stop();g.tracking=this;a.target.tracking=true;this.trackMove(a)}},stopTrack:function(){g.tracking=false;this.field.tracking=
19
- false;this.colors.tracking=false},trackMove:function(a){var b,c=a.position();if(this.field.tracking)b=this.field.dimensions();else if(this.colors.tracking)b=this.colors.dimensions();if(b){a=this.bound(c.y-b.top,0,b.height);c=this.bound(c.x-b.left,0,b.width);if(this.field.tracking){this.satur=c/b.width;this.bright=1-a/b.height}else if(this.colors.tracking){if(a==b.height)a=b.height-0.1;b=b.height/6;c=this.tint=[0,0,0];var d=a%b/b,f=1-d;if(a<b){c[0]=1;c[2]=d}else if(a<b*2){c[0]=f;c[2]=1}else if(a<b*
20
- 3){c[2]=1;c[1]=d}else if(a<b*4){c[2]=f;c[1]=1}else if(a<b*5){c[1]=1;c[0]=d}else{c[1]=f;c[0]=1}}this.recalc().update()}},cancelTimer:function(){j(function(){if(this._hide_delay){this._hide_delay.cancel();this._hide_delay=null}}).bind(this).delay(10)}}),A=new o(m,{initialize:function(){this.$super("div",{"class":"field"});this.insert(this.pointer=h("div",{"class":"pointer"}))}}),B=new o(m,{initialize:function(){this.$super("div",{"class":"colors"});this.insert(this.pointer=h("div",{"class":"pointer"}))}}),
21
- C=new o(m,{initialize:function(){this.$super("div",{"class":"controls"});this.insert([this.preview=h("div",{"class":"preview",html:"&nbsp;"}),this.display=h("input",{type:"text","class":"display",maxlength:7}),h("div",{"class":"rgb-display"}).insert([h("div").insert([h("label",{html:"R:"}),this.rDisplay=h("input",{maxlength:3,cIndex:0})]),h("div").insert([h("label",{html:"G:"}),this.gDisplay=h("input",{maxlength:3,cIndex:1})]),h("div").insert([h("label",{html:"B:"}),this.bDisplay=h("input",{maxlength:3,
22
- cIndex:2})])]),this.button=(new x(g.i18n.Done)).onClick("fire","done")])}});g.include({toRgb:function(){return"rgb("+this.color.join(",")+")"},toHex:function(){return"#"+this.color.map(function(a){return(a<16?"0":"")+a.toString(16)}).join("")},toColor:function(a){a=a.toLowerCase();var b;if(b=/rgb\((\d+),(\d+),(\d+)\)/.exec(a))return[b[1],b[2],b[3]].map(i);else if(/#[\da-f]+/.test(a)){if(b=/^#([\da-f])([\da-f])([\da-f])$/.exec(a))a="#"+b[1]+b[1]+b[2]+b[2]+b[3]+b[3];if(b=/#([\da-f]{2})([\da-f]{2})([\da-f]{2})/.exec(a))return[b[1],
17
+ a=this.field.size();var c=this.satur*a.x-2;b.top=this.bound(a.y-this.bright*a.y-2,0,a.y-5)+"px";b.left=this.bound(c,0,a.x-5)+"px";b=this.tint;a=this.colors.size();b=b[1]==0?b[0]==1?b[2]:2-b[0]:b[0]==0?2+(b[2]==1?b[1]:2-b[2]):4+(b[1]==1?b[0]:2-b[1]);b=b/6*a.y;this.colors.pointer._.style.top=this.bound(b,0,a.y-4)+"px";if(this.prevColor!==""+this.color){this.fire("change",{value:this.color});this.prevColor=""+this.color}return this},recalc:function(a){if(a){a=a.target;var b=a._.value,c=s(this.color),
18
+ d=false;if(a===this.controls.display&&/#\w{6}/.test(b))d=c=this.toColor(b);else if(/^\d+$/.test(b)){c[a._.cIndex]=b;d=true}d&&this.setValue(c)}else this.tint2color();return this},startTrack:function(a){this.stopTrack();this.cancelTimer();if(a.target===this.field.pointer)a.target=this.field;else if(a.target===this.colors.pointer)a.target=this.colors;if(a.target===this.field||a.target===this.colors){a.stop();g.tracking=this;a.target.tracking=true;this.trackMove(a)}},stopTrack:function(){g.tracking=
19
+ false;this.field.tracking=false;this.colors.tracking=false},trackMove:function(a){var b,c=a.position();if(this.field.tracking)b=this.field.dimensions();else if(this.colors.tracking)b=this.colors.dimensions();if(b){a=this.bound(c.y-b.top,0,b.height);c=this.bound(c.x-b.left,0,b.width);if(this.field.tracking){this.satur=c/b.width;this.bright=1-a/b.height}else if(this.colors.tracking){if(a==b.height)a=b.height-0.1;b=b.height/6;c=this.tint=[0,0,0];var d=a%b/b,f=1-d;if(a<b){c[0]=1;c[2]=d}else if(a<b*2){c[0]=
20
+ f;c[2]=1}else if(a<b*3){c[2]=1;c[1]=d}else if(a<b*4){c[2]=f;c[1]=1}else if(a<b*5){c[1]=1;c[0]=d}else{c[1]=f;c[0]=1}}this.recalc().update()}},cancelTimer:function(){j(function(){if(this._hide_delay){this._hide_delay.cancel();this._hide_delay=null}}).bind(this).delay(10)}}),A=new o(m,{initialize:function(){this.$super("div",{"class":"field"});this.insert(this.pointer=h("div",{"class":"pointer"}))}}),B=new o(m,{initialize:function(){this.$super("div",{"class":"colors"});this.insert(this.pointer=h("div",
21
+ {"class":"pointer"}))}}),C=new o(m,{initialize:function(){this.$super("div",{"class":"controls"});this.insert([this.preview=h("div",{"class":"preview",html:"&nbsp;"}),this.display=h("input",{type:"text","class":"display",maxlength:7}),h("div",{"class":"rgb-display"}).insert([h("div").insert([h("label",{html:"R:"}),this.rDisplay=h("input",{maxlength:3,cIndex:0})]),h("div").insert([h("label",{html:"G:"}),this.gDisplay=h("input",{maxlength:3,cIndex:1})]),h("div").insert([h("label",{html:"B:"}),this.bDisplay=
22
+ h("input",{maxlength:3,cIndex:2})])]),this.button=(new x(g.i18n.Done)).onClick("fire","done")])}});g.include({toRgb:function(){return"rgb("+this.color.join(",")+")"},toHex:function(){return"#"+this.color.map(function(a){return(a<16?"0":"")+a.toString(16)}).join("")},toColor:function(a){a=a.toLowerCase();var b;if(b=/rgb\((\d+),(\d+),(\d+)\)/.exec(a))return[b[1],b[2],b[3]].map(i);else if(/#[\da-f]+/.test(a)){if(b=/^#([\da-f])([\da-f])([\da-f])$/.exec(a))a="#"+b[1]+b[1]+b[2]+b[2]+b[3]+b[3];if(b=/#([\da-f]{2})([\da-f]{2})([\da-f]{2})/.exec(a))return[b[1],
23
23
  b[2],b[3]].map(function(c){return i(c,16)})}},color2tint:function(){var a=s(this.color).sort(function(d,f){return d-f}),b=a[0],c=a[2];this.bright=c/255;this.satur=1-b/(c||1);this.tint.each(function(d,f){this.tint[f]=!b&&!c||b==c?f==0?1:0:(this.color[f]-b)/(c-b);return this.tint[f]},this);return this},tint2color:function(){for(var a=this.tint,b=this.color,c=0;c<3;c++){b[c]=1+this.satur*(a[c]-1);b[c]=q.round(255*b[c]*this.bright)}return this},bound:function(a,b,c){a=a;if(b<c)a=a<b?b:a>c?c:a;else{if(a>
24
24
  c)a=c;if(a<b)a=b}return a}});n(p).on({mouseup:function(){g.tracking&&g.tracking.stopTrack()},mousemove:function(a){g.tracking&&g.tracking.trackMove(a)},focus:function(a){a=a.target instanceof t?a.target:null;g.hideAll();if(a&&(a.colorpicker||a.match(g.Options.cssRule)))(a.colorpicker||new g({update:a})).setValue(a.value()).showAt(a)},blur:function(a){var b=a.target.colorpicker;if(b)b._hide_delay=j(function(){b.hide()}).delay(200)},click:function(a){var b=a.target instanceof m?a.target:null;if(b&&
25
25
  (b.colorpicker||b.match(g.Options.cssRule))){if(!(b instanceof t)){a.stop();(b.colorpicker||new g({trigger:b})).hide(null).toggleAt(b.assignedInput)}}else a.find("div.rui-colorpicker")||g.hideAll()},keydown:function(a){var b=g.current,c={27:"hide",13:"done"}[a.keyCode];if(c&&b&&b.visible()){a.stop();b[c]()}}});p.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>');
@@ -29,45 +29,45 @@ var R = RightJS,
29
29
  var Draggable = new Class(Observer, {
30
30
  extend: {
31
31
  EVENTS: $w('before start drag stop drop'),
32
-
32
+
33
33
  Options: {
34
34
  handle: null, // a handle element that will start the drag
35
-
35
+
36
36
  snap: 0, // a number in pixels or [x,y]
37
37
  axis: null, // null or 'x' or 'y' or 'vertical' or 'horizontal'
38
38
  range: null, // {x: [min, max], y:[min, max]} or reference to another element
39
-
39
+
40
40
  dragClass: 'dragging', // the in-process class name
41
-
41
+
42
42
  clone: false, // if should keep a clone in place
43
43
  revert: false, // marker if the object should be moved back on finish
44
44
  revertDuration: 'normal', // the moving back fx duration
45
-
46
- scroll: true, // if it should automatically scroll
45
+
46
+ scroll: true, // if it should automatically scroll
47
47
  scrollSensitivity: 32, // the scrolling area size in pixels
48
-
48
+
49
49
  zIndex: 10000000, // the element's z-index
50
50
  moveOut: false, // marker if the draggable should be moved out of it's context (for overflown elements)
51
-
51
+
52
52
  relName: 'draggable' // the audodiscovery feature key
53
53
  },
54
-
54
+
55
55
  // referenece to the currently active draggable
56
56
  current: null,
57
-
57
+
58
58
  // scans the document for auto-processed draggables with the rel="draggable" attribute
59
59
  rescan: function(scope) {
60
60
  var key = this.Options.relName;
61
-
61
+
62
62
  ($(scope)||$(document)).select('*[rel^="'+key+'"]').each(function(element) {
63
63
  if (!element.draggable) {
64
- var data = element.get('data-'+key+'-options');
64
+ var data = element.get('data-'+key);
65
65
  new this(element, eval('('+data+')') || {});
66
66
  }
67
67
  }, this);
68
68
  }
69
69
  },
70
-
70
+
71
71
  /**
72
72
  * Basic controller
73
73
  *
@@ -77,10 +77,10 @@ var Draggable = new Class(Observer, {
77
77
  initialize: function(element, options) {
78
78
  this.element = $(element);
79
79
  this.$super(options);
80
-
80
+
81
81
  this.element.draggable = this.init();
82
82
  },
83
-
83
+
84
84
  /**
85
85
  * detaches the mouse observers out of the draggable element
86
86
  *
@@ -89,17 +89,17 @@ var Draggable = new Class(Observer, {
89
89
  destroy: function() {
90
90
  this.handle.stopObserving('mousedown', this._dragStart);
91
91
  delete(this.element.draggable);
92
-
92
+
93
93
  return this;
94
94
  },
95
-
95
+
96
96
  // additional options processing
97
97
  setOptions: function(options) {
98
98
  this.$super(options);
99
-
99
+
100
100
  // checking the handle
101
101
  this.handle = this.options.handle ? $(this.options.handle) : this.element;
102
-
102
+
103
103
  // checking the spappings
104
104
  if (isArray(this.options.snap)) {
105
105
  this.snapX = this.options.snap[0];
@@ -107,10 +107,10 @@ var Draggable = new Class(Observer, {
107
107
  } else {
108
108
  this.snapX = this.snapY = this.options.snap;
109
109
  }
110
-
110
+
111
111
  return this;
112
112
  },
113
-
113
+
114
114
  /**
115
115
  * Moves the element back to the original position
116
116
  *
@@ -122,7 +122,7 @@ var Draggable = new Class(Observer, {
122
122
  top: (position.y + this.ryDiff) + 'px',
123
123
  left: (position.x + this.rxDiff) + 'px'
124
124
  };
125
-
125
+
126
126
  if (this.options.revertDuration && this.element.morph) {
127
127
  this.element.morph(end_style, {
128
128
  duration: this.options.revertDuration,
@@ -132,56 +132,56 @@ var Draggable = new Class(Observer, {
132
132
  this.element.setStyle(end_style);
133
133
  this.swapBack();
134
134
  }
135
-
135
+
136
136
  return this;
137
137
  },
138
-
138
+
139
139
  // protected
140
140
 
141
141
  init: function() {
142
142
  // caching the callback so that we could detach it later
143
143
  this._dragStart = R(this.dragStart).bind(this);
144
-
144
+
145
145
  this.handle.onMousedown(this._dragStart);
146
-
146
+
147
147
  return this;
148
148
  },
149
-
149
+
150
150
  // handles the event start
151
151
  dragStart: function(event) {
152
152
  this.fire('before', this, event.stop());
153
-
153
+
154
154
  // calculating the positions diff
155
155
  var position = this.element.position();
156
-
156
+
157
157
  this.xDiff = event.pageX - position.x;
158
158
  this.yDiff = event.pageY - position.y;
159
-
159
+
160
160
  // grabbing the relative position diffs
161
161
  var relative_position = {
162
162
  y: R(this.element.getStyle('top')).toFloat(),
163
163
  x: R(this.element.getStyle('left')).toFloat()
164
164
  };
165
-
165
+
166
166
  this.rxDiff = isNaN(relative_position.x) ? 0 : (relative_position.x - position.x);
167
167
  this.ryDiff = isNaN(relative_position.y) ? 0 : (relative_position.y - position.y);
168
-
168
+
169
169
  // preserving the element sizes
170
170
  var size = {
171
171
  x: this.element.getStyle('width'),
172
172
  y: this.element.getStyle('height')
173
173
  };
174
-
174
+
175
175
  if (size.x == 'auto') { size.x = this.element._.offsetWidth + 'px'; }
176
176
  if (size.y == 'auto') { size.y = this.element._.offsetHeight + 'px'; }
177
-
177
+
178
178
  // building a clone element if necessary
179
179
  if (this.options.clone || this.options.revert) {
180
180
  this.clone = new Element(this.element._.cloneNode(true)).setStyle({
181
181
  visibility: this.options.clone ? 'visible' : 'hidden'
182
182
  }).insertTo(this.element, 'before');
183
183
  }
184
-
184
+
185
185
  // reinserting the element to the body so it was over all the other elements
186
186
  this.element.setStyle({
187
187
  position: 'absolute',
@@ -191,25 +191,25 @@ var Draggable = new Class(Observer, {
191
191
  width: size.x,
192
192
  height: size.y
193
193
  }).addClass(this.options.dragClass);
194
-
194
+
195
195
  if (this.options.moveOut) {
196
196
  this.element.insertTo(document.body);
197
197
  }
198
-
199
-
198
+
199
+
200
200
  // caching the window scrolls
201
201
  this.winScrolls = $(window).scrolls();
202
202
  this.winSizes = $(window).size();
203
-
203
+
204
204
  Draggable.current = this.calcConstraints().fire('start', this, event);
205
-
205
+
206
206
  this.style = this.element._.style;
207
207
  },
208
-
208
+
209
209
  // catches the mouse move event
210
210
  dragProcess: function(event) {
211
211
  var page_x = event.pageX, page_y = event.pageY, x = page_x - this.xDiff, y = page_y - this.yDiff;
212
-
212
+
213
213
  // checking the range
214
214
  if (this.ranged) {
215
215
  if (this.minX > x) { x = this.minX; }
@@ -217,61 +217,61 @@ var Draggable = new Class(Observer, {
217
217
  if (this.minY > y) { y = this.minY; }
218
218
  if (this.maxY < y) { y = this.maxY; }
219
219
  }
220
-
220
+
221
221
  // checking the scrolls
222
222
  if (this.options.scroll) {
223
223
  var scrolls = {x: this.winScrolls.x, y: this.winScrolls.y},
224
224
  sensitivity = this.options.scrollSensitivity;
225
-
225
+
226
226
  if ((page_y - scrolls.y) < sensitivity) {
227
227
  scrolls.y = page_y - sensitivity;
228
228
  } else if ((scrolls.y + this.winSizes.y - page_y) < sensitivity){
229
229
  scrolls.y = page_y - this.winSizes.y + sensitivity;
230
230
  }
231
-
231
+
232
232
  if ((page_x - scrolls.x) < sensitivity) {
233
233
  scrolls.x = page_x - sensitivity;
234
234
  } else if ((scrolls.x + this.winSizes.x - page_x) < sensitivity){
235
235
  scrolls.x = page_x - this.winSizes.x + sensitivity;
236
236
  }
237
-
237
+
238
238
  if (scrolls.y < 0) { scrolls.y = 0; }
239
239
  if (scrolls.x < 0) { scrolls.x = 0; }
240
-
240
+
241
241
  if (scrolls.y < this.winScrolls.y || scrolls.y > this.winScrolls.y ||
242
242
  scrolls.x < this.winScrolls.x || scrolls.x > this.winScrolls.x) {
243
-
243
+
244
244
  $(window).scrollTo(this.winScrolls = scrolls);
245
245
  }
246
246
  }
247
-
247
+
248
248
  // checking the snaps
249
249
  if (this.snapX) { x = x - x % this.snapX; }
250
250
  if (this.snapY) { y = y - y % this.snapY; }
251
-
251
+
252
252
  // checking the constraints
253
253
  if (!this.axisY) { this.style.left = (x + this.rxDiff) + 'px'; }
254
254
  if (!this.axisX) { this.style.top = (y + this.ryDiff) + 'px'; }
255
-
255
+
256
256
  this.fire('drag', this, event);
257
257
  },
258
-
258
+
259
259
  // handles the event stop
260
260
  dragStop: function(event) {
261
261
  this.element.removeClass(this.options.dragClass);
262
-
262
+
263
263
  // notifying the droppables for the drop
264
264
  Droppable.checkDrop(event, this);
265
-
265
+
266
266
  if (this.options.revert) {
267
267
  this.revert();
268
268
  }
269
-
269
+
270
270
  Draggable.current = null;
271
-
271
+
272
272
  this.fire('stop', this, event);
273
273
  },
274
-
274
+
275
275
  // swaps the clone element to the actual element back
276
276
  swapBack: function() {
277
277
  if (this.clone) {
@@ -285,23 +285,23 @@ var Draggable = new Class(Observer, {
285
285
  );
286
286
  }
287
287
  },
288
-
288
+
289
289
  // calculates the constraints
290
290
  calcConstraints: function() {
291
291
  var axis = this.options.axis;
292
292
  this.axisX = R(['x', 'horizontal']).include(axis);
293
293
  this.axisY = R(['y', 'vertical']).include(axis);
294
-
294
+
295
295
  this.ranged = false;
296
296
  var range = this.options.range;
297
297
  if (range) {
298
298
  this.ranged = true;
299
-
299
+
300
300
  // if the range is defined by another element
301
301
  var element = $(range);
302
302
  if (element instanceof Element) {
303
303
  var dims = element.dimensions();
304
-
304
+
305
305
  range = {
306
306
  x: [dims.left, dims.left + dims.width],
307
307
  y: [dims.top, dims.top + dims.height]
@@ -310,7 +310,7 @@ var Draggable = new Class(Observer, {
310
310
 
311
311
  if (isHash(range)) {
312
312
  var size = this.element.size();
313
-
313
+
314
314
  if (range.x) {
315
315
  this.minX = range.x[0];
316
316
  this.maxX = range.x[1] - size.x;
@@ -321,7 +321,7 @@ var Draggable = new Class(Observer, {
321
321
  }
322
322
  }
323
323
  }
324
-
324
+
325
325
  return this;
326
326
  }
327
327
  });
@@ -5,8 +5,8 @@
5
5
  * Copyright (C) 2009-2010 Nikolay Nemshilov
6
6
  */
7
7
  (function(q,r,f){var k=f.$,t=f.$w,u=f.Class,w=f.isHash,x=f.isArray,s=f.Element,v=f.Observer,j=new u(v,{extend:{EVENTS:t("before start drag stop drop"),Options:{handle:null,snap:0,axis:null,range:null,dragClass:"dragging",clone:false,revert:false,revertDuration:"normal",scroll:true,scrollSensitivity:32,zIndex:1E7,moveOut:false,relName:"draggable"},current:null,rescan:function(a){var c=this.Options.relName;(k(a)||k(r)).select('*[rel^="'+c+'"]').each(function(b){if(!b.draggable){var e=b.get("data-"+
8
- c+"-options");new this(b,eval("("+e+")")||{})}},this)}},initialize:function(a,c){this.element=k(a);this.$super(c);this.element.draggable=this.init()},destroy:function(){this.handle.stopObserving("mousedown",this._dragStart);delete this.element.draggable;return this},setOptions:function(a){this.$super(a);this.handle=this.options.handle?k(this.options.handle):this.element;if(x(this.options.snap)){this.snapX=this.options.snap[0];this.snapY=this.options.snap[1]}else this.snapX=this.snapY=this.options.snap;
9
- return this},revert:function(){var a=this.clone.position();a={top:a.y+this.ryDiff+"px",left:a.x+this.rxDiff+"px"};if(this.options.revertDuration&&this.element.morph)this.element.morph(a,{duration:this.options.revertDuration,onFinish:f(this.swapBack).bind(this)});else{this.element.setStyle(a);this.swapBack()}return this},init:function(){this._dragStart=f(this.dragStart).bind(this);this.handle.onMousedown(this._dragStart);return this},dragStart:function(a){this.fire("before",this,a.stop());var c=this.element.position();
8
+ c);new this(b,eval("("+e+")")||{})}},this)}},initialize:function(a,c){this.element=k(a);this.$super(c);this.element.draggable=this.init()},destroy:function(){this.handle.stopObserving("mousedown",this._dragStart);delete this.element.draggable;return this},setOptions:function(a){this.$super(a);this.handle=this.options.handle?k(this.options.handle):this.element;if(x(this.options.snap)){this.snapX=this.options.snap[0];this.snapY=this.options.snap[1]}else this.snapX=this.snapY=this.options.snap;return this},
9
+ revert:function(){var a=this.clone.position();a={top:a.y+this.ryDiff+"px",left:a.x+this.rxDiff+"px"};if(this.options.revertDuration&&this.element.morph)this.element.morph(a,{duration:this.options.revertDuration,onFinish:f(this.swapBack).bind(this)});else{this.element.setStyle(a);this.swapBack()}return this},init:function(){this._dragStart=f(this.dragStart).bind(this);this.handle.onMousedown(this._dragStart);return this},dragStart:function(a){this.fire("before",this,a.stop());var c=this.element.position();
10
10
  this.xDiff=a.pageX-c.x;this.yDiff=a.pageY-c.y;var b={y:f(this.element.getStyle("top")).toFloat(),x:f(this.element.getStyle("left")).toFloat()};this.rxDiff=isNaN(b.x)?0:b.x-c.x;this.ryDiff=isNaN(b.y)?0:b.y-c.y;b={x:this.element.getStyle("width"),y:this.element.getStyle("height")};if(b.x=="auto")b.x=this.element._.offsetWidth+"px";if(b.y=="auto")b.y=this.element._.offsetHeight+"px";if(this.options.clone||this.options.revert)this.clone=(new s(this.element._.cloneNode(true))).setStyle({visibility:this.options.clone?
11
11
  "visible":"hidden"}).insertTo(this.element,"before");this.element.setStyle({position:"absolute",zIndex:j.Options.zIndex++,top:c.y+this.ryDiff+"px",left:c.x+this.rxDiff+"px",width:b.x,height:b.y}).addClass(this.options.dragClass);this.options.moveOut&&this.element.insertTo(r.body);this.winScrolls=k(q).scrolls();this.winSizes=k(q).size();j.current=this.calcConstraints().fire("start",this,a);this.style=this.element._.style},dragProcess:function(a){var c=a.pageX,b=a.pageY,e=c-this.xDiff,h=b-this.yDiff;
12
12
  if(this.ranged){if(this.minX>e)e=this.minX;if(this.maxX<e)e=this.maxX;if(this.minY>h)h=this.minY;if(this.maxY<h)h=this.maxY}if(this.options.scroll){var d={x:this.winScrolls.x,y:this.winScrolls.y},g=this.options.scrollSensitivity;if(b-d.y<g)d.y=b-g;else if(d.y+this.winSizes.y-b<g)d.y=b-this.winSizes.y+g;if(c-d.x<g)d.x=c-g;else if(d.x+this.winSizes.x-c<g)d.x=c-this.winSizes.x+g;if(d.y<0)d.y=0;if(d.x<0)d.x=0;if(d.y<this.winScrolls.y||d.y>this.winScrolls.y||d.x<this.winScrolls.x||d.x>this.winScrolls.x)k(q).scrollTo(this.winScrolls=
@@ -33,19 +33,20 @@ var R = RightJS,
33
33
 
34
34
 
35
35
 
36
+
36
37
  /**
37
38
  * The widget units constructor
38
39
  *
39
40
  * @param String tag-name or Object methods
40
41
  * @param Object methods
41
42
  * @return Widget wrapper
42
- */
43
+ */
43
44
  function Widget(tag_name, methods) {
44
45
  if (!methods) {
45
46
  methods = tag_name;
46
47
  tag_name = 'DIV';
47
48
  }
48
-
49
+
49
50
  /**
50
51
  * An Abstract Widget Unit
51
52
  *
@@ -62,17 +63,17 @@ function Widget(tag_name, methods) {
62
63
  initialize: function(key, options) {
63
64
  this.key = key;
64
65
  var args = [{'class': 'rui-' + key}];
65
-
66
+
66
67
  // those two have different constructors
67
68
  if (!(this instanceof RightJS.Input || this instanceof RightJS.Form)) {
68
69
  args.unshift(tag_name);
69
70
  }
70
71
  this.$super.apply(this, args);
71
-
72
+
72
73
  if (RightJS.isString(options)) {
73
74
  options = RightJS.$(options);
74
75
  }
75
-
76
+
76
77
  // if the options is another element then
77
78
  // try to dynamically rewrap it with our widget
78
79
  if (options instanceof RightJS.Element) {
@@ -105,16 +106,16 @@ function Widget(tag_name, methods) {
105
106
  return this;
106
107
  }
107
108
  });
108
-
109
+
109
110
  /**
110
111
  * Creating the actual widget class
111
112
  *
112
113
  */
113
114
  var Klass = new RightJS.Wrapper(AbstractWidget, methods);
114
-
115
+
115
116
  // creating the widget related shortcuts
116
117
  RightJS.Observer.createShortcuts(Klass.prototype, Klass.EVENTS || []);
117
-
118
+
118
119
  return Klass;
119
120
  }
120
121
 
@@ -132,18 +133,18 @@ var Spinner = new RightJS.Wrapper(RightJS.Element, {
132
133
  * @return void
133
134
  */
134
135
  initialize: function(size) {
135
- this.$super('div', {'class': 'rui-spinner'});
136
+ this.$super('div', {'class': 'rui-spinner'});
136
137
  this.dots = [];
137
-
138
+
138
139
  for (var i=0; i < (size || 4); i++) {
139
140
  this.dots.push(new RightJS.Element('div'));
140
141
  }
141
-
142
+
142
143
  this.dots[0].addClass('glowing');
143
144
  this.insert(this.dots);
144
145
  RightJS(this.shift).bind(this).periodical(300);
145
146
  },
146
-
147
+
147
148
  /**
148
149
  * Shifts the spinner elements
149
150
  *
@@ -158,6 +159,7 @@ var Spinner = new RightJS.Wrapper(RightJS.Element, {
158
159
  }
159
160
  });
160
161
 
162
+
161
163
  /**
162
164
  * An inline editor feature
163
165
  *
@@ -166,31 +168,31 @@ var Spinner = new RightJS.Wrapper(RightJS.Element, {
166
168
  var InEdit = new Widget('FORM', {
167
169
  extend: {
168
170
  version: '2.0.0',
169
-
171
+
170
172
  EVENTS: $w('show hide send update'),
171
-
173
+
172
174
  Options: {
173
175
  url: null, // the url address where to send the stuff
174
176
  name: 'text', // the field name
175
177
  method: 'put', // the method
176
-
178
+
177
179
  type: 'text', // the input type, 'text', 'file', 'password' or 'textarea'
178
-
180
+
179
181
  toggle: null, // a reference to an element that should get hidden when the editor is active
180
-
182
+
181
183
  update: true, // a marker if the element should be updated with the response-text
182
-
184
+
183
185
  Xhr: {} // additional Xhr options
184
186
  },
185
-
187
+
186
188
  i18n: {
187
189
  Save: 'Save',
188
190
  Cancel: 'Cancel'
189
191
  },
190
-
192
+
191
193
  current: null // currently opened editor
192
194
  },
193
-
195
+
194
196
  /**
195
197
  * Constructor
196
198
  *
@@ -200,7 +202,7 @@ var InEdit = new Widget('FORM', {
200
202
  */
201
203
  initialize: function(element, options) {
202
204
  this.element = $(element);
203
-
205
+
204
206
  this
205
207
  .$super('in-edit', options)
206
208
  .set('action', this.options.url)
@@ -213,7 +215,7 @@ var InEdit = new Widget('FORM', {
213
215
  .onClick(this.clicked)
214
216
  .onSubmit(this.send);
215
217
  },
216
-
218
+
217
219
  /**
218
220
  * Shows the inline-editor form
219
221
  *
@@ -222,31 +224,31 @@ var InEdit = new Widget('FORM', {
222
224
  show: function() {
223
225
  if (InEdit.current !== this) {
224
226
  if (InEdit.current) { InEdit.current.hide(); }
225
-
227
+
226
228
  this.oldContent = this.element.html();
227
-
229
+
228
230
  if (!R(['file', 'password']).include(this.options.type)) {
229
231
  this.field.setValue(this.oldContent);
230
232
  }
231
-
233
+
232
234
  this.element.update(this);
233
-
235
+
234
236
  this.spinner.hide();
235
237
  this.submit.show();
236
-
238
+
237
239
  if (this.options.toggle) {
238
240
  $(this.options.toggle).hide();
239
241
  }
240
242
  }
241
-
243
+
242
244
  if (this.options.type !== 'file') {
243
245
  this.field.focus();
244
246
  }
245
-
247
+
246
248
  InEdit.current = this;
247
- return this.fire('show', this);
249
+ return this.fire('show');
248
250
  },
249
-
251
+
250
252
  /**
251
253
  * Hides the form and brings the content back
252
254
  *
@@ -255,14 +257,14 @@ var InEdit = new Widget('FORM', {
255
257
  */
256
258
  hide: function() {
257
259
  this.element._.innerHTML = this.oldContent;
258
-
260
+
259
261
  if (this.xhr) {
260
262
  this.xhr.cancel();
261
263
  }
262
-
264
+
263
265
  return this.finish();
264
266
  },
265
-
267
+
266
268
  /**
267
269
  * Triggers the form remote submit
268
270
  *
@@ -270,19 +272,19 @@ var InEdit = new Widget('FORM', {
270
272
  */
271
273
  send: function(event) {
272
274
  if (event) { event.stop(); }
273
-
275
+
274
276
  this.spinner.show().resize(this.submit.size());
275
277
  this.submit.hide();
276
-
278
+
277
279
  this.xhr = new Xhr(this.options.url, Object.merge(this.options.Xhr, {
278
280
  method: this.options.method,
279
281
  spinner: this.spinner,
280
282
  onComplete: R(this.receive).bind(this)
281
283
  })).send(this);
282
-
283
- return this.fire('send', this);
284
+
285
+ return this.fire('send');
284
286
  },
285
-
287
+
286
288
  // protected
287
289
 
288
290
  // finishes up with the form
@@ -290,23 +292,23 @@ var InEdit = new Widget('FORM', {
290
292
  if (this.options.toggle) {
291
293
  $(this.options.toggle).show();
292
294
  }
293
-
295
+
294
296
  InEdit.current = null;
295
- return this.fire('hide', this);
297
+ return this.fire('hide');
296
298
  },
297
299
 
298
300
  // the xhr callback
299
301
  receive: function() {
300
302
  if (this.options.update) {
301
303
  this.element.update(this.xhr.text);
302
- this.fire('update', this);
304
+ this.fire('update');
303
305
  }
304
-
306
+
305
307
  this.xhr = null;
306
-
308
+
307
309
  this.finish();
308
310
  },
309
-
311
+
310
312
  // catches clicks on the element
311
313
  clicked: function(event) {
312
314
  if (event.target === this.cancel) {
@@ -314,9 +316,10 @@ var InEdit = new Widget('FORM', {
314
316
  this.hide();
315
317
  }
316
318
  }
317
-
319
+
318
320
  });
319
321
 
322
+
320
323
  /**
321
324
  * The document hooks for in-edit form
322
325
  *
@@ -329,6 +332,7 @@ $(document).onKeydown(function(event) {
329
332
  }
330
333
  });
331
334
 
335
+
332
336
  /**
333
337
  * The element level inline editor extension
334
338
  *
@@ -346,7 +350,8 @@ Element.include({
346
350
  }
347
351
  });
348
352
 
353
+
349
354
  document.write("<style type=\"text/css\">div.rui-spinner,div.rui-spinner div{margin:0;padding:0;border:none;background:none;list-style:none;font-weight:normal;float:none;display:inline-block; *display:inline; *zoom:1;border-radius:.12em;-moz-border-radius:.12em;-webkit-border-radius:.12em}div.rui-spinner{text-align:center;white-space:nowrap;background:#EEE;border:1px solid #DDD;height:1.2em;padding:0 .2em}div.rui-spinner div{width:.4em;height:70%;background:#BBB;margin-left:1px}div.rui-spinner div:first-child{margin-left:0}div.rui-spinner div.glowing{background:#777}form.rui-in-edit,form.rui-in-edit .cancel{margin:0;padding:0;float:none;position:static}form.rui-in-edit{display:inline-block; *display:inline; *zoom:1;border:none;background:none}form.rui-in-edit div.rui-spinner{margin-right:.2em}form.rui-in-edit div.rui-spinner div{margin-top:.2em}form.rui-in-edit textarea.field{width:100%;margin-bottom:.5em}form.rui-in-edit .field,form.rui-in-edit .submit{margin-right:.2em}form.rui-in-edit,form.rui-in-edit .field,form.rui-in-edit .submit,form.rui-in-edit div.rui-spinner,form.rui-in-edit .cancel{vertical-align:middle}</style>");
350
355
 
351
356
  return InEdit;
352
- })(document, RightJS);
357
+ })(document, RightJS);