Commit 058199f2 authored by Nick Poulden's avatar Nick Poulden
Browse files

Merge branch 'master' into comments

parents 848853d9 5f40da6f
Loading
Loading
Loading
Loading
+2 −8
Original line number Diff line number Diff line
@@ -118,8 +118,8 @@ module JsDuck
            :type => :operator,
            :value => @input.scan(/./)
          }
        elsif @input.check(/[a-zA-Z_]/)
          value = @input.scan(/\w+/)
        elsif @input.check(/[a-zA-Z_$]/)
          value = @input.scan(/[$\w]+/)
          return {
            :type => KEYWORDS[value] ? :keyword : :ident,
            :value => value
@@ -167,12 +167,6 @@ module JsDuck
            :type => :number,
            :value => nr
          }
        elsif @input.check(/\$/)
          value = @input.scan(/\$\w*/)
          return {
            :type => :ident,
            :value => value
          }
        elsif  @input.check(/./)
          return {
            :type => :operator,
+8 −0
Original line number Diff line number Diff line
@@ -25,6 +25,14 @@ describe JsDuck::Lexer do
    ]
  end

  it "handles $ in identifiers" do
    lex("$fo$o").should == [[:ident, "$fo$o"]]
  end

  it "handles numbers in identifiers" do
    lex("x2").should == [[:ident, "x2"]]
  end

  describe "differenciates regex from division" do

    it "when regex after operator" do
+78 −0
Original line number Diff line number Diff line
/**
 * Creates HTML for Sencha Touch (inline-)example.
 */
Ext.define('Docs.view.examples.Device', {
    config: {
        /**
         * @cfg {String} url
         * Path to the example.
         */
        url: "",
        /**
         * @cfg {String} id
         * ID for the iframe. Auto-generated by default.
         */
        id: undefined,
        /**
         * @cfg {String} device
         * Either phone or tablet.
         * @accessor
         */
        device: 'phone',
        /**
         * @cfg {String} orientation
         * Either landscape or portrait.
         * @accessor
         */
        orientation: 'landscape'
    },

    constructor: function(cfg) {
        Ext.apply(this, cfg);
        Ext.apply(this, this.getIframeSize());
        this.id = this.id || Ext.id();

        // Template for the DIV containing device image and iframe
        this.tpl = new Ext.XTemplate(
            '<div class="touchExample {device} {orientation}">',
                '<iframe id={id} style="width: {width}; height: {height}; border: 0;" ',
                        'src="{url}"></iframe>',
            '</div>'
        );
    },

    /**
     * Returns the HTML displaying the example in this device.
     * @return {String}
     */
    toHtml: function() {
        return this.tpl.apply(this);
    },

    setDevice: function(device) {
        this.device = device;
        Ext.apply(this, this.getIframeSize());
    },

    setOrientation: function(orientation) {
        this.orientation = orientation;
        Ext.apply(this, this.getIframeSize());
    },

    // Returns width and height of current device iframe.
    getIframeSize: function() {
        // device dimensions in landscape orientation
        var landscape = {
            phone: {width: '480px', height: '320px'},
            tablet: {width: '717px', height: '538px'}
        }[this.device];

        // return landscape w/h or swap the dimensions
        if (this.orientation === 'landscape') {
            return landscape;
        }
        else {
            return {width: landscape.height, height: landscape.width};
        }
    }
});
+2 −2
Original line number Diff line number Diff line
@@ -18,7 +18,7 @@ Ext.define('Docs.view.examples.Inline', {
        constrainTo: false
    },
    // Make too long examples scrollable
    maxHeight: 400,
    maxHeight: 890,

    dockedItems: [{
        xtype: 'toolbar',
@@ -97,7 +97,7 @@ Ext.define('Docs.view.examples.Inline', {
    // Syncs the height with number of lines in code example.
    updateHeight: function() {
        if (Docs.touchExamplesUi) {
            this.setHeight(320+50);
            this.setHeight(this.preview.getHeight());
        }
        else {
            var editorHeight = this.editor.getHeight();
+16 −9
Original line number Diff line number Diff line
@@ -3,6 +3,10 @@
 */
Ext.define('Docs.view.examples.InlinePreview', {
    extend: 'Ext.Panel',
    requires: [
        'Docs.view.examples.Device'
    ],

    bodyPadding: '0 10',

    statics: {
@@ -17,16 +21,11 @@ Ext.define('Docs.view.examples.InlinePreview', {

    getHtml: function() {
        if (Docs.touchExamplesUi) {
            var tpl = new Ext.XTemplate(
                '<div class="touchExample {device} {orientation}">',
                    '<iframe id="{id}" style="border: 0;"></iframe>',
                '</div>'
            );
            return tpl.apply({
            return Ext.create('Docs.view.examples.Device', {
                id: this.getIframeId(),
                device: this.options.tablet ? "tablet" : "phone",
                orientation: this.options.portrait ? "portrait" : "landscape"
            });
            }).toHtml();
        }
        else {
            var tpl = new Ext.XTemplate(
@@ -43,14 +42,14 @@ Ext.define('Docs.view.examples.InlinePreview', {
     * @param {String} code  The code to run inside iframe.
     */
    update: function(code) {
        var options = this.options.raw;
        var options = this.options;
        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(code, options.raw);
                iframe.contentWindow.refreshPage(code, options);
            }, 100);
        };
        iframe.src = Docs.touchExamplesUi ? "touchIframe.html" : "extIframe.html";
@@ -63,6 +62,14 @@ Ext.define('Docs.view.examples.InlinePreview', {
            this.iframeId = "egIframe" + this.statics().iframeId;
        }
        return this.iframeId;
    },

    /**
     * Returns the current height of the preview.
     * @return {Number}
     */
    getHeight: function() {
        return document.getElementById(this.getIframeId()).parentNode.clientHeight;
    }

});
Loading