Skip to content

Commit

Permalink
Added jQuery and what-input to dependencies.
Browse files Browse the repository at this point in the history
Updated demo pages.
Added whatinput rule in SASS.
  • Loading branch information
Owlbertz committed Mar 29, 2016
1 parent b044b9f commit 19bb4f9
Show file tree
Hide file tree
Showing 6 changed files with 138 additions and 7 deletions.
3 changes: 2 additions & 1 deletion demo/index.html
Expand Up @@ -118,7 +118,8 @@ <h3>Fifth</h3>
</ol>


<script src="../node_modules/foundation-sites/node_modules/jquery/dist/jquery.js" type="text/javascript"></script>
<script src="../node_modules/jquery/dist/jquery.js" type="text/javascript"></script>
<script src="../node_modules/what-input/what-input.js" type="text/javascript"></script>
<script src="../node_modules/foundation-sites/dist/foundation.js" type="text/javascript"></script>
<script src="../dist/foundation.joyride.js" type="text/javascript"></script>
<script type="text/javascript">
Expand Down
4 changes: 2 additions & 2 deletions demo/standalone.html
Expand Up @@ -118,8 +118,8 @@ <h3>Fifth</h3>
</ol>


<script src="../node_modules/foundation-sites/node_modules/jquery/dist/jquery.js" type="text/javascript"></script>
<!--<script src="../node_modules/foundation-sites/dist/foundation.js" type="text/javascript"></script>-->
<script src="../node_modules/jquery/dist/jquery.js" type="text/javascript"></script>
<script src="../node_modules/what-input/what-input.js" type="text/javascript"></script> <!--<script src="../node_modules/foundation-sites/dist/foundation.js" type="text/javascript"></script>-->
<script src="../dist/solo.joyride.js" type="text/javascript"></script>
<script type="text/javascript">
// initialize Foundation
Expand Down
8 changes: 6 additions & 2 deletions demo/umd.html
Expand Up @@ -124,7 +124,11 @@ <h3>Fifth</h3>
requirejs.config({
packages: [{
name: 'jquery',
location: '../node_modules/foundation-sites/node_modules/jquery/dist',
location: '../node_modules/jquery/dist',
main: 'jquery'
},{
name: 'what-input',
location: '../node_modules/jquery/dist',
main: 'jquery'
},{
name: 'joyride',
Expand All @@ -136,7 +140,7 @@ <h3>Fifth</h3>
main: 'foundation'
}]
});
requirejs(['jquery', 'foundation', 'joyride'], function(Joyride, Foundation, jQuery) {
requirejs(['jquery', 'what-input', 'foundation', 'joyride'], function(Joyride, Foundation, jQuery) {
// initialize Foundation
$(document).foundation();
});
Expand Down
4 changes: 4 additions & 0 deletions package.json
Expand Up @@ -24,6 +24,10 @@
"test:sass": "mocha test/sass/test_sass.js",
"test:javascript": "gulp build:all && mocha-phantomjs test/javascript/index.html"
},
"dependencies": {
"jquery": "^2.2.0",
"what-input": "^2.0.0"
},
"devDependencies": {
"babel-core": "^6.3.26",
"babel-eslint": "^5.0.0",
Expand Down
4 changes: 2 additions & 2 deletions scss/joyride.scss
Expand Up @@ -47,6 +47,6 @@ $joyride-button-space: 0.5em;
}
}

[data-joyride] {
display: none;
[data-whatinput='mouse'] .joyride {
outline: 0;
}
122 changes: 122 additions & 0 deletions test/javascript/joyride.js
@@ -0,0 +1,122 @@
describe('Joyride', function() {
var plugin;
var $html;
var joyrideListHtml = '<div><h2 id="target-1">Target 1</h2><h2 id="target-2">Target 2</h2>'
+'<ol data-joyride data-autostart="true">'
+ '<li data-target="#target-1">'
+ '<h3>First</h3>'
+ '</li>'
+ '<li data-target="#target-2">'
+ '<h3>Second</h3>'
+ '</li>'
+ '</ol></div>';

afterEach(function() {
plugin.destroy();
$html.remove();
});

describe('constructor()', function() {
it('stores the element and plugin options', function() {
$html = $(joyrideListHtml).appendTo('body');
plugin = new Foundation.Joyride($html.find('[data-joyride]'), {});

plugin.$element.should.be.an('object');
plugin.options.should.be.an('object');
});
});

describe('_init()', function() {
it('hides the joyride list', function() {
$html = $(joyrideListHtml).appendTo('body');
plugin = new Foundation.Joyride($html.find('[data-joyride]'), {});

plugin.$element.should.have.attr('data-joyride');
plugin.$element.should.be.hidden;
});
});

describe('_render()', function() {
it('creates tooltips for stops with target', function() {
$html = $(joyrideListHtml).appendTo('body');
plugin = new Foundation.Joyride($html.find('[data-joyride]'), {});

plugin.structure[0].item.$element.should.have.attr('data-tooltip');
});

it('creates reveal modals for stops without target', function() {
$html = $(joyrideListHtml);
$html.find('li').removeAttr('data-target');
$html.appendTo('body');
plugin = new Foundation.Joyride($html.find('[data-joyride]'), {});

plugin.structure[0].item.$element.should.have.attr('data-reveal');
});
});

describe('start()', function() {
it('starts joyride automatically', function() {
$html = $(joyrideListHtml).appendTo('body');
plugin = new Foundation.Joyride($html.find('[data-joyride]'), {});
plugin.start();

$(plugin.$items[0]).should.be.visible;
});

it('starts joyride by clicking', function() {
$html = $(joyrideListHtml);
$html.find('[data-joyride]').attr({'data-autostart': false, 'id': 'test-joyride'});

var $button = $('<button class="button" data-joyride-start="#test-joyride">Start</button>');
$html.append($button);
$html.appendTo('body');
plugin = new Foundation.Joyride($html.find('[data-joyride]'), {});

$button.trigger('click');

$(plugin.$items[0]).should.have.attr('aria-hidden', 'false');
});
});

describe('showNext()', function() {
it('hides the current element', function() {
$html = $(joyrideListHtml).appendTo('body');
plugin = new Foundation.Joyride($html.find('[data-joyride]'), {});
plugin.start();

plugin.showNext();
$(plugin.$items[0]).should.have.attr('aria-hidden', 'true');
});

it('shows the next element', function() {
$html = $(joyrideListHtml).appendTo('body');
plugin = new Foundation.Joyride($html.find('[data-joyride]'), {});
plugin.start();

plugin.showNext();
$(plugin.$items[1]).should.have.attr('aria-hidden', 'false');
});
});

describe('showPrev()', function() {
it('hides the current element', function() {
$html = $(joyrideListHtml).appendTo('body');
plugin = new Foundation.Joyride($html.find('[data-joyride]'), {});
plugin.start();

plugin.showNext();
plugin.showPrev();
$(plugin.$items[1]).should.have.attr('aria-hidden', 'true');
});

it('shows the previous element', function() {
$html = $(joyrideListHtml).appendTo('body');
plugin = new Foundation.Joyride($html.find('[data-joyride]'), {});
plugin.start();

plugin.showNext();
plugin.showPrev();
$(plugin.$items[0]).should.have.attr('aria-hidden', 'false');
});
});
});

0 comments on commit 19bb4f9

Please sign in to comment.