The fifth revision of the HyperText Markup Language, named “HTML5,” is formally defined by an international standards body known as the World Wide Web Consortium (“W3C”). HTML5 includes more than 100 specifications that relate to the next generation of Web technologies. HTML5 describes a set of HTML, CSS (Cascading Style Sheets), and JavaScript specifications configured to enable designers and developers to build the next generation of web sites and applications. While such technologies perform satisfactorily in many usage scenarios, opportunities still exist for enhanced and richer web application development experiences to be implemented.
This Background is provided to introduce a brief context for the Summary and Detailed Description that follow. This Background is not intended to be an aid in determining the scope of the claimed subject matter nor be viewed as limiting the claimed subject matter to implementations that solve any or all of the disadvantages or problems presented above.
A user interface (“UI”) control framework enables UI controls to be declaratively created inline with the HTML markup without having to write boilerplate JavaScript that would usually be needed with conventional UI control models. In one particular illustrative embodiment, the UI control framework is architected to sit on top of existing WinJS (Windows Library for JavaScript) functionality and encapsulates behaviors that are common across many control implementations so that a single instance of a UI control template may be used to stamp out multiple control instances. The UI control framework separates layout from the “code behind” in the backing controls so that data binding can be implemented abstractly without explicit knowledge of the layout of the control and any of its child controls. The markup provides “anchor points” that allow the code to have direct access to a child control. Custom expando HTML attributes are utilized that place named properties on control instances.
Advantageously, the loose coupling between the layout and backing controls allows UI controls to be readily created by web application designers who tend to be specialists in HTML and CSS but who may not be as conversant in JavaScript coding as programmers/developers. The framework supports declarative creation of UI controls without the designer having to touch the backing control code. The framework and its declarative templates are further inherently flexible so that designers can make large scale changes to control layout so long as the anchor points remain named the same without triggering a need to update code in the backing controls. Such flexibility provides powerful tools for application designers to produce rich user experiences while also reducing expenses associated with code maintenance.
This Summary is provided to introduce a selection of concepts in a simplified form that are further described below in the Detailed Description. This Summary is not intended to identify key features or essential features of the claimed subject matter, nor is it intended to be used as an aid in determining the scope of the claimed subject matter.
Like reference numerals describe like elements in the drawings.
While not a required functionality to implement the present UI control framework, the computing devices 110 may often have some form of network connectivity feature, either directly or through an intermediary device (e.g., an Internet-connected personal computer), as well as a web browser or application or embedded features that provide similar functionality which operates on the device and supports user interactivity through a display and input device such as a touchscreen, keypad, pointing device, and the like. As shown in
A web application designer 135 works with the provider 115 to design next generation web technologies including applications and websites that leverage the capabilities of HTML5. A programmer 140 also works with the provider. In this illustrative example, the designer is typically familiar with, and uses HTML and CSS and does not necessarily have the same high level of expertise in coding as the programmer.
As shown in
With traditional development models, designers may need to touch code when creating or modifying an application feature which can often be problematic given the designer's more limited code expertise. The tight coupling between code and layout can also give rise to a need to generate relatively large amounts of boilerplate code for each UI control.
As shown in this example, even with a relatively simple control, there is a large amount of boilerplate code where such code will typically need to be repeated for virtually every UI control. This situation can lead to the programmer (e.g., programmer 140 in
Unlike the tight coupling in traditional UI control models, the UI control layout 505 is loosely coupled to the code behind 510 in the present UI control framework, as shown in
Data for a UI control, such as a property or value, is not directly managed by a control in the layout. Instead, the data is requested through declarative specification in the layout to loosely source the data from the backing control.
A namespace and a default control class are defined in WinJS as shown in the code segment 905 shown in
The function parameters are shown in Table 1 below:
It is noted that it is possible to derive from an existing control. The common usage in this case would be to employ a different template for the same control behavior. Such usage is similar to the control implementation in Windows Presentation Foundation (“WPF”).
A control base class implements the WinJS contract (e.g., setOptions, setElement, and function (element, options) constructor function), while providing optional customization for designers and programmers extending this class. The control base class supports various functions as shown in Table 2 below:
There may be occasions when a control author needs to perform work when the author's control is removed from the UI, for example to either free resources, or persist state. To enable this, if a control is removed from the HTML DOM (Document Object Model), then a method called ‘unload’ is called on the control instance. This allows the author to do the work at the right time.
When a template is loaded, it is encapsulated so that the loading of the markup and CSS that implement a UI control is transparent to the control consumer (e.g., the designer 135). To enable this transparency, the control definition will have a URI (Uniform Resource Identifier) that represents both the file, and the identifier within that file for the template. An illustrative example is: “SimpleControls.html#EditBox” as shown in Table 3 below.
It could be possible to utilize the HTML id attribute to identify the specific template, but there are some issues around uniqueness when merged with the parent document. To resolve this, a custom HTML expando attribute ‘data-ent-templateid’is utilized which is set to a value unique within an HTML document. The combination of file path and id may be used to identify the template globally.
Given the one-to-many relationship of control layout files to templates, the loading of a specific file (fragment) into the DOM for access to the templates needs to be transparent to the control consumer. WinJS has a rich and full featured fragment loading mechanism which can be leveraged by the present UI control framework. This allows fragments to be loaded into the document, and they reside in the document until explicitly unloaded. Subsequent calls to load the same fragment will thus be completed immediately. This implicit caching thus manages the fragments as they are loaded. In addition the instantiated WinJS.Binding.Template instances are cached so they do not need be fetched every time a control is rendered.
The CSS and scripts that are included in the source HTML file are merged, without duplication into the parent document. WinJS provides the ability to ‘unload’ the fragment, which will remove and unload the content. Templates will use the WinJS.Binding.Template( ) function (which conforms to the control contract) in WinJS to perform the actual template hydration for the control, and data binding. Thus, both fragment loading, and template hydration will be handled seamlessly for the control author.
In addition to the core functionality of the UI control framework described above, a number of custom HTML expando attributes may be utilized that provide for additional control behaviors. One particular issue addressed by the attributes is that for a given control's DOM tree, it may need access to specific HTML elements—either directly or through the control represented by that element. An illustrative DOM tree 1310 is shown in
To address this access issue, a template is allowed to be authored where an expando attribute named ‘data-ent-member’ is placed on certain elements. This attribute is interpreted to place the instance of the element it is placed on as a member on the control instance. If the element represents a control, then instead of the element, the control instance is placed in that member. An example is shown in the HTML fragment 1405 shown in
Given the complexity of a typical DOM tree, and the goal to decouple the layout (i.e., HTML, CSS) from the code implementation as much as possible, events are attached declaratively rather than using code and implementing an event listener. While the ‘data-ent-member’ attribute allows the constituent parts of the template to move and maintain low impact on the code, it still requires calls to the event listener, defined functions, etc. Additionally, the ‘this’ pointer points to the element raising the event not the control itself. This typically means developers are using ‘liar that’, or doing .bind(this) throughout their code. To avoid developers having to concern themselves with such formalities and write the event handlers just like any other function, the expando attribute ‘data-ent-event’ is utilized as shown in the HTML fragment 1505 in
All the handler methods will be found on the control instance and will have their ‘this’ pointer set to the control instance. When called, they will pass the standard parameters passed to any DOM Event handler.
An additional need is to abstract away certain operations in an application—for example, playing a video, purchasing a track, etc.—to hide the complexity of the operation from the control consumer. To resolve this, a concept called ‘actions’ is created. This concept provides a simple contract for the states of invocation, enabled (e.g. has a valid selection), and available (cannot ever happen based on machine configuration, or market requirements).
While the present UI control framework does not handle the actual invocation of the functionality itself (as it is up to the control to determine the best interaction) the infrastructure of getting an action, handling availability, and making it available to a control is part of the control framework. Accordingly, the expando attribute ‘data-ent-action’ is utilized as shown in the HTML fragment 1605 in
Animations are often utilized to produce a compelling set of experiences for users. To enable a consistent, compelling experience, rather than simply elements appearing on the screen as jarring visual flashes, an objective of the present UI control framework is to have controls reveal themselves. Rather than have the controls manage this individually on a case by case basis, the expando attributes of ‘data-ent-showanimation’ and ‘data-ent-hideanimation’ may be used to declare CSS animations that are played on a given element when it is respectively shown and/or hidden. It should be noted that ‘shown’ takes into account the possibility that the element may believe itself to be visible, but because of the visibility of parent elements may not actually be visible. This means that these animations should only be played when the element actually becomes visible, when taking into account the tree it resides in. Additionally, as well as having these animations play automatically when being shown or hidden, there needs to be a way to explicitly start them. Primarily this will revolve around functions intended as drop in replacements for the known [remove|insert|append] Child functions from the DOM. A full set of functions and corresponding descriptions are shown in Table 6 below.
An illustrative example of animation handling is shown in the HTML fragment 1705 in
The system memory 1811 includes read only memory (“ROM”) 1817 and random access memory (“RAM”) 1821. A basic input/output system (“BIOS”) 1825, containing the basic routines that help to transfer information between elements within the computer system 1800, such as during start up, is stored in ROM 1817. The computer system 1800 may further include a hard disk drive 1828 for reading from and writing to an internally disposed hard disk (not shown), a magnetic disk drive 1830 for reading from or writing to a removable magnetic disk 1833 (e.g., a floppy disk), and an optical disk drive 1838 for reading from or writing to a removable optical disc 1843 such as a CD (compact disc), DVD (digital versatile disc), or other optical media. The hard disk drive 1828, magnetic disk drive 1830, and optical disk drive 1838 are connected to the system bus 1814 by a hard disk drive interface 1846, a magnetic disk drive interface 1849, and an optical drive interface 1852, respectively.
The drives and their associated computer-readable storage media provide non-volatile storage of computer readable instructions, data structures, program modules, and other data for the computer system 1800. Although this illustrative example shows a hard disk, a removable magnetic disk 1833, and a removable optical disk 1843, other types of computer-readable storage media which can store data that is accessible by a computer such as magnetic cassettes, flash memory cards, digital video disks, data cartridges, RAMs, ROMs, and the like may also be used in some applications of the present UI control framework. In addition, as used herein, the term computer readable medium includes one or more instances of a media type (e.g., one or more magnetic disks, one or more CDs, etc.).
A number of program modules may be stored on the hard disk, magnetic disk 1833, optical disk 1843, ROM 1817, or RAM 1821, including an operating system 1855, one or more application programs 1857, other program modules 1860, and program data 1863. A user may enter commands and information into the computer system 1800 through input devices such as a keyboard 1866 and pointing device 1868 such as a mouse, or via voice using a natural user interface (“NUI”) (not shown in
Other input devices (not shown) may include a microphone, joystick, game pad, satellite disk, scanner, or the like. These and other input devices are often connected to the processor 1805 through a serial port interface 1871 that is coupled to the system bus 1814, but may be connected by other interfaces, such as a parallel port, game port, or universal serial bus (“USB”). A monitor 1873 or other type of display device is also connected to the system bus 1814 via an interface, such as a video adapter 1875.
In addition to the monitor 1873, personal computers typically include other peripheral output devices (not shown), such as speakers and printers. The illustrative example shown in
The computer system 1800 is operable in a networked environment using logical connections to one or more remote computers, such as a remote computer 1888. The remote computer 1888 may be selected as another personal computer, a server, a router, a network PC, a peer device, or other common network node, and typically includes many or all of the elements described above relative to the computer system 1800, although only a single representative remote memory/storage device 1890 is shown in
The logical connections depicted in
When used in a LAN networking environment, the computer system 1800 is connected to the local area network 1893 through a network interface or adapter 1896. When used in a WAN networking environment, the computer system 1800 typically includes a broadband modem 1898, network gateway, or other means for establishing communications over the wide area network 1895, such as the Internet. The broadband modem 1898, which may be internal or external, is connected to the system bus 1814 via the serial port interface 1871.
In a networked environment, program modules related to the computer system 1800, or portions thereof, may be stored in the remote memory storage device 1890. It is noted that the network connections shown in
Although the subject matter has been described in language specific to structural features and/or methodological acts, it is to be understood that the subject matter defined in the appended claims is not necessarily limited to the specific features or acts described above. Rather, the specific features and acts described above are disclosed as example forms of implementing the claims.