Skip to content
This repository has been archived by the owner on Dec 21, 2021. It is now read-only.

Commit

Permalink
Merge remote-tracking branch 'aui-local/master' into ee-1.5.x
Browse files Browse the repository at this point in the history
  • Loading branch information
natecavanaugh committed Jul 27, 2012
2 parents 67fbb55 + d67fc56 commit 1045d3d
Showing 1 changed file with 46 additions and 3 deletions.
49 changes: 46 additions & 3 deletions demos/ace-editor/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,24 @@
height: 400px;
position: relative;
}
.controls {
margin-bottom: 1em;
}
</style>
<body>

<div id="wrapper">
<h1>Alloy Ace Editor Wrapper</h1>

<div class="controls">
<label for="mode">Language Mode:</label>
<select id="mode">
<option>javascript</option>
<option>json</option>
<option>xml</option>
<option>php</option>
</select>
<label><input checked="checked" id="updateEditor" type="checkbox" />Update editor value for the selected language</label>
</div>
<div id="editor"></div>
</div>
<script type="text/javascript" charset="utf-8">
Expand All @@ -40,16 +52,47 @@ <h1>Alloy Ace Editor Wrapper</h1>
// useSoftTabs: true,
// useWrapMode: true,
// showPrintMargin: false,
value: 'Write something \nhere ...'
mode: 'javascript',
value: 'alert("Write something here...");'
}
).render();

// editor.getEditor().setTheme('ace/theme/cobalt');

editor.set('mode', 'javascript');
//editor.set('mode', 'javascript');
// editor.set('mode', 'json');
// editor.set('mode', 'xml');

var mode = A.one('#mode');
if (mode) {
var updateEditor = A.one('#updateEditor');

var contents = {
javascript: 'alert("Write something here...");',
php: '<?php echo "Write something here..."); ?>',
xml: '<value attr="something">Write something here...</value>',
json: '{"value": "Write something here..."}'
};

var currentMode = 'javascript';

var updateValue = function() {
if (updateEditor.attr('checked')) {
editor.set('value', contents[currentMode]);
}
};

updateEditor.on('change', updateValue);

mode.on('change', function(event) {
currentMode = this.val();

editor.set('mode', currentMode);

updateValue();
});
}

// editor.set('value', 'Change the original content');
});
</script>
Expand Down

0 comments on commit 1045d3d

Please sign in to comment.