Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Initial commit

  • Loading branch information...
commit ec2efbff14e496c0121bfbb0045e43ec619a43b7 0 parents
@heelhook authored
4 .gitignore
@@ -0,0 +1,4 @@
+*.gem
+.bundle
+Gemfile.lock
+pkg/*
2  Gemfile
@@ -0,0 +1,2 @@
+source "https://rubygems.org"
+gemspec
20 LICENSE
@@ -0,0 +1,20 @@
+Copyright (c) 2012 Pablo Fernandez
+
+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.
45 README.md
@@ -0,0 +1,45 @@
+# intro.js-rails
+**Intro.js for rails asset pipeline**
+
+[Intro.js][0] is a better way for new feature introduction and step-by-step users guide for your website and project.
+
+## Usage
+
+### Install introjs-rails gem
+
+Add `introjs-rails` to your Gemfile and run `bundle install`:
+
+ gem "introjs-rails"
+
+### Include introjs-rails javascript assets
+
+Add the following to your `app/assets/javascripts/application.js`:
+
+ //= require introjs
+
+### Include introjs-rails stylesheet assets
+
+Add to your `app/assets/stylesheets/application.css`:
+
+ *= require introjs
+
+## Version
+
+`introjs-rails` tracks [Intro.js][0]'s versions.
+
+## Contributions
+
+If you want to contribute, please:
+
+ * Fork the project.
+ * Make your feature addition or bug fix.
+ * Send me a pull request on Github.
+
+## Copyright
+
+### MIT Licensed
+
+Copyright (c) 2013 Pablo Fernandez. See [LICENSE][1] for details.
+
+[0]: https://github.com/usablica/intro.js
+[1]: https://github.com/heelhook/intro.js-rails/blob/master/LICENSE
28 Rakefile
@@ -0,0 +1,28 @@
+#!/usr/bin/env rake
+
+require "bundler/gem_tasks"
+require File.expand_path('../lib/introjs-rails/source_file', __FILE__)
+
+$LOAD_PATH.unshift File.expand_path("../lib", __FILE__)
+require 'introjs-rails/version'
+
+task default: :update
+
+desc "Update library"
+task :update do
+ files = SourceFile.new
+ files.fetch
+end
+
+task gem: :build
+task :build do
+ system "gem build introjs-rails.gemspec"
+end
+
+task release: :build do
+ version = Introjs::Rails::VERSION
+ system "git tag -a v#{version} -m 'Tagging #{version}'"
+ system "git push --tags"
+ system "gem push introjs-#{version}.gem"
+ system "rm introjs-#{version}.gem"
+end
1  app/assets/javascripts/introjs.js
@@ -0,0 +1 @@
+(function(){function t(e){this._targetElement=e}function n(e){var t=e.querySelectorAll("*[data-intro]"),n=[],o=this;if(t.length<1){return}for(var a=0,f=t.length;a<f;a++){var l=t[a];n.push({element:l,intro:l.getAttribute("data-intro"),step:parseInt(l.getAttribute("data-step"))})}n.sort(function(e,t){return e.step-t.step});o._introItems=n;if(u(e)){r.call(o);var c=e.querySelector(".introjs-skipbutton"),h=e.querySelector(".introjs-nextbutton");e.onkeydown=function(t){if(t.keyCode==27){s(e)}if([37,39].indexOf(t.keyCode)>=0){if(t.keyCode==37){i.call(o)}else if(t.keyCode==39){r.call(o)}}}}return false}function r(){if(this._currentStep==undefined){this._currentStep=0}else{++this._currentStep}if(this._introItems.length<=this._currentStep){s(this._targetElement);return}o.call(this,this._introItems[this._currentStep].element)}function i(){if(this._currentStep==0)return;o.call(this,this._introItems[--this._currentStep].element)}function s(e){var t=e.querySelector(".introjs-overlay");t.style.opacity=0;setTimeout(function(){t.parentNode.removeChild(t)},500);var n=e.querySelector(".introjs-helperLayer");n.parentNode.removeChild(n);var r=document.querySelector(".introjs-showElement");r.className=r.className.replace(/introjs-showElement/,"").trim();e.onkeydown=null}function o(e){var t=this,n=document.querySelector(".introjs-helperLayer"),i=a(e);if(n!=null){var o=n.querySelector(".introjs-helperNumberLayer"),u=n.querySelector(".introjs-tooltiptext"),f=n.querySelector(".introjs-tooltip");n.setAttribute("style","width: "+(i.width+10)+"px; "+"height:"+(i.height+10)+"px; "+"top:"+(i.top-5)+"px;"+"left: "+(i.left-5)+"px;");o.innerHTML=e.getAttribute("data-step");u.innerHTML=e.getAttribute("data-intro");var l=document.querySelector(".introjs-showElement");l.className=l.className.replace(/introjs-showElement/,"").trim();e.className+=" introjs-showElement";setTimeout(function(){f.style.bottom="-"+(a(f).height+10)+"px"},300)}else{e.className+=" introjs-showElement";var c=document.createElement("div"),h=document.createElement("span"),p=document.createElement("div");c.className="introjs-helperLayer";c.setAttribute("style","width: "+(i.width+10)+"px; "+"height:"+(i.height+10)+"px; "+"top:"+(i.top-5)+"px;"+"left: "+(i.left-5)+"px;");document.body.appendChild(c);h.className="introjs-helperNumberLayer";p.className="introjs-tooltip";h.innerHTML=e.getAttribute("data-step");p.innerHTML="<div class='introjs-tooltiptext'>"+e.getAttribute("data-intro")+"</div><div class='introjs-tooltipbuttons'></div>";c.appendChild(h);c.appendChild(p);var d=document.createElement("a");d.className="introjs-skipbutton";d.href="javascript:void(0);";d.innerHTML="Skip";var v=document.createElement("a");v.onclick=function(){r.call(t)};v.className="introjs-nextbutton";v.href="javascript:void(0);";v.innerHTML="Next →";d.onclick=function(){s(t._targetElement)};var m=p.querySelector(".introjs-tooltipbuttons");m.appendChild(d);m.appendChild(v);p.style.bottom="-"+(a(p).height+10)+"px"}if(typeof e.scrollIntoViewIfNeeded==="function"){e.scrollIntoViewIfNeeded()}}function u(e){var t=document.createElement("div"),n="";t.className="introjs-overlay";var r=a(e);if(r){n+="width: "+r.width+"px; height:"+r.height+"px; top:"+r.top+"px;left: "+r.left+"px;";t.setAttribute("style",n)}e.appendChild(t);t.onclick=function(){s(e)};setTimeout(function(){n+="opacity: .5;";t.setAttribute("style",n)},10);return true}function a(e){var t={};t.width=e.offsetWidth;t.height=e.offsetHeight;var n=0;var r=0;while(e&&!isNaN(e.offsetLeft)&&!isNaN(e.offsetTop)){n+=e.offsetLeft;r+=e.offsetTop;e=e.offsetParent}t.top=r;t.left=n;return t}var e="0.1.0";var f=function(e){if(typeof e==="object"){return new t(e)}else if(typeof e==="string"){var n=document.querySelector(e);if(n){return new t(n)}else{throw new Error("There's no element with given selector.")}}else{return new t(document.body)}};f.version=e;f.fn=t.prototype={clone:function(){return t(this)},start:function(){return n.call(this,this._targetElement)}};this["introJs"]=f})()
1  app/assets/stylesheets/introjs.css
@@ -0,0 +1 @@
+.introjs-overlay{position:absolute;z-index:999999;background-color:#000;opacity:0;-webkit-transition:all .3s ease-out;-moz-transition:all .3s ease-out;-o-transition:all .3s ease-out;-ms-transition:all .3s ease-out;transition:all .3s ease-out}.introjs-showElement{z-index:9999999;position:relative}.introjs-helperLayer{background-color:rgba(255,255,255,0.9);z-index:9999998;position:absolute;border-radius:4px;border:1px solid rgba(0,0,0,0.5);box-shadow:0 2px 15px rgba(0,0,0,0.4);-webkit-transition:all .3s ease-out;-moz-transition:all .3s ease-out;-o-transition:all .3s ease-out;-ms-transition:all .3s ease-out;transition:all .3s ease-out}.introjs-helperNumberLayer{z-index:9999999999!important;padding:2px;background:#ff3019;background:-moz-linear-gradient(top,#ff3019 0,#cf0404 100%);background:-webkit-gradient(linear,left top,left bottom,color-stop(0%,#ff3019),color-stop(100%,#cf0404));background:-webkit-linear-gradient(top,#ff3019 0,#cf0404 100%);background:-o-linear-gradient(top,#ff3019 0,#cf0404 100%);background:-ms-linear-gradient(top,#ff3019 0,#cf0404 100%);background:linear-gradient(to bottom,#ff3019 0,#cf0404 100%);filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#ff3019',endColorstr='#cf0404',GradientType=0);color:white;position:absolute;border-radius:50%;font-family:Arial,verdana,tahoma;font-size:13px;font-weight:bold;text-align:center;width:20px;border:3px solid white;box-shadow:0 2px 5px rgba(0,0,0,0.4);text-shadow:1px 1px 1px rgba(0,0,0,0.3);left:-16px;top:-16px}.introjs-tooltip:before{border:5px solid white;content:'';border-top-color:transparent;border-right-color:transparent;border-bottom-color:white;border-left-color:transparent;position:absolute;top:-10px}.introjs-tooltip{position:absolute;padding:10px;background-color:white;border-radius:3px;box-shadow:0 1px 10px rgba(0,0,0,0.4);-webkit-transition:all .1s ease-out;-moz-transition:all .1s ease-out;-o-transition:all .1s ease-out;-ms-transition:all .1s ease-out;transition:all .1s ease-out}.introjs-tooltipbuttons{font-size:10px;text-align:right}.introjs-tooltipbuttons .introjs-skipbutton{margin-right:5px;color:gray}.introjs-tooltipbuttons .introjs-nextbutton{font-weight:bold;color:#2071d3;font-size:11px}
20 introjs-rails.gemspec
@@ -0,0 +1,20 @@
+require File.expand_path("../lib/introjs-rails/version", __FILE__)
+
+Gem::Specification.new do |s|
+ s.name = "introjs-rails"
+ s.version = Introjs::Rails::VERSION
+ s.authors = ["Pablo Fernandez"]
+ s.email = ["heelhook@littleq.net"]
+ s.homepage = "https://github.com/heelhook/introjs-rails"
+ s.summary = %q{Integrate the excellent Intro.js javascript library with Rails asset pipeline}
+ s.description = %q{A better way for new feature introduction and step-by-step users guide for your website and project.}
+
+ s.files = `git ls-files`.split("\n")
+ s.require_paths = ["lib"]
+
+ s.add_dependency "thor", "~> 0.14"
+ s.add_runtime_dependency "sass-rails", ">= 3.2"
+ s.add_development_dependency "bundler", "~> 1.0"
+ s.add_development_dependency "rails", "~> 3.0"
+ s.add_development_dependency "httpclient", "~> 2.2"
+end
0  lib/introjs-rails.rb
No changes.
6 lib/introjs-rails/engine.rb
@@ -0,0 +1,6 @@
+module Introjs
+ module Rails
+ class Engine < ::Rails::Engine
+ end
+ end
+end
33 lib/introjs-rails/source_file.rb
@@ -0,0 +1,33 @@
+require "thor"
+require "json"
+require "httpclient"
+
+class SourceFile < Thor
+ include Thor::Actions
+
+ desc "fetch source files", "fetch source files from GitHub"
+ def fetch
+ filtered_tags = fetch_tags
+ tag = select("Which tag do you want to fetch?", filtered_tags)
+ self.destination_root = "app/assets"
+ remote = "https://github.com/usablica/intro.js"
+ get "#{remote}/raw/#{tag}/minified/intro.min.js", "javascripts/introjs.js"
+ get "#{remote}/raw/#{tag}/minified/introjs.min.css", "stylesheets/introjs.css"
+ end
+
+ private
+
+ def fetch_tags
+ http = HTTPClient.new
+ response = JSON.parse(http.get("https://api.github.com/repos/usablica/intro.js/tags").body)
+ response.map{|tag| tag["name"]}.sort
+ end
+
+ def select msg, elements
+ elements.each_with_index do |element, index|
+ say(block_given? ? yield(element, index + 1) : ("#{index + 1}. #{element.to_s}"))
+ end
+ result = ask(msg).to_i
+ elements[result - 1]
+ end
+end
5 lib/introjs-rails/version.rb
@@ -0,0 +1,5 @@
+module Introjs
+ module Rails
+ VERSION = "0.1.0"
+ end
+end
Please sign in to comment.
Something went wrong with that request. Please try again.