Commit 04d06859 authored by Rene Saarsoo's avatar Rene Saarsoo
Browse files

Refactor extracting inline preview options from class attribute.

Also document the options object.
parent 94bdfce1
Loading
Loading
Loading
Loading
+10 −2
Original line number Diff line number Diff line
@@ -74,8 +74,16 @@ Ext.define('Docs.controller.InlineExamples', {
            // Strip tags and replace HTML entities with their values
            var code = Ext.String.htmlDecode(Ext.util.Format.stripTags(inlineEg.innerHTML));
            var options = {};
            Ext.Array.forEach(inlineEg.className.split(/ +/), function(cssClass) {
                options[cssClass] = true;
            Ext.Array.forEach(inlineEg.className.split(/ +/), function(cls) {
                if (cls === "phone" || cls === "miniphone" || cls === "tablet") {
                    options.device = cls;
                }
                else if (cls === "ladscape" || cls === "portrait") {
                    options.orientation = cls;
                }
                else {
                    options[cls] = true;
                }
            });
            var div = document.createElement("div");
            inlineEg.parentNode.replaceChild(div, inlineEg);
+10 −0
Original line number Diff line number Diff line
@@ -47,6 +47,16 @@ Ext.define('Docs.view.examples.Inline', {
        ]
    }],

    /**
     * @cfg {Object} options
     * A set of options for configuring the preview:
     *
     * @cfg {String} options.device phone, miniphone or tablet
     * @cfg {String} options.orientation ladscape or portrait
     * @cfg {Boolean} options.raw True to turn off Ext.setup().
     */
    options: {},

    initComponent: function() {
        this.items = [
            this.editor = Ext.create('Docs.view.examples.InlineEditor', {
+9 −2
Original line number Diff line number Diff line
@@ -13,6 +13,13 @@ Ext.define('Docs.view.examples.InlinePreview', {
        iframeId: 0
    },

    /**
     * @cfg {Object} options
     * A set of options for configuring the preview.
     * See docs of parent component.
     */
    options: {},

    initComponent: function() {
        this.html = this.getHtml();

@@ -23,8 +30,8 @@ Ext.define('Docs.view.examples.InlinePreview', {
        if (Docs.touchExamplesUi) {
            return Ext.create('Docs.view.examples.Device', {
                id: this.getIframeId(),
                device: this.options.tablet ? "tablet" : (this.options.miniphone ? "miniphone" : "phone"),
                orientation: this.options.portrait ? "portrait" : "landscape"
                device: this.options.device,
                orientation: this.options.orientation
            }).toHtml();
        }
        else {