// Copyright (c) Microsoft Corporation. All Rights Reserved. Licensed under the MIT License. See License.txt in the project root for license information.
// IListDataSource functions and objects that are declared only for documentation purposes
(function () {
// Items
///
/// Object representing an item. Note that additional domain-specific properties may be present in addition to the
/// ones listed here.
///
var IItem = WinJS.Class.define(function () {
}, {
// Public properties
///
/// The item's unique and invariant key
///
key: {
get: function () { }
},
///
/// The item's data
///
data: {
get: function () { }
},
///
/// The unique handle assigned to the item
///
handle: {
get: function () { }
},
///
/// The item's index, if known
///
index: {
get: function () { }
}
}
);
// List Binding
///
/// A Promise for an Item. In addition to the normal Promise properties, has the Item-specific properties listed here.
///
var IItemPromise = WinJS.Class.derive(Promise, function () {
}, {
// Public properties
///
/// The unique handle assigned to the item
///
handle: {
get: function () { }
},
///
/// The item's index, if known
///
index: {
get: function () { }
},
retain: function () {
///
/// Requests that notifications be sent for the item until it is released. The item is only released when
/// the number of release calls matches the number of retain calls. This method is only present if an
/// IListNotificationHandler was passed to IListDataSource.createListBinding when the IListBinding that
/// returned this IItemPromise was created.
///
},
release: function () {
///
/// Requests that notifications no longer be sent for the item. The item is only released when the number
/// of release calls matches the number of retain calls. The number of release calls must not exceed the
/// number of retain calls. This method is only present if an IListNotificationHandler was passed to
/// IListDataSource.createListBinding when the IListBinding that returned this IItemPromise was created.
///
}
}
);
///
/// Interface to be implemented by client of IListBinding, to receive change notifications
///
var IListNotificationHandler = WinJS.Class.define(function () {
}, {
// Public properties
reload: function () {
///
/// Called when the list data has changed so much that individual notifications will not be sent. The
/// client must abandon its current items (they do not need to be released) and re-request the items it
/// needs.
///
},
beginNotifications: function () {
///
/// Notification that a sequence of other notification calls is about to begin. The sequence will be
/// concluded with a call to endNotifications, and such pairs of calls will not be nested.
///
},
inserted: function (itemPromise, previousHandle, nextHandle) {
///
/// Called when an item has been inserted
///
///
/// An object that implements the IItemPromise interface, serving as a promise for the inserted item
///
///
/// The handle of the item before the insertion point, or null if the item was inserted at the start of the
/// list
///
///
/// The handle of the item after the insertion point, null if the item was inserted at the end of the list
///
},
changed: function (newItem, oldItem) {
///
/// Called when an item has changed
///
///
/// The new version of the item
///
///
/// The old version of the item - with some data adapters, this may be the same object as newItem
///
},
moved: function (itemPromise, previousHandle, nextHandle) {
///
/// Called when an item has been moved to a new position
///
///
/// An object that implements the IItemPromise interface, serving as a promise for the item that has moved
///
///
/// The handle of the item before the insertion point, or null if the item was moved to the start of the
/// list
///
///
/// The handle of the item after the insertion point, null if the item was moved to the end of the list
///
},
removed: function (handle, mirage, existingHandle) {
///
/// Called when an item has been removed
///
///
/// The handle of the item that has been removed
///
///
/// Whether the item was a mirage, i.e. never existed in the first place. This can only happen if an item
/// promise has not yet completed, and may be due to the item not existing in the list, or two item
/// requests resolving to the same underlying item in the data, in which case one of the requested "items"
/// is deleted as a mirage.
///
///
/// If the item was a mirage due to the request resolving to an item that has already been obtained by
/// other means, the handle of the latter item.
///
},
countChanged: function (newCount, oldCount) {
///
/// Called when the total count of items has changed
///
///
/// The new count of items. May be CountResult.unknown.
///
///
/// The old count of items. May be CountResult.unknown.
///
},
indexChanged: function (handle, newIndex, oldIndex) {
///
/// Called when the index of an item has changed
///
///
/// The handle of the item of which the index has changed.
///
///
/// The new index of the item
///
///
/// The old index of the item
///
},
///
/// Notification that a sequence of other notification calls has concluded.
///
endNotifications: function () {
}
}
);
// List Data
///
/// Expected properties on fetch result object returned from ListDataAdapter fetch methods
///
var IFetchResult = WinJS.Class.define(function () {
}, {
// Public properties
///
/// An array of items, each having at least key and data properties
///
items: {
get: function () { }
},
///
/// The local index of the requested item within the items array
///
offset: {
get: function () { }
},
///
/// The total number of items in the list, if known
///
totalCount: {
get: function () { }
},
///
/// The absolute index of the requested item, if known
///
absoluteIndex: {
get: function () { }
},
///
/// If absoluteIndex is not supplied, this must be true when the first item in the items array is the first item
/// in the list.
///
atStart: {
get: function () { }
},
///
/// If absoluteIndex and totalCount are not both supplied, this must be true when the last item in the items \
/// is the last item in the list.
///
atEnd: {
get: function () { }
}
}
);
///
/// Interface to be implemented by a data adapter object, to enable access to a custom data source via an object
/// derived from VirtualizedDataSource. Many properties in IListDataAdapter are optional, but some of
/// VirtualizedDataSource's functionality may be disabled, depending on what is implemented.
///
var IListDataAdapter = WinJS.Class.define(function () {
}, {
// Public properties
setNotificationHandler: function (notificationHandler) {
///
/// OPTIONAL
/// Sets the data notification handler object to call when data has changed
///
///
/// A data notification handler object that the data adapter can call to notify the VirtualizedDataSource
/// when the list data has changed. Data adapters may provide precise notifications for all changes to the
/// data, coarse notifications to inform the VirtualizedDataSource only that something has changed, or no
/// notifications at all. In the latter case, the application should periodically call invalidateAll on
/// the VirtualizedDataSource to refresh the data.
///
},
///
/// If true, indicates to the VirtualizedDataSource that only the identity of the data properties should be
/// compared. By default, data properties are stringified to JSON and compared by value.
///
compareByIdentity: {
get: function () { }
},
itemSignature: function (data) {
///
/// OPTIONAL
/// Generates a signature for an item's data that is guaranteed to change if the data changes in any way
///
///
/// The data property of the item
///
///
/// A signature for the item's data that is guaranteed to change if the data changes in any way
///
},
itemsFromStart: function (count) {
///
/// OPTIONAL
/// Fetches the first items in the list
///
///
/// The requested number of items. It is acceptable to return less or more than this number, but at least
/// one item should be returned, unless the list is empty.
///
///
/// If successful, the promise should complete with an IFetchResult value. Otherwise, it should fail with
/// a FetchError error result, in a reasonable amount of time.
///
},
itemsFromEnd: function (count) {
///
/// OPTIONAL
/// Fetches the last items in the list
///
///
/// The requested number of items. It is acceptable to return less or more than this number, but at least
/// one item should be returned, unless the list is empty.
///
///
/// If successful, the promise should complete with an IFetchResult value. Otherwise, it should fail with
/// a FetchError error result, in a reasonable amount of time.
///
},
itemsFromKey: function (key, countBefore, countAfter) {
///
/// OPTIONAL
/// At least one of itemsFromKey and itemsFromIndex must be implemented.
///
/// Fetches the item with the given key, and surrounding items in the list
///
///
/// The key of the requested item
///
///
/// The requested number of additional items before the item with the given key. It is acceptable to
/// return less or more than this number, but if countBefore is non-zero, at least one item before the
/// requested item should be returned, if such an item exists.
///
///
/// The requested number of additional items after the item with the given key. It is acceptable to return
/// less or more than this number, but if countAfter is non-zero, at least one item after the requested
/// item should be returned, if such an item exists.
///
///
/// If successful, the promise should complete with an IFetchResult value. Otherwise, it should fail with
/// a FetchError error result, in a reasonable amount of time.
///
},
itemsFromIndex: function (index, countBefore, countAfter) {
///
/// OPTIONAL
/// At least one of itemsFromKey and itemsFromIndex must be implemented.
///
/// Fetches the item with the given index, and surrounding items in the list
///
///
/// The index of the requested item
///
///
/// The requested number of additional items before the item with the given index. It is acceptable to
/// return less or more than this number.
///
///
/// The requested number of additional items after the item with the given index. It is acceptable to
/// return less or more than this number.
///
///
/// If successful, the promise should complete with an IFetchResult value. Otherwise, it should fail with
/// a FetchError error result, in a reasonable amount of time.
///
},
itemsFromDescription: function (description, countBefore, countAfter) {
///
/// OPTIONAL
/// Fetches the first item with a description matching or after the given one, as interpreted by the data
/// adapter, and surrounding items in the list
///
///
/// The description of the requested item, to be interpreted by the data adapter
///
///
/// The requested number of additional items before the requested item. It is acceptable to return less or
/// more than this number.
///
///
/// The requested number of additional items after the requested item. It is acceptable to return less or
/// more than this number.
///
///
/// If successful, the promise should complete with an IFetchResult value. Otherwise, it should fail with
/// a FetchError error result, in a reasonable amount of time.
///
},
getCount: function () {
///
/// OPTIONAL
/// Fetches the total number of items
///
///
/// If successful, the promise should complete with an integer value or CountResult.unknown. Otherwise, it
/// should fail with a CountError error result, in a reasonable amount of time.
///
},
beginEdits: function () {
///
/// OPTIONAL
/// Notifies the data adapter that a sequence of edits is about to begin. The VirtualizedDataSource will
/// call beginEdits and beginEdits once each for a sequence of edits.
///
},
insertAtStart: function (key, data) {
///
/// OPTIONAL
/// Inserts an item at the start of the list
///
///
/// The key of the item to insert, if known
///
///
/// The data of the item to insert
///
///
/// If successful, the promise should complete with an item object, having at least key and data
/// properties, or no value if the inserted item's only properties are the key and data passed in.
/// Otherwise, it should fail with an EditError error result, in a reasonable amount of time.
///
},
insertBefore: function (key, data, nextKey, nextIndexHint) {
///
/// OPTIONAL
/// Inserts an item before a given item in the list
///
///
/// The key of the item to insert, if known
///
///
/// The data of the item to insert
///
///
/// The key of the item immediately after the insertion point
///
///
/// The most recent index, if any, observed by the VirtualizedDataSource of the item identified by nextKey
///
///
/// If successful, the promise should complete with an item object, having at least key and data
/// properties, or no value if the inserted item's only properties are the key and data passed in.
/// Otherwise, it should fail with an EditError error result, in a reasonable amount of time.
///
},
insertAfter: function (key, data, previousKey, previousIndexHint) {
///
/// OPTIONAL
/// Inserts an item after a given item in the list
///
///
/// The key of the item to insert, if known
///
///
/// The data of the item to insert
///
///
/// The key of the item immediately before the insertion point
///
///
/// The most recent index, if any, observed by the VirtualizedDataSource of the item identified by
/// previousKey
///
///
/// If successful, the promise should complete with an item object, having at least key and data
/// properties, or no value if the inserted item's only properties are the key and data passed in.
/// Otherwise, it should fail with an EditError error result, in a reasonable amount of time.
///
},
insertAtEnd: function (key, data) {
///
/// OPTIONAL
/// Inserts an item at the end of the list
///
///
/// The key of the item to insert, if known
///
///
/// The data of the item to insert
///
///
/// If successful, the promise should complete with an item object, having at least key and data
/// properties, or no value if the inserted item's only properties are the key and data passed in.
/// Otherwise, it should fail with an EditError error result, in a reasonable amount of time.
///
},
change: function (key, newData, indexHint) {
///
/// OPTIONAL
/// Changes the data of an item
///
///
/// The item's key
///
///
/// The item's new data
///
///
/// If successful, the promise should complete with an item object, having at least key and data
/// properties, or no value if the only property that has changed on the item is its data. Otherwise, it
/// should fail with an EditError error result, in a reasonable amount of time.
///
},
moveToStart: function (key, indexHint) {
///
/// OPTIONAL
/// Moves an item to the start of the list
///
///
/// The key of the item to move
///
///
/// The most recent index, if any, observed by the VirtualizedDataSource of the item identified by key
///
///
/// If successful, the promise should complete with an item object, having at least key and data
/// properties, or no value if no properties on the item have changed as a result of the move. Otherwise,
/// it should fail with an EditError error result, in a reasonable amount of time.
///
},
moveBefore: function (key, nextKey, indexHint, nextIndexHint) {
///
/// OPTIONAL
/// Moves an item before a given item
///
///
/// The key of the item to move
///
///
/// The key of the item immediately after the insertion point
///
///
/// The most recent index, if any, observed by the VirtualizedDataSource of the item identified by key
///
///
/// The most recent index, if any, observed by the VirtualizedDataSource of the item identified by nextKey
///
///
/// If successful, the promise should complete with an item object, having at least key and data
/// properties, or no value if no properties on the item have changed as a result of the move. Otherwise,
/// it should fail with an EditError error result, in a reasonable amount of time.
///
},
moveAfter: function (key, previousKey, indexHint, previousIndexHint) {
///
/// OPTIONAL
/// Moves an item after a given item
///
///
/// The key of the item to move
///
///
/// The key of the item immediately after the insertion point
///
///
/// The most recent index, if any, observed by the VirtualizedDataSource of the item identified by key
///
///
/// The most recent index, if any, observed by the VirtualizedDataSource of the item identified by
/// previousKey
///
///
/// If successful, the promise should complete with an item object, having at least key and data
/// properties, or no value if no properties on the item have changed as a result of the move. Otherwise,
/// it should fail with an EditError error result, in a reasonable amount of time.
///
},
moveToEnd: function (key, indexHint) {
///
/// OPTIONAL
/// Moves an item to the end of the list
///
///
/// The key of the item to move
///
///
/// The most recent index, if any, observed by the VirtualizedDataSource of the item identified by key
///
///
/// If successful, the promise should complete with an item object, having at least key and data
/// properties, or no value if no properties on the item have changed as a result of the move. Otherwise,
/// it should fail with an EditError error result, in a reasonable amount of time.
///
},
remove: function (key, indexHint) {
///
/// OPTIONAL
/// Removes an item
///
///
/// The item's key
///
///
/// The most recent index, if any, observed by the VirtualizedDataSource of the item identified by key
///
///
/// If successful, the promise should complete without a value. Otherwise, it should fail with an
/// EditError error result, in a reasonable amount of time.
///
},
endEdits: function () {
///
/// OPTIONAL
/// Notifies the data adapter that a sequence of edits has ended. The VirtualizedDataSource will call
/// beginEdits and beginEdits once each for a sequence of edits.
///
}
}
);
// Grouping
function groupKeyCallback(item) {
///
/// Expected function signature of the groupKey parameter passed to WinJS.UI.computeDataSourceGroups
///
///
/// Individual item to be assigned to a group
///
///
/// The key of the group to which the item belongs
///
}
function groupDataCallback(item) {
///
/// Expected function signature of the groupData parameter passed to WinJS.UI.computeDataSourceGroups
///
///
/// Individual item to be assigned to a group
///
///
/// The data of the group to which the item belongs
///
}
// Templates
function itemTemplateCallback(itemPromise, recycledElement) {
///
/// Expected function signature of an item template
///
///
/// Promise for the item for which a DOM tree is to be generated
///
///
/// Output, that is no longer needed, of an earlier call to the template that is no longer needed. May be used as
/// a starting point for this template's output.
///
///
/// An object with two properties, "element" and "renderComplete". "element" may be a DOM element or a Promise for
/// a DOM element. "renderComplete", if present must be a Promise that completes when the template has finished its
/// work. Alternately, a DOM element may be returned.
///
}
///
/// Object passed to itemTemplateCallback (i.e. as the result when the given itemPromise completes) representing the
/// item for which a DOM tree should be generated. Note that additional domain-specific properties may be present in
/// addition to the ones listed here.
///
var ITemplateItem = WinJS.Class.define(function () {
}, {
// Public properties
///
/// The item's unique and invariant key
///
key: {
get: function () { }
},
///
/// The item's data
///
data: {
get: function () { }
},
///
/// The unique handle assigned to the item
///
handle: {
get: function () { }
},
///
/// The item's index, if known
///
index: {
get: function () { }
},
///
/// A promise that completes when the control is ready for the renderer to do any more-time-consuming work (for
/// example, instantiating child controls)
///
ready: {
get: function () { }
},
isOnScreen: function () {
///
/// Determines whether this item is currently visible in the control viewport
///
///
/// A promise for a Boolean specifying whether this item is currently visible in the control viewport
///
},
loadImage: function (srcUrl, image) {
///
/// Sets the src attribute of an img tag when the control deems it appropriate
///
///
/// The URL to use for the img src attribute
///
///
/// The img element; if absent, one will be created
///
///
/// A promise that completes when the image data has been loaded
///
},
isImageCached: function (srcUrl) {
///
/// Determines whether a given image is locally cached
///
///
/// The URL of the image
///
///
/// Whether the image data for the given URL is locally cached
///
}
}
);
}); // Don't run this