nprogress-rails-0.1.6.7/0000755000076400007640000000000012554152231014051 5ustar pravipravinprogress-rails-0.1.6.7/LICENSE.txt0000644000076400007640000000207012554152231015673 0ustar pravipraviCopyright (c) 2013 Carlos Alexandro Becker MIT License Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. nprogress-rails-0.1.6.7/nprogress-rails.gemspec0000644000076400007640000000205012554152231020545 0ustar pravipravi# coding: utf-8 lib = File.expand_path('../lib', __FILE__) $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib) Gem::Specification.new do |spec| spec.name = 'nprogress-rails' spec.version = '0.1.6.7' spec.authors = ['Carlos Alexandro Becker'] spec.email = ['caarlos0@gmail.com'] spec.description = %q{This is a gem for the rstacruz' nprogress implementation. It's based on version nprogress 0.1.6.} spec.summary = %q{Slim progress bars for Ajax'y applications. Inspired by Google, YouTube, and Medium.} spec.homepage = 'https://github.com/caarlos0/nprogress-rails' spec.license = 'MIT' spec.files = `git ls-files`.split($/) spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) } spec.test_files = spec.files.grep(%r{^(test|spec|features)/}) spec.require_paths = ['lib'] spec.add_development_dependency 'bundler', '~> 1.3' spec.add_development_dependency 'rake' spec.add_development_dependency 'sass-rails' spec.add_development_dependency 'sass' end nprogress-rails-0.1.6.7/README.md0000644000076400007640000000641512554152231015336 0ustar pravipravi# nprogress-rails [![Gem Version](https://badge.fury.io/rb/nprogress-rails.svg)](http://badge.fury.io/rb/nprogress-rails) [![Dependency Status](https://gemnasium.com/caarlos0/nprogress-rails.svg)](https://gemnasium.com/caarlos0/nprogress-rails) [![Stories in Ready](https://badge.waffle.io/caarlos0/nprogress-rails.png?label=ready&title=Ready)](https://waffle.io/caarlos0/nprogress-rails) This is basically a ruby gem for asset pipeline which includes the version 0.1.6 of the awesome [rstacruz][rstacruz]' [nprogress][lib] library. - [**Original lib**][lib] - [**Demo**][demo] [rstacruz]: https://github.com/rstacruz [lib]: https://github.com/rstacruz/nprogress [demo]: http://ricostacruz.com/nprogress/ ## Installation Add this line to your application's Gemfile: gem 'nprogress-rails' And then execute: $ bundle Or install it yourself as: $ gem install nprogress-rails ## Usage You basically have to add the requires to the `application.js` file: ```javascript //= require nprogress //= require nprogress-turbolinks ``` The `nprogress-turbolinks` is required only if you use turbolinks. Using pjax rather than turbolinks? Simply require `nprogress-pjax` instead. Want it also for simple jQuery AJAX calls? Just require `nprogress-ajax`. Otherwise, you will have to deal with show/hide the progress by your own. Also, into your `application.css.scss` file: ```scss *= require nprogress *= require nprogress-bootstrap ``` The `nprogress-bootstrap` is required if you use bootstrap and have a fixed toolbar or anything else. tl;dr: if the console shows no errors, but the progress doesn't appear, try this. ### Angular.js support You can try the Angular.js support with something like this (again, in `application.js` file): ```javascript //= require nprogress //= require nprogress-angular angular.module('myApp', [ 'nprogress-rails' ]); ``` This should make all requests made with `$http` show/hide the NProgress bar. ## Customization You can use any of the configurations described in the [readme](https://github.com/rstacruz/nprogress#configuration) with this lib. I just recommend you to do so ASAP, for example, just after the `nprogress-rails` require: ```javascript //= require nprogress NProgress.configure({ showSpinner: false, ease: 'ease', speed: 500 }); ``` Since the [v0.1.2.3 release](https://github.com/caarlos0/nprogress-rails/releases/tag/v0.1.2.3), you can also change the color of the progressbar using SASS: ```scss $nprogress-color: #f1f1f1; $nprogress-height: 10px; $nprogress-zindex: 10100; @import 'nprogress'; @import 'nprogress-bootstrap'; ``` ## Ajax - jQuery or Prototype `nprogress-ajax` automatically triggers the NProgress bar when an Ajax request is started (the 'ajaxStart' event), and finishes it when the Ajax request completes (the 'ajaxStop' event). This works for any Ajax events triggered using jQuery. If you're using Prototype, you can include the `nprogress-ajax-prototype` javascript file instead, which works for Ajax requests started from Prototype (the 'onCreate' and 'onComplete' events, to be exact). ## Contributing 1. Fork it 2. Create your feature branch (`git checkout -b my-new-feature`) 3. Commit your changes (`git commit -am 'Add some feature'`) 4. Push to the branch (`git push origin my-new-feature`) 5. Create new Pull Request nprogress-rails-0.1.6.7/app/0000755000076400007640000000000012554152231014631 5ustar pravipravinprogress-rails-0.1.6.7/app/assets/0000755000076400007640000000000012554152231016133 5ustar pravipravinprogress-rails-0.1.6.7/app/assets/stylesheets/0000755000076400007640000000000012554152231020507 5ustar pravipravinprogress-rails-0.1.6.7/app/assets/stylesheets/nprogress-bootstrap.css0000644000076400007640000000007412554152231025257 0ustar pravipravi#nprogress .bar, #nprogress .spinner { z-index: 999999; } nprogress-rails-0.1.6.7/app/assets/stylesheets/nprogress.scss0000644000076400007640000000317112554152231023430 0ustar pravipravi$nprogress-color: #29d !default; $nprogress-height: 2px !default; $nprogress-zindex: 100 !default; /* Make clicks pass-through */ #nprogress { pointer-events: none; } #nprogress .bar { background: $nprogress-color; position: fixed; z-index: $nprogress-zindex; top: 0; left: 0; width: 100%; height: $nprogress-height; } /* Fancy blur effect */ #nprogress .peg { display: block; position: absolute; right: 0px; width: 100px; height: 100%; box-shadow: 0 0 10px $nprogress-color, 0 0 5px $nprogress-color; opacity: 1.0; -webkit-transform: rotate(3deg) translate(0px, -4px); -ms-transform: rotate(3deg) translate(0px, -4px); transform: rotate(3deg) translate(0px, -4px); } /* Remove these to get rid of the spinner */ #nprogress .spinner { display: block; position: fixed; z-index: $nprogress-zindex; top: 15px; right: 15px; } #nprogress .spinner-icon { width: 18px; height: 18px; box-sizing: border-box; border: solid 2px transparent; border-top-color: $nprogress-color; border-left-color: $nprogress-color; border-radius: 50%; -webkit-animation: nprogress-spinner 400ms linear infinite; animation: nprogress-spinner 400ms linear infinite; } .nprogress-custom-parent { overflow: hidden; position: relative; } .nprogress-custom-parent #nprogress .spinner, .nprogress-custom-parent #nprogress .bar { position: absolute; } @-webkit-keyframes nprogress-spinner { 0% { -webkit-transform: rotate(0deg); } 100% { -webkit-transform: rotate(360deg); } } @keyframes nprogress-spinner { 0% { transform: rotate(0deg); } 100% { transform: rotate(360deg); } } nprogress-rails-0.1.6.7/app/assets/javascripts/0000755000076400007640000000000012554152231020464 5ustar pravipravinprogress-rails-0.1.6.7/app/assets/javascripts/nprogress-ajax-prototype.js0000644000076400007640000000021112554152231026022 0ustar pravipraviAjax.Responders.register({ onCreate: function() { NProgress.start(); }, onComplete: function() { NProgress.done(); } }); nprogress-rails-0.1.6.7/app/assets/javascripts/nprogress-pjax.js0000644000076400007640000000025612554152231024007 0ustar pravipravijQuery(function() { jQuery(document).on('pjax:send', function() { NProgress.start(); }); jQuery(document).on('pjax:complete', function() { NProgress.done(); }); }); nprogress-rails-0.1.6.7/app/assets/javascripts/nprogress-ajax.js0000644000076400007640000000024612554152231023767 0ustar pravipravijQuery(function() { jQuery(document).on('ajaxStart', function() { NProgress.start(); }); jQuery(document).on('ajaxStop', function() { NProgress.done(); }); }); nprogress-rails-0.1.6.7/app/assets/javascripts/nprogress-angular.js0000644000076400007640000000121012554152231024465 0ustar pravipraviangular.module('nprogress-rails', []) .config(['$httpProvider', function($httpProvider) { $httpProvider.interceptors.push(['$q', function($q) { return { 'request': function(config) { NProgress.start(); return config; }, 'requestError': function(rejection) { NProgress.done(); return $q.reject(rejection); }, 'response': function(response) { NProgress.done(); return response; }, 'responseError': function(rejection) { NProgress.done(); return $q.reject(rejection); } }; }]); }]); nprogress-rails-0.1.6.7/app/assets/javascripts/nprogress.js0000644000076400007640000002651012554152231023050 0ustar pravipravi/* NProgress, (c) 2013, 2014 Rico Sta. Cruz - http://ricostacruz.com/nprogress * @license MIT */ ;(function(root, factory) { if (typeof define === 'function' && define.amd) { define(factory); } else if (typeof exports === 'object') { module.exports = factory(); } else { root.NProgress = factory(); } })(this, function() { var NProgress = {}; NProgress.version = '0.1.6'; var Settings = NProgress.settings = { minimum: 0.08, easing: 'ease', positionUsing: '', speed: 200, trickle: true, trickleRate: 0.02, trickleSpeed: 800, showSpinner: true, barSelector: '[role="bar"]', spinnerSelector: '[role="spinner"]', parent: 'body', template: '
' }; /** * Updates configuration. * * NProgress.configure({ * minimum: 0.1 * }); */ NProgress.configure = function(options) { var key, value; for (key in options) { value = options[key]; if (value !== undefined && options.hasOwnProperty(key)) Settings[key] = value; } return this; }; /** * Last number. */ NProgress.status = null; /** * Sets the progress bar status, where `n` is a number from `0.0` to `1.0`. * * NProgress.set(0.4); * NProgress.set(1.0); */ NProgress.set = function(n) { var started = NProgress.isStarted(); n = clamp(n, Settings.minimum, 1); NProgress.status = (n === 1 ? null : n); var progress = NProgress.render(!started), bar = progress.querySelector(Settings.barSelector), speed = Settings.speed, ease = Settings.easing; progress.offsetWidth; /* Repaint */ queue(function(next) { // Set positionUsing if it hasn't already been set if (Settings.positionUsing === '') Settings.positionUsing = NProgress.getPositioningCSS(); // Add transition css(bar, barPositionCSS(n, speed, ease)); if (n === 1) { // Fade out css(progress, { transition: 'none', opacity: 1 }); progress.offsetWidth; /* Repaint */ setTimeout(function() { css(progress, { transition: 'all ' + speed + 'ms linear', opacity: 0 }); setTimeout(function() { NProgress.remove(); next(); }, speed); }, speed); } else { setTimeout(next, speed); } }); return this; }; NProgress.isStarted = function() { return typeof NProgress.status === 'number'; }; /** * Shows the progress bar. * This is the same as setting the status to 0%, except that it doesn't go backwards. * * NProgress.start(); * */ NProgress.start = function() { if (!NProgress.status) NProgress.set(0); var work = function() { setTimeout(function() { if (!NProgress.status) return; NProgress.trickle(); work(); }, Settings.trickleSpeed); }; if (Settings.trickle) work(); return this; }; /** * Hides the progress bar. * This is the *sort of* the same as setting the status to 100%, with the * difference being `done()` makes some placebo effect of some realistic motion. * * NProgress.done(); * * If `true` is passed, it will show the progress bar even if its hidden. * * NProgress.done(true); */ NProgress.done = function(force) { if (!force && !NProgress.status) return this; return NProgress.inc(0.3 + 0.5 * Math.random()).set(1); }; /** * Increments by a random amount. */ NProgress.inc = function(amount) { var n = NProgress.status; if (!n) { return NProgress.start(); } else { if (typeof amount !== 'number') { amount = (1 - n) * clamp(Math.random() * n, 0.1, 0.95); } n = clamp(n + amount, 0, 0.994); return NProgress.set(n); } }; NProgress.trickle = function() { return NProgress.inc(Math.random() * Settings.trickleRate); }; /** * Waits for all supplied jQuery promises and * increases the progress as the promises resolve. * * @param $promise jQUery Promise */ (function() { var initial = 0, current = 0; NProgress.promise = function($promise) { if (!$promise || $promise.state() == "resolved") { return this; } if (current == 0) { NProgress.start(); } initial++; current++; $promise.always(function() { current--; if (current == 0) { initial = 0; NProgress.done(); } else { NProgress.set((initial - current) / initial); } }); return this; }; })(); /** * (Internal) renders the progress bar markup based on the `template` * setting. */ NProgress.render = function(fromStart) { if (NProgress.isRendered()) return document.getElementById('nprogress'); addClass(document.documentElement, 'nprogress-busy'); var progress = document.createElement('div'); progress.id = 'nprogress'; progress.innerHTML = Settings.template; var bar = progress.querySelector(Settings.barSelector), perc = fromStart ? '-100' : toBarPerc(NProgress.status || 0), parent = document.querySelector(Settings.parent), spinner; css(bar, { transition: 'all 0 linear', transform: 'translate3d(' + perc + '%,0,0)' }); if (!Settings.showSpinner) { spinner = progress.querySelector(Settings.spinnerSelector); spinner && removeElement(spinner); } if (parent != document.body) { addClass(parent, 'nprogress-custom-parent'); } parent.appendChild(progress); return progress; }; /** * Removes the element. Opposite of render(). */ NProgress.remove = function() { removeClass(document.documentElement, 'nprogress-busy'); removeClass(document.querySelector(Settings.parent), 'nprogress-custom-parent') var progress = document.getElementById('nprogress'); progress && removeElement(progress); }; /** * Checks if the progress bar is rendered. */ NProgress.isRendered = function() { return !!document.getElementById('nprogress'); }; /** * Determine which positioning CSS rule to use. */ NProgress.getPositioningCSS = function() { // Sniff on document.body.style var bodyStyle = document.body.style; // Sniff prefixes var vendorPrefix = ('WebkitTransform' in bodyStyle) ? 'Webkit' : ('MozTransform' in bodyStyle) ? 'Moz' : ('msTransform' in bodyStyle) ? 'ms' : ('OTransform' in bodyStyle) ? 'O' : ''; if (vendorPrefix + 'Perspective' in bodyStyle) { // Modern browsers with 3D support, e.g. Webkit, IE10 return 'translate3d'; } else if (vendorPrefix + 'Transform' in bodyStyle) { // Browsers without 3D support, e.g. IE9 return 'translate'; } else { // Browsers without translate() support, e.g. IE7-8 return 'margin'; } }; /** * Helpers */ function clamp(n, min, max) { if (n < min) return min; if (n > max) return max; return n; } /** * (Internal) converts a percentage (`0..1`) to a bar translateX * percentage (`-100%..0%`). */ function toBarPerc(n) { return (-1 + n) * 100; } /** * (Internal) returns the correct CSS for changing the bar's * position given an n percentage, and speed and ease from Settings */ function barPositionCSS(n, speed, ease) { var barCSS; if (Settings.positionUsing === 'translate3d') { barCSS = { transform: 'translate3d('+toBarPerc(n)+'%,0,0)' }; } else if (Settings.positionUsing === 'translate') { barCSS = { transform: 'translate('+toBarPerc(n)+'%,0)' }; } else { barCSS = { 'margin-left': toBarPerc(n)+'%' }; } barCSS.transition = 'all '+speed+'ms '+ease; return barCSS; } /** * (Internal) Queues a function to be executed. */ var queue = (function() { var pending = []; function next() { var fn = pending.shift(); if (fn) { fn(next); } } return function(fn) { pending.push(fn); if (pending.length == 1) next(); }; })(); /** * (Internal) Applies css properties to an element, similar to the jQuery * css method. * * While this helper does assist with vendor prefixed property names, it * does not perform any manipulation of values prior to setting styles. */ var css = (function() { var cssPrefixes = [ 'Webkit', 'O', 'Moz', 'ms' ], cssProps = {}; function camelCase(string) { return string.replace(/^-ms-/, 'ms-').replace(/-([\da-z])/gi, function(match, letter) { return letter.toUpperCase(); }); } function getVendorProp(name) { var style = document.body.style; if (name in style) return name; var i = cssPrefixes.length, capName = name.charAt(0).toUpperCase() + name.slice(1), vendorName; while (i--) { vendorName = cssPrefixes[i] + capName; if (vendorName in style) return vendorName; } return name; } function getStyleProp(name) { name = camelCase(name); return cssProps[name] || (cssProps[name] = getVendorProp(name)); } function applyCss(element, prop, value) { prop = getStyleProp(prop); element.style[prop] = value; } return function(element, properties) { var args = arguments, prop, value; if (args.length == 2) { for (prop in properties) { value = properties[prop]; if (value !== undefined && properties.hasOwnProperty(prop)) applyCss(element, prop, value); } } else { applyCss(element, args[1], args[2]); } } })(); /** * (Internal) Determines if an element or space separated list of class names contains a class name. */ function hasClass(element, name) { var list = typeof element == 'string' ? element : classList(element); return list.indexOf(' ' + name + ' ') >= 0; } /** * (Internal) Adds a class to an element. */ function addClass(element, name) { var oldList = classList(element), newList = oldList + name; if (hasClass(oldList, name)) return; // Trim the opening space. element.className = newList.substring(1); } /** * (Internal) Removes a class from an element. */ function removeClass(element, name) { var oldList = classList(element), newList; if (!hasClass(element, name)) return; // Replace the class name. newList = oldList.replace(' ' + name + ' ', ' '); // Trim the opening and closing spaces. element.className = newList.substring(1, newList.length - 1); } /** * (Internal) Gets a space separated list of the class names on the element. * The list is wrapped with a single space on each end to facilitate finding * matches within the list. */ function classList(element) { return (' ' + (element.className || '') + ' ').replace(/\s+/gi, ' '); } /** * (Internal) Removes an element from the DOM. */ function removeElement(element) { element && element.parentNode && element.parentNode.removeChild(element); } return NProgress; });nprogress-rails-0.1.6.7/app/assets/javascripts/nprogress-turbolinks.js0000644000076400007640000000050412554152231025235 0ustar pravipravijQuery(function() { jQuery(document).on('page:fetch', function() { NProgress.start(); }); jQuery(document).on('page:receive', function() { NProgress.set(0.7); }); jQuery(document).on('page:change', function() { NProgress.done(); }); jQuery(document).on('page:restore', function() { NProgress.remove(); }); }); nprogress-rails-0.1.6.7/Gemfile0000644000076400007640000000014412554152231015343 0ustar pravipravisource 'https://rubygems.org' # Specify your gem's dependencies in nprogress-rails.gemspec gemspec nprogress-rails-0.1.6.7/metadata.yml0000644000076400007640000000565212554152231016364 0ustar pravipravi--- !ruby/object:Gem::Specification name: nprogress-rails version: !ruby/object:Gem::Version version: 0.1.6.7 platform: ruby authors: - Carlos Alexandro Becker autorequire: bindir: bin cert_chain: [] date: 2015-05-09 00:00:00.000000000 Z dependencies: - !ruby/object:Gem::Dependency name: bundler requirement: !ruby/object:Gem::Requirement requirements: - - "~>" - !ruby/object:Gem::Version version: '1.3' type: :development prerelease: false version_requirements: !ruby/object:Gem::Requirement requirements: - - "~>" - !ruby/object:Gem::Version version: '1.3' - !ruby/object:Gem::Dependency name: rake requirement: !ruby/object:Gem::Requirement requirements: - - ">=" - !ruby/object:Gem::Version version: '0' type: :development prerelease: false version_requirements: !ruby/object:Gem::Requirement requirements: - - ">=" - !ruby/object:Gem::Version version: '0' - !ruby/object:Gem::Dependency name: sass-rails requirement: !ruby/object:Gem::Requirement requirements: - - ">=" - !ruby/object:Gem::Version version: '0' type: :development prerelease: false version_requirements: !ruby/object:Gem::Requirement requirements: - - ">=" - !ruby/object:Gem::Version version: '0' - !ruby/object:Gem::Dependency name: sass requirement: !ruby/object:Gem::Requirement requirements: - - ">=" - !ruby/object:Gem::Version version: '0' type: :development prerelease: false version_requirements: !ruby/object:Gem::Requirement requirements: - - ">=" - !ruby/object:Gem::Version version: '0' description: This is a gem for the rstacruz' nprogress implementation. It's based on version nprogress 0.1.6. email: - caarlos0@gmail.com executables: [] extensions: [] extra_rdoc_files: [] files: - ".gitignore" - Gemfile - LICENSE.txt - README.md - Rakefile - app/assets/javascripts/nprogress-ajax-prototype.js - app/assets/javascripts/nprogress-ajax.js - app/assets/javascripts/nprogress-angular.js - app/assets/javascripts/nprogress-pjax.js - app/assets/javascripts/nprogress-turbolinks.js - app/assets/javascripts/nprogress.js - app/assets/stylesheets/nprogress-bootstrap.css - app/assets/stylesheets/nprogress.scss - lib/nprogress-rails.rb - nprogress-rails.gemspec homepage: https://github.com/caarlos0/nprogress-rails licenses: - MIT metadata: {} post_install_message: rdoc_options: [] require_paths: - lib required_ruby_version: !ruby/object:Gem::Requirement requirements: - - ">=" - !ruby/object:Gem::Version version: '0' required_rubygems_version: !ruby/object:Gem::Requirement requirements: - - ">=" - !ruby/object:Gem::Version version: '0' requirements: [] rubyforge_project: rubygems_version: 2.2.2 signing_key: specification_version: 4 summary: Slim progress bars for Ajax'y applications. Inspired by Google, YouTube, and Medium. test_files: [] nprogress-rails-0.1.6.7/lib/0000755000076400007640000000000012554152231014617 5ustar pravipravinprogress-rails-0.1.6.7/lib/nprogress-rails.rb0000644000076400007640000000010112554152231020266 0ustar pravipravimodule NprogressRails class Engine < ::Rails::Engine end end nprogress-rails-0.1.6.7/Rakefile0000644000076400007640000000003412554152231015513 0ustar pravipravirequire "bundler/gem_tasks" nprogress-rails-0.1.6.7/.gitignore0000644000076400007640000000024712554152231016044 0ustar pravipravi*.gem *.rbc .bundle .config .yardoc Gemfile.lock InstalledFiles _yardoc coverage doc/ lib/bundler/man pkg rdoc spec/reports test/tmp test/version_tmp tmp .sass-cache/