Commit 4ddabdd7 authored by Marin Jankovski's avatar Marin Jankovski

Merge branch 'master' of dev.gitlab.org:gitlab/gitlabhq

parents 9531e592 2fc6f8f2
......@@ -38,3 +38,4 @@ public/uploads.*
public/assets/
.envrc
dump.rdb
tags
......@@ -44,7 +44,7 @@ Please send a merge request with a tested solution or a merge request with a fai
1. **Output of checks**
* Results of GitLab [Application Check](doc/install/installation.md#check-application-status) (`sudo -u git -H bundle exec rake gitlab:check RAILS_ENV=production SANITIZE=true`); we will only investigate if the tests are passing
* Version of GitLab you are running; we will only investigate issues in the latest stable and development releases as per the [maintenance policy](MAINTENANCE.md)
* Add the last commit sha1 of the GitLab version you used to replicate the issue (obtainable from the help page)
* Add the last commit SHA-1 of the GitLab version you used to replicate the issue (obtainable from the help page)
* Describe your setup (use relevant parts from `sudo -u git -H bundle exec rake gitlab:env:info RAILS_ENV=production`)
1. **Possible fixes**: If you can, link to the line of code that might be responsible for the problem
......@@ -76,7 +76,7 @@ If you can, please submit a merge request with the fix or improvements including
The **official merge window** is in the beginning of the month from the 1st to the 7th day of the month. The best time to submit a MR and get feedback fast. Before this time the GitLab B.V. team is still dealing with work that is created by the monthly release such as assisting subscribers with upgrade issues, the release of Enterprise Edition and the upgrade of GitLab Cloud. After the 7th it is already getting closer to the release date of the next version. This means there is less time to fix the issues created by merging large new features.
Please keep the change in a single MR **as small as possible**. If you want to contribute a large feature think very hard what the minimum viable change is. Can you split functionality? Can you only submit the backend/API code? Can you start with a very simple UI? Can you do part of the refactor? The increased reviewability of small MR's that leads to higher code quality is more important to us than having a mimimal commit log. The smaller a MR is the more likely it is it will be merged (quickly), after that you can send more MR's to enhance it.
Please keep the change in a single MR **as small as possible**. If you want to contribute a large feature think very hard what the minimum viable change is. Can you split functionality? Can you only submit the backend/API code? Can you start with a very simple UI? Can you do part of the refactor? The increased reviewability of small MR's that leads to higher code quality is more important to us than having a minimal commit log. The smaller a MR is the more likely it is it will be merged (quickly), after that you can send more MR's to enhance it.
For examples of feedback on merge requests please look at already [closed merge requests](https://gitlab.com/gitlab-org/gitlab-ce/merge_requests?assignee_id=&label_name=&milestone_id=&scope=&sort=&state=closed). If you would like quick feedback on your merge request feel free to mention one of the Merge Marshalls of [the core-team](https://about.gitlab.com/core-team/). Please ensure that your merge request meets the following contribution acceptance criteria.
......@@ -86,7 +86,7 @@ For examples of feedback on merge requests please look at already [closed merge
1. Are there points in the code the reviewer needs to double check?
1. Why was this MR needed?
1. What are the relevant issue numbers / [Feature requests](http://feedback.gitlab.com/)?
1. Screenshots (If appropiate)
1. Screenshots (If appropriate)
## Contribution acceptance criteria
......@@ -115,4 +115,4 @@ For examples of feedback on merge requests please look at already [closed merge
1. [Shell commands](doc/development/shell_commands.md) created by GitLab contributors to enhance security
1. [Markdown](http://www.cirosantilli.com/markdown-styleguide)
This is also the style used by linting tools such as [Rubocop](https://github.com/bbatsov/rubocop), [PullReview](https://www.pullreview.com/) and [Hound CI](https://houndci.com).
This is also the style used by linting tools such as [RuboCop](https://github.com/bbatsov/rubocop), [PullReview](https://www.pullreview.com/) and [Hound CI](https://houndci.com).
......@@ -15,7 +15,6 @@
#= require jquery.atwho
#= require jquery.scrollTo
#= require jquery.blockUI
#= require jquery.sticky
#= require turbolinks
#= require jquery.turbolinks
#= require bootstrap
......
......@@ -34,8 +34,7 @@ class Diff
$.get(link, params, (response) =>
target.parent().replaceWith(response)
)
).ready =>
$(".diff-header").sticky {responsiveWidth:true, getWidthFrom: ".diff-file"}
)
lineNumbers: (line) ->
return ([0, 0]) unless line.children().length
......
class @ZenMode
@fullscreen_prefix = 'fullscreen_'
@ESC = 27
constructor: ->
@active_zen_area = null
@active_checkbox = null
@scroll_position = 0
$(window).scroll =>
if not @active_checkbox
@scroll_position = window.pageYOffset
$('body').on 'change', '.zennable input[type=checkbox]', (e) =>
checkbox = e.currentTarget;
checkbox = e.currentTarget
if checkbox.checked
# Disable other keyboard shortcuts in ZEN mode
Mousetrap.pause()
@udpateActiveZenArea(checkbox)
else
@exitZenMode()
$(document).on 'keydown', (e) =>
console.log("esc")
if e.keyCode is ZenMode.ESC
if e.keyCode is $.ui.keyCode.ESCAPE
@exitZenMode()
e.preventDefault()
$(window).on 'hashchange', @updateZenModeFromLocationHash
......@@ -27,7 +32,7 @@ class @ZenMode
@active_zen_area = @active_checkbox.parent().find('textarea')
@active_zen_area.focus()
window.location.hash = ZenMode.fullscreen_prefix + @active_checkbox.prop('id')
exitZenMode: =>
if @active_zen_area isnt null
Mousetrap.unpause()
......@@ -35,6 +40,7 @@ class @ZenMode
@active_zen_area = null
@active_checkbox = null
window.location.hash = ''
window.scrollTo(window.pageXOffset, @scroll_position)
checkboxFromLocationHash: (e) ->
id = $.trim(window.location.hash.replace('#' + ZenMode.fullscreen_prefix, ''))
......@@ -48,4 +54,4 @@ class @ZenMode
if checkbox
@udpateActiveZenArea(checkbox)
else
@exitZenMode()
@exitZenMode()
/**
* Styles that apply to both issues and merge requests.
*/
.issue-form, .merge-request-form {
.description {
height: 20em;
}
}
......@@ -40,7 +40,7 @@
.star-fork-buttons {
float: right;
width: 200px;
min-width: 200px;
font-size: 14px;
font-weight: bold;
......
......@@ -6,7 +6,7 @@
SSH keys allow you to establish a secure connection between your computer and GitLab
%br
Before you can add an SSH key you need to
= link_to "generate it", help_page_path("ssh", "README")
= link_to "generate it", help_page_path("ssh", "ssh")
%hr
......
......@@ -7,12 +7,8 @@
.form-group.issuable-description
= f.label :description, 'Description', class: 'control-label'
.col-sm-10
.zennable
%input#zen-toggle-comment{ tabindex: '-1', type: 'checkbox' }
.zen-backdrop
= f.text_area :description, rows: 14, class: 'form-control js-gfm-input markdown-area', placeholder: 'Leave a comment'
%label{ for: 'zen-toggle-comment', class: 'expand' } Edit in fullscreen
%label{ for: 'zen-toggle-comment', class: 'collapse' }
= render 'projects/zen', f: f, attr: :description,
classes: 'description form-control'
.col-sm-12.hint
.pull-left
Parsed with
......
.zennable
%input#zen-toggle-comment{ tabindex: '-1', type: 'checkbox' }
.zen-backdrop
- classes << ' js-gfm-input markdown-area'
= f.text_area attr, class: classes, placeholder: 'Leave a comment'
%label{ for: 'zen-toggle-comment', class: 'expand' } Edit in fullscreen
%label{ for: 'zen-toggle-comment', class: 'collapse' }
......@@ -21,12 +21,8 @@
.form-group
.light
= f.label :description, "Description"
.zennable
%input#zen-toggle-comment{ tabindex: '-1', type: 'checkbox' }
.zen-backdrop
= f.text_area :description, class: 'form-control js-gfm-input markdown-area', rows: 10, placeholder: 'Leave a comment'
%label{ for: 'zen-toggle-comment', class: 'expand' } Edit in fullscreen
%label{ for: 'zen-toggle-comment', class: 'collapse' }
= render 'projects/zen', f: f, attr: :description,
classes: 'description form-control'
.clearfix.hint
.pull-left Description is parsed with #{link_to "GitLab Flavored Markdown", help_page_path("markdown", "markdown"), target: '_blank'}.
.pull-right Attach images (JPG, PNG, GIF) by dragging & dropping or #{link_to "selecting them", '#', class: 'markdown-selector' }.
......
......@@ -14,13 +14,8 @@
Preview
%div
.note-write-holder
.zennable
%input#zen-toggle-comment{ tabindex: '-1', type: 'checkbox' }
.zen-backdrop
= f.text_area :note, size: 255, class: 'note_text js-note-text js-gfm-input markdown-area', placeholder: 'Leave a comment'
%label{ for: 'zen-toggle-comment', class: 'expand' } Edit in fullscreen
%label{ for: 'zen-toggle-comment', class: 'collapse' }
= render 'projects/zen', f: f, attr: :note,
classes: 'note_text js-note-text'
.light.clearfix
.pull-left Comments are parsed with #{link_to "GitLab Flavored Markdown", help_page_path("markdown", "markdown"),{ target: '_blank', tabindex: -1 }}
.pull-right Attach images (JPG, PNG, GIF) by dragging &amp; dropping or #{link_to "selecting them", '#', class: 'markdown-selector', tabindex: -1 }.
......
......@@ -3,3 +3,4 @@
- [Architecture](architecture.md) of GitLab
- [Shell commands](shell_commands.md) in the GitLab codebase
- [Rake tasks](rake_tasks.md) for development
- [CI setup](ci_setup.md) for testing GitLab
# CI setup
This document describes what services we use for testing GitLab and GitLab CI.
We currently use three CI services to test GitLab:
1. GitLab CI on [GitHost.io](https://gitlab-ce.githost.io/projects/2/) for the [GitLab.com repo](https://gitlab.com/gitlab-org/gitlab-ce)
2. GitLab CI at ci.gitlab.org to test the private GitLab B.V. repo at dev.gitlab.org
3. [Semephore](https://semaphoreapp.com/gitlabhq/gitlabhq/) for [GitHub.com repo](https://github.com/gitlabhq/gitlabhq)
| Software @ configuration being tested | GitLab CI (ci.gitlab.org) | GitLab CI (GitHost.io) | Semaphore |
|---------------------------------------|---------------------------|------------------------|-----------|
| GitLab CE @ MySQL | ✓ | ✓ | |
| GitLab CE @ PostgreSQL | | | ✓ |
| GitLab EE @ MySQL | ✓ | | |
| GitLab CI @ MySQL | ✓ | | |
| GitLab CI @ PostgreSQL | | | ✓ |
| GitLab CI Runner | ✓ | | ✓ |
| GitLab Shell | ✓ | | ✓ |
| GitLab Shell | ✓ | | ✓ |
We use [these build scripts](https://gitlab.com/gitlab-org/gitlab-ci/blob/master/doc/examples/build_script_gitlab_ce.md) for testing with GitLab CI.
# Build configuration on [Semaphore](https://semaphoreapp.com/gitlabhq/gitlabhq/) for testing the [GitHub.com repo](https://github.com/gitlabhq/gitlabhq)
Language: Ruby
Ruby verion: 2.1.2
database.yml: pg
Build commands
```bash
sudo apt-get install cmake libicu-dev -y (Setup)
bundle install --deployment --path vendor/bundle (Setup)
cp config/gitlab.yml.example config/gitlab.yml (Setup)
bundle exec rake db:create (Setup)
bundle exec rake spinach (Thread #1)
bundle exec rake spec (Thread #2)
```
Use rubygems mirror.
......@@ -139,7 +139,12 @@ We recommend using a PostgreSQL database. For MySQL check [MySQL setup guide](da
# Configure redis to use sockets
sudo cp /etc/redis/redis.conf /etc/redis/redis.conf.orig
sed -e 's/^# unixsocket /unixsocket /' -e 's/^port .*/port 0/' /etc/redis/redis.conf.orig | sudo tee /etc/redis/redis.conf
# Disable Redis listening on TCP by setting 'port' to 0
sed 's/^port .*/port 0/' /etc/redis/redis.conf.orig | sudo tee /etc/redis/redis.conf
# Enable Redis socket for default Debian / Ubuntu path
echo 'unixsocket /var/run/redis/redis.sock' | sudo tee -a /etc/redis/redis.conf
# Activate the changes to redis.conf
sudo service redis-server restart
......@@ -211,7 +216,7 @@ We recommend using a PostgreSQL database. For MySQL check [MySQL setup guide](da
# Configure Redis connection settings
sudo -u git -H cp config/resque.yml.example config/resque.yml
# Change the Redis socket path if necessary
# Change the Redis socket path if you are not using the default Debian / Ubuntu configuration
sudo -u git -H editor config/resque.yml
**Important Note:** Make sure to edit both `gitlab.yml` and `unicorn.rb` to match your setup.
......
......@@ -34,7 +34,7 @@ Please consider using a virtual machine to run GitLab.
GitLab requires Ruby (MRI) 2.0 or 2.1
You will have to use the standard MRI implementation of Ruby.
We love [JRuby](http://jruby.org/) and [Rubinius](http://rubini.us/)) but GitLab needs several Gems that have native extensions.
We love [JRuby](http://jruby.org/) and [Rubinius](http://rubini.us/) but GitLab needs several Gems that have native extensions.
## Hardware requirements
......
......@@ -27,11 +27,11 @@ If a user is a GitLab administrator they receive all permissions.
| Create new milestones | | | | ✓ | ✓ |
| Add new team members | | | | ✓ | ✓ |
| Push to protected branches | | | | ✓ | ✓ |
| Enable/Disable branch protection | | | | ✓ | ✓ |
| Enable/disable branch protection | | | | ✓ | ✓ |
| Rewrite/remove git tags | | | | ✓ | ✓ |
| Edit project | | | | ✓ | ✓ |
| Add Deploy Keys to project | | | | ✓ | ✓ |
| Configure Project Hooks | | | | ✓ | ✓ |
| Add deploy keys to project | | | | ✓ | ✓ |
| Configure project hooks | | | | ✓ | ✓ |
| Switch visibility level | | | | | ✓ |
| Transfer project to another namespace | | | | | ✓ |
| Remove project | | | | | ✓ |
......
......@@ -6,8 +6,8 @@
A backup creates an archive file that contains the database, all repositories and all attachments.
This archive will be saved in backup_path (see `config/gitlab.yml`).
The filename will be `[TIMESTAMP]_gitlab_backup.tar`. This timestamp can be used to restore an specific backup.
You can only restore a backup to exactly the same version of GitLab that you created it on, for example 7.2.1.
```
# omnibus-gitlab
......@@ -55,6 +55,8 @@ If you have a manual installation please consider backing up your gitlab.yml fil
## Restore a previously created backup
You can only restore a backup to exactly the same version of GitLab that you created it on, for example 7.2.1.
```
# omnibus-gitlab
sudo gitlab-rake gitlab:backup:restore
......
......@@ -113,7 +113,8 @@ Check if any of these changed since last release:
- <https://gitlab.com/gitlab-org/gitlab-ce/commits/master/config/unicorn.rb.example>
- <https://gitlab.com/gitlab-org/gitlab-ce/commits/master/config/database.yml.mysql>
- <https://gitlab.com/gitlab-org/gitlab-ce/commits/master/config/database.yml.postgresql>
- <https://gitlab.com/gitlab-org/gitlab-ce/blob/master/config/initializers/rack_attack.rb.example>
- <https://gitlab.com/gitlab-org/gitlab-ce/commits/master/config/initializers/rack_attack.rb.example>
- <https://gitlab.com/gitlab-org/gitlab-ce/commits/master/config/resque.yml.example>
#### 8. Need to update init script?
......@@ -149,6 +150,23 @@ Create an annotated tag that points to the version change commit:
git tag -a vx.x.0.rc1 -m 'Version x.x.0.rc1'
```
### **6. Create stable branches**
For GitLab EE, append `-ee` to the branch.
`x-x-stable-ee`
```
git checkout master
git pull
git checkout -b x-x-stable
git push <remote> x-x-stable
```
Now developers can use master for merging new features.
So you should use stable branch for future code chages related to release.
# **18th - Release RC1**
### **1. Update GitLab.com**
......@@ -222,11 +240,9 @@ Note: Merge CE into EE if needed.
- Change the VERSION file in `master` branch of the CE repository and commit and push.
- Change the VERSION file in `master` branch of the EE repository and commit and push.
### **2. Create x-x-stable branch and push to the repositories**
### **2. Push latest changes from x-x-stable branch to the repositories**
```
git checkout master
git pull
git checkout -b x-x-stable
git push <remote> x-x-stable
```
......
......@@ -2,3 +2,4 @@
- [Password length limits](password_length_limits.md)
- [Rack attack](rack_attack.md)
- [Information exclusivity](information_exclusivity.md)
# Information exclusivity
Git is a distributed version control system (DVCS).
This means that everyone that works with the source code has a local copy of the complete repository.
In GitLab every project member that is not a guest (so reporters, developers and masters) can clone the repository to get a local copy.
After obtaining this local copy the user can upload the full repository anywhere, including another project under their control or another server.
The consequense is that you can't build access controls that prevent the intentional sharing of source code by users that have access to the source code.
This is an inherent feature of a DVCS and all git management systems have this limitation.
Obviously you can take steps to prevent unintentional sharing and information destruction, this is why only some people are allowed to invite others and nobody can force push a protected branch.
......@@ -9,7 +9,7 @@ As of 6.1 issue numbers are project specific. This means all issues are renumber
## Editable labels
In GitLab 7.2 we replace Issue and Merge Request tags with labels, making it
possible to edit the label text and color. The characters '?', '&' and ',' are
possible to edit the label text and color. The characters `?`, `&` and `,` are
no longer allowed however so those will be removed from your tags during the
database migrations for GitLab 7.2.
......@@ -80,7 +80,6 @@ For GitLab Enterprise Edition:
sudo -u git -H git checkout 7-3-stable-ee
```
## 4. Install additional packages
```bash
......@@ -95,21 +94,22 @@ sudo apt-get install pkg-config cmake
# Configure redis to use sockets
sudo cp /etc/redis/redis.conf /etc/redis/redis.conf.orig
sed -e 's/^# unixsocket /unixsocket /' -e 's/^port .*/port 0/' /etc/redis/redis.conf.orig | sudo tee /etc/redis/redis.conf
# Disable Redis listening on TCP by setting 'port' to 0
sed 's/^port .*/port 0/' /etc/redis/redis.conf.orig | sudo tee /etc/redis/redis.conf
# Enable Redis socket for default Debian / Ubuntu path
echo 'unixsocket /var/run/redis/redis.sock' | sudo tee -a /etc/redis/redis.conf
# Activate the changes to redis.conf
sudo service redis-server restart
# Add git to the redis group
sudo usermod -aG redis git
cd /home/git/gitlab
# Configure Redis connection settings
sudo -u git -H cp config/resque.yml.example config/resque.yml
# Change the Redis socket path if necessary
# Change the Redis socket path if you are not using the default Debian / Ubuntu configuration
sudo -u git -H editor config/resque.yml
cd /home/git/gitlab-shell
# Configure gitlab-shell to use Redis sockets
sudo -u git -H sed -i 's|^ # socket.*| socket: /var/run/redis/redis.sock|' config.yml
sudo -u git -H sed -i 's|^ # socket.*| socket: /var/run/redis/redis.sock|' /home/git/gitlab-shell/config.yml
## 6. Update gitlab-shell
......@@ -148,7 +148,7 @@ sudo cp lib/support/init.d/gitlab /etc/init.d/gitlab
## 8. Update config files
TIP: to see what changed in gitlab.yml.example in this release use next command:
TIP: to see what changed in `gitlab.yml.example` in this release use next command:
```
git diff 6-0-stable:config/gitlab.yml.example 7-3-stable:config/gitlab.yml.example
......
......@@ -3,7 +3,7 @@
## Editable labels
In GitLab 7.2 we replace Issue and Merge Request tags with labels, making it
possible to edit the label text and color. The characters '?', '&' and ',' are
possible to edit the label text and color. The characters `?`, `&` and `,` are
no longer allowed however so those will be removed from your tags during the
database migrations for GitLab 7.2.
......@@ -46,7 +46,7 @@ sudo -u git -H git checkout 7-2-stable-ee
```bash
cd /home/git/gitlab-shell
sudo -u git -H git fetch
sudo -u git -H git checkout v1.9.7
sudo -u git -H git checkout v1.9.8
```
### 4. Install new system dependencies
......@@ -81,9 +81,9 @@ sudo cp lib/support/init.d/gitlab /etc/init.d/gitlab
### 6. Update config files
#### New configuration options for gitlab.yml
#### New configuration options for `gitlab.yml`
There are new configuration options available for gitlab.yml. View them with the command below and apply them to your current gitlab.yml.
There are new configuration options available for `gitlab.yml`. View them with the command below and apply them to your current `gitlab.yml`.
```
git diff 7-1-stable:config/gitlab.yml.example 7-2-stable:config/gitlab.yml.example
......
......@@ -70,21 +70,22 @@ sudo cp lib/support/init.d/gitlab /etc/init.d/gitlab
# Configure redis to use sockets
sudo cp /etc/redis/redis.conf /etc/redis/redis.conf.orig
sed -e 's/^# unixsocket /unixsocket /' -e 's/^port .*/port 0/' /etc/redis/redis.conf.orig | sudo tee /etc/redis/redis.conf
# Disable Redis listening on TCP by setting 'port' to 0
sed 's/^port .*/port 0/' /etc/redis/redis.conf.orig | sudo tee /etc/redis/redis.conf
# Enable Redis socket for default Debian / Ubuntu path
echo 'unixsocket /var/run/redis/redis.sock' | sudo tee -a /etc/redis/redis.conf
# Activate the changes to redis.conf
sudo service redis-server restart
# Add git to the redis group
sudo usermod -aG redis git
cd /home/git/gitlab
# Configure Redis connection settings
sudo -u git -H cp config/resque.yml.example config/resque.yml
# Change the Redis socket path if necessary
# Change the Redis socket path if you are not using the default Debian / Ubuntu configuration
sudo -u git -H editor config/resque.yml
cd /home/git/gitlab-shell
# Configure gitlab-shell to use Redis sockets
sudo -u git -H sed -i 's|^ # socket.*| socket: /var/run/redis/redis.sock|' config.yml
sudo -u git -H sed -i 's|^ # socket.*| socket: /var/run/redis/redis.sock|' /home/git/gitlab-shell/config.yml
### 6. Update config files
......@@ -96,15 +97,14 @@ There are new configuration options available for gitlab.yml. View them with the
git diff 7-2-stable:config/gitlab.yml.example 7-3-stable:config/gitlab.yml.example
```
* HTTP setups: Make `/etc/nginx/sites-available/nginx` the same as https://gitlab.com/gitlab-org/gitlab-ce/blob/7-3-stable/lib/support/nginx/gitlab but with your settings.
* HTTPS setups: Make `/etc/nginx/sites-available/nginx-ssl` the same as https://gitlab.com/gitlab-org/gitlab-ce/blob/7-3-stable/lib/support/nginx/gitlab-ssl but with your setting
Update rack attack middleware config
```
sudo -u git -H cp config/initializers/rack_attack.rb.example config/initializers/rack_attack.rb
# Use the default Unicorn socket backlog value of 1024
sudo -u git -H sed -i 's|^:backlog => 64|:backlog => 1024|' config/unicorn.rb
```
* HTTP setups: Make `/etc/nginx/sites-available/nginx` the same as https://gitlab.com/gitlab-org/gitlab-ce/blob/7-3-stable/lib/support/nginx/gitlab but with your settings.
* HTTPS setups: Make `/etc/nginx/sites-available/nginx-ssl` the same as https://gitlab.com/gitlab-org/gitlab-ce/blob/7-3-stable/lib/support/nginx/gitlab-ssl but with your setting
### 7. Start application
sudo service gitlab start
......
......@@ -124,12 +124,14 @@ Save the following file as `print_http_body.rb`.
```ruby
require 'webrick'
server = WEBrick::HTTPServer.new(Port: ARGV.first)
server = WEBrick::HTTPServer.new(:Port => ARGV.first)
server.mount_proc '/' do |req, res|
puts req.body
end
trap 'INT' do server.shutdown end
trap 'INT' do
server.shutdown
end
server.start
```
......
......@@ -13,7 +13,7 @@ Feature: Project Browse files
Scenario: I browse file content
Given I click on ".gitignore" file in repo
Then I should see it content
Then I should see its content
Scenario: I browse raw file
Given I visit blob file from repo
......
......@@ -20,7 +20,7 @@ class ProjectBrowseFiles < Spinach::FeatureSteps
click_link ".gitignore"
end
step 'I should see it content' do
step 'I should see its content' do
page.should have_content "*.rbc"
end
......
// Sticky Plugin v1.0.0 for jQuery
// =============
// Author: Anthony Garand
// Improvements by German M. Bravo (Kronuz) and Ruud Kamphuis (ruudk)
// Improvements by Leonardo C. Daronco (daronco)
// Created: 2/14/2011
// Date: 2/12/2012
// Website: http://labs.anthonygarand.com/sticky
// Description: Makes an element on the page stick on the screen as you scroll
// It will only set the 'top' and 'position' of your element, you
// might need to adjust the width in some cases.
(function($) {
var defaults = {
topSpacing: 0,
bottomSpacing: 0,
className: 'is-sticky',
wrapperClassName: 'sticky-wrapper',
center: false,
getWidthFrom: '',
responsiveWidth: false
},
$window = $(window),
$document = $(document),
sticked = [],
windowHeight = $window.height(),
scroller = function() {
var scrollTop = $window.scrollTop(),
documentHeight = $document.height(),
dwh = documentHeight - windowHeight,
extra = (scrollTop > dwh) ? dwh - scrollTop : 0;
for (var i = 0; i < sticked.length; i++) {
var s = sticked[i],
elementTop = s.stickyWrapper.offset().top,
etse = elementTop - s.topSpacing - extra;
if (scrollTop <= etse) {
if (s.currentTop !== null) {
s.stickyElement
.css('position', '')
.css('top', '');
s.stickyElement.trigger('sticky-end', [s]).parent().removeClass(s.className);
s.currentTop = null;
}
}
else {
var newTop = documentHeight - s.stickyElement.outerHeight()
- s.topSpacing - s.bottomSpacing - scrollTop - extra;
if (newTop < 0) {
newTop = newTop + s.topSpacing;
} else {
newTop = s.topSpacing;
}
if (s.currentTop != newTop) {
s.stickyElement
.css('position', 'fixed')
.css('top', newTop);
if (typeof s.getWidthFrom !== 'undefined') {
s.stickyElement.css('width', $(s.getWidthFrom).width());
}
s.stickyElement.trigger('sticky-start', [s]).parent().addClass(s.className);
s.currentTop = newTop;
}
}
}
},
resizer = function() {
windowHeight = $window.height();
for (var i = 0; i < sticked.length; i++) {
var s = sticked[i];
if (typeof s.getWidthFrom !== 'undefined' && s.responsiveWidth === true) {
s.stickyElement.css('width', $(s.getWidthFrom).width());
}
}
},
methods = {
init: function(options) {
var o = $.extend({}, defaults, options);
return this.each(function() {
var stickyElement = $(this);
var stickyId = stickyElement.attr('id');
var wrapperId = stickyId ? stickyId + '-' + defaults.wrapperClassName : defaults.wrapperClassName
var wrapper = $('<div></div>')
.attr('id', stickyId + '-sticky-wrapper')
.addClass(o.wrapperClassName);
stickyElement.wrapAll(wrapper);
if (o.center) {
stickyElement.parent().css({width:stickyElement.outerWidth(),marginLeft:"auto",marginRight:"auto"});
}
if (stickyElement.css("float") == "right") {
stickyElement.css({"float":"none"}).parent().css({"float":"right"});
}
var stickyWrapper = stickyElement.parent();
stickyWrapper.css('height', stickyElement.outerHeight());
sticked.push({
topSpacing: o.topSpacing,
bottomSpacing: o.bottomSpacing,
stickyElement: stickyElement,
currentTop: null,
stickyWrapper: stickyWrapper,
className: o.className,
getWidthFrom: o.getWidthFrom,
responsiveWidth: o.responsiveWidth
});
});
},
update: scroller,
unstick: function(options) {
return this.each(function() {
var unstickyElement = $(this);
var removeIdx = -1;
for (var i = 0; i < sticked.length; i++)
{
if (sticked[i].stickyElement.get(0) == unstickyElement.get(0))
{
removeIdx = i;
}
}
if(removeIdx != -1)
{
sticked.splice(removeIdx,1);
unstickyElement.unwrap();
unstickyElement.removeAttr('style');
}
});
}
};
// should be more efficient than using $window.scroll(scroller) and $window.resize(resizer):
if (window.addEventListener) {
window.addEventListener('scroll', scroller, false);
window.addEventListener('resize', resizer, false);
} else if (window.attachEvent) {
window.attachEvent('onscroll', scroller);
window.attachEvent('onresize', resizer);
}
$.fn.sticky = function(method) {
if (methods[method]) {
return methods[method].apply(this, Array.prototype.slice.call(arguments, 1));
} else if (typeof method === 'object' || !method ) {
return methods.init.apply( this, arguments );
} else {
$.error('Method ' + method + ' does not exist on jQuery.sticky');
}
};
$.fn.unstick = function(method) {
if (methods[method]) {
return methods[method].apply(this, Array.prototype.slice.call(arguments, 1));
} else if (typeof method === 'object' || !method ) {
return methods.unstick.apply( this, arguments );
} else {
$.error('Method ' + method + ' does not exist on jQuery.sticky');
}
};
$(function() {
setTimeout(scroller, 0);
});
})(jQuery);
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment