ava_rails_generator 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- data/MIT-LICENSE +20 -0
- data/README.rdoc +19 -0
- data/Rakefile +54 -0
- data/USAGE +27 -0
- data/VERSION +1 -0
- data/ava_rails_generator.rb +201 -0
- data/templates/001_create_sessions.rb +16 -0
- data/templates/002_create_users.rb +20 -0
- data/templates/action_view_helper.rb +35 -0
- data/templates/action_view_ja.yml +115 -0
- data/templates/active_record_ja.yml +66 -0
- data/templates/active_support_ja.yml +36 -0
- data/templates/ann_back.png +0 -0
- data/templates/ann_back02.png +0 -0
- data/templates/application.html.erb +35 -0
- data/templates/application.js +128 -0
- data/templates/application_controller.rb +90 -0
- data/templates/application_csv.rb +66 -0
- data/templates/application_helper.rb +558 -0
- data/templates/application_search.rb +74 -0
- data/templates/arrow_h.gif +0 -0
- data/templates/arrow_l.png +0 -0
- data/templates/arrow_n.gif +0 -0
- data/templates/arrow_r.png +0 -0
- data/templates/arrow_v.gif +0 -0
- data/templates/auth_controller.rb +80 -0
- data/templates/bak.png +0 -0
- data/templates/btn_back.png +0 -0
- data/templates/btn_cancel_cre.png +0 -0
- data/templates/btn_cancel_upd.png +0 -0
- data/templates/btn_clear.png +0 -0
- data/templates/btn_close.png +0 -0
- data/templates/btn_complete.png +0 -0
- data/templates/btn_confirm_cre.png +0 -0
- data/templates/btn_confirm_upd.png +0 -0
- data/templates/btn_create.png +0 -0
- data/templates/btn_csv.png +0 -0
- data/templates/btn_delete.png +0 -0
- data/templates/btn_login.png +0 -0
- data/templates/btn_new.png +0 -0
- data/templates/btn_reenter.png +0 -0
- data/templates/btn_reload.png +0 -0
- data/templates/btn_reply.png +0 -0
- data/templates/btn_search.png +0 -0
- data/templates/btn_send.png +0 -0
- data/templates/btn_sub01.png +0 -0
- data/templates/btn_sub02.png +0 -0
- data/templates/btn_upd.png +0 -0
- data/templates/btn_upd_cancel.png +0 -0
- data/templates/btn_update.png +0 -0
- data/templates/btn_xml.png +0 -0
- data/templates/bubble_ex_g.png +0 -0
- data/templates/bubble_ex_p.png +0 -0
- data/templates/bubble_minus.gif +0 -0
- data/templates/bubble_plus.gif +0 -0
- data/templates/builder.js +136 -0
- data/templates/calendar.gif +0 -0
- data/templates/csv.rb +997 -0
- data/templates/default.css +92 -0
- data/templates/footer_a_bak.gif +0 -0
- data/templates/footer_m_bak.gif +0 -0
- data/templates/footer_w_bak.gif +0 -0
- data/templates/form.css +105 -0
- data/templates/g_navi_bak.gif +0 -0
- data/templates/import.css +13 -0
- data/templates/index.html.erb +8 -0
- data/templates/jquery-1.4.4.min.js +167 -0
- data/templates/jquery-ui-1.8.10.custom.css +573 -0
- data/templates/jquery-ui-1.8.10.custom.min.js +782 -0
- data/templates/jquery.ui.datepicker-ja.js +23 -0
- data/templates/layout.css +938 -0
- data/templates/link.gif +0 -0
- data/templates/link_t.gif +0 -0
- data/templates/login.html.erb +64 -0
- data/templates/login_back01.png +0 -0
- data/templates/logo.png +0 -0
- data/templates/mail.png +0 -0
- data/templates/menuTabL.gif +0 -0
- data/templates/menuTabR.gif +0 -0
- data/templates/navis.gif +0 -0
- data/templates/pageTitle_bak.png +0 -0
- data/templates/page_bak.gif +0 -0
- data/templates/password.html.erb +69 -0
- data/templates/pop.png +0 -0
- data/templates/prototype.js +6081 -0
- data/templates/rails.png +0 -0
- data/templates/scaffold.css +110 -0
- data/templates/scriptaculous.js +68 -0
- data/templates/slider.js +275 -0
- data/templates/sound.js +59 -0
- data/templates/tip.png +0 -0
- data/templates/tolist.png +0 -0
- data/templates/top_controller.rb +5 -0
- data/templates/translation_ja.yml +30 -0
- data/templates/ui-bg_flat_0_aaaaaa_40x100.png +0 -0
- data/templates/ui-bg_flat_55_fbec88_40x100.png +0 -0
- data/templates/ui-bg_glass_75_d0e5f5_1x400.png +0 -0
- data/templates/ui-bg_glass_85_dfeffc_1x400.png +0 -0
- data/templates/ui-bg_glass_95_fef1ec_1x400.png +0 -0
- data/templates/ui-bg_gloss-wave_55_5c9ccc_500x100.png +0 -0
- data/templates/ui-bg_inset-hard_100_f5f8f9_1x100.png +0 -0
- data/templates/ui-bg_inset-hard_100_fcfdfd_1x100.png +0 -0
- data/templates/ui-icons_217bc0_256x240.png +0 -0
- data/templates/ui-icons_2e83ff_256x240.png +0 -0
- data/templates/ui-icons_469bdd_256x240.png +0 -0
- data/templates/ui-icons_6da8d5_256x240.png +0 -0
- data/templates/ui-icons_cd0a0a_256x240.png +0 -0
- data/templates/ui-icons_d8e7f3_256x240.png +0 -0
- data/templates/ui-icons_f9bd01_256x240.png +0 -0
- data/templates/unittest.js +568 -0
- data/templates/user.rb +71 -0
- data/templates/user_blue.css +62 -0
- data/templates/user_green.css +61 -0
- data/templates/user_red.css +61 -0
- metadata +254 -0
data/templates/rails.png
ADDED
Binary file
|
@@ -0,0 +1,110 @@
|
|
1
|
+
/*
|
2
|
+
body { background-color: #fff; color: #333; }
|
3
|
+
|
4
|
+
body, p, ol, ul, td {
|
5
|
+
font-family: verdana, arial, helvetica, sans-serif;
|
6
|
+
font-size: 13px;
|
7
|
+
line-height: 18px;
|
8
|
+
}
|
9
|
+
|
10
|
+
pre {
|
11
|
+
background-color: #eee;
|
12
|
+
padding: 10px;
|
13
|
+
font-size: 11px;
|
14
|
+
}
|
15
|
+
|
16
|
+
a { color: #000; }
|
17
|
+
a:visited { color: #666; }
|
18
|
+
a:hover { color: #fff; background-color:#000; }
|
19
|
+
*/
|
20
|
+
|
21
|
+
|
22
|
+
.fieldWithErrors {
|
23
|
+
display: inline-block;
|
24
|
+
padding: 2px;
|
25
|
+
background-color: #ffcce5;
|
26
|
+
}
|
27
|
+
|
28
|
+
.fieldWithErrors input,
|
29
|
+
.fieldWithErrors textarea,
|
30
|
+
.fieldWithErrors select {
|
31
|
+
background-color: #ffcce5;
|
32
|
+
}
|
33
|
+
|
34
|
+
|
35
|
+
th > .fieldWithErrors {
|
36
|
+
background: #aaa;
|
37
|
+
}
|
38
|
+
|
39
|
+
/*
|
40
|
+
.fieldWithErrors input,
|
41
|
+
.fieldWithErrors select,
|
42
|
+
.fieldWithErrors textarea{
|
43
|
+
padding: 2px;
|
44
|
+
background-color: #ffcce5;
|
45
|
+
}
|
46
|
+
*/
|
47
|
+
|
48
|
+
|
49
|
+
#errorExplanation {
|
50
|
+
font-size: 14px;
|
51
|
+
line-height: 120%;
|
52
|
+
background: #ffffc6;
|
53
|
+
margin: 20px;
|
54
|
+
padding: 10px;
|
55
|
+
border: 1px solid #ff7fbf;
|
56
|
+
}
|
57
|
+
|
58
|
+
#errorExplanation h2 {
|
59
|
+
font-weight: bold;
|
60
|
+
padding: 5px 5px 5px 15px;
|
61
|
+
font-size: 12px;
|
62
|
+
background-color: #ffcce5;
|
63
|
+
color: #ff007f;
|
64
|
+
}
|
65
|
+
|
66
|
+
#errorExplanation p {
|
67
|
+
margin: 0;
|
68
|
+
padding: 5px 5px 5px 20px;
|
69
|
+
}
|
70
|
+
|
71
|
+
#errorExplanation ul li {
|
72
|
+
font-size: 12px;
|
73
|
+
list-style: square;
|
74
|
+
list-style-position: inside;
|
75
|
+
padding-left: 20px;
|
76
|
+
}
|
77
|
+
|
78
|
+
/*
|
79
|
+
|
80
|
+
#errorExplanation {
|
81
|
+
width: 400px;
|
82
|
+
border: 2px solid red;
|
83
|
+
padding: 7px;
|
84
|
+
padding-bottom: 12px;
|
85
|
+
margin-bottom: 20px;
|
86
|
+
background-color: #f0f0f0;
|
87
|
+
}
|
88
|
+
|
89
|
+
#errorExplanation h2 {
|
90
|
+
text-align: left;
|
91
|
+
font-weight: bold;
|
92
|
+
padding: 5px 5px 5px 15px;
|
93
|
+
font-size: 12px;
|
94
|
+
margin: -7px;
|
95
|
+
background-color: #c00;
|
96
|
+
color: #fff;
|
97
|
+
}
|
98
|
+
|
99
|
+
#errorExplanation p {
|
100
|
+
color: #333;
|
101
|
+
margin-bottom: 0;
|
102
|
+
padding: 5px;
|
103
|
+
}
|
104
|
+
|
105
|
+
#errorExplanation ul li {
|
106
|
+
font-size: 12px;
|
107
|
+
list-style: square;
|
108
|
+
}
|
109
|
+
|
110
|
+
*/
|
@@ -0,0 +1,68 @@
|
|
1
|
+
// script.aculo.us scriptaculous.js v1.9.0, Thu Dec 23 16:54:48 -0500 2010
|
2
|
+
|
3
|
+
// Copyright (c) 2005-2010 Thomas Fuchs (http://script.aculo.us, http://mir.aculo.us)
|
4
|
+
//
|
5
|
+
// Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
// a copy of this software and associated documentation files (the
|
7
|
+
// "Software"), to deal in the Software without restriction, including
|
8
|
+
// without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
// distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
// permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
// the following conditions:
|
12
|
+
//
|
13
|
+
// The above copyright notice and this permission notice shall be
|
14
|
+
// included in all copies or substantial portions of the Software.
|
15
|
+
//
|
16
|
+
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
23
|
+
//
|
24
|
+
// For details, see the script.aculo.us web site: http://script.aculo.us/
|
25
|
+
|
26
|
+
var Scriptaculous = {
|
27
|
+
Version: '1.9.0',
|
28
|
+
require: function(libraryName) {
|
29
|
+
try{
|
30
|
+
// inserting via DOM fails in Safari 2.0, so brute force approach
|
31
|
+
document.write('<script type="text/javascript" src="'+libraryName+'"><\/script>');
|
32
|
+
} catch(e) {
|
33
|
+
// for xhtml+xml served content, fall back to DOM methods
|
34
|
+
var script = document.createElement('script');
|
35
|
+
script.type = 'text/javascript';
|
36
|
+
script.src = libraryName;
|
37
|
+
document.getElementsByTagName('head')[0].appendChild(script);
|
38
|
+
}
|
39
|
+
},
|
40
|
+
REQUIRED_PROTOTYPE: '1.6.0.3',
|
41
|
+
load: function() {
|
42
|
+
function convertVersionString(versionString) {
|
43
|
+
var v = versionString.replace(/_.*|\./g, '');
|
44
|
+
v = parseInt(v + '0'.times(4-v.length));
|
45
|
+
return versionString.indexOf('_') > -1 ? v-1 : v;
|
46
|
+
}
|
47
|
+
|
48
|
+
if((typeof Prototype=='undefined') ||
|
49
|
+
(typeof Element == 'undefined') ||
|
50
|
+
(typeof Element.Methods=='undefined') ||
|
51
|
+
(convertVersionString(Prototype.Version) <
|
52
|
+
convertVersionString(Scriptaculous.REQUIRED_PROTOTYPE)))
|
53
|
+
throw("script.aculo.us requires the Prototype JavaScript framework >= " +
|
54
|
+
Scriptaculous.REQUIRED_PROTOTYPE);
|
55
|
+
|
56
|
+
var js = /scriptaculous\.js(\?.*)?$/;
|
57
|
+
$$('script[src]').findAll(function(s) {
|
58
|
+
return s.src.match(js);
|
59
|
+
}).each(function(s) {
|
60
|
+
var path = s.src.replace(js, ''),
|
61
|
+
includes = s.src.match(/\?.*load=([a-z,]*)/);
|
62
|
+
(includes ? includes[1] : 'builder,effects,dragdrop,controls,slider,sound').split(',').each(
|
63
|
+
function(include) { Scriptaculous.require(path+include+'.js') });
|
64
|
+
});
|
65
|
+
}
|
66
|
+
};
|
67
|
+
|
68
|
+
Scriptaculous.load();
|
data/templates/slider.js
ADDED
@@ -0,0 +1,275 @@
|
|
1
|
+
// script.aculo.us slider.js v1.9.0, Thu Dec 23 16:54:48 -0500 2010
|
2
|
+
|
3
|
+
// Copyright (c) 2005-2010 Marty Haught, Thomas Fuchs
|
4
|
+
//
|
5
|
+
// script.aculo.us is freely distributable under the terms of an MIT-style license.
|
6
|
+
// For details, see the script.aculo.us web site: http://script.aculo.us/
|
7
|
+
|
8
|
+
if (!Control) var Control = { };
|
9
|
+
|
10
|
+
// options:
|
11
|
+
// axis: 'vertical', or 'horizontal' (default)
|
12
|
+
//
|
13
|
+
// callbacks:
|
14
|
+
// onChange(value)
|
15
|
+
// onSlide(value)
|
16
|
+
Control.Slider = Class.create({
|
17
|
+
initialize: function(handle, track, options) {
|
18
|
+
var slider = this;
|
19
|
+
|
20
|
+
if (Object.isArray(handle)) {
|
21
|
+
this.handles = handle.collect( function(e) { return $(e) });
|
22
|
+
} else {
|
23
|
+
this.handles = [$(handle)];
|
24
|
+
}
|
25
|
+
|
26
|
+
this.track = $(track);
|
27
|
+
this.options = options || { };
|
28
|
+
|
29
|
+
this.axis = this.options.axis || 'horizontal';
|
30
|
+
this.increment = this.options.increment || 1;
|
31
|
+
this.step = parseInt(this.options.step || '1');
|
32
|
+
this.range = this.options.range || $R(0,1);
|
33
|
+
|
34
|
+
this.value = 0; // assure backwards compat
|
35
|
+
this.values = this.handles.map( function() { return 0 });
|
36
|
+
this.spans = this.options.spans ? this.options.spans.map(function(s){ return $(s) }) : false;
|
37
|
+
this.options.startSpan = $(this.options.startSpan || null);
|
38
|
+
this.options.endSpan = $(this.options.endSpan || null);
|
39
|
+
|
40
|
+
this.restricted = this.options.restricted || false;
|
41
|
+
|
42
|
+
this.maximum = this.options.maximum || this.range.end;
|
43
|
+
this.minimum = this.options.minimum || this.range.start;
|
44
|
+
|
45
|
+
// Will be used to align the handle onto the track, if necessary
|
46
|
+
this.alignX = parseInt(this.options.alignX || '0');
|
47
|
+
this.alignY = parseInt(this.options.alignY || '0');
|
48
|
+
|
49
|
+
this.trackLength = this.maximumOffset() - this.minimumOffset();
|
50
|
+
|
51
|
+
this.handleLength = this.isVertical() ?
|
52
|
+
(this.handles[0].offsetHeight != 0 ?
|
53
|
+
this.handles[0].offsetHeight : this.handles[0].style.height.replace(/px$/,"")) :
|
54
|
+
(this.handles[0].offsetWidth != 0 ? this.handles[0].offsetWidth :
|
55
|
+
this.handles[0].style.width.replace(/px$/,""));
|
56
|
+
|
57
|
+
this.active = false;
|
58
|
+
this.dragging = false;
|
59
|
+
this.disabled = false;
|
60
|
+
|
61
|
+
if (this.options.disabled) this.setDisabled();
|
62
|
+
|
63
|
+
// Allowed values array
|
64
|
+
this.allowedValues = this.options.values ? this.options.values.sortBy(Prototype.K) : false;
|
65
|
+
if (this.allowedValues) {
|
66
|
+
this.minimum = this.allowedValues.min();
|
67
|
+
this.maximum = this.allowedValues.max();
|
68
|
+
}
|
69
|
+
|
70
|
+
this.eventMouseDown = this.startDrag.bindAsEventListener(this);
|
71
|
+
this.eventMouseUp = this.endDrag.bindAsEventListener(this);
|
72
|
+
this.eventMouseMove = this.update.bindAsEventListener(this);
|
73
|
+
|
74
|
+
// Initialize handles in reverse (make sure first handle is active)
|
75
|
+
this.handles.each( function(h,i) {
|
76
|
+
i = slider.handles.length-1-i;
|
77
|
+
slider.setValue(parseFloat(
|
78
|
+
(Object.isArray(slider.options.sliderValue) ?
|
79
|
+
slider.options.sliderValue[i] : slider.options.sliderValue) ||
|
80
|
+
slider.range.start), i);
|
81
|
+
h.makePositioned().observe("mousedown", slider.eventMouseDown);
|
82
|
+
});
|
83
|
+
|
84
|
+
this.track.observe("mousedown", this.eventMouseDown);
|
85
|
+
document.observe("mouseup", this.eventMouseUp);
|
86
|
+
document.observe("mousemove", this.eventMouseMove);
|
87
|
+
|
88
|
+
this.initialized = true;
|
89
|
+
},
|
90
|
+
dispose: function() {
|
91
|
+
var slider = this;
|
92
|
+
Event.stopObserving(this.track, "mousedown", this.eventMouseDown);
|
93
|
+
Event.stopObserving(document, "mouseup", this.eventMouseUp);
|
94
|
+
Event.stopObserving(document, "mousemove", this.eventMouseMove);
|
95
|
+
this.handles.each( function(h) {
|
96
|
+
Event.stopObserving(h, "mousedown", slider.eventMouseDown);
|
97
|
+
});
|
98
|
+
},
|
99
|
+
setDisabled: function(){
|
100
|
+
this.disabled = true;
|
101
|
+
},
|
102
|
+
setEnabled: function(){
|
103
|
+
this.disabled = false;
|
104
|
+
},
|
105
|
+
getNearestValue: function(value){
|
106
|
+
if (this.allowedValues){
|
107
|
+
if (value >= this.allowedValues.max()) return(this.allowedValues.max());
|
108
|
+
if (value <= this.allowedValues.min()) return(this.allowedValues.min());
|
109
|
+
|
110
|
+
var offset = Math.abs(this.allowedValues[0] - value);
|
111
|
+
var newValue = this.allowedValues[0];
|
112
|
+
this.allowedValues.each( function(v) {
|
113
|
+
var currentOffset = Math.abs(v - value);
|
114
|
+
if (currentOffset <= offset){
|
115
|
+
newValue = v;
|
116
|
+
offset = currentOffset;
|
117
|
+
}
|
118
|
+
});
|
119
|
+
return newValue;
|
120
|
+
}
|
121
|
+
if (value > this.range.end) return this.range.end;
|
122
|
+
if (value < this.range.start) return this.range.start;
|
123
|
+
return value;
|
124
|
+
},
|
125
|
+
setValue: function(sliderValue, handleIdx){
|
126
|
+
if (!this.active) {
|
127
|
+
this.activeHandleIdx = handleIdx || 0;
|
128
|
+
this.activeHandle = this.handles[this.activeHandleIdx];
|
129
|
+
this.updateStyles();
|
130
|
+
}
|
131
|
+
handleIdx = handleIdx || this.activeHandleIdx || 0;
|
132
|
+
if (this.initialized && this.restricted) {
|
133
|
+
if ((handleIdx>0) && (sliderValue<this.values[handleIdx-1]))
|
134
|
+
sliderValue = this.values[handleIdx-1];
|
135
|
+
if ((handleIdx < (this.handles.length-1)) && (sliderValue>this.values[handleIdx+1]))
|
136
|
+
sliderValue = this.values[handleIdx+1];
|
137
|
+
}
|
138
|
+
sliderValue = this.getNearestValue(sliderValue);
|
139
|
+
this.values[handleIdx] = sliderValue;
|
140
|
+
this.value = this.values[0]; // assure backwards compat
|
141
|
+
|
142
|
+
this.handles[handleIdx].style[this.isVertical() ? 'top' : 'left'] =
|
143
|
+
this.translateToPx(sliderValue);
|
144
|
+
|
145
|
+
this.drawSpans();
|
146
|
+
if (!this.dragging || !this.event) this.updateFinished();
|
147
|
+
},
|
148
|
+
setValueBy: function(delta, handleIdx) {
|
149
|
+
this.setValue(this.values[handleIdx || this.activeHandleIdx || 0] + delta,
|
150
|
+
handleIdx || this.activeHandleIdx || 0);
|
151
|
+
},
|
152
|
+
translateToPx: function(value) {
|
153
|
+
return Math.round(
|
154
|
+
((this.trackLength-this.handleLength)/(this.range.end-this.range.start)) *
|
155
|
+
(value - this.range.start)) + "px";
|
156
|
+
},
|
157
|
+
translateToValue: function(offset) {
|
158
|
+
return ((offset/(this.trackLength-this.handleLength) *
|
159
|
+
(this.range.end-this.range.start)) + this.range.start);
|
160
|
+
},
|
161
|
+
getRange: function(range) {
|
162
|
+
var v = this.values.sortBy(Prototype.K);
|
163
|
+
range = range || 0;
|
164
|
+
return $R(v[range],v[range+1]);
|
165
|
+
},
|
166
|
+
minimumOffset: function(){
|
167
|
+
return(this.isVertical() ? this.alignY : this.alignX);
|
168
|
+
},
|
169
|
+
maximumOffset: function(){
|
170
|
+
return(this.isVertical() ?
|
171
|
+
(this.track.offsetHeight != 0 ? this.track.offsetHeight :
|
172
|
+
this.track.style.height.replace(/px$/,"")) - this.alignY :
|
173
|
+
(this.track.offsetWidth != 0 ? this.track.offsetWidth :
|
174
|
+
this.track.style.width.replace(/px$/,"")) - this.alignX);
|
175
|
+
},
|
176
|
+
isVertical: function(){
|
177
|
+
return (this.axis == 'vertical');
|
178
|
+
},
|
179
|
+
drawSpans: function() {
|
180
|
+
var slider = this;
|
181
|
+
if (this.spans)
|
182
|
+
$R(0, this.spans.length-1).each(function(r) { slider.setSpan(slider.spans[r], slider.getRange(r)) });
|
183
|
+
if (this.options.startSpan)
|
184
|
+
this.setSpan(this.options.startSpan,
|
185
|
+
$R(0, this.values.length>1 ? this.getRange(0).min() : this.value ));
|
186
|
+
if (this.options.endSpan)
|
187
|
+
this.setSpan(this.options.endSpan,
|
188
|
+
$R(this.values.length>1 ? this.getRange(this.spans.length-1).max() : this.value, this.maximum));
|
189
|
+
},
|
190
|
+
setSpan: function(span, range) {
|
191
|
+
if (this.isVertical()) {
|
192
|
+
span.style.top = this.translateToPx(range.start);
|
193
|
+
span.style.height = this.translateToPx(range.end - range.start + this.range.start);
|
194
|
+
} else {
|
195
|
+
span.style.left = this.translateToPx(range.start);
|
196
|
+
span.style.width = this.translateToPx(range.end - range.start + this.range.start);
|
197
|
+
}
|
198
|
+
},
|
199
|
+
updateStyles: function() {
|
200
|
+
this.handles.each( function(h){ Element.removeClassName(h, 'selected') });
|
201
|
+
Element.addClassName(this.activeHandle, 'selected');
|
202
|
+
},
|
203
|
+
startDrag: function(event) {
|
204
|
+
if (Event.isLeftClick(event)) {
|
205
|
+
if (!this.disabled){
|
206
|
+
this.active = true;
|
207
|
+
|
208
|
+
var handle = Event.element(event);
|
209
|
+
var pointer = [Event.pointerX(event), Event.pointerY(event)];
|
210
|
+
var track = handle;
|
211
|
+
if (track==this.track) {
|
212
|
+
var offsets = this.track.cumulativeOffset();
|
213
|
+
this.event = event;
|
214
|
+
this.setValue(this.translateToValue(
|
215
|
+
(this.isVertical() ? pointer[1]-offsets[1] : pointer[0]-offsets[0])-(this.handleLength/2)
|
216
|
+
));
|
217
|
+
var offsets = this.activeHandle.cumulativeOffset();
|
218
|
+
this.offsetX = (pointer[0] - offsets[0]);
|
219
|
+
this.offsetY = (pointer[1] - offsets[1]);
|
220
|
+
} else {
|
221
|
+
// find the handle (prevents issues with Safari)
|
222
|
+
while((this.handles.indexOf(handle) == -1) && handle.parentNode)
|
223
|
+
handle = handle.parentNode;
|
224
|
+
|
225
|
+
if (this.handles.indexOf(handle)!=-1) {
|
226
|
+
this.activeHandle = handle;
|
227
|
+
this.activeHandleIdx = this.handles.indexOf(this.activeHandle);
|
228
|
+
this.updateStyles();
|
229
|
+
|
230
|
+
var offsets = this.activeHandle.cumulativeOffset();
|
231
|
+
this.offsetX = (pointer[0] - offsets[0]);
|
232
|
+
this.offsetY = (pointer[1] - offsets[1]);
|
233
|
+
}
|
234
|
+
}
|
235
|
+
}
|
236
|
+
Event.stop(event);
|
237
|
+
}
|
238
|
+
},
|
239
|
+
update: function(event) {
|
240
|
+
if (this.active) {
|
241
|
+
if (!this.dragging) this.dragging = true;
|
242
|
+
this.draw(event);
|
243
|
+
if (Prototype.Browser.WebKit) window.scrollBy(0,0);
|
244
|
+
Event.stop(event);
|
245
|
+
}
|
246
|
+
},
|
247
|
+
draw: function(event) {
|
248
|
+
var pointer = [Event.pointerX(event), Event.pointerY(event)];
|
249
|
+
var offsets = this.track.cumulativeOffset();
|
250
|
+
pointer[0] -= this.offsetX + offsets[0];
|
251
|
+
pointer[1] -= this.offsetY + offsets[1];
|
252
|
+
this.event = event;
|
253
|
+
this.setValue(this.translateToValue( this.isVertical() ? pointer[1] : pointer[0] ));
|
254
|
+
if (this.initialized && this.options.onSlide)
|
255
|
+
this.options.onSlide(this.values.length>1 ? this.values : this.value, this);
|
256
|
+
},
|
257
|
+
endDrag: function(event) {
|
258
|
+
if (this.active && this.dragging) {
|
259
|
+
this.finishDrag(event, true);
|
260
|
+
Event.stop(event);
|
261
|
+
}
|
262
|
+
this.active = false;
|
263
|
+
this.dragging = false;
|
264
|
+
},
|
265
|
+
finishDrag: function(event, success) {
|
266
|
+
this.active = false;
|
267
|
+
this.dragging = false;
|
268
|
+
this.updateFinished();
|
269
|
+
},
|
270
|
+
updateFinished: function() {
|
271
|
+
if (this.initialized && this.options.onChange)
|
272
|
+
this.options.onChange(this.values.length>1 ? this.values : this.value, this);
|
273
|
+
this.event = null;
|
274
|
+
}
|
275
|
+
});
|