Skip to content

Commit 590e33a

Browse files
committed
Initial commit
0 parents  commit 590e33a

23 files changed

+8240
-0
lines changed

.bowerrc

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"directory": "src/plugins",
3+
"registry": "http://adapt-bower-repository.herokuapp.com/"
4+
}

.travis.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
language: node_js
2+
node_js:
3+
- 0.10

LICENSE

Lines changed: 674 additions & 0 deletions
Large diffs are not rendered by default.

README.md

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
#adapt-notepad
2+
3+
A very simple adapt core contributed text component.
4+
5+
6+
##Installation
7+
8+
First, be sure to install the [Adapt Command Line Interface](https://github.com/adaptlearning/adapt-cli), then from the command line run:-
9+
10+
adapt install adapt-contrib-text
11+
12+
This component can also be installed by adding the component to the adapt.json file before running `adapt install`:
13+
14+
"adapt-contrib-text": "*"
15+
16+
##Usage
17+
18+
This is a very simple component with just title and body text elements.
19+
20+
##Settings overview
21+
22+
####_component
23+
24+
This value must be: `text`
25+
26+
####_classes
27+
28+
You can use this setting to add custom classes to your template and LESS file.
29+
30+
####_layout
31+
32+
This defines the position of the component in the block. Values can be `full`, `left` or `right`.
33+
34+
####displayTitle and body
35+
36+
The `displayTitle` and `body` settings can be left blank. Although the blank component could be used instead: [adapt-contrib-blank](https://github.com/adaptlearning/adapt-contrib-blank)
37+
38+
##Limitations
39+
40+
To be completed.
41+
42+
##Browser spec
43+
44+
This component has been tested to the standard Adapt browser specification.
45+

bower.json

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
{
2+
"name": "adapt-noteplad",
3+
"version": "0.0.1",
4+
"homepage": "https://github.com/darylhedley/adapt-notepad",
5+
"authors": [
6+
"Daryl Hedley <[email protected]>"
7+
],
8+
"displayName" : "Notepad",
9+
"component" : "notepad",
10+
"description": "A simple core contributed text component",
11+
"main": "/js/adapt-notepad.js",
12+
"keywords": [
13+
"adapt-plugin",
14+
"adapt-component"
15+
],
16+
"license": "GPLv3"
17+
}

example.json

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
{
2+
"_id":"c-05",
3+
"_parentId":"b-05",
4+
"_type":"component",
5+
"_component":"notepad",
6+
"_classes":"",
7+
"_layout":"left",
8+
"title":"Our first look at a component",
9+
"displayTitle":"Our first look at a component",
10+
"body":"This component you're reading is a text component. All components take this form of a title and body - except a blank component. However it's important to realise that title and body attributes are not needed. <br><br>Take for instance the media component opposite or below on a smaller device - has no body attribute. Instead of the HTML being rendered Adapt simply doesn't render it. The title attribute is simply a break tag to push the media component level with the opposite component.",
11+
"instruction":"",
12+
"placeholder": "",
13+
"_maxlength": 700,
14+
"_rows":,
15+
"_cols":
16+
}

js/adapt-notepad.js

Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
/*
2+
* adapt-notepad
3+
* License - http://github.com/adaptlearning/adapt_framework/blob/master/LICENSE
4+
* Maintainers - Chuck Lorenz <[email protected]>
5+
*/
6+
define(function(require) {
7+
8+
var ComponentView = require('coreViews/componentView');
9+
var Adapt = require('coreJS/adapt');
10+
11+
var Notepad = ComponentView.extend({
12+
events: {
13+
'click button': 'onButtonClicked',
14+
'blur textarea': 'storeUserAnswer'
15+
},
16+
17+
//preRender: function() {
18+
// Checks to see if the notepad should be reset on revisit
19+
//this.checkIfResetOnRevisit();
20+
//},
21+
22+
postRender: function() {
23+
this.setReadyStatus();
24+
25+
if (this.model.get('userInput')) {
26+
this.resetUserAnswer();
27+
}
28+
29+
// Check if instruction or body is set, otherwise force completion
30+
var cssSelector = this.$('.component-instruction').length > 0
31+
? '.component-instruction'
32+
: (this.$('.component-body').length > 0 ? '.component-body' : null);
33+
34+
if (!cssSelector) {
35+
this.setCompletionStatus();
36+
} else {
37+
this.model.set('cssSelector', cssSelector);
38+
this.$(cssSelector).on('inview', _.bind(this.inview, this));
39+
}
40+
},
41+
42+
//This preserve the state of the users answers for returning or showing the users answer
43+
storeUserAnswer: function() {
44+
this.model.set('userInput', this.$('textarea').val());
45+
},
46+
47+
// Used by the question view to reset the stored user answer
48+
resetUserAnswer: function() {
49+
this.$('textarea').val(this.model.Get('userInput'));
50+
this.forceFixedPositionFakeScroll();
51+
},
52+
53+
forceFixedPositionFakeScroll: function() {
54+
if (Modernizr.touch) {
55+
_.defer(function() {
56+
window.scrollTo(document.body.scrollLeft, document.body.scrollTop);
57+
});
58+
}
59+
},
60+
61+
onButtonClicked: function() {
62+
this.$('.textinput-item-textbox').val('');
63+
this.storeUserAnswer();
64+
},
65+
66+
// Used to check if the notepad should reset on revisit
67+
//checkIfResetOnRevisit: function() {
68+
// var isResetOnRevisit = this.model.get('_isResetOnRevisit');
69+
70+
// If reset is enabled set defaults
71+
// if (isResetOnRevisit) {
72+
// this.model.reset(isResetOnRevisit);
73+
// }
74+
//},
75+
76+
inview: function(event, visible, visiblePartX, visiblePartY) {
77+
if (visible) {
78+
if (visiblePartY === 'top') {
79+
this._isVisibleTop = true;
80+
} else if (visiblePartY === 'bottom') {
81+
this._isVisibleBottom = true;
82+
} else {
83+
this._isVisibleTop = true;
84+
this._isVisibleBottom = true;
85+
}
86+
87+
if (this._isVisibleTop && this._isVisibleBottom) {
88+
this.$(this.model.get('cssSelector')).off('inview');
89+
this.setCompletionStatus();
90+
}
91+
}
92+
}
93+
94+
});
95+
96+
Adapt.register('notepad', Notepad);
97+
98+
return Notepad;
99+
100+
});

karma.conf.js

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
module.exports = function(config) {
2+
config.set({
3+
// The root path location that will be used to resolve all relative paths
4+
// defined in files and exclude
5+
basePath: '',
6+
// List of files or patterns to load in the browser
7+
files: [
8+
{ pattern: 'js/**/*.js', included: false },
9+
{ pattern: 'tests/spec/**/*.js', included: false },
10+
'tests/test-main.js'
11+
],
12+
// List of frameworks you want to use: jasmine, mocha, qunit
13+
frameworks: ['expect', 'mocha', 'requirejs'],
14+
// Enable or disable watching files and executing the tests
15+
// whenever one of these files changes.
16+
autoWatch: false,
17+
// Chrome (comes installed with Karma)
18+
// ChromeCanary (comes installed with Karma)
19+
// PhantomJS (comes installed with Karma)
20+
// Firefox (requires karma-firefox-launcher plugin)
21+
// Opera (requires karma-opera-launcher plugin)
22+
// Internet Explorer (requires karma-ie-launcher plugin)
23+
// Safari (requires karma-safari-launcher plugin)
24+
browsers: ['Chrome', 'PhantomJS', 'Firefox'],
25+
// If singleRun is set to true, Karma will start and capture all
26+
// configured browsers, run tests and then exit with an exit code of 0 or 1.
27+
singleRun: false
28+
});
29+
};

less/notepad.less

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
.notepad-component {
2+
textarea {
3+
overflow: auto;
4+
width: 100%;
5+
display:block;
6+
min-height: 100px;
7+
background-color: #fff;
8+
padding: @item-padding;
9+
position: relative;
10+
border: @item-border;
11+
margin-bottom: 2px;
12+
-moz-box-sizing: border-box;
13+
-webkit-box-sizing: border-box;
14+
box-sizing: border-box;
15+
}
16+
17+
.textinput-item-textbox {
18+
float: left;
19+
.dir-rtl & {
20+
float: right;
21+
}
22+
}
23+
24+
button {
25+
width:49.5%;
26+
float:left;
27+
}
28+
}

package.json

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
{
2+
"name": "adapt-notepad",
3+
"version": "0.0.1",
4+
"description": "A text component",
5+
"main": "",
6+
"scripts": {
7+
"test": "./node_modules/.bin/karma start --single-run --browsers PhantomJS"
8+
},
9+
"repository": {
10+
"type": "git",
11+
"url": "git://github.com/adaptlearning/adapt-contrib-text.git"
12+
},
13+
"author": "AdaptLearning",
14+
"license": "GPL v3",
15+
"bugs": {
16+
"url": "https://github.com/adaptlearning/adapt-contrib-text/issues"
17+
},
18+
"devDependencies": {
19+
"karma": "0.10",
20+
"karma-mocha": "0.1.0",
21+
"karma-expect": "1.1.0"
22+
}
23+
}

0 commit comments

Comments
 (0)