Commit b7e3d3db authored by Rene Saarsoo's avatar Rene Saarsoo
Browse files

Support for raw examples.

parent e2764afa
Loading
Loading
Loading
Loading
+4 −3
Original line number Diff line number Diff line
@@ -40,16 +40,17 @@ Ext.define('Docs.view.examples.InlinePreview', {

    /**
     * Updates the live example inside iframe with new code.
     * @param {String} javascript  The code to run inside iframe.
     * @param {String} code  The code to run inside iframe.
     */
    update: function(javascript) {
    update: function(code) {
        var options = this.options.raw;
        var iframe = document.getElementById(this.getIframeId());
        // Something is not quite ready when onload fires.
        // I'm unsure what I should wait for. So I'm currently adding just this nasty delay.
        // 1 ms works in Chrome, Firefox wants something bigger. Works in IE too.
        iframe.onload = function() {
            Ext.Function.defer(function() {
                iframe.contentWindow.refreshPage(javascript);
                iframe.contentWindow.refreshPage(code, options.raw);
            }, 100);
        };
        iframe.src = Docs.touchExamplesUi ? "touchIframe.html" : "extIframe.html";
+5 −2
Original line number Diff line number Diff line
@@ -8,10 +8,13 @@
    <link rel="stylesheet" type="text/css" href="touch/resources/css/sencha-touch.css">

    <script type="text/javascript">
        var refreshPage = function(code) {
        var refreshPage = function(code, raw) {
            try {
                document.body.innerHTML = '';
                eval("Ext.setup({onReady: function(){" + code + "}});");
                if (!raw) {
                    code = "Ext.setup({onReady: function(){" + code + "}});";
                }
                eval(code);
            } catch (e) {
                document.body.innerHTML = e;
            }