doc: Convert all subheadings to H5s throughout.
This commit is contained in:
parent
f4314a8789
commit
cfc7e7a2e7
@ -8,7 +8,7 @@
|
||||
*
|
||||
* Actual requests are made by creating instances of [[Ajax.Request]].
|
||||
*
|
||||
* <h4>Request headers</h4>
|
||||
* <h5>Request headers</h5>
|
||||
*
|
||||
* The following headers are sent with all Ajax requests (and can be
|
||||
* overridden with the `requestHeaders` option described below):
|
||||
@ -21,7 +21,7 @@
|
||||
* * `Content-type` is automatically determined based on the `contentType`
|
||||
* and `encoding` options.
|
||||
*
|
||||
* <h4>Ajax options</h4>
|
||||
* <h5>Ajax options</h5>
|
||||
*
|
||||
* All Ajax classes share a common set of _options_ and _callbacks_.
|
||||
* Callbacks are called at various points in the life-cycle of a request, and
|
||||
@ -64,7 +64,7 @@
|
||||
* `true` otherwise): Sanitizes the contents of
|
||||
* [[Ajax.Response#responseText]] before evaluating it.
|
||||
*
|
||||
* <h4>Common callbacks</h4>
|
||||
* <h5>Common callbacks</h5>
|
||||
*
|
||||
* When used on individual instances, all callbacks (except `onException`) are
|
||||
* invoked with two parameters: the `XMLHttpRequest` object and the result of
|
||||
|
@ -16,7 +16,7 @@
|
||||
* keeping track of the response text so it can (optionally) react to
|
||||
* receiving the exact same response consecutively.
|
||||
*
|
||||
* <h4>Additional options</h4>
|
||||
* <h5>Additional options</h5>
|
||||
*
|
||||
* `Ajax.PeriodicalUpdater` features all the common options and callbacks
|
||||
* described in the [[Ajax section]] — _plus_ those added by `Ajax.Updater`.
|
||||
@ -34,7 +34,7 @@
|
||||
* is the same; when the result is different once again, `frequency` will
|
||||
* revert to its original value.
|
||||
*
|
||||
* <h4>Disabling and re-enabling a <code>PeriodicalUpdater</code></h4>
|
||||
* <h5>Disabling and re-enabling a <code>PeriodicalUpdater</code></h5>
|
||||
*
|
||||
* You can hit the brakes on a running `PeriodicalUpdater` by calling
|
||||
* [[Ajax.PeriodicalUpdater#stop]]. If you wish to re-enable it later, call
|
||||
|
@ -5,7 +5,7 @@
|
||||
*
|
||||
* `Ajax.Request` is a general-purpose class for making HTTP requests.
|
||||
*
|
||||
* <h4>Automatic JavaScript response evaluation</h4>
|
||||
* <h5>Automatic JavaScript response evaluation</h5>
|
||||
*
|
||||
* If an Ajax request follows the _same-origin policy_ **and** its response
|
||||
* has a JavaScript-related `Content-type`, the content of the `responseText`
|
||||
@ -28,7 +28,7 @@
|
||||
*
|
||||
* The MIME-type string is examined in a case-insensitive manner.
|
||||
*
|
||||
* <h4>Methods you may find useful</h4>
|
||||
* <h5>Methods you may find useful</h5>
|
||||
*
|
||||
* Instances of the `Request` object provide several methods that can come in
|
||||
* handy in your callback functions, especially once the request is complete.
|
||||
|
@ -34,7 +34,7 @@
|
||||
* }
|
||||
* });
|
||||
*
|
||||
* <h4>Responder callbacks</h4>
|
||||
* <h5>Responder callbacks</h5>
|
||||
*
|
||||
* The callbacks for responders are similar to the callbacks described in
|
||||
* the [[Ajax section]], but take a different signature. They're invoked with
|
||||
|
@ -7,7 +7,7 @@
|
||||
* `Ajax.Updater` is a subclass of [[Ajax.Request]] built for a common
|
||||
* use-case.
|
||||
*
|
||||
* <h4>Example</h4>
|
||||
* <h5>Example</h5>
|
||||
*
|
||||
* new Ajax.Updater('items', '/items', {
|
||||
* parameters: { text: $F('text') }
|
||||
@ -17,13 +17,13 @@
|
||||
* parameters); it will then replace the contents of the element with the ID
|
||||
* of `items` with whatever response it receives.
|
||||
*
|
||||
* <h4>Callbacks</h4>
|
||||
* <h5>Callbacks</h5>
|
||||
*
|
||||
* `Ajax.Updater` supports all the callbacks listed in the [[Ajax section]].
|
||||
* Note that the `onComplete` callback will be invoked **after** the element
|
||||
* is updated.
|
||||
*
|
||||
* <h4>Additional options</h4>
|
||||
* <h5>Additional options</h5>
|
||||
*
|
||||
* `Ajax.Updater` has some options of its own apart from the common options
|
||||
* described in the [[Ajax section]]:
|
||||
@ -37,7 +37,7 @@
|
||||
* `top`, `bottom`, `before`, or `after` — and _inserts_ the contents of the
|
||||
* response in the manner described by [[Element#insert]].
|
||||
*
|
||||
* <h4>More About `evalScripts`</h4>
|
||||
* <h5>More About `evalScripts`</h5>
|
||||
*
|
||||
* If you use `evalScripts: true`, any _inline_ `<script>` block will be evaluated.
|
||||
* This **does not** mean it will be evaluated in the global scope; it won't, and that
|
||||
@ -45,7 +45,7 @@
|
||||
* that only inline `<script>` blocks are supported; external scripts are ignored.
|
||||
* See [[String#evalScripts]] for the details.
|
||||
*
|
||||
* <h4>Single container, or success/failure split?</h4>
|
||||
* <h5>Single container, or success/failure split?</h5>
|
||||
*
|
||||
* The examples above all assume you're going to update the same container
|
||||
* whether your request succeeds or fails. Instead, you may want to update
|
||||
|
@ -320,7 +320,7 @@ Element.Methods = {
|
||||
* - `top` (as `element`'s first child)
|
||||
* - `bottom` (as `element`'s last child)
|
||||
*
|
||||
* <h4>Examples</h4>
|
||||
* <h5>Examples</h5>
|
||||
*
|
||||
* Insert the given HTML at the bottom of the element (using the default):
|
||||
*
|
||||
|
@ -5,7 +5,7 @@
|
||||
*
|
||||
* The namespace for Prototype's event system.
|
||||
*
|
||||
* <h4>Events: a fine mess</h4>
|
||||
* <h5>Events: a fine mess</h5>
|
||||
*
|
||||
* Event management is one of the really sore spots of cross-browser
|
||||
* scripting.
|
||||
@ -17,7 +17,7 @@
|
||||
* Safari). Also, MSIE has a tendency to leak memory when it comes to
|
||||
* discarding event handlers.
|
||||
*
|
||||
* <h4>Prototype to the rescue</h4>
|
||||
* <h5>Prototype to the rescue</h5>
|
||||
*
|
||||
* Of course, Prototype smooths it over so well you'll forget these
|
||||
* troubles even exist. Enter the `Event` namespace. It is replete with
|
||||
@ -418,7 +418,7 @@
|
||||
*
|
||||
* The examples in this documentation use the [[Element#observe]] form.
|
||||
*
|
||||
* <h4>The Handler</h4>
|
||||
* <h5>The Handler</h5>
|
||||
*
|
||||
* Signature:
|
||||
*
|
||||
@ -435,13 +435,13 @@
|
||||
* Note that we used `this` to refer to the element, and that we received the `event` object
|
||||
* as a parameter (even on MSIE).
|
||||
*
|
||||
* <h4>It's All About Timing</h4>
|
||||
* <h5>It's All About Timing</h5>
|
||||
*
|
||||
* One of the most common errors trying to observe events is trying to do it before the element
|
||||
* exists in the DOM. Don't try to observe elements until after the
|
||||
* [[document.observe dom:loaded]] event or `window` `load` event has been fired.
|
||||
*
|
||||
* <h4>Preventing the Default Event Action and Bubbling</h4>
|
||||
* <h5>Preventing the Default Event Action and Bubbling</h5>
|
||||
*
|
||||
* If we want to stop the event (e.g., prevent its default action and stop it bubbling), we can
|
||||
* do so with the extended event object's [[Event#stop]] method:
|
||||
@ -450,7 +450,7 @@
|
||||
* event.stop();
|
||||
* });
|
||||
*
|
||||
* <h4>Finding the Element Where the Event Occurred</h4>
|
||||
* <h5>Finding the Element Where the Event Occurred</h5>
|
||||
*
|
||||
* Since most events bubble from descendant elements up through the hierarchy until they're
|
||||
* handled, we can observe an event on a container rather than individual elements within the
|
||||
@ -481,12 +481,12 @@
|
||||
* record was clicked. [[Event#findElement]] finds the row that was clicked, and `this` refers
|
||||
* to the table we were observing.
|
||||
*
|
||||
* <h4>Stopping Observing the Event</h4>
|
||||
* <h5>Stopping Observing the Event</h5>
|
||||
*
|
||||
* If we don't need to observe the event anymore, we can stop observing it with
|
||||
* [[Event.stopObserving]] (aka [[Element#stopObserving]]).
|
||||
*
|
||||
* <h4>Using an Instance Method as a Handler</h4>
|
||||
* <h5>Using an Instance Method as a Handler</h5>
|
||||
*
|
||||
* If we want to use an instance method as a handler, we will probably want to use
|
||||
* [[Function#bind]] to set the handler's context; otherwise, the context will be lost and
|
||||
@ -511,13 +511,13 @@
|
||||
* details. There's also [[Function#bindAsEventListener]], which is handy for certain very
|
||||
* specific situations. (Normally, `bind` is all you need.)
|
||||
*
|
||||
* <h4>Side Notes</h4>
|
||||
* <h5>Side Notes</h5>
|
||||
*
|
||||
* Although Prototype smooths out most of the differences between browsers, the fundamental
|
||||
* behavior of a browser implementation isn't changed. For example, the timing of the `change`
|
||||
* or `blur` events varies a bit from browser to browser.
|
||||
*
|
||||
* <h4>Changes in 1.6.x</h4>
|
||||
* <h5>Changes in 1.6.x</h5>
|
||||
*
|
||||
* Prior to Prototype 1.6, `observe` supported a fourth argument (`useCapture`), a boolean that
|
||||
* indicated whether to use the browser's capturing phase or its bubbling phase. Since MSIE does
|
||||
@ -572,7 +572,7 @@
|
||||
* for that `eventName`. If `eventName` is also omitted, unregisters _all_
|
||||
* event handlers on `element`. (In each case, only affects handlers registered via Prototype.)
|
||||
*
|
||||
* <h4>Examples</h4>
|
||||
* <h5>Examples</h5>
|
||||
*
|
||||
* Assuming:
|
||||
*
|
||||
@ -591,7 +591,7 @@
|
||||
*
|
||||
* $('foo').stopObserving();
|
||||
*
|
||||
* <h4>A Common Error</h4>
|
||||
* <h5>A Common Error</h5>
|
||||
*
|
||||
* When using instance methods as observers, it's common to use [[Function#bind]] on them, e.g.:
|
||||
*
|
||||
|
@ -39,7 +39,7 @@ var Form = {
|
||||
* the value for that key in the object will be an array of the field values
|
||||
* in the order they appeared on the array of elements.
|
||||
*
|
||||
* <h4>The Options</h4>
|
||||
* <h5>The Options</h5>
|
||||
*
|
||||
* The options allow you to control two things: What kind of return
|
||||
* value you get (an object or a string), and whether and which `submit`
|
||||
@ -64,7 +64,7 @@ var Form = {
|
||||
* _(Deprecated)_ If you pass in a [[Boolean]] instead of an object for `options`, it
|
||||
* is used as the `hash` option and all other options are defaulted.
|
||||
*
|
||||
* <h4>A <em>hash</em>, not a Hash</h4>
|
||||
* <h5>A <em>hash</em>, not a Hash</h5>
|
||||
*
|
||||
* If you opt to receive an object, it is a plain JavaScript object with keys
|
||||
* and values, __not__ a [[Hash]]. All JavaScript objects are hashes in the lower-case
|
||||
@ -490,7 +490,7 @@ Form.Element.Serializers = {
|
||||
* [[Form.Observer]], which serializes a form and triggers when the result has changed; and
|
||||
* [[Form.Element.Observer]], which triggers when the value of a given form field changes.
|
||||
*
|
||||
* <h4>Creating Your Own TimedObserver Implementations</h4>
|
||||
* <h5>Creating Your Own TimedObserver Implementations</h5>
|
||||
*
|
||||
* It's easy to create your own `TimedObserver` implementations: Simply subclass `TimedObserver`
|
||||
* and provide the `getValue()` method. For example, this is the complete source code for
|
||||
|
@ -52,7 +52,7 @@ Array.from = $A;
|
||||
* their `[]` indexing operator. They become very powerful objects that
|
||||
* greatly simplify the code for 99% of the common use cases involving them.
|
||||
*
|
||||
* <h4>Why you should stop using for...in to iterate</h4>
|
||||
* <h5>Why you should stop using for...in to iterate</h5>
|
||||
*
|
||||
* Many JavaScript authors have been misled into using the `for...in` JavaScript
|
||||
* construct to loop over array elements. This kind of code just won't work
|
||||
@ -77,7 +77,7 @@ Array.from = $A;
|
||||
* those coming from the [[Enumerable]] module, and those Prototype puts in the
|
||||
* Array namespace (listed further below).
|
||||
*
|
||||
* <h4>What you should use instead</h4>
|
||||
* <h5>What you should use instead</h5>
|
||||
*
|
||||
* You can revert to vanilla loops:
|
||||
*
|
||||
@ -99,7 +99,7 @@ Array.from = $A;
|
||||
* module. So manual loops should be fairly rare.
|
||||
*
|
||||
*
|
||||
* <h4>A note on performance</h4>
|
||||
* <h5>A note on performance</h5>
|
||||
*
|
||||
* Should you have a very large array, using iterators with lexical closures
|
||||
* (anonymous functions that you pass to the iterators and that get invoked at
|
||||
@ -134,7 +134,7 @@ Array.from = $A;
|
||||
*
|
||||
* Clears the array (makes it empty) and returns the array reference.
|
||||
*
|
||||
* ### Example
|
||||
* <h5>Example</h5>
|
||||
*
|
||||
* var guys = ['Sam', 'Justin', 'Andrew', 'Dan'];
|
||||
* guys.clear();
|
||||
@ -170,7 +170,7 @@ Array.from = $A;
|
||||
*
|
||||
* Returns a **copy** of the array without any `null` or `undefined` values.
|
||||
*
|
||||
* ### Example
|
||||
* <h5>Example</h5>
|
||||
*
|
||||
* var orig = [undefined, 'A', undefined, 'B', null, 'C'];
|
||||
* var copy = orig.compact();
|
||||
@ -193,7 +193,7 @@ Array.from = $A;
|
||||
* useful when handling the results of a recursive collection algorithm,
|
||||
* for instance.
|
||||
*
|
||||
* ### Example
|
||||
* <h5>Example</h5>
|
||||
*
|
||||
* var a = ['frank', ['bob', 'lisa'], ['jill', ['tom', 'sally']]];
|
||||
* var b = a.flatten();
|
||||
@ -216,7 +216,7 @@ Array.from = $A;
|
||||
* Produces a new version of the array that does not contain any of the
|
||||
* specified values, leaving the original array unchanged.
|
||||
*
|
||||
* ### Examples
|
||||
* <h5>Examples</h5>
|
||||
*
|
||||
* [3, 5, 6].without(3)
|
||||
* // -> [5, 6]
|
||||
@ -238,7 +238,7 @@ Array.from = $A;
|
||||
*
|
||||
* Reverses the array's contents, optionally cloning it first.
|
||||
*
|
||||
* ### Examples
|
||||
* <h5>Examples</h5>
|
||||
*
|
||||
* // Making a copy
|
||||
* var nums = [3, 5, 6, 1, 20];
|
||||
@ -266,7 +266,7 @@ Array.from = $A;
|
||||
* On large arrays when `sorted` is `false`, this method has a potentially
|
||||
* large performance cost.
|
||||
*
|
||||
* ### Examples
|
||||
* <h5>Examples</h5>
|
||||
*
|
||||
* [1, 3, 2, 1].uniq();
|
||||
* // -> [1, 2, 3]
|
||||
@ -325,7 +325,7 @@ Array.from = $A;
|
||||
*
|
||||
* Returns the debug-oriented string representation of an array.
|
||||
*
|
||||
* ### Example
|
||||
* <h5>Example</h5>
|
||||
*
|
||||
* ['Apples', {good: 'yes', bad: 'no'}, 3, 34].inspect()
|
||||
* // -> "['Apples', [object Object], 3, 34]"
|
||||
@ -339,7 +339,7 @@ Array.from = $A;
|
||||
*
|
||||
* Returns a JSON string representation of the array.
|
||||
*
|
||||
* ### Example
|
||||
* <h5>Example</h5>
|
||||
*
|
||||
* ['a', {b: null}].toJSON();
|
||||
* //-> '["a", {"b": null}]'
|
||||
@ -363,7 +363,7 @@ Array.from = $A;
|
||||
* or `-1` if `item` doesn't exist in the array. `Array#indexOf` compares
|
||||
* items using *strict equality* (`===`).
|
||||
*
|
||||
* ### Examples
|
||||
* <h5>Examples</h5>
|
||||
*
|
||||
* [3, 5, 6, 1, 20].indexOf(1)
|
||||
* // -> 3
|
||||
|
@ -86,7 +86,7 @@ var Class = (function() {
|
||||
* of the class and of all its subclasses, even those that have already been
|
||||
* instantiated.
|
||||
*
|
||||
* <h4>Examples</h4>
|
||||
* <h5>Examples</h5>
|
||||
*
|
||||
* var Animal = Class.create({
|
||||
* initialize: function(name, sound) {
|
||||
|
@ -10,7 +10,7 @@
|
||||
* Produces a string representation of the date in ISO 8601 format.
|
||||
* The time zone is always UTC, as denoted by the suffix "Z".
|
||||
*
|
||||
* ### Example
|
||||
* <h5>Example</h5>
|
||||
*
|
||||
* var d = new Date(1969, 11, 31, 19);
|
||||
* d.getTimezoneOffset();
|
||||
|
@ -12,7 +12,7 @@
|
||||
* are [[Array]] and [[Hash]], but you'll find it in less obvious spots as
|
||||
* well, such as in [[ObjectRange]] and various DOM- or Ajax-related objects.
|
||||
*
|
||||
* <h4>The <code>context</code> parameter</h4>
|
||||
* <h5>The <code>context</code> parameter</h5>
|
||||
*
|
||||
* Every method of `Enumerable` that takes an iterator also takes the "context
|
||||
* object" as the next (optional) parameter. The context object is what the
|
||||
@ -31,7 +31,7 @@
|
||||
* If there is no `context` argument, the iterator function will execute in
|
||||
* the scope from which the `Enumerable` method itself was called.
|
||||
*
|
||||
* <h4>Mixing <code>Enumerable</code> into your own objects</h4>
|
||||
* <h5>Mixing <code>Enumerable</code> into your own objects</h5>
|
||||
*
|
||||
* So, let's say you've created your very own collection-like object (say,
|
||||
* some sort of Set, or perhaps something that dynamically fetches data
|
||||
@ -93,12 +93,12 @@ var Enumerable = (function() {
|
||||
*
|
||||
* Calls `iterator` for each item in the collection.
|
||||
*
|
||||
* ### Examples
|
||||
* <h5>Examples</h5>
|
||||
*
|
||||
* ['one', 'two', 'three'].each(alert);
|
||||
* // Alerts "one", then alerts "two", then alerts "three"
|
||||
*
|
||||
* ### Built-In Variants
|
||||
* <h5>Built-In Variants</h5>
|
||||
*
|
||||
* Most of the common use cases for `each` are already available pre-coded
|
||||
* as other methods on `Enumerable`. Whether you want to find the first
|
||||
@ -131,7 +131,7 @@ var Enumerable = (function() {
|
||||
* fewer than `number` items; it won't "pad" the last group with empty
|
||||
* values. For that behavior, use [[Enumerable#inGroupsOf]].
|
||||
*
|
||||
* ### Example
|
||||
* <h5>Example</h5>
|
||||
*
|
||||
* var students = [
|
||||
* { name: 'Sunny', age: 20 },
|
||||
@ -168,7 +168,7 @@ var Enumerable = (function() {
|
||||
* is boolean-equivalent to `false`, such as `undefined`, `0`, or indeed
|
||||
* `false`);
|
||||
*
|
||||
* ### Examples
|
||||
* <h5>Examples</h5>
|
||||
*
|
||||
* [].all();
|
||||
* // -> true (empty arrays have no elements that could be falsy)
|
||||
@ -203,7 +203,7 @@ var Enumerable = (function() {
|
||||
* Determines whether at least one element is truthy (boolean-equivalent to
|
||||
* `true`), either directly or through computation by the provided iterator.
|
||||
*
|
||||
* ### Examples
|
||||
* <h5>Examples</h5>
|
||||
*
|
||||
* [].any();
|
||||
* // -> false (empty arrays have no elements that could be truthy)
|
||||
@ -235,7 +235,7 @@ var Enumerable = (function() {
|
||||
* `iterator` is provided, the elements are simply copied to the
|
||||
* returned array.
|
||||
*
|
||||
* ### Examples
|
||||
* <h5>Examples</h5>
|
||||
*
|
||||
* ['Hitch', "Hiker's", 'Guide', 'to', 'the', 'Galaxy'].collect(function(s) {
|
||||
* return s.charAt(0).toUpperCase();
|
||||
@ -266,7 +266,7 @@ var Enumerable = (function() {
|
||||
* Returns the first element for which the iterator returns a truthy value.
|
||||
* Aliased by the [[Enumerable#find]] method.
|
||||
*
|
||||
* ### Example
|
||||
* <h5>Example</h5>
|
||||
*
|
||||
* [1, 7, -2, -4, 5].detect(function(n) { return n < 0; });
|
||||
* // -> -2
|
||||
@ -291,7 +291,7 @@ var Enumerable = (function() {
|
||||
* Returns all the elements for which the iterator returned a truthy value.
|
||||
* For the opposite operation, see [[Enumerable#reject]].
|
||||
*
|
||||
* ### Example
|
||||
* <h5>Example</h5>
|
||||
*
|
||||
* [1, 'two', 3, 'four', 5].findAll(Object.isString);
|
||||
* // -> ['two', 'four']
|
||||
@ -326,7 +326,7 @@ var Enumerable = (function() {
|
||||
* or a falsy value not to. Note that the `RegExp` `match` function will
|
||||
* convert elements to Strings to perform matching.
|
||||
*
|
||||
* ### Examples
|
||||
* <h5>Examples</h5>
|
||||
*
|
||||
* // Get all strings containing a repeated letter
|
||||
* ['hello', 'world', 'this', 'is', 'cool'].grep(/(.)\1/);
|
||||
@ -358,7 +358,7 @@ var Enumerable = (function() {
|
||||
* based on the `==` comparison operator (equality with implicit type
|
||||
* conversion).
|
||||
*
|
||||
* ### Examples
|
||||
* <h5>Examples</h5>
|
||||
*
|
||||
* $R(1, 15).include(10);
|
||||
* // -> true
|
||||
@ -392,7 +392,7 @@ var Enumerable = (function() {
|
||||
* Like [[Enumerable#eachSlice]], but pads out the last chunk with the
|
||||
* specified value if necessary and doesn't support the `iterator` function.
|
||||
*
|
||||
* ### Examples
|
||||
* <h5>Examples</h5>
|
||||
*
|
||||
* var students = [
|
||||
* { name: 'Sunny', age: 20 },
|
||||
@ -434,7 +434,7 @@ var Enumerable = (function() {
|
||||
* argument, the element as its second argument, and the element's index as
|
||||
* its third. It returns the new value for the accumulator.
|
||||
*
|
||||
* ### Examples
|
||||
* <h5>Examples</h5>
|
||||
*
|
||||
* $R(1,10).inject(0, function(acc, n) { return acc + n; });
|
||||
* // -> 55 (sum of 1 to 10)
|
||||
@ -462,7 +462,7 @@ var Enumerable = (function() {
|
||||
* Invokes the same method, with the same arguments, for all items in a
|
||||
* collection. Returns an array of the results of the method calls.
|
||||
*
|
||||
* ### Examples
|
||||
* <h5>Examples</h5>
|
||||
*
|
||||
* ['hello', 'world'].invoke('toUpperCase');
|
||||
* // -> ['HELLO', 'WORLD']
|
||||
@ -499,7 +499,7 @@ var Enumerable = (function() {
|
||||
* evaluated, and its index in the enumeration; it should return the value
|
||||
* `max` should consider (and potentially return).
|
||||
*
|
||||
* ### Examples
|
||||
* <h5>Examples</h5>
|
||||
*
|
||||
* ['c', 'b', 'a'].max();
|
||||
* // -> 'c'
|
||||
@ -539,7 +539,7 @@ var Enumerable = (function() {
|
||||
* evaluated, and its index in the enumeration; it should return the value
|
||||
* `min` should consider (and potentially return).
|
||||
*
|
||||
* ### Examples
|
||||
* <h5>Examples</h5>
|
||||
*
|
||||
* ['c', 'b', 'a'].min();
|
||||
* // -> 'a'
|
||||
@ -578,7 +578,7 @@ var Enumerable = (function() {
|
||||
* then using [[Enumerable#reject]] because the enumeration is only processed
|
||||
* once.
|
||||
*
|
||||
* ### Examples
|
||||
* <h5>Examples</h5>
|
||||
*
|
||||
* ['hello', null, 42, false, true, , 17].partition();
|
||||
* // -> [['hello', 42, true, 17], [null, false, undefined]]
|
||||
@ -606,7 +606,7 @@ var Enumerable = (function() {
|
||||
* and [[Enumerable#each]]: fetching the same property for all of the
|
||||
* elements. Returns an array of the property values.
|
||||
*
|
||||
* ### Example
|
||||
* <h5>Example</h5>
|
||||
*
|
||||
* ['hello', 'world', 'this', 'is', 'nice'].pluck('length');
|
||||
* // -> [5, 5, 4, 2, 4]
|
||||
@ -628,7 +628,7 @@ var Enumerable = (function() {
|
||||
* Returns all the elements for which the iterator returns a falsy value.
|
||||
* For the opposite operation, see [[Enumerable#findAll]].
|
||||
*
|
||||
* ### Example
|
||||
* <h5>Example</h5>
|
||||
*
|
||||
* [1, "two", 3, "four", 5].reject(Object.isString);
|
||||
* // -> [1, 3, 5]
|
||||
@ -657,7 +657,7 @@ var Enumerable = (function() {
|
||||
* `sortBy` does not guarantee a *stable* sort; adjacent equivalent elements
|
||||
* may be swapped.
|
||||
*
|
||||
* ### Example
|
||||
* <h5>Example</h5>
|
||||
*
|
||||
* ['hello', 'world', 'this', 'is', 'nice'].sortBy(function(s) {
|
||||
* return s.length;
|
||||
@ -681,7 +681,7 @@ var Enumerable = (function() {
|
||||
*
|
||||
* Returns an Array containing the elements of the enumeration.
|
||||
*
|
||||
* ### Example
|
||||
* <h5>Example</h5>
|
||||
*
|
||||
* $R(1, 5).toArray();
|
||||
* // -> [1, 2, 3, 4, 5]
|
||||
@ -708,7 +708,7 @@ var Enumerable = (function() {
|
||||
* If supplied, `iterator` is called with each tuple as its only argument
|
||||
* and should return the value to use in place of that tuple.
|
||||
*
|
||||
* ### Examples
|
||||
* <h5>Examples</h5>
|
||||
*
|
||||
* var firstNames = ['Jane', 'Nitin', 'Guy'];
|
||||
* var lastNames = ['Doe', 'Patel', 'Forcier'];
|
||||
|
@ -24,7 +24,7 @@ Object.extend(Function.prototype, (function() {
|
||||
* the values as an array of strings (or an empty array if the function is
|
||||
* defined without parameters).
|
||||
*
|
||||
* ### Examples
|
||||
* <h5>Examples</h5>
|
||||
*
|
||||
* function fn(foo, bar) {
|
||||
* return foo + bar;
|
||||
@ -52,7 +52,7 @@ Object.extend(Function.prototype, (function() {
|
||||
* function is called, it will call the original ensuring that `this` is set
|
||||
* to `context`. Also optionally curries arguments for the function.
|
||||
*
|
||||
* ### Examples
|
||||
* <h5>Examples</h5>
|
||||
*
|
||||
* A typical use of `Function#bind` is to ensure that a callback (event
|
||||
* handler, etc.) that is an object method gets called with the correct
|
||||
@ -136,7 +136,7 @@ Object.extend(Function.prototype, (function() {
|
||||
* This mostly happens if the number of arguments will vary, and so you
|
||||
* want to know the event object is the first argument.
|
||||
*
|
||||
* ### Example
|
||||
* <h5>Example</h5>
|
||||
*
|
||||
* var ContentUpdater = Class.create({
|
||||
* initialize: function(initialData) {
|
||||
@ -226,7 +226,7 @@ Object.extend(Function.prototype, (function() {
|
||||
* To schedule a function to run as soon as the interpreter is idle, use
|
||||
* [[Function#defer]].
|
||||
*
|
||||
* ### Example
|
||||
* <h5>Example</h5>
|
||||
*
|
||||
* function showMsg(msg) {
|
||||
* alert(msg);
|
||||
@ -255,7 +255,7 @@ Object.extend(Function.prototype, (function() {
|
||||
* ID that can be used to clear the timeout with `window.clearTimeout` before
|
||||
* it runs.
|
||||
*
|
||||
* ### Example
|
||||
* <h5>Example</h5>
|
||||
*
|
||||
* function showMsg(msg) {
|
||||
* alert(msg);
|
||||
@ -293,7 +293,7 @@ Object.extend(Function.prototype, (function() {
|
||||
* indirection in-between that sets up the proper context \[`this` value\] for
|
||||
* it.)
|
||||
*
|
||||
* ### Example
|
||||
* <h5>Example</h5>
|
||||
*
|
||||
* // Wrap String#capitalize so it accepts an additional argument
|
||||
* String.prototype.capitalize = String.prototype.capitalize.wrap(
|
||||
@ -333,7 +333,7 @@ Object.extend(Function.prototype, (function() {
|
||||
* want to transform a function that takes an object to a method of that
|
||||
* object or its prototype, shortening its signature by one argument.
|
||||
*
|
||||
* ### Example
|
||||
* <h5>Example</h5>
|
||||
*
|
||||
* // A function that sets a name on a target object
|
||||
* function setName(target, name) {
|
||||
|
@ -22,7 +22,7 @@ function $H(object) {
|
||||
* methods that let you enumerate keys and values, iterate over key/value
|
||||
* pairs, merge two hashes together, and much more.
|
||||
*
|
||||
* <h4>Creating a hash</h4>
|
||||
* <h5>Creating a hash</h5>
|
||||
*
|
||||
* You can create a Hash either via `new Hash()` or the convenience alias
|
||||
* `$H()`; there is **no** difference between them. In either case, you may
|
||||
@ -67,7 +67,7 @@ var Hash = Class.create(Enumerable, (function() {
|
||||
* implementations exhibit *ordered* behavior, this is not standardized and
|
||||
* may not always be the case, and so cannot be relied upon.
|
||||
*
|
||||
* ### Example
|
||||
* <h5>Example</h5>
|
||||
*
|
||||
* var h = $H({version: 1.6, author: 'The Core Team'});
|
||||
*
|
||||
@ -96,7 +96,7 @@ var Hash = Class.create(Enumerable, (function() {
|
||||
*
|
||||
* Stores `value` in the hash using the key `key` and returns `value`.
|
||||
*
|
||||
* ### Example
|
||||
* <h5>Example</h5>
|
||||
*
|
||||
* var h = $H();
|
||||
* h.keys();
|
||||
@ -117,7 +117,7 @@ var Hash = Class.create(Enumerable, (function() {
|
||||
*
|
||||
* Returns the stored value for the given `key`.
|
||||
*
|
||||
* ### Examples
|
||||
* <h5>Examples</h5>
|
||||
*
|
||||
* var h = new Hash({a: 'apple', b: 'banana', c: 'coconut'});
|
||||
* h.get('a');
|
||||
@ -135,7 +135,7 @@ var Hash = Class.create(Enumerable, (function() {
|
||||
* Deletes the stored pair for the given `key` from the hash and returns its
|
||||
* value.
|
||||
*
|
||||
* ### Example
|
||||
* <h5>Example</h5>
|
||||
*
|
||||
* var h = new Hash({a: 'apple', b: 'banana', c: 'coconut'});
|
||||
* h.keys();
|
||||
@ -157,7 +157,7 @@ var Hash = Class.create(Enumerable, (function() {
|
||||
* Returns a cloned, vanilla object whose properties (and property values)
|
||||
* match the keys (and values) from the hash.
|
||||
*
|
||||
* ### Example
|
||||
* <h5>Example</h5>
|
||||
*
|
||||
* var h = new Hash({ a: 'apple', b: 'banana', c: 'coconut' });
|
||||
* var obj = h.toObject();
|
||||
@ -175,7 +175,7 @@ var Hash = Class.create(Enumerable, (function() {
|
||||
*
|
||||
* The order of the keys is not guaranteed.
|
||||
*
|
||||
* ### Example
|
||||
* <h5>Example</h5>
|
||||
*
|
||||
* var h = $H({one: "uno", two: "due", three: "tre"});
|
||||
* h.keys();
|
||||
@ -192,7 +192,7 @@ var Hash = Class.create(Enumerable, (function() {
|
||||
*
|
||||
* The order of the values is not guaranteed.
|
||||
*
|
||||
* ### Example
|
||||
* <h5>Example</h5>
|
||||
*
|
||||
* var h = $H({one: "uno", two: "due", three: "tre"});
|
||||
* h.values();
|
||||
@ -225,7 +225,7 @@ var Hash = Class.create(Enumerable, (function() {
|
||||
*
|
||||
* To modify the original hash in place, use [[Hash#update]].
|
||||
*
|
||||
* ### Example
|
||||
* <h5>Example</h5>
|
||||
*
|
||||
* var h = $H({one: "uno", two: "due"});
|
||||
* var h2 = h.merge({three: "tre"});
|
||||
@ -249,7 +249,7 @@ var Hash = Class.create(Enumerable, (function() {
|
||||
* `update` modifies the hash. To get a new hash instead, use
|
||||
* [[Hash#merge]].
|
||||
*
|
||||
* ### Example
|
||||
* <h5>Example</h5>
|
||||
*
|
||||
* var h = $H({one: "uno", two: "due"});
|
||||
* h.update({three: "tre"});
|
||||
@ -289,7 +289,7 @@ var Hash = Class.create(Enumerable, (function() {
|
||||
* The order of pairs in the string is not guaranteed, other than the order
|
||||
* of array values described above.
|
||||
*
|
||||
* ### Example
|
||||
* <h5>Example</h5>
|
||||
*
|
||||
* $H({action: 'ship',
|
||||
* order_id: 123,
|
||||
@ -337,7 +337,7 @@ var Hash = Class.create(Enumerable, (function() {
|
||||
*
|
||||
* Returns a JSON string containing the keys and values in this hash.
|
||||
*
|
||||
* ### Example
|
||||
* <h5>Example</h5>
|
||||
*
|
||||
* var h = $H({'a': 'apple', 'b': 23, 'c': false});
|
||||
* h.toJSON();
|
||||
|
@ -20,7 +20,7 @@ Object.extend(Number.prototype, (function() {
|
||||
* (which is therefore assumed to be in the \[0..255\] range, inclusive).
|
||||
* Useful for composing CSS color strings.
|
||||
*
|
||||
* ### Example
|
||||
* <h5>Example</h5>
|
||||
*
|
||||
* 10.toColorPart()
|
||||
* // -> "0a"
|
||||
@ -49,7 +49,7 @@ Object.extend(Number.prototype, (function() {
|
||||
* the first parameter. The number will be 0 on first call, 1 on second
|
||||
* call, etc. `times` returns the number instance it was called on.
|
||||
*
|
||||
* ### Example
|
||||
* <h5>Example</h5>
|
||||
*
|
||||
* (3).times(alert);
|
||||
* // -> Alerts "0", then "1", then "2"; returns 3
|
||||
@ -81,7 +81,7 @@ Object.extend(Number.prototype, (function() {
|
||||
* that the string's length is at least equal to `length`. Takes an optional
|
||||
* `radix` argument which specifies the base to use for conversion.
|
||||
*
|
||||
* ### Examples
|
||||
* <h5>Examples</h5>
|
||||
*
|
||||
* (13).toPaddedString(4);
|
||||
* // -> "0013"
|
||||
|
@ -173,7 +173,7 @@
|
||||
* Do note that this is a _shallow_ copy, not a _deep_ copy. Nested objects
|
||||
* will retain their references.
|
||||
*
|
||||
* ### Examples
|
||||
* <h5>Examples</h5>
|
||||
*
|
||||
* var original = {name: 'primaryColors', values: ['red', 'green', 'blue']};
|
||||
* var copy = Object.clone(original);
|
||||
|
@ -127,7 +127,7 @@ Object.extend(String.prototype, (function() {
|
||||
* `span`, and `abbr`. It _will not_ strip namespace-prefixed tags such
|
||||
* as `h:table` or `xsl:template`.
|
||||
*
|
||||
* <h4>Caveat User</h4>
|
||||
* <h5>Caveat User</h5>
|
||||
*
|
||||
* Note that the processing `stripTags` does is good enough for most purposes, but
|
||||
* you cannot rely on it for security purposes. If you're processing end-user-supplied
|
||||
@ -145,12 +145,12 @@ Object.extend(String.prototype, (function() {
|
||||
*
|
||||
* Strips a string of things that look like an HTML script blocks.
|
||||
*
|
||||
* <h4>Example</h4>
|
||||
* <h5>Example</h5>
|
||||
*
|
||||
* "<p>This is a test.<script>alert("Look, a test!");</script>End of test</p>".stripScripts();
|
||||
* // => "<p>This is a test.End of test</p>"
|
||||
*
|
||||
* <h4>Caveat User</h4>
|
||||
* <h5>Caveat User</h5>
|
||||
*
|
||||
* Note that the processing `stripScripts` does is good enough for most purposes,
|
||||
* but you cannot rely on it for security purposes. If you're processing end-user-supplied
|
||||
@ -183,7 +183,7 @@ Object.extend(String.prototype, (function() {
|
||||
* they were empty (the result for that position in the array will be `undefined`);
|
||||
* external files are _not_ loaded and processed by `evalScripts`.
|
||||
*
|
||||
* <h4>About `evalScripts`, `var`s, and defining functions</h4>
|
||||
* <h5>About `evalScripts`, `var`s, and defining functions</h5>
|
||||
*
|
||||
* `evalScripts` evaluates script blocks, but this **does not** mean they are
|
||||
* evaluated in the global scope. They aren't, they're evaluated in the scope of
|
||||
@ -302,7 +302,7 @@ Object.extend(String.prototype, (function() {
|
||||
* Converts a string separated by dashes into a camelCase equivalent.
|
||||
* For instance, 'foo-bar' would be converted to 'fooBar'.
|
||||
*
|
||||
* <h4>Examples</h4>
|
||||
* <h5>Examples</h5>
|
||||
*
|
||||
* 'background-color'.camelize();
|
||||
* // -> 'backgroundColor'
|
||||
|
@ -14,7 +14,7 @@
|
||||
* expression. The `Template` class provides a much nicer and clearer way of
|
||||
* achieving this formatting.
|
||||
*
|
||||
* <h4>Straightforward templates</h4>
|
||||
* <h5>Straightforward templates</h5>
|
||||
*
|
||||
* The `Template` class uses a basic formatting syntax, similar to what is
|
||||
* used in Ruby. The templates are created from strings that have embedded
|
||||
@ -36,7 +36,7 @@
|
||||
* myTemplate.evaluate(show);
|
||||
* // -> "The TV show The Simpsons was created by Matt Groening."
|
||||
*
|
||||
* <h4>Templates are meant to be reused</h4>
|
||||
* <h5>Templates are meant to be reused</h5>
|
||||
*
|
||||
* As the example illustrates, `Template` objects are not tied to specific
|
||||
* data. The data is bound to the template only during the evaluation of the
|
||||
@ -60,7 +60,7 @@
|
||||
* // -> Multiply by 0.9478 to convert from kilojoules to BTUs.
|
||||
* // -> Multiply by 1024 to convert from megabytes to gigabytes.
|
||||
*
|
||||
* <h4>Escape sequence</h4>
|
||||
* <h5>Escape sequence</h5>
|
||||
*
|
||||
* There's always the chance that one day you'll need to have a literal in your
|
||||
* template that looks like a symbol, but is not supposed to be replaced. For
|
||||
@ -75,7 +75,7 @@
|
||||
* t.evaluate(data);
|
||||
* // -> in Ruby we also use the #{variable} syntax for templates.
|
||||
*
|
||||
* <h4>Custom syntaxes</h4>
|
||||
* <h5>Custom syntaxes</h5>
|
||||
*
|
||||
* The default syntax of the template strings will probably be enough for most
|
||||
* scenarios. In the rare occasion where the default Ruby-like syntax is
|
||||
|
Loading…
Reference in New Issue
Block a user