right-rails 1.2.2 → 1.3.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (131) hide show
  1. data/CHANGELOG +7 -0
  2. data/README.rdoc +1 -1
  3. data/Rakefile +1 -1
  4. data/init.rb +1 -0
  5. data/lib/generators/right_rails/right_rails_generator.rb +15 -6
  6. data/lib/right_rails.rb +1 -1
  7. data/lib/right_rails/controller_extensions.rb +28 -15
  8. data/lib/right_rails/helpers/misc.rb +38 -38
  9. data/lib/right_rails/helpers/rails.rb +50 -7
  10. data/lib/rjs_renderer.rb +26 -0
  11. data/spec/lib/right_rails/controller_extensions_spec.rb +25 -14
  12. data/spec/lib/right_rails/helpers/forms_spec.rb +6 -6
  13. data/spec/lib/right_rails/helpers/rails_spec.rb +44 -45
  14. data/vendor/assets/images/rightjs-ui/rte.png +0 -0
  15. data/vendor/assets/javascripts/right-safe-src.js +2 -2
  16. data/vendor/assets/javascripts/right-safe.js +2 -2
  17. data/vendor/assets/javascripts/right-src.js +386 -100
  18. data/vendor/assets/javascripts/right.js +2 -2
  19. data/vendor/assets/javascripts/right/calendar-src.js +19 -3
  20. data/vendor/assets/javascripts/right/calendar.js +2 -2
  21. data/vendor/assets/javascripts/right/colorpicker-src.js +59 -20
  22. data/vendor/assets/javascripts/right/colorpicker.js +2 -2
  23. data/vendor/assets/javascripts/right/i18n/de.js +43 -42
  24. data/vendor/assets/javascripts/right/i18n/es.js +1 -0
  25. data/vendor/assets/javascripts/right/i18n/fi.js +1 -0
  26. data/vendor/assets/javascripts/right/i18n/fr.js +1 -0
  27. data/vendor/assets/javascripts/right/i18n/hu.js +1 -0
  28. data/vendor/assets/javascripts/right/i18n/it.js +1 -0
  29. data/vendor/assets/javascripts/right/i18n/jp.js +1 -0
  30. data/vendor/assets/javascripts/right/i18n/lt.js +96 -0
  31. data/vendor/assets/javascripts/right/i18n/nl.js +1 -0
  32. data/vendor/assets/javascripts/right/i18n/pt-br.js +1 -0
  33. data/vendor/assets/javascripts/right/i18n/ru.js +1 -0
  34. data/vendor/assets/javascripts/right/i18n/ua.js +1 -0
  35. data/vendor/assets/javascripts/right/jquerysh-src.js +4 -4
  36. data/vendor/assets/javascripts/right/jquerysh.js +2 -2
  37. data/vendor/assets/javascripts/right/rails-src.js +51 -15
  38. data/vendor/assets/javascripts/right/rails.js +2 -2
  39. data/vendor/assets/javascripts/right/resizable-src.js +11 -11
  40. data/vendor/assets/javascripts/right/rte-src.js +33 -13
  41. data/vendor/assets/javascripts/right/rte.js +2 -2
  42. data/vendor/assets/javascripts/right/slider-src.js +137 -28
  43. data/vendor/assets/javascripts/right/slider.js +2 -2
  44. metadata +24 -126
  45. data/generators/right_rails/right_rails_generator.rb +0 -46
  46. data/generators/right_rails/templates/iframed.html.erb +0 -10
  47. data/generators/right_scaffold/right_scaffold_generator.rb +0 -53
  48. data/generators/right_scaffold/templates/controller.rb +0 -99
  49. data/generators/right_scaffold/templates/helper.rb +0 -2
  50. data/generators/right_scaffold/templates/layout.html.erb +0 -18
  51. data/generators/right_scaffold/templates/style.css +0 -54
  52. data/generators/right_scaffold/templates/view__form.html.erb +0 -16
  53. data/generators/right_scaffold/templates/view__item.html.erb +0 -13
  54. data/generators/right_scaffold/templates/view_edit.html.erb +0 -6
  55. data/generators/right_scaffold/templates/view_index.html.erb +0 -9
  56. data/generators/right_scaffold/templates/view_new.html.erb +0 -5
  57. data/generators/right_scaffold/templates/view_show.html.erb +0 -10
  58. data/lib/generators/right_rails/templates/iframed.html.erb +0 -10
  59. data/public/images/rightjs-ui/colorpicker.png +0 -0
  60. data/public/images/rightjs-ui/resizable.png +0 -0
  61. data/public/images/rightjs-ui/rte.png +0 -0
  62. data/public/javascripts/right-olds-src.js +0 -652
  63. data/public/javascripts/right-olds.js +0 -9
  64. data/public/javascripts/right-safe-src.js +0 -68
  65. data/public/javascripts/right-safe.js +0 -7
  66. data/public/javascripts/right-src.js +0 -6014
  67. data/public/javascripts/right.js +0 -7
  68. data/public/javascripts/right/autocompleter-src.js +0 -625
  69. data/public/javascripts/right/autocompleter.js +0 -7
  70. data/public/javascripts/right/billboard-src.js +0 -564
  71. data/public/javascripts/right/billboard.js +0 -7
  72. data/public/javascripts/right/calendar-src.js +0 -1464
  73. data/public/javascripts/right/calendar.js +0 -7
  74. data/public/javascripts/right/casting-src.js +0 -183
  75. data/public/javascripts/right/casting.js +0 -7
  76. data/public/javascripts/right/colorpicker-src.js +0 -981
  77. data/public/javascripts/right/colorpicker.js +0 -7
  78. data/public/javascripts/right/dialog-src.js +0 -768
  79. data/public/javascripts/right/dialog.js +0 -7
  80. data/public/javascripts/right/dnd-src.js +0 -591
  81. data/public/javascripts/right/dnd.js +0 -7
  82. data/public/javascripts/right/effects-src.js +0 -508
  83. data/public/javascripts/right/effects.js +0 -7
  84. data/public/javascripts/right/i18n/de.js +0 -95
  85. data/public/javascripts/right/i18n/en-us.js +0 -11
  86. data/public/javascripts/right/i18n/es.js +0 -95
  87. data/public/javascripts/right/i18n/fi.js +0 -96
  88. data/public/javascripts/right/i18n/fr.js +0 -95
  89. data/public/javascripts/right/i18n/hu.js +0 -100
  90. data/public/javascripts/right/i18n/it.js +0 -95
  91. data/public/javascripts/right/i18n/jp.js +0 -99
  92. data/public/javascripts/right/i18n/nl.js +0 -95
  93. data/public/javascripts/right/i18n/pt-br.js +0 -95
  94. data/public/javascripts/right/i18n/ru.js +0 -95
  95. data/public/javascripts/right/i18n/ua.js +0 -99
  96. data/public/javascripts/right/in-edit-src.js +0 -373
  97. data/public/javascripts/right/in-edit.js +0 -7
  98. data/public/javascripts/right/jquerysh-src.js +0 -362
  99. data/public/javascripts/right/jquerysh.js +0 -7
  100. data/public/javascripts/right/json-src.js +0 -147
  101. data/public/javascripts/right/json.js +0 -7
  102. data/public/javascripts/right/keys-src.js +0 -87
  103. data/public/javascripts/right/keys.js +0 -7
  104. data/public/javascripts/right/lightbox-src.js +0 -931
  105. data/public/javascripts/right/lightbox.js +0 -7
  106. data/public/javascripts/right/rails-src.js +0 -402
  107. data/public/javascripts/right/rails.js +0 -7
  108. data/public/javascripts/right/rater-src.js +0 -384
  109. data/public/javascripts/right/rater.js +0 -7
  110. data/public/javascripts/right/resizable-src.js +0 -465
  111. data/public/javascripts/right/resizable.js +0 -7
  112. data/public/javascripts/right/rte-src.js +0 -2685
  113. data/public/javascripts/right/rte.js +0 -7
  114. data/public/javascripts/right/selectable-src.js +0 -725
  115. data/public/javascripts/right/selectable.js +0 -7
  116. data/public/javascripts/right/sizzle-src.js +0 -1132
  117. data/public/javascripts/right/sizzle.js +0 -7
  118. data/public/javascripts/right/slider-src.js +0 -395
  119. data/public/javascripts/right/slider.js +0 -7
  120. data/public/javascripts/right/sortable-src.js +0 -430
  121. data/public/javascripts/right/sortable.js +0 -7
  122. data/public/javascripts/right/table-src.js +0 -176
  123. data/public/javascripts/right/table.js +0 -7
  124. data/public/javascripts/right/tabs-src.js +0 -1157
  125. data/public/javascripts/right/tabs.js +0 -7
  126. data/public/javascripts/right/tags-src.js +0 -745
  127. data/public/javascripts/right/tags.js +0 -7
  128. data/public/javascripts/right/tooltips-src.js +0 -331
  129. data/public/javascripts/right/tooltips.js +0 -7
  130. data/public/javascripts/right/uploader-src.js +0 -302
  131. data/public/javascripts/right/uploader.js +0 -7
@@ -1,7 +0,0 @@
1
- /**
2
- * Drag'n'Drop module v2.2.2
3
- * http://rightjs.org/plugins/drag-n-drop
4
- *
5
- * Copyright (C) 2009-2011 Nikolay Nemshilov
6
- */
7
- (function(a,b,c){var d=c,e=c.$,f=c.$w,g=c.Class,h=c.isHash,i=c.isArray,j=c.Element,k=c.Observer,l=new g(k,{extend:{version:"2.2.2",EVENTS:f("before start drag stop drop"),Options:{handle:null,snap:0,axis:null,range:null,dragClass:"dragging",clone:!1,revert:!1,revertDuration:"normal",scroll:!0,scrollSensitivity:32,zIndex:1e7,moveOut:!1,relName:"draggable"},current:null,rescan:function(a){var c=this.Options.relName,d=this===l?"draggable":"droppable";(e(a)||e(b)).find('*[rel^="'+c+'"]').each(function(a){a[d]||new this(a,(new Function("return "+a.get("data-"+c)))()||{})},this)}},initialize:function(a,b){this.element=e(a),this.$super(b),this._dragStart=d(this.dragStart).bind(this),this.handle.onMousedown(this._dragStart),this.element.draggable=this},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?e(this.options.handle):this.element,i(this.options.snap)?(this.snapX=this.options.snap[0],this.snapY=this.options.snap[1]):this.snapX=this.snapY=this.options.snap;return this},revert:function(){var a=this.clone.position(),b={top:a.y+this.ryDiff+"px",left:a.x+this.rxDiff+"px"};this.options.revertDuration&&this.element.morph?this.element.morph(b,{duration:this.options.revertDuration,onFinish:d(this.swapBack).bind(this)}):(this.element.setStyle(b),this.swapBack());return this},dragStart:function(c){if(this._drag)return!1;this._drag=!0,this.fire("before",this,c.stop());var d=this.element.position();this.xDiff=c.pageX-d.x,this.yDiff=c.pageY-d.y,this.rxDiff=this.ryDiff=0,this.element.parents().reverse().each(function(a){a.getStyle("position")!=="static"&&(a=a.position(),this.rxDiff=-a.x,this.ryDiff=-a.y)},this);var f={x:this.element.getStyle("width"),y:this.element.getStyle("height")};f.x=="auto"&&(f.x=this.element._.offsetWidth+"px"),f.y=="auto"&&(f.y=this.element._.offsetHeight+"px");if(this.options.clone||this.options.revert)this.clone=(new j(this.element._.cloneNode(!0))).setStyle({visibility:this.options.clone?"visible":"hidden"}).insertTo(this.element,"before");this.element.setStyle({position:"absolute",zIndex:l.Options.zIndex++,top:d.y+this.ryDiff+"px",left:d.x+this.rxDiff+"px",width:f.x,height:f.y}).addClass(this.options.dragClass),this.options.moveOut&&this.element.insertTo(b.body),this.winScrolls=e(a).scrolls(),this.winSizes=e(a).size(),l.current=this.calcConstraints().fire("start",this,c),this.style=this.element._.style},dragProcess:function(b){var c=b.pageX,d=b.pageY,f=c-this.xDiff,g=d-this.yDiff;this.ranged&&(this.minX>f&&(f=this.minX),this.maxX<f&&(f=this.maxX),this.minY>g&&(g=this.minY),this.maxY<g&&(g=this.maxY));if(this.options.scroll){var h={x:this.winScrolls.x,y:this.winScrolls.y},i=this.options.scrollSensitivity;d-h.y<i?h.y=d-i:h.y+this.winSizes.y-d<i&&(h.y=d-this.winSizes.y+i),c-h.x<i?h.x=c-i:h.x+this.winSizes.x-c<i&&(h.x=c-this.winSizes.x+i),h.y<0&&(h.y=0),h.x<0&&(h.x=0),(h.y<this.winScrolls.y||h.y>this.winScrolls.y||h.x<this.winScrolls.x||h.x>this.winScrolls.x)&&e(a).scrollTo(this.winScrolls=h)}this.snapX&&(f=f-f%this.snapX),this.snapY&&(g=g-g%this.snapY),this.axisY||(this.style.left=f+this.rxDiff+"px"),this.axisX||(this.style.top=g+this.ryDiff+"px"),this.fire("drag",this,b)},dragStop:function(a){this.element.removeClass(this.options.dragClass),m.checkDrop(a,this),this.options.revert?this.revert():this._drag=!1,l.current=null,this.fire("stop",this,a)},swapBack:function(){this.clone&&this.clone.replace(this.element.setStyle({width:this.clone.getStyle("width"),height:this.clone.getStyle("height"),position:this.clone.getStyle("position"),zIndex:this.clone.getStyle("zIndex")||""})),this._drag=!1},calcConstraints:function(){var a=this.options.axis;this.axisX=d(["x","horizontal"]).include(a),this.axisY=d(["y","vertical"]).include(a),this.ranged=!1;var b=this.options.range;if(b){this.ranged=!0;var c=e(b);if(c instanceof j){var f=c.dimensions();b={x:[f.left,f.left+f.width],y:[f.top,f.top+f.height]}}if(h(b)){var g=this.element.size();b.x&&(this.minX=b.x[0],this.maxX=b.x[1]-g.x),b.y&&(this.minY=b.y[0],this.maxY=b.y[1]-g.y)}}return this}}),m=new g(k,{extend:{EVENTS:f("drop hover leave"),Options:{accept:"*",containment:null,overlap:null,overlapSize:.5,allowClass:"droppable-allow",denyClass:"droppable-deny",relName:"droppable"},rescan:l.rescan,checkHover:function(a,b){for(var c=0,d=this.active.length;c<d;c++)this.active[c].checkHover(a,b)},checkDrop:function(a,b){for(var c=0,d=this.active.length;c<d;c++)this.active[c].checkDrop(a,b)},active:[]},initialize:function(a,b){this.element=e(a),this.$super(b),m.active.push(this.element._droppable=this)},destroy:function(){m.active=m.active.without(this),delete this.element.droppable;return this},checkHover:function(a,b){this.hoveredBy(a,b)?this._hovered||(this._hovered=!0,this.element.addClass(this.options[this.allows(b)?"allowClass":"denyClass"]),this.fire("hover",b,this,a)):this._hovered&&(this._hovered=!1,this.reset().fire("leave",b,this,a))},checkDrop:function(a,b){this.reset(),this.hoveredBy(a,b)&&this.allows(b)&&(b.fire("drop",this,b,a),this.fire("drop",b,this,a))},reset:function(){this.element.removeClass(this.options.allowClass).removeClass(this.options.denyClass);return this},hoveredBy:function(a,b){var c=this.element.dimensions(),d=c.top,e=c.left,f=c.left+c.width,g=c.top+c.height,h=a.pageX,i=a.pageY;if(!this.options.overlap)return h>e&&h<f&&i>d&&i<g;var j=b.element.dimensions(),k=this.options.overlapSize,l=j.top,m=j.left,n=j.left+j.width,o=j.top+j.height;switch(this.options.overlap){case"x":case"horizontal":return(l>d&&l<g||o>d&&o<g)&&(m>e&&m<f-c.width*k||n<f&&n>e+c.width*k);case"y":case"vertical":return(m>e&&m<f||n>e&&n<f)&&(l>d&&l<g-c.height*k||o<g&&o>d+c.height*k);default:return(m>e&&m<f-c.width*k||n<f&&n>e+c.width*k)&&(l>d&&l<g-c.height*k||o<g&&o>d+c.height*k)}},allows:function(a){this.options.containment&&!this._scanned&&(this.options.containment=d(this.options.containment).map(e),this._scanned=!0);var b=this.options.containment?this.options.containment.includes(a.element):!0;return b&&(this.options.accept=="*"?!0:a.element.match(this.options.accept))}});e(b).on({ready:function(){l.rescan(),m.rescan()},mousemove:function(a){l.current!==null&&(l.current.dragProcess(a),m.checkHover(a,l.current))},mouseup:function(a){l.current!==null&&l.current.dragStop(a)}}),j.include({makeDraggable:function(a){new l(this,a);return this},undoDraggable:function(){"draggable"in this&&this.draggable.destroy();return this},makeDroppable:function(a){new m(this,a);return this},undoDroppable:function(){"droppable"in this&&this.droppable.destroy();return this}}),a.Draggable=c.Draggable=l,a.Droppable=c.Droppable=m})(window,document,RightJS)
@@ -1,508 +0,0 @@
1
- /**
2
- * Additional Visual Effects v2.2.0
3
- * http://rightjs.org/plugins/effects
4
- *
5
- * Copyright (C) 2009-2011 Nikolay Nemshilov
6
- */
7
- (function(RightJS) {
8
- if (!RightJS.Fx) { throw "RightJS Fx is missing"; }
9
-
10
- /**
11
- * The plugin initializtion script
12
- *
13
- * Copyright (C) 2010 Nikolay Nemshilov
14
- */
15
-
16
- var R = RightJS,
17
- $ = RightJS.$,
18
- $w = RightJS.$w,
19
- $A = RightJS.$A,
20
- Fx = RightJS.Fx,
21
- Class = RightJS.Class,
22
- Object = RightJS.Object,
23
- Element = RightJS.Element,
24
- defined = RightJS.defined,
25
- isHash = RightJS.isHash,
26
- isString = RightJS.isString;
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
- */
39
- Fx.Move = new Class(Fx.Morph, {
40
- extend: {
41
- Options: Object.merge(Fx.Options, {
42
- duration: 'long',
43
- position: 'absolute' // <- defines the positions measurment principle, not the element positioning
44
- })
45
- },
46
-
47
- prepare: function(end_position) {
48
- return this.$super(this.getEndPosition(end_position));
49
- },
50
-
51
- // moved to a separated method to be able to call it from subclasses
52
- getEndPosition: function(end_position) {
53
- var position = this.element.getStyle('position'), end_style = {};
54
-
55
- if (position != 'absolute' || position != 'relative') {
56
- this.element._.style.position = position = position == 'fixed' ? 'absolute' : 'relative';
57
- }
58
-
59
- if (end_position.top) { end_position.y = end_position.top.toInt(); }
60
- if (end_position.left) { end_position.x = end_position.left.toInt(); }
61
-
62
- // adjusting the end position
63
- var cur_position = this.element.position();
64
- var par_position = this.getParentPosition();
65
- var rel_left = cur_position.x - par_position.x;
66
- var rel_top = cur_position.y - par_position.y;
67
-
68
- if (this.options.position == 'relative') {
69
- if (position == 'absolute') {
70
- if (defined(end_position.x)) { end_position.x += cur_position.x; }
71
- if (defined(end_position.y)) { end_position.y += cur_position.x; }
72
- } else {
73
- if (defined(end_position.x)) { end_position.x += rel_left; }
74
- if (defined(end_position.y)) { end_position.y += rel_top; }
75
- }
76
- } else if (position == 'relative') {
77
- if (defined(end_position.x)) { end_position.x += rel_left - cur_position.x; }
78
- if (defined(end_position.y)) { end_position.y += rel_top - cur_position.y; }
79
- }
80
-
81
- // need this to bypass the other styles from the subclasses
82
- for (var key in end_position) {
83
- switch (key) {
84
- case 'top': case 'left': break;
85
- case 'y': end_style.top = end_position.y + 'px'; break;
86
- case 'x': end_style.left = end_position.x + 'px'; break;
87
- default: end_style[key] = end_position[key];
88
- }
89
- }
90
-
91
- return end_style;
92
- },
93
-
94
- getParentPosition: function() {
95
- Fx.Move.Dummy = Fx.Move.Dummy || new Element('div', {style: 'width:0;height:0;visibility:hidden'});
96
- this.element.insert(Fx.Move.Dummy, 'before');
97
- var position = Fx.Move.Dummy.position();
98
- Fx.Move.Dummy.remove();
99
- return position;
100
- }
101
- });
102
-
103
- /**
104
- * Zoom visual effect, graduately zoom and element in or out
105
- *
106
- * @copyright (C) 2009-2011 Nikolay V. Nemshilov
107
- */
108
- Fx.Zoom = new Class(Fx.Move, {
109
- PROPERTIES: $w('width height lineHeight paddingTop paddingRight paddingBottom paddingLeft fontSize borderWidth'),
110
-
111
- extend: {
112
- Options: Object.merge(Fx.Move.Options, {
113
- position: 'relative', // overriding the Fx.Move default
114
- duration: 'normal',
115
- from: 'center'
116
- })
117
- },
118
-
119
- prepare: function(size, additional_styles) {
120
- return this.$super(this._getZoomedStyle(size, additional_styles));
121
- },
122
-
123
- // private
124
-
125
- // calculates the end zoommed style
126
- _getZoomedStyle: function(size, additional_styles) {
127
- var proportion = this._getProportion(size);
128
-
129
- return Object.merge(
130
- this._getBasicStyle(proportion),
131
- this._getEndPosition(proportion),
132
- additional_styles
133
- );
134
- },
135
-
136
- // calculates the zooming proportion
137
- _getProportion: function(size) {
138
- if (isHash(size)) {
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();
150
- } else if (isString(size)) {
151
- size = R(size).endsWith('%') ? R(size).toFloat() / 100 : R(size).toFloat();
152
- }
153
-
154
- return size;
155
- },
156
-
157
- // getting the basic end style
158
- _getBasicStyle: function(proportion) {
159
- var style = clone_styles(this.element, this.PROPERTIES), re = /([\d\.]+)/g;
160
-
161
- function adjust_value(m) {
162
- return ''+ (R(m).toFloat() * proportion);
163
- }
164
-
165
- for (var key in style) {
166
- if (key === 'width' || key === 'height') {
167
- style[key] = style[key] || (this.element['offset'+R(key).capitalize()]+'px');
168
- }
169
-
170
- if (style[key].match(re)) {
171
- style[key] = style[key].replace(re, adjust_value);
172
- } else {
173
- delete(style[key]);
174
- }
175
- }
176
-
177
- // preventing the border disappearance
178
- if (style.borderWidth && R(style.borderWidth).toFloat() < 1) {
179
- style.borderWidth = '1px';
180
- }
181
-
182
- return style;
183
- },
184
-
185
- // getting the position adjustments
186
- _getEndPosition: function(proportion) {
187
- var position = {};
188
- var sizes = this.element.size();
189
- var x_diff = sizes.x * (proportion - 1);
190
- var y_diff = sizes.y * (proportion - 1);
191
-
192
- switch (this.options.from.replace('-', ' ').split(' ').sort().join('_')) {
193
- case 'top':
194
- position.x = - x_diff / 2;
195
- break;
196
-
197
- case 'right':
198
- position.x = - x_diff;
199
- position.y = - y_diff / 2;
200
- break;
201
-
202
- case 'bottom':
203
- position.x = - x_diff / 2;
204
- case 'bottom_left':
205
- position.y = - y_diff;
206
- break;
207
-
208
- case 'bottom_right':
209
- position.y = - y_diff;
210
- case 'right_top':
211
- position.x = - x_diff;
212
- break;
213
-
214
- case 'center':
215
- position.x = - x_diff / 2;
216
- case 'left':
217
- position.y = - y_diff / 2;
218
- break;
219
-
220
- default: // left_top or none, do nothing, let the thing expand as is
221
- }
222
-
223
- return position;
224
- }
225
- });
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
-
238
- /**
239
- * Bounce visual effect, slightly moves an element forward and back
240
- *
241
- * @copyright (C) 2009 Nikolay V. Nemshilov
242
- */
243
- Fx.Bounce = new Class(Fx, {
244
- extend: {
245
- Options: Object.merge(Fx.Options, {
246
- duration: 'short',
247
- direction: 'top',
248
- value: 16 // the shake distance
249
- })
250
- },
251
-
252
- prepare: function(value) {
253
- value = value || this.options.value;
254
-
255
- var position = this.element.position();
256
- var duration = Fx.Durations[this.options.duration] || this.options.duration;
257
- var move_options = {duration: duration, position: 'relative'};
258
-
259
- var key = 'y'; // top bounce by default
260
-
261
- switch (this.options.direction) {
262
- case 'right':
263
- value = -value;
264
- case 'left':
265
- key = 'x';
266
- break;
267
- case 'bottom':
268
- value = -value;
269
- }
270
-
271
- var up_pos = {}, down_pos = {};
272
- up_pos[key] = -value;
273
- down_pos[key] = value;
274
-
275
- new Fx.Move(this.element, move_options).start(up_pos);
276
- new Fx.Move(this.element, move_options).start(down_pos);
277
-
278
- this.finish.bind(this).delay(1);
279
-
280
- return this;
281
- }
282
- });
283
-
284
- /**
285
- * run out and run in efffects
286
- *
287
- * Copyright (C) 2009-2010 Nikolay V. Nemshilov
288
- */
289
- Fx.Run = new Class(Fx.Move, {
290
- extend: {
291
- Options: Object.merge(Fx.Move.Options, {
292
- direction: 'left'
293
- })
294
- },
295
-
296
- prepare: function(in_how) {
297
- var how = in_how || 'toggle', position = {}, dimensions = this.element.dimensions(), threshold = 80;
298
-
299
- if (how == 'out' || (how == 'toggle' && this.element.visible())) {
300
- if (this.options.direction == 'left') {
301
- position.x = -dimensions.width - threshold;
302
- } else {
303
- position.y = -dimensions.height - threshold;
304
- }
305
- this.onFinish(function() {
306
- this.element.hide().setStyle(this.getEndPosition({x: dimensions.left, y: dimensions.top}));
307
- });
308
- } else {
309
- dimensions = this.element.setStyle('visibility: hidden').show().dimensions();
310
- var pre_position = {};
311
-
312
- if (this.options.direction == 'left') {
313
- pre_position.x = - dimensions.width - threshold;
314
- position.x = dimensions.left;
315
- } else {
316
- pre_position.y = - dimensions.height - threshold;
317
- position.y = dimensions.top;
318
- }
319
-
320
- this.element.setStyle(this.getEndPosition(pre_position)).setStyle('visibility: visible');
321
- }
322
-
323
- return this.$super(position);
324
- }
325
- });
326
-
327
- /**
328
- * The puff visual effect
329
- *
330
- * Copyright (C) 2009-2010 Nikolay V. Nemshilov
331
- */
332
- Fx.Puff = new Class(Fx.Zoom, {
333
- extend: {
334
- Options: Object.merge(Fx.Zoom.Options, {
335
- size: 1.4 // the end/initial size of the element
336
- })
337
- },
338
-
339
- // protected
340
-
341
- prepare: function(in_how) {
342
- var how = in_how || 'toggle', opacity = 0, size = this.options.size, initial_style;
343
-
344
- if (how == 'out' || (how == 'toggle' && this.element.visible())) {
345
- initial_style = this.getEndPosition(this._getZoomedStyle(1));
346
- this.onFinish(function() {
347
- initial_style.opacity = 1;
348
- this.element.hide().setStyle(initial_style);
349
- });
350
-
351
- } else {
352
- this.element.setStyle('visibility: visible').show();
353
-
354
- var width = this.element.offsetWidth;
355
- initial_style = this.getEndPosition(this._getZoomedStyle(1));
356
-
357
- this.onFinish(function() {
358
- this.element.setStyle(initial_style);
359
- });
360
-
361
- this.element.setStyle(Object.merge(
362
- this.getEndPosition(this._getZoomedStyle(size)), {
363
- opacity: 0,
364
- visibility: 'visible'
365
- }
366
- ));
367
-
368
- size = width / this.element.offsetWidth;
369
- opacity = 1;
370
- }
371
-
372
-
373
- return this.$super(size, {opacity: opacity});
374
- }
375
-
376
- });
377
-
378
- /**
379
- * Glow effect, kinda the same thing as Hightlight, but changes the text color
380
- *
381
- * Copyright (C) 2011 Nikolay Nemshilov
382
- */
383
- Fx.Glow = new Class(Fx.Morph, {
384
- extend: {
385
- Options: Object.merge(Fx.Options, {
386
- color: '#FF8',
387
- transition: 'Exp'
388
- })
389
- },
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});
414
- }
415
- });
416
-
417
- /**
418
- * Element shortcuts for the additional effects
419
- *
420
- * @copyright (C) 2009-2011 Nikolay Nemshilov
421
- */
422
- RightJS.Element.include({
423
- /**
424
- * The move visual effect shortcut
425
- *
426
- * @param position Object end position x/y or top/left
427
- * @param options Object fx options
428
- * @return Element self
429
- */
430
- move: function(position, options) {
431
- return call_fx(this, 'move', [position, options || {}]); // <- don't replace with arguments
432
- },
433
-
434
- /**
435
- * The bounce effect shortcut
436
- *
437
- * @param Number optional bounce size
438
- * @param Object fx options
439
- * @return Element self
440
- */
441
- bounce: function() {
442
- return call_fx(this, 'bounce', arguments);
443
- },
444
-
445
- /**
446
- * The zoom effect shortcut
447
- *
448
- * @param mixed the zooming value, see Fx.Zoom#start options
449
- * @param Object fx options
450
- * @return Element self
451
- */
452
- zoom: function(size, options) {
453
- return call_fx(this, 'zoom', [size, options || {}]);
454
- },
455
-
456
- /**
457
- * Initiates the Fx.Run effect
458
- *
459
- * @param String running direction
460
- * @param Object fx options
461
- * @return Element self
462
- */
463
- run: function() {
464
- return call_fx(this, 'run', arguments);
465
- },
466
-
467
- /**
468
- * The puff effect shortcut
469
- *
470
- * @param String running direction in|out|toggle
471
- * @param Object fx options
472
- * @return Element self
473
- */
474
- puff: function() {
475
- return call_fx(this, 'puff', arguments);
476
- },
477
-
478
- /**
479
- * The Fx.Glow effect shortcut
480
- *
481
- * @param String optinal glow color
482
- * @param Object fx options
483
- * @return Element self
484
- */
485
- glow: function() {
486
- return call_fx(this, 'glow', arguments);
487
- }
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
-
508
- })(RightJS);