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-30 09:42:31 +01:00
|
|
|
this.setState({ templateHTML: evt.target.value });
|
2014-12-07 14:12:50 +01:00
|
|
|
}
|
2014-12-28 16:36:39 +01:00
|
|
|
function onChange4(evt) {
|
2014-12-30 09:42:31 +01:00
|
|
|
this.setState({ templateProps: evt.target.value });
|
2014-12-07 14:12:50 +01:00
|
|
|
}
|
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',
|
2014-12-30 09:42:31 +01:00
|
|
|
'className': 'code-area ' + this.getLayoutClass()
|
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-30 09:42:31 +01:00
|
|
|
'className': 'result-area ' + this.getLayoutClass()
|
2014-12-28 10:47:34 +01:00
|
|
|
}, React.createElement('span', { 'className': 'preview-title' }, '\xA0'), React.createElement('form', {
|
2014-12-30 09:42:31 +01:00
|
|
|
'ref': 'mount',
|
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-30 09:42:31 +01:00
|
|
|
} /* <this.sample key="sample"> */
|
|
|
|
/* </this.sample> */)), React.createElement('br', { 'style': { clear: 'both' } }));
|
2014-12-07 14:12:50 +01:00
|
|
|
};
|
|
|
|
});
|