From c5c57cccf67392132b8fdd5d6e025c7e635cac98 Mon Sep 17 00:00:00 2001 From: Dmitry Baranovskiy Date: Tue, 10 Sep 2013 10:26:53 +1000 Subject: [PATCH] Fix docs for bug #4 --- dist/reference.html | 144 ++++++++++++++++++++++---------------------- src/svg.js | 4 +- 2 files changed, 74 insertions(+), 74 deletions(-) diff --git a/dist/reference.html b/dist/reference.html index e5812e8..705386e 100644 --- a/dist/reference.html +++ b/dist/reference.html @@ -31,10 +31,10 @@

Element.after(el)

Inserts given element after the current one.

Parameters

  1. el @@ -42,7 +42,7 @@ element to insert

Returns: Element parent

-

Element.animate(attrs, ms, [easing], [callback])

+

Element.animate(attrs, ms, [easing], [callback])

Animate given attributes of the element.

Parameters

  1. attrs @@ -61,7 +61,7 @@  

Returns: Element the element

-

Element.append(el)

+

Element.append(el)

Appends given element to current one.

Parameters

  1. el @@ -69,7 +69,7 @@ element to append

Returns: Element parent

-

Element.asPX(attr, [value])

+

Element.asPX(attr, [value])

Return given attribute of the element as a px value. (Not %, em, etc)

Parameters

  1. attr @@ -81,7 +81,7 @@ attribute value

Returns: Element result of query selection

-

Element.attr(…)

+

Element.attr(…)

Gets or sets given attributes of the element

Parameters

  1. params @@ -106,7 +106,7 @@ }); console.log(el.attr("fill")); // “#fc0”
-

Element.before(el)

+

Element.before(el)

Inserts given element before the current one.

Parameters

  1. el @@ -122,11 +122,11 @@ console.log(el.attr("fill")); // “#fc0” handler for the event

Returns: object Element

-

Element.clone()

-

Creates <use> element linked to the current element. +

Element.clone()

+

Creates clone of the element and inserts it after the element.

-

Returns: Element <use> element

-

Element.data(key, [value])

+

Returns: Element the clone

+

Element.data(key, [value])

Adds or retrieves given value asociated with given key. See also Element.removeData

@@ -159,7 +159,7 @@ See also Element.removeData handler for the event

Returns: object Element

-

Element.drag(onmove, onstart, onend, [mcontext], [scontext], [econtext])

+

Element.drag(onmove, onstart, onend, [mcontext], [scontext], [econtext])

Adds event handlers for drag of the element.

Parameters

  1. onmove @@ -207,7 +207,7 @@ See also Element.removeData
    1. eventobjectDOM event object

    Returns: object Element

    -

Element.getBBox()

+

Element.getBBox()

Returns bounding box descriptor for the given element.

Returns: object bounding box descriptor:

@@ -227,7 +227,7 @@ See also Element.removeData
  • y2:numbery of the right side,
  • y:numbery of the left side
  • }
  • -

    Element.getPointAtLength(length)

    +

    Element.getPointAtLength(length)

    Return coordinates of the point located at the given length on the given path. Only works for element of “path” type.

    Parameters

    1. length @@ -239,7 +239,7 @@ See also Element.removeData
    2. y:numbery coordinate
    3. alpha:numberangle of derivative
  • }
  • -

    Element.getSubpath(from, to)

    +

    Element.getSubpath(from, to)

    Return subpath of a given element from given length to given length. Only works for element of “path” type.

    Parameters

    1. from @@ -250,11 +250,11 @@ See also Element.removeData position of the end of the segment

    Returns: string pathstring for the segment

    -

    Element.getTotalLength()

    +

    Element.getTotalLength()

    Returns length of the path in pixels. Only works for element of “path” type.

    Returns: number length.

    -

    Element.hover(f_in, f_out, [icontext], [ocontext])

    +

    Element.hover(f_in, f_out, [icontext], [ocontext])

    Adds event handlers for hover for the element.

    Parameters

    1. f_in @@ -273,7 +273,7 @@ See also Element.removeData context for hover out handler

    Returns: object Element

    -

    Element.inAnim()

    +

    Element.inAnim()

    Returns an array of animations element currently in

    Returns: object in format

    @@ -282,7 +282,7 @@ See also Element.removeData
  • statusfunctiongets or sets the status of the animation,
  • stopfunctionstops the animation
  • }
  • -

    Element.insertAfter(el)

    +

    Element.insertAfter(el)

    Inserts the element after the given one.

    Parameters

    1. el @@ -290,7 +290,7 @@ See also Element.removeData element next to whom insert to

    Returns: Element parent

    -

    Element.insertBefore(el)

    +

    Element.insertBefore(el)

    Inserts the element after the given one.

    Parameters

    1. el @@ -298,7 +298,7 @@ See also Element.removeData element next to whom insert to

    Returns: Element parent

    -

    Element.marker(x, y, width, height, refX, refY)

    +

    Element.marker(x, y, width, height, refX, refY)

    Creates <marker> element from the current element. To create a marker you have to specify the bounding rect and reference point:

    @@ -364,18 +364,18 @@ To create a marker you have to specify the bounding rect and reference point: handler for the event

    Returns: object Element

    -

    Element.onDragOver(f)

    +

    Element.onDragOver(f)

    Shortcut for assigning event handler for drag.over.<id> event, where id is id of the element (see Element.id).

    Parameters

    1. f function handler for event, first argument would be the element you are dragging over
    -

    Element.parent()

    +

    Element.parent()

    Returns parent of the element

    Returns: Element parent

    -

    Element.pattern(x, y, width, height)

    +

    Element.pattern(x, y, width, height)

    Creates <pattern> element from the current element. To create a pattern you have to specify the pattern rect:

    @@ -405,7 +405,7 @@ c.attr({ fill: p });
    -

    Element.prepend(el)

    +

    Element.prepend(el)

    Prepends given element to current one.

    Parameters

    1. el @@ -413,10 +413,10 @@ c.attr({ element to prepend

    Returns: Element parent

    -

    Element.remove()

    +

    Element.remove()

    Removes element from the DOM

    -

    Element.removeData([key])

    +

    Element.removeData([key])

    Removes value associated with an element by given key. If key is not provided, removes all the data of the element.

    @@ -426,7 +426,7 @@ If key is not provided, removes all the data of the element. key

    Returns: object Element

    -

    Element.select(query)

    +

    Element.select(query)

    Applies CSS selector with the element as a parent and returns the result as an Element.

    Parameters

    1. query @@ -434,7 +434,7 @@ If key is not provided, removes all the data of the element. CSS selector

    Returns: Element result of query selection

    -

    Element.selectAll(query)

    +

    Element.selectAll(query)

    Applies CSS selector with the element as a parent and returns the result as a set or array of elements.

    Parameters

    1. query @@ -442,7 +442,7 @@ If key is not provided, removes all the data of the element. CSS selector

    Returns: Set array result of query selection

    -

    Element.stop()

    +

    Element.stop()

    Stops all the animations of the current element.

    Returns: Element the element

    @@ -478,7 +478,7 @@ If key is not provided, removes all the data of the element. handler for the event

    Returns: object Element

    -

    Element.transform(tstr)

    +

    Element.transform(tstr)

    Gets or sets transformation of the element

    Parameters

    1. tstr @@ -513,10 +513,10 @@ If key is not provided, removes all the data of the element. handler for the event

    Returns: object Element

    -

    Element.undrag()

    +

    Element.undrag()

    Removes all drag event handlers from given element.

    -

    Element.unhover(f_in, f_out)

    +

    Element.unhover(f_in, f_out)

    Removes event handlers for hover for the element.

    Parameters

    1. f_in @@ -599,15 +599,15 @@ If key is not provided, removes all the data of the element. handler for the event

    Returns: object Element

    -

    Element.use()

    +

    Element.use()

    Creates <use> element linked to the current element.

    Returns: Element <use> element

    Fragment

    -

    Fragment.select()

    +

    Fragment.select()

    Fragment.selectAll()

    +

    Fragment.selectAll()

    Matrix

    @@ -725,7 +725,7 @@ If key is not provided, removes all the data of the element.

    Returns: number y

    Paper

    -

    Paper.circle(x, y, r)

    +

    Paper.circle(x, y, r)

    Draws a circle.

    Parameters

    1. x @@ -741,7 +741,7 @@ If key is not provided, removes all the data of the element.

      Returns: object Element object with type “circle”

      Usage

      var c = paper.circle(50, 50, 40);
       
      -

    Paper.el(name, attr)

    +

    Paper.el(name, attr)

    Creates element on paper with a given name and no attributes.

    Parameters

    1. name @@ -759,7 +759,7 @@ var c = paper.el("circle").attr({ r: 10 });
    -

    Paper.ellipse(x, y, rx, ry)

    +

    Paper.ellipse(x, y, rx, ry)

    Draws an ellipse.

    Parameters

    1. x @@ -833,7 +833,7 @@ var c = paper.el("circle").attr({ filter: f });
    -

    Paper.g([varargs])

    +

    Paper.g([varargs])

    Makes a group element.

    Parameters

    1. varargs @@ -853,7 +853,7 @@ var c = paper.el("circle").attr({ g = paper.g(); g.add(c2, c1);
    -

    Paper.gradient(gradient)

    +

    Paper.gradient(gradient)

    Creates a gradient element.

    Parameters

    1. gradient @@ -891,10 +891,10 @@ through red at 25% to white. });

    Returns: object Element object with type “gradient”

    -

    Paper.group()

    +

    Paper.group()

    See Paper.g

    -

    Paper.image(src, x, y, width, height)

    +

    Paper.image(src, x, y, width, height)

    Embeds an image into the surface.

    Parameters

    1. src @@ -937,7 +937,7 @@ through red at 25% to white.

      Returns: object Element object with type “image”

      Usage

      var c = paper.image("apple.png", 10, 10, 80, 80);
       
      -

    Paper.line(x1, y1, x2, y2)

    +

    Paper.line(x1, y1, x2, y2)

    Draws a line.

    Parameters

    1. x1 @@ -956,7 +956,7 @@ through red at 25% to white.

      Returns: object Element object with type “line”

      Usage

      var t1 = paper.line(50, 50, 100, 100);
       
      -

    Paper.path([pathString])

    +

    Paper.path([pathString])

    Creates a path element by given path data string.

    Parameters

    1. pathString @@ -991,10 +991,10 @@ Note: there is a special case when path consist of just three commands: “M10,1 // draw a diagonal line: // move to 10,10, line to 90,90
    -

    Paper.polygon()

    +

    Paper.polygon()

    Draws a polygon. See Paper.polyline

    -

    Paper.polyline(…)

    +

    Paper.polyline(…)

    Draws a polyline.

    Parameters

    1. points @@ -1011,7 +1011,7 @@ Note: there is a special case when path consist of just three commands: “M10,1

      Usage

      var p1 = paper.polyline([10, 10, 100, 100]);
       var p2 = paper.polyline(10, 10, 100, 100);
       
      -

    Paper.rect(x, y, width, height, [rx], [ry])

    +

    Paper.rect(x, y, width, height, [rx], [ry])

    Draws a rectangle.

    @@ -1042,7 +1042,7 @@ var c = paper.rect(10, 10, 50, 50); // rectangle with rounded corners var c = paper.rect(40, 40, 50, 50, 10);
    -

    Paper.text(x, y, text)

    +

    Paper.text(x, y, text)

    Draws a text string.

    Parameters

    1. x @@ -1059,7 +1059,7 @@ var c = paper.rect(40, 40, 50, 50, 10);

      Usage

      var t1 = paper.text(50, 50, "Savage");
       var t2 = paper.text(50, 50, ["S","a","v","a","g","e"]);
       
      -

    Paper.toString()

    +

    Paper.toString()

    Returns SVG code of the Paper.

    Returns: string SVG code of the Paper.

    @@ -1094,7 +1094,7 @@ Returns matrix based on given parameters.  

    Returns: object Matrix

    -

    Savage.ajax(…)

    +

    Savage.ajax(…)

    Simple implementation of Ajax.

    Parameters

    1. url @@ -1125,7 +1125,7 @@ Returns matrix based on given parameters. scope of callback

    Returns: XMLHttpRequest XMLHttpRequest (just in case)

    -

    Savage.animate(from, to, setter, ms, [easing], [callback])

    +

    Savage.animate(from, to, setter, ms, [easing], [callback])

    Runs generic animation of one number into another with a caring function.

    Parameters

    1. from @@ -1157,7 +1157,7 @@ Returns matrix based on given parameters.
    2. statusfunctiongets or sets the status of the animation,
    3. stopfunctionstops the animation
  • }
  • -

    Savage.animation(attr, ms, [easing], [callback])

    +

    Savage.animation(attr, ms, [easing], [callback])

    Creates animation object.

    Parameters

    1. attr @@ -1202,7 +1202,7 @@ Returns matrix based on given parameters. angle in radians

    Returns: number angle in degrees.

    -

    Savage.findDotsAtSegment(p1x, p1y, c1x, c1y, c2x, c2y, p2x, p2y, t)

    +

    Savage.findDotsAtSegment(p1x, p1y, c1x, c1y, c2x, c2y, p2x, p2y, t)

    Utility method Find dot coordinates on the given cubic bezier curve at the given t.

    @@ -1269,7 +1269,7 @@ paper.path(Savage.format("M{x},{y}h{dim.width}v{dim.height}h{dim['negative width } }));
    -

    Savage.fragment(varargs)

    +

    Savage.fragment(varargs)

    Creates DOM fragment from given list of elements or strings

    Parameters

    1. varargs @@ -1379,7 +1379,7 @@ paper.path(Savage.format("M{x},{y}h{dim.width}v{dim.height}h{dim['negative width name of the type, i.e. “string”, “function”, “number”, etc.

    Returns: boolean is given value is of given type

    -

    Savage.load(url, callback, [scope])

    +

    Savage.load(url, callback, [scope])

    Loads external SVG file as a Fragment. For more advanced AJAX see Savage.ajax.

    Parameters

    1. url @@ -1393,7 +1393,7 @@ paper.path(Savage.format("M{x},{y}h{dim.width}v{dim.height}h{dim['negative width object scope of callback
    -

    Savage.parse(svg)

    +

    Savage.parse(svg)

    Parses SVG fragment and converts it into Fragment.

    Parameters

    1. svg @@ -1420,7 +1420,7 @@ Parses given path string into an array of transformations.

    Returns: array array of transformations.

    Savage.path

    -

    Savage.path.bezierBBox(…)

    +

    Savage.path.bezierBBox(…)

    Utility method Return bounding box of a given cubic bezier curve

    @@ -1461,7 +1461,7 @@ Return bounding box of a given cubic bezier curve
  • }
  • max: {
    1. x:numberx coordinate of the right point
    2. y:numbery coordinate of the bottom point
  • }
  • }
  • -

    Savage.path.getPointAtLength(path, length)

    +

    Savage.path.getPointAtLength(path, length)

    Return coordinates of the point located at the given length on the given path.

    Parameters

    1. path @@ -1476,7 +1476,7 @@ Return bounding box of a given cubic bezier curve
    2. y:numbery coordinate
    3. alpha:numberangle of derivative
  • }
  • -

    Savage.path.getSubpath(path, from, to)

    +

    Savage.path.getSubpath(path, from, to)

    Return subpath of a given path from given length to given length.

    Parameters

    1. path @@ -1490,7 +1490,7 @@ Return bounding box of a given cubic bezier curve position of the end of the segment

    Returns: string pathstring for the segment

    -

    Savage.path.getTotalLength(path)

    +

    Savage.path.getTotalLength(path)

    Returns length of the given path in pixels.

    Parameters

    1. path @@ -1498,7 +1498,7 @@ Return bounding box of a given cubic bezier curve SVG path string.

    Returns: number length.

    -

    Savage.path.intersection(path1, path2)

    +

    Savage.path.intersection(path1, path2)

    Utility method Finds intersections of two paths

    @@ -1519,7 +1519,7 @@ Finds intersections of two paths
  • bez1:arrayeight coordinates representing beziér curve for the segment of path1
  • bez2:arrayeight coordinates representing beziér curve for the segment of path2
  • }
  • ] -
  • Savage.path.isBBoxIntersect(bbox1, bbox2)

    +

    Savage.path.isBBoxIntersect(bbox1, bbox2)

    Utility method Returns true if two bounding boxes intersect

    @@ -1531,7 +1531,7 @@ Returns true if two bounding boxes intersect second bounding box

    Returns: boolean true if they intersect

    -

    Savage.path.isPointInside(path, x, y)

    +

    Savage.path.isPointInside(path, x, y)

    Utility method Returns true if given point is inside a given closed path.

    @@ -1546,7 +1546,7 @@ Returns true if given point is inside a given closed path. y of the point

    Returns: boolean true, if point is inside the path

    -

    Savage.path.isPointInsideBBox(bbox, x, y)

    +

    Savage.path.isPointInsideBBox(bbox, x, y)

    Utility method Returns true if given point is inside bounding box.

    @@ -1561,7 +1561,7 @@ Returns true if given point is inside bounding box. y coordinate of the point

    Returns: boolean true if point inside

    -

    Savage.path.map(path, matrix)

    +

    Savage.path.map(path, matrix)

    Transform the path string with given matrix.

    Parameters

    1. path @@ -1572,7 +1572,7 @@ Returns true if given point is inside bounding box. see Matrix

    Returns: string transformed path string

    -

    Savage.path.toAbsolute(path)

    +

    Savage.path.toAbsolute(path)

    Utility method Converts path coordinates into absolute values.

    @@ -1581,7 +1581,7 @@ Converts path coordinates into absolute values. path string

    Returns: array path string

    -

    Savage.path.toCubic(pathString)

    +

    Savage.path.toCubic(pathString)

    Utility method Converts path to a new path where all segments are cubic bezier curves.

    @@ -1590,7 +1590,7 @@ Converts path to a new path where all segments are cubic bezier curves. path string or array of segments

    Returns: array array of segments.

    -

    Savage.path.toRelative(path)

    +

    Savage.path.toRelative(path)

    Utility method Converts path coordinates into relative values.

    @@ -1599,7 +1599,7 @@ Converts path coordinates into relative values. path string

    Returns: array path string

    -

    Savage.pathBBox(path)

    +

    Savage.pathBBox(path)

    Utility method Return bounding box of a given path

    @@ -1673,7 +1673,7 @@ Return bounding box of a given path
  • snumbersaturation
  • lnumberluminosity
  • }
  • -

    Savage.select(query)

    +

    Savage.select(query)

    Wraps DOM element specified by CSS selector as Element

    Parameters

    1. query @@ -1681,7 +1681,7 @@ Return bounding box of a given path CSS selector of the element

    Returns: Element

    -

    Savage.selectAll(query)

    +

    Savage.selectAll(query)

    Wraps DOM elements specified by CSS selector as set or array of Element

    Parameters

    1. query diff --git a/src/svg.js b/src/svg.js index c6d5089..1cfbd19 100644 --- a/src/svg.js +++ b/src/svg.js @@ -1724,9 +1724,9 @@ function arrayFirstValue(arr) { * Element.clone [ method ] ** - * Creates `` element linked to the current element. + * Creates clone of the element and inserts it after the element. ** - = (Element) `` element + = (Element) the clone \*/ elproto.clone = function () { var clone = wrap(this.node.cloneNode(true));