Skip to content

Commit

Permalink
Initial commit of adapt-contrib-accordion
Browse files Browse the repository at this point in the history
- Render a list of clickable titles, which reveal display text
  • Loading branch information
Kevin Corry committed Nov 29, 2013
1 parent 771eb0d commit a0df989
Show file tree
Hide file tree
Showing 21 changed files with 8,096 additions and 1 deletion.
4 changes: 4 additions & 0 deletions .bowerrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"directory": "src/plugins",
"registry": "http://adapt-bower-repository.herokuapp.com/"
}
3 changes: 3 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
language: node_js
node_js:
- 0.10
674 changes: 674 additions & 0 deletions LICENSE

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
adapt-contrib-accordion
=======================
===============

An accordion component that displays clickable titles, which reveal display text
15 changes: 15 additions & 0 deletions bower.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"name": "adapt-contrib-accordion",
"version": "0.0.1",
"homepage": "https://github.com/adaptlearning/adapt-contrib-accordion",
"authors": [
"Kevin Corry <[email protected]>"
],
"description": "An accordion component that displays clickable titles, which reveal display text",
"main": "/js/adapt-contrib-accordion.js",
"keywords": [
"adapt-plugin",
"adapt-component"
],
"license": "GPLv3"
}
38 changes: 38 additions & 0 deletions js/adapt-contrib-accordion.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
define(function(require) {
var ComponentView = require('coreViews/componentView');
var Adapt = require('coreJS/adapt');

var Accordion = ComponentView.extend({

postRender: function() {
this.setReadyStatus();
this.setCompletionStatus();
},

events: {
'click .item .title' : 'toggleItem'
},

toggleItem: function (event) {
event.preventDefault();
this.$('.item .body').stop(true,true).slideUp();
if (!$(event.currentTarget).hasClass('selected')) {
this.$('.item .title').removeClass('selected');
$(event.currentTarget).addClass('selected visited').siblings('.body').slideToggle();
this.$('.icon').removeClass('minus').addClass('plus');
$('.icon', event.currentTarget).removeClass('plus').addClass('minus');
} else {
this.$('.item .title').removeClass('selected');
$(event.currentTarget).removeClass('selected');
$('.icon', event.currentTarget).removeClass('minus').addClass('plus');
}
if (this.$('.item .visited').length==this.$('.item').length && this.model.get('complete')==false) {
this.model.set('complete',true);
}
}

});

Adapt.register("accordion", Accordion);

});
29 changes: 29 additions & 0 deletions karma.conf.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
module.exports = function(config) {
config.set({
// The root path location that will be used to resolve all relative paths
// defined in files and exclude
basePath: '',
// List of files or patterns to load in the browser
files: [
{ pattern: 'src/**/*.js', included: false },
{ pattern: 'test/spec/**/*.js', included: false },
'test/test-main.js'
],
// List of frameworks you want to use: jasmine, mocha, qunit
frameworks: ['expect', 'mocha', 'requirejs'],
// Enable or disable watching files and executing the tests
// whenever one of these files changes.
autoWatch: false,
// Chrome (comes installed with Karma)
// ChromeCanary (comes installed with Karma)
// PhantomJS (comes installed with Karma)
// Firefox (requires karma-firefox-launcher plugin)
// Opera (requires karma-opera-launcher plugin)
// Internet Explorer (requires karma-ie-launcher plugin)
// Safari (requires karma-safari-launcher plugin)
browsers: ['Chrome', 'PhantomJS', 'Firefox'],
// If singleRun is set to true, Karma will start and capture all
// configured browsers, run tests and then exit with an exit code of 0 or 1.
singleRun: false
});
};
Empty file added less/accordion.less
Empty file.
23 changes: 23 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"name": "adapt-contrib-accordion",
"version": "0.0.1",
"description": "An accordion component that displays clickable titles, which reveal display text",
"main": "",
"scripts": {
"test": "./node_modules/.bin/karma start --single-run --browsers PhantomJS"
},
"repository": {
"type": "git",
"url": "git://github.com/adaptlearning/adapt-contrib-accordion.git"
},
"author": "AdaptLearning",
"license": "GPL v3",
"bugs": {
"url": "https://github.com/adaptlearning/adapt-contrib-accordion/issues"
},
"devDependencies": {
"karma": "~0.9",
"karma-mocha": "*",
"karma-expect": "*"
}
}
33 changes: 33 additions & 0 deletions templates/accordion.hbs
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<div class="inner">
{{#if title}}
<div class="title">
<h4 class="inner">
{{{title}}}
</h4>
</div>
{{/if}}
{{#if body}}
<div class="body">
<p class="inner">
{{{body}}}
</p>
</div>
{{/if}}
<div class="widget">
{{#each items}}
<div class="item">
<a href="#" class="title" title="{{alt}}">
<div class="icon plus"></div>
<h5 class="inner">
{{{title}}}
</h5>
</a>
<div class="body clearfix">
<p class="inner">
{{{body}}}
</p>
</div>
</div>
{{/each}}
</div>
</div>
69 changes: 69 additions & 0 deletions tests/SpecRunner.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
<!DOCTYPE html>
<html>
<head>
<title>Adapt Spec Runner</title>
<link rel="stylesheet" href="libraries/mocha.css">
<script src="libraries/expect.js"></script>
<script src="libraries/mocha.js"></script>
<script>
var require = {
baseUrl: '../src',
paths: {
jquery: 'core/js/libraries/jquery',
underscore: 'core/js/libraries/underscore',
backbone: 'core/js/libraries/backbone',
modernizr: 'core/js/libraries/modernizr',
handlebars: 'core/js/libraries/handlebars',
imageReady: 'core/js/libraries/imageReady',
inview: 'core/js/libraries/inview',
scrollTo: 'core/js/libraries/scrollTo',
coreJS: 'core/js',
coreViews: 'core/js/views',
coreModels: 'core/js/models',
coreCollections: 'core/js/collections',
templates: 'templates/templates',
components: 'components',
spec: '../test/spec',
expect: '../test/libraries/expect',
mocha: '../test/libraries/mocha'
},
shim: {
jquery: [],
backbone: {
deps: [
'underscore',
'jquery'
],
exports: 'Backbone'
},
underscore: {
exports: '_'
},
handlebars: {
exports: 'Handlebars'
}
}
}
</script>
<script src="../src/core/js/libraries/require.js"></script>
<script type="text/javascript">
require(['require', 'expect', 'mocha'], function(require, expect, chai) {

mocha.setup('bdd');
mocha.checkLeaks();
mocha.globals(['jQuery']);
// Require test specs here
// Change componentName to your test file
require([
'spec/componentName'
], function(capitalize){
mocha.run();
});

});
</script>
</head>
<body>
<div id="mocha"></div>
</body>
</html>
26 changes: 26 additions & 0 deletions tests/data/articles.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
[
{
"_id":"a-05",
"_parentId":"co-05",
"_type":"article",
"title":"Article first title"
},
{
"_id":"a-10",
"_parentId":"co-05",
"_type":"article",
"title":"Article second title"
},
{
"_id":"a-15",
"_parentId":"co-15",
"_type":"article",
"title":"Article third title"
},
{
"_id":"a-20",
"_parentId":"co-20",
"_type":"article",
"title":"Article fourth title"
}
]
32 changes: 32 additions & 0 deletions tests/data/blocks.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
[
{
"_id":"b-05",
"_parentId":"a-05",
"_type":"block",
"title":"Title of first block"
},
{
"_id":"b-10",
"_parentId":"a-05",
"_type":"block",
"title":"Title of second block"
},
{
"_id":"b-15",
"_parentId":"a-10",
"_type":"block",
"title":"Title of third block"
},
{
"_id":"b-20",
"_parentId":"a-15",
"_type":"block",
"title":"Title of fourth block"
},
{
"_id":"b-25",
"_parentId":"a-20",
"_type":"block",
"title":"Title of fifth block"
}
]
47 changes: 47 additions & 0 deletions tests/data/components.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
[
{
"_id":"c-05",
"_parentId":"b-05",
"_type":"component",
"_component":"text",
"_classes":"",
"title":"Title of our very first component",
"body":"Whoo - if we get this rendering we've made the big time"
},
{
"_id":"c-10",
"_parentId":"b-05",
"_type":"component",
"_component":"text",
"_classes":"",
"title":"Title of our very second component",
"body":"Whoo - if we get this rendering we've made the big time"
},
{
"_id":"c-15",
"_parentId":"b-10",
"_type":"component",
"_component":"text",
"_classes":"",
"title":"Title of our very third component",
"body":"Whoo - if we get this rendering we've made the big time"
},
{
"_id":"c-20",
"_parentId":"b-10",
"_type":"component",
"_component":"text",
"_classes":"",
"title":"Title of our very fourth component",
"body":"Whoo - if we get this rendering we've made the big time"
},
{
"_id":"c-25",
"_parentId":"b-15",
"_type":"component",
"_component":"text",
"_classes":"",
"title":"Title of our very fifth component",
"body":"Whoo - if we get this rendering we've made the big time"
}
]
26 changes: 26 additions & 0 deletions tests/data/contentObjects.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
[
{
"_id":"co-05",
"_parentId":"course",
"_type":"page",
"title":"Title of first page model"
},
{
"_id":"co-10",
"_parentId":"course",
"_type":"menu",
"title":"Title of second page model"
},
{
"_id":"co-15",
"_parentId":"co-10",
"_type":"page",
"title":"Title of third page model"
},
{
"_id":"co-20",
"_parentId":"course",
"_type":"page",
"title":"Title of fourth page model"
}
]
6 changes: 6 additions & 0 deletions tests/data/course.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"_id":"course",
"_type":"course",
"title":"Adapt",
"body":"This is the first version of the open source re-architecture"
}
Loading

0 comments on commit a0df989

Please sign in to comment.