right-rails 1.2.1 → 1.2.2
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG +4 -0
- data/README.rdoc +10 -18
- data/Rakefile +2 -2
- data/init.rb +9 -2
- data/lib/right_rails.rb +1 -1
- data/vendor/assets/images/rightjs-ui/colorpicker.png +0 -0
- data/vendor/assets/images/rightjs-ui/resizable.png +0 -0
- data/vendor/assets/images/rightjs-ui/rte.png +0 -0
- data/vendor/assets/javascripts/right-olds-src.js +652 -0
- data/vendor/assets/javascripts/right-olds.js +9 -0
- data/vendor/assets/javascripts/right-safe-src.js +68 -0
- data/vendor/assets/javascripts/right-safe.js +7 -0
- data/vendor/assets/javascripts/right-src.js +6014 -0
- data/vendor/assets/javascripts/right.js +7 -0
- data/vendor/assets/javascripts/right/autocompleter-src.js +625 -0
- data/vendor/assets/javascripts/right/autocompleter.js +7 -0
- data/vendor/assets/javascripts/right/billboard-src.js +564 -0
- data/vendor/assets/javascripts/right/billboard.js +7 -0
- data/vendor/assets/javascripts/right/calendar-src.js +1464 -0
- data/vendor/assets/javascripts/right/calendar.js +7 -0
- data/vendor/assets/javascripts/right/casting-src.js +183 -0
- data/vendor/assets/javascripts/right/casting.js +7 -0
- data/vendor/assets/javascripts/right/colorpicker-src.js +981 -0
- data/vendor/assets/javascripts/right/colorpicker.js +7 -0
- data/vendor/assets/javascripts/right/dialog-src.js +768 -0
- data/vendor/assets/javascripts/right/dialog.js +7 -0
- data/vendor/assets/javascripts/right/dnd-src.js +591 -0
- data/vendor/assets/javascripts/right/dnd.js +7 -0
- data/vendor/assets/javascripts/right/effects-src.js +508 -0
- data/vendor/assets/javascripts/right/effects.js +7 -0
- data/vendor/assets/javascripts/right/i18n/de.js +95 -0
- data/vendor/assets/javascripts/right/i18n/en-us.js +11 -0
- data/vendor/assets/javascripts/right/i18n/es.js +95 -0
- data/vendor/assets/javascripts/right/i18n/fi.js +96 -0
- data/vendor/assets/javascripts/right/i18n/fr.js +95 -0
- data/vendor/assets/javascripts/right/i18n/hu.js +100 -0
- data/vendor/assets/javascripts/right/i18n/it.js +95 -0
- data/vendor/assets/javascripts/right/i18n/jp.js +99 -0
- data/vendor/assets/javascripts/right/i18n/nl.js +95 -0
- data/vendor/assets/javascripts/right/i18n/pt-br.js +95 -0
- data/vendor/assets/javascripts/right/i18n/ru.js +95 -0
- data/vendor/assets/javascripts/right/i18n/ua.js +99 -0
- data/vendor/assets/javascripts/right/in-edit-src.js +373 -0
- data/vendor/assets/javascripts/right/in-edit.js +7 -0
- data/vendor/assets/javascripts/right/jquerysh-src.js +362 -0
- data/vendor/assets/javascripts/right/jquerysh.js +7 -0
- data/vendor/assets/javascripts/right/json-src.js +147 -0
- data/vendor/assets/javascripts/right/json.js +7 -0
- data/vendor/assets/javascripts/right/keys-src.js +87 -0
- data/vendor/assets/javascripts/right/keys.js +7 -0
- data/vendor/assets/javascripts/right/lightbox-src.js +931 -0
- data/vendor/assets/javascripts/right/lightbox.js +7 -0
- data/vendor/assets/javascripts/right/rails-src.js +402 -0
- data/vendor/assets/javascripts/right/rails.js +7 -0
- data/vendor/assets/javascripts/right/rater-src.js +384 -0
- data/vendor/assets/javascripts/right/rater.js +7 -0
- data/vendor/assets/javascripts/right/resizable-src.js +465 -0
- data/vendor/assets/javascripts/right/resizable.js +7 -0
- data/vendor/assets/javascripts/right/rte-src.js +2685 -0
- data/vendor/assets/javascripts/right/rte.js +7 -0
- data/vendor/assets/javascripts/right/selectable-src.js +725 -0
- data/vendor/assets/javascripts/right/selectable.js +7 -0
- data/vendor/assets/javascripts/right/sizzle-src.js +1132 -0
- data/vendor/assets/javascripts/right/sizzle.js +7 -0
- data/vendor/assets/javascripts/right/slider-src.js +395 -0
- data/vendor/assets/javascripts/right/slider.js +7 -0
- data/vendor/assets/javascripts/right/sortable-src.js +430 -0
- data/vendor/assets/javascripts/right/sortable.js +7 -0
- data/vendor/assets/javascripts/right/table-src.js +176 -0
- data/vendor/assets/javascripts/right/table.js +7 -0
- data/vendor/assets/javascripts/right/tabs-src.js +1157 -0
- data/vendor/assets/javascripts/right/tabs.js +7 -0
- data/vendor/assets/javascripts/right/tags-src.js +745 -0
- data/vendor/assets/javascripts/right/tags.js +7 -0
- data/vendor/assets/javascripts/right/tooltips-src.js +331 -0
- data/vendor/assets/javascripts/right/tooltips.js +7 -0
- data/vendor/assets/javascripts/right/uploader-src.js +302 -0
- data/vendor/assets/javascripts/right/uploader.js +7 -0
- metadata +78 -14
@@ -0,0 +1,7 @@
|
|
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)
|
@@ -0,0 +1,508 @@
|
|
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);
|