jQuery UI API #136

wants to merge 4 commits into


None yet

4 participants

igochkov commented Jan 2, 2012

Complete implementation of jQuery UI API generated based on jQuery UI MediaWiki templates.
The generated code contains XML Documentation Comments.

The API includes implementation for:

  1. Behaviour: Draggable, Droppable, Resizable, Selectable, Sortable
  2. Controls: Accordion, Autocomplete, Button, Datepicker, Dialog, Progressbar, Slider, Tabs

Future work: A rewrite in Script# of http://jqueryui.com/demos/ will be included as Sample application.

nikhilk commented Jan 3, 2012

Hi Ivaylo, this looks really great. Should be a good addition.

I have a few comments, but perhaps more interesting would be to understand the code generator you created. That would be useful to check out, and possibly check-in, so that both the comments might be addressed, as well as future updates more easily performed. Could you share some details? Feel free to message me directly. Looking forward to hearing from you...

igochkov added some commits Jan 3, 2012
@igochkov igochkov Fix of the return type in EventData objects. Extension methods (Enabl…
…eSelection, DisableSelection, ect.) of jQueryObject were added.
@igochkov igochkov Initial version of the sample application for the usage of jQuery UI …
…API. Currently are implemented samples only for interactions Draggable and Droppable.
igochkov commented Jan 4, 2012

Hi Nikhil,

The jQuery UI API generator I kept intentionally simple as the jQuery UI team are transitioning their documentation from Mediawiki templates to XML templates (see http://wiki.jqueryui.com/w/page/40995891/Docs2xml).

The old MediaWiki templates are not descriptive enough to generate the jQuery UI API, e.g. I had to write by hand the EventData objects!

The new XML templates are in their initial phase of development (https://github.com/jquery/jquery-docs) and can not be currently used. In the future when they are ready the parsing part can be re-witten and instead of Regex a XML parser can be used.

What are your comments and suggestions about the generated code?

I have a few challenges as this is the first time I actively use Script#:

  • In the beginning my intention was to generate jQueryUI Methods in the {Plugin}Object class as C# methods, but I quickly discovered that it wont work and I introduced enumeration {Plugin}Method for each plugin.
  • jQueryUI extends jQuery object with a few undocumented functions (e.g. enableSelection and disableSelection). Currently I inherit from jQueryObject class which force me to do a cast each time I use one of the extension functions (see Script#/samples/jQuery.UI/jQuery.UI.Sample/Draggable/DelayStart.cs) in my branch. Is there more elegant solution to this problem? I was thinking about C# extension methods but they are not supported from the C# 2.0 compiler.

By the way since I am mentioning the jQueryUI samples, I pushed the first initial version yesterday evening so you can see what I have in mind as sample application. Only the draggable and droppable examples are ready!

alenas commented Feb 7, 2012

Seems like there are few problems with that generated code or how script# handles it.
I added just Autocomplete, Dialog and Resizable folders to my script# project.
When I use Autocomplete like this:
jQuery.Select("#txtWhat").Plugin().Autocomplete(new AutocompleteOptions(
"minLength", 3,
"select", new AutocompleteEventHandler(delegate(jQueryEvent evnt, AutocompleteEventData ui) {
if (Script.IsValue(ui.Item)) TermSuggestions.AutocompleteSearch(ui.Item);
"source", new RequestResponseEventHandler(TermSuggestions.Suggest)

It would not build until I change AutocompleteObject.cs first method to this:
public AutocompleteObject Autocomplete() {
return null;
// removed extern and return null

Note that I am not even using this method - I am using another one - but it just does not compile if first method is extern. Same with DialogObject.cs

igochkov commented Jun 1, 2012

Hi Nikhil,

This project of mine was on hold for a while. Is there still interest from the ScriptSharp users to have jQuery UI API finished?
Do you have any suggestions and/or recommendations?

I can rewrite the generator to use as a source https://github.com/jquery/jquery-docs and then I can publish it as well.


I would like to see the generator, im looking into the possibility of writing some similar but more generic so that it can read javascript files and build the import libraries - including taking over any of the comments from the javascript source.

nikhilk commented Jun 1, 2012

Yes, there is interest to get this out. Some feedback on the generated code, and the additions, as well as questions on the generator.

For feedback, I looked at the ProgressBar APIs, rather than everything, as it can probably be mapped to all other stuff given it is generated code.


  • Use an enum with [NamedValues] instead of a set of string constants
  • Call this ProgressbarEvents (to free up the ProgressbarEvent name for the event object)


  • Call this ProgressbarEvent (to match with jQueryEvent)


  • Call the second arg as "progressEvent" instead of "ui" or "uiEvent" if you want a generic name for all widgets
  • Potentially define just one jQueryUIEventHandler instead which has a generic argument for the widget-specific event.


  • Same as ProgressbarEvent - used an enum with [NamedValues]


  • File Header ... please make it match the rest of the sources
  • Bracing ... please use K&R style
  • Use of #region - don't
  • Ordering of members - ctors, properties, methods, and alphabetized within each group
  • Naming ... consistency with .net naming patterns... generally this is the case, but for example ProgressBar, AutoComplete etc. have mixed case (also ensure file names match in process).

Most of this is covered in the coding guidelines doc in the repo... I really appreciate the effort to keep the codebase consistent. Thanks!


  • Would be useful to see this (along with notes about how to use it), so it is possible to update the generated code, for future updates, as well easily tweaking the output to match guidelines
  • Is this only usable against jQueryUI, or other jQuery plugins as well including jQueryMobile?


  • I'd like to start with just the wrappers for jQueryUI, rather than the extensive port of samples to c# along, and avoid dependencies like asp.net mvc, web pages, razor etc. needed to build and maintain the source tree.

As mentioned earlier, thanks for taking up the effort to get this functionality together!

igochkov commented Jun 6, 2012

Thanks for the quick response. I am currently working on the changes. I already rewrote the parser which now uses api.jqueryui.com as a source.

  • Generator: Yes it is jQueryUI specific as only jQueryUI team has such a nice and extended XML documentation. However we can format the jQuery.Mobile documentation to what jQuery UI are using and generate it as well.

Where is the right location to include the jQueryUI API Generator in the Script# repository: "scriptsharp/tools" or "scriptsharp/src/Tools"?

  • Samples: I totally understand and I will remove it from the Script# repository. As it is a nice testing platform for the generator I will separate it in other repository under my name and maintain it if that is ok with you.

Note to KarlMaynardDK: Abstraction is always nice. At the beginning I was considering parsing directly javascript as well. The down side is a lot of complexity and inability to generate XML Documentation Comments. I think that the power of those Script# libraries is not only in the provided intelli-sense but also the documentation itself.

nikhilk commented Jun 6, 2012

Generator location - scriptsharp/tools/jQueryUIGenerator

Totally fine with creating a separate repository for samples. Ultimately, I am fine if you think it is better to create a separate repository for the generator all up. This way the samples can sit alongside if they serve as good test cases. I buy that scenario, so that might in fact be ideal. Your decision. My real point was to have it be available such that anyone could use it ...

@nikhilk nikhilk referenced this pull request Jun 6, 2012

jQuery UI Library #129

@nikhilk nikhilk closed this Jul 13, 2012
nikhilk commented Jul 13, 2012

Closing this to make room for the new generated sources to be used instead...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment