Freigeben über


WinJS.Utilities Namespace

Provides helper functions, for example, functions to add and remove CSS classes.

The WinJS.Utilities namespace has these types of members:

  • Enumerations
  • Objects
  • Functions

Enumerations

Enumeration Description

Key enumeration

Defines a set of keyboard values.

 

Objects

Object Description

eventMixin object

A mixin that contains event-related functions.

QueryCollection object

Represents the result of a query selector, and provides various operations that perform actions over the elements of the collection.

 

Functions

Function Description

addClass function

Adds the specified class to the specified element.

children function

Gets a collection of elements that are the direct children of the specified element.

convertToPixels function

Converts a CSS positioning string for the specified element to pixels.

createEventProperties function

Creates an object that has one event for each name passed to the function.

data function

Gets the data value associated with the specified element.

disposeSubTree function

Disposes all first-generation disposable elements that are descendents of the specified element. The specified element itself is not disposed.

empty function

Removes all the child nodes from the specified element.

eventWithinElement function

Determines whether the specified event occurred within the specified element.

formatLog function

Adds tags and type to a logging message.

getContentHeight function

Gets the height of the content of the specified element. The content height does not include borders or padding.

getContentWidth function

Gets the width of the content of the specified element. The content width does not include borders or padding.

getMember function

Gets the leaf-level type or namespace specified by the name parameter.

getPosition function

Gets the position of the specified element.

getRelativeLeft function

Gets the left coordinate of the specified element relative to the specified parent.

getRelativeTop function

Gets the top coordinate of the element relative to the specified parent.

getTotalHeight function

Gets the height of the element, including its margins.

getTotalWidth function

Gets the width of the element, including margins.

hasClass function

Determines whether the specified element has the specified class.

id function

Returns a collection with zero or one elements matching the specified id.

insertAdjacentHTML function

Calls insertAdjacentHTML on the specified element.

insertAdjacentHTMLUnsafe function

Calls insertAdjacentHTML on the specified element in the context of MSApp.execUnsafeLocalFunction.

markDisposable function

Attaches the default dispose API wrapping the dispose implementation to the specified element.

markSupportedForProcessing function

Marks a function as being compatible with declarative processing. Declarative processing is performed by WinJS.UI.processAll or WinJS.Binding.processAll.

query function

Returns a QueryCollection with zero or one elements matching the specified selector query.

ready function

Ensures that the specified function executes only after the DOMContentLoaded event has fired for the current page. The DOMContentLoaded event occurs after the page has been parsed but before all the resources are loaded.

removeClass function

Removes the specified class from the specified element.

requireSupportedForProcessing method

Asserts that the value is compatible with declarative processing. Declarative processing is performed by WinJS.UI.processAll or WinJS.Binding.processAll. If the value is not compatible, and strictProcessing is on, an exception is thrown.

All functions that have been declared using WinJS.Class.define, WinJS.Class.derive, WinJS.UI.Pages.define, or WinJS.Binding.converter are automatically marked as supported for declarative processing. Any other function that you use from a declarative context (that is, a context in which an HTML element has a data-win-control or data-win-options attribute) must be marked manually by calling this function. When you mark a function as supported for declarative processing, you are guaranteeing that the code in the function is secure from injection of third-party content.

setInnerHTML function

Sets the innerHTML property of the specified element to the specified text.

setInnerHTMLUnsafe function

Sets the innerHTML property of the specified element to the specified text.

setOuterHTML function

Sets the outerHTML property of the specified element to the specified text.

setOuterHTMLUnsafe function

Sets the outerHTML property of the specified element to the specified text in the context of MSApp.execUnsafeLocalFunction.

startLog function

Configures a logger that writes messages containing the specified tags to the JavaScript console.

stopLog function

Removes the WinJS logger that had previously been set up.

toggleClass function

Toggles (adds or removes) the specified class on the specified element. If the class is present, it is removed; if it is absent, it is added.

 

Requirements

Minimum WinJS version

WinJS 1.0

Namespace

WinJS.Utilities