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

Use this.statics() for storing the iframeId var.

Also accessing the ID outside the class through a method.
parent 0745f9f0
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -104,7 +104,7 @@ Ext.define('Docs.controller.Examples', {
                url: exampleId,
                success: function(json) {
                    inlineEg.codeEditor.setValue(json.data.files["basic_grid_panel.js"].content);
                    window.frames['egIframe' + inlineEg.iframeId].refreshPage(inlineEg.codeEditor.getValue(), '');
                    window.frames[inlineEg.getIframeId()].refreshPage(inlineEg.codeEditor.getValue(), '');
                },
                scope: this
            });
@@ -157,7 +157,7 @@ Ext.define('Docs.controller.Examples', {
    },

    refreshPreview: function(cmp) {
        document.getElementById('egIframe' + cmp.iframeId).contentWindow.refreshPage(cmp.codeEditor.getValue(), '');
        document.getElementById(cmp.getIframeId()).contentWindow.refreshPage(cmp.codeEditor.getValue(), '');
    }

});
 No newline at end of file
+17 −5
Original line number Diff line number Diff line
@@ -14,6 +14,10 @@ Ext.define('Docs.view.examples.Inline', {
        constrainTo: false
    },

    statics: {
        iframeId: 0
    },

    dockedItems: [{
        xtype: 'toolbar',
        dock: 'left',
@@ -52,10 +56,6 @@ Ext.define('Docs.view.examples.Inline', {
    },

    initComponent: function() {
        Docs.view.examples.Inline.prototype.iframeId = Docs.view.examples.Inline.prototype.iframeId || 0;
        Docs.view.examples.Inline.prototype.iframeId = Docs.view.examples.Inline.prototype.iframeId + 1;
        this.iframeId = Docs.view.examples.Inline.prototype.iframeId;

        this.items = [{
            cmpName: 'code',
            style: 'border: 0',
@@ -67,7 +67,7 @@ Ext.define('Docs.view.examples.Inline', {
        this.items.push({
            bodyPadding: 10,
            cmpName: 'preview',
            html: '<iframe id="egIframe' + this.iframeId + '" src="egIframe.html" style="width: 100%; height: 100%; border: 0"></iframe>'
            html: '<iframe id="' + this.getIframeId() + '" src="egIframe.html" style="width: 100%; height: 100%; border: 0"></iframe>'
        });

        this.items.push({
@@ -79,6 +79,18 @@ Ext.define('Docs.view.examples.Inline', {
        this.callParent(arguments);
    },

    /**
     * Returns iframe ID for this inline example component.
     * @return {String}
     */
    getIframeId: function() {
        if (!this.iframeId) {
            this.statics().iframeId += 1;
            this.iframeId = "egIframe" + this.statics().iframeId;
        }
        return this.iframeId;
    },

    /**
     * Syncs the height with number of lines in code example.
     */