Giter Site home page Giter Site logo

caarlos0-graveyard / nprogress-rails Goto Github PK

View Code? Open in Web Editor NEW
514.0 12.0 39.0 63 KB

Slim progress bars for Ajax'y applications. Inspired by Google, YouTube, and Medium for the Rails Asset Pipeline (and some turbolinks/pjax/angular love)

Home Page: https://rubygems.org/gems/nprogress-rails

License: MIT License

Ruby 7.79% JavaScript 81.26% CSS 10.95%

nprogress-rails's Introduction

nprogress-rails Gem Version Dependency Status Stories in Ready

This is basically a ruby gem for asset pipeline which includes the version 0.2.0 of the awesome rstacruz' nprogress library.

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:

//= 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:

*= require nprogress
*= require nprogress-bootstrap
*= require nprogress-turbolinks5

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.

The nprogress-turbolinks5 is required if you use turbolinks 5 and does not want the default turbolinks progress to show up.

Angular.js support

You can try the Angular.js support with something like this (again, in application.js file):

//= 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 with this lib. I just recommend you to do so ASAP, for example, just after the nprogress-rails require:

//= require nprogress

NProgress.configure({
  showSpinner: false,
  ease: 'ease',
  speed: 500
});

Since the v0.1.2.3 release, you can also change the color of the progressbar using SASS:

$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's People

Contributors

caarlos0 avatar cllns avatar davidcelis avatar diego-silva avatar ericboehs avatar lukerollans avatar mpeteuil avatar prayagverma avatar rbmrclo avatar ssjr avatar waffle-iron avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

nprogress-rails's Issues

Turbolinks.ProgressBar.disable is not a function

I'm trying to use this gem.
Gemfile
gem 'nprogress-rails'

application.css.scss
*= require_tree .
*= require_self
*= require nprogress
*= require nprogress-bootstrap

application.js
//= require jquery
//= require jquery_ujs
//= require turbolinks
//= require nprogress
//= require nprogress-turbolinks
//= require_tree .

but it's not work
screenshot from 2016-08-05 13 24 15

NProgress Spinner still appearing

Having done following the installation guide as shown below, NProgress spinner still appears on the page transition.

  • Code Implementation
    screenshot from 2013-09-06 14 07 40
  • Spinner still running
    screenshot from 2013-09-06 14 07 07

Is there something that wasn't done properly? Or is there still something that needs to be implemented into the code?

Couldn't find file

This is what I've added to my gemfile:
gem 'nprogress-rails', '~> 0.1.6.3'

And then I ran bundle. The gem shows now up as installed.
nprogress-rails (0.1.6.3)
Author: Carlos Alexandro Becker
Homepage: https://github.com/caarlos0/nprogress-rails
License: MIT
Installed at: /home/vagrant/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0

Slim progress bars for Ajax'y applications. Inspired by Google,
YouTube, and Medium.

This is my application.js
//= require jquery
//= require jquery.turbolinks
//= require jquery_ujs
//= require turbolinks
//= require emerald
//= require fittext
//= require wow
//= require share
//= require password
//= require impulse.min
//= require owl.carousel
//= require owl.schedule
//= require nprogress
//= require nprogress-turbolinks
//= require custom
//= require_tree .

This is application.css.scss

@import "bootstrap";
@import "emerald";
@import "spinner";
@import "animate";
@import "owl.carousel";
@import "owl.theme";
@import "nprogress";
@import "nprogress-bootstrap";
@import "menu";
@import "profile";
@import "schedule";
@import "bookings";
@import "settings";
@import "custom";

The error messages I receive are:
Showing /vagrant/app/views/layouts/application.html.haml where line #16 raised:
couldn't find file 'nprogress'
(in /vagrant/app/assets/stylesheets/application.css.scss:13)

Showing /vagrant/app/views/layouts/application.html.haml where line #17 raised:
couldn't find file 'nprogress'
(in /vagrant/app/assets/javascripts/application.js:25)

Is there something that I've done wrong, or is it another problem?

Error compiling CSS asset

Hello,

I am getting the following error in the browser (chrome and firefox):

ArgumentError: wrong number of arguments (2 for 1)
   (in /home/user/.rvm/gems/ruby-2.1.2/gems/nprogress-rails-0.1.6.3/app/assets/stylesheets/nprogress.css.scss)
/home/user/.rvm/gems/ruby-2.1.2/gems/sass-3.4.6/lib/sass/importers/filesystem.rb:14:in `initialize'

I have installed a new (current) sass with a bundle update.

Thank you for your help.

Best regards
Mario

Rename to 'nprogress-rails'

I would like to suggest renaming repo and gem to ngprogress-rails, to follow what rubygems.org recommends for gem extensions. This is also comparable to what other gems do such as 'query-rails.'

Cheers to your quick work! ๐Ÿป

How to deal with Turbolinks 3.0?

I'm using it in one of my projects and it's a pain. I have two bar. I have to disable tubolinks 3.0's bar to show your one. How to style the default bar?

Progress bar until bg image is loaded

Hello,
I'm wondering if it's possible to keep loader shown until background image is loaded?
Currently: Page is loading bg image, but progress bar is gone (still see in safari's status bar that website is loading its resources)
I'd like to see progress bar until background image is loaded.
Btw I specify bg images in stylesheets not this way .class { background-image: url(<%= asset_path 'image.png' %>) }

Error when adding requires

I'm getting this error after adding the requires to the application.js and bundled:

couldn't find file 'nprogress-turbolink'

I've added

//= require nprogress
//= require nprogress-turbolink

Any ideas?

Error when adding requires

I'm getting this error after adding the requires to the application.js and bundled:

couldn't find file 'nprogress-turbolink'

I've added

//= require nprogress
//= require nprogress-turbolink

Any ideas?

Progress on form submit?

Is there a way to get the progress bar to work once a form is submitted? It's working great for me during normal page navigation, but is there a reason it doesn't work when submitting a form?

Change Nprogress bar location

I am running one mvc 4 application where i have navbar in my layout.cshtml page. I recently added N progress from here for one of my view to show progress bar when page loads. in that view i have one div. When i run my application progress bar is showing up of navbar. But i wanted to show progress bar below of the div. How would i achieve the same?

Changing loading-bar location?

Hey,

I like your spinner - but I have one (hopefully easy) question in regards to its customization:

If it possible to set where the loading bar loads? I am using a bootstrap navbar and would prefer the loading bar to be right below the navbar instead of on top of it. Is this possible?

Thanks

Clash of nprogress id with rails params id

Did anyone notice the folowing behaviour? When using nprogress, the id in my rails forms when updating an object gets overwritten with 'nprogress', which results in a error retrieving the object that should be rendered.

Here is the log info:
Started GET "/case_files/56a62ba62a104f0038000009/liabilities_files/56a62ba62a104f003800000b/liabilities/56a731b8eebcd10037000169?locale=nl&tab=5638fe096591483757000029" for 127.0.0.1 at 2016-02-02 12:34:25 +0100
Processing by LiabilitiesController#show as HTML
Parameters: {"locale"=>"nl", "tab"=>"5638fe096591483757000029", "case_file_id"=>"56a62ba62a104f0038000009", "liabilities_file_id"=>"56a62ba62a104f003800000b", "id"=>"56a731b8eebcd10037000169"}
Rendered layouts/_case_file_panes.html.erb (4.3ms)
Rendered partials/_show_event_dates.erb (1.9ms)
Rendered partials/_show_re.erb (311.5ms)
Rendered partials/_show_al.erb (42.9ms)
Rendered liabilities/show.html.erb within layouts/application (386.9ms)
Rendered layouts/_menu.html.erb (4.7ms)
Completed 200 OK in 806ms (Views: 574.3ms)
Started GET "/case_files/56a62ba62a104f0038000009/liabilities_files/56a62ba62a104f003800000b/liabilities/nprogress.js" for 127.0.0.1 at 2016-02-02 12:34:27 +0100
Processing by LiabilitiesController#show as JS
Parameters: {"case_file_id"=>"56a62ba62a104f0038000009", "liabilities_file_id"=>"56a62ba62a104f003800000b", # "id"=>"nprogress"}
Rendered layouts/_case_file_panes.html.erb (3.1ms)
Rendered liabilities/show.html.erb (8.1ms)
Completed 500 Internal Server Error in 298ms

couldn't find file 'nprogress'

In Rails 4, after put it in gem file, executed bundle command and added requires in javascript and styleheet file I get this error:

Sprockets::FileNotFound at /t/brand/apache

couldn't find file 'nprogress' (in ..... /app/assets/javascripts/spree/frontend/all.js:11)

couldn't find file 'nprogress'

I have needed to deploy app via Capistrano. There was a problem with precompile of assets, so I have deleted files from downloaded template and deleted all from application.js and application.css. Now I want to debug app by adding one files per rake assets:precompile, but still have this issue.

Application.js:

//= require turbolinks
//= require nprogress
//= require nprogress-turbolinks

Application.css:

*= require nprogress
*= require nprogress-bootstrap
@import "nprogress";

Sprockets::FileNotFound in Home#index
Showing /Users/user/app/app/views/layouts/application.html.erb where line #6 raised:

couldn't find file 'nprogress'
  (in /Users/user/app/app/assets/stylesheets/application.css:13)
Extracted source (around line #6):
3
4
5
6
7
8
9

  <!--[if !IE]><!--> <html lang="en"> <!--<![endif]-->
  <html>
  <head>
    <%= stylesheet_link_tag    'application', media: 'all', 'data-turbolinks-track' => true %>
    <%= javascript_include_tag 'application', 'data-turbolinks-track' => true %>
    <%= csrf_meta_tags %>
    <meta charset="utf-8">

Am I missing something? Is there some file nprogress which I have deleted as well? Or is this nprogress error? And yes, I have restarted server (actually many times).

Turbolinks and Full Page Loads

My rails website leverages turbolinks for the majority of the application, but for a few links I do not use turbolinks because it seems to break some jquery/js functionality (jquery-turbolinks gem doesn't resolve those bugs either)

So is it possible to use this for page loads with and without turbolinks? I can only seem to get it to work one way or the other.

Thanks

Ajax responder for prototype

Hey there,
I just added nprogress-rails to a legacy app which still uses Prototype. Here's the a version of nprogress-ajax that works with the Ajax events from Prototype. Feel free to include it in the package (maybe call it nprogress-ajax-prototype?), but I understand if you don't want to, since it's such a small niche. Regardless, I just wanted to document it here for anyone else who might need it.

(The normal jQuery one only works for Ajax events started by jQuery, so even though my app has the two co-existing, that one doesn't work).

Ajax.Responders.register({
  onCreate: function() {
    NProgress.start();
  },
  onComplete: function() {
    NProgress.done();
  }
});

Problem with parent:

Not allowed to use "parent" to change the id or class of performance.
Example:
NProgress.configure({ parent: '#container' });

This works perfectly in the original plugin.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.