parlement 0.5 → 0.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (56) hide show
  1. data/CHANGES +26 -0
  2. data/README +2 -1
  3. data/app/controllers/account_controller.rb +27 -18
  4. data/app/controllers/application.rb +1 -3
  5. data/app/controllers/elt_controller.rb +92 -42
  6. data/app/helpers/elt_helper.rb +7 -18
  7. data/app/models/elt.rb +76 -22
  8. data/app/models/mail.rb +13 -10
  9. data/app/models/mail_notify.rb +11 -27
  10. data/app/models/person.rb +1 -1
  11. data/app/views/account/_login.rhtml +14 -9
  12. data/app/views/account/_show.rhtml +23 -9
  13. data/app/views/elt/_choice.rhtml +32 -0
  14. data/app/views/elt/_elt.rhtml +90 -78
  15. data/app/views/elt/_list.rhtml +83 -50
  16. data/app/views/elt/_listByDate.rhtml +60 -0
  17. data/app/views/elt/_listByVote.rhtml +71 -0
  18. data/app/views/elt/choices.rhtml +29 -0
  19. data/app/views/elt/new.rhtml +11 -26
  20. data/app/views/elt/rss.rxml +14 -12
  21. data/app/views/elt/show.rhtml +23 -29
  22. data/app/views/elt/vote_rss.rxml +40 -0
  23. data/app/views/layouts/top.rhtml +5 -13
  24. data/config/environment.rb +3 -1
  25. data/config/routes.rb +4 -0
  26. data/db/development_structure.sql +5 -2
  27. data/db/migrate/002_nested_set.rb +22 -0
  28. data/db/migrate/003_elt_children_count.rb +12 -0
  29. data/public/images/ParlementLogo.png +0 -0
  30. data/public/images/indicator.gif +0 -0
  31. data/public/javascripts/behaviour.js +254 -0
  32. data/public/javascripts/mybehaviour.js +96 -0
  33. data/public/javascripts/slider.js +188 -163
  34. data/test/fixtures/elts.yml +19 -0
  35. data/test/fixtures/mail/mail_ruby +4 -0
  36. data/test/fixtures/mail/mail_rubyChild +1 -1
  37. data/test/fixtures/mail/mail_rubyChild2 +1 -1
  38. data/test/functional/account_controller_test.rb +24 -0
  39. data/test/functional/elt_controller_test.rb +64 -4
  40. data/test/unit/elt_test.rb +28 -4
  41. data/test/unit/mail_notify_test.rb +7 -5
  42. data/test/unit/mail_test.rb +1 -1
  43. data/vendor/plugins/google_analytics/README +19 -0
  44. data/vendor/plugins/google_analytics/Rakefile +22 -0
  45. data/vendor/plugins/google_analytics/init.rb +3 -0
  46. data/vendor/plugins/google_analytics/lib/rubaidh/google_analytics.rb +70 -0
  47. data/vendor/plugins/google_analytics/test/google_analytics_test.rb +8 -0
  48. data/vendor/plugins/output_compression/README +4 -0
  49. data/vendor/plugins/output_compression/Rakefile +22 -0
  50. data/vendor/plugins/output_compression/init.rb +2 -0
  51. data/vendor/plugins/output_compression/lib/output_compression.rb +66 -0
  52. data/vendor/plugins/output_compression/tasks/output_compression_tasks.rake +4 -0
  53. data/vendor/plugins/output_compression/test/output_compression_test.rb +8 -0
  54. metadata +32 -4
  55. data/public/images/smile.svg +0 -257
  56. data/public/javascripts/borders.js +0 -687
@@ -0,0 +1,96 @@
1
+ var myrules = {
2
+ /*
3
+ * Possibility to open and close elements
4
+ *
5
+ * Two things:
6
+ * - an opening or closing will open or close all sub elements
7
+ * - an opened element contained by a closed element will be closed if any
8
+ * sub element is also closed (due to technical limitations)
9
+ */
10
+ '.eltSub' : function(elt) {
11
+ }
12
+ };
13
+
14
+ //Behaviour.register(myrules);
15
+
16
+ function setKnobs(elt) {
17
+ var knobOpened = document.createElement("a");
18
+ Element.addClassName(knobOpened, "knobOpened");
19
+ knobOpened.href = "#";
20
+ knobOpened.appendChild(document.createTextNode("V"));
21
+
22
+ var knobClosed = document.createElement("a");
23
+ Element.addClassName(knobClosed, "knobClosed");
24
+ knobClosed.href = "#";
25
+ knobClosed.appendChild(document.createTextNode(">"));
26
+
27
+ elt.insertBefore(knobOpened, elt.firstChild);
28
+ elt.insertBefore(knobClosed, elt.firstChild);
29
+
30
+ knobOpened.onclick = function() { return closeElt(elt); }
31
+ knobClosed.onclick = function() { return openElt(elt); }
32
+ }
33
+
34
+
35
+ function closeElt(elt) {
36
+ Element.addClassName(elt, "closed");
37
+ Element.removeClassName(elt, "opened");
38
+
39
+ $A(document.getElementsByClassName("opened", elt)).each( function(e) {
40
+ Element.removeClassName(e, "opened");
41
+ });
42
+ $A(document.getElementsByClassName("closed", elt)).each( function(e) {
43
+ Element.removeClassName(e, "closed");
44
+ });
45
+
46
+ var openedParent = false;
47
+ var current = elt;
48
+ while (!openedParent && document != (current = current.parentNode)) {
49
+ openedParent = Element.hasClassName(current, 'opened');
50
+ }
51
+ if (openedParent) {
52
+ Element.removeClassName(current, "opened");
53
+ Element.removeClassName(elt, "closed");
54
+ }
55
+ return false;
56
+ }
57
+
58
+ function openElt(elt) {
59
+ var closedParent = false;
60
+ var current = elt;
61
+ while (!closedParent && document != (current = current.parentNode)) {
62
+ closedParent = Element.hasClassName(current, 'closed');
63
+ }
64
+ if (closedParent) {
65
+ Element.addClassName(elt, "opened");
66
+ }
67
+
68
+ Element.removeClassName(elt, "closed");
69
+ $A(document.getElementsByClassName("opened", elt)).each( function(e) {
70
+ Element.removeClassName(e, "opened");
71
+ });
72
+ $A(document.getElementsByClassName("closed", elt)).each( function(e) {
73
+ Element.removeClassName(e, "closed");
74
+ });
75
+ return false;
76
+ }
77
+
78
+ function resetChoices() {
79
+ $A(document.getElementsByClassName('selected', document.body)).each( function(choice) {
80
+ Element.removeClassName(choice, 'selected');
81
+ });
82
+ }
83
+
84
+ function updateChoices(choices) {
85
+ $A(document.getElementsByClassName('con', document.body)).each( function(choice) {
86
+ if (choices[choice.parentNode.parentNode.parentNode.id] == "-1") {
87
+ Element.addClassName(choice, 'selected');
88
+ }
89
+ });
90
+ $A(document.getElementsByClassName('pro', document.body)).each( function(choice) {
91
+ if (choices[choice.parentNode.parentNode.parentNode.id] == "1") {
92
+ Element.addClassName(choice, 'selected');
93
+ }
94
+ });
95
+ }
96
+
@@ -1,184 +1,251 @@
1
- // Copyright (c) 2005 Marty Haught
1
+ // Copyright (c) 2005 Marty Haught, Thomas Fuchs
2
+ //
3
+ // See http://script.aculo.us for more info
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:
2
12
  //
3
- // See scriptaculous.js for full license.
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.
4
23
 
5
24
  if(!Control) var Control = {};
6
25
  Control.Slider = Class.create();
7
26
 
8
27
  // options:
9
28
  // axis: 'vertical', or 'horizontal' (default)
10
- // increment: (default: 1)
11
- // step: (default: 1)
12
29
  //
13
30
  // callbacks:
14
31
  // onChange(value)
15
32
  // onSlide(value)
16
33
  Control.Slider.prototype = {
17
34
  initialize: function(handle, track, options) {
18
- this.handle = $(handle);
35
+ var slider = this;
36
+
37
+ if(handle instanceof Array) {
38
+ this.handles = handle.collect( function(e) { return $(e) });
39
+ } else {
40
+ this.handles = [$(handle)];
41
+ }
42
+
19
43
  this.track = $(track);
20
-
21
44
  this.options = options || {};
22
45
 
23
46
  this.axis = this.options.axis || 'horizontal';
24
47
  this.increment = this.options.increment || 1;
25
- this.step = parseInt(this.options.step) || 1;
26
- this.value = 0;
27
-
28
- var defaultMaximum = Math.round(this.track.offsetWidth / this.increment);
29
- if(this.isVertical()) defaultMaximum = Math.round(this.track.offsetHeight / this.increment);
48
+ this.step = parseInt(this.options.step || '1');
49
+ this.range = this.options.range || $R(0,1);
30
50
 
31
- this.maximum = this.options.maximum || defaultMaximum;
32
- this.minimum = this.options.minimum || 0;
33
-
34
- // Will be used to align the handle onto the track, if necessary
35
- this.alignX = parseInt (this.options.alignX) || 0;
36
- this.alignY = parseInt (this.options.alignY) || 0;
37
-
38
- // Zero out the slider position
39
- this.setCurrentLeft(Position.cumulativeOffset(this.track)[0] - Position.cumulativeOffset(this.handle)[0] + this.alignX);
40
- this.setCurrentTop(this.trackTop() - Position.cumulativeOffset(this.handle)[1] + this.alignY);
51
+ this.value = 0; // assure backwards compat
52
+ this.values = this.handles.map( function() { return 0 });
53
+ this.spans = this.options.spans ? this.options.spans.map(function(s){ return $(s) }) : false;
54
+ this.options.startSpan = $(this.options.startSpan || null);
55
+ this.options.endSpan = $(this.options.endSpan || null);
41
56
 
42
- this.offsetX = 0;
43
- this.offsetY = 0;
57
+ this.restricted = this.options.restricted || false;
44
58
 
45
- this.originalLeft = this.currentLeft();
46
- this.originalTop = this.currentTop();
47
- this.originalZ = parseInt(this.handle.style.zIndex || "0");
59
+ this.maximum = this.options.maximum || this.range.end;
60
+ this.minimum = this.options.minimum || this.range.start;
48
61
 
49
- // Prepopulate Slider value
50
- this.setSliderValue(parseInt(this.options.sliderValue) || 0);
62
+ // Will be used to align the handle onto the track, if necessary
63
+ this.alignX = parseInt(this.options.alignX || '0');
64
+ this.alignY = parseInt(this.options.alignY || '0');
65
+
66
+ this.trackLength = this.maximumOffset() - this.minimumOffset();
67
+ this.handleLength = this.isVertical() ? this.handles[0].offsetHeight : this.handles[0].offsetWidth;
51
68
 
52
69
  this.active = false;
53
70
  this.dragging = false;
54
71
  this.disabled = false;
55
72
 
56
- // FIXME: use css
57
- this.handleImage = $(this.options.handleImage) || false;
58
- this.handleDisabled = this.options.handleDisabled || false;
59
- this.handleEnabled = false;
60
- if(this.handleImage)
61
- this.handleEnabled = this.handleImage.src || false;
62
-
63
- if(this.options.disabled)
64
- this.setDisabled();
65
-
66
- // Value Array
67
- this.values = this.options.values || false; // Add method to validate and sort??
73
+ if(this.options.disabled) this.setDisabled();
68
74
 
69
- Element.makePositioned(this.handle); // fix IE
75
+ // Allowed values array
76
+ this.allowedValues = this.options.values ? this.options.values.sortBy(Prototype.K) : false;
77
+ if(this.allowedValues) {
78
+ this.minimum = this.allowedValues.min();
79
+ this.maximum = this.allowedValues.max();
80
+ }
70
81
 
71
82
  this.eventMouseDown = this.startDrag.bindAsEventListener(this);
72
83
  this.eventMouseUp = this.endDrag.bindAsEventListener(this);
73
84
  this.eventMouseMove = this.update.bindAsEventListener(this);
74
- this.eventKeypress = this.keyPress.bindAsEventListener(this);
75
85
 
76
- Event.observe(this.handle, "mousedown", this.eventMouseDown);
86
+ // Initialize handles in reverse (make sure first handle is active)
87
+ this.handles.each( function(h,i) {
88
+ i = slider.handles.length-1-i;
89
+ slider.setValue(parseFloat(
90
+ (slider.options.sliderValue instanceof Array ?
91
+ slider.options.sliderValue[i] : slider.options.sliderValue) ||
92
+ slider.range.start), i);
93
+ Element.makePositioned(h); // fix IE
94
+ Event.observe(h, "mousedown", slider.eventMouseDown);
95
+ });
96
+
97
+ Event.observe(this.track, "mousedown", this.eventMouseDown);
77
98
  Event.observe(document, "mouseup", this.eventMouseUp);
78
99
  Event.observe(document, "mousemove", this.eventMouseMove);
79
- Event.observe(document, "keypress", this.eventKeypress);
100
+
101
+ this.initialized = true;
80
102
  },
81
103
  dispose: function() {
82
- Event.stopObserving(this.handle, "mousedown", this.eventMouseDown);
104
+ var slider = this;
105
+ Event.stopObserving(this.track, "mousedown", this.eventMouseDown);
83
106
  Event.stopObserving(document, "mouseup", this.eventMouseUp);
84
107
  Event.stopObserving(document, "mousemove", this.eventMouseMove);
85
- Event.stopObserving(document, "keypress", this.eventKeypress);
108
+ this.handles.each( function(h) {
109
+ Event.stopObserving(h, "mousedown", slider.eventMouseDown);
110
+ });
86
111
  },
87
112
  setDisabled: function(){
88
113
  this.disabled = true;
89
- if(this.handleDisabled)
90
- this.handleImage.src = this.handleDisabled;
91
114
  },
92
115
  setEnabled: function(){
93
116
  this.disabled = false;
94
- if(this.handleEnabled)
95
- this.handleImage.src = this.handleEnabled;
96
117
  },
97
- currentLeft: function() {
98
- return parseInt(this.handle.style.left || '0');
99
- },
100
- currentTop: function() {
101
- return parseInt(this.handle.style.top || '0');
102
- },
103
- setCurrentLeft: function(left) {
104
- this.handle.style.left = left +"px";
105
- },
106
- setCurrentTop: function(top) {
107
- this.handle.style.top = top +"px";
108
- },
109
- trackLeft: function(){
110
- return Position.cumulativeOffset(this.track)[0];
111
- },
112
- trackTop: function(){
113
- return Position.cumulativeOffset(this.track)[1];
114
- },
115
118
  getNearestValue: function(value){
116
- if(this.values){
117
- var i = 0;
118
- var offset = Math.abs(this.values[0] - value);
119
- var newValue = this.values[0];
120
-
121
- for(i=0; i < this.values.length; i++){
122
- var currentOffset = Math.abs(this.values[i] - value);
123
- if(currentOffset < offset){
124
- newValue = this.values[i];
119
+ if(this.allowedValues){
120
+ if(value >= this.allowedValues.max()) return(this.allowedValues.max());
121
+ if(value <= this.allowedValues.min()) return(this.allowedValues.min());
122
+
123
+ var offset = Math.abs(this.allowedValues[0] - value);
124
+ var newValue = this.allowedValues[0];
125
+ this.allowedValues.each( function(v) {
126
+ var currentOffset = Math.abs(v - value);
127
+ if(currentOffset <= offset){
128
+ newValue = v;
125
129
  offset = currentOffset;
126
- }
127
- }
130
+ }
131
+ });
128
132
  return newValue;
129
133
  }
134
+ if(value > this.range.end) return this.range.end;
135
+ if(value < this.range.start) return this.range.start;
130
136
  return value;
131
137
  },
132
- setSliderValue: function(sliderValue){
133
- // First check our max and minimum and nearest values
134
- sliderValue = this.getNearestValue(sliderValue);
135
- if(sliderValue > this.maximum) sliderValue = this.maximum;
136
- if(sliderValue < this.minimum) sliderValue = this.minimum;
137
- var offsetDiff = (sliderValue - (this.value||this.minimum)) * this.increment;
138
-
139
- if(this.isVertical()){
140
- this.setCurrentTop(offsetDiff + this.currentTop());
141
- } else {
142
- this.setCurrentLeft(offsetDiff + this.currentLeft());
138
+ setValue: function(sliderValue, handleIdx){
139
+ if(!this.active) {
140
+ this.activeHandle = this.handles[handleIdx];
141
+ this.activeHandleIdx = handleIdx;
142
+ this.updateStyles();
143
143
  }
144
- this.value = sliderValue;
145
- this.updateFinished();
146
- },
144
+ handleIdx = handleIdx || this.activeHandleIdx || 0;
145
+ if(this.initialized && this.restricted) {
146
+ if((handleIdx>0) && (sliderValue<this.values[handleIdx-1]))
147
+ sliderValue = this.values[handleIdx-1];
148
+ if((handleIdx < (this.handles.length-1)) && (sliderValue>this.values[handleIdx+1]))
149
+ sliderValue = this.values[handleIdx+1];
150
+ }
151
+ sliderValue = this.getNearestValue(sliderValue);
152
+ this.values[handleIdx] = sliderValue;
153
+ this.value = this.values[0]; // assure backwards compat
154
+
155
+ this.handles[handleIdx].style[this.isVertical() ? 'top' : 'left'] =
156
+ this.translateToPx(sliderValue);
157
+
158
+ this.drawSpans();
159
+ if(!this.dragging || !this.event) this.updateFinished();
160
+ },
161
+ setValueBy: function(delta, handleIdx) {
162
+ this.setValue(this.values[handleIdx || this.activeHandleIdx || 0] + delta,
163
+ handleIdx || this.activeHandleIdx || 0);
164
+ },
165
+ translateToPx: function(value) {
166
+ return Math.round(
167
+ ((this.trackLength-this.handleLength)/(this.range.end-this.range.start)) *
168
+ (value - this.range.start)) + "px";
169
+ },
170
+ translateToValue: function(offset) {
171
+ return ((offset/(this.trackLength-this.handleLength) *
172
+ (this.range.end-this.range.start)) + this.range.start);
173
+ },
174
+ getRange: function(range) {
175
+ var v = this.values.sortBy(Prototype.K);
176
+ range = range || 0;
177
+ return $R(v[range],v[range+1]);
178
+ },
147
179
  minimumOffset: function(){
148
- return(this.isVertical() ?
149
- this.trackTop() + this.alignY :
150
- this.trackLeft() + this.alignX);
180
+ return(this.isVertical() ? this.alignY : this.alignX);
151
181
  },
152
182
  maximumOffset: function(){
153
183
  return(this.isVertical() ?
154
- this.trackTop() + this.alignY + (this.maximum - this.minimum) * this.increment :
155
- this.trackLeft() + this.alignX + (this.maximum - this.minimum) * this.increment);
184
+ this.track.offsetHeight - this.alignY : this.track.offsetWidth - this.alignX);
156
185
  },
157
186
  isVertical: function(){
158
187
  return (this.axis == 'vertical');
159
188
  },
189
+ drawSpans: function() {
190
+ var slider = this;
191
+ if(this.spans)
192
+ $R(0, this.spans.length-1).each(function(r) { slider.setSpan(slider.spans[r], slider.getRange(r)) });
193
+ if(this.options.startSpan)
194
+ this.setSpan(this.options.startSpan,
195
+ $R(0, this.values.length>1 ? this.getRange(0).min() : this.value ));
196
+ if(this.options.endSpan)
197
+ this.setSpan(this.options.endSpan,
198
+ $R(this.values.length>1 ? this.getRange(this.spans.length-1).max() : this.value, this.maximum));
199
+ },
200
+ setSpan: function(span, range) {
201
+ if(this.isVertical()) {
202
+ span.style.top = this.translateToPx(range.start);
203
+ span.style.height = this.translateToPx(range.end - range.start);
204
+ } else {
205
+ span.style.left = this.translateToPx(range.start);
206
+ span.style.width = this.translateToPx(range.end - range.start);
207
+ }
208
+ },
209
+ updateStyles: function() {
210
+ this.handles.each( function(h){ Element.removeClassName(h, 'selected') });
211
+ Element.addClassName(this.activeHandle, 'selected');
212
+ },
160
213
  startDrag: function(event) {
161
214
  if(Event.isLeftClick(event)) {
162
215
  if(!this.disabled){
163
216
  this.active = true;
164
- var pointer = [Event.pointerX(event), Event.pointerY(event)];
165
- var offsets = Position.cumulativeOffset(this.handle);
166
- this.offsetX = (pointer[0] - offsets[0]);
167
- this.offsetY = (pointer[1] - offsets[1]);
168
- this.originalLeft = this.currentLeft();
169
- this.originalTop = this.currentTop();
217
+
218
+ var handle = Event.element(event);
219
+ var pointer = [Event.pointerX(event), Event.pointerY(event)];
220
+ if(handle==this.track) {
221
+ var offsets = Position.cumulativeOffset(this.track);
222
+ this.event = event;
223
+ this.setValue(this.translateToValue(
224
+ (this.isVertical() ? pointer[1]-offsets[1] : pointer[0]-offsets[0])-(this.handleLength/2)
225
+ ));
226
+ var offsets = Position.cumulativeOffset(this.activeHandle);
227
+ this.offsetX = (pointer[0] - offsets[0]);
228
+ this.offsetY = (pointer[1] - offsets[1]);
229
+ } else {
230
+ // find the handle (prevents issues with Safari)
231
+ while((this.handles.indexOf(handle) == -1) && handle.parentNode)
232
+ handle = handle.parentNode;
233
+
234
+ this.activeHandle = handle;
235
+ this.activeHandleIdx = this.handles.indexOf(this.activeHandle);
236
+ this.updateStyles();
237
+
238
+ var offsets = Position.cumulativeOffset(this.activeHandle);
239
+ this.offsetX = (pointer[0] - offsets[0]);
240
+ this.offsetY = (pointer[1] - offsets[1]);
241
+ }
170
242
  }
171
243
  Event.stop(event);
172
244
  }
173
245
  },
174
246
  update: function(event) {
175
247
  if(this.active) {
176
- if(!this.dragging) {
177
- var style = this.handle.style;
178
- this.dragging = true;
179
- if(style.position=="") style.position = "relative";
180
- style.zIndex = this.options.zindex;
181
- }
248
+ if(!this.dragging) this.dragging = true;
182
249
  this.draw(event);
183
250
  // fix AppleWebKit rendering
184
251
  if(navigator.appVersion.indexOf('AppleWebKit')>0) window.scrollBy(0,0);
@@ -187,43 +254,13 @@ Control.Slider.prototype = {
187
254
  },
188
255
  draw: function(event) {
189
256
  var pointer = [Event.pointerX(event), Event.pointerY(event)];
190
- var offsets = Position.cumulativeOffset(this.handle);
191
-
192
- offsets[0] -= this.currentLeft();
193
- offsets[1] -= this.currentTop();
194
-
195
- // Adjust for the pointer's position on the handle
196
- pointer[0] -= this.offsetX;
197
- pointer[1] -= this.offsetY;
198
- var style = this.handle.style;
199
-
200
- if(this.isVertical()){
201
- if(pointer[1] > this.maximumOffset())
202
- pointer[1] = this.maximumOffset();
203
- if(pointer[1] < this.minimumOffset())
204
- pointer[1] = this.minimumOffset();
205
-
206
- // Increment by values
207
- if(this.values){
208
- this.value = this.getNearestValue(Math.round((pointer[1] - this.minimumOffset()) / this.increment) + this.minimum);
209
- pointer[1] = this.trackTop() + this.alignY + (this.value - this.minimum) * this.increment;
210
- } else {
211
- this.value = Math.round((pointer[1] - this.minimumOffset()) / this.increment) + this.minimum;
212
- }
213
- style.top = pointer[1] - offsets[1] + "px";
214
- } else {
215
- if(pointer[0] > this.maximumOffset()) pointer[0] = this.maximumOffset();
216
- if(pointer[0] < this.minimumOffset()) pointer[0] = this.minimumOffset();
217
- // Increment by values
218
- if(this.values){
219
- this.value = this.getNearestValue(Math.round((pointer[0] - this.minimumOffset()) / this.increment) + this.minimum);
220
- pointer[0] = this.trackLeft() + this.alignX + (this.value - this.minimum) * this.increment;
221
- } else {
222
- this.value = Math.round((pointer[0] - this.minimumOffset()) / this.increment) + this.minimum;
223
- }
224
- style.left = (pointer[0] - offsets[0]) + "px";
225
- }
226
- if(this.options.onSlide) this.options.onSlide(this.value);
257
+ var offsets = Position.cumulativeOffset(this.track);
258
+ pointer[0] -= this.offsetX + offsets[0];
259
+ pointer[1] -= this.offsetY + offsets[1];
260
+ this.event = event;
261
+ this.setValue(this.translateToValue( this.isVertical() ? pointer[1] : pointer[0] ));
262
+ if(this.initialized && this.options.onSlide)
263
+ this.options.onSlide(this.values.length>1 ? this.values : this.value, this);
227
264
  },
228
265
  endDrag: function(event) {
229
266
  if(this.active && this.dragging) {
@@ -236,23 +273,11 @@ Control.Slider.prototype = {
236
273
  finishDrag: function(event, success) {
237
274
  this.active = false;
238
275
  this.dragging = false;
239
- this.handle.style.zIndex = this.originalZ;
240
- this.originalLeft = this.currentLeft();
241
- this.originalTop = this.currentTop();
242
276
  this.updateFinished();
243
277
  },
244
278
  updateFinished: function() {
245
- if(this.options.onChange) this.options.onChange(this.value);
246
- },
247
- keyPress: function(event) {
248
- if(this.active && !this.disabled) {
249
- switch(event.keyCode) {
250
- case Event.KEY_ESC:
251
- this.finishDrag(event, false);
252
- Event.stop(event);
253
- break;
254
- }
255
- if(navigator.appVersion.indexOf('AppleWebKit')>0) Event.stop(event);
256
- }
279
+ if(this.initialized && this.options.onChange)
280
+ this.options.onChange(this.values.length>1 ? this.values : this.value, this);
281
+ this.event = null;
257
282
  }
258
- }
283
+ }
@@ -1,17 +1,36 @@
1
1
  # Read about fixtures at http://ar.rubyonrails.org/classes/Fixtures.html
2
2
  first_elts:
3
3
  id: ROOT
4
+ lft: 1
5
+ rgt: 10
6
+ elts_count: 3
4
7
  second_elts:
5
8
  id: 0
6
9
  parent_id: ROOT
7
10
  subject: zeroth element
8
11
  body: zeroeth element
12
+ lft: 2
13
+ rgt: 3
14
+ elts_count: 0
9
15
  another_elts:
10
16
  id: 1
11
17
  parent_id: ROOT
12
18
  subject: Another element
19
+ lft: 4
20
+ rgt: 5
21
+ elts_count: 0
13
22
  mail:
14
23
  id: mail
15
24
  parent_id: ROOT
16
25
  subject: Mails
17
26
  body: The different mailing lists managed on this server
27
+ lft: 6
28
+ rgt: 9
29
+ elts_count: 0
30
+ mailList:
31
+ id: mailList
32
+ parent_id: mail
33
+ subject: Mail list
34
+ body: One mailing lists managed on this server
35
+ lft: 7
36
+ rgt: 8
@@ -19,6 +19,7 @@ To: mailingList@leparlement.org
19
19
  Subject: test parlement
20
20
  Date: Fri, 20 Jan 2006 18:11:00 -0000
21
21
  Content-Type: text/plain; charset="utf-8"
22
+ Content-Transfer-Encoding: quoted-printable
22
23
  Message-Id: <E1F02OK-0002EG-DN@vvv>
23
24
  Status: RO
24
25
  Content-Length: 1007
@@ -33,3 +34,6 @@ Et ici de faux votes qui ne devraient pas être pris en compte:
33
34
  1
34
35
  + 1
35
36
 
37
+ Due to quoted-printable transformation, it breaks over that bit (note,
38
+ this is a null character):
39
+ + =00 +
@@ -14,7 +14,7 @@ Received: from manu by vvv with local (Exim 4.60)
14
14
  (envelope-from <manu@leparlement.org>)
15
15
  id 1F02OK-0002EG-DN
16
16
  for manu@localhost; Fri, 20 Jan 2006 20:57:48 +0100
17
- From: echarp <manu@leparlement.org>
17
+ From: echarp2 <manu2@leparlement.org>
18
18
  To: mailingList@leparlement.org
19
19
  Subject: test threaded parlement reply
20
20
  Date: Fri, 20 Jan 2006 18:11:00 -0000
@@ -14,7 +14,7 @@ Received: from manu by vvv with local (Exim 4.60)
14
14
  (envelope-from <manu@leparlement.org>)
15
15
  id 1F02OK-0002EG-DN
16
16
  for manu@localhost; Fri, 20 Jan 2006 20:57:48 +0100
17
- From: echarp <manu@leparlement.org>
17
+ From: echarp3 <manu3@leparlement.org>
18
18
  To: mailingList@leparlement.org
19
19
  Subject: test threaded parlement reply
20
20
  Date: Fri, 20 Jan 2006 18:11:00 -0000
@@ -19,6 +19,8 @@ class AccountControllerTest < Test::Unit::TestCase
19
19
  @controller = AccountController.new
20
20
  @request, @response = ActionController::TestRequest.new, ActionController::TestResponse.new
21
21
  @request.host = "localhost"
22
+
23
+ @elt = Elt.find '1'
22
24
  end
23
25
 
24
26
 
@@ -237,5 +239,27 @@ class AccountControllerTest < Test::Unit::TestCase
237
239
  assert_not_nil session[:user]
238
240
  get :logout
239
241
  end
242
+
243
+ def test_update_subscribe
244
+ post :login, :person => { :name => "bob_other", :email => "" },
245
+ :user => { :password => "" }, :divId => 'author_ROOT'
246
+
247
+ controller = @controller
248
+ @controller = EltController.new
249
+ post :create, :id => @elt.id, :commit => "Propose!",
250
+ :elt =>{
251
+ :body => "+1", :subject => "test_create", :parent_id => @elt.id }
252
+ @controller = controller
253
+ get :logout
254
+
255
+ post :login, :person => { :name => "bob_other", :email => "" },
256
+ :user => { :password => "" }, :divId => 'author_1'
257
+
258
+ assert_success
259
+ assert_not_nil session[:person]
260
+ assert_template 'account/_show'
261
+
262
+ assert_tag :tag => "div", :attributes => { :class => "choicesToUpdate" }
263
+ end
240
264
  end
241
265