Feedback on Prompt.jsm

Mark Finkle mfinkle at mozilla.com
Thu May 23 06:40:39 PDT 2013


For those following along, bug 875119 has several sets of feedback. Take a look in the bug for details. 

----- Original Message -----

> I put up a patch in bug 875119 to add a new Prompt.jsm module to
> Fennec. The idea is to expose some of the extra features that
> prompts can have (in our own code and in addons), without requiring
> them to learn (or tying us to) a particular JSON message format.
> Before we land something like this, I'd love to get some feedback
> from anyone interested.

> This requires the async prompt service code i'm writing in bug 870062
> to work. The API is pretty self explanatory. Most (except show)
> methods return the prompt object so you can chain them. Quick
> overview:

> Prompt(window)
> setTitle: function(aTitle)
> setMessage: function(aMessage)

> // adds buttons at the bottom of the dialog.
> // throws if you try to add more than three buttons
> // XXX Is this confusing with the other inputs below?
> addButton: function(aLabel)

> // order of calling these dictates the order they're shown
> addCheckbox: function(aLabel, aChecked)
> addTextbox: function(aValue, aHint, aAutofocus)
> addPassword: function(aValue, aHint, aAutofocus)
> addMenulist: function(aValues)
> // XXX: Add date-time inputs...

> show: function(callback)

> // aItems can be an array of strings or objects
> // these should(?) (but don't currently) throw if you've set a
> message
> // or other inputs as we currently don't support showing both
> // simultaneously. I'd like to fix that someday though.
> setSingleChoiceItems: function(aItems)
> setMultiChoiceItems: function(aItems)

> Examples:

> // Show a prompt with a title, message, checkbox, and one button
> var p = new Prompt(window) // in case we ever have tab modal prompts
> .setTitle("Title")
> .setMessage("this is a message")
> .addCheckbox("My checkbox", true, "myCheckbox")
> .addButton("B1")
> .show(function(data) {
> // the return value isn't well formalized yet...
> var button = data.button;
> var checked = data.myCheckbox;
> });

> Ex2:
> // Show a prompt with a list of single choice items and a title
> var p = new Prompt(window);
> p.setTitle("My Title");
> p.setSingleChoiceItems(["One", "Two", "Three"]);
> p.show(function(data) {
> var indexClicked = data.button;
> });

> Ex3:
> // Show a prompt with a list of multi choice items and a title
> var p = new Prompt(window);
> p.setTitle("My Title");
> p.setMultichoiceItems([
> { label: "One", id: 1, disabled: true },
> // Shows as a group header with children underneath
> { label: "Two", id: 2, children: [
> { label: "Three", id: 3 }
> ]},
> // We also support sub-menus, but I'm not sure how to expose them.
> // This is stubbed right now so that we can at least show the submenu
> arrow
> { label: "Four", id 4, submenu: true },
> ]).show(function(data) {
> // button contains an array of booleans indicating whether
> // a row is now selected or unselected...
> var selected = data.button;
> });
> _______________________________________________
> mobile-firefox-dev mailing list
> mobile-firefox-dev at mozilla.org
> https://mail.mozilla.org/listinfo/mobile-firefox-dev
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/mobile-firefox-dev/attachments/20130523/c681430f/attachment.html>


More information about the mobile-firefox-dev mailing list