Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix bugs #221

Open
wants to merge 11 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
root = true

[*]
indent_style = tab
indent_size = 4
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true

[*.md]
trim_trailing_whitespace = false

[*.json]
indent_style = space
indent_size = 2
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
node_modules
7 changes: 7 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
language: node_js
node_js:
- "stable"
cache:
directories:
- node_modules
script: bash ./deploy.sh
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

*More [fiddle](http://jsfiddle.net/) demo links [below](#demos).*

ScrollToFixed
ScrollToFixed [![Build Status](https://travis-ci.org/Grawl/ScrollToFixed.svg?branch=master)](https://travis-ci.org/Grawl/ScrollToFixed)
==========================

This jQuery plugin is used to fix elements on the page (top, bottom, anywhere); however, it still allows the element to continue to move left or right with the horizontal scroll.
Expand Down
2 changes: 2 additions & 0 deletions build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#!/bin/bash
npm run gulp
90 changes: 90 additions & 0 deletions deploy.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
#!/bin/bash
# This is a Bash shell script to use with [Travis Continuous Integration](https://travis-ci.org)
# It will build your project as you will configure Travis CI, and if there will be any changes, it will push them into your repository as a commit. Basically, this script will push any added or removed files by your build process.
# For example: if you update `some-script.js`, you want to minify it and push as `some-script.min.js`. Travis CI can launch your build script on it's own server just after you push `some-script.js` and then it will push updated `some-script.min.js`.
# To use it, you have to authenticate on Travis CI and enable Continuous Integration for this project, then open settings and add some environment variables to allow Travis CI to push into your repository:
# `GIT_HOST` – server hostname, `github.com` by default
# `GIT_USER` – username
# `GIT_PASSWORD` – password
# Don't worry, [you can trust Travis](https://docs.travis-ci.com/user/environment-variables/#Defining-Variables-in-Repository-Settings)
# Also, you have to add `.travis.yml` file with this:

# script: bash ./deploy.sh

# Configuring Travis CI [is not hard](https://docs.travis-ci.com/user/getting-started/), just few lines and you are a pilot!

# And after, you can change this function to what you want to do to build your project:
function build {
bash ./build.sh
}

# I am using some Travis environment variables like `TRAVIS` or `TRAVIS_COMMIT` here, you can look their output in [Travis CI Documentation](https://docs.travis-ci.com/user/environment-variables/#Default-Environment-Variables)

set -e # Exit with nonzero exit code if anything fails
# set -x # Enable debug mode. It will print every executed line into log. Do not forget to clear any public logs after debug build that prints your sensitive data like passwords!
if [ ! "$TRAVIS" ]; then
echo "This script should work only on Travis CI server"
# Remove this code if you want to debug this script
exit 0
fi
# Pull requests shouldn't try to deploy, just build to verify
if [ "$TRAVIS_PULL_REQUEST" != "false" ]; then
echo "Should not deploy pull request; just doing a build."
build
exit 0
fi
SETTINGS_URL="https://travis-ci.org/${TRAVIS_REPO_SLUG}/settings"
if [ ! "$GIT_USER" ]; then
echo "Cannot push without git credentials: no user provided; set up GIT_USER environment variable in Travis CI project settings: ${SETTINGS_URL}"
# There is no reason to continue deploy without push – the target action of this script
exit 0
fi
if [ ! "$GIT_PASSWORD" ]; then
echo "Cannot push without git credentials: no password provided; set up GIT_PASSWORD environment variable in Travis CI project settings: ${SETTINGS_URL}"
# There is no reason to continue deploy without push – the target action of this script
exit 0
fi
if [ ! "$GIT_HOST" ]; then
echo "Cannot push without git credentials: no host provided; using GitHub.com as a default."
echo "You can set up GIT_HOST environment variable in Travis CI project settings: ${SETTINGS_URL}"
# You can skip defining this variable if your project are hosted on GitHub.com
GIT_HOST="github.com"
fi
if [ ! "$SOURCE_BRANCH" ]; then
echo "You are not provided a source git branch; using current Travis CI branch as a default."
echo "You can set up SOURCE_BRANCH environment variable in Travis CI project settings: ${SETTINGS_URL}"
# You can skip defining this variable if you want to deploy to the same branch
SOURCE_BRANCH=$TRAVIS_BRANCH
fi
if [ ! "$TARGET_BRANCH" ]; then
echo "You are not provided a target git branch; using current Travis CI branch as a default."
echo "You can set up TARGET_BRANCH environment variable in Travis CI project settings: ${SETTINGS_URL}"
# You can skip defining this variable if you want to deploy to the same branch
# TODO: add specific behaviour if SOURCE_BRANCH != TARGET_BRANCH (gh-pages for example)
TARGET_BRANCH=$TRAVIS_BRANCH
fi
# If we want to deploy, we want to push. But Travis CI doing `git checkout -qf ${TRAVIS_COMMIT}` and there comes a detached HEAD. I don't want to figure out this shit, just let's checkout from detached HEAD into source branch.
git checkout ${SOURCE_BRANCH}
# Now let's build our project to know if there are will be any changes:
build
# Check if there are changes generated by build:
if [[ `git status --porcelain` ]]; then
echo "There are changes to publish!"
git status # debug
# Add any changes to index
git add .
# Tell everyone that this changes is pushed by Travis CI:
git config user.name "Travis CI"
# Author email will contain server address where this build done and looks like [this](travis@testing-worker-linux-docker-c84a3a30-3437-linux-5.prod.travis-ci.org)
# Add `[skip ci]` to commit message to not start Travis CI build from push of this deployment commit
git commit -m "Travis CI $TRAVIS_COMMIT [skip ci]"
# Build HTTPS git remote from Travis CI project environment variables
git remote add deployment https://${GIT_USER}:${GIT_PASSWORD}@${GIT_HOST}/${TRAVIS_REPO_SLUG}.git
# Push changes to target branch
git push -u deployment ${TARGET_BRANCH}
# If no changes generated by build:
else
echo "No changes to the output on this push; exiting."
exit 0
fi
# I am scripting in Bash for the first time. Many thanks to [Domenic Denicola](https://github.com/domenic) for his [GitHub Pages publish script](https://gist.github.com/domenic/ec8b0fc8ab45f39403dd).
44 changes: 44 additions & 0 deletions gulpfile.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
'use strict'
// global
const gulp = require('gulp')
const browserify = require('browserify')
const $ = require('gulp-load-plugins')()
// local
const env = {
scriptsToCompile: [
'./*.js',
'!./*-min.js',
'!./gulpfile.js'
],
destScriptsNaming: $.rename({
suffix: '-min'
}),
dest: './'
}
// public tasks
gulp.task('default', ['scripts'])
gulp.task('scripts', ()=> {
// some strange code because of gulp team think there is not necessary to have a plugin to just `.pipe(browserify())`, you have to build bicycles instead: https://github.com/gulpjs/plugins/issues/47
return gulp.src(env.scriptsToCompile, {read: false})
.pipe(
// transform file objects
$.tap(file=> {
$.util.log('bundling ' + file.path)
// replace file contents with Browserify bundle stream
file.contents = browserify(
file.path,
// Babel and other transforms is plugged in package.json
{
debug: true
}
).bundle()
})
)
// transform streaming contents into buffer contents (because gulp-sourcemaps does not support streaming contents)
.pipe($.buffer())
// non-bycicle gulp pipeline starts here
.pipe(env.destScriptsNaming)
.pipe($.sourcemaps.init({loadMaps: true}))
.pipe($.sourcemaps.write('./'))
.pipe(gulp.dest(env.dest))
})
8 changes: 7 additions & 1 deletion jquery-scrolltofixed-min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions jquery-scrolltofixed-min.js.map

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions jquery-scrolltofixed.js
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@
// not fill the rest of the page horizontally. Also, set its top
// to the margin top specified in the options.

cssOptions={
var cssOptions={
'z-index' : base.options.zIndex,
'position' : 'fixed',
'top' : base.options.bottom == -1?getMarginTop():'',
Expand Down Expand Up @@ -176,7 +176,7 @@
top = top - offsetTop;
}

cssOptions={
var cssOptions={
'position' : 'absolute',
'top' : top,
'left' : left,
Expand Down Expand Up @@ -211,7 +211,7 @@
'margin-left' : ''
});

target.removeClass('scroll-to-fixed-fixed');
target.removeClass(base.options.baseClassName);

if (base.options.className) {
target.removeClass(base.options.className);
Expand Down
Loading