Beyond basic DOM manipulation, the WebForms class provides several higher-level methods for handling more advanced browser interface operations. These methods allow developers to preserve and restore DOM states, display modal dialogs, animate elements, and create loading placeholders.

Unlike the basic Add, Set, Insert, and Delete groups, these operations address broader UI behaviors and provide more specialized functionality.

3.1. Snapshot and Rollback

WebForms Core provides Snapshot and Rollback to save and restore the state of a selected DOM element.

The Snapshot method captures the current state of a target element, while Rollback restores the previously captured state. This can be useful when an operation temporarily changes an element and the application needs the ability to return it to an earlier state.

For example, consider an interface where a user edits a section of a page. Before applying the changes, its current state can be captured:

webForms.Snapshot("profile"); 

If the application later needs to restore that state, it can use:

webForms.Rollback("profile"); 

Both methods accept two optional parameters: key and permanent.

The key parameter allows a snapshot to be identified independently of the target expression. If no key is provided, the InputPlace expression is used as the default key. This makes it possible to manage snapshots through an explicit identifier.

The permanent parameter changes the snapshot's persistence behavior:

webForms.Snapshot("profile", "profile-backup", true); 

The same key and persistence setting can be supplied when restoring the snapshot:

webForms.Rollback("profile", "profile-backup", true); 

An important implementation detail is that these operations are intended for a single target element rather than an arbitrary collection of elements. The WebForms Core source also recommends assigning a stable ID to the selected element because the snapshot and rollback mechanism is sensitive to DOM changes.

3.2. Modal Dialogs

The WebForms class includes methods for displaying and closing modal dialogs without requiring developers to implement the entire interaction manually.

The ShowModal method displays a modal using a specified target element. It accepts optional settings for the dialog title, width, and whether the content should be copied.

For example:

webForms.ShowModal("dialog-content", "User Details", 600); 

The width can also be supplied as a string:

webForms.ShowModal("dialog-content", "User Details", "600px"); 

The optional copy parameter can be used to enable the copy setting:

webForms.ShowModal("dialog-content", "User Details", 600, true); 

To close the currently displayed modal, the class provides CloseModal:

webForms.CloseModal(); 

This API offers a straightforward way to control modal presentation from server-side code while leaving the actual browser-side execution to WebFormsJS.

3.3. Animation

WebForms Core also provides an Animate method for applying browser animations to selected elements.

Instead of requiring a separate JavaScript function for every animation, developers can specify the target element, animation keyframes, and optional animation settings.

For example:

webForms.Animate( "notification", "[{ opacity: 0 }, { opacity: 1 }]", "{ duration: 500, iterations: 1 }" ); 

The method accepts the animation keyframes as a string and an optional options string. These values are passed to the client-side execution engine, allowing the animation to be configured from the server-side programming interface.

This approach is useful for adding visual feedback to UI operations, such as displaying notifications, highlighting updated content, or animating the appearance of an element.

3.4. Skeleton Loading

The WebForms class includes a Skeleton feature for displaying loading placeholders while content is being prepared.

Skeletons are useful when an application needs to indicate that content is loading without leaving an empty area in the interface. Instead of displaying a traditional loading message or spinner, the application can show placeholder shapes that represent the expected content layout.

The AddSkeleton method adds a skeleton shape to a target element:

webForms.AddSkeleton("profile", "circle", 60); 

The method supports several predefined shapes:

  • text
  • paragraph
  • square
  • triangle
  • rectangle
  • circle
  • avatar
  • image
  • button
  • space

A width can also be specified:

webForms.AddSkeleton("content", "paragraph", 80); webForms.AddSkeleton("avatar", "circle", 50); webForms.AddSkeleton("banner", "rectangle", 100); 

The width parameter accepts either a string or an integer. If omitted, its default value is 100.

When a skeleton needs to be removed explicitly, the class provides DeleteSkeleton:

webForms.DeleteSkeleton("profile"); 

This allows the application to control the loading placeholder independently of the content that will eventually be displayed.

3.5. Bringing These Operations Together

These methods demonstrate that the WebForms class goes beyond simple element and attribute manipulation. It also provides mechanisms for managing the lifecycle and presentation of interface elements.

For example, an application can capture an element's state before modifying it, display a modal containing additional information, animate the appearance of updated content, and use skeleton placeholders while waiting for data.

The important architectural point is that these operations are still expressed through the server-side WebForms API. The server describes the requested behavior, and WebFormsJS performs the corresponding operations in the browser.

Together, Snapshot, Rollback, Modal, Animation, and Skeleton provide higher-level building blocks for developing interactive interfaces without requiring developers to write custom JavaScript for each individual operation.