Skip to content
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

NFR: Allow nested object creation #24

Closed
Martii opened this issue Aug 4, 2010 · 11 comments
Closed

NFR: Allow nested object creation #24

Martii opened this issue Aug 4, 2010 · 11 comments
Labels
Rejected proposed change is rejected

Comments

@Martii
Copy link
Collaborator

Martii commented Aug 4, 2010

New Feature Request

This is offered as a possible alternative to the issue #23 and goes along the lines of my thinking for #15 as well.

It would be helpful for coders to be able to control what happens with DOM creation.

An example init settings object could be this:

{
  {
    "checkBoxItem1": {
        "label": '',    // Would be nice to omit this line if possible.
        "type": 'checkbox',
        "default": true
    },
    "labelItem1": {
      "label": 'The actual text for item 1'
    }
  },
  {
    "checkBoxItem2": {
        "label": '',    // Would be nice to omit this line if possible.
        "type": 'checkbox',
        "default": true
    },
    "labelItem2": {
      "label": 'The actual text for item 2'
    }
  }
}

This would create the DOM something like this

...

<div class="config_var" title="">
  <span id="something1" class="something">
    <input type="checkbox" id="gmc_field_checkBoxItem1" value="true">
  </span>
  <span id="something2" class="something">
    <span id="gmc_labelItem1_field_label" class="field_label">The actual text for item 1</span>
  </span>
</div>
<div class="config_var" title="">
  <span id="something3" class="something">
    <input type="checkbox" id="gmc_field_checkBoxItem2" value="true">
  </span>
  <span id="something4" class="something">
    <span id="gmc_labelItem2_field_label" class="field_label">The actual text for item 2</span>
  </span>
</div>

...

This would create a third tier of object creation instead of the standard two... plus it could be backwards compatible perhaps.

Let me know what you think. :)

@sizzlemctwizzle
Copy link
Owner

I don't like it. I'm not willing to add yet another level of nesting to the JSON, especially when all it achieves is a cosmetic change.

You have to remember these are settings for managing values and aren't meant to control the layout of the resulting window. GM_config focuses on functionality and not looks. That should be left to the author of the script using CSS and Javascript(through the use of callbacks).

I also really don't like how the fields and labels are wrapped in an unnamed object. That sort of nesting looks confusing to me.

#23 sounds like a much better compromise to specifying the order of elements.

@Martii
Copy link
Collaborator Author

Martii commented Aug 4, 2010

While #23 will be appreciated for standardizing the toolkit for left aligned text wrapping this ticket would also allow multiple columns instead of just a single column... so if there was a label in one column and then below it a bunch of checkboxes in some sort of matrix (say 5 x 3 ) this would allow it it as well... not just a cosmetic but the ability to maximize the available space for the UI depending on the questions/actions offered. ;) Granted this would need to be a recursive creation.

For example:

Lets say I create an options dialog that asks... (X being a checkbox or radio button depending on my implied logic)

Where do you want to float the button(s) on the the screen?

X upper-left     X upper-left-middle     X upper-middle     X upper-right-middle    X upper-right
X middle-left    X middle-left-middle    X middle-middle    X middle-right-middle   X middle-right
X lower-left     X lower-left-middle     X lower-middle     X lower-right-middle    X lower-right

Next Option
Next Option
Next Option
Next Option
Next Option
Next Option
Next Option
Next Option
Next Option
...

instead of what is currently available in GMC

Where do you want to float the button(s) on the the screen?

X upper-left
X upper-left-middle
X upper-middle
X upper-right-middle
X upper-right
X middle-left
X middle-left-middle
X middle-middle
X middle-right-middle
X middle-right
X lower-left
X lower-left-middle
X lower-middle
X lower-right-middle
X lower-right

Next Option
Next Option
Next Option
Next Option
Next Option
Next Option
Next Option
Next Option
Next Option
...

As you can see anyone can quickly run out of screen real estate just with this one question/option.

@sizzlemctwizzle
Copy link
Owner

That can all be done with CSS. If you want multiple items on one line just set the wrapper div of the element to display: inline !important;. I've given that element its own id so it should be really easy(or you can use a headerless section which I've also added support for). Relying on the settings JSON to define how the elements are displayed is just bad design.

By the way, Joe already thought of what you are requesting(allowing nested fields) and its the only change I haven't pulled from his fork. On further questioning he admitted that he "just wanted the ability for similar fields to be side-by-side." Which is something I want too, but again doing this with JSON is not the right solution.

@sizzlemctwizzle
Copy link
Owner

Here's a script that can basically do what you describe but it relies on CSS and headerless sections.

@Martii
Copy link
Collaborator Author

Martii commented Aug 4, 2010

That can all be done with CSS.

cough not until at least this commit today after I made this issue ticket reply it wasn't possible ;) If you continued to reject this I would have done a NFR for it anyhow. Don't forget I usually know the answers to most of my questions before I ask them :) Glad you added the ability... makes GMC more adaptable.

@Martii
Copy link
Collaborator Author

Martii commented Aug 4, 2010

Here's a script that can basically do what you describe but it relies on CSS and headerless sections.

Btw that script is currently broken.

@sizzlemctwizzle
Copy link
Owner

not until at least this commit today
You could have but it would've required a little XPath magic in your open callback. Anyway, I'm glad I made it easier to achieve.
currently broken.
Bound to happen when you @require a webpage lol

@Martii
Copy link
Collaborator Author

Martii commented Aug 5, 2010

You could have but it would've required a little XPath magic in your open callback. Anyway, I'm glad I made it easier to achieve.

Not true... IE doesn't support XPath on the document object ;) hence why I'm buggin ya in other circles. :)

Bound to happen when you @require a webpage lol

hehe ;)

@sizzlemctwizzle
Copy link
Owner

IE doesn't support XPath on the document object
I didn't know GM_config even supported IE.

Edit: I did a little research and apparently IE has a JSON parser and localStorage. Crazy they have those and still no native XPath for HTML pages. So maybe GMC is IE compatible lol

Nevermind, did more research and IE doesn't support addEventListener until IE 9 so we aren't compatible after all.

@Martii
Copy link
Collaborator Author

Martii commented Aug 5, 2010

You see part of my point though? ;) and I'm reminded of:

... I definitely want GM_config to be compatible with as many user script enabled browsers as possible.

I think it does support some form of event listening but I am so rarely in IE

Anywho... I'll try the new ids out later this weekend have work to do today so no more play.

P.S. Safari just made it in my local news with a major vulnerability too LOL... GO FIREFOX! ;)

@sizzlemctwizzle
Copy link
Owner

I think it does support some form of event listening but I am so rarely in IE
It does but its archaic.
and I'm reminded of:
I knew I'd regret that statement. Anyway, IE users not invited to the party for now.
GO FIREFOX! ;)
I'd say that I love Firefox, but that is an understatement.
have work to do today so no more play.
Me too man :(

This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Rejected proposed change is rejected
Projects
None yet
Development

No branches or pull requests

2 participants