right-rails 1.0.10 → 1.0.12

Sign up to get free protection for your applications and to get access to all the features.
Files changed (56) hide show
  1. data/README.rdoc +4 -4
  2. data/Rakefile +4 -4
  3. data/lib/right_rails.rb +1 -1
  4. data/public/javascripts/right/autocompleter-src.js +115 -106
  5. data/public/javascripts/right/autocompleter.js +3 -14
  6. data/public/javascripts/right/billboard-src.js +58 -38
  7. data/public/javascripts/right/billboard.js +3 -13
  8. data/public/javascripts/right/calendar-src.js +136 -133
  9. data/public/javascripts/right/calendar.js +4 -33
  10. data/public/javascripts/right/colorpicker-src.js +128 -125
  11. data/public/javascripts/right/colorpicker.js +4 -23
  12. data/public/javascripts/right/dialog-src.js +67 -37
  13. data/public/javascripts/right/dialog.js +3 -17
  14. data/public/javascripts/right/dnd-src.js +44 -43
  15. data/public/javascripts/right/dnd.js +3 -16
  16. data/public/javascripts/right/effects-src.js +125 -98
  17. data/public/javascripts/right/effects.js +3 -13
  18. data/public/javascripts/right/in-edit-src.js +54 -38
  19. data/public/javascripts/right/in-edit.js +4 -10
  20. data/public/javascripts/right/jquerysh-src.js +344 -20
  21. data/public/javascripts/right/jquerysh.js +3 -3
  22. data/public/javascripts/right/json-src.js +22 -35
  23. data/public/javascripts/right/json.js +4 -7
  24. data/public/javascripts/right/keys-src.js +87 -0
  25. data/public/javascripts/right/keys.js +7 -0
  26. data/public/javascripts/right/lightbox-src.js +76 -58
  27. data/public/javascripts/right/lightbox.js +3 -20
  28. data/public/javascripts/right/rails-src.js +108 -107
  29. data/public/javascripts/right/rails.js +4 -11
  30. data/public/javascripts/right/rater-src.js +47 -31
  31. data/public/javascripts/right/rater.js +3 -9
  32. data/public/javascripts/right/resizable-src.js +60 -33
  33. data/public/javascripts/right/resizable.js +3 -11
  34. data/public/javascripts/right/selectable-src.js +87 -51
  35. data/public/javascripts/right/selectable.js +3 -18
  36. data/public/javascripts/right/sizzle-src.js +15 -10
  37. data/public/javascripts/right/sizzle.js +4 -27
  38. data/public/javascripts/right/slider-src.js +49 -33
  39. data/public/javascripts/right/slider.js +3 -10
  40. data/public/javascripts/right/sortable-src.js +46 -32
  41. data/public/javascripts/right/sortable.js +4 -13
  42. data/public/javascripts/right/table-src.js +19 -10
  43. data/public/javascripts/right/table.js +4 -6
  44. data/public/javascripts/right/tabs-src.js +69 -47
  45. data/public/javascripts/right/tabs.js +4 -26
  46. data/public/javascripts/right/tooltips-src.js +78 -56
  47. data/public/javascripts/right/tooltips.js +4 -9
  48. data/public/javascripts/right/uploader-src.js +50 -34
  49. data/public/javascripts/right/uploader.js +3 -9
  50. data/public/javascripts/right-olds-src.js +528 -355
  51. data/public/javascripts/right-olds.js +4 -13
  52. data/public/javascripts/right-safe-src.js +4 -99
  53. data/public/javascripts/right-safe.js +3 -4
  54. data/public/javascripts/right-src.js +1618 -1245
  55. data/public/javascripts/right.js +4 -91
  56. metadata +8 -6
@@ -1,24 +1,18 @@
1
1
  /**
2
- * RightJS Additional visual effects module
2
+ * Additional Visual Effects v2.2.0
3
3
  * http://rightjs.org/plugins/effects
4
4
  *
5
- * Copyright (C) 2008-2010 Nikolay Nemshilov
5
+ * Copyright (C) 2009-2011 Nikolay Nemshilov
6
6
  */
7
7
  (function(RightJS) {
8
8
  if (!RightJS.Fx) { throw "RightJS Fx is missing"; }
9
9
 
10
10
  /**
11
- * The basic move visual effect
12
- *
13
- * @copyright (C) 2009-2010 Nikolay V. Nemshilov
14
- */
15
-
16
- /**
17
11
  * The plugin initializtion script
18
12
  *
19
13
  * Copyright (C) 2010 Nikolay Nemshilov
20
14
  */
21
-
15
+
22
16
  var R = RightJS,
23
17
  $ = RightJS.$,
24
18
  $w = RightJS.$w,
@@ -30,8 +24,18 @@ var R = RightJS,
30
24
  defined = RightJS.defined,
31
25
  isHash = RightJS.isHash,
32
26
  isString = RightJS.isString;
33
-
34
27
 
28
+ RightJS.Effects = {
29
+ version: '2.2.0'
30
+ };
31
+
32
+
33
+
34
+ /**
35
+ * The basic move visual effect
36
+ *
37
+ * @copyright (C) 2009-2010 Nikolay V. Nemshilov
38
+ */
35
39
  Fx.Move = new Class(Fx.Morph, {
36
40
  extend: {
37
41
  Options: Object.merge(Fx.Options, {
@@ -99,11 +103,11 @@ Fx.Move = new Class(Fx.Morph, {
99
103
  /**
100
104
  * Zoom visual effect, graduately zoom and element in or out
101
105
  *
102
- * @copyright (C) 2009-2010 Nikolay V. Nemshilov
106
+ * @copyright (C) 2009-2011 Nikolay V. Nemshilov
103
107
  */
104
108
  Fx.Zoom = new Class(Fx.Move, {
105
109
  PROPERTIES: $w('width height lineHeight paddingTop paddingRight paddingBottom paddingLeft fontSize borderWidth'),
106
-
110
+
107
111
  extend: {
108
112
  Options: Object.merge(Fx.Move.Options, {
109
113
  position: 'relative', // overriding the Fx.Move default
@@ -111,110 +115,126 @@ Fx.Zoom = new Class(Fx.Move, {
111
115
  from: 'center'
112
116
  })
113
117
  },
114
-
118
+
115
119
  prepare: function(size, additional_styles) {
116
120
  return this.$super(this._getZoomedStyle(size, additional_styles));
117
121
  },
118
-
122
+
119
123
  // private
120
124
 
121
125
  // calculates the end zoommed style
122
126
  _getZoomedStyle: function(size, additional_styles) {
123
127
  var proportion = this._getProportion(size);
124
-
128
+
125
129
  return Object.merge(
126
130
  this._getBasicStyle(proportion),
127
131
  this._getEndPosition(proportion),
128
- additional_styles || {}
132
+ additional_styles
129
133
  );
130
134
  },
131
135
 
132
136
  // calculates the zooming proportion
133
137
  _getProportion: function(size) {
134
138
  if (isHash(size)) {
135
- var sizes = $E('div').insertTo(
136
- $E('div', {style: "visibility:hidden;float:left;height:0;width:0"}).insertTo(document.body)
137
- ).setStyle(size).size();
138
-
139
- if (size.height) { size = sizes.y / this.element.size().y; }
140
- else { size = sizes.x / this.element.size().x; }
139
+ var dummy = $E('div').insertTo(
140
+ $E('div', {
141
+ style: "visibility:hidden;float:left;height:0;width:0"
142
+ }).insertTo(document.body)
143
+ ).setStyle(size);
144
+
145
+ size = size.height ?
146
+ dummy.size().y / this.element.size().y :
147
+ dummy.size().x / this.element.size().x ;
148
+
149
+ dummy.remove();
141
150
  } else if (isString(size)) {
142
151
  size = R(size).endsWith('%') ? R(size).toFloat() / 100 : R(size).toFloat();
143
152
  }
144
-
153
+
145
154
  return size;
146
155
  },
147
-
156
+
148
157
  // getting the basic end style
149
158
  _getBasicStyle: function(proportion) {
150
- var style = this._cloneStyle(this.element, this.PROPERTIES), re = /([\d\.]+)/g;
151
-
159
+ var style = clone_styles(this.element, this.PROPERTIES), re = /([\d\.]+)/g;
160
+
152
161
  function adjust_value(m) {
153
162
  return ''+ (R(m).toFloat() * proportion);
154
163
  }
155
-
164
+
156
165
  for (var key in style) {
157
166
  if (key === 'width' || key === 'height') {
158
167
  style[key] = style[key] || (this.element['offset'+R(key).capitalize()]+'px');
159
168
  }
160
-
169
+
161
170
  if (style[key].match(re)) {
162
171
  style[key] = style[key].replace(re, adjust_value);
163
172
  } else {
164
173
  delete(style[key]);
165
174
  }
166
175
  }
167
-
176
+
168
177
  // preventing the border disappearance
169
178
  if (style.borderWidth && R(style.borderWidth).toFloat() < 1) {
170
179
  style.borderWidth = '1px';
171
180
  }
172
-
181
+
173
182
  return style;
174
183
  },
175
-
184
+
176
185
  // getting the position adjustments
177
186
  _getEndPosition: function(proportion) {
178
187
  var position = {};
179
188
  var sizes = this.element.size();
180
189
  var x_diff = sizes.x * (proportion - 1);
181
190
  var y_diff = sizes.y * (proportion - 1);
182
-
191
+
183
192
  switch (this.options.from.replace('-', ' ').split(' ').sort().join('_')) {
184
193
  case 'top':
185
194
  position.x = - x_diff / 2;
186
195
  break;
187
-
196
+
188
197
  case 'right':
189
198
  position.x = - x_diff;
190
199
  position.y = - y_diff / 2;
191
200
  break;
192
-
201
+
193
202
  case 'bottom':
194
203
  position.x = - x_diff / 2;
195
204
  case 'bottom_left':
196
205
  position.y = - y_diff;
197
206
  break;
198
-
207
+
199
208
  case 'bottom_right':
200
209
  position.y = - y_diff;
201
210
  case 'right_top':
202
211
  position.x = - x_diff;
203
212
  break;
204
-
213
+
205
214
  case 'center':
206
215
  position.x = - x_diff / 2;
207
216
  case 'left':
208
217
  position.y = - y_diff / 2;
209
218
  break;
210
-
219
+
211
220
  default: // left_top or none, do nothing, let the thing expand as is
212
221
  }
213
-
222
+
214
223
  return position;
215
224
  }
216
225
  });
217
226
 
227
+ function clone_styles(element, keys) {
228
+ for (var i=0, len = keys.length, style = element.computedStyles(), clean = {}, key; i < len; i++) {
229
+ key = keys[i];
230
+ if (key in style) {
231
+ clean[key] = ''+ style[key];
232
+ }
233
+ }
234
+
235
+ return clean;
236
+ }
237
+
218
238
  /**
219
239
  * Bounce visual effect, slightly moves an element forward and back
220
240
  *
@@ -356,57 +376,48 @@ Fx.Puff = new Class(Fx.Zoom, {
356
376
  });
357
377
 
358
378
  /**
359
- * Handles the to-class and from-class visual effects
379
+ * Glow effect, kinda the same thing as Hightlight, but changes the text color
360
380
  *
361
- * Copyright (C) 2009-2010 Nikolay Nemshilov
381
+ * Copyright (C) 2011 Nikolay Nemshilov
362
382
  */
363
- Fx.Css = Fx.CSS = new Class(Fx.Morph, {
364
- STYLES: $w('width height lineHeight opacity border padding margin color fontSize background top left right bottom'),
365
-
366
- // protected
367
-
368
- prepare: function(add_class, remove_class) {
369
- this.addClass = add_class || '';
370
- this.removeClass = remove_class || '';
371
-
372
- // wiring the classes add/remove on-finish
373
- if (add_class) { this.onFinish(this.element.addClass.bind(this.element, add_class)); }
374
- if (remove_class) { this.onFinish(this.element.removeClass.bind(this.element, remove_class)); }
375
-
376
- return this.$super({});
377
- },
378
-
379
- // hacking the old method to make it apply the classes
380
- _endStyle: function(style, keys) {
381
- var element = this.element, dummy = $(element._.cloneNode(true))
382
- .setStyle('position:absolute;z-index:-1;visibility:hidden')
383
- .setWidth(element.size().x)
384
- .addClass(this.addClass).removeClass(this.removeClass);
385
-
386
- if (element._.parentNode) { element.insert(dummy, 'before'); }
387
-
388
- var after = this._cloneStyle(dummy, keys);
389
-
390
- dummy.remove();
391
-
392
- return after;
383
+ Fx.Glow = new Class(Fx.Morph, {
384
+ extend: {
385
+ Options: Object.merge(Fx.Options, {
386
+ color: '#FF8',
387
+ transition: 'Exp'
388
+ })
393
389
  },
394
-
395
- // replacing the old method to make it return our own list of properties
396
- _styleKeys: function() {
397
- var hash = {};
398
- this.STYLES.each(function(name) {
399
- hash[name] = 1;
400
- });
401
-
402
- return this.$super(hash);
390
+
391
+ // protected
392
+
393
+ /**
394
+ * starts the transition
395
+ *
396
+ * @param high String the hightlight color
397
+ * @param back String optional fallback color
398
+ * @return self
399
+ */
400
+ prepare: function(start, end) {
401
+ var element = this.element,
402
+ element_style = element._.style,
403
+ style_name = 'color',
404
+ end_color = end || element.getStyle(style_name);
405
+
406
+ // trying to find the end color
407
+ end_color = [element].concat(element.parents())
408
+ .map('getStyle', style_name)
409
+ .compact().first() || '#FFF';
410
+
411
+ element_style[style_name] = (start || this.options.color);
412
+
413
+ return this.$super({color: end_color});
403
414
  }
404
415
  });
405
416
 
406
417
  /**
407
418
  * Element shortcuts for the additional effects
408
419
  *
409
- * @copyright (C) 2009-2010 Nikolay Nemshilov
420
+ * @copyright (C) 2009-2011 Nikolay Nemshilov
410
421
  */
411
422
  RightJS.Element.include({
412
423
  /**
@@ -417,9 +428,9 @@ RightJS.Element.include({
417
428
  * @return Element self
418
429
  */
419
430
  move: function(position, options) {
420
- return this.fx('move', [position, options || {}]); // <- don't replace with arguments
431
+ return call_fx(this, 'move', [position, options || {}]); // <- don't replace with arguments
421
432
  },
422
-
433
+
423
434
  /**
424
435
  * The bounce effect shortcut
425
436
  *
@@ -428,9 +439,9 @@ RightJS.Element.include({
428
439
  * @return Element self
429
440
  */
430
441
  bounce: function() {
431
- return this.fx('bounce', arguments);
442
+ return call_fx(this, 'bounce', arguments);
432
443
  },
433
-
444
+
434
445
  /**
435
446
  * The zoom effect shortcut
436
447
  *
@@ -439,9 +450,9 @@ RightJS.Element.include({
439
450
  * @return Element self
440
451
  */
441
452
  zoom: function(size, options) {
442
- return this.fx('zoom', [size, options || {}]);
453
+ return call_fx(this, 'zoom', [size, options || {}]);
443
454
  },
444
-
455
+
445
456
  /**
446
457
  * Initiates the Fx.Run effect
447
458
  *
@@ -450,9 +461,9 @@ RightJS.Element.include({
450
461
  * @return Element self
451
462
  */
452
463
  run: function() {
453
- return this.fx('run', arguments);
464
+ return call_fx(this, 'run', arguments);
454
465
  },
455
-
466
+
456
467
  /**
457
468
  * The puff effect shortcut
458
469
  *
@@ -461,21 +472,37 @@ RightJS.Element.include({
461
472
  * @return Element self
462
473
  */
463
474
  puff: function() {
464
- return this.fx('puff', arguments);
475
+ return call_fx(this, 'puff', arguments);
465
476
  },
466
-
477
+
467
478
  /**
468
- * The Fx.Class effect shortcut
479
+ * The Fx.Glow effect shortcut
469
480
  *
470
- * @param add String css-class name to add
471
- * @param remove String css-class name to remove
481
+ * @param String optinal glow color
472
482
  * @param Object fx options
483
+ * @return Element self
473
484
  */
474
- morphToClass: function() {
475
- var args = $A(arguments);
476
- if (args[0] === null) { args[0] = ''; }
477
-
478
- return this.fx('CSS', args);
485
+ glow: function() {
486
+ return call_fx(this, 'glow', arguments);
479
487
  }
480
488
  });
489
+
490
+ /**
491
+ * Runs Fx on the element
492
+ *
493
+ * @param Element element reference
494
+ * @param String fx name
495
+ * @param Array effect arguments
496
+ * @return the element back
497
+ */
498
+ function call_fx(element, name, params) {
499
+ var args = $A(params).compact(),
500
+ options = isHash(args.last()) ? args.pop() : {},
501
+ fx = new Fx[name.capitalize()](element, options);
502
+
503
+ fx.start.apply(fx, args);
504
+
505
+ return element;
506
+ }
507
+
481
508
  })(RightJS);
@@ -1,17 +1,7 @@
1
1
  /**
2
- * RightJS Additional visual effects module
2
+ * Additional Visual Effects v2.2.0
3
3
  * http://rightjs.org/plugins/effects
4
4
  *
5
- * Copyright (C) 2008-2010 Nikolay Nemshilov
5
+ * Copyright (C) 2009-2011 Nikolay Nemshilov
6
6
  */
7
- (function(g){if(!g.Fx)throw"RightJS Fx is missing";var i=g,o=g.$,n=g.$w,p=g.$A,e=g.Fx,j=g.Class,h=g.Object,q=g.Element,k=g.defined,r=g.isHash,s=g.isString;e.Move=new j(e.Morph,{extend:{Options:h.merge(e.Options,{duration:"long",position:"absolute"})},prepare:function(a){return this.$super(this.getEndPosition(a))},getEndPosition:function(a){var b=this.element.getStyle("position"),c={};if(b!="absolute"||b!="relative")this.element._.style.position=b=b=="fixed"?"absolute":"relative";if(a.top)a.y=a.top.toInt();
8
- if(a.left)a.x=a.left.toInt();var d=this.element.position(),f=this.getParentPosition(),l=d.x-f.x;f=d.y-f.y;if(this.options.position=="relative")if(b=="absolute"){if(k(a.x))a.x+=d.x;if(k(a.y))a.y+=d.x}else{if(k(a.x))a.x+=l;if(k(a.y))a.y+=f}else if(b=="relative"){if(k(a.x))a.x+=l-d.x;if(k(a.y))a.y+=f-d.y}for(var m in a)switch(m){case "top":case "left":break;case "y":c.top=a.y+"px";break;case "x":c.left=a.x+"px";break;default:c[m]=a[m]}return c},getParentPosition:function(){e.Move.Dummy=e.Move.Dummy||
9
- new q("div",{style:"width:0;height:0;visibility:hidden"});this.element.insert(e.Move.Dummy,"before");var a=e.Move.Dummy.position();e.Move.Dummy.remove();return a}});e.Zoom=new j(e.Move,{PROPERTIES:n("width height lineHeight paddingTop paddingRight paddingBottom paddingLeft fontSize borderWidth"),extend:{Options:h.merge(e.Move.Options,{position:"relative",duration:"normal",from:"center"})},prepare:function(a,b){return this.$super(this._getZoomedStyle(a,b))},_getZoomedStyle:function(a,b){var c=this._getProportion(a);
10
- return h.merge(this._getBasicStyle(c),this._getEndPosition(c),b||{})},_getProportion:function(a){if(r(a)){var b=$E("div").insertTo($E("div",{style:"visibility:hidden;float:left;height:0;width:0"}).insertTo(document.body)).setStyle(a).size();a=a.height?b.y/this.element.size().y:b.x/this.element.size().x}else if(s(a))a=i(a).endsWith("%")?i(a).toFloat()/100:i(a).toFloat();return a},_getBasicStyle:function(a){function b(l){return""+i(l).toFloat()*a}var c=this._cloneStyle(this.element,this.PROPERTIES),
11
- d=/([\d\.]+)/g;for(var f in c){if(f==="width"||f==="height")c[f]=c[f]||this.element["offset"+i(f).capitalize()]+"px";if(c[f].match(d))c[f]=c[f].replace(d,b);else delete c[f]}if(c.borderWidth&&i(c.borderWidth).toFloat()<1)c.borderWidth="1px";return c},_getEndPosition:function(a){var b={},c=this.element.size(),d=c.x*(a-1);a=c.y*(a-1);switch(this.options.from.replace("-"," ").split(" ").sort().join("_")){case "top":b.x=-d/2;break;case "right":b.x=-d;b.y=-a/2;break;case "bottom":b.x=-d/2;case "bottom_left":b.y=
12
- -a;break;case "bottom_right":b.y=-a;case "right_top":b.x=-d;break;case "center":b.x=-d/2;case "left":b.y=-a/2;break;default:}return b}});e.Bounce=new j(e,{extend:{Options:h.merge(e.Options,{duration:"short",direction:"top",value:16})},prepare:function(a){a=a||this.options.value;this.element.position();var b={duration:e.Durations[this.options.duration]||this.options.duration,position:"relative"},c="y";switch(this.options.direction){case "right":a=-a;case "left":c="x";break;case "bottom":a=-a}var d=
13
- {},f={};d[c]=-a;f[c]=a;(new e.Move(this.element,b)).start(d);(new e.Move(this.element,b)).start(f);this.finish.bind(this).delay(1);return this}});e.Run=new j(e.Move,{extend:{Options:h.merge(e.Move.Options,{direction:"left"})},prepare:function(a){var b=a||"toggle";a={};var c=this.element.dimensions();if(b=="out"||b=="toggle"&&this.element.visible()){if(this.options.direction=="left")a.x=-c.width-80;else a.y=-c.height-80;this.onFinish(function(){this.element.hide().setStyle(this.getEndPosition({x:c.left,
14
- y:c.top}))})}else{c=this.element.setStyle("visibility: hidden").show().dimensions();b={};if(this.options.direction=="left"){b.x=-c.width-80;a.x=c.left}else{b.y=-c.height-80;a.y=c.top}this.element.setStyle(this.getEndPosition(b)).setStyle("visibility: visible")}return this.$super(a)}});e.Puff=new j(e.Zoom,{extend:{Options:h.merge(e.Zoom.Options,{size:1.4})},prepare:function(a){var b=a||"toggle",c=0;a=this.options.size;var d;if(b=="out"||b=="toggle"&&this.element.visible()){d=this.getEndPosition(this._getZoomedStyle(1));
15
- this.onFinish(function(){d.opacity=1;this.element.hide().setStyle(d)})}else{this.element.setStyle("visibility: visible").show();b=this.element.offsetWidth;d=this.getEndPosition(this._getZoomedStyle(1));this.onFinish(function(){this.element.setStyle(d)});this.element.setStyle(h.merge(this.getEndPosition(this._getZoomedStyle(a)),{opacity:0,visibility:"visible"}));a=b/this.element.offsetWidth;c=1}return this.$super(a,{opacity:c})}});e.Css=e.CSS=new j(e.Morph,{STYLES:n("width height lineHeight opacity border padding margin color fontSize background top left right bottom"),
16
- prepare:function(a,b){this.addClass=a||"";this.removeClass=b||"";a&&this.onFinish(this.element.addClass.bind(this.element,a));b&&this.onFinish(this.element.removeClass.bind(this.element,b));return this.$super({})},_endStyle:function(a,b){var c=this.element,d=o(c._.cloneNode(true)).setStyle("position:absolute;z-index:-1;visibility:hidden").setWidth(c.size().x).addClass(this.addClass).removeClass(this.removeClass);c._.parentNode&&c.insert(d,"before");c=this._cloneStyle(d,b);d.remove();return c},_styleKeys:function(){var a=
17
- {};this.STYLES.each(function(b){a[b]=1});return this.$super(a)}});g.Element.include({move:function(a,b){return this.fx("move",[a,b||{}])},bounce:function(){return this.fx("bounce",arguments)},zoom:function(a,b){return this.fx("zoom",[a,b||{}])},run:function(){return this.fx("run",arguments)},puff:function(){return this.fx("puff",arguments)},morphToClass:function(){var a=p(arguments);if(a[0]===null)a[0]="";return this.fx("CSS",a)}})})(RightJS);
7
+ (function(a){function n(a,b,c){var d=e(c).compact(),g=k(d.last())?d.pop():{},h=new(f[b.capitalize()])(a,g);h.start.apply(h,d);return a}function m(a,b){for(var c=0,d=b.length,e=a.computedStyles(),f={},g;c<d;c++)g=b[c],g in e&&(f[g]=""+e[g]);return f}if(!a.Fx)throw"RightJS Fx is missing";var b=a,c=a.$,d=a.$w,e=a.$A,f=a.Fx,g=a.Class,h=a.Object,i=a.Element,j=a.defined,k=a.isHash,l=a.isString;a.Effects={version:"2.2.0"},f.Move=new g(f.Morph,{extend:{Options:h.merge(f.Options,{duration:"long",position:"absolute"})},prepare:function(a){return this.$super(this.getEndPosition(a))},getEndPosition:function(a){var b=this.element.getStyle("position"),c={};if(b!="absolute"||b!="relative")this.element._.style.position=b=b=="fixed"?"absolute":"relative";a.top&&(a.y=a.top.toInt()),a.left&&(a.x=a.left.toInt());var d=this.element.position(),e=this.getParentPosition(),f=d.x-e.x,g=d.y-e.y;this.options.position=="relative"?b=="absolute"?(j(a.x)&&(a.x+=d.x),j(a.y)&&(a.y+=d.x)):(j(a.x)&&(a.x+=f),j(a.y)&&(a.y+=g)):b=="relative"&&(j(a.x)&&(a.x+=f-d.x),j(a.y)&&(a.y+=g-d.y));for(var h in a)switch(h){case"top":case"left":break;case"y":c.top=a.y+"px";break;case"x":c.left=a.x+"px";break;default:c[h]=a[h]}return c},getParentPosition:function(){f.Move.Dummy=f.Move.Dummy||new i("div",{style:"width:0;height:0;visibility:hidden"}),this.element.insert(f.Move.Dummy,"before");var a=f.Move.Dummy.position();f.Move.Dummy.remove();return a}}),f.Zoom=new g(f.Move,{PROPERTIES:d("width height lineHeight paddingTop paddingRight paddingBottom paddingLeft fontSize borderWidth"),extend:{Options:h.merge(f.Move.Options,{position:"relative",duration:"normal",from:"center"})},prepare:function(a,b){return this.$super(this._getZoomedStyle(a,b))},_getZoomedStyle:function(a,b){var c=this._getProportion(a);return h.merge(this._getBasicStyle(c),this._getEndPosition(c),b)},_getProportion:function(a){if(k(a)){var c=$E("div").insertTo($E("div",{style:"visibility:hidden;float:left;height:0;width:0"}).insertTo(document.body)).setStyle(a);a=a.height?c.size().y/this.element.size().y:c.size().x/this.element.size().x,c.remove()}else l(a)&&(a=b(a).endsWith("%")?b(a).toFloat()/100:b(a).toFloat());return a},_getBasicStyle:function(a){function e(c){return""+b(c).toFloat()*a}var c=m(this.element,this.PROPERTIES),d=/([\d\.]+)/g;for(var f in c){if(f==="width"||f==="height")c[f]=c[f]||this.element["offset"+b(f).capitalize()]+"px";c[f].match(d)?c[f]=c[f].replace(d,e):delete c[f]}c.borderWidth&&b(c.borderWidth).toFloat()<1&&(c.borderWidth="1px");return c},_getEndPosition:function(a){var b={},c=this.element.size(),d=c.x*(a-1),e=c.y*(a-1);switch(this.options.from.replace("-"," ").split(" ").sort().join("_")){case"top":b.x=-d/2;break;case"right":b.x=-d,b.y=-e/2;break;case"bottom":b.x=-d/2;case"bottom_left":b.y=-e;break;case"bottom_right":b.y=-e;case"right_top":b.x=-d;break;case"center":b.x=-d/2;case"left":b.y=-e/2;break;default:}return b}}),f.Bounce=new g(f,{extend:{Options:h.merge(f.Options,{duration:"short",direction:"top",value:16})},prepare:function(a){a=a||this.options.value;var b=this.element.position(),c=f.Durations[this.options.duration]||this.options.duration,d={duration:c,position:"relative"},e="y";switch(this.options.direction){case"right":a=-a;case"left":e="x";break;case"bottom":a=-a}var g={},h={};g[e]=-a,h[e]=a,(new f.Move(this.element,d)).start(g),(new f.Move(this.element,d)).start(h),this.finish.bind(this).delay(1);return this}}),f.Run=new g(f.Move,{extend:{Options:h.merge(f.Move.Options,{direction:"left"})},prepare:function(a){var b=a||"toggle",c={},d=this.element.dimensions(),e=80;if(b=="out"||b=="toggle"&&this.element.visible())this.options.direction=="left"?c.x=-d.width-e:c.y=-d.height-e,this.onFinish(function(){this.element.hide().setStyle(this.getEndPosition({x:d.left,y:d.top}))});else{d=this.element.setStyle("visibility: hidden").show().dimensions();var f={};this.options.direction=="left"?(f.x=-d.width-e,c.x=d.left):(f.y=-d.height-e,c.y=d.top),this.element.setStyle(this.getEndPosition(f)).setStyle("visibility: visible")}return this.$super(c)}}),f.Puff=new g(f.Zoom,{extend:{Options:h.merge(f.Zoom.Options,{size:1.4})},prepare:function(a){var b=a||"toggle",c=0,d=this.options.size,e;if(b=="out"||b=="toggle"&&this.element.visible())e=this.getEndPosition(this._getZoomedStyle(1)),this.onFinish(function(){e.opacity=1,this.element.hide().setStyle(e)});else{this.element.setStyle("visibility: visible").show();var f=this.element.offsetWidth;e=this.getEndPosition(this._getZoomedStyle(1)),this.onFinish(function(){this.element.setStyle(e)}),this.element.setStyle(h.merge(this.getEndPosition(this._getZoomedStyle(d)),{opacity:0,visibility:"visible"})),d=f/this.element.offsetWidth,c=1}return this.$super(d,{opacity:c})}}),f.Glow=new g(f.Morph,{extend:{Options:h.merge(f.Options,{color:"#FF8",transition:"Exp"})},prepare:function(a,b){var c=this.element,d=c._.style,e="color",f=b||c.getStyle(e);f=[c].concat(c.parents()).map("getStyle",e).compact().first()||"#FFF",d[e]=a||this.options.color;return this.$super({color:f})}}),a.Element.include({move:function(a,b){return n(this,"move",[a,b||{}])},bounce:function(){return n(this,"bounce",arguments)},zoom:function(a,b){return n(this,"zoom",[a,b||{}])},run:function(){return n(this,"run",arguments)},puff:function(){return n(this,"puff",arguments)},glow:function(){return n(this,"glow",arguments)}})})(RightJS)
@@ -1,8 +1,8 @@
1
1
  /**
2
- * Inline editor feature for RightJS
3
- * http://rightjs.org/ui/in-edit
2
+ * RightJS-UI InEdit v2.2.0
3
+ * http://rightjs.org/ui/in-edit
4
4
  *
5
- * Copyright (C) 2009-2010 Nikolay Nemshilov
5
+ * Copyright (C) 2009-2011 Nikolay Nemshilov
6
6
  */
7
7
  var InEdit = RightJS.InEdit = (function(document, RightJS) {
8
8
  /**
@@ -10,30 +10,9 @@ var InEdit = RightJS.InEdit = (function(document, RightJS) {
10
10
  * it creates an abstract proxy with the common functionality
11
11
  * which then we reuse and override in the actual widgets
12
12
  *
13
- * Copyright (C) 2010 Nikolay Nemshilov
13
+ * Copyright (C) 2010-2011 Nikolay Nemshilov
14
14
  */
15
15
 
16
- /**
17
- * In-Edit plugin initalization
18
- *
19
- * Copyright (C) 2010 Nikolay Nemshilov
20
- */
21
- var R = RightJS,
22
- $ = RightJS.$,
23
- $w = RightJS.$w,
24
- Xhr = RightJS.Xhr,
25
- Object = RightJS.Object,
26
- Element = RightJS.Element,
27
- Input = RightJS.Input;
28
-
29
-
30
-
31
-
32
-
33
-
34
-
35
-
36
-
37
16
  /**
38
17
  * The widget units constructor
39
18
  *
@@ -52,7 +31,7 @@ function Widget(tag_name, methods) {
52
31
  *
53
32
  * Copyright (C) 2010 Nikolay Nemshilov
54
33
  */
55
- var AbstractWidget = new RightJS.Wrapper(RightJS.Element.Wrappers[tag_name] || RightJS.Element, {
34
+ var AbstractWidget = new RightJS.Class(RightJS.Element.Wrappers[tag_name] || RightJS.Element, {
56
35
  /**
57
36
  * The common constructor
58
37
  *
@@ -84,7 +63,8 @@ function Widget(tag_name, methods) {
84
63
  options = {};
85
64
  }
86
65
  this.setOptions(options, this);
87
- return this;
66
+
67
+ return (RightJS.Wrapper.Cache[RightJS.$uid(this._)] = this);
88
68
  },
89
69
 
90
70
  // protected
@@ -97,12 +77,16 @@ function Widget(tag_name, methods) {
97
77
  * @return void
98
78
  */
99
79
  setOptions: function(options, element) {
100
- element = element || this;
101
- RightJS.Options.setOptions.call(this,
102
- RightJS.Object.merge(options, eval("("+(
80
+ if (element) {
81
+ options = RightJS.Object.merge(options, new Function("return "+(
103
82
  element.get('data-'+ this.key) || '{}'
104
- )+")"))
105
- );
83
+ ))());
84
+ }
85
+
86
+ if (options) {
87
+ RightJS.Options.setOptions.call(this, RightJS.Object.merge(this.options, options));
88
+ }
89
+
106
90
  return this;
107
91
  }
108
92
  });
@@ -111,7 +95,7 @@ function Widget(tag_name, methods) {
111
95
  * Creating the actual widget class
112
96
  *
113
97
  */
114
- var Klass = new RightJS.Wrapper(AbstractWidget, methods);
98
+ var Klass = new RightJS.Class(AbstractWidget, methods);
115
99
 
116
100
  // creating the widget related shortcuts
117
101
  RightJS.Observer.createShortcuts(Klass.prototype, Klass.EVENTS || []);
@@ -123,9 +107,9 @@ function Widget(tag_name, methods) {
123
107
  /**
124
108
  * A shared module to create textual spinners
125
109
  *
126
- * Copyright (C) 2010 Nikolay Nemshilov
110
+ * Copyright (C) 2010-2011 Nikolay Nemshilov
127
111
  */
128
- var Spinner = new RightJS.Wrapper(RightJS.Element, {
112
+ var Spinner = new RightJS.Class(RightJS.Element, {
129
113
  /**
130
114
  * Constructor
131
115
  *
@@ -160,14 +144,35 @@ var Spinner = new RightJS.Wrapper(RightJS.Element, {
160
144
  });
161
145
 
162
146
 
147
+ /**
148
+ * In-Edit plugin initalization
149
+ *
150
+ * Copyright (C) 2010 Nikolay Nemshilov
151
+ */
152
+ var R = RightJS,
153
+ $ = RightJS.$,
154
+ $w = RightJS.$w,
155
+ Xhr = RightJS.Xhr,
156
+ Object = RightJS.Object,
157
+ Element = RightJS.Element,
158
+ Input = RightJS.Input;
159
+
160
+
161
+
162
+
163
+
164
+
165
+
166
+
167
+
163
168
  /**
164
169
  * An inline editor feature
165
170
  *
166
- * Copyright (C) 2009-2010 Nikolay Nemshilov
171
+ * Copyright (C) 2009-2011 Nikolay Nemshilov
167
172
  */
168
173
  var InEdit = new Widget('FORM', {
169
174
  extend: {
170
- version: '2.0.0',
175
+ version: '2.2.0',
171
176
 
172
177
  EVENTS: $w('show hide send update'),
173
178
 
@@ -351,7 +356,18 @@ Element.include({
351
356
  });
352
357
 
353
358
 
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>");
359
+ var embed_style = document.createElement('style'),
360
+ embed_rules = document.createTextNode("div.rui-spinner,div.rui-spinner div{margin:0;padding:0;border:none;background:none;list-style:none;font-weight:normal;float:none;display:inline-block; *display:inline; *zoom:1;border-radius:.12em;-moz-border-radius:.12em;-webkit-border-radius:.12em}div.rui-spinner{text-align:center;white-space:nowrap;background:#EEE;border:1px solid #DDD;height:1.2em;padding:0 .2em}div.rui-spinner div{width:.4em;height:70%;background:#BBB;margin-left:1px}div.rui-spinner div:first-child{margin-left:0}div.rui-spinner div.glowing{background:#777}form.rui-in-edit,form.rui-in-edit .cancel{margin:0;padding:0;float:none;position:static}form.rui-in-edit{display:inline-block; *display:inline; *zoom:1;border:none;background:none}form.rui-in-edit div.rui-spinner{margin-right:.2em}form.rui-in-edit div.rui-spinner div{margin-top:.2em}form.rui-in-edit textarea.field{width:100%;margin-bottom:.5em}form.rui-in-edit .field,form.rui-in-edit .submit{margin-right:.2em}form.rui-in-edit,form.rui-in-edit .field,form.rui-in-edit .submit,form.rui-in-edit div.rui-spinner,form.rui-in-edit .cancel{vertical-align:middle}");
361
+
362
+ embed_style.type = 'text/css';
363
+ document.getElementsByTagName('head')[0].appendChild(embed_style);
364
+
365
+ if(embed_style.styleSheet) {
366
+ embed_style.styleSheet.cssText = embed_rules.nodeValue;
367
+ } else {
368
+ embed_style.appendChild(embed_rules);
369
+ }
370
+
355
371
 
356
372
  return InEdit;
357
373
  })(document, RightJS);
@@ -1,13 +1,7 @@
1
1
  /**
2
- * Inline editor feature for RightJS
3
- * http://rightjs.org/ui/in-edit
2
+ * RightJS-UI InEdit v2.2.0
3
+ * http://rightjs.org/ui/in-edit
4
4
  *
5
- * Copyright (C) 2009-2010 Nikolay Nemshilov
5
+ * Copyright (C) 2009-2011 Nikolay Nemshilov
6
6
  */
7
- var InEdit=RightJS.InEdit=function(i,a){var g=a.$,m=a.$w,n=a.Xhr,o=a.Object,j=a.Element,k=a.Input,p=new a.Wrapper(a.Element,{initialize:function(b){this.$super("div",{"class":"rui-spinner"});this.dots=[];for(var e=0;e<(b||4);e++)this.dots.push(new a.Element("div"));this.dots[0].addClass("glowing");this.insert(this.dots);a(this.shift).bind(this).periodical(300)},shift:function(){if(this.visible()){var b=this.dots.pop();this.dots.unshift(b);this.insert(b,"top")}}}),d=new (function(b,e){if(!e){e=b;b=
8
- "DIV"}var f=new a.Wrapper(a.Element.Wrappers[b]||a.Element,{initialize:function(h,c){this.key=h;var l=[{"class":"rui-"+h}];this instanceof a.Input||this instanceof a.Form||l.unshift(b);this.$super.apply(this,l);if(a.isString(c))c=a.$(c);if(c instanceof a.Element){this._=c._;if("$listeners"in c)c.$listeners=c.$listeners;c={}}this.setOptions(c,this);return this},setOptions:function(h,c){c=c||this;a.Options.setOptions.call(this,a.Object.merge(h,eval("("+(c.get("data-"+this.key)||"{}")+")")));return this}});
9
- f=new a.Wrapper(f,e);a.Observer.createShortcuts(f.prototype,f.EVENTS||[]);return f})("FORM",{extend:{version:"2.0.0",EVENTS:m("show hide send update"),Options:{url:null,name:"text",method:"put",type:"text",toggle:null,update:true,Xhr:{}},i18n:{Save:"Save",Cancel:"Cancel"},current:null},initialize:function(b,e){this.element=g(b);this.$super("in-edit",e).set("action",this.options.url).insert([this.field=new k({type:this.options.type,name:this.options.name,"class":"field"}),this.spinner=new p(4),this.submit=
10
- new k({type:"submit","class":"submit",value:d.i18n.Save}),this.cancel=new j("a",{"class":"cancel",href:"#",html:d.i18n.Cancel})]).onClick(this.clicked).onSubmit(this.send)},show:function(){if(d.current!==this){d.current&&d.current.hide();this.oldContent=this.element.html();a(["file","password"]).include(this.options.type)||this.field.setValue(this.oldContent);this.element.update(this);this.spinner.hide();this.submit.show();this.options.toggle&&g(this.options.toggle).hide()}this.options.type!=="file"&&
11
- this.field.focus();d.current=this;return this.fire("show")},hide:function(){this.element._.innerHTML=this.oldContent;this.xhr&&this.xhr.cancel();return this.finish()},send:function(b){b&&b.stop();this.spinner.show().resize(this.submit.size());this.submit.hide();this.xhr=(new n(this.options.url,o.merge(this.options.Xhr,{method:this.options.method,spinner:this.spinner,onComplete:a(this.receive).bind(this)}))).send(this);return this.fire("send")},finish:function(){this.options.toggle&&g(this.options.toggle).show();
12
- d.current=null;return this.fire("hide")},receive:function(){if(this.options.update){this.element.update(this.xhr.text);this.fire("update")}this.xhr=null;this.finish()},clicked:function(b){if(b.target===this.cancel){b.stop();this.hide()}}});g(i).onKeydown(function(b){b.keyCode===27&&d.current&&d.current.hide()});j.include({inEdit:function(b){return(new d(this,b)).show()}});i.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>');
13
- return d}(document,RightJS);
7
+ var InEdit=RightJS.InEdit=function(a,b){function c(a,c){c||(c=a,a="DIV");var d=new b.Class(b.Element.Wrappers[a]||b.Element,{initialize:function(c,d){this.key=c;var e=[{"class":"rui-"+c}];this instanceof b.Input||this instanceof b.Form||e.unshift(a),this.$super.apply(this,e),b.isString(d)&&(d=b.$(d)),d instanceof b.Element&&(this._=d._,"$listeners"in d&&(d.$listeners=d.$listeners),d={}),this.setOptions(d,this);return b.Wrapper.Cache[b.$uid(this._)]=this},setOptions:function(a,c){c&&(a=b.Object.merge(a,(new Function("return "+(c.get("data-"+this.key)||"{}")))())),a&&b.Options.setOptions.call(this,b.Object.merge(this.options,a));return this}}),e=new b.Class(d,c);b.Observer.createShortcuts(e.prototype,e.EVENTS||[]);return e}var d=new b.Class(b.Element,{initialize:function(a){this.$super("div",{"class":"rui-spinner"}),this.dots=[];for(var c=0;c<(a||4);c++)this.dots.push(new b.Element("div"));this.dots[0].addClass("glowing"),this.insert(this.dots),b(this.shift).bind(this).periodical(300)},shift:function(){if(this.visible()){var a=this.dots.pop();this.dots.unshift(a),this.insert(a,"top")}}}),e=b,f=b.$,g=b.$w,h=b.Xhr,i=b.Object,j=b.Element,k=b.Input,l=new c("FORM",{extend:{version:"2.2.0",EVENTS:g("show hide send update"),Options:{url:null,name:"text",method:"put",type:"text",toggle:null,update:!0,Xhr:{}},i18n:{Save:"Save",Cancel:"Cancel"},current:null},initialize:function(a,b){this.element=f(a),this.$super("in-edit",b).set("action",this.options.url).insert([this.field=new k({type:this.options.type,name:this.options.name,"class":"field"}),this.spinner=new d(4),this.submit=new k({type:"submit","class":"submit",value:l.i18n.Save}),this.cancel=new j("a",{"class":"cancel",href:"#",html:l.i18n.Cancel})]).onClick(this.clicked).onSubmit(this.send)},show:function(){l.current!==this&&(l.current&&l.current.hide(),this.oldContent=this.element.html(),e(["file","password"]).include(this.options.type)||this.field.setValue(this.oldContent),this.element.update(this),this.spinner.hide(),this.submit.show(),this.options.toggle&&f(this.options.toggle).hide()),this.options.type!=="file"&&this.field.focus(),l.current=this;return this.fire("show")},hide:function(){this.element._.innerHTML=this.oldContent,this.xhr&&this.xhr.cancel();return this.finish()},send:function(a){a&&a.stop(),this.spinner.show().resize(this.submit.size()),this.submit.hide(),this.xhr=(new h(this.options.url,i.merge(this.options.Xhr,{method:this.options.method,spinner:this.spinner,onComplete:e(this.receive).bind(this)}))).send(this);return this.fire("send")},finish:function(){this.options.toggle&&f(this.options.toggle).show(),l.current=null;return this.fire("hide")},receive:function(){this.options.update&&(this.element.update(this.xhr.text),this.fire("update")),this.xhr=null,this.finish()},clicked:function(a){a.target===this.cancel&&(a.stop(),this.hide())}});f(a).onKeydown(function(a){a.keyCode===27&&l.current&&l.current.hide()}),j.include({inEdit:function(a){return(new l(this,a)).show()}});var m=a.createElement("style"),n=a.createTextNode("div.rui-spinner,div.rui-spinner div{margin:0;padding:0;border:none;background:none;list-style:none;font-weight:normal;float:none;display:inline-block; *display:inline; *zoom:1;border-radius:.12em;-moz-border-radius:.12em;-webkit-border-radius:.12em}div.rui-spinner{text-align:center;white-space:nowrap;background:#EEE;border:1px solid #DDD;height:1.2em;padding:0 .2em}div.rui-spinner div{width:.4em;height:70%;background:#BBB;margin-left:1px}div.rui-spinner div:first-child{margin-left:0}div.rui-spinner div.glowing{background:#777}form.rui-in-edit,form.rui-in-edit .cancel{margin:0;padding:0;float:none;position:static}form.rui-in-edit{display:inline-block; *display:inline; *zoom:1;border:none;background:none}form.rui-in-edit div.rui-spinner{margin-right:.2em}form.rui-in-edit div.rui-spinner div{margin-top:.2em}form.rui-in-edit textarea.field{width:100%;margin-bottom:.5em}form.rui-in-edit .field,form.rui-in-edit .submit{margin-right:.2em}form.rui-in-edit,form.rui-in-edit .field,form.rui-in-edit .submit,form.rui-in-edit div.rui-spinner,form.rui-in-edit .cancel{vertical-align:middle}");m.type="text/css",a.getElementsByTagName("head")[0].appendChild(m),m.styleSheet?m.styleSheet.cssText=n.nodeValue:m.appendChild(n);return l}(document,RightJS)