summaryrefslogtreecommitdiffstats
path: root/public
Commit message (Expand)AuthorAgeFilesLines
* Don't warn users about *every* dirty form (#3707)Gerben2018-03-231-2/+5
* Add label descriptions (#3662)Lauris BH2018-03-133-1/+13
* Added issue search via api (#3612)kolaente2018-03-071-0/+6
* Make columns in split view of the same width (#3619)Morgan Bazalgette2018-03-072-32/+45
* Add Attachment API (#3478)Jonas Franz2018-03-061-1/+387
* Use Segoe UI for Latin characters before falling back to YaHei (#3616)Mahmoud Al-Qudsi2018-03-042-2/+2
* Rework special link parsing in the post-processing of markup (#3354)Morgan Bazalgette2018-02-273-68/+0
* Fix checklist padding (#3460)modmew82018-02-062-15/+19
* Emoji Autocomplete (#3433)modmew82018-02-035-17/+32
* Fix Delete repository message (#3260)muhfaris2018-01-151-1/+4
* Add Pull Request merge options - Ignore white-space for conflict checking, Re...Lauris BH2018-01-051-0/+22
* Fix swagger docs (#3300)Ethan Koenig2018-01-041-155/+6
* Added progressbar for issues (#1146). (#3171)modmew82018-01-032-1/+15
* Responsive view (#2750)Morgan Bazalgette2017-12-308-131/+229
* Improve suppressed diff boxes (#3193)silverwind2017-12-143-2/+5
* Mention completion for issue editor. (#3136)harry2017-12-113-0/+43
* Rework button styles on repo and commit page (#3104)silverwind2017-12-072-6/+8
* Delete a user's public key via admin api (closes #3014) (#3059)Vlad Temian2017-12-061-5/+196
* Fix reaction possition when there is attachments (#3099)Lauris BH2017-12-061-1/+7
* fix button heights on commits page (#3091)silverwind2017-12-052-6/+13
* Add reactions to issues/PR and comments (#2856)Lauris BH2017-12-043-2/+88
* Remove box-shadow from UI, fix dashboard issue (#3065)silverwind2017-12-033-1/+12
* Convert tabs to spaces in .less files (#3064)silverwind2017-12-0212-1357/+1357
* Fix misalignment issue in repo header (#3062)silverwind2017-12-022-3/+3
* Dashboard: Fix line height problem in issue titles (#3054)silverwind2017-12-022-2/+1
* Expandable commit bodies (#2980)Sondre Nilsen2017-11-303-1/+13
* Add fingerprint to ssh key endpoints. (#3009)Vlad Temian2017-11-281-1/+5
* Update gitgraph.js to fix blurry commit graph on HiDPI screens (#2957)Michael Kuhn2017-11-232-4/+21
* Add dingtalk webhook (#2777)Lunny Xiao2017-11-211-0/+0
* Fix comment API paths (#2813)Ethan Koenig2017-11-201-85/+186
* Fix API status code for hook creation (#2814)Ethan Koenig2017-11-201-1/+1
* Page parameter for repo search API (#2915)Ethan Koenig2017-11-151-3/+9
* Update swagger documentation (#2899)Ethan Koenig2017-11-131-1184/+5297
* Fix adding a new authentication source after selecting OAuth (#2889)Shaun2017-11-121-1/+1
* Fix attachments icon size on zoom in/out (#2853)Jakub2017-11-052-2/+2
* Use custom search for each filter type in dashboard (#2343)Morlinest2017-11-011-12/+52
* Add Safari pinned tab icon (#2799)Bastian Rinsche2017-10-281-0/+1
* Code/repo search (#2582)Ethan Koenig2017-10-272-3/+18
* Add wrapping to long diff lines (#2789)Lauris BH2017-10-273-1717/+1721
* Add search mode option to /api/repo/search (#2756)Morlinest2017-10-271-1/+18
* Add branch overiew page (#2108)Bwko2017-10-264-25/+68
* Fix emojify image URL (#2769)Lauris BH2017-10-231-1/+1
* Fix activity css conflit with semantic ui (#2758)Lauris BH2017-10-212-2/+2
* Move swagger-ui under /api/v1 (#2746)Antoine GIRARD2017-10-219-174/+130
* Fix IE unsupported javascript construction (#2736)Lauris BH2017-10-191-2/+2
* Render plain text README.txt monospaced (#2721)Jonas Franz2017-10-172-1/+5
* Create new branch from branch selection dropdown (#2130)Lauris BH2017-10-153-13/+198
* Add Activity page to repository (#2674)Lauris BH2017-10-153-2/+45
* Use Semantic UI's Search component for user and repo search (#2636)harry2017-10-033-101/+45
* Compress css with nodejs (#2580)Morlinest2017-09-241-1/+1
alic } /* Name.Label */ .highlight .nn { color: #bb0066; font-weight: bold } /* Name.Namespace */ .highlight .py { color: #336699; font-weight: bold } /* Name.Property */ .highlight .nt { color: #bb0066; font-weight: bold } /* Name.Tag */ .highlight .nv { color: #336699 } /* Name.Variable */ .highlight .ow { color: #008800 } /* Operator.Word */ .highlight .w { color: #bbbbbb } /* Text.Whitespace */ .highlight .mb { color: #0000DD; font-weight: bold } /* Literal.Number.Bin */ .highlight .mf { color: #0000DD; font-weight: bold } /* Literal.Number.Float */ .highlight .mh { color: #0000DD; font-weight: bold } /* Literal.Number.Hex */ .highlight .mi { color: #0000DD; font-weight: bold } /* Literal.Number.Integer */ .highlight .mo { color: #0000DD; font-weight: bold } /* Literal.Number.Oct */ .highlight .sa { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Affix */ .highlight .sb { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Backtick */ .highlight .sc { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Char */ .highlight .dl { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Delimiter */ .highlight .sd { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Doc */ .highlight .s2 { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Double */ .highlight .se { color: #0044dd; background-color: #fff0f0 } /* Literal.String.Escape */ .highlight .sh { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Heredoc */ .highlight .si { color: #3333bb; background-color: #fff0f0 } /* Literal.String.Interpol */ .highlight .sx { color: #22bb22; background-color: #f0fff0 } /* Literal.String.Other */ .highlight .sr { color: #008800; background-color: #fff0ff } /* Literal.String.Regex */ .highlight .s1 { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Single */ .highlight .ss { color: #aa6600; background-color: #fff0f0 } /* Literal.String.Symbol */ .highlight .bp { color: #003388 } /* Name.Builtin.Pseudo */ .highlight .fm { color: #0066bb; font-weight: bold } /* Name.Function.Magic */ .highlight .vc { color: #336699 } /* Name.Variable.Class */ .highlight .vg { color: #dd7700 } /* Name.Variable.Global */ .highlight .vi { color: #3333bb } /* Name.Variable.Instance */ .highlight .vm { color: #336699 } /* Name.Variable.Magic */ .highlight .il { color: #0000DD; font-weight: bold } /* Literal.Number.Integer.Long */
# Svg.js

Svg.js is a lightweight (3k gzipped) library for manipulating SVG.

Svg.js is licensed under the terms of the MIT License.


## Usage

### Create a SVG document

Use the `svg()` function to create a SVG document within a given html element:

```javascript
var draw = svg('paper').size(300, 300);
var rect = draw.rect(100, 100).attr({ fill: '#f06' });
```
The first argument can either be an id of the element or the selected element itself.
This will generate the following output:

```html
<div id="paper">
	<svg xmlns="http://www.w3.org/2000/svg" version="1.1" xlink="http://www.w3.org/1999/xlink" width="300" height="300">
		<rect width="100" height="100" fill="#f06"></rect>
	</svg>
</div>
```
By default the svg canvas follows the dimensions of its parent, in this case `#paper`:
```javascript
var draw = svg('paper').size('100%', '100%');
```


## Elements

### Rect
Rects have two arguments, their `width` and `height`:

```javascript
var text = draw.rect(100, 100);
```


### Ellipse
Ellipses, like rects, have two arguments, their `width` and `height`:

```javascript
var ellipse = draw.ellipse(100, 100);
```

### Circle
The only argument necessary for a circle is the diameter:

```javascript
var circle = draw.circle(100);
```

_Note that this generates an `<ellipse>` element rather than a `<circle>`. This choice has been made to keep the size of the library down._


### Polyline
The polyline element defines a set of connected straight line segments. Typically, polyline elements define open shapes:

```javascript
// polyline(x1, y1, x2, y2)
var polyline = draw.polyline('10,20 30,40 50,60');
```

Polyline strings consist of a list of points separated by spaces: `x,y x,y x,y`.

_Note that the svg `<line>` element is not implemented. Therefore you might want to use the `polyline()` method to create a line._


### Polygon
The polygon element, unlike the polyline element, defines a closed shape consisting of a set of connected straight line segments:

```javascript
// polyline('x,y x,y x,y')
var polygon = draw.polygon('10,20 30,40 50,60');
```

Polygon strings are exactly the same as polyline strings. There is no need to close the shape as the first and last point will be automatically connected.


### Path
The path string is similar to the polygon string but much more complex in order to support curves:

```javascript
// polyline('path data')
var path = draw.path('M10,20L30,40');
```

For more details on path data strings, please refer to the SVG documentation:
http://www.w3.org/TR/SVG/paths.html#PathData


### Image
When creating images the `width` and `height` values should be defined:

```javascript
// image(src, width, height)
var image = draw.image('/path/to/image.jpg', 200, 200).move(100, 100);
```


### Text
The first argument of a text element is the actual text content:
```javascript
var text = draw.text("svg\nto\nthe\npoint.").move(300, 0);
```
Changing text afterwards is also possible with the `text()` method:
```javascript
text.text('Brilliant!');
```
To get the raw text content:
```javascript
text.content;
```
The sugar.js module provides some syntax sugar specifically for this element type:
```javascript
text.font({
  family:   'Helvetica',
  size:     144,
  anchor:   'middle',
  leading:  1.5
});
```


## Manipulating elements

### Attributes
You can get and set an element's attributes directly using `attr()`:

```javascript
// get a single attribute
rect.attr('x');

// set a single attribute
rect.attr('x', 50);

// set multiple attributes at once
rect.attr({
  fill: '#f06',
  'fill-opacity': 0.5,
  stroke: '#000',
  'stroke-width': 10
});

// set an attribute with a namespace
rect.attr('x', 50, 'http://www.w3.org/2000/svg');
```


### Transform
With the `transform()` method elements can be scaled, rotated, translated and skewed:

```javascript
rect.transform({
  rotation: 45,
  cx:       100,
  cy:       100
});
```

All available transformations are:

```javascript
rect.transform({
  x:        [translation on x-axis],
  y:        [translation on y-axis],
  rotation: [degrees],
  cx:       [x rotation point],
  cy:       [y rotation point],
  scaleX:   [scaling on x-axis],
  scaleX:   [scaling on y-axis],
  skewX:    [skewing on x-axis],
  skewY:    [skewing on y-axis]
});
```

Important: matrix transformations are not yet supported.


### Move 
Move the element to a given `x` and `y` position by its upper left corner:

```javascript
rect.move(200, 350);
```

Note that you can also use the following code to move elements around:

```javascript
rect.attr({ x: 20, y: 60 });
``` 

Although `move()` is much more convenient because it will always use the upper left corner as the position reference, whereas with using `attr()` the `x` and `y` reference differ between element types. For example, rect uses the upper left corner with the `x` and `y` attributes, circle and ellipse use their center with the `cx` and `cy` attributes and thereby simply ignoring the `x` and `y` values you might assign.


### Size
Set the size of an element by a given `width` and `height`:

```javascript
rect.size(200, 300);
```

Same as with `move()` the size of an element could be set by using `attr()`. But because every type of element is handles its size differently the `size()` method is much more convenient.


### Center
This is an extra method to move an element by its center:

```javascript
rect.center(150, 150);
```


### Removing elements
Pretty straightforward:
```javascript
rect.remove();
```


## Bounding box

```javascript
path.bbox();
```
This will return an object with the following values:

```javascript
{ height: 20, width: 20, y: 20, x: 10, cx: 30, cy: 20 } 
```

As opposed to the native `getBBox()` method any translations used with the `transform()` method will be taken into account. 


## Syntax sugar
Fill and stroke are used quite often. Therefore two convenience methods are provided:

### Fill
The `fill()` method is a pretty alternative to the `attr()` method:
```javascript
rect.fill({ color: '#f06', opacity: 0.6 });
```

### Stroke
The `stroke()` method is similar to `fill()`:

```javascript
rect.stroke({ color: '#f06', opacity: 0.6, width: 5 });
```

### Rotate
The `rotate()` method will automatically rotate elements according to the center of the element:

```javascript
// rotate(degrees)
rect.rotate(45);
```

Unless you also define a rotation point:

```javascript
// rotate(degrees, cx, cy)
rect.rotate(45, 100, 100);
```

### Skew
The `skew()` method will take an `x` and `y` value:

```javascript
// skew(x, y)
rect.skew(0, 45);
```

_This functionality requires the sugar.js module which is included in the default distribution._


## Clipping elements
Clipping elements can be done with either `clip()` or `clipTo()`.

Using `clip()` creates a clip path in the parents 'defs' node, and passes it to a block:

```javascript
rect.clip(function(clipPath) {
	clipPath.rect(80, 80).move(10, 10);
});
```

You can also reuse clip paths for multiple elements using `clipTo()`.
```javascript
var clipPath = doc.defs().clip();
clipRect = clipPath.rect(80, 80).move(10, 10);
rect.clipTo(clipPath);
```

_This functionality requires the clip.js module which is included in the default distribution._


## Arranging elements
You can arrange elements within their parent SVG document using the following methods:

```javascript
// move element to the front
rect.front();

// move element to the back
rect.back();

// move element one step forward
rect.forward();

// move element one step backward
rect.backward();
```

_This functionality requires the arrange.js module which is included in the default distribution._


## Grouping elements
Grouping elements is useful if you want to transform a set of elements as if it were one. All element within a group maintain their position relative to the group they belong to. A group has all the same element methods as the root svg document: 
```javascript
var group = draw.group();
group.path('M10,20L30,40');
```
Existing elements from the svg document can also be added to a group:
```javascript
group.add(rect);
```

_This functionality requires the group.js module which is included in the default distribution._


## Gradients
There are linear and radial gradients. The linear gradient can be created like this:
```javascript
var gradient = draw.gradient('linear', function(stop) {
  stop.at({ offset: 0, color: '#333', opacity: 1 });
  stop.at({ offset: 100, color: '#fff', opacity: 1 });
});
```
The `offset` and `color` parameters are required for stops, `opacity` is optional. Offset is an integer expressed in percentage. To define the direction you can set from `x`, `y` and to `x`, `y`:
```javascript
gradient.from(0, 0).to(0, 100);
```
The from and to values are also expressed in percent.
Finally, to use the gradient on an element:
```javascript
rect.attr({ fill: gradient.fill() });
```
Radial gradients have a `radius()` method to define the outermost radius to where the inner color should develop:
```javascript
var gradient = draw.gradient('radial', function(stop) {
  stop.at({ offset: 0, color: '#333', opacity: 1 });
  stop.at({ offset: 100, color: '#fff', opacity: 1 });
});

gradient.from(50, 50).to(50, 50).radius(50);
```
A gradient can also be updated afterwards:
```javascript
gradient.update(function(stop) {
  stop.at({ offset: 10, color: '#333', opacity: 0.2 });
  stop.at({ offset: 90, color: '#f03', opacity: 1 });
});
```
And even a single stop can be updated:
```javascript
var s1, s2, s3;

draw.gradient('radial', function(stop) {
  s1 = stop.at({ offset: 0, color: '#000', opacity: 1 });
  s2 = stop.at({ offset: 50, color: '#f03', opacity: 1 });
  s3 = stop.at({ offset: 100, color: '#066', opacity: 1 });
});

s1.update({ offset: 10, color: '#0f0', opacity: 1 });
```

[W3Schools](http://www.w3schools.com/svg/svg_grad_linear.asp) has a great example page on how
[linear gradients](http://www.w3schools.com/svg/svg_grad_linear.asp) and
[radial gradients](http://www.w3schools.com/svg/svg_grad_radial.asp) work.

_This functionality requires the gradient.js module which is included in the default distribution._


## Extending functionality
Svg.js has a modular structure. It is very easy to add you own methods at different levels. Let's say we want to add a method to all shape types then we would add our method to SVG.Shape:
```javascript
SVG.extend(SVG.Shape, {
  
  paintRed: function() {
    return this.fill({ color: 'red' });
  }
  
});
```
Now all shapes will have the paintRed method available. Say we want to have the paintRed method on a circle apply a slightly different color:
```javascript
SVG.extend(SVG.Circle, {
  
  paintRed: function() {
    return this.fill({ color: 'orangered' });
  }
  
});
```
The complete inheritance stack for `SVG.Circle` is:

_SVG.Circle < SVG.Shape < SVG.Element_

The SVG document can be extended by using:

```javascript
SVG.extend(SVG.Doc, {
  
  paintAllPink: function() {
    var children = this.children();
    
    for (var i = 0, l = children.length; i < l; i++) {
      children[i].fill({ color: 'pink' });
    };
    
    return this;
  }
  
});
```




## Building
Starting out with the default distribution of svg.js is good. Although you might want to remove some modules to keep the size at minimum. 

You will need ruby, RubyGems, and rake installed on your system.

``` sh
# dependencies:
$ ruby -v
$ gem -v
$ rake -V

# required to generate the minified version:
$ gem install uglifier
```

Build Zepto by running `rake`:

``` sh
$ rake
Original version: 17.010k
Minified: 9.083k
Minified and gzipped: 2.760k, compression factor 6.163
```

The resulting files are:

1. `dist/svg.js`
2. `dist/svg.min.js`

To include optional modules and remove default ones, use the `concat` task. In
this example, 'clip' is removed, but 'group' and 'arrange' are added:

```
$ rake concat[-clip:group:arrange] dist
```

_The Rakefile has been borrowed from [madrobby's](https://github.com/madrobby) [Zepto](https://github.com/madrobby/zepto)_


## To-do
- Animation module (element animation, path tweens and easing)
- Draggable module (make elements and groups draggable)
- Shapes module (add preset shapes like star, n-gon)
- Text on path module (write text along paths)
- Nested SVG (add a svg document inside another svg document)



## Compatibility

### Desktop
- Firefox 3+
- Chrome 4+
- Safari 3.2+
- Opera 9+
- IE9 +

### Mobile
- iOS Safari 3.2+
- Android Browser 3+
- Opera Mobile 10+
- Chrome for Android 18+
- Firefox for Android 15+

Visit the [svg.js test page](http://svgjs.com/test) if you want to check compatibility with different browsers.

Important: this library is still in alpha, therefore the API might be subject to change in the course of development.