2014-12-07 14:12:50 +01:00
|
|
|
define([
|
|
|
|
'react/addons',
|
|
|
|
'lodash',
|
2014-12-28 10:47:34 +01:00
|
|
|
'./CodeMirrorEditor'
|
2014-12-07 14:12:50 +01:00
|
|
|
], function (React, _, CodeEditor) {
|
|
|
|
'use strict';
|
2014-12-28 16:36:39 +01:00
|
|
|
function onClick1(tab, tabIndex, evt) {
|
|
|
|
evt.preventDefault();
|
|
|
|
this.setState({ 'currentTab': tab[0] });
|
|
|
|
}
|
|
|
|
function repeatTab2(tab, tabIndex) {
|
|
|
|
return React.createElement('li', {
|
|
|
|
'role': 'presentation',
|
|
|
|
'className': React.addons.classSet({ active: this.state.currentTab === tab[0] }),
|
|
|
|
'onClick': onClick1.bind(this, tab, tabIndex)
|
|
|
|
}, React.createElement('a', { 'aria-controls': tab[1] }, tab[1]));
|
|
|
|
}
|
|
|
|
function onChange3(evt) {
|
2014-12-07 14:12:50 +01:00
|
|
|
this.setState({ 'templateHTML': evt.target.value });
|
|
|
|
}
|
2014-12-28 16:36:39 +01:00
|
|
|
function onChange4(evt) {
|
2014-12-07 14:12:50 +01:00
|
|
|
this.setState({ 'templateProps': evt.target.value });
|
|
|
|
}
|
2014-12-28 16:36:39 +01:00
|
|
|
function onSubmit5(e) {
|
2014-12-07 14:12:50 +01:00
|
|
|
e.preventDefault();
|
|
|
|
}
|
|
|
|
return function () {
|
|
|
|
return React.createElement('div', { 'className': 'playground' }, React.createElement('div', {
|
|
|
|
'id': this.props.id + '-myTab',
|
|
|
|
'className': 'code-area ' + (this.props.direction === 'horizontal' && 'horizontal' || 'vertical')
|
2014-12-28 16:36:39 +01:00
|
|
|
} /* Nav tabs */, React.createElement.apply(this, _.flatten([
|
|
|
|
'ul',
|
|
|
|
{
|
|
|
|
'className': 'nav nav-tabs',
|
|
|
|
'role': 'tablist'
|
|
|
|
},
|
|
|
|
_.map(this.getTabs(), repeatTab2.bind(this))
|
|
|
|
])) /* Tab panes */, React.createElement('div', {}, this.state.currentTab === 'templateHTML' ? React.createElement('div', { 'className': 'tab-pane active' }, React.createElement(CodeEditor, {
|
2014-12-28 10:47:34 +01:00
|
|
|
'ref': 'editorRT',
|
2014-12-07 14:12:50 +01:00
|
|
|
'className': 'large-text-area',
|
2014-12-28 10:47:34 +01:00
|
|
|
'style': { border: this.validHTML ? '' : '2px solid red' },
|
2014-12-07 14:12:50 +01:00
|
|
|
'value': this.state.templateHTML,
|
|
|
|
'mode': 'html',
|
2014-12-28 16:36:39 +01:00
|
|
|
'onChange': onChange3.bind(this)
|
|
|
|
})) : null, this.state.currentTab === 'templateProps' ? React.createElement('div', { 'className': 'tab-pane active' }, React.createElement(CodeEditor, {
|
2014-12-28 10:47:34 +01:00
|
|
|
'ref': 'editorCode',
|
2014-12-07 14:12:50 +01:00
|
|
|
'className': 'large-text-area',
|
2014-12-28 10:47:34 +01:00
|
|
|
'style': { border: this.validProps ? '' : '2px solid red' },
|
2014-12-07 14:12:50 +01:00
|
|
|
'value': this.state.templateProps,
|
|
|
|
'mode': 'javascript',
|
2014-12-28 16:36:39 +01:00
|
|
|
'onChange': onChange4.bind(this)
|
|
|
|
})) : null, this.state.currentTab === 'templateSource' ? React.createElement('div', { 'className': 'tab-pane active' }, React.createElement(CodeEditor, {
|
2014-12-07 14:12:50 +01:00
|
|
|
'className': 'large-text-area',
|
|
|
|
'value': this.templateSource,
|
|
|
|
'mode': 'javascript',
|
|
|
|
'readOnly': true
|
2014-12-28 16:36:39 +01:00
|
|
|
})) : null)), React.createElement('div', {
|
2014-12-07 14:12:50 +01:00
|
|
|
'key': 'result-area',
|
2014-12-28 10:47:34 +01:00
|
|
|
'className': 'result-area ' + (this.props.direction === 'horizontal' && 'horizontal' || 'vertical')
|
|
|
|
}, React.createElement('span', { 'className': 'preview-title' }, '\xA0'), React.createElement('form', {
|
2014-12-07 14:12:50 +01:00
|
|
|
'className': 'sample-view',
|
2014-12-28 16:36:39 +01:00
|
|
|
'onSubmit': onSubmit5.bind(this)
|
2014-12-07 14:12:50 +01:00
|
|
|
}, React.createElement(this.sample, { 'key': 'sample' }))), React.createElement('br', { 'style': { clear: 'both' } }));
|
|
|
|
};
|
|
|
|
});
|