-
Notifications
You must be signed in to change notification settings - Fork 684
Dimensions 2 #744
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Dimensions 2 #744
Conversation
1. Updated sizing/dimensions code. 2. Added text wrapping option. 3. Using getBoundingClientRect() 4. Ditch globals 5. Update tests. 6. Update CSS
|
@mlh758 When you have had a chance to look at this, there are a few things I would to discuss related to defaults and default behavior for some of the new options. |
|
Do you want to address those questions before merging this PR? |
mlh758
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
After our discussion with code comments in an earlier PR, I'd prefer you at least stuck to the JSDoc stuff on your methods that return values.
tests/unit/options.js
Outdated
|
|
||
| width = "3in"; | ||
| el.multiselect("option", "menuWidth", width).multiselect('refresh'); | ||
| assert.equal(menu().parent().find(".ui-multiselect-menu").outerWidth(), 3 * 96.0, 'menuWidth supports strings suffixed with various units as well as integer px values'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you update the assert message here with the in unit?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok
| }); | ||
|
|
||
| checkboxes = el.multiselect("widget").find(":checkbox"); | ||
| var checkboxes = el.multiselect("widget").find(":checkbox"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch adding all these vars.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually, this is a result of you updating Qunit. 👍
It has a new option you can set when running it to find all the global variables and flag them as test failures.
src/jquery.multiselect.js
Outdated
|
|
||
| this.$buttonlabel = $( document.createElement('span') ) | ||
| .html(options.noneSelectedText) | ||
| .html(options.noneSelectedText || $element[0].placeholder || 'Select options') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you need the third item in the || clauses? The description made it sound like if the option was null it would use the placeholder. If it's null and there's no placeholder I think I would prefer it do nothing or log a warning instead of having two places for the nonSelectedText option in the code.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That is fine. I can take that out.
src/jquery.multiselect.js
Outdated
| * @param {object} $checkboxes widget's container to append the built options to | ||
| */ | ||
| _buildOptionList: function($element, $checkboxContainer) { | ||
| _buildOptionList: function($element, $checkboxes) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Now that the recursion is gone, we could probably use the instance variables of the widget instead of passing these parameters in. Don't need to fix it in this PR, just something I wanted to make a note of.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agreed.
src/jquery.multiselect.js
Outdated
|
|
||
| self._setButtonValue(value, isDefault); | ||
|
|
||
| if ( !/\bbutton\b/.test( options.wrapText ) ) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For consistency I prefer that even single line if statements be wrapped in braces.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok
src/jquery.multiselect.js
Outdated
| var minimax = parsed.minimax; | ||
| width = minimax < 0 ? Math.max(width, pixels) : ( minimax > 0 ? Math.min(width, pixels) : pixels ); | ||
| } | ||
| else // keywords |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same thing with the braces on all these.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Keywords?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Keywords : e.g. 'auto' The comment is just emphasizing that keyword options drop to the else.
src/jquery.multiselect.js
Outdated
| /** | ||
| * Toggles the checked state on options within the menu | ||
| * Potentially scoped down to visible elements from filteredInputs | ||
| * Groups don't show up in the filter search right now, so both |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I deleted this portion of the comment intentionally, it wasn't true.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, did I revert the delete by accident?
src/jquery.multiselect.js
Outdated
| // show the menu, maybe with a speed/effect combo | ||
| // if there's an effect, assume jQuery UI is in use | ||
| $.fn.show.apply($menu, effect ? [ effect, speed ] : []); | ||
| if (effect) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same thing with braces.
|
I created a dialog demo in the same gist I had the speed test demo in. It looks like the width doesn't get calculated when the widget is in a dialog. Prior to this it would just wrap the text. Edit: With a little more testing I found a bug in the base branch as well. Setting |
Look at the wrapText option... It should be set as 'button,header,menu' as the default. It looks like I goofed and forgot to set that before committing. |
|
@mlh758 Ok, made changes. Can you please take another look at the layout issues you were seeing? I am hoping it was just a case of me previously forgetting to change the default value for an option back before committing. |
|
@mlh758 As to what I wanted to discuss... (this is long... sorry)
Again, sorry for the length... Your thoughts? |
|
Checked it out again, layout issues are fixed and that 100% issue I showed on the base branch is also fixed. Edit: Your changes look good to merge now too. |
min-width has good browser support for the basic pixel/percentage values. But yes, we only really resize at specifically coded moments, so I'm not really sure if that would give us any extra benefit. I think it might be worth adding a wiki example that shows people how to hook into
I think having the text wrapping on by default is the best way to go. It does seem to grow in auto mode now which, if someone wants that, is functional. I'm not sure on the practicality of it either but if it works and isn't the default behavior then I'm okay with it.
To me that seems like the expected behavior of going out of your way to set the widths differently. I think the user could call
I don't think that's necessary since the default behavior is matching widths. If the user is changing these options it is presumably to no longer have them match.
I agree with you here. At some point, if too much of our behavior mimics theirs, it might be worth asking if it's really worth having a separate widget from theirs. It's probably our differences in behavior that will keep this project valuable, as long as those differences aren't degrading the user experience.
What is the takeaway I should be getting from that snippet? Their use of the css property? |
Yes. I was just referencing that in my comments about min-width and whether I should maybe be setting it or any other CSS. No matter... I think I have my answer from your other comments. 😉 I think you can merge this. I have a few closing comments I want to record "for posterity" in the related issue #727, but I will close that also. |


Addresses #717 (partially) , #727, #737 (partially)
Note that this includes the Qunit / tests update by @mlh758