Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Automatically Removed Whitespace #1

Open
wants to merge 1 commit into from

0 participants

Gun.io Robot

Hi there!

This is WhitespaceBot. I'm an open-source robot that removes trailing white space in your code.

Why whitespace? Whitespace is an eyesore for developers who use text editors with dark themes. It's not a huge deal, but it's a bit annoying if you use Vim in a terminal. Really, I'm just a proof of concept - GitHub's V3 API allows robots to automatically improve open source projects, and that's really cool. Hopefully, somebody, maybe you!, will fork me and make me even more useful.

I've only cleaned your most popular project, and I've added you to a list of users not to contact again, so you won't get any more pull requests from me unless you ask. If I'm misbehaving, please email my owner and tell him to turn me off! If this is pull request is of no use to you, please just ignore it.

Thanks!
WhitespaceBot.

Gun.io Whitespace Robot Remove whitespace [WhitespaceBot] 4545e92
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Showing 1 unique commit by 1 author.

Jan 31, 2012
Gun.io Whitespace Robot Remove whitespace [WhitespaceBot] 4545e92
This page is out of date. Refresh to see the latest.
6 app/controllers/application.rb
@@ -7,10 +7,10 @@ class ApplicationController < ActionController::Base
7 7 # See ActionController::RequestForgeryProtection for details
8 8 # Uncomment the :secret if you're not using the cookie session store
9 9 protect_from_forgery # :secret => '335355b4e3b87c6b8ae7a9a94c1893dc'
10   -
11   - # See ActionController::Base for details
  10 +
  11 + # See ActionController::Base for details
12 12 # Uncomment this to filter the contents of submitted sensitive data parameters
13   - # from your application log (in this case, all fields with names like "password").
  13 + # from your application log (in this case, all fields with names like "password").
14 14 # filter_parameter_logging :password
15 15
16 16 include ExceptionNotifiable
6 config/environment.rb
@@ -20,13 +20,13 @@
20 20 # you must remove the Active Record framework.
21 21 # config.frameworks -= [ :active_record, :active_resource, :action_mailer ]
22 22
23   - # Specify gems that this application depends on.
  23 + # Specify gems that this application depends on.
24 24 # They can then be installed with "rake gems:install" on new installations.
25 25 # config.gem "bj"
26 26 # config.gem "hpricot", :version => '0.6', :source => "http://code.whytheluckystiff.net"
27 27 # config.gem "aws-s3", :lib => "aws/s3"
28 28
29   - # Only load the plugins named here, in the order given. By default, all plugins
  29 + # Only load the plugins named here, in the order given. By default, all plugins
30 30 # in vendor/plugins are loaded in alphabetical order.
31 31 # :all can be used as a placeholder for all plugins not explicitly named
32 32 # config.plugins = [ :exception_notification, :ssl_requirement, :all ]
@@ -45,7 +45,7 @@
45 45
46 46 # Your secret key for verifying cookie session data integrity.
47 47 # If you change this key, all old sessions will become invalid!
48   - # Make sure the secret is at least 30 characters and all random,
  48 + # Make sure the secret is at least 30 characters and all random,
49 49 # no regular words or you'll be exposed to dictionary attacks.
50 50 config.action_controller.session = {
51 51 :session_key => '_baseapp_session',
2  config/initializers/inflections.rb
... ... @@ -1,6 +1,6 @@
1 1 # Be sure to restart your server when you modify this file.
2 2
3   -# Add new inflection rules using the following format
  3 +# Add new inflection rules using the following format
4 4 # (all these examples are active by default):
5 5 # ActiveSupport::Inflector.inflections do |inflect|
6 6 # inflect.plural /^(ox)$/i, '\1en'
2  config/routes.rb
@@ -17,7 +17,7 @@
17 17
18 18 # Sample resource route with sub-resources:
19 19 # map.resources :products, :has_many => [ :comments, :sales ], :has_one => :seller
20   -
  20 +
21 21 # Sample resource route with more complex sub-resources
22 22 # map.resources :products do |products|
23 23 # products.resources :comments
2  lib/tasks/diagrams.rake
... ... @@ -1,6 +1,6 @@
1 1 # Rake task tomada de la página de Railroad (http://railroad.rubyforge.org/)
2 2 # Gracias a Thomas Ritz por el código (http://www.galaxy-ritz.de/)
3   -# Modificada por Amaia Castro (amaia@dabne.net) para incluir la generación de
  3 +# Modificada por Amaia Castro (amaia@dabne.net) para incluir la generación de
4 4 # diagramas en png.
5 5
6 6 namespace :doc do
54 public/index.html
@@ -14,20 +14,20 @@
14 14 font-size: 13px;
15 15 color: #333;
16 16 }
17   -
  17 +
18 18 h1 {
19 19 font-size: 28px;
20 20 color: #000;
21 21 }
22   -
  22 +
23 23 a {color: #03c}
24 24 a:hover {
25 25 background-color: #03c;
26 26 color: white;
27 27 text-decoration: none;
28 28 }
29   -
30   -
  29 +
  30 +
31 31 #page {
32 32 background-color: #f0f0f0;
33 33 width: 750px;
@@ -35,7 +35,7 @@
35 35 margin-left: auto;
36 36 margin-right: auto;
37 37 }
38   -
  38 +
39 39 #content {
40 40 float: left;
41 41 background-color: white;
@@ -44,7 +44,7 @@
44 44 padding: 25px;
45 45 width: 500px;
46 46 }
47   -
  47 +
48 48 #sidebar {
49 49 float: right;
50 50 width: 175px;
@@ -53,7 +53,7 @@
53 53 #footer {
54 54 clear: both;
55 55 }
56   -
  56 +
57 57
58 58 #header, #about, #getting-started {
59 59 padding-left: 75px;
@@ -73,14 +73,14 @@
73 73 font-weight: normal;
74 74 font-size: 16px;
75 75 }
76   -
77   -
  76 +
  77 +
78 78 #about h3 {
79 79 margin: 0;
80 80 margin-bottom: 10px;
81 81 font-size: 14px;
82 82 }
83   -
  83 +
84 84 #about-content {
85 85 background-color: #ffd;
86 86 border: 1px solid #fc0;
@@ -99,7 +99,7 @@
99 99 }
100 100 #about-content td.name {color: #555}
101 101 #about-content td.value {color: #000}
102   -
  102 +
103 103 #about-content.failure {
104 104 background-color: #fcc;
105 105 border: 1px solid #f00;
@@ -108,8 +108,8 @@
108 108 margin: 0;
109 109 padding: 10px;
110 110 }
111   -
112   -
  111 +
  112 +
113 113 #getting-started {
114 114 border-top: 1px solid #ccc;
115 115 margin-top: 25px;
@@ -145,8 +145,8 @@
145 145 color: #555;
146 146 font-size: 13px;
147 147 }
148   -
149   -
  148 +
  149 +
150 150 #search {
151 151 margin: 0;
152 152 padding-top: 10px;
@@ -158,8 +158,8 @@
158 158 margin: 2px;
159 159 }
160 160 #search-text {width: 170px}
161   -
162   -
  161 +
  162 +
163 163 #sidebar ul {
164 164 margin-left: 0;
165 165 padding-left: 0;
@@ -176,7 +176,7 @@
176 176 #sidebar ul.links li {
177 177 margin-bottom: 5px;
178 178 }
179   -
  179 +
180 180 </style>
181 181 <script type="text/javascript" src="javascripts/prototype.js"></script>
182 182 <script type="text/javascript" src="javascripts/effects.js"></script>
@@ -189,11 +189,11 @@
189 189 onComplete: function() {new Effect.BlindDown('about-content', {duration: 0.25})}
190 190 });
191 191 } else {
192   - new Effect[Element.visible('about-content') ?
  192 + new Effect[Element.visible('about-content') ?
193 193 'BlindUp' : 'BlindDown']('about-content', {duration: 0.25});
194 194 }
195 195 }
196   -
  196 +
197 197 window.onload = function() {
198 198 $('search-text').value = '';
199 199 $('search').onsubmit = function() {
@@ -213,7 +213,7 @@
213 213 <input type="submit" value="Search" /> the Rails site
214 214 </form>
215 215 </li>
216   -
  216 +
217 217 <li>
218 218 <h3>Join the community</h3>
219 219 <ul class="links">
@@ -222,7 +222,7 @@
222 222 <li><a href="http://wiki.rubyonrails.org/">Wiki</a></li>
223 223 </ul>
224 224 </li>
225   -
  225 +
226 226 <li>
227 227 <h3>Browse the documentation</h3>
228 228 <ul class="links">
@@ -244,17 +244,17 @@
244 244 <h3><a href="rails/info/properties" onclick="about(); return false">About your application&rsquo;s environment</a></h3>
245 245 <div id="about-content" style="display: none"></div>
246 246 </div>
247   -
  247 +
248 248 <div id="getting-started">
249 249 <h1>Getting started</h1>
250 250 <h2>Here&rsquo;s how to get rolling:</h2>
251   -
252   - <ol>
  251 +
  252 + <ol>
253 253 <li>
254 254 <h2>Use <tt>script/generate</tt> to create your models and controllers</h2>
255 255 <p>To see all available options, run it without parameters.</p>
256 256 </li>
257   -
  257 +
258 258 <li>
259 259 <h2>Set up a default route and remove or rename this file</h2>
260 260 <p>Routes are set up in config/routes.rb.</p>
@@ -267,7 +267,7 @@
267 267 </ol>
268 268 </div>
269 269 </div>
270   -
  270 +
271 271 <div id="footer">&nbsp;</div>
272 272 </div>
273 273 </body>
122 public/javascripts/controls.js
@@ -5,18 +5,18 @@
5 5 // Richard Livsey
6 6 // Rahul Bhargava
7 7 // Rob Wills
8   -//
  8 +//
9 9 // script.aculo.us is freely distributable under the terms of an MIT-style license.
10 10 // For details, see the script.aculo.us web site: http://script.aculo.us/
11 11
12   -// Autocompleter.Base handles all the autocompletion functionality
  12 +// Autocompleter.Base handles all the autocompletion functionality
13 13 // that's independent of the data source for autocompletion. This
14 14 // includes drawing the autocompletion menu, observing keyboard
15 15 // and mouse events, and similar.
16 16 //
17   -// Specific autocompleters need to provide, at the very least,
  17 +// Specific autocompleters need to provide, at the very least,
18 18 // a getUpdatedChoices function that will be invoked every time
19   -// the text inside the monitored textbox changes. This method
  19 +// the text inside the monitored textbox changes. This method
20 20 // should get the text for which to provide autocompletion by
21 21 // invoking this.getToken(), NOT by directly accessing
22 22 // this.element.value. This is to allow incremental tokenized
@@ -30,8 +30,8 @@
30 30 // will incrementally autocomplete with a comma as the token.
31 31 // Additionally, ',' in the above example can be replaced with
32 32 // a token array, e.g. { tokens: [',', '\n'] } which
33   -// enables autocompletion on multiple tokens. This is most
34   -// useful when one of the tokens is \n (a newline), as it
  33 +// enables autocompletion on multiple tokens. This is most
  34 +// useful when one of the tokens is \n (a newline), as it
35 35 // allows smart autocompletion after linebreaks.
36 36
37 37 if(typeof Effect == 'undefined')
@@ -41,12 +41,12 @@ var Autocompleter = { }
41 41 Autocompleter.Base = Class.create({
42 42 baseInitialize: function(element, update, options) {
43 43 element = $(element)
44   - this.element = element;
45   - this.update = $(update);
46   - this.hasFocus = false;
47   - this.changed = false;
48   - this.active = false;
49   - this.index = 0;
  44 + this.element = element;
  45 + this.update = $(update);
  46 + this.hasFocus = false;
  47 + this.changed = false;
  48 + this.active = false;
  49 + this.index = 0;
50 50 this.entryCount = 0;
51 51 this.oldElementValue = this.element.value;
52 52
@@ -59,28 +59,28 @@ Autocompleter.Base = Class.create({
59 59 this.options.tokens = this.options.tokens || [];
60 60 this.options.frequency = this.options.frequency || 0.4;
61 61 this.options.minChars = this.options.minChars || 1;
62   - this.options.onShow = this.options.onShow ||
63   - function(element, update){
  62 + this.options.onShow = this.options.onShow ||
  63 + function(element, update){
64 64 if(!update.style.position || update.style.position=='absolute') {
65 65 update.style.position = 'absolute';
66 66 Position.clone(element, update, {
67   - setHeight: false,
  67 + setHeight: false,
68 68 offsetTop: element.offsetHeight
69 69 });
70 70 }
71 71 Effect.Appear(update,{duration:0.15});
72 72 };
73   - this.options.onHide = this.options.onHide ||
  73 + this.options.onHide = this.options.onHide ||
74 74 function(element, update){ new Effect.Fade(update,{duration:0.15}) };
75 75
76   - if(typeof(this.options.tokens) == 'string')
  76 + if(typeof(this.options.tokens) == 'string')
77 77 this.options.tokens = new Array(this.options.tokens);
78 78 // Force carriage returns as token delimiters anyway
79 79 if (!this.options.tokens.include('\n'))
80 80 this.options.tokens.push('\n');
81 81
82 82 this.observer = null;
83   -
  83 +
84 84 this.element.setAttribute('autocomplete','off');
85 85
86 86 Element.hide(this.update);
@@ -91,10 +91,10 @@ Autocompleter.Base = Class.create({
91 91
92 92 show: function() {
93 93 if(Element.getStyle(this.update, 'display')=='none') this.options.onShow(this.element, this.update);
94   - if(!this.iefix &&
  94 + if(!this.iefix &&
95 95 (Prototype.Browser.IE) &&
96 96 (Element.getStyle(this.update, 'position')=='absolute')) {
97   - new Insertion.After(this.update,
  97 + new Insertion.After(this.update,
98 98 '<iframe id="' + this.update.id + '_iefix" '+
99 99 'style="display:none;position:absolute;filter:progid:DXImageTransform.Microsoft.Alpha(opacity=0);" ' +
100 100 'src="javascript:false;" frameborder="0" scrolling="no"></iframe>');
@@ -102,7 +102,7 @@ Autocompleter.Base = Class.create({
102 102 }
103 103 if(this.iefix) setTimeout(this.fixIEOverlapping.bind(this), 50);
104 104 },
105   -
  105 +
106 106 fixIEOverlapping: function() {
107 107 Position.clone(this.update, this.iefix, {setTop:(!this.update.style.height)});
108 108 this.iefix.style.zIndex = 1;
@@ -150,15 +150,15 @@ Autocompleter.Base = Class.create({
150 150 Event.stop(event);
151 151 return;
152 152 }
153   - else
154   - if(event.keyCode==Event.KEY_TAB || event.keyCode==Event.KEY_RETURN ||
  153 + else
  154 + if(event.keyCode==Event.KEY_TAB || event.keyCode==Event.KEY_RETURN ||
155 155 (Prototype.Browser.WebKit > 0 && event.keyCode == 0)) return;
156 156
157 157 this.changed = true;
158 158 this.hasFocus = true;
159 159
160 160 if(this.observer) clearTimeout(this.observer);
161   - this.observer =
  161 + this.observer =
162 162 setTimeout(this.onObserverEvent.bind(this), this.options.frequency*1000);
163 163 },
164 164
@@ -170,35 +170,35 @@ Autocompleter.Base = Class.create({
170 170
171 171 onHover: function(event) {
172 172 var element = Event.findElement(event, 'LI');
173   - if(this.index != element.autocompleteIndex)
  173 + if(this.index != element.autocompleteIndex)
174 174 {
175 175 this.index = element.autocompleteIndex;
176 176 this.render();
177 177 }
178 178 Event.stop(event);
179 179 },
180   -
  180 +
181 181 onClick: function(event) {
182 182 var element = Event.findElement(event, 'LI');
183 183 this.index = element.autocompleteIndex;
184 184 this.selectEntry();
185 185 this.hide();
186 186 },
187   -
  187 +
188 188 onBlur: function(event) {
189 189 // needed to make click events working
190 190 setTimeout(this.hide.bind(this), 250);
191 191 this.hasFocus = false;
192   - this.active = false;
193   - },
194   -
  192 + this.active = false;
  193 + },
  194 +
195 195 render: function() {
196 196 if(this.entryCount > 0) {
197 197 for (var i = 0; i < this.entryCount; i++)
198   - this.index==i ?
199   - Element.addClassName(this.getEntry(i),"selected") :
  198 + this.index==i ?
  199 + Element.addClassName(this.getEntry(i),"selected") :
200 200 Element.removeClassName(this.getEntry(i),"selected");
201   - if(this.hasFocus) {
  201 + if(this.hasFocus) {
202 202 this.show();
203 203 this.active = true;
204 204 }
@@ -207,27 +207,27 @@ Autocompleter.Base = Class.create({
207 207 this.hide();
208 208 }
209 209 },
210   -
  210 +
211 211 markPrevious: function() {
212 212 if(this.index > 0) this.index--
213 213 else this.index = this.entryCount-1;
214 214 this.getEntry(this.index).scrollIntoView(true);
215 215 },
216   -
  216 +
217 217 markNext: function() {
218 218 if(this.index < this.entryCount-1) this.index++
219 219 else this.index = 0;
220 220 this.getEntry(this.index).scrollIntoView(false);
221 221 },
222   -
  222 +
223 223 getEntry: function(index) {
224 224 return this.update.firstChild.childNodes[index];
225 225 },
226   -
  226 +
227 227 getCurrentEntry: function() {
228 228 return this.getEntry(this.index);
229 229 },
230   -
  230 +
231 231 selectEntry: function() {
232 232 this.active = false;
233 233 this.updateElement(this.getCurrentEntry());
@@ -244,7 +244,7 @@ Autocompleter.Base = Class.create({
244 244 if(nodes.length>0) value = Element.collectTextNodes(nodes[0], this.options.select);
245 245 } else
246 246 value = Element.collectTextNodesIgnoreClass(selectedElement, 'informal');
247   -
  247 +
248 248 var bounds = this.getTokenBounds();
249 249 if (bounds[0] != -1) {
250 250 var newValue = this.element.value.substr(0, bounds[0]);
@@ -257,7 +257,7 @@ Autocompleter.Base = Class.create({
257 257 }
258 258 this.oldElementValue = this.element.value;
259 259 this.element.focus();
260   -
  260 +
261 261 if (this.options.afterUpdateElement)
262 262 this.options.afterUpdateElement(this.element, selectedElement);
263 263 },
@@ -269,20 +269,20 @@ Autocompleter.Base = Class.create({
269 269 Element.cleanWhitespace(this.update.down());
270 270
271 271 if(this.update.firstChild && this.update.down().childNodes) {
272   - this.entryCount =
  272 + this.entryCount =
273 273 this.update.down().childNodes.length;
274 274 for (var i = 0; i < this.entryCount; i++) {
275 275 var entry = this.getEntry(i);
276 276 entry.autocompleteIndex = i;
277 277 this.addObservers(entry);
278 278 }
279   - } else {
  279 + } else {
280 280 this.entryCount = 0;
281 281 }
282 282
283 283 this.stopIndicator();
284 284 this.index = 0;
285   -
  285 +
286 286 if(this.entryCount==1 && this.options.autoSelect) {
287 287 this.selectEntry();
288 288 this.hide();
@@ -298,7 +298,7 @@ Autocompleter.Base = Class.create({
298 298 },
299 299
300 300 onObserverEvent: function() {
301   - this.changed = false;
  301 + this.changed = false;
302 302 this.tokenBounds = null;
303 303 if(this.getToken().length>=this.options.minChars) {
304 304 this.getUpdatedChoices();
@@ -351,16 +351,16 @@ Ajax.Autocompleter = Class.create(Autocompleter.Base, {
351 351
352 352 getUpdatedChoices: function() {
353 353 this.startIndicator();
354   -
355   - var entry = encodeURIComponent(this.options.paramName) + '=' +
  354 +
  355 + var entry = encodeURIComponent(this.options.paramName) + '=' +
356 356 encodeURIComponent(this.getToken());
357 357
358 358 this.options.parameters = this.options.callback ?
359 359 this.options.callback(this.element, entry) : entry;
360 360
361   - if(this.options.defaultParams)
  361 + if(this.options.defaultParams)
362 362 this.options.parameters += '&' + this.options.defaultParams;
363   -
  363 +
364 364 new Ajax.Request(this.url, this.options);
365 365 },
366 366
@@ -382,7 +382,7 @@ Ajax.Autocompleter = Class.create(Autocompleter.Base, {
382 382 // - choices - How many autocompletion choices to offer
383 383 //
384 384 // - partialSearch - If false, the autocompleter will match entered
385   -// text only at the beginning of strings in the
  385 +// text only at the beginning of strings in the
386 386 // autocomplete array. Defaults to true, which will
387 387 // match text at the beginning of any *word* in the
388 388 // strings in the autocomplete array. If you want to
@@ -399,7 +399,7 @@ Ajax.Autocompleter = Class.create(Autocompleter.Base, {
399 399 // - ignoreCase - Whether to ignore case when autocompleting.
400 400 // Defaults to true.
401 401 //
402   -// It's possible to pass in a custom function as the 'selector'
  402 +// It's possible to pass in a custom function as the 'selector'
403 403 // option, if you prefer to write your own autocompletion logic.
404 404 // In that case, the other options above will not apply unless
405 405 // you support them.
@@ -427,20 +427,20 @@ Autocompleter.Local = Class.create(Autocompleter.Base, {
427 427 var entry = instance.getToken();
428 428 var count = 0;
429 429
430   - for (var i = 0; i < instance.options.array.length &&
431   - ret.length < instance.options.choices ; i++) {
  430 + for (var i = 0; i < instance.options.array.length &&
  431 + ret.length < instance.options.choices ; i++) {
432 432
433 433 var elem = instance.options.array[i];
434   - var foundPos = instance.options.ignoreCase ?
435   - elem.toLowerCase().indexOf(entry.toLowerCase()) :
  434 + var foundPos = instance.options.ignoreCase ?
  435 + elem.toLowerCase().indexOf(entry.toLowerCase()) :
436 436 elem.indexOf(entry);
437 437
438 438 while (foundPos != -1) {
439   - if (foundPos == 0 && elem.length != entry.length) {
440   - ret.push("<li><strong>" + elem.substr(0, entry.length) + "</strong>" +
  439 + if (foundPos == 0 && elem.length != entry.length) {
  440 + ret.push("<li><strong>" + elem.substr(0, entry.length) + "</strong>" +
441 441 elem.substr(entry.length) + "</li>");
442 442 break;
443   - } else if (entry.length >= instance.options.partialChars &&
  443 + } else if (entry.length >= instance.options.partialChars &&
444 444 instance.options.partialSearch && foundPos != -1) {
445 445 if (instance.options.fullSearch || /\s/.test(elem.substr(foundPos-1,1))) {
446 446 partial.push("<li>" + elem.substr(0, foundPos) + "<strong>" +
@@ -450,8 +450,8 @@ Autocompleter.Local = Class.create(Autocompleter.Base, {
450 450 }
451 451 }
452 452
453   - foundPos = instance.options.ignoreCase ?
454   - elem.toLowerCase().indexOf(entry.toLowerCase(), foundPos + 1) :
  453 + foundPos = instance.options.ignoreCase ?
  454 + elem.toLowerCase().indexOf(entry.toLowerCase(), foundPos + 1) :
455 455 elem.indexOf(entry, foundPos + 1);
456 456
457 457 }
@@ -937,7 +937,7 @@ Ajax.InPlaceCollectionEditor.DefaultOptions = {
937 937 loadingCollectionText: 'Loading options...'
938 938 };
939 939
940   -// Delayed observer, like Form.Element.Observer,
  940 +// Delayed observer, like Form.Element.Observer,
941 941 // but waits for delay after last key input
942 942 // Ideal for live-search fields
943 943
@@ -947,7 +947,7 @@ Form.Element.DelayedObserver = Class.create({
947 947 this.element = $(element);
948 948 this.callback = callback;
949 949 this.timer = null;
950   - this.lastValue = $F(this.element);
  950 + this.lastValue = $F(this.element);
951 951 Event.observe(this.element,'keyup',this.delayedListener.bindAsEventListener(this));
952 952 },
953 953 delayedListener: function(event) {
288 public/javascripts/dragdrop.js
... ... @@ -1,6 +1,6 @@
1 1 // Copyright (c) 2005-2008 Thomas Fuchs (http://script.aculo.us, http://mir.aculo.us)
2 2 // (c) 2005-2007 Sammi Williams (http://www.oriontransfer.co.nz, sammi@oriontransfer.co.nz)
3   -//
  3 +//
4 4 // script.aculo.us is freely distributable under the terms of an MIT-style license.
5 5 // For details, see the script.aculo.us web site: http://script.aculo.us/
6 6
@@ -32,7 +32,7 @@ var Droppables = {
32 32 options._containers.push($(containment));
33 33 }
34 34 }
35   -
  35 +
36 36 if(options.accept) options.accept = [options.accept].flatten();
37 37
38 38 Element.makePositioned(element); // fix IE
@@ -40,34 +40,34 @@ var Droppables = {
40 40
41 41 this.drops.push(options);
42 42 },
43   -
  43 +
44 44 findDeepestChild: function(drops) {
45 45 deepest = drops[0];
46   -
  46 +
47 47 for (i = 1; i < drops.length; ++i)
48 48 if (Element.isParent(drops[i].element, deepest.element))
49 49 deepest = drops[i];
50   -
  50 +
51 51 return deepest;
52 52 },
53 53
54 54 isContained: function(element, drop) {
55 55 var containmentNode;
56 56 if(drop.tree) {
57   - containmentNode = element.treeNode;
  57 + containmentNode = element.treeNode;
58 58 } else {
59 59 containmentNode = element.parentNode;
60 60 }
61 61 return drop._containers.detect(function(c) { return containmentNode == c });
62 62 },
63   -
  63 +
64 64 isAffected: function(point, element, drop) {
65 65 return (
66 66 (drop.element!=element) &&
67 67 ((!drop._containers) ||
68 68 this.isContained(element, drop)) &&
69 69 ((!drop.accept) ||
70   - (Element.classNames(element).detect(
  70 + (Element.classNames(element).detect(
71 71 function(v) { return drop.accept.include(v) } ) )) &&
72 72 Position.within(drop.element, point[0], point[1]) );
73 73 },
@@ -87,12 +87,12 @@ var Droppables = {
87 87 show: function(point, element) {
88 88 if(!this.drops.length) return;
89 89 var drop, affected = [];
90   -
  90 +
91 91 this.drops.each( function(drop) {
92 92 if(Droppables.isAffected(point, element, drop))
93 93 affected.push(drop);
94 94 });
95   -
  95 +
96 96 if(affected.length>0)
97 97 drop = Droppables.findDeepestChild(affected);
98 98
@@ -101,7 +101,7 @@ var Droppables = {
101 101 Position.within(drop.element, point[0], point[1]);
102 102 if(drop.onHover)
103 103 drop.onHover(element, drop.element, Position.overlap(drop.overlap, drop.element));
104   -
  104 +
105 105 if (drop != this.last_active) Droppables.activate(drop);
106 106 }
107 107 },
@@ -112,8 +112,8 @@ var Droppables = {
112 112
113 113 if (this.isAffected([Event.pointerX(event), Event.pointerY(event)], element, this.last_active))
114 114 if (this.last_active.onDrop) {
115   - this.last_active.onDrop(element, this.last_active.element, event);
116   - return true;
  115 + this.last_active.onDrop(element, this.last_active.element, event);
  116 + return true;
117 117 }
118 118 },
119 119
@@ -126,20 +126,20 @@ var Droppables = {
126 126 var Draggables = {
127 127 drags: [],
128 128 observers: [],
129   -
  129 +
130 130 register: function(draggable) {
131 131 if(this.drags.length == 0) {
132 132 this.eventMouseUp = this.endDrag.bindAsEventListener(this);
133 133 this.eventMouseMove = this.updateDrag.bindAsEventListener(this);
134 134 this.eventKeypress = this.keyPress.bindAsEventListener(this);
135   -
  135 +
136 136 Event.observe(document, "mouseup", this.eventMouseUp);
137 137 Event.observe(document, "mousemove", this.eventMouseMove);
138 138 Event.observe(document, "keypress", this.eventKeypress);
139 139 }
140 140 this.drags.push(draggable);
141 141 },
142   -
  142 +
143 143 unregister: function(draggable) {
144 144 this.drags = this.drags.reject(function(d) { return d==draggable });
145 145 if(this.drags.length == 0) {
@@ -148,24 +148,24 @@ var Draggables = {
148 148 Event.stopObserving(document, "keypress", this.eventKeypress);
149 149 }
150 150 },
151   -
  151 +
152 152 activate: function(draggable) {
153   - if(draggable.options.delay) {
154   - this._timeout = setTimeout(function() {
155   - Draggables._timeout = null;
156   - window.focus();
157   - Draggables.activeDraggable = draggable;
158   - }.bind(this), draggable.options.delay);
  153 + if(draggable.options.delay) {
  154 + this._timeout = setTimeout(function() {
  155 + Draggables._timeout = null;
  156 + window.focus();
  157 + Draggables.activeDraggable = draggable;
  158 + }.bind(this), draggable.options.delay);
159 159 } else {
160 160 window.focus(); // allows keypress events if window isn't currently focused, fails for Safari
161 161 this.activeDraggable = draggable;
162 162 }
163 163 },
164   -
  164 +
165 165 deactivate: function() {
166 166 this.activeDraggable = null;
167 167 },
168   -
  168 +
169 169 updateDrag: function(event) {
170 170 if(!this.activeDraggable) return;
171 171 var pointer = [Event.pointerX(event), Event.pointerY(event)];
@@ -173,36 +173,36 @@ var Draggables = {
173 173 // the same coordinates, prevent needless redrawing (moz bug?)
174 174 if(this._lastPointer && (this._lastPointer.inspect() == pointer.inspect())) return;
175 175 this._lastPointer = pointer;
176   -
  176 +
177 177 this.activeDraggable.updateDrag(event, pointer);
178 178 },
179   -
  179 +
180 180 endDrag: function(event) {
181   - if(this._timeout) {
182   - clearTimeout(this._timeout);
183   - this._timeout = null;
  181 + if(this._timeout) {
  182 + clearTimeout(this._timeout);
  183 + this._timeout = null;
184 184 }
185 185 if(!this.activeDraggable) return;
186 186 this._lastPointer = null;
187 187 this.activeDraggable.endDrag(event);
188 188 this.activeDraggable = null;
189 189 },
190   -
  190 +
191 191 keyPress: function(event) {
192 192 if(this.activeDraggable)
193 193 this.activeDraggable.keyPress(event);
194 194 },
195   -
  195 +
196 196 addObserver: function(observer) {
197 197 this.observers.push(observer);
198 198 this._cacheObserverCallbacks();
199 199 },
200   -
  200 +
201 201 removeObserver: function(element) { // element instead of observer fixes mem leaks
202 202 this.observers = this.observers.reject( function(o) { return o.element==element });
203 203 this._cacheObserverCallbacks();
204 204 },
205   -
  205 +
206 206 notify: function(eventName, draggable, event) { // 'onStart', 'onEnd', 'onDrag'
207 207 if(this[eventName+'Count'] > 0)
208 208 this.observers.each( function(o) {
@@ -210,7 +210,7 @@ var Draggables = {
210 210 });
211 211 if(draggable.options[eventName]) draggable.options[eventName](draggable, event);
212 212 },
213   -
  213 +
214 214 _cacheObserverCallbacks: function() {
215 215 ['onStart','onEnd','onDrag'].each( function(eventName) {
216 216 Draggables[eventName+'Count'] = Draggables.observers.select(
@@ -234,12 +234,12 @@ var Draggable = Class.create({
234 234 },
235 235 endeffect: function(element) {
236 236 var toOpacity = Object.isNumber(element._opacity) ? element._opacity : 1.0;
237   - new Effect.Opacity(element, {duration:0.2, from:0.7, to:toOpacity,
  237 + new Effect.Opacity(element, {duration:0.2, from:0.7, to:toOpacity,
238 238 queue: {scope:'_draggable', position:'end'},
239   - afterFinish: function(){
240   - Draggable._dragging[element] = false
  239 + afterFinish: function(){
  240 + Draggable._dragging[element] = false
241 241 }
242   - });
  242 + });
243 243 },
244 244 zindex: 1000,
245 245 revert: false,
@@ -250,57 +250,57 @@ var Draggable = Class.create({
250 250 snap: false, // false, or xy or [x,y] or function(x,y){ return [x,y] }
251 251 delay: 0
252 252 };
253   -
  253 +
254 254 if(!arguments[1] || Object.isUndefined(arguments[1].endeffect))
255 255 Object.extend(defaults, {
256 256 starteffect: function(element) {
257 257 element._opacity = Element.getOpacity(element);
258 258 Draggable._dragging[element] = true;
259   - new Effect.Opacity(element, {duration:0.2, from:element._opacity, to:0.7});
  259 + new Effect.Opacity(element, {duration:0.2, from:element._opacity, to:0.7});
260 260 }
261 261 });
262   -
  262 +
263 263 var options = Object.extend(defaults, arguments[1] || { });
264 264
265 265 this.element = $(element);
266   -
  266 +
267 267 if(options.handle && Object.isString(options.handle))
268 268 this.handle = this.element.down('.'+options.handle, 0);
269   -
  269 +
270 270 if(!this.handle) this.handle = $(options.handle);
271 271 if(!this.handle) this.handle = this.element;
272   -
  272 +
273 273 if(options.scroll && !options.scroll.scrollTo && !options.scroll.outerHTML) {
274 274 options.scroll = $(options.scroll);
275 275 this._isScrollChild = Element.childOf(this.element, options.scroll);
276 276 }
277 277
278   - Element.makePositioned(this.element); // fix IE
  278 + Element.makePositioned(this.element); // fix IE
279 279
280 280 this.options = options;
281   - this.dragging = false;
  281 + this.dragging = false;
282 282
283 283 this.eventMouseDown = this.initDrag.bindAsEventListener(this);
284 284 Event.observe(this.handle, "mousedown", this.eventMouseDown);
285   -
  285 +
286 286 Draggables.register(this);
287 287 },
288   -
  288 +
289 289 destroy: function() {
290 290 Event.stopObserving(this.handle, "mousedown", this.eventMouseDown);
291 291 Draggables.unregister(this);
292 292 },
293   -
  293 +
294 294 currentDelta: function() {
295 295 return([
296 296 parseInt(Element.getStyle(this.element,'left') || '0'),
297 297 parseInt(Element.getStyle(this.element,'top') || '0')]);
298 298 },
299   -
  299 +
300 300 initDrag: function(event) {
301 301 if(!Object.isUndefined(Draggable._dragging[this.element]) &&
302 302 Draggable._dragging[this.element]) return;
303   - if(Event.isLeftClick(event)) {
  303 + if(Event.isLeftClick(event)) {
304 304 // abort on form elements, fixes a Firefox issue
305 305 var src = Event.element(event);
306 306 if((tag_name = src.tagName.toUpperCase()) && (
@@ -309,26 +309,26 @@ var Draggable = Class.create({
309 309 tag_name=='OPTION' ||
310 310 tag_name=='BUTTON' ||
311 311 tag_name=='TEXTAREA')) return;
312   -
  312 +
313 313 var pointer = [Event.pointerX(event), Event.pointerY(event)];
314 314 var pos = Position.cumulativeOffset(this.element);
315 315 this.offset = [0,1].map( function(i) { return (pointer[i] - pos[i]) });
316   -
  316 +
317 317 Draggables.activate(this);
318 318 Event.stop(event);
319 319 }
320 320 },
321   -
  321 +
322 322 startDrag: function(event) {
323 323 this.dragging = true;
324 324 if(!this.delta)
325 325 this.delta = this.currentDelta();
326   -
  326 +
327 327 if(this.options.zindex) {
328 328 this.originalZ = parseInt(Element.getStyle(this.element,'z-index') || 0);
329 329 this.element.style.zIndex = this.options.zindex;
330 330 }
331   -
  331 +
332 332 if(this.options.ghosting) {
333 333 this._clone = this.element.cloneNode(true);
334 334 this.element._originallyAbsolute = (this.element.getStyle('position') == 'absolute');
@@ -336,7 +336,7 @@ var Draggable = Class.create({
336 336 Position.absolutize(this.element);
337 337 this.element.parentNode.insertBefore(this._clone, this.element);
338 338 }
339   -
  339 +
340 340 if(this.options.scroll) {
341 341 if (this.options.scroll == window) {
342 342 var where = this._getWindowScroll(this.options.scroll);
@@ -347,28 +347,28 @@ var Draggable = Class.create({
347 347 this.originalScrollTop = this.options.scroll.scrollTop;
348 348 }
349 349 }
350   -
  350 +
351 351 Draggables.notify('onStart', this, event);
352   -
  352 +
353 353 if(this.options.starteffect) this.options.starteffect(this.element);
354 354 },
355   -
  355 +
356 356 updateDrag: function(event, pointer) {
357 357 if(!this.dragging) this.startDrag(event);
358   -
  358 +
359 359 if(!this.options.quiet){
360 360 Position.prepare();
361 361 Droppables.show(pointer, this.element);
362 362 }
363   -
  363 +
364 364 Draggables.notify('onDrag', this, event);
365   -
  365 +
366 366 this.draw(pointer);
367 367 if(this.options.change) this.options.change(this);
368   -
  368 +
369 369 if(this.options.scroll) {
370 370 this.stopScrolling();
371   -
  371 +
372 372 var p;
373 373 if (this.options.scroll == window) {
374 374 with(this._getWindowScroll(this.options.scroll)) { p = [ left, top, left+width, top+height ]; }
@@ -386,16 +386,16 @@ var Draggable = Class.create({
386 386 if(pointer[1] > (p[3]-this.options.scrollSensitivity)) speed[1] = pointer[1]-(p[3]-this.options.scrollSensitivity);
387 387 this.startScrolling(speed);
388 388 }
389   -
  389 +
390 390 // fix AppleWebKit rendering
391 391 if(Prototype.Browser.WebKit) window.scrollBy(0,0);
392   -
  392 +
393 393 Event.stop(event);
394 394 },
395   -
  395 +
396 396 finishDrag: function(event, success) {
397 397 this.dragging = false;
398   -
  398 +
399 399 if(this.options.quiet){
400 400 Position.prepare();
401 401 var pointer = [Event.pointerX(event), Event.pointerY(event)];
@@ -410,17 +410,17 @@ var Draggable = Class.create({
410 410 this._clone = null;
411 411 }
412 412
413   - var dropped = false;
414   - if(success) {
415   - dropped = Droppables.fire(event, this.element);
416   - if (!dropped) dropped = false;
  413 + var dropped = false;
  414 + if(success) {
  415 + dropped = Droppables.fire(event, this.element);
  416 + if (!dropped) dropped = false;
417 417 }
418 418 if(dropped && this.options.onDropped) this.options.onDropped(this.element);
419 419 Draggables.notify('onEnd', this, event);
420 420
421 421 var revert = this.options.revert;
422 422 if(revert && Object.isFunction(revert)) revert = revert(this.element);
423   -
  423 +
424 424 var d = this.currentDelta();
425 425 if(revert && this.options.reverteffect) {
426 426 if (dropped == 0 || revert != 'failure')
@@ -433,45 +433,45 @@ var Draggable = Class.create({
433 433 if(this.options.zindex)
434 434 this.element.style.zIndex = this.originalZ;
435 435
436   - if(this.options.endeffect)
  436 + if(this.options.endeffect)
437 437 this.options.endeffect(this.element);
438   -
  438 +
439 439 Draggables.deactivate(this);
440 440 Droppables.reset();
441 441 },
442   -
  442 +
443 443 keyPress: function(event) {
444 444 if(event.keyCode!=Event.KEY_ESC) return;
445 445 this.finishDrag(event, false);
446 446 Event.stop(event);
447 447 },
448   -
  448 +
449 449 endDrag: function(event) {
450 450 if(!this.dragging) return;
451 451 this.stopScrolling();
452 452 this.finishDrag(event, true);
453 453 Event.stop(event);
454 454 },
455   -
  455 +
456 456 draw: function(point) {
457 457 var pos = Position.cumulativeOffset(this.element);
458 458 if(this.options.ghosting) {
459 459 var r = Position.realOffset(this.element);
460 460 pos[0] += r[0] - Position.deltaX; pos[1] += r[1] - Position.deltaY;
461 461 }
462   -
  462 +
463 463 var d = this.currentDelta();
464 464 pos[0] -= d[0]; pos[1] -= d[1];
465   -
  465 +
466 466 if(this.options.scroll && (this.options.scroll != window && this._isScrollChild)) {
467 467 pos[0] -= this.options.scroll.scrollLeft-this.originalScrollLeft;
468 468 pos[1] -= this.options.scroll.scrollTop-this.originalScrollTop;
469 469 }
470   -
471   - var p = [0,1].map(function(i){
472   - return (point[i]-pos[i]-this.offset[i])
  470 +
  471 + var p = [0,1].map(function(i){
  472 + return (point[i]-pos[i]-this.offset[i])
473 473 }.bind(this));
474   -
  474 +
475 475 if(this.options.snap) {
476 476 if(Object.isFunction(this.options.snap)) {
477 477 p = this.options.snap(p[0],p[1],this);
@@ -484,16 +484,16 @@ var Draggable = Class.create({
484 484 return (v/this.options.snap).round()*this.options.snap }.bind(this))
485 485 }
486 486 }}
487   -
  487 +
488 488 var style = this.element.style;
489 489 if((!this.options.constraint) || (this.options.constraint=='horizontal'))
490 490 style.left = p[0] + "px";
491 491 if((!this.options.constraint) || (this.options.constraint=='vertical'))
492 492 style.top = p[1] + "px";
493   -
  493 +
494 494 if(style.visibility=="hidden") style.visibility = ""; // fix gecko rendering
495 495 },
496   -
  496 +
497 497 stopScrolling: function() {
498 498 if(this.scrollInterval) {
499 499 clearInterval(this.scrollInterval);
@@ -501,14 +501,14 @@ var Draggable = Class.create({
501 501 Draggables._lastScrollPointer = null;
502 502 }
503 503 },
504   -
  504 +
505 505 startScrolling: function(speed) {
506 506 if(!(speed[0] || speed[1])) return;
507 507 this.scrollSpeed = [speed[0]*this.options.scrollSpeed,speed[1]*this.options.scrollSpeed];
508 508 this.lastScrolled = new Date();
509 509 this.scrollInterval = setInterval(this.scroll.bind(this), 10);
510 510 },
511   -
  511 +
512 512 scroll: function() {
513 513 var current = new Date();
514 514 var delta = current - this.lastScrolled;