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.
- data/README.rdoc +4 -4
- data/Rakefile +4 -4
- data/lib/right_rails.rb +1 -1
- data/public/javascripts/right/autocompleter-src.js +115 -106
- data/public/javascripts/right/autocompleter.js +3 -14
- data/public/javascripts/right/billboard-src.js +58 -38
- data/public/javascripts/right/billboard.js +3 -13
- data/public/javascripts/right/calendar-src.js +136 -133
- data/public/javascripts/right/calendar.js +4 -33
- data/public/javascripts/right/colorpicker-src.js +128 -125
- data/public/javascripts/right/colorpicker.js +4 -23
- data/public/javascripts/right/dialog-src.js +67 -37
- data/public/javascripts/right/dialog.js +3 -17
- data/public/javascripts/right/dnd-src.js +44 -43
- data/public/javascripts/right/dnd.js +3 -16
- data/public/javascripts/right/effects-src.js +125 -98
- data/public/javascripts/right/effects.js +3 -13
- data/public/javascripts/right/in-edit-src.js +54 -38
- data/public/javascripts/right/in-edit.js +4 -10
- data/public/javascripts/right/jquerysh-src.js +344 -20
- data/public/javascripts/right/jquerysh.js +3 -3
- data/public/javascripts/right/json-src.js +22 -35
- data/public/javascripts/right/json.js +4 -7
- data/public/javascripts/right/keys-src.js +87 -0
- data/public/javascripts/right/keys.js +7 -0
- data/public/javascripts/right/lightbox-src.js +76 -58
- data/public/javascripts/right/lightbox.js +3 -20
- data/public/javascripts/right/rails-src.js +108 -107
- data/public/javascripts/right/rails.js +4 -11
- data/public/javascripts/right/rater-src.js +47 -31
- data/public/javascripts/right/rater.js +3 -9
- data/public/javascripts/right/resizable-src.js +60 -33
- data/public/javascripts/right/resizable.js +3 -11
- data/public/javascripts/right/selectable-src.js +87 -51
- data/public/javascripts/right/selectable.js +3 -18
- data/public/javascripts/right/sizzle-src.js +15 -10
- data/public/javascripts/right/sizzle.js +4 -27
- data/public/javascripts/right/slider-src.js +49 -33
- data/public/javascripts/right/slider.js +3 -10
- data/public/javascripts/right/sortable-src.js +46 -32
- data/public/javascripts/right/sortable.js +4 -13
- data/public/javascripts/right/table-src.js +19 -10
- data/public/javascripts/right/table.js +4 -6
- data/public/javascripts/right/tabs-src.js +69 -47
- data/public/javascripts/right/tabs.js +4 -26
- data/public/javascripts/right/tooltips-src.js +78 -56
- data/public/javascripts/right/tooltips.js +4 -9
- data/public/javascripts/right/uploader-src.js +50 -34
- data/public/javascripts/right/uploader.js +3 -9
- data/public/javascripts/right-olds-src.js +528 -355
- data/public/javascripts/right-olds.js +4 -13
- data/public/javascripts/right-safe-src.js +4 -99
- data/public/javascripts/right-safe.js +3 -4
- data/public/javascripts/right-src.js +1618 -1245
- data/public/javascripts/right.js +4 -91
- metadata +8 -6
@@ -1,8 +1,8 @@
|
|
1
1
|
/**
|
2
|
-
*
|
2
|
+
* RightJS-UI Dialog v2.2.0
|
3
3
|
* http://rightjs.org/ui/dialog
|
4
4
|
*
|
5
|
-
* Copyright (C) 2010 Nikolay Nemshilov
|
5
|
+
* Copyright (C) 2010-2011 Nikolay Nemshilov
|
6
6
|
*/
|
7
7
|
var Dialog = RightJS.Dialog = (function(RightJS) {
|
8
8
|
/**
|
@@ -10,27 +10,9 @@ var Dialog = RightJS.Dialog = (function(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
|
-
* Dialog widget initialization script
|
18
|
-
*
|
19
|
-
* Copyright (C) 2010 Nikolay Nemshilov
|
20
|
-
*/
|
21
|
-
var R = RightJS,
|
22
|
-
$ = RightJS.$,
|
23
|
-
$w = RightJS.$w,
|
24
|
-
$E = RightJS.$E,
|
25
|
-
Class = RightJS.Class,
|
26
|
-
Object = RightJS.Object;
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
16
|
/**
|
35
17
|
* The widget units constructor
|
36
18
|
*
|
@@ -49,7 +31,7 @@ function Widget(tag_name, methods) {
|
|
49
31
|
*
|
50
32
|
* Copyright (C) 2010 Nikolay Nemshilov
|
51
33
|
*/
|
52
|
-
var AbstractWidget = new RightJS.
|
34
|
+
var AbstractWidget = new RightJS.Class(RightJS.Element.Wrappers[tag_name] || RightJS.Element, {
|
53
35
|
/**
|
54
36
|
* The common constructor
|
55
37
|
*
|
@@ -81,7 +63,8 @@ function Widget(tag_name, methods) {
|
|
81
63
|
options = {};
|
82
64
|
}
|
83
65
|
this.setOptions(options, this);
|
84
|
-
|
66
|
+
|
67
|
+
return (RightJS.Wrapper.Cache[RightJS.$uid(this._)] = this);
|
85
68
|
},
|
86
69
|
|
87
70
|
// protected
|
@@ -94,12 +77,16 @@ function Widget(tag_name, methods) {
|
|
94
77
|
* @return void
|
95
78
|
*/
|
96
79
|
setOptions: function(options, element) {
|
97
|
-
|
98
|
-
|
99
|
-
RightJS.Object.merge(options, eval("("+(
|
80
|
+
if (element) {
|
81
|
+
options = RightJS.Object.merge(options, new Function("return "+(
|
100
82
|
element.get('data-'+ this.key) || '{}'
|
101
|
-
)
|
102
|
-
|
83
|
+
))());
|
84
|
+
}
|
85
|
+
|
86
|
+
if (options) {
|
87
|
+
RightJS.Options.setOptions.call(this, RightJS.Object.merge(this.options, options));
|
88
|
+
}
|
89
|
+
|
103
90
|
return this;
|
104
91
|
}
|
105
92
|
});
|
@@ -108,7 +95,7 @@ function Widget(tag_name, methods) {
|
|
108
95
|
* Creating the actual widget class
|
109
96
|
*
|
110
97
|
*/
|
111
|
-
var Klass = new RightJS.
|
98
|
+
var Klass = new RightJS.Class(AbstractWidget, methods);
|
112
99
|
|
113
100
|
// creating the widget related shortcuts
|
114
101
|
RightJS.Observer.createShortcuts(Klass.prototype, Klass.EVENTS || []);
|
@@ -123,9 +110,9 @@ function Widget(tag_name, methods) {
|
|
123
110
|
* so those buttons didn't interfere with
|
124
111
|
* the user's tab-index on his page
|
125
112
|
*
|
126
|
-
* Copyright (C) 2010 Nikolay Nemshilov
|
113
|
+
* Copyright (C) 2010-2011 Nikolay Nemshilov
|
127
114
|
*/
|
128
|
-
var Button = new RightJS.
|
115
|
+
var Button = new RightJS.Class(RightJS.Element, {
|
129
116
|
/**
|
130
117
|
* Constructor
|
131
118
|
*
|
@@ -194,9 +181,9 @@ var Button = new RightJS.Wrapper(RightJS.Element, {
|
|
194
181
|
/**
|
195
182
|
* A shared module to create textual spinners
|
196
183
|
*
|
197
|
-
* Copyright (C) 2010 Nikolay Nemshilov
|
184
|
+
* Copyright (C) 2010-2011 Nikolay Nemshilov
|
198
185
|
*/
|
199
|
-
var Spinner = new RightJS.
|
186
|
+
var Spinner = new RightJS.Class(RightJS.Element, {
|
200
187
|
/**
|
201
188
|
* Constructor
|
202
189
|
*
|
@@ -232,18 +219,38 @@ var Spinner = new RightJS.Wrapper(RightJS.Element, {
|
|
232
219
|
|
233
220
|
|
234
221
|
/**
|
235
|
-
*
|
222
|
+
* Dialog widget initialization script
|
236
223
|
*
|
237
224
|
* Copyright (C) 2010 Nikolay Nemshilov
|
238
225
|
*/
|
226
|
+
var R = RightJS,
|
227
|
+
$ = RightJS.$,
|
228
|
+
$w = RightJS.$w,
|
229
|
+
$E = RightJS.$E,
|
230
|
+
Class = RightJS.Class,
|
231
|
+
Object = RightJS.Object,
|
232
|
+
Element = RightJS.Element;
|
233
|
+
|
234
|
+
|
235
|
+
|
236
|
+
|
237
|
+
|
238
|
+
|
239
|
+
|
240
|
+
/**
|
241
|
+
* Basic dialog class
|
242
|
+
*
|
243
|
+
* Copyright (C) 2010-2011 Nikolay Nemshilov
|
244
|
+
*/
|
239
245
|
var Dialog = new Widget({
|
240
246
|
extend: {
|
241
|
-
version: '2.
|
247
|
+
version: '2.2.0',
|
242
248
|
|
243
249
|
EVENTS: $w('ok cancel help expand collapse resize load'),
|
244
250
|
|
245
251
|
Options: {
|
246
252
|
lockScreen: true, // if you need to lock the scrreen
|
253
|
+
fxDuration: 'short', // dialog appearance duration
|
247
254
|
|
248
255
|
draggable: true, // sets if the user should be able to drag the dialog around
|
249
256
|
closeable: true, // allow the user to close the dialog
|
@@ -315,7 +322,19 @@ var Dialog = new Widget({
|
|
315
322
|
this.locker.insertTo(document.body);
|
316
323
|
}
|
317
324
|
|
318
|
-
this
|
325
|
+
this
|
326
|
+
.setStyle('visibility:hidden')
|
327
|
+
.insertTo(document.body)
|
328
|
+
.resize()
|
329
|
+
.setStyle('visibility:visible;opacity:0');
|
330
|
+
|
331
|
+
if (this.options.fxDuration) {
|
332
|
+
this.morph({opacity: 1}, {
|
333
|
+
duration: this.options.fxDuration
|
334
|
+
});
|
335
|
+
} else {
|
336
|
+
this.setStyle('opacity:1');
|
337
|
+
}
|
319
338
|
|
320
339
|
return (Dialog.current = this);
|
321
340
|
},
|
@@ -732,7 +751,18 @@ $(window).onResize(function() {
|
|
732
751
|
}
|
733
752
|
});
|
734
753
|
|
735
|
-
|
754
|
+
var embed_style = document.createElement('style'),
|
755
|
+
embed_rules = document.createTextNode("*.rui-button{display:inline-block; *display:inline; *zoom:1;height:1em;line-height:1em;margin:0;padding:.2em .5em;text-align:center;border:1px solid #CCC;border-radius:.2em;-moz-border-radius:.2em;-webkit-border-radius:.2em;cursor:pointer;color:#333;background-color:#FFF;user-select:none;-moz-user-select:none;-webkit-user-select:none} *.rui-button:hover{color:#111;border-color:#999;background-color:#DDD;box-shadow:#888 0 0 .1em;-moz-box-shadow:#888 0 0 .1em;-webkit-box-shadow:#888 0 0 .1em} *.rui-button:active{color:#000;border-color:#777;text-indent:1px;box-shadow:none;-moz-box-shadow:none;-webkit-box-shadow:none} *.rui-button-disabled, *.rui-button-disabled:hover, *.rui-button-disabled:active{color:#888;background:#DDD;border-color:#CCC;cursor:default;text-indent:0;box-shadow:none;-moz-box-shadow:none;-webkit-box-shadow:none}div.rui-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}div.rui-screen-locker{position:fixed;top:0;left:0;width:100%;height:100%;margin:0;padding:0;background:#000;opacity:.5;filter:alpha(opacity=50);z-index:99999;cursor:default}div.rui-dialog{position:absolute;z-index:99999;background:white;margin:0;padding:0;padding-top:2.5em;padding-bottom:2.8em;border-radius:.35em;-moz-border-radius:.35em;-webkit-border-radius:.35em;border:1px solid #ccc}div.rui-dialog-body{min-width:20em;min-height:4.5em;margin:0;padding:0 1em;height:100%;overflow:auto;position:relative}div.rui-dialog-body-locker{position:absolute;z-index:9999;left:0;top:0;width:100%;height:100%;text-align:center;opacity:.6;filter:alpha(opacity=60)}div.rui-dialog-body-locker div.rui-spinner{border:none;background:none;font-size:150%;margin-top:8%}div.rui-dialog-body-icon{float:left;background:#eee;font-size:360%;font-family:Arial;border:2px solid gray;border-radius:.1em;-moz-border-radius:.1em;-webkit-border-radius:.1em;width:1em;line-height:1em;text-align:center;margin-right:.2em;margin-top:.05em;cursor:default;user-select:none;-moz-user-select:none;-webkit-user-select:none}div.rui-dialog-head{position:absolute;top:0;left:0;margin:0;padding:0;width:100%;line-height:2em;background:#ccc;border-radius:.35em;-moz-border-radius:.35em;-webkit-border-radius:.35em;border-bottom-left-radius:0;border-bottom-right-radius:0;-moz-border-radius-bottomleft:0;-moz-border-radius-bottomright:0;-webkit-border-bottom-left-radius:0;-webkit-border-bottom-right-radius:0;cursor:move;user-select:none;-moz-user-select:none;-webkit-user-select:none}div.rui-dialog-head div.icon{float:left;height:1.4em;width:1.4em;margin-left:1em;margin-top:.3em;margin-right:.3em;display:none}div.rui-dialog-head div.title{margin-left:1em;color:#444}div.rui-dialog-head div.tools{position:absolute;right:.3em;top:.3em}div.rui-dialog-head div.tools div{float:left;width:1.4em;line-height:1.4em;text-align:center;margin-left:.15em;cursor:pointer;background:#aaa;border-radius:.2em;-moz-border-radius:.2em;-webkit-border-radius:.2em;font-family:Verdana;opacity:.6;filter:alpha(opacity=60)}div.rui-dialog-head div.tools div:hover{opacity:1;filter:alpha(opacity=100);box-shadow:#444 0 0 .1em;-moz-box-shadow:#444 0 0 .1em;-webkit-box-shadow:#444 0 0 .1em}div.rui-dialog-head div.tools div.close:hover{background:#daa}div.rui-dialog-nodrag div.rui-dialog-head{cursor:default}div.rui-dialog-foot{position:absolute;bottom:0;left:0;width:100%;text-align:right}div.rui-dialog-foot div.rui-button{margin:.6em 1em;background:#eee;width:4em}div.rui-dialog-foot div.help{float:left}div.rui-dialog-foot div.cancel{margin-right:-.5em}div.rui-dialog-foot div.ok:hover{background-color:#ded}div.rui-dialog-foot div.cancel:hover{background-color:#ecc}div.rui-dialog-alert div.rui-dialog-foot{text-align:center}div.rui-dialog-alert div.rui-dialog-foot div.cancel{display:none}div.rui-dialog-alert div.rui-dialog-body-icon{color:brown;background:#FEE;border-color:brown}div.rui-dialog-confirm div.rui-dialog-body-icon{color:#44A;background:#EEF;border-color:#44a}div.rui-dialog-prompt div.rui-dialog-body-icon{color:#333}div.rui-dialog-prompt div.rui-dialog-body label{display:block;font-weight:bold;font-size:120%;color:#444;margin-bottom:.5em}div.rui-dialog-prompt div.rui-dialog-body input,div.rui-dialog-prompt div.rui-dialog-body textarea{border:1px solid #aaa;font-size:1em;display:block;width:16em;margin:0;padding:.2em;margin-left:4.7em;border-radius:.2em;-moz-border-radius:.2em;-webkit-border-radius:.2em;outline:none}div.rui-dialog-prompt div.rui-dialog-body textarea{width:24em;height:8em}");
|
756
|
+
|
757
|
+
embed_style.type = 'text/css';
|
758
|
+
document.getElementsByTagName('head')[0].appendChild(embed_style);
|
759
|
+
|
760
|
+
if(embed_style.styleSheet) {
|
761
|
+
embed_style.styleSheet.cssText = embed_rules.nodeValue;
|
762
|
+
} else {
|
763
|
+
embed_style.appendChild(embed_rules);
|
764
|
+
}
|
765
|
+
|
736
766
|
|
737
767
|
return Dialog;
|
738
768
|
})(RightJS);
|
@@ -1,21 +1,7 @@
|
|
1
1
|
/**
|
2
|
-
*
|
2
|
+
* RightJS-UI Dialog v2.2.0
|
3
3
|
* http://rightjs.org/ui/dialog
|
4
4
|
*
|
5
|
-
* Copyright (C) 2010 Nikolay Nemshilov
|
5
|
+
* Copyright (C) 2010-2011 Nikolay Nemshilov
|
6
6
|
*/
|
7
|
-
var Dialog=RightJS.Dialog=function(d){var h=d.$,n=d.$w,g=d.$E,i=d.Class,j=d.Object,l=new d.Wrapper(d.Element,{initialize:function(a,c){this.$super("div",c);this._.innerHTML=a;this.addClass("rui-button");this.on("selectstart","stopEvent")},disable:function(){return this.addClass("rui-button-disabled")},enable:function(){return this.removeClass("rui-button-disabled")},disabled:function(){return this.hasClass("rui-button-disabled")},enabled:function(){return!this.disabled()},fire:function(){this.enabled()&&
|
8
|
-
this.$super.apply(this,arguments);return this}}),o=new d.Wrapper(d.Element,{initialize:function(a){this.$super("div",{"class":"rui-spinner"});this.dots=[];for(var c=0;c<(a||4);c++)this.dots.push(new d.Element("div"));this.dots[0].addClass("glowing");this.insert(this.dots);d(this.shift).bind(this).periodical(300)},shift:function(){if(this.visible()){var a=this.dots.pop();this.dots.unshift(a);this.insert(a,"top")}}}),b=new (function(a,c){if(!c){c=a;a="DIV"}var f=new d.Wrapper(d.Element.Wrappers[a]||
|
9
|
-
d.Element,{initialize:function(k,e){this.key=k;var m=[{"class":"rui-"+k}];this instanceof d.Input||this instanceof d.Form||m.unshift(a);this.$super.apply(this,m);if(d.isString(e))e=d.$(e);if(e instanceof d.Element){this._=e._;if("$listeners"in e)e.$listeners=e.$listeners;e={}}this.setOptions(e,this);return this},setOptions:function(k,e){e=e||this;d.Options.setOptions.call(this,d.Object.merge(k,eval("("+(e.get("data-"+this.key)||"{}")+")")));return this}});f=new d.Wrapper(f,c);d.Observer.createShortcuts(f.prototype,
|
10
|
-
f.EVENTS||[]);return f})({extend:{version:"2.0.0",EVENTS:n("ok cancel help expand collapse resize load"),Options:{lockScreen:true,draggable:true,closeable:true,expandable:false,showHelp:false,showIcon:null,title:null,html:null,url:null},i18n:{Ok:"Ok",Close:"Close",Cancel:"Cancel",Help:"Help",Expand:"Expand",Collapse:"Collapse",Alert:"Warning!",Confirm:"Confirm",Prompt:"Enter"},current:false,dragged:false},initialize:function(a){this.$super("dialog",a).append(this.head=new b.Head(this),this.body=new b.Body(this),
|
11
|
-
this.foot=new b.Foot(this)).onCancel(this.hide);this.locker=g("div",{"class":"rui-screen-locker"});this.options.title&&this.title(this.options.title);this.options.html&&this.html(this.options.html);this.options.url&&this.load(this.options.url)},show:function(){this.options.lockScreen&&this.locker.insertTo(document.body);this.insertTo(document.body).resize();return b.current=this},hide:function(){this.locker.remove();this.remove();b.current=false;return this},resize:function(){arguments.length&&this.$super.apply(this,
|
12
|
-
arguments);var a=this.size(),c=h(window).size();if(this.expanded){a.x=c.x-20;a.y=c.y-10;this.$super.call(this,a)}this.setStyle({top:(c.y-a.y)/2+h(window).scrolls().y+"px",left:(c.x-a.x-16)/2+"px"});return this.fire("resize")},title:function(a){if(arguments.length){this.head.title.html(a);return this}else return this.head.title.html()},update:function(a){this.body.update(a);return this.resize()},html:function(){return arguments.length?this.$super.apply(this,arguments):this.body.html()},load:function(a,
|
13
|
-
c){this.show();this.body.load(a,c);return this},expand:function(){if(!this.expanded){this._prevSize=this.size();this.resize({x:h(window).size().x-20,y:h(window).size().y-10});this.expanded=true;this.fire("expand")}return this},collapse:function(){if(this.expanded){this.expanded=false;this.resize(this._prevSize);this.fire("collapse")}return this}});b.Head=new i(Element,{initialize:function(a){this.dialog=a;this.options=a.options;this.$super("div",{"class":"rui-dialog-head"});this.append(this.icon=
|
14
|
-
g("div",{"class":"icon"}),this.title=g("div",{"class":"title",html:" "}),this.tools=g("div",{"class":"tools"}));this.fsButton=g("div",{"class":"expand",html:"≡",title:b.i18n.Expand}).onClick(function(){if(a.expanded){a.collapse();this.html("≡").set("title",b.i18n.Expand)}else{a.expand();this.html("_").set("title",b.i18n.Collapse)}});this.closeButton=g("div",{"class":"close",html:"×",title:b.i18n.Close}).onClick(function(){a.fire("cancel")});this.options.expandable&&this.tools.insert(this.fsButton);
|
15
|
-
this.options.closeable&&this.tools.insert(this.closeButton);this.on({selectstart:function(c){c.stop()},mousedown:this.dragStart});this.options.draggable||this.dialog.addClass("rui-dialog-nodrag")},dragStart:function(a){if(this.options.draggable&&!a.find("div.tools div")){var c=this.dialog.dimensions(),f=a.position();this.xDiff=c.left-f.x;this.yDiff=c.top-f.y;this.maxX=h(window).size().x-c.width-20;this.dlgStyle=this.dialog.get("style");b.dragged=this.dialog;a.stop()}},dragMove:function(a){var c=a.position();
|
16
|
-
a=c.x+this.xDiff;c=c.y+this.yDiff;if(a<0)a=0;else if(a>this.maxX)a=this.maxX;if(c<0)c=0;this.dlgStyle.top=c+"px";this.dlgStyle.left=a+"px"},dragStop:function(){b.dragged=false}});b.Body=new i(Element,{initialize:function(a){this.dialog=a;this.options=a.options;this.$super("div",{"class":"rui-dialog-body"});this.locker=g("div",{"class":"rui-dialog-body-locker"}).insert(new o)},load:function(a,c){this.insert(this.locker,"top");this.xhr=(new Xhr(a,j.merge({method:"get"},c))).onComplete(d(function(f){this.update(f.text);
|
17
|
-
this.dialog.resize().fire("load")}).bind(this)).send();return this},update:function(a){this.$super(a);this.options.showIcon&&this.insert('<div class="rui-dialog-body-icon">'+this.options.showIcon+"</div>","top");return this}});b.Foot=new i(Element,{initialize:function(a){this.$super("div",{"class":"rui-dialog-foot"});this.dialog=a;a.okButton=(new l(b.i18n.Ok,{"class":"ok"})).onClick(function(){a.fire("ok")});a.helpButton=(new l(b.i18n.Help,{"class":"help"})).onClick(function(){a.fire("help")});a.cancelButton=
|
18
|
-
(new l(b.i18n.Cancel,{"class":"cancel"})).onClick(function(){a.fire("cancel")});a.options.showHelp&&this.insert(a.helpButton);a.options.closeable&&this.insert(a.cancelButton);this.insert(a.okButton)}});b.Alert=new i(b,{initialize:function(a){a=j.merge({showIcon:"!",title:b.i18n.Alert},a);this.$super(a);this.addClass("rui-dialog-alert");this.on("ok","hide")}});b.Confirm=new i(b,{initialize:function(a){a=j.merge({showIcon:"?",title:b.i18n.Confirm},a);this.$super(a);this.addClass("rui-dialog-confirm");
|
19
|
-
this.on("ok","hide")}});b.Prompt=new i(b,{initialize:function(a){a=j.merge({showIcon:"➥",title:b.i18n.Prompt,label:b.i18n.Prompt},a);this.$super(a);this.addClass("rui-dialog-prompt");this.html([g("label",{html:this.options.label}),this.input=new d.Input(this.options.input||{})]);this.input.get("type")!=="textarea"&&this.input.onKeydown(d(function(c){c.keyCode===13&&this.fire("ok")}).bind(this))},show:function(){this.$super.apply(this,arguments);this.input.select();return this}});h(document).on({keydown:function(a){if(a.keyCode===
|
20
|
-
27&&b.current)b.current.options.closeable&&b.current.fire("cancel");else if(a.keyCode===13&&b.current)if(!(b.current instanceof b.Prompt)){a.stop();b.current.fire("ok")}},mousemove:function(a){b.dragged&&b.dragged.head.dragMove(a)},mouseup:function(a){b.dragged&&b.dragged.head.dragStop(a)}});h(window).onResize(function(){b.current&&b.current.resize()});document.write('<style type="text/css"> *.rui-button{display:inline-block; *display:inline; *zoom:1;height:1em;line-height:1em;margin:0;padding:.2em .5em;text-align:center;border:1px solid #CCC;border-radius:.2em;-moz-border-radius:.2em;-webkit-border-radius:.2em;cursor:pointer;color:#333;background-color:#FFF;user-select:none;-moz-user-select:none;-webkit-user-select:none} *.rui-button:hover{color:#111;border-color:#999;background-color:#DDD;box-shadow:#888 0 0 .1em;-moz-box-shadow:#888 0 0 .1em;-webkit-box-shadow:#888 0 0 .1em} *.rui-button:active{color:#000;border-color:#777;text-indent:1px;box-shadow:none;-moz-box-shadow:none;-webkit-box-shadow:none} *.rui-button-disabled, *.rui-button-disabled:hover, *.rui-button-disabled:active{color:#888;background:#DDD;border-color:#CCC;cursor:default;text-indent:0;box-shadow:none;-moz-box-shadow:none;-webkit-box-shadow:none}div.rui-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}div.rui-screen-locker{position:fixed;top:0;left:0;width:100%;height:100%;margin:0;padding:0;background:#000;opacity:.5;filter:alpha(opacity=50);z-index:99999;cursor:default}div.rui-dialog{position:absolute;z-index:99999;background:white;margin:0;padding:0;padding-top:2.5em;padding-bottom:2.8em;border-radius:.35em;-moz-border-radius:.35em;-webkit-border-radius:.35em;border:1px solid #ccc}div.rui-dialog-body{min-width:20em;min-height:4.5em;margin:0;padding:0 1em;height:100%;overflow:auto;position:relative}div.rui-dialog-body-locker{position:absolute;z-index:9999;left:0;top:0;width:100%;height:100%;text-align:center;opacity:.6;filter:alpha(opacity=60)}div.rui-dialog-body-locker div.rui-spinner{border:none;background:none;font-size:150%;margin-top:8%}div.rui-dialog-body-icon{float:left;background:#eee;font-size:360%;font-family:Arial;border:2px solid gray;border-radius:.1em;-moz-border-radius:.1em;-webkit-border-radius:.1em;width:1em;line-height:1em;text-align:center;margin-right:.2em;margin-top:.05em;cursor:default;user-select:none;-moz-user-select:none;-webkit-user-select:none}div.rui-dialog-head{position:absolute;top:0;left:0;margin:0;padding:0;width:100%;line-height:2em;background:#ccc;border-radius:.35em;-moz-border-radius:.35em;-webkit-border-radius:.35em;border-bottom-left-radius:0;border-bottom-right-radius:0;-moz-border-radius-bottomleft:0;-moz-border-radius-bottomright:0;-webkit-border-bottom-left-radius:0;-webkit-border-bottom-right-radius:0;cursor:move;user-select:none;-moz-user-select:none;-webkit-user-select:none}div.rui-dialog-head div.icon{float:left;height:1.4em;width:1.4em;margin-left:1em;margin-top:.3em;margin-right:.3em;display:none}div.rui-dialog-head div.title{margin-left:1em;color:#444}div.rui-dialog-head div.tools{position:absolute;right:.3em;top:.3em}div.rui-dialog-head div.tools div{float:left;width:1.4em;line-height:1.4em;text-align:center;margin-left:.15em;cursor:pointer;background:#aaa;border-radius:.2em;-moz-border-radius:.2em;-webkit-border-radius:.2em;font-family:Verdana;opacity:.6;filter:alpha(opacity=60)}div.rui-dialog-head div.tools div:hover{opacity:1;filter:alpha(opacity=100);box-shadow:#444 0 0 .1em;-moz-box-shadow:#444 0 0 .1em;-webkit-box-shadow:#444 0 0 .1em}div.rui-dialog-head div.tools div.close:hover{background:#daa}div.rui-dialog-nodrag div.rui-dialog-head{cursor:default}div.rui-dialog-foot{position:absolute;bottom:0;left:0;width:100%;text-align:right}div.rui-dialog-foot div.rui-button{margin:.6em 1em;background:#eee;width:4em}div.rui-dialog-foot div.help{float:left}div.rui-dialog-foot div.cancel{margin-right:-.5em}div.rui-dialog-foot div.ok:hover{background-color:#ded}div.rui-dialog-foot div.cancel:hover{background-color:#ecc}div.rui-dialog-alert div.rui-dialog-foot{text-align:center}div.rui-dialog-alert div.rui-dialog-foot div.cancel{display:none}div.rui-dialog-alert div.rui-dialog-body-icon{color:brown;background:#FEE;border-color:brown}div.rui-dialog-confirm div.rui-dialog-body-icon{color:#44A;background:#EEF;border-color:#44a}div.rui-dialog-prompt div.rui-dialog-body-icon{color:#333}div.rui-dialog-prompt div.rui-dialog-body label{display:block;font-weight:bold;font-size:120%;color:#444;margin-bottom:.5em}div.rui-dialog-prompt div.rui-dialog-body input,div.rui-dialog-prompt div.rui-dialog-body textarea{border:1px solid #aaa;font-size:1em;display:block;width:16em;margin:0;padding:.2em;margin-left:4.7em;border-radius:.2em;-moz-border-radius:.2em;-webkit-border-radius:.2em;outline:none}div.rui-dialog-prompt div.rui-dialog-body textarea{width:24em;height:8em}</style>');
|
21
|
-
return b}(RightJS);
|
7
|
+
var Dialog=RightJS.Dialog=function(a){function b(b,c){c||(c=b,b="DIV");var d=new a.Class(a.Element.Wrappers[b]||a.Element,{initialize:function(c,d){this.key=c;var e=[{"class":"rui-"+c}];this instanceof a.Input||this instanceof a.Form||e.unshift(b),this.$super.apply(this,e),a.isString(d)&&(d=a.$(d)),d instanceof a.Element&&(this._=d._,"$listeners"in d&&(d.$listeners=d.$listeners),d={}),this.setOptions(d,this);return a.Wrapper.Cache[a.$uid(this._)]=this},setOptions:function(b,c){c&&(b=a.Object.merge(b,(new Function("return "+(c.get("data-"+this.key)||"{}")))())),b&&a.Options.setOptions.call(this,a.Object.merge(this.options,b));return this}}),e=new a.Class(d,c);a.Observer.createShortcuts(e.prototype,e.EVENTS||[]);return e}var c=new a.Class(a.Element,{initialize:function(a,b){this.$super("div",b),this._.innerHTML=a,this.addClass("rui-button"),this.on("selectstart","stopEvent")},disable:function(){return this.addClass("rui-button-disabled")},enable:function(){return this.removeClass("rui-button-disabled")},disabled:function(){return this.hasClass("rui-button-disabled")},enabled:function(){return!this.disabled()},fire:function(){this.enabled()&&this.$super.apply(this,arguments);return this}}),d=new a.Class(a.Element,{initialize:function(b){this.$super("div",{"class":"rui-spinner"}),this.dots=[];for(var c=0;c<(b||4);c++)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 a=this.dots.pop();this.dots.unshift(a),this.insert(a,"top")}}}),e=a,f=a.$,g=a.$w,h=a.$E,i=a.Class,j=a.Object,k=a.Element,l=new b({extend:{version:"2.2.0",EVENTS:g("ok cancel help expand collapse resize load"),Options:{lockScreen:!0,fxDuration:"short",draggable:!0,closeable:!0,expandable:!1,showHelp:!1,showIcon:null,title:null,html:null,url:null},i18n:{Ok:"Ok",Close:"Close",Cancel:"Cancel",Help:"Help",Expand:"Expand",Collapse:"Collapse",Alert:"Warning!",Confirm:"Confirm",Prompt:"Enter"},current:!1,dragged:!1},initialize:function(a){this.$super("dialog",a).append(this.head=new l.Head(this),this.body=new l.Body(this),this.foot=new l.Foot(this)).onCancel(this.hide),this.locker=h("div",{"class":"rui-screen-locker"}),this.options.title&&this.title(this.options.title),this.options.html&&this.html(this.options.html),this.options.url&&this.load(this.options.url)},show:function(){this.options.lockScreen&&this.locker.insertTo(document.body),this.setStyle("visibility:hidden").insertTo(document.body).resize().setStyle("visibility:visible;opacity:0"),this.options.fxDuration?this.morph({opacity:1},{duration:this.options.fxDuration}):this.setStyle("opacity:1");return l.current=this},hide:function(){this.locker.remove(),this.remove(),l.current=!1;return this},resize:function(){arguments.length&&this.$super.apply(this,arguments);var a=this.size(),b=f(window).size();this.expanded&&(a.x=b.x-20,a.y=b.y-10,this.$super.call(this,a)),this.setStyle({top:(b.y-a.y)/2+f(window).scrolls().y+"px",left:(b.x-a.x-16)/2+"px"});return this.fire("resize")},title:function(a){if(arguments.length){this.head.title.html(a);return this}return this.head.title.html()},update:function(a){this.body.update(a);return this.resize()},html:function(){return arguments.length?this.$super.apply(this,arguments):this.body.html()},load:function(a,b){this.show(),this.body.load(a,b);return this},expand:function(){this.expanded||(this._prevSize=this.size(),this.resize({x:f(window).size().x-20,y:f(window).size().y-10}),this.expanded=!0,this.fire("expand"));return this},collapse:function(){this.expanded&&(this.expanded=!1,this.resize(this._prevSize),this.fire("collapse"));return this}});l.Head=new i(k,{initialize:function(a){this.dialog=a,this.options=a.options,this.$super("div",{"class":"rui-dialog-head"}),this.append(this.icon=h("div",{"class":"icon"}),this.title=h("div",{"class":"title",html:" "}),this.tools=h("div",{"class":"tools"})),this.fsButton=h("div",{"class":"expand",html:"≡",title:l.i18n.Expand}).onClick(function(){a.expanded?(a.collapse(),this.html("≡").set("title",l.i18n.Expand)):(a.expand(),this.html("_").set("title",l.i18n.Collapse))}),this.closeButton=h("div",{"class":"close",html:"×",title:l.i18n.Close}).onClick(function(){a.fire("cancel")}),this.options.expandable&&this.tools.insert(this.fsButton),this.options.closeable&&this.tools.insert(this.closeButton),this.on({selectstart:function(a){a.stop()},mousedown:this.dragStart}),this.options.draggable||this.dialog.addClass("rui-dialog-nodrag")},dragStart:function(a){if(this.options.draggable&&!a.find("div.tools div")){var b=this.dialog.dimensions(),c=a.position();this.xDiff=b.left-c.x,this.yDiff=b.top-c.y,this.maxX=f(window).size().x-b.width-20,this.dlgStyle=this.dialog.get("style"),l.dragged=this.dialog,a.stop()}},dragMove:function(a){var b=a.position(),c=b.x+this.xDiff,d=b.y+this.yDiff;c<0?c=0:c>this.maxX&&(c=this.maxX),d<0&&(d=0),this.dlgStyle.top=d+"px",this.dlgStyle.left=c+"px"},dragStop:function(a){l.dragged=!1}}),l.Body=new i(k,{initialize:function(a){this.dialog=a,this.options=a.options,this.$super("div",{"class":"rui-dialog-body"}),this.locker=h("div",{"class":"rui-dialog-body-locker"}).insert(new d)},load:function(a,b){this.insert(this.locker,"top"),this.xhr=(new Xhr(a,j.merge({method:"get"},b))).onComplete(e(function(a){this.update(a.text),this.dialog.resize().fire("load")}).bind(this)).send();return this},update:function(a){this.$super(a),this.options.showIcon&&this.insert('<div class="rui-dialog-body-icon">'+this.options.showIcon+"</div>","top");return this}}),l.Foot=new i(k,{initialize:function(a){this.$super("div",{"class":"rui-dialog-foot"}),this.dialog=a,a.okButton=(new c(l.i18n.Ok,{"class":"ok"})).onClick(function(){a.fire("ok")}),a.helpButton=(new c(l.i18n.Help,{"class":"help"})).onClick(function(){a.fire("help")}),a.cancelButton=(new c(l.i18n.Cancel,{"class":"cancel"})).onClick(function(){a.fire("cancel")}),a.options.showHelp&&this.insert(a.helpButton),a.options.closeable&&this.insert(a.cancelButton),this.insert(a.okButton)}}),l.Alert=new i(l,{initialize:function(a){a=j.merge({showIcon:"!",title:l.i18n.Alert},a),this.$super(a),this.addClass("rui-dialog-alert"),this.on("ok","hide")}}),l.Confirm=new i(l,{initialize:function(a){a=j.merge({showIcon:"?",title:l.i18n.Confirm},a),this.$super(a),this.addClass("rui-dialog-confirm"),this.on("ok","hide")}}),l.Prompt=new i(l,{initialize:function(b){b=j.merge({showIcon:"➥",title:l.i18n.Prompt,label:l.i18n.Prompt},b),this.$super(b),this.addClass("rui-dialog-prompt"),this.html([h("label",{html:this.options.label}),this.input=new a.Input(this.options.input||{})]),this.input.get("type")!=="textarea"&&this.input.onKeydown(e(function(a){a.keyCode===13&&this.fire("ok")}).bind(this))},show:function(){this.$super.apply(this,arguments),this.input.select();return this}}),f(document).on({keydown:function(a){a.keyCode===27&&l.current?l.current.options.closeable&&l.current.fire("cancel"):a.keyCode===13&&l.current&&(l.current instanceof l.Prompt||(a.stop(),l.current.fire("ok")))},mousemove:function(a){l.dragged&&l.dragged.head.dragMove(a)},mouseup:function(a){l.dragged&&l.dragged.head.dragStop(a)}}),f(window).onResize(function(){l.current&&l.current.resize()});var m=document.createElement("style"),n=document.createTextNode("*.rui-button{display:inline-block; *display:inline; *zoom:1;height:1em;line-height:1em;margin:0;padding:.2em .5em;text-align:center;border:1px solid #CCC;border-radius:.2em;-moz-border-radius:.2em;-webkit-border-radius:.2em;cursor:pointer;color:#333;background-color:#FFF;user-select:none;-moz-user-select:none;-webkit-user-select:none} *.rui-button:hover{color:#111;border-color:#999;background-color:#DDD;box-shadow:#888 0 0 .1em;-moz-box-shadow:#888 0 0 .1em;-webkit-box-shadow:#888 0 0 .1em} *.rui-button:active{color:#000;border-color:#777;text-indent:1px;box-shadow:none;-moz-box-shadow:none;-webkit-box-shadow:none} *.rui-button-disabled, *.rui-button-disabled:hover, *.rui-button-disabled:active{color:#888;background:#DDD;border-color:#CCC;cursor:default;text-indent:0;box-shadow:none;-moz-box-shadow:none;-webkit-box-shadow:none}div.rui-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}div.rui-screen-locker{position:fixed;top:0;left:0;width:100%;height:100%;margin:0;padding:0;background:#000;opacity:.5;filter:alpha(opacity=50);z-index:99999;cursor:default}div.rui-dialog{position:absolute;z-index:99999;background:white;margin:0;padding:0;padding-top:2.5em;padding-bottom:2.8em;border-radius:.35em;-moz-border-radius:.35em;-webkit-border-radius:.35em;border:1px solid #ccc}div.rui-dialog-body{min-width:20em;min-height:4.5em;margin:0;padding:0 1em;height:100%;overflow:auto;position:relative}div.rui-dialog-body-locker{position:absolute;z-index:9999;left:0;top:0;width:100%;height:100%;text-align:center;opacity:.6;filter:alpha(opacity=60)}div.rui-dialog-body-locker div.rui-spinner{border:none;background:none;font-size:150%;margin-top:8%}div.rui-dialog-body-icon{float:left;background:#eee;font-size:360%;font-family:Arial;border:2px solid gray;border-radius:.1em;-moz-border-radius:.1em;-webkit-border-radius:.1em;width:1em;line-height:1em;text-align:center;margin-right:.2em;margin-top:.05em;cursor:default;user-select:none;-moz-user-select:none;-webkit-user-select:none}div.rui-dialog-head{position:absolute;top:0;left:0;margin:0;padding:0;width:100%;line-height:2em;background:#ccc;border-radius:.35em;-moz-border-radius:.35em;-webkit-border-radius:.35em;border-bottom-left-radius:0;border-bottom-right-radius:0;-moz-border-radius-bottomleft:0;-moz-border-radius-bottomright:0;-webkit-border-bottom-left-radius:0;-webkit-border-bottom-right-radius:0;cursor:move;user-select:none;-moz-user-select:none;-webkit-user-select:none}div.rui-dialog-head div.icon{float:left;height:1.4em;width:1.4em;margin-left:1em;margin-top:.3em;margin-right:.3em;display:none}div.rui-dialog-head div.title{margin-left:1em;color:#444}div.rui-dialog-head div.tools{position:absolute;right:.3em;top:.3em}div.rui-dialog-head div.tools div{float:left;width:1.4em;line-height:1.4em;text-align:center;margin-left:.15em;cursor:pointer;background:#aaa;border-radius:.2em;-moz-border-radius:.2em;-webkit-border-radius:.2em;font-family:Verdana;opacity:.6;filter:alpha(opacity=60)}div.rui-dialog-head div.tools div:hover{opacity:1;filter:alpha(opacity=100);box-shadow:#444 0 0 .1em;-moz-box-shadow:#444 0 0 .1em;-webkit-box-shadow:#444 0 0 .1em}div.rui-dialog-head div.tools div.close:hover{background:#daa}div.rui-dialog-nodrag div.rui-dialog-head{cursor:default}div.rui-dialog-foot{position:absolute;bottom:0;left:0;width:100%;text-align:right}div.rui-dialog-foot div.rui-button{margin:.6em 1em;background:#eee;width:4em}div.rui-dialog-foot div.help{float:left}div.rui-dialog-foot div.cancel{margin-right:-.5em}div.rui-dialog-foot div.ok:hover{background-color:#ded}div.rui-dialog-foot div.cancel:hover{background-color:#ecc}div.rui-dialog-alert div.rui-dialog-foot{text-align:center}div.rui-dialog-alert div.rui-dialog-foot div.cancel{display:none}div.rui-dialog-alert div.rui-dialog-body-icon{color:brown;background:#FEE;border-color:brown}div.rui-dialog-confirm div.rui-dialog-body-icon{color:#44A;background:#EEF;border-color:#44a}div.rui-dialog-prompt div.rui-dialog-body-icon{color:#333}div.rui-dialog-prompt div.rui-dialog-body label{display:block;font-weight:bold;font-size:120%;color:#444;margin-bottom:.5em}div.rui-dialog-prompt div.rui-dialog-body input,div.rui-dialog-prompt div.rui-dialog-body textarea{border:1px solid #aaa;font-size:1em;display:block;width:16em;margin:0;padding:.2em;margin-left:4.7em;border-radius:.2em;-moz-border-radius:.2em;-webkit-border-radius:.2em;outline:none}div.rui-dialog-prompt div.rui-dialog-body textarea{width:24em;height:8em}");m.type="text/css",document.getElementsByTagName("head")[0].appendChild(m),m.styleSheet?m.styleSheet.cssText=n.nodeValue:m.appendChild(n);return l}(RightJS)
|
@@ -1,16 +1,10 @@
|
|
1
1
|
/**
|
2
|
-
* Drag'n'Drop module
|
2
|
+
* Drag'n'Drop module v2.2.0
|
3
3
|
* http://rightjs.org/plugins/drag-n-drop
|
4
4
|
*
|
5
|
-
* Copyright (C) 2009-
|
5
|
+
* Copyright (C) 2009-2011 Nikolay Nemshilov
|
6
6
|
*/
|
7
7
|
(function(window, document, RightJS) {
|
8
|
-
/**
|
9
|
-
* Draggable unit
|
10
|
-
*
|
11
|
-
* Copyright (C) 2009-2010 Nikolay Nemshilov
|
12
|
-
*/
|
13
|
-
|
14
8
|
/**
|
15
9
|
* The DND module initialization script
|
16
10
|
*
|
@@ -26,8 +20,16 @@ var R = RightJS,
|
|
26
20
|
Observer = RightJS.Observer;
|
27
21
|
|
28
22
|
|
23
|
+
|
24
|
+
/**
|
25
|
+
* Draggable unit
|
26
|
+
*
|
27
|
+
* Copyright (C) 2009-2011 Nikolay Nemshilov
|
28
|
+
*/
|
29
29
|
var Draggable = new Class(Observer, {
|
30
30
|
extend: {
|
31
|
+
version: '2.2.0',
|
32
|
+
|
31
33
|
EVENTS: $w('before start drag stop drop'),
|
32
34
|
|
33
35
|
Options: {
|
@@ -57,12 +59,11 @@ var Draggable = new Class(Observer, {
|
|
57
59
|
|
58
60
|
// scans the document for auto-processed draggables with the rel="draggable" attribute
|
59
61
|
rescan: function(scope) {
|
60
|
-
var key = this.Options.relName;
|
62
|
+
var key = this.Options.relName, ref = this === Draggable ? 'draggable' : 'droppable';
|
61
63
|
|
62
|
-
($(scope)||$(document)).
|
63
|
-
if (!element
|
64
|
-
|
65
|
-
new this(element, eval('('+data+')') || {});
|
64
|
+
($(scope)||$(document)).find('*[rel^="'+key+'"]').each(function(element) {
|
65
|
+
if (!element[ref]) {
|
66
|
+
new this(element, new Function('return '+element.get('data-'+key))() || {});
|
66
67
|
}
|
67
68
|
}, this);
|
68
69
|
}
|
@@ -334,23 +335,23 @@ var Draggable = new Class(Observer, {
|
|
334
335
|
var Droppable = new Class(Observer, {
|
335
336
|
extend: {
|
336
337
|
EVENTS: $w('drop hover leave'),
|
337
|
-
|
338
|
+
|
338
339
|
Options: {
|
339
340
|
accept: '*',
|
340
341
|
containment: null, // the list of elements (or ids) that should to be accepted
|
341
|
-
|
342
|
+
|
342
343
|
overlap: null, // 'x', 'y', 'horizontal', 'vertical', 'both' makes it respond only if the draggable overlaps the droppable
|
343
344
|
overlapSize: 0.5, // the overlapping level 0 for nothing 1 for the whole thing
|
344
|
-
|
345
|
+
|
345
346
|
allowClass: 'droppable-allow',
|
346
347
|
denyClass: 'droppable-deny',
|
347
|
-
|
348
|
+
|
348
349
|
relName: 'droppable' // automatically discovered feature key
|
349
350
|
},
|
350
|
-
|
351
|
+
|
351
352
|
// See the Draggable rescan method, case we're kinda hijacking it in here
|
352
|
-
rescan:
|
353
|
-
|
353
|
+
rescan: Draggable.rescan,
|
354
|
+
|
354
355
|
/**
|
355
356
|
* Checks for hoverting draggable
|
356
357
|
*
|
@@ -362,10 +363,10 @@ var Droppable = new Class(Observer, {
|
|
362
363
|
this.active[i].checkHover(event, draggable);
|
363
364
|
}
|
364
365
|
},
|
365
|
-
|
366
|
+
|
366
367
|
/**
|
367
368
|
* Checks for a drop
|
368
|
-
*
|
369
|
+
*
|
369
370
|
* @param Event mouse event
|
370
371
|
* @param Draggable draggable
|
371
372
|
*/
|
@@ -374,10 +375,10 @@ var Droppable = new Class(Observer, {
|
|
374
375
|
this.active[i].checkDrop(event, draggable);
|
375
376
|
}
|
376
377
|
},
|
377
|
-
|
378
|
+
|
378
379
|
active: []
|
379
380
|
},
|
380
|
-
|
381
|
+
|
381
382
|
/**
|
382
383
|
* Basic cosntructor
|
383
384
|
*
|
@@ -387,10 +388,10 @@ var Droppable = new Class(Observer, {
|
|
387
388
|
initialize: function(element, options) {
|
388
389
|
this.element = $(element);
|
389
390
|
this.$super(options);
|
390
|
-
|
391
|
+
|
391
392
|
Droppable.active.push(this.element._droppable = this);
|
392
393
|
},
|
393
|
-
|
394
|
+
|
394
395
|
/**
|
395
396
|
* Detaches the attached events
|
396
397
|
*
|
@@ -401,7 +402,7 @@ var Droppable = new Class(Observer, {
|
|
401
402
|
delete(this.element.droppable);
|
402
403
|
return this;
|
403
404
|
},
|
404
|
-
|
405
|
+
|
405
406
|
/**
|
406
407
|
* checks the event for hovering
|
407
408
|
*
|
@@ -420,7 +421,7 @@ var Droppable = new Class(Observer, {
|
|
420
421
|
this.reset().fire('leave', draggable, this, event);
|
421
422
|
}
|
422
423
|
},
|
423
|
-
|
424
|
+
|
424
425
|
/**
|
425
426
|
* Checks if it should process the drop from draggable
|
426
427
|
*
|
@@ -434,7 +435,7 @@ var Droppable = new Class(Observer, {
|
|
434
435
|
this.fire('drop', draggable, this, event);
|
435
436
|
}
|
436
437
|
},
|
437
|
-
|
438
|
+
|
438
439
|
/**
|
439
440
|
* resets the element state
|
440
441
|
*
|
@@ -444,7 +445,7 @@ var Droppable = new Class(Observer, {
|
|
444
445
|
this.element.removeClass(this.options.allowClass).removeClass(this.options.denyClass);
|
445
446
|
return this;
|
446
447
|
},
|
447
|
-
|
448
|
+
|
448
449
|
// protected
|
449
450
|
|
450
451
|
// checks if the element is hovered by the event
|
@@ -456,7 +457,7 @@ var Droppable = new Class(Observer, {
|
|
456
457
|
t_bottom = dims.top + dims.height,
|
457
458
|
event_x = event.pageX,
|
458
459
|
event_y = event.pageY;
|
459
|
-
|
460
|
+
|
460
461
|
// checking the overlapping
|
461
462
|
if (this.options.overlap) {
|
462
463
|
var drag_dims = draggable.element.dimensions(),
|
@@ -465,8 +466,8 @@ var Droppable = new Class(Observer, {
|
|
465
466
|
left = drag_dims.left,
|
466
467
|
right = drag_dims.left + drag_dims.width,
|
467
468
|
bottom = drag_dims.top + drag_dims.height;
|
468
|
-
|
469
|
-
|
469
|
+
|
470
|
+
|
470
471
|
switch (this.options.overlap) {
|
471
472
|
// horizontal overlapping only check
|
472
473
|
case 'x':
|
@@ -478,7 +479,7 @@ var Droppable = new Class(Observer, {
|
|
478
479
|
(left > t_left && left < (t_right - dims.width * level)) ||
|
479
480
|
(right < t_right && right > (t_left + dims.width * level))
|
480
481
|
);
|
481
|
-
|
482
|
+
|
482
483
|
// vertical overlapping only check
|
483
484
|
case 'y':
|
484
485
|
case 'vertical':
|
@@ -489,7 +490,7 @@ var Droppable = new Class(Observer, {
|
|
489
490
|
(top > t_top && top < (t_bottom - dims.height * level)) ||
|
490
491
|
(bottom < t_bottom && bottom > (t_top + dims.height * level))
|
491
492
|
);
|
492
|
-
|
493
|
+
|
493
494
|
// both overlaps check
|
494
495
|
default:
|
495
496
|
return (
|
@@ -500,32 +501,32 @@ var Droppable = new Class(Observer, {
|
|
500
501
|
(bottom < t_bottom && bottom > (t_top + dims.height * level))
|
501
502
|
);
|
502
503
|
}
|
503
|
-
|
504
|
+
|
504
505
|
} else {
|
505
506
|
// simple check agains the event position
|
506
507
|
return event_x > t_left && event_x < t_right && event_y > t_top && event_y < t_bottom;
|
507
508
|
}
|
508
509
|
},
|
509
|
-
|
510
|
+
|
510
511
|
// checks if the object accepts the draggable
|
511
512
|
allows: function(draggable) {
|
512
513
|
if (this.options.containment && !this._scanned) {
|
513
514
|
this.options.containment = R(this.options.containment).map($);
|
514
515
|
this._scanned = true;
|
515
516
|
}
|
516
|
-
|
517
|
+
|
517
518
|
// checking the invitations list
|
518
519
|
var welcomed = this.options.containment ? this.options.containment.includes(draggable.element) : true;
|
519
|
-
|
520
|
+
|
520
521
|
return welcomed && (this.options.accept == '*' ? true : draggable.element.match(this.options.accept));
|
521
522
|
}
|
522
|
-
|
523
|
+
|
523
524
|
});
|
524
525
|
|
525
526
|
/**
|
526
527
|
* The document events hooker
|
527
528
|
*
|
528
|
-
* Copyright (C) 2009-
|
529
|
+
* Copyright (C) 2009-2011 Nikolay Nemshilov
|
529
530
|
*/
|
530
531
|
$(document).on({
|
531
532
|
// parocesses the automatically discovered elements
|
@@ -533,7 +534,7 @@ $(document).on({
|
|
533
534
|
Draggable.rescan();
|
534
535
|
Droppable.rescan();
|
535
536
|
},
|
536
|
-
|
537
|
+
|
537
538
|
// watch the draggables moving arond
|
538
539
|
mousemove: function(event) {
|
539
540
|
if (Draggable.current !== null) {
|
@@ -541,7 +542,7 @@ $(document).on({
|
|
541
542
|
Droppable.checkHover(event, Draggable.current);
|
542
543
|
}
|
543
544
|
},
|
544
|
-
|
545
|
+
|
545
546
|
// releases the current draggable on mouse up
|
546
547
|
mouseup: function(event) {
|
547
548
|
if (Draggable.current !== null) {
|
@@ -1,20 +1,7 @@
|
|
1
1
|
/**
|
2
|
-
* Drag'n'Drop module
|
2
|
+
* Drag'n'Drop module v2.2.0
|
3
3
|
* http://rightjs.org/plugins/drag-n-drop
|
4
4
|
*
|
5
|
-
* Copyright (C) 2009-
|
5
|
+
* Copyright (C) 2009-2011 Nikolay Nemshilov
|
6
6
|
*/
|
7
|
-
(function(
|
8
|
-
c);new this(b,eval("("+e+")")||{})}},this)}},initialize:function(a,c){this.element=k(a);this.$super(c);this.element.draggable=this.init()},destroy:function(){this.handle.stopObserving("mousedown",this._dragStart);delete this.element.draggable;return this},setOptions:function(a){this.$super(a);this.handle=this.options.handle?k(this.options.handle):this.element;if(x(this.options.snap)){this.snapX=this.options.snap[0];this.snapY=this.options.snap[1]}else this.snapX=this.snapY=this.options.snap;return this},
|
9
|
-
revert:function(){var a=this.clone.position();a={top:a.y+this.ryDiff+"px",left:a.x+this.rxDiff+"px"};if(this.options.revertDuration&&this.element.morph)this.element.morph(a,{duration:this.options.revertDuration,onFinish:f(this.swapBack).bind(this)});else{this.element.setStyle(a);this.swapBack()}return this},init:function(){this._dragStart=f(this.dragStart).bind(this);this.handle.onMousedown(this._dragStart);return this},dragStart:function(a){this.fire("before",this,a.stop());var c=this.element.position();
|
10
|
-
this.xDiff=a.pageX-c.x;this.yDiff=a.pageY-c.y;var b={y:f(this.element.getStyle("top")).toFloat(),x:f(this.element.getStyle("left")).toFloat()};this.rxDiff=isNaN(b.x)?0:b.x-c.x;this.ryDiff=isNaN(b.y)?0:b.y-c.y;b={x:this.element.getStyle("width"),y:this.element.getStyle("height")};if(b.x=="auto")b.x=this.element._.offsetWidth+"px";if(b.y=="auto")b.y=this.element._.offsetHeight+"px";if(this.options.clone||this.options.revert)this.clone=(new s(this.element._.cloneNode(true))).setStyle({visibility:this.options.clone?
|
11
|
-
"visible":"hidden"}).insertTo(this.element,"before");this.element.setStyle({position:"absolute",zIndex:j.Options.zIndex++,top:c.y+this.ryDiff+"px",left:c.x+this.rxDiff+"px",width:b.x,height:b.y}).addClass(this.options.dragClass);this.options.moveOut&&this.element.insertTo(r.body);this.winScrolls=k(q).scrolls();this.winSizes=k(q).size();j.current=this.calcConstraints().fire("start",this,a);this.style=this.element._.style},dragProcess:function(a){var c=a.pageX,b=a.pageY,e=c-this.xDiff,h=b-this.yDiff;
|
12
|
-
if(this.ranged){if(this.minX>e)e=this.minX;if(this.maxX<e)e=this.maxX;if(this.minY>h)h=this.minY;if(this.maxY<h)h=this.maxY}if(this.options.scroll){var d={x:this.winScrolls.x,y:this.winScrolls.y},g=this.options.scrollSensitivity;if(b-d.y<g)d.y=b-g;else if(d.y+this.winSizes.y-b<g)d.y=b-this.winSizes.y+g;if(c-d.x<g)d.x=c-g;else if(d.x+this.winSizes.x-c<g)d.x=c-this.winSizes.x+g;if(d.y<0)d.y=0;if(d.x<0)d.x=0;if(d.y<this.winScrolls.y||d.y>this.winScrolls.y||d.x<this.winScrolls.x||d.x>this.winScrolls.x)k(q).scrollTo(this.winScrolls=
|
13
|
-
d)}if(this.snapX)e-=e%this.snapX;if(this.snapY)h-=h%this.snapY;if(!this.axisY)this.style.left=e+this.rxDiff+"px";if(!this.axisX)this.style.top=h+this.ryDiff+"px";this.fire("drag",this,a)},dragStop:function(a){this.element.removeClass(this.options.dragClass);n.checkDrop(a,this);this.options.revert&&this.revert();j.current=null;this.fire("stop",this,a)},swapBack:function(){if(this.clone)this.clone.replace(this.element.setStyle({width:this.clone.getStyle("width"),height:this.clone.getStyle("height"),
|
14
|
-
position:this.clone.getStyle("position"),zIndex:this.clone.getStyle("zIndex")||""}))},calcConstraints:function(){var a=this.options.axis;this.axisX=f(["x","horizontal"]).include(a);this.axisY=f(["y","vertical"]).include(a);this.ranged=false;if(a=this.options.range){this.ranged=true;var c=k(a);if(c instanceof s){a=c.dimensions();a={x:[a.left,a.left+a.width],y:[a.top,a.top+a.height]}}if(w(a)){c=this.element.size();if(a.x){this.minX=a.x[0];this.maxX=a.x[1]-c.x}if(a.y){this.minY=a.y[0];this.maxY=a.y[1]-
|
15
|
-
c.y}}}return this}}),n=new u(v,{extend:{EVENTS:t("drop hover leave"),Options:{accept:"*",containment:null,overlap:null,overlapSize:0.5,allowClass:"droppable-allow",denyClass:"droppable-deny",relName:"droppable"},rescan:eval("["+j.rescan.toString().replace(/\.draggable/g,".droppable")+"]")[0],checkHover:function(a,c){for(var b=0,e=this.active.length;b<e;b++)this.active[b].checkHover(a,c)},checkDrop:function(a,c){for(var b=0,e=this.active.length;b<e;b++)this.active[b].checkDrop(a,c)},active:[]},initialize:function(a,
|
16
|
-
c){this.element=k(a);this.$super(c);n.active.push(this.element._droppable=this)},destroy:function(){n.active=n.active.without(this);delete this.element.droppable;return this},checkHover:function(a,c){if(this.hoveredBy(a,c)){if(!this._hovered){this._hovered=true;this.element.addClass(this.options[this.allows(c)?"allowClass":"denyClass"]);this.fire("hover",c,this,a)}}else if(this._hovered){this._hovered=false;this.reset().fire("leave",c,this,a)}},checkDrop:function(a,c){this.reset();if(this.hoveredBy(a,
|
17
|
-
c)&&this.allows(c)){c.fire("drop",this,c,a);this.fire("drop",c,this,a)}},reset:function(){this.element.removeClass(this.options.allowClass).removeClass(this.options.denyClass);return this},hoveredBy:function(a,c){var b=this.element.dimensions(),e=b.top,h=b.left,d=b.left+b.width,g=b.top+b.height,l=a.pageX,m=a.pageY;if(this.options.overlap){var i=c.element.dimensions();l=this.options.overlapSize;m=i.top;var o=i.left,p=i.left+i.width;i=i.top+i.height;switch(this.options.overlap){case "x":case "horizontal":return(m>
|
18
|
-
e&&m<g||i>e&&i<g)&&(o>h&&o<d-b.width*l||p<d&&p>h+b.width*l);case "y":case "vertical":return(o>h&&o<d||p>h&&p<d)&&(m>e&&m<g-b.height*l||i<g&&i>e+b.height*l);default:return(o>h&&o<d-b.width*l||p<d&&p>h+b.width*l)&&(m>e&&m<g-b.height*l||i<g&&i>e+b.height*l)}}else return l>h&&l<d&&m>e&&m<g},allows:function(a){if(this.options.containment&&!this._scanned){this.options.containment=f(this.options.containment).map(k);this._scanned=true}return(this.options.containment?this.options.containment.includes(a.element):
|
19
|
-
true)&&(this.options.accept=="*"?true:a.element.match(this.options.accept))}});k(r).on({ready:function(){j.rescan();n.rescan()},mousemove:function(a){if(j.current!==null){j.current.dragProcess(a);n.checkHover(a,j.current)}},mouseup:function(a){j.current!==null&&j.current.dragStop(a)}});s.include({makeDraggable:function(a){new j(this,a);return this},undoDraggable:function(){"draggable"in this&&this.draggable.destroy();return this},makeDroppable:function(a){new n(this,a);return this},undoDroppable:function(){"droppable"in
|
20
|
-
this&&this.droppable.destroy();return this}});q.Draggable=f.Draggable=j;q.Droppable=f.Droppable=n})(window,document,RightJS);
|
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.0",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.element.draggable=this.init()},destroy:function(){this.handle.stopObserving("mousedown",this._dragStart),delete this.element.draggable;return this},setOptions:function(a){this.$super(a),this.handle=this.options.handle?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},init:function(){this._dragStart=d(this.dragStart).bind(this),this.handle.onMousedown(this._dragStart);return this},dragStart:function(c){this.fire("before",this,c.stop());var f=this.element.position();this.xDiff=c.pageX-f.x,this.yDiff=c.pageY-f.y;var g={y:d(this.element.getStyle("top")).toFloat(),x:d(this.element.getStyle("left")).toFloat()};this.rxDiff=isNaN(g.x)?0:g.x-f.x,this.ryDiff=isNaN(g.y)?0:g.y-f.y;var h={x:this.element.getStyle("width"),y:this.element.getStyle("height")};h.x=="auto"&&(h.x=this.element._.offsetWidth+"px"),h.y=="auto"&&(h.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:f.y+this.ryDiff+"px",left:f.x+this.rxDiff+"px",width:h.x,height:h.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(),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")||""}))},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)
|