bootstrap-tour-rails 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,17 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in bootstrap-tour-rails.gemspec
4
+ gemspec
data/LICENSE ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2013 Tien Le
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,57 @@
1
+ # Bootstrap::Tour::Rails
2
+
3
+ Bootstrap is a toolkit from Twitter designed to kickstart development of webapps
4
+ and sites. It includes base CSS and HTML for typography, forms, buttons, tables,
5
+ grids, navigation, and more.
6
+
7
+ http://twitter.github.com/bootstrap/
8
+
9
+ Bootstrap tour is a plugin for Bootstrap. It provides quick and easy product
10
+ tours with Twitter Bootstrap Popovers.
11
+
12
+ https://github.com/sorich87/bootstrap-tour
13
+
14
+ Bootstrap-tour-rails project integrates it with Rails 3.1+ assets
15
+ pipeline.
16
+
17
+ https://github.com/tienle/bootstrap-tour-rails
18
+
19
+
20
+ ## Installation
21
+
22
+ Add this line to your application's Gemfile:
23
+
24
+ gem 'bootstrap-tour-rails'
25
+
26
+ And then execute:
27
+
28
+ $ bundle
29
+
30
+ Or install it yourself as:
31
+
32
+ $ gem install bootstrap-tour-rails
33
+
34
+
35
+ Assumes that you already have `bootstrap` and `jquery`.
36
+
37
+ ## Configuration
38
+
39
+ Add necessary javascript(s) files to app/assets/javascripts/application.js
40
+
41
+ ```javascript
42
+ //= require bootstrap-tour
43
+ ```
44
+
45
+ You may need to restart your rails server.
46
+
47
+ ## Usage
48
+
49
+ Reference here: http://sorich87.github.com/bootstrap-tour/index.html
50
+
51
+ ## Contributing
52
+
53
+ 1. Fork it
54
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
55
+ 3. Commit your changes (`git commit -am 'Added some feature'`)
56
+ 4. Push to the branch (`git push origin my-new-feature`)
57
+ 5. Create new Pull Request
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env rake
2
+ require "bundler/gem_tasks"
@@ -0,0 +1,17 @@
1
+ # -*- encoding: utf-8 -*-
2
+ require File.expand_path('../lib/bootstrap-tour-rails/version', __FILE__)
3
+
4
+ Gem::Specification.new do |gem|
5
+ gem.authors = ["Tien Le"]
6
+ gem.email = ["tienlx@gmail.com"]
7
+ gem.description = %q{Quick and easy product tours with Twitter Bootstrap Popovers.}
8
+ gem.summary = %q{ Bootstrap tour is a plugin for Bootstrap. It provides quick and easy product tours with Twitter Bootstrap Popovers.}
9
+ gem.homepage = "https://github.com/tienle/bootstrap-tour-rails"
10
+
11
+ gem.files = `git ls-files`.split($\)
12
+ gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
13
+ gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
14
+ gem.name = "bootstrap-tour-rails"
15
+ gem.require_paths = ["lib"]
16
+ gem.version = Bootstrap::Tour::Rails::VERSION
17
+ end
@@ -0,0 +1,14 @@
1
+ require 'rails'
2
+ require 'bootstrap-tour-rails/version'
3
+
4
+ module Bootstrap
5
+ module Tour
6
+ module Rails
7
+ class Engine < ::Rails::Engine
8
+ initializer "BootstrapTourRails precompile hook", :group => :all do |app|
9
+ app.config.assets.precompile += %w(bootstrap-tour.js)
10
+ end
11
+ end
12
+ end
13
+ end
14
+ end
@@ -0,0 +1,7 @@
1
+ module Bootstrap
2
+ module Tour
3
+ module Rails
4
+ VERSION = "0.0.1"
5
+ end
6
+ end
7
+ end
@@ -0,0 +1,320 @@
1
+ // Generated by CoffeeScript 1.4.0
2
+
3
+ /* ============================================================
4
+ # bootstrap-tour.js v0.1
5
+ # http://pushly.github.com/bootstrap-tour/
6
+ # ==============================================================
7
+ # Copyright 2012 Push.ly
8
+ #
9
+ # Licensed under the Apache License, Version 2.0 (the "License");
10
+ # you may not use this file except in compliance with the License.
11
+ # You may obtain a copy of the License at
12
+ #
13
+ # http://www.apache.org/licenses/LICENSE-2.0
14
+ #
15
+ # Unless required by applicable law or agreed to in writing, software
16
+ # distributed under the License is distributed on an "AS IS" BASIS,
17
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18
+ # See the License for the specific language governing permissions and
19
+ # limitations under the License.
20
+ */
21
+
22
+
23
+ (function() {
24
+
25
+ (function($, window) {
26
+ var Tour, document;
27
+ document = window.document;
28
+ Tour = (function() {
29
+
30
+ function Tour(options) {
31
+ var _this = this;
32
+ this._options = $.extend({
33
+ name: 'tour',
34
+ labels: {
35
+ end: 'End tour',
36
+ next: 'Next &raquo;',
37
+ prev: '&laquo; Prev'
38
+ },
39
+ keyboard: true,
40
+ useLocalStorage: false,
41
+ afterSetState: function(key, value) {},
42
+ afterGetState: function(key, value) {},
43
+ onStart: function(tour) {},
44
+ onEnd: function(tour) {},
45
+ onShow: function(tour) {},
46
+ onHide: function(tour) {},
47
+ onShown: function(tour) {}
48
+ }, options);
49
+ this._steps = [];
50
+ this.setCurrentStep();
51
+ this._onresize(function() {
52
+ if (!_this.ended) {
53
+ return _this.showStep(_this._current);
54
+ }
55
+ });
56
+ }
57
+
58
+ Tour.prototype.setState = function(key, value) {
59
+ if (this._options.useLocalStorage) {
60
+ window.localStorage.setItem("" + this._options.name + "_" + key, value);
61
+ } else {
62
+ $.cookie("" + this._options.name + "_" + key, value, {
63
+ expires: 36500,
64
+ path: '/'
65
+ });
66
+ }
67
+ return this._options.afterSetState(key, value);
68
+ };
69
+
70
+ Tour.prototype.getState = function(key) {
71
+ var value;
72
+ if (this._options.useLocalStorage) {
73
+ value = window.localStorage.getItem("" + this._options.name + "_" + key);
74
+ } else {
75
+ value = $.cookie("" + this._options.name + "_" + key);
76
+ }
77
+ this._options.afterGetState(key, value);
78
+ return value;
79
+ };
80
+
81
+ Tour.prototype.addStep = function(step) {
82
+ return this._steps.push(step);
83
+ };
84
+
85
+ Tour.prototype.getStep = function(i) {
86
+ if (this._steps[i] != null) {
87
+ return $.extend({
88
+ path: "",
89
+ placement: "right",
90
+ title: "",
91
+ content: "",
92
+ next: i === this._steps.length - 1 ? -1 : i + 1,
93
+ prev: i - 1,
94
+ animation: true,
95
+ onShow: this._options.onShow,
96
+ onHide: this._options.onHide,
97
+ onShown: this._options.onShown
98
+ }, this._steps[i]);
99
+ }
100
+ };
101
+
102
+ Tour.prototype.start = function(force) {
103
+ var _this = this;
104
+ if (force == null) {
105
+ force = false;
106
+ }
107
+ if (this.ended() && !force) {
108
+ return;
109
+ }
110
+ $(document).off("click.bootstrap-tour", ".popover .next").on("click.bootstrap-tour", ".popover .next", function(e) {
111
+ e.preventDefault();
112
+ return _this.next();
113
+ });
114
+ $(document).off("click.bootstrap-tour", ".popover .prev").on("click.bootstrap-tour", ".popover .prev", function(e) {
115
+ e.preventDefault();
116
+ return _this.prev();
117
+ });
118
+ $(document).off("click.bootstrap-tour", ".popover .end").on("click.bootstrap-tour", ".popover .end", function(e) {
119
+ e.preventDefault();
120
+ return _this.end();
121
+ });
122
+ this._setupKeyboardNavigation();
123
+ if (this._options.onStart != null) {
124
+ this._options.onStart(this);
125
+ }
126
+ return this.showStep(this._current);
127
+ };
128
+
129
+ Tour.prototype.next = function() {
130
+ this.hideStep(this._current);
131
+ return this.showNextStep();
132
+ };
133
+
134
+ Tour.prototype.prev = function() {
135
+ this.hideStep(this._current);
136
+ return this.showPrevStep();
137
+ };
138
+
139
+ Tour.prototype.end = function() {
140
+ this.hideStep(this._current);
141
+ $(document).off(".bootstrap-tour");
142
+ this.setState("end", "yes");
143
+ if (this._options.onEnd != null) {
144
+ return this._options.onEnd(this);
145
+ }
146
+ };
147
+
148
+ Tour.prototype.ended = function() {
149
+ return !!this.getState("end");
150
+ };
151
+
152
+ Tour.prototype.restart = function() {
153
+ this.setState("current_step", null);
154
+ this.setState("end", null);
155
+ this.setCurrentStep(0);
156
+ return this.start();
157
+ };
158
+
159
+ Tour.prototype.hideStep = function(i) {
160
+ var step;
161
+ step = this.getStep(i);
162
+ if (step.onHide != null) {
163
+ step.onHide(this);
164
+ }
165
+ return $(step.element).popover("hide");
166
+ };
167
+
168
+ Tour.prototype.showStep = function(i) {
169
+ var step;
170
+ step = this.getStep(i);
171
+ if (!step) {
172
+ return;
173
+ }
174
+ this.setCurrentStep(i);
175
+ if (step.path !== "" && document.location.pathname !== step.path && document.location.pathname.replace(/^.*[\\\/]/, '') !== step.path) {
176
+ document.location.href = step.path;
177
+ return;
178
+ }
179
+ if (step.onShow != null) {
180
+ step.onShow(this);
181
+ }
182
+ if (!((step.element != null) && $(step.element).length !== 0 && $(step.element).is(":visible"))) {
183
+ this.showNextStep();
184
+ return;
185
+ }
186
+ this._showPopover(step, i);
187
+ if (step.onShown != null) {
188
+ return step.onShown(this);
189
+ }
190
+ };
191
+
192
+ Tour.prototype.setCurrentStep = function(value) {
193
+ if (value != null) {
194
+ this._current = value;
195
+ return this.setState("current_step", value);
196
+ } else {
197
+ this._current = this.getState("current_step");
198
+ if (this._current === null || this._current === "null") {
199
+ return this._current = 0;
200
+ } else {
201
+ return this._current = parseInt(this._current);
202
+ }
203
+ }
204
+ };
205
+
206
+ Tour.prototype.showNextStep = function() {
207
+ var step;
208
+ step = this.getStep(this._current);
209
+ return this.showStep(step.next);
210
+ };
211
+
212
+ Tour.prototype.showPrevStep = function() {
213
+ var step;
214
+ step = this.getStep(this._current);
215
+ return this.showStep(step.prev);
216
+ };
217
+
218
+ Tour.prototype._showPopover = function(step, i) {
219
+ var content, nav, options, tip,
220
+ _this = this;
221
+ content = "" + step.content + "<br /><p>";
222
+ options = $.extend({}, this._options);
223
+ if (step.options) {
224
+ $.extend(options, step.options);
225
+ }
226
+ if (step.reflex) {
227
+ $(step.element).css("cursor", "pointer");
228
+ $(step.element).on("click", function(e) {
229
+ $(step.element).css("cursor", "auto");
230
+ return _this.next();
231
+ });
232
+ }
233
+ nav = [];
234
+ if (step.prev >= 0) {
235
+ nav.push("<a href='#" + step.prev + "' class='prev'>" + options.labels.prev + "</a>");
236
+ }
237
+ if (step.next >= 0) {
238
+ nav.push("<a href='#" + step.next + "' class='next'>" + options.labels.next + "</a>");
239
+ }
240
+ content += nav.join(" | ");
241
+ content += "<a href='#' class='pull-right end'>" + options.labels.end + "</a>";
242
+ $(step.element).popover('destroy').popover({
243
+ placement: step.placement,
244
+ trigger: "manual",
245
+ title: step.title,
246
+ content: content,
247
+ html: true,
248
+ animation: step.animation
249
+ }).popover("show");
250
+ tip = $(step.element).data("popover").tip();
251
+ this._reposition(tip);
252
+ return this._scrollIntoView(tip);
253
+ };
254
+
255
+ Tour.prototype._reposition = function(tip) {
256
+ var offsetBottom, offsetRight, tipOffset;
257
+ tipOffset = tip.offset();
258
+ offsetBottom = $(document).outerHeight() - tipOffset.top - $(tip).outerHeight();
259
+ if (offsetBottom < 0) {
260
+ tipOffset.top = tipOffset.top + offsetBottom;
261
+ }
262
+ offsetRight = $(document).outerWidth() - tipOffset.left - $(tip).outerWidth();
263
+ if (offsetRight < 0) {
264
+ tipOffset.left = tipOffset.left + offsetRight;
265
+ }
266
+ if (tipOffset.top < 0) {
267
+ tipOffset.top = 0;
268
+ }
269
+ if (tipOffset.left < 0) {
270
+ tipOffset.left = 0;
271
+ }
272
+ return tip.offset(tipOffset);
273
+ };
274
+
275
+ Tour.prototype._scrollIntoView = function(tip) {
276
+ var tipRect;
277
+ tipRect = tip.get(0).getBoundingClientRect();
278
+ if (!(tipRect.top > 0 && tipRect.bottom < $(window).height() && tipRect.left > 0 && tipRect.right < $(window).width())) {
279
+ return tip.get(0).scrollIntoView(true);
280
+ }
281
+ };
282
+
283
+ Tour.prototype._onresize = function(cb, timeout) {
284
+ return $(window).resize(function() {
285
+ clearTimeout(timeout);
286
+ return timeout = setTimeout(cb, 100);
287
+ });
288
+ };
289
+
290
+ Tour.prototype._setupKeyboardNavigation = function() {
291
+ var _this = this;
292
+ if (this._options.keyboard) {
293
+ return $(document).on("keyup.bootstrap-tour", function(e) {
294
+ if (!e.which) {
295
+ return;
296
+ }
297
+ switch (e.which) {
298
+ case 39:
299
+ e.preventDefault();
300
+ if (_this._current < _this._steps.length - 1) {
301
+ return _this.next();
302
+ }
303
+ break;
304
+ case 37:
305
+ e.preventDefault();
306
+ if (_this._current > 0) {
307
+ return _this.prev();
308
+ }
309
+ }
310
+ });
311
+ }
312
+ };
313
+
314
+ return Tour;
315
+
316
+ })();
317
+ return window.Tour = Tour;
318
+ })(jQuery, window);
319
+
320
+ }).call(this);
@@ -0,0 +1,2 @@
1
+ //= require ./jquery.cookie
2
+ //= require ./bootstrap-tour
@@ -0,0 +1,90 @@
1
+ /*!
2
+ * jQuery Cookie Plugin v1.3.1
3
+ * https://github.com/carhartl/jquery-cookie
4
+ *
5
+ * Copyright 2013 Klaus Hartl
6
+ * Released under the MIT license
7
+ */
8
+ (function ($, document, undefined) {
9
+
10
+ var pluses = /\+/g;
11
+
12
+ function raw(s) {
13
+ return s;
14
+ }
15
+
16
+ function decoded(s) {
17
+ return unRfc2068(decodeURIComponent(s.replace(pluses, ' ')));
18
+ }
19
+
20
+ function unRfc2068(value) {
21
+ if (value.indexOf('"') === 0) {
22
+ // This is a quoted cookie as according to RFC2068, unescape
23
+ value = value.slice(1, -1).replace(/\\"/g, '"').replace(/\\\\/g, '\\');
24
+ }
25
+ return value;
26
+ }
27
+
28
+ function fromJSON(value) {
29
+ return config.json ? JSON.parse(value) : value;
30
+ }
31
+
32
+ var config = $.cookie = function (key, value, options) {
33
+
34
+ // write
35
+ if (value !== undefined) {
36
+ options = $.extend({}, config.defaults, options);
37
+
38
+ if (value === null) {
39
+ options.expires = -1;
40
+ }
41
+
42
+ if (typeof options.expires === 'number') {
43
+ var days = options.expires, t = options.expires = new Date();
44
+ t.setDate(t.getDate() + days);
45
+ }
46
+
47
+ value = config.json ? JSON.stringify(value) : String(value);
48
+
49
+ return (document.cookie = [
50
+ encodeURIComponent(key), '=', config.raw ? value : encodeURIComponent(value),
51
+ options.expires ? '; expires=' + options.expires.toUTCString() : '', // use expires attribute, max-age is not supported by IE
52
+ options.path ? '; path=' + options.path : '',
53
+ options.domain ? '; domain=' + options.domain : '',
54
+ options.secure ? '; secure' : ''
55
+ ].join(''));
56
+ }
57
+
58
+ // read
59
+ var decode = config.raw ? raw : decoded;
60
+ var cookies = document.cookie.split('; ');
61
+ var result = key ? null : {};
62
+ for (var i = 0, l = cookies.length; i < l; i++) {
63
+ var parts = cookies[i].split('=');
64
+ var name = decode(parts.shift());
65
+ var cookie = decode(parts.join('='));
66
+
67
+ if (key && key === name) {
68
+ result = fromJSON(cookie);
69
+ break;
70
+ }
71
+
72
+ if (!key) {
73
+ result[name] = fromJSON(cookie);
74
+ }
75
+ }
76
+
77
+ return result;
78
+ };
79
+
80
+ config.defaults = {};
81
+
82
+ $.removeCookie = function (key, options) {
83
+ if ($.cookie(key) !== null) {
84
+ $.cookie(key, null, options);
85
+ return true;
86
+ }
87
+ return false;
88
+ };
89
+
90
+ })(jQuery, document);
metadata ADDED
@@ -0,0 +1,57 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: bootstrap-tour-rails
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Tien Le
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2013-03-06 00:00:00.000000000 Z
13
+ dependencies: []
14
+ description: Quick and easy product tours with Twitter Bootstrap Popovers.
15
+ email:
16
+ - tienlx@gmail.com
17
+ executables: []
18
+ extensions: []
19
+ extra_rdoc_files: []
20
+ files:
21
+ - .gitignore
22
+ - Gemfile
23
+ - LICENSE
24
+ - README.md
25
+ - Rakefile
26
+ - bootstrap-tour-rails.gemspec
27
+ - lib/bootstrap-tour-rails.rb
28
+ - lib/bootstrap-tour-rails/version.rb
29
+ - vendor/assets/javascripts/bootstrap-tour/bootstrap-tour.js
30
+ - vendor/assets/javascripts/bootstrap-tour/index.js
31
+ - vendor/assets/javascripts/bootstrap-tour/jquery.cookie.js
32
+ homepage: https://github.com/tienle/bootstrap-tour-rails
33
+ licenses: []
34
+ post_install_message:
35
+ rdoc_options: []
36
+ require_paths:
37
+ - lib
38
+ required_ruby_version: !ruby/object:Gem::Requirement
39
+ none: false
40
+ requirements:
41
+ - - ! '>='
42
+ - !ruby/object:Gem::Version
43
+ version: '0'
44
+ required_rubygems_version: !ruby/object:Gem::Requirement
45
+ none: false
46
+ requirements:
47
+ - - ! '>='
48
+ - !ruby/object:Gem::Version
49
+ version: '0'
50
+ requirements: []
51
+ rubyforge_project:
52
+ rubygems_version: 1.8.24
53
+ signing_key:
54
+ specification_version: 3
55
+ summary: Bootstrap tour is a plugin for Bootstrap. It provides quick and easy product
56
+ tours with Twitter Bootstrap Popovers.
57
+ test_files: []