Loading ...
Sorry, an error occurred while loading the content.

Re: [jslint] Re: Double Indentation (UNCLASSIFIED)

Expand Messages
  • Cheney, Edward A SSG RES USAR USARC
    Classification: UNCLASSIFIED The whitespace algorithm is not wrong in its error. The cause of your problem is the .css . This this instead: var i =
    Message 1 of 4 , Apr 6, 2011
    • 0 Attachment
      Classification: UNCLASSIFIED
      The whitespace algorithm is not wrong in its error. The cause of your problem is the ".css".
      This this instead:

      var i = $('<p></p>').css({
      width: '100%',
      height: '200px'
      }),
      o = $('<div></div>').css({
      position: 'absolute',
      top: '0',
      left: '0',
      visibility: 'hidden',
      width: '200px',
      height: '150px',
      overflow: 'hidden'
      }),
      w1,
      h1,
      w2,
      h2;


      Thanks,
      Austin Cheney, CISSP
      http://prettydiff.com/
      Classification: UNCLASSIFIED
    • Cheney, Edward A SSG RES USAR USARC
      Classification: UNCLASSIFIED That did not work. Go here instead: http://prettydiff.com/jslint_whitespace.txt Thanks, Austin Cheney, CISSP
      Message 2 of 4 , Apr 6, 2011
      • 0 Attachment
        Classification: UNCLASSIFIED
        That did not work. Go here instead:

        http://prettydiff.com/jslint_whitespace.txt

        Thanks,
        Austin Cheney, CISSP
        http://prettydiff.com/
        Classification: UNCLASSIFIED
      • Erik Eckhardt
        That works to satisfy jslint, but if I m chaining methods together then it gets a little weird: var z, i = $( ).css({ width: 100% , height:
        Message 3 of 4 , Apr 6, 2011
        • 0 Attachment
          That works to satisfy jslint, but if I'm chaining methods together then it
          gets a little weird:

          var z,
          i = $('<div></div>').css({
          width: '100%',
          height: '200px'
          }).append($('<p></p>')).css({
          color: 'blue'
          }),
          x,
          y;

          var z,
          i2 = $('<div></div>')
          .css({
          width: '100%',
          height: '200px'
          })
          .append($('<p></p>'))
          .css({
          color: 'blue'
          }),
          x,
          y;

          I like the second one better, despite how deep it gets, because it puts one
          chained method per line, at the beginning of the line. In the upper example,
          it makes it look like color: 'blue' is part of append, when it's not. Moving
          the .css({ to the next line after append now has some method lines starting
          with }) and some with . in an inconsistent fashion. The extra level of
          indentation keeps variable names at one indent and the method chaining in
          one so there's no confusion about what variable started the chaining.

          In the second example }) always ends a line and doesn't have a method coming
          after it. Methods are always introduced at the beginning of a line. It makes
          more sense to me.

          Douglas, what are you thoughts?

          Erik

          P.S. If the spaces didn't come through please let me know and I'll redo.

          On Wed, Apr 6, 2011 at 7:31 AM, Cheney, Edward A SSG RES USAR USARC <
          austin.cheney@...> wrote:

          >
          >
          > Classification: UNCLASSIFIED
          > The whitespace algorithm is not wrong in its error. The cause of your
          > problem is the ".css".
          > This this instead:
          >
          > var i = $('<p></p>').css({
          > width: '100%',
          > height: '200px'
          > }),
          > o = $('<div></div>').css({
          > position: 'absolute',
          > top: '0',
          > left: '0',
          > visibility: 'hidden',
          > width: '200px',
          > height: '150px',
          > overflow: 'hidden'
          > }),
          > w1,
          > h1,
          > w2,
          > h2;
          >
          > Thanks,
          > Austin Cheney, CISSP
          > http://prettydiff.com/
          > Classification: UNCLASSIFIED
          >
          >


          [Non-text portions of this message have been removed]
        • Rob Richardson
          Turn off strict white-space and JSLint won t annoy you in this way anymore. Rob ... From: jslint_com@yahoogroups.com [mailto:jslint_com@yahoogroups.com] On
          Message 4 of 4 , Apr 6, 2011
          • 0 Attachment
            Turn off strict white-space and JSLint won't annoy you in this way anymore.

            Rob


            -----Original Message-----
            From: jslint_com@yahoogroups.com [mailto:jslint_com@yahoogroups.com] On
            Behalf Of Erik Eckhardt
            Sent: Wednesday, April 06, 2011 9:33 AM
            To: jslint_com@yahoogroups.com
            Subject: Re: [jslint] Re: Double Indentation (UNCLASSIFIED)

            That works to satisfy jslint, but if I'm chaining methods together then it
            gets a little weird:

            var z,
            i = $('<div></div>').css({
            width: '100%',
            height: '200px'
            }).append($('<p></p>')).css({
            color: 'blue'
            }),
            x,
            y;

            var z,
            i2 = $('<div></div>')
            .css({
            width: '100%',
            height: '200px'
            })
            .append($('<p></p>'))
            .css({
            color: 'blue'
            }),
            x,
            y;

            I like the second one better, despite how deep it gets, because it puts one
            chained method per line, at the beginning of the line. In the upper example,
            it makes it look like color: 'blue' is part of append, when it's not. Moving
            the .css({ to the next line after append now has some method lines starting
            with }) and some with . in an inconsistent fashion. The extra level of
            indentation keeps variable names at one indent and the method chaining in
            one so there's no confusion about what variable started the chaining.

            In the second example }) always ends a line and doesn't have a method coming
            after it. Methods are always introduced at the beginning of a line. It makes
            more sense to me.

            Douglas, what are you thoughts?

            Erik

            P.S. If the spaces didn't come through please let me know and I'll redo.

            On Wed, Apr 6, 2011 at 7:31 AM, Cheney, Edward A SSG RES USAR USARC <
            austin.cheney@...> wrote:

            >
            >
            > Classification: UNCLASSIFIED
            > The whitespace algorithm is not wrong in its error. The cause of your
            > problem is the ".css".
            > This this instead:
            >
            > var i = $('<p></p>').css({
            > width: '100%',
            > height: '200px'
            > }),
            > o = $('<div></div>').css({
            > position: 'absolute',
            > top: '0',
            > left: '0',
            > visibility: 'hidden',
            > width: '200px',
            > height: '150px',
            > overflow: 'hidden'
            > }),
            > w1,
            > h1,
            > w2,
            > h2;
            >
            > Thanks,
            > Austin Cheney, CISSP
            > http://prettydiff.com/
            > Classification: UNCLASSIFIED
            >
            >


            [Non-text portions of this message have been removed]



            ------------------------------------

            Yahoo! Groups Links
          Your message has been successfully submitted and would be delivered to recipients shortly.