Index: reference/jquery-plugins/guided-tour-arrow/.gitignore =================================================================== diff -u --- reference/jquery-plugins/guided-tour-arrow/.gitignore (revision 0) +++ reference/jquery-plugins/guided-tour-arrow/.gitignore (revision 10417a3908ef7516203be30712af4d355287973b) @@ -0,0 +1,6 @@ +.sass-cache +.publish +bower_components +node_modules +config.rb +*.TODO \ No newline at end of file Index: reference/jquery-plugins/guided-tour-arrow/LICENSE =================================================================== diff -u --- reference/jquery-plugins/guided-tour-arrow/LICENSE (revision 0) +++ reference/jquery-plugins/guided-tour-arrow/LICENSE (revision 10417a3908ef7516203be30712af4d355287973b) @@ -0,0 +1,22 @@ +The MIT License (MIT) + +Copyright (c) 2014 epetrova + +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. + Index: reference/jquery-plugins/guided-tour-arrow/README.md =================================================================== diff -u --- reference/jquery-plugins/guided-tour-arrow/README.md (revision 0) +++ reference/jquery-plugins/guided-tour-arrow/README.md (revision 10417a3908ef7516203be30712af4d355287973b) @@ -0,0 +1,155 @@ +guides.js +====== +Guides.js is a lightweight javascript library for making guided website tours. It finds the element you want to highlight, creates a guide element using the html you specified in the configuration options and connects the guide and the highlighted element with an svg arrow. + +#Demo + +[http://ejulianova.github.io/guides/](http://ejulianova.github.io/guides/) + +#Getting started + +Once you have downloaded the source, simply include guides.css in the head of your page: + +```html + + ... + + +``` + +and guides.js in your page scripts section. Make sure you include it after jquery: + +```html + ... + + + + +

Download This Plugin Back To jQueryScript

+

+

An easy-to-use jQuery plugin that adds an intuitive, interactive, dynamic guided tour to your website.

+

+ Main call to action + Secondary action +

+ + + + +
+
+ +
+
+
+ PlaceholderThumbnail + +
+

This is a wider card with supporting text below as a natural lead-in to additional content. This content is a little bit longer.

+
+
+ + +
+ 9 mins +
+
+
+
+
+
+ PlaceholderThumbnail + +
+

This is a wider card with supporting text below as a natural lead-in to additional content. This content is a little bit longer.

+
+
+ + +
+ 9 mins +
+
+
+
+
+
+ PlaceholderThumbnail + +
+

This is a wider card with supporting text below as a natural lead-in to additional content. This content is a little bit longer.

+
+
+ + +
+ 9 mins +
+
+
+
+ +
+
+ PlaceholderThumbnail + +
+

This is a wider card with supporting text below as a natural lead-in to additional content. This content is a little bit longer.

+
+
+ + +
+ 9 mins +
+
+
+
+
+
+ PlaceholderThumbnail + +
+

This is a wider card with supporting text below as a natural lead-in to additional content. This content is a little bit longer.

+
+
+ + +
+ 9 mins +
+
+
+
+
+
+ PlaceholderThumbnail + +
+

This is a wider card with supporting text below as a natural lead-in to additional content. This content is a little bit longer.

+
+
+ + +
+ 9 mins +
+
+
+
+ +
+
+ PlaceholderThumbnail + +
+

This is a wider card with supporting text below as a natural lead-in to additional content. This content is a little bit longer.

+
+
+ + +
+ 9 mins +
+
+
+
+
+
+ PlaceholderThumbnail + +
+

This is a wider card with supporting text below as a natural lead-in to additional content. This content is a little bit longer.

+
+
+ + +
+ 9 mins +
+
+
+
+
+
+ PlaceholderThumbnail + +
+

This is a wider card with supporting text below as a natural lead-in to additional content. This content is a little bit longer.

+
+
+ + +
+ 9 mins +
+
+
+
+
+
+
+ + + + + + + + + + + + Index: reference/jquery-plugins/guided-tour-arrow/karma.conf.js =================================================================== diff -u --- reference/jquery-plugins/guided-tour-arrow/karma.conf.js (revision 0) +++ reference/jquery-plugins/guided-tour-arrow/karma.conf.js (revision 10417a3908ef7516203be30712af4d355287973b) @@ -0,0 +1,17 @@ +module.exports = function(config) { + config.set({ + browsers: ['PhantomJS'], + frameworks: ['jasmine', 'browserify'], + files: [ + 'node_modules/jquery/dist/jquery.js', + 'test/**/*.spec.js' + ], + preprocessors: { + 'test/**/*.spec.js': [ 'browserify' ] + }, + plugins : ['karma-jasmine', 'karma-phantomjs-launcher', 'karma-browserify'], + browserify: { + debug: true + } + }); +}; \ No newline at end of file Index: reference/jquery-plugins/guided-tour-arrow/package.json =================================================================== diff -u --- reference/jquery-plugins/guided-tour-arrow/package.json (revision 0) +++ reference/jquery-plugins/guided-tour-arrow/package.json (revision 10417a3908ef7516203be30712af4d355287973b) @@ -0,0 +1,73 @@ +{ + "name": "guides", + "version": "1.3.0", + "description": "Simple way to highlighting DOM elements and guide your users with step-by-step welcome tours in your web app.", + "title": "Guides.js - highlight DOM elements and make step-by-step website tours", + "author": { + "name": "Elena Petrova", + "email": "elena.julianova@gmail.com", + "url": "http://ejulianova.github.io/guides/" + }, + "main": "guides.js", + "dependencies": { + "jquery": "^3.0.0" + }, + "devDependencies": { + "gulp": "^3.9.1", + "gulp-banner": "^0.1.3", + "gulp-browserify": "^0.5.1", + "gulp-connect": "^5.6.1", + "gulp-gh-pages": "^0.5.4", + "gulp-rename": "^1.4.0", + "gulp-sass": "^4.0.1", + "gulp-uglify": "^3.0.1", + "jasmine": "^2.4.1", + "karma": "^3.0.0", + "karma-browserify": "^5.3.0", + "karma-jasmine": "^1.1.2", + "karma-phantomjs-launcher": "^1.0.4", + "open": "0.0.5", + "phantomjs": "^2.1.7", + "phantomjs-prebuilt": "^2.1.16" + }, + "scripts": { + "test": "./node_modules/.bin/gulp test", + "build": "./node_modules/.bin/gulp build", + "start": "./node_modules/.bin/gulp" + }, + "keywords": [ + "guide", + "guides", + "guiders", + "guided", + "tour", + "welcome", + "helper", + "wizard", + "highlight", + "jquery-plugin", + "jquery", + "plugin", + "step-by-step", + "intro", + "introduction", + "ecosystem:jquery" + ], + "docs": "http://ejulianova.github.io/guides/", + "demo": "http://ejulianova.github.io/guides/", + "homepage": "http://ejulianova.github.io/guides/", + "repository": { + "type": "git", + "url": "https://github.com/ejulianova/guides.git" + }, + "bugs": { + "url": "https://github.com/ejulianova/guides/issues" + }, + "licenses": [ + { + "type": "MIT", + "url": "https://opensource.org/licenses/MIT" + } + ], + "license": "MIT" +} Index: reference/jquery-plugins/guided-tour-arrow/src/guides.js =================================================================== diff -u --- reference/jquery-plugins/guided-tour-arrow/src/guides.js (revision 0) +++ reference/jquery-plugins/guided-tour-arrow/src/guides.js (revision 10417a3908ef7516203be30712af4d355287973b) @@ -0,0 +1,21 @@ +'use strict'; + +var Guides = require('./modules/Guides'); + +$.fn.guides = function (option, optionData) { + return this.each(function () { + var $this = $(this), + data = $this.data('guides'), + options = typeof option === 'object' && option; + + if (!data && typeof options == 'string') return; + if (!data) $this.data('guides', (data = new Guides(this, options))); + if (typeof option == 'string') data[option](optionData); + }); +}; + +$.guides = function (options) { + return new Guides(null, options); +}; + +$.fn.guides.Constructor = Guides; \ No newline at end of file Index: reference/jquery-plugins/guided-tour-arrow/src/guides.scss =================================================================== diff -u --- reference/jquery-plugins/guided-tour-arrow/src/guides.scss (revision 0) +++ reference/jquery-plugins/guided-tour-arrow/src/guides.scss (revision 10417a3908ef7516203be30712af4d355287973b) @@ -0,0 +1,74 @@ +.guides-canvas, .guides-mask, .guides-overlay { + position: absolute; + top: 0; + left: 0; + bottom: 0; + right: 0; +} + +.guides-overlay { + background: rgba(0,0,0,.6); + z-index: 99996; +} + +.guides-mask { + z-index: 99998; +} + +.guides-current-element { + z-index: 99997; + position: relative; +} + +@-webkit-keyframes fadeIn { + 0% { opacity: 0; } + 100% { opacity: .5; } +} +@-moz-keyframes fadeIn { + 0% { opacity: 0; } + 100% { opacity: .5; } +} +@-o-keyframes fadeIn { + 0% { opacity: 0; } + 100% { opacity: .5; } +} +@keyframes fadeIn { + 0% { opacity: 0; } + 100% { opacity: .5; } +} + +.guides-fade-in { + -webkit-animation: fadeIn .25s ease; /* Safari 4+ */ + -moz-animation: fadeIn .25s ease; /* Fx 5+ */ + -o-animation: fadeIn .25s ease; /* Opera 12+ */ + animation: fadeIn .25s ease; /* IE 10+ */ +} + +.guides-guide { + color: #fff; + font-size: 1.5rem; + text-shadow: 0 0 10px #000; + position: absolute; + margin: 5px; + z-index: 99999; + svg { + position: absolute; + top: 0; + left: 0; + } + span { + display: inline-block; + padding: 10px; + font-size: 2rem; + } +} + +.guides-top svg { + top: auto; + bottom: 0; +} + +.guides-left svg { + left: auto; + right: 0; +} \ No newline at end of file Index: reference/jquery-plugins/guided-tour-arrow/src/modules/Guide.js =================================================================== diff -u --- reference/jquery-plugins/guided-tour-arrow/src/modules/Guide.js (revision 0) +++ reference/jquery-plugins/guided-tour-arrow/src/modules/Guide.js (revision 10417a3908ef7516203be30712af4d355287973b) @@ -0,0 +1,229 @@ +var format = require('./format'); + +var Guide = function (guide, $container, options) { + this.guide = guide; + this._distance = guide.distance || options.distance; + this._color = guide.color || options.color; + this._class = guide.cssClass || options.cssClass || ''; + this.$highlightedElement = $(guide.element).addClass('guides-current-element'); + this.$container = $container; + this.init(); +}; + +Guide.prototype._arrowSize = 10; +// Mx1,y1, Cdx1,dy1,dx2,dy2,x2,y2 +// (x1,y1) - start point +// (dx1,dy1) - curve control point 1 +// (dx2,dy2) - curve control point 2 +// (x2,y2) - end point +Guide.prototype._path = 'M{0},{1} C{2},{3},{4},{5},{6},{7}'; +Guide.prototype._arrowTemplate = '\ + \ + \ + \ + \ + \ + \ +'; + +Guide.prototype.init = function() { + this.$guide = $('
', { + 'class': 'guides-fade-in guides-guide ' + this._class, + 'html': '' + this.guide.html + '' + }); + this._position(); + return this; +}; + +Guide.prototype._position = function () { + if (this.$highlightedElement && this.$highlightedElement.length > 0) { + this._attachToElement(); + this.$guide.appendTo(this.$container); + this._renderArrow(); + } else { + this._center(); + } + this._scrollIntoView(); +}; + +Guide.prototype._center = function () { + this.$guide + .css('visibility', 'hidden') + .appendTo(this.$container) + .addClass('guides-center') + .css({ + left: 0, + right: 0, + textAlign: 'center', + top: (window.innerHeight / 2) - (this.$guide.outerHeight() / 2) + }).css('visibility', 'visible'); +}; + +Guide.prototype._attachToElement = function () { + var elOffset = this.$highlightedElement.offset(), + docWidth = $('body').width(), + docHeight = $('body').height(), + leftSpace = elOffset.left, + topSpace = elOffset.top, + highlightedElementWidth = this.$highlightedElement.outerWidth(), + highlightedElementHeight = this.$highlightedElement.outerHeight(), + rightSpace = docWidth - leftSpace - highlightedElementWidth, + bottomSpace = docHeight - topSpace - highlightedElementHeight, + css = { + color: this._color, + top: docHeight / 2 > elOffset.top ? elOffset.top : 'auto', + left: docWidth / 2 > elOffset.left ? elOffset.left : 'auto', + right: docWidth / 2 > elOffset.left ? 'auto' : docWidth - elOffset.left - highlightedElementWidth, + bottom: docHeight / 2 > elOffset.top ? 'auto' : elOffset.bottom + }; + + switch (Math.max(leftSpace, rightSpace, topSpace, bottomSpace)) { + case leftSpace: + this.position = 'left'; + css.paddingRight = this._distance; + css.right = $(document).width() - elOffset.left; + css.left = 'auto'; + break; + case topSpace: + this.position = 'top'; + css.paddingBottom = this._distance; + css.bottom = $(document).height() - elOffset.top; + css.top = 'auto'; + break; + case rightSpace: + this.position = 'right'; + css.paddingLeft = this._distance; + css.left = elOffset.left + highlightedElementWidth; + css.right = 'auto'; + break; + default: + this.position = 'bottom'; + css.paddingTop = this._distance; + css.top = elOffset.top + highlightedElementHeight; + css.bottom = 'auto'; + break; + } + this.$guide.addClass('guides-' + this.position).css(css); +}; + +Guide.prototype._renderArrow = function() { + this._width = this.$guide.outerWidth(); + this._height = this.$guide.outerHeight(); + this.$guide.append(format(this._arrowTemplate, + this._width, this._distance, this[this.position](), this._arrowSize, this._color)); +}; + +Guide.prototype.top = function () { + var coord = this._verticalAlign(); + return this._getPath(coord); +}; + +Guide.prototype.bottom = function () { + var coord = this._verticalAlign(true); + return this._getPath(coord); +}; + +Guide.prototype.left = function () { + var coord = this._horizontalAlign(); + return this._getPath(coord); +}; + +Guide.prototype.right = function () { + var coord = this._horizontalAlign(true); + return this._getPath(coord); +}; + +Guide.prototype._getPath = function (coord) { + return format(this._path, coord.x1, coord.y1, coord.dx1, coord.dy1, coord.dx2, coord.dy2, coord.x2, coord.y2); +}; + +Guide.prototype._getFluctuation = function () { + return Math.floor(Math.random() * 20) + 10; +}; + +Guide.prototype._verticalAlign = function (bottom) { + var x1 = this._width / 2, + y1 = bottom ? this._distance : 0, + x2 = Math.max( + Math.min( + this.$highlightedElement.offset().left + (this.$highlightedElement.outerWidth() / 2) - this.$guide.offset().left, + this._width - this._arrowSize), + this._arrowSize), + y2 = bottom ? this._arrowSize : this._distance - this._arrowSize; + return { + x1: x1, + y1: y1, + x2: x2, + y2: y2, + dx1: Math.max(0, Math.min(Math.abs((2 * x1) - x2) / 3, this._width) + this._getFluctuation()), + dy1: bottom + ? Math.max(0, y2 + (Math.abs(y1 - y2) * 3 / 4)) + : Math.max(0, y1 + (Math.abs(y1 - y2) * 3 / 4)), + dx2: Math.max(0, Math.min(Math.abs(x1 - (x2 * 3)) / 2, this._width) - this._getFluctuation()), + dy2: bottom + ? Math.max(0, y2 + (Math.abs(y1 - y2) * 3 / 4)) + : Math.max(0, y1 + (Math.abs(y1 - y2) * 3 / 4)) + } +}; + +Guide.prototype._horizontalAlign = function (right) { + var x1 = right ? this._distance : this._width - this._distance, + y1 = this._height / 2, + x2 = right ? this._arrowSize : this._width - this._arrowSize, + y2 = Math.max( + Math.min( + this.$highlightedElement.offset().top + (this.$highlightedElement.outerHeight() / 2) - this.$guide.offset().top, + this._height - this._arrowSize), + this._arrowSize); + return { + x1: x1, + y1: y1, + x2: x2, + y2: y2, + dx1: right + ? Math.max(0, x2 + (Math.abs(x1 - x2) * 3 / 4)) + : Math.max(0, x1 + Math.abs(x1 - x2) * 3 / 4), + dy1: Math.max(0, Math.min(Math.abs((2 * y1) - y2) / 3, this._height) + this._getFluctuation()), + dx2: right + ? Math.max(0, x2 + (Math.abs(x1 - x2) * 3 / 4)) + : Math.max(0, x1 + Math.abs(x1 - x2) * 3 / 4), + dy2: Math.max(0, Math.min(Math.abs(y1 - (y2 * 3)) / 2, this._height) + this._getFluctuation()) + } +}; + +Guide.prototype._scrollIntoView = function () { + if (this.$highlightedElement.length === 0) { + $('html,body').animate({ + scrollTop: 0 + }, 500); + return; + } + var guideOffset = this.$guide.offset(), + top = guideOffset.top, + bottom = guideOffset.top + this.$guide.outerHeight(), + left = guideOffset.left, + right = guideOffset.left + this.$guide.outerWidth(), + scrollTop = $(document).scrollTop(), + scrollLeft = $(document).scrollLeft(); + + //scroll vertically to element if it is not visible in the view port + if (scrollTop > top || scrollTop + $(window).height() < bottom) { + $('html,body').animate({ + scrollTop: this.position === 'bottom' ? top - 100 : top + }, 500); + } + + //scroll horizontally to element if it is not visible in the view port + if (scrollLeft > left || scrollLeft + $(window).width() < right) { + $('html,body').animate({ + scrollLeft: this.position === 'righ' ? left - 100 : left + }, 500); + } +}; + +Guide.prototype.destroy = function() { + this.$highlightedElement.removeClass('guides-current-element'); + this.$guide.remove(); +}; + +module.exports = Guide; \ No newline at end of file Index: reference/jquery-plugins/guided-tour-arrow/src/modules/Guides.js =================================================================== diff -u --- reference/jquery-plugins/guided-tour-arrow/src/modules/Guides.js (revision 0) +++ reference/jquery-plugins/guided-tour-arrow/src/modules/Guides.js (revision 10417a3908ef7516203be30712af4d355287973b) @@ -0,0 +1,156 @@ +var Guide = require('./Guide'); + +var Guides = function (element, options) { + this.element = element; + this.$element = $(element); + this.options = {}; + this._current = 0; + this.setOptions(options); + if (element) { + this.$element.on('click.guides', $.proxy(this.start, this)); + } +}; + +Guides.DEFAULTS = { + distance: 100, + color: '#fff', + cssClass: '', + guides: [] +}; + +Guides.prototype.start = function(e) { + if (e) { + e.preventDefault(); + } + if (this._isAlreadyRunning()) { + return this; + } + this._current = 0; + this._renderCanvas() + ._renderGuide(this.options.guides[this._current]) + ._callback('start'); + return this; +}; + +Guides.prototype.end = function() { + if (this.$canvas) { + this.$canvas.remove(); + this.$canvas = null; + } + if (this._currentGuide) { + this._currentGuide.destroy(); + this._currentGuide = null; + } + $(document).off('keyup.guides'); + this._callback('end'); + return this; +}; + +Guides.prototype.next = function () { + this._renderGuide(this.options.guides[++this._current]) + ._callback('next'); + return this; +}; + +Guides.prototype.prev = function () { + if (!this._current) { + return; + } + this._renderGuide(this.options.guides[--this._current]) + ._callback('prev'); + return this; +}; + +Guides.prototype.setOptions = function(options) { + if (typeof options !== 'object') { + return this; + } + this.options = $.extend({}, Guides.DEFAULTS, this.options, options); +}; + +Guides.prototype.destroy = function() { + this.end(); + this.$element.off('click.guides'); + this._callback('destroy'); + return this; +}; + +Guides.prototype._callback = function (eventName) { + var callback = this.options[eventName], + eventObject = { + sender: this + }; + + if (this._currentGuide) { + eventObject.$element = this._currentGuide.guide.element; + eventObject.$guide = this._currentGuide.$element; + } + + if ($.isFunction(callback)) { + callback.apply(this, [eventObject]); + } +}; + +Guides.prototype._isAlreadyRunning = function () { + return !!this.$canvas; +}; + +Guides.prototype._renderCanvas = function () { + this.$canvas = $('
', { + 'class': 'guides-canvas guides-fade-in', + 'html': '
' + }).appendTo('body'); + this._bindNavigation(); + return this; +}; + +Guides.prototype._renderGuide = function (guide) { + if (!guide) { //no more guides + this.end(); + return this; + } + + if (this._currentGuide) { + this._currentGuide.destroy(); + } + + this._callback('render', guide); + + if ($.isFunction(guide.render)) { + guide.render.apply(this, [guide]); + } + + this._currentGuide = new Guide(guide, this.$canvas, this.options); + return this; +}; + +Guides.prototype._bindNavigation = function () { + this.$canvas.on('click.guides', $.proxy(this._onCanvasClick, this)); + $(document).on('keyup.guides', $.proxy(this._onDocKeyUp, this)); + return this; +}; + +Guides.prototype._onCanvasClick = function (e) { + this.next(); +}; + +Guides.prototype._onDocKeyUp = function (e) { + switch (e.which) { + case 27: //esc + this.end(); + break; + case 39: //right arrow + case 32: //space + this.next(); + break; + case 37: //left arrow + case 8: //backspace + e.preventDefault(); + this.prev(); + break; + default: + break; + } +}; + +module.exports = Guides; \ No newline at end of file Index: reference/jquery-plugins/guided-tour-arrow/src/modules/format.js =================================================================== diff -u --- reference/jquery-plugins/guided-tour-arrow/src/modules/format.js (revision 0) +++ reference/jquery-plugins/guided-tour-arrow/src/modules/format.js (revision 10417a3908ef7516203be30712af4d355287973b) @@ -0,0 +1,8 @@ +module.exports = function format () { + var s = arguments[0]; + for (var i = 0; i < arguments.length - 1; i++) { + var reg = new RegExp("\\{" + i + "\\}", "gm"); + s = s.replace(reg, arguments[i + 1]); + } + return s; +}; \ No newline at end of file Index: reference/jquery-plugins/guided-tour-arrow/test/Guide.spec.js =================================================================== diff -u --- reference/jquery-plugins/guided-tour-arrow/test/Guide.spec.js (revision 0) +++ reference/jquery-plugins/guided-tour-arrow/test/Guide.spec.js (revision 10417a3908ef7516203be30712af4d355287973b) @@ -0,0 +1,164 @@ +var Guide = require('../src/modules/Guide'); + +describe('Guide class tests', function() { + var $element, + $container = $('
', { + position: 'absolute', + top: 0, + left: 0, + bottom: 0, + right: 0, + height: window.innerHeight, + width: window.innerWidth + }).appendTo('body'), + options = { + color: '#fff', + cssClass: '', + distance: 100 + }; + + beforeEach(function () { + $element = $('
Test
', {position: 'absolute'}).appendTo('body'); + }); + + afterEach(function () { + $element.remove(); + }); + + it('auto positions - right', function() { + $element.width(20); + $element.height(window.innerHeight); + $element.offset({top: 0, left: 0}); + guide = new Guide({ + element: $element, + html: 'Magna esse aliquet laborum et felis euismod' + }, $container, options); + expect(guide.position).toBe('right'); + }); + + it('auto positions - bottom', function() { + $element.width(window.innerWidth); + $element.height(20); + $element.offset({top: 0, left: 0}); + guide = new Guide({ + element: $element, + html: 'Magna esse aliquet laborum et felis euismod' + }, $container, options); + expect(guide.position).toBe('bottom'); + }); + + it('auto positions - left', function() { + $element.width(20); + $element.height(window.innerHeight); + $element.offset({ + top: 0, + left: $(document).width() - $element.width() + }); + guide = new Guide({ + element: $element, + html: 'Magna esse aliquet laborum et felis euismod' + }, $container, options); + expect(guide.position).toBe('left'); + }); + + it('auto positions - top', function() { + $element.width(window.innerWidth); + $element.height(20); + $element.offset({ + top: $(document).height() - $element.height(), + left: 0 + }); + guide = new Guide({ + element: $element, + html: 'Magna esse aliquet laborum et felis euismod' + }, $container, options); + expect(guide.position).toBe('top'); + }); + + it('creates an svg with a curve that fits the container (top)', function() { + $element.width(window.innerWidth); + $element.height(20); + $element.offset({ + top: $(document).height() - $element.height(), + left: 0 + }); + guide = new Guide({ + element: $element, + html: 'Magna esse aliquet laborum et felis euismod' + }, $container, options); + + var coord = guide._verticalAlign(); + expect(coord.x1 < 0).toBe(false); + expect(coord.x1 > this._width).toBe(false); + expect(coord.y1 < 0).toBe(false); + expect(coord.y1 > this._distance).toBe(false); + expect(coord.dx1 < 0).toBe(false); + expect(coord.dx1 > this._width).toBe(false); + expect(coord.dy1 < 0).toBe(false); + expect(coord.dy1 > this._distance).toBe(false); + }); + + it('creates an svg with a curve that fits the container (bottom)', function() { + $element.width(window.innerWidth); + $element.height(20); + $element.offset({top: 0, left: 0}); + guide = new Guide({ + element: $element, + html: 'Magna esse aliquet laborum et felis euismod' + }, $container, options); + + var coord = guide._verticalAlign(); + expect(coord.x1 < 0).toBe(false); + expect(coord.x1 > this._width).toBe(false); + expect(coord.y1 < 0).toBe(false); + expect(coord.y1 > this._distance).toBe(false); + expect(coord.dx1 < 0).toBe(false); + expect(coord.dx1 > this._width).toBe(false); + expect(coord.dy1 < 0).toBe(false); + expect(coord.dy1 > this._distance).toBe(false); + }); + + it('creates an svg with a curve that fits the container (left)', function() { + $element.width(20); + $element.height(window.innerHeight); + $element.offset({ + top: 0, + left: $(document).width() - $element.width() + }); + guide = new Guide({ + element: $element, + html: 'Magna esse aliquet laborum et felis euismod' + }, $container, options); + + var coord = guide._verticalAlign(); + expect(coord.x1 < 0).toBe(false); + expect(coord.x1 > this._width).toBe(false); + expect(coord.y1 < 0).toBe(false); + expect(coord.y1 > this._distance).toBe(false); + expect(coord.dx1 < 0).toBe(false); + expect(coord.dx1 > this._width).toBe(false); + expect(coord.dy1 < 0).toBe(false); + expect(coord.dy1 > this._distance).toBe(false); + }); + + it('creates an svg with a curve that fits the container (right)', function() { + $element.width(20); + $element.height(window.innerHeight); + $element.offset({top: 0, left: 0}); + guide = new Guide({ + element: $element, + html: 'Magna esse aliquet laborum et felis euismod' + }, $container, options); + + var coord = guide._verticalAlign(); + expect(coord.x1 < 0).toBe(false); + expect(coord.x1 > this._width).toBe(false); + expect(coord.y1 < 0).toBe(false); + expect(coord.y1 > this._distance).toBe(false); + expect(coord.dx1 < 0).toBe(false); + expect(coord.dx1 > this._width).toBe(false); + expect(coord.dy1 < 0).toBe(false); + expect(coord.dy1 > this._distance).toBe(false); + }); + +}); \ No newline at end of file Index: reference/jquery-plugins/guided-tour-arrow/test/Guides.spec.js =================================================================== diff -u --- reference/jquery-plugins/guided-tour-arrow/test/Guides.spec.js (revision 0) +++ reference/jquery-plugins/guided-tour-arrow/test/Guides.spec.js (revision 10417a3908ef7516203be30712af4d355287973b) @@ -0,0 +1,114 @@ +var Guides = require('../src/modules/Guides'); + +describe("Guides class tests", function() { + + var $element = $('
Test
', {position: 'fixed'}).appendTo('body'), + guides; + + $element.width(window.innerWidth); + $element.height(20); + $element.offset({top: 0, left: 0}); + + beforeEach(function (done) { + guides = new Guides($element, { + guides: [{ + element: $element, + html: 'Welcome to Guides.js' + }, { + element: $element, + html: 'Navigate through guides.js website' + }, { + element: $element, + html: 'See how it works' + }, { + element: $element, + html: 'Download guides.js' + }, { + element: $element, + html: 'Check out how to get started with guides.js' + }, { + element: $element, + html: 'Read the docs' + }] + }); + done(); + }); + + afterEach(function (done) { + guides.destroy(); + done(); + }); + + it('only one element is created if start is called twice', function() { + guides.start().start(); + expect($('.guides-canvas').length).toBe(1); + }); + + it('does not throw an error if a method other than start is called before start', function() { + expect(guides.next).not.toThrow(Error); + expect(guides.prev).not.toThrow(Error); + expect(guides.end).not.toThrow(Error); + expect(guides.destroy).not.toThrow(Error); + }); + + it('sets the correct step when the start method is called', function() { + guides.start(); + expect(guides._current).toBe(0); + }); + + it('sets the correct step when the next method is called', function() { + guides.start().next(); + expect(guides._current).toBe(1); + }); + + it('sets the correct step when the prev method is called', function() { + guides.start().next().prev(); + expect(guides._current).toBe(0); + }); + + it('removes dom elements when the end method is called', function() { + guides.start().end(); + expect(guides.$canvas).toBe(null); + expect($('.guides-canvas').length).toBe(0); + }); + + it('sets the new options correctly when setOptions method is called', function() { + guides.setOptions({ + start: function () {} + }); + expect(typeof guides.options.guides).toBe('object'); + expect(typeof guides.options.start).toContain('function'); + }); + + it('calls event handlers', function() { + var test = 0; + guides.setOptions({ + start: function () { + test = 1; + } + }); + guides.start(); + expect(test).toBe(1); + }); + + it('uses guide color setting', function() { + guides.options.color = 'red'; + guides.options.guides[0].color = 'blue'; + guides.start(); + expect(guides._currentGuide._color).toBe('blue'); + }); + + it('falls back to global color setting', function() { + guides.setOptions({ + color: 'red' + }); + guides.start(); + expect(guides._currentGuide._color).toBe('red'); + }); + + it('removes dom elements when destroy method is called', function() { + guides.start().destroy(); + expect(guides.$canvas).toBe(null); + expect($('.guides-canvas').length).toBe(0); + }); +}); \ No newline at end of file Index: reference/jquery-plugins/guided-tour-arrow/test/format.spec.js =================================================================== diff -u --- reference/jquery-plugins/guided-tour-arrow/test/format.spec.js (revision 0) +++ reference/jquery-plugins/guided-tour-arrow/test/format.spec.js (revision 10417a3908ef7516203be30712af4d355287973b) @@ -0,0 +1,29 @@ +var format = require('../src/modules/format'); + +describe("format string function tests", function() { + + it("keeps the string the same if there are no placeholders", function() { + expect(format('ala bala', 'portokala')).toBe('ala bala'); + }); + + it("keeps the string the same if there are no placeholders and no arguments", function() { + expect(format('ala bala')).toBe('ala bala'); + }); + + it("keeps the string the same if there are no arguments", function() { + expect(format('ala {0} bala')).toBe('ala {0} bala'); + }); + + it("formats correcly {0} {1}", function() { + expect(format('{0} {1}', 'ala', 'bala')).toBe('ala bala'); + }); + + it("formats correcly {1} {0}", function() { + expect(format('{1} {0}', 'ala', 'bala')).toBe('bala ala'); + }); + + it("formats correcly {1} {1} {0}", function() { + expect(format('{1} {1} {0}', 'ala', 'bala')).toBe('bala bala ala'); + }); + +}); \ No newline at end of file