From e20747ef9bd206df6d03cc4c2ccb074eadf4a8df Mon Sep 17 00:00:00 2001 From: petehunt Date: Wed, 29 May 2013 13:24:51 -0700 Subject: [PATCH] Fix live editor on mobile devices --- docs/_config.yml | 4 ++-- docs/_js/live_editor.js | 24 +++++++++++++++++++++++- 2 files changed, 25 insertions(+), 3 deletions(-) diff --git a/docs/_config.yml b/docs/_config.yml index 2299c474de..12f9928142 100644 --- a/docs/_config.yml +++ b/docs/_config.yml @@ -1,6 +1,7 @@ --- -markdown: redcarpet name: React +markdown: redcarpet +baseurl: /react react_version: 0.3.0 redcarpet: extensions: @@ -11,4 +12,3 @@ exclude: - Gemfile.lock - README.md - Rakefile -baseurl: /react diff --git a/docs/_js/live_editor.js b/docs/_js/live_editor.js index 0b7bc86803..de3c7951b4 100644 --- a/docs/_js/live_editor.js +++ b/docs/_js/live_editor.js @@ -2,8 +2,22 @@ * @jsx React.DOM */ + +var IS_MOBILE = ( + navigator.userAgent.match(/Android/i) + || navigator.userAgent.match(/webOS/i) + || navigator.userAgent.match(/iPhone/i) + || navigator.userAgent.match(/iPad/i) + || navigator.userAgent.match(/iPod/i) + || navigator.userAgent.match(/BlackBerry/i) + || navigator.userAgent.match(/Windows Phone/i) +); + var CodeMirrorEditor = React.createClass({ componentDidMount: function(root) { + if (IS_MOBILE) { + return; + } this.editor = CodeMirror.fromTextArea(this.refs.editor.getDOMNode(), { mode: 'javascript', lineNumbers: false, @@ -21,9 +35,17 @@ var CodeMirrorEditor = React.createClass({ }, render: function() { // wrap in a div to fully contain CodeMirror + var editor; + + if (IS_MOBILE) { + editor =
{this.props.codeText}
; + } else { + editor = ; + } + return (
- + {editor}
); }