Skip to content

Commit 5e5cfff

Browse files
committed
Sprockets 2 compatibility
1 parent 1fb9728 commit 5e5cfff

33 files changed

+237
-231
lines changed

Rakefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ module PrototypeHelper
7676
</h1>
7777
EOF
7878
PDoc.run({
79-
:source_files => Dir[File.join('src', '**', '*.js')],
79+
:source_files => Dir[File.join('src', 'prototype', '**', '*.js')],
8080
:destination => DOC_DIR,
8181
:index_page => 'README.markdown',
8282
:syntax_highlighter => syntax_highlighter,

src/prototype.js

Lines changed: 6 additions & 188 deletions
Original file line numberDiff line numberDiff line change
@@ -1,188 +1,6 @@
1-
/* Prototype JavaScript framework, version <%= PROTOTYPE_VERSION %>
2-
* (c) 2005-2010 Sam Stephenson
3-
*
4-
* Prototype is freely distributable under the terms of an MIT-style license.
5-
* For details, see the Prototype web site: http://www.prototypejs.org/
6-
*
7-
*--------------------------------------------------------------------------*/
8-
9-
/**
10-
* Prototype
11-
*
12-
* The [[Prototype]] namespace provides fundamental information about the
13-
* Prototype library you're using, as well as a central repository for default
14-
* iterators or functions.
15-
*
16-
* We say "namespace," because the [[Prototype]] object is not intended for
17-
* instantiation, nor for mixing in other objects. It's really just... a
18-
* namespace.
19-
*
20-
* ##### Your version of Prototype
21-
*
22-
* Your scripts can check against a particular version of Prototype by
23-
* examining [[Prototype.Version]], which is a version [[String]] (e.g.
24-
* "<%= PROTOTYPE_VERSION %>"). The famous
25-
* [script.aculo.us](http://script.aculo.us) library does this at load time to
26-
* ensure it's being used with a reasonably recent version of Prototype, for
27-
* instance.
28-
*
29-
* ##### Browser features
30-
*
31-
* Prototype also provides a (nascent) repository of
32-
* [[Prototype.BrowserFeatures browser feature information]], which it then
33-
* uses here and there in its source code. The idea is, first, to make
34-
* Prototype's source code more readable; and second, to centralize whatever
35-
* scripting trickery might be necessary to detect the browser feature, in
36-
* order to ease maintenance.
37-
*
38-
* ##### Default iterators and functions
39-
*
40-
* Numerous methods in Prototype objects (most notably the [[Enumerable]]
41-
* module) let the user pass in a custom iterator, but make it optional by
42-
* defaulting to an "identity function" (an iterator that just returns its
43-
* argument, untouched). This is the [[Prototype.K]] function, which you'll
44-
* see referred to in many places.
45-
*
46-
* Many methods also take it easy by protecting themselves against missing
47-
* methods here and there, reverting to empty functions when a supposedly
48-
* available method is missing. Such a function simply ignores its potential
49-
* arguments, and does nothing whatsoever (which is, oddly enough,
50-
* blazing fast). The quintessential empty function sits, unsurprisingly,
51-
* at [[Prototype.emptyFunction]] (note the lowercase first letter).
52-
**/
53-
var Prototype = {
54-
55-
/**
56-
* Prototype.Version -> String
57-
*
58-
* The version of the Prototype library you are using (e.g.
59-
* "<%= PROTOTYPE_VERSION %>").
60-
**/
61-
Version: '<%= PROTOTYPE_VERSION %>',
62-
63-
/**
64-
* Prototype.Browser
65-
*
66-
* A collection of [[Boolean]] values indicating the browser which is
67-
* currently in use. Available properties are `IE`, `Opera`, `WebKit`,
68-
* `MobileSafari` and `Gecko`.
69-
*
70-
* Example
71-
*
72-
* Prototype.Browser.WebKit;
73-
* //-> true, when executed in any WebKit-based browser.
74-
**/
75-
Browser: (function(){
76-
var ua = navigator.userAgent;
77-
// Opera (at least) 8.x+ has "Opera" as a [[Class]] of `window.opera`
78-
// This is a safer inference than plain boolean type conversion of `window.opera`
79-
var isOpera = Object.prototype.toString.call(window.opera) == '[object Opera]';
80-
return {
81-
IE: !!window.attachEvent && !isOpera,
82-
Opera: isOpera,
83-
WebKit: ua.indexOf('AppleWebKit/') > -1,
84-
Gecko: ua.indexOf('Gecko') > -1 && ua.indexOf('KHTML') === -1,
85-
MobileSafari: /Apple.*Mobile/.test(ua)
86-
}
87-
})(),
88-
89-
/**
90-
* Prototype.BrowserFeatures
91-
*
92-
* A collection of [[Boolean]] values indicating the presence of specific
93-
* browser features.
94-
**/
95-
BrowserFeatures: {
96-
/**
97-
* Prototype.BrowserFeatures.XPath -> Boolean
98-
*
99-
* Used internally to detect if the browser supports
100-
* [DOM Level 3 XPath](http://www.w3.org/TR/DOM-Level-3-XPath/xpath.html).
101-
**/
102-
XPath: !!document.evaluate,
103-
104-
/**
105-
* Prototype.BrowserFeatures.SelectorsAPI -> Boolean
106-
*
107-
* Used internally to detect if the browser supports the
108-
* [NodeSelector API](http://www.w3.org/TR/selectors-api/#nodeselector).
109-
**/
110-
SelectorsAPI: !!document.querySelector,
111-
112-
/**
113-
* Prototype.BrowserFeatures.ElementExtensions -> Boolean
114-
*
115-
* Used internally to detect if the browser supports extending html element
116-
* prototypes.
117-
**/
118-
ElementExtensions: (function() {
119-
var constructor = window.Element || window.HTMLElement;
120-
return !!(constructor && constructor.prototype);
121-
})(),
122-
SpecificElementExtensions: (function() {
123-
// First, try the named class
124-
if (typeof window.HTMLDivElement !== 'undefined')
125-
return true;
126-
127-
var div = document.createElement('div'),
128-
form = document.createElement('form'),
129-
isSupported = false;
130-
131-
if (div['__proto__'] && (div['__proto__'] !== form['__proto__'])) {
132-
isSupported = true;
133-
}
134-
135-
div = form = null;
136-
137-
return isSupported;
138-
})()
139-
},
140-
141-
ScriptFragment: '<script[^>]*>([\\S\\s]*?)<\/script>',
142-
JSONFilter: /^\/\*-secure-([\s\S]*)\*\/\s*$/,
143-
144-
/**
145-
* Prototype.emptyFunction([argument...]) -> undefined
146-
* - argument (Object): Optional arguments
147-
*
148-
* The [[Prototype.emptyFunction]] does nothing... and returns nothing!
149-
*
150-
* It is used thoughout the framework to provide a fallback function in order
151-
* to cut down on conditionals. Typically you'll find it as a default value
152-
* for optional callback functions.
153-
**/
154-
emptyFunction: function() { },
155-
156-
/**
157-
* Prototype.K(argument) -> argument
158-
* - argument (Object): Optional argument...
159-
*
160-
* [[Prototype.K]] is Prototype's very own
161-
* [identity function](http://en.wikipedia.org/wiki/Identity_function), i.e.
162-
* it returns its `argument` untouched.
163-
*
164-
* This is used throughout the framework, most notably in the [[Enumerable]]
165-
* module as a default value for iterators.
166-
*
167-
* ##### Examples
168-
*
169-
* Prototype.K('hello world!');
170-
* // -> 'hello world!'
171-
*
172-
* Prototype.K(200);
173-
* // -> 200
174-
*
175-
* Prototype.K(Prototype.K);
176-
* // -> Prototype.K
177-
**/
178-
K: function(x) { return x }
179-
};
180-
181-
if (Prototype.Browser.MobileSafari)
182-
Prototype.BrowserFeatures.SpecificElementExtensions = false;
183-
184-
//= require "lang"
185-
//= require "ajax"
186-
//= require "dom"
187-
188-
//= require "deprecated"
1+
//= compat
2+
//= require "./prototype/prototype"
3+
//= require "./prototype/lang"
4+
//= require "./prototype/ajax"
5+
//= require "./prototype/dom"
6+
//= require "./prototype/deprecated"

src/ajax.js renamed to src/prototype/ajax.js

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,12 @@
1+
//= compat
2+
//= require "ajax/ajax"
3+
//= require "ajax/responders"
4+
//= require "ajax/base"
5+
//= require "ajax/request"
6+
//= require "ajax/response"
7+
//= require "ajax/updater"
8+
//= require "ajax/periodical_updater"
9+
110
/**
211
* == Ajax ==
312
*
@@ -31,7 +40,7 @@
3140
*
3241
* * `asynchronous` ([[Boolean]]; default `true`): Determines whether
3342
* `XMLHttpRequest` is used asynchronously or not. Synchronous usage is
34-
* **strongly discouraged** &mdash; it halts all script execution for the
43+
* **strongly discouraged** &mdash; it halts all script execution for the
3544
* duration of the request _and_ blocks the browser UI.
3645
* * `contentType` ([[String]]; default `application/x-www-form-urlencoded`):
3746
* The `Content-type` header for your request. Change this header if you
@@ -106,11 +115,3 @@
106115
* happened during the request.
107116
*
108117
**/
109-
110-
//= require "ajax/ajax"
111-
//= require "ajax/responders"
112-
//= require "ajax/base"
113-
//= require "ajax/request"
114-
//= require "ajax/response"
115-
//= require "ajax/updater"
116-
//= require "ajax/periodical_updater"
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 commit comments

Comments
 (0)