Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(7769)

Issue 82042: Melange Surveys: Survey taking and editing JS, additions to CSS.

Can't Edit
Can't Publish+Mail
Start Review
Created:
14 years, 10 months ago by ajaksu
Modified:
8 years, 4 months ago
Reviewers:
Mario Ferraro
CC:
melange-soc-dev_googlegroups.com, thelevybreaks
Visibility:
Public.

Patch Set 1 #

Patch Set 2 : Updated #

Total comments: 229

Patch Set 3 : Merged James's code, no fixes from review yet... #

Patch Set 4 : Addresses most issues raised #

Total comments: 29

Patch Set 5 : Fixed latest issues #

Unified diffs Side-by-side diffs Delta from patch set Stats (+1171 lines, -6 lines) Patch
M app/soc/content/css/soc-090602.css View 1 2 3 4 5 chunks +213 lines, -6 lines 0 comments Download
A app/soc/content/js/default-text.js View 2 3 4 1 chunk +91 lines, -0 lines 0 comments Download
A app/soc/content/js/edit_survey.js View 1 2 3 4 1 chunk +715 lines, -0 lines 0 comments Download
A app/soc/content/js/take_survey.js View 1 2 3 4 1 chunk +152 lines, -0 lines 0 comments Download

Messages

Total messages: 4
Mario Ferraro
Hi guys, for the moment I've put focus on style issues, please don't hate me ...
14 years, 10 months ago (2009-06-23 23:42:36 UTC) #1
ajaksu
Mario, a *huge*, never-ending stream of thank you very much for this great review! :) ...
14 years, 10 months ago (2009-06-25 06:31:03 UTC) #2
Mario Ferraro
Great work ^__^ Just few things to correct, one thing I was wrong (fixed our ...
14 years, 10 months ago (2009-06-26 12:02:10 UTC) #3
ajaksu
14 years, 10 months ago (2009-06-26 13:53:07 UTC) #4
Thanks again for reviewing, Mario. 

Regarding the function per line style, we have to avoid making code harder to
read by stretching it too high. I'm afraid three lines per-call (assuming one
argument) tends to make chainy code too high, so we could make it less chainy,
use a rule that lowers the average lines per-call, etc. (if this is a concern)
:)

http://codereview.appspot.com/82042/diff/1008/2010
File app/soc/content/css/soc-090602.css (right):

http://codereview.appspot.com/82042/diff/1008/2010#newcode1
Line 1: /*
On 2009/06/26 12:02:10, Mario Ferraro wrote:
> For the whole file: I was thinking it could be good to agree on using a space
> after ":" for every statement like this:
> 
> .classwhatever {
>   width: 50px;
> }
> 
> instead of
> 
> .classwhatever {
>   width:50px;
> }
> 
> I see you use both, perhaps we want to do it only in the former way. Just a
> suggestion :)

I actually wanted to use a space, but missed some places, thank!

http://codereview.appspot.com/82042/diff/1008/2010#newcode661
Line 661: 
On 2009/06/26 12:02:10, Mario Ferraro wrote:
> Ehm :) Now it's void... it's still needed to be filled afterwards?

Not sure, but as we have to go through CSS and HTML for cross-browser checking,
adding a TODO to remove if not needed :)

http://codereview.appspot.com/82042/diff/1008/2010#newcode669
Line 669: div #survey_widget th, div #survey_widget td {
On 2009/06/26 12:02:10, Mario Ferraro wrote:
> Sorry I didn't understand if you liked the idea or if you missed the change :)
> If it's so, just put every selector in a line like this:
> 
> div #survey_widget th,
> div #survey_widget td {
> }

Missed this one :)
Done,thanks!

http://codereview.appspot.com/82042/diff/1008/2010#newcode781
Line 781: .ui-button {
On 2009/06/26 12:02:10, Mario Ferraro wrote:
> Ok I was meaning exactly that ^__^

Cool :)

http://codereview.appspot.com/82042/diff/1008/2011
File app/soc/content/js/default-text.js (right):

http://codereview.appspot.com/82042/diff/1008/2011#newcode72
Line 72: };
On 2009/06/26 12:02:10, Mario Ferraro wrote:
> Uhm, you're right... I was very wrong here, it's unnecessary and packers would
> like it anyway... it's when you're storing anonymous functions inside
variables
> that is necessary. Changed the style guide in our wiki accordingly... and
> well... please forgive me if I ask you to delete it :D :D

No problem, done :)

http://codereview.appspot.com/82042/diff/1008/2011#newcode82
Line 82: };
On 2009/06/26 12:02:10, Mario Ferraro wrote:
> Delete it again without hating me too much :P

Done.

http://codereview.appspot.com/82042/diff/1008/2012
File app/soc/content/js/edit_survey.js (right):

http://codereview.appspot.com/82042/diff/1008/2012#newcode1
Line 1: /* Copyright 2009 the Melange authors.
On 2009/06/26 12:02:10, Mario Ferraro wrote:
> Just a general style question to you for using jQuery (we're enhancing style
> guide here, cool ^__^).
> I find code in lines 199 (with every chained function in a new line) more
> readable than normal chains like do().something().now().
> If you find it also more readable we might want to change it everywhere (if
> we're in a hurry to push, just do it afterwards).

I like the idea, but I think we should discuss it a bit more. I don't believe
I'll have time change the style in all the code before it's July, as we still
have features, testing and fixes to add/do/make.

Would we indent on arguments? Would
field_template.find('label').attr('for', 'NEW_' +
name).append(question_content).end().find('td').append(new_field);

become
field_template.find('label')
.attr('for', 'NEW_' + name)
.append(question_content)
.end()
.find('td')
.append(new_field);

or 

field_template.find(
  'label'
)
.attr(
  'for',
  'NEW_' + name
)
.append(
  question_content
)
.end()
.find(
  'td'
)
.append(
  new_field
);



I'd like to use a less chainy style (maybe unidiomatic JS or jQuery), and we
might want to have a rule of thumb for when to break lines (e.g. after we change
the target object):
field_template.find('label')
.attr('for', 'NEW_' + name);

field_template.append(question_content).end();
// or is the append to the label? :)

field_template.find('td')
.append(new_field);

http://codereview.appspot.com/82042/diff/1008/2012#newcode26
Line 26: var SURVEY_PREFIX = 'survey__';
On 2009/06/26 12:02:10, Mario Ferraro wrote:
> I think you can declare them twice or wrap all the script inside another
> 
> (function() {
> })();
> 
> Don't know if it would work good with this script, if not try also to wrap it
> into:
> 
> (function() {
> });
> 
> or
> 
> var survey = function () {
> }
> 
> it depends on what you have in HTML and the overall functioning of the script.
> Just make some attempts ^__^

I've redeclared them, will test wrapping everything later :)

http://codereview.appspot.com/82042/diff/1008/2012#newcode92
Line 92: widget.find('.long_answer,input').each(function () {
On 2009/06/26 12:02:10, Mario Ferraro wrote:
> Anonymous function in a new line

Missed this one, sorry.

Done

http://codereview.appspot.com/82042/diff/1008/2012#newcode281
Line 281: 
On 2009/06/26 12:02:10, Mario Ferraro wrote:
> Perfect :) The trick is allowed also with jsLint. What that jsLint doesn't
like
> is doing something like this:
> 
> var foo = [
>   '<div>',
>     '<table>',
>     '</table>',
>   '</div>'
> ]
> 
> which, however, is something more readable. We might want to see what can be
> done in jsLint to avoid checking of arrays indentation, or just try something
> else like browser side templates (I'm exploring that solution these days)
> 
How about
var foo = [
  '<div>',
  '  <table>',
  '  </table>',
  '</div>'
]
?

http://codereview.appspot.com/82042/diff/1008/2012#newcode293
Line 293: switch (role_type) {
On 2009/06/26 12:02:10, Mario Ferraro wrote:
> Hmm I think it's ok also with this kind of indentation

Done.

http://codereview.appspot.com/82042/diff/1008/2012#newcode360
Line 360: .end().html());
On 2009/06/26 12:02:10, Mario Ferraro wrote:
> Ok, this is an example of what I meant in the first line: doing something like
> the following perhaps improves readability. Just a proposal.
> 
> $('input#id_s_html')
> .val(
>   widget
>   .find(
>     'div#survey_options'
>   )
>   .remove()
>   .end()
>   .html()
> );
>        

Clear win here, done :)

http://codereview.appspot.com/82042/diff/1008/2012#newcode536
Line 536: switch (button_id) {
On 2009/06/26 12:02:10, Mario Ferraro wrote:
> Just leave this indentation it's fine I think :)

Done.

http://codereview.appspot.com/82042/diff/1008/2013
File app/soc/content/js/take_survey.js (right):

http://codereview.appspot.com/82042/diff/1008/2013#newcode81
Line 81: // remember if form has been touched
On 2009/06/26 12:02:10, Mario Ferraro wrote:
> Fix comment indentation

Done.
Sign in to reply to this message.

Powered by Google App Engine
RSS Feeds Recent Issues | This issue
This is Rietveld f62528b