Windows 8 Ria Application

Source: Internet
Author: User
Ria call example this example demonstrates how to use accessible RIA to ensure a fully accessible Metro style Application Program . The example shows how to implement the aria tag in a simulated chat software. In the UI and simple functions, you can better focus on the implemented Ria.

(Function(){

"Use strict ";

VaRUi = winjs. UI;

FunctionUpdatelayout (element, layoutstate ){
}

FunctionReady (element, options ){

// Build up the contents of the group list.
VaR Itemsgroup = getitemsgroup ();
VaR Listviewgroup = element. queryselector (". chatlistgroup"). wincontrol;
Ui. setoptions (listviewgroup ,{
Itemdatasource: itemsgroup. datasource,
Itemtemplate: element. queryselector (". itemtemplate "),
Oniteminvoked: iteminvokedgroup,
});

// Build up the contents of the contact list.
VaR Itemscontact = getitemscontact (0 );
VaR Listviewcontact = element. queryselector (". chatlistcontact"). wincontrol;
Ui. setoptions (listviewcontact ,{
Itemdatasource: itemscontact. datasource,
Itemtemplate: element. queryselector (". itemtemplate "),
Oniteminvoked: iteminvokedcontact,
});

// Add a key down event handler to the text input area to react to a press of the Enter key.
VaR Chattextinput = element. queryselector ('. chattextinput ');
Chattextinput. addeventlistener ("keydown ", Function (Eventdata ){
// Has the Enter key been pressed?
If (Eventdata. keycode === winjs. Utilities. Key. Enter ){
VaR Textinput = Document. queryselector ('. chattextinput ');

// Add the text in the text input area immediately to the Chat History area.
VaR Texttoadd = textinput. value;
If (Texttoadd! = ""){
// Clear the text input area.
Chattextinput. value = "";

Addtexttochat ("me:" + texttoadd );

//Start a 3 second timer to have a simulated reply appear later.
SetTimeout (Function() {Chattimerfired () ;}, 3000 );
}
}
});
}

Function Getitemsgroup (){
VaR Colors = ["red", "green", "blue"];
VaR Items = New Winjs. Binding. List ();
For ( VaR I = 1; I <= 3; I ++ ){
Items. Push ({
Key: I,
Title: "group" + I,
Description: "This is group" + I,
Borderall: "2px solid rgba (255,255,255, 1.0 )",
Backgroundcolor: colors [(I-1) % colors. Length],
});
}
Return Items;
}

Function Getitemscontact (INDEX ){
VaR Colors = ["red", "green", "blue"];
VaR Items = New Winjs. Binding. List ();
For ( VaR I = 1; I <= 3; I ++ ){
Items. Push ({
Key: I,
Title: 'Contact '+ I,
Description: 'This is contact' + (index + 1) + '.' + I,
Borderall: "2px solid rgba (255,255,255, 1.0 )",
Backgroundcolor: colors [Index],
});
}
Return Items;
}

FunctionIteminvokedgroup (e ){
VaRLvcontact = Document. queryselector (". chatlistcontact"). wincontrol;
VaRItemscontact = getitemscontact (E. Detail. itemindex );

Ui. setoptions (lvcontact ,{
Itemdatasource: itemscontact. datasource,
Itemtemplate: Document. queryselector (". itemtemplate "),
Oniteminvoked: iteminvokedcontact,
});
}

function iteminvokedcontact (e) {
/// clear the contacts list before navigating away from the page.
var items = New winjs. binding. list ();
var lvcontact = document. queryselector ('. chatlistcontact ');
winjs. UI. setoptions (lvcontact, {
datasource: items. datasource
});

Winjs. Navigation. navigate ("/html/tablepage.html", {item: item });
}

FunctionChattimerfired (){
VaRSendername = "Unknown sender ";
Addtexttochat (sendername + ": This is a sample reply .");
}

FunctionAddtexttochat (texttoadd ){

VaR Textecho = Document. queryselector ('. chattextechocontainer ');
If (Textecho ){
// Add a div element containing the new text being echoed, beneath the element containing all
// Echoed text. This leads to keep Ive technologies wide Ying users immediately of the update due
// To the use of the aria-live and Aria-relevant properties on the chattextechocontainer element.
Textecho. insertadjacenthtml ('beforeend', "<Div class = \" chattextecho \ ">" + texttoadd + "</div> ");
}
}

Ui. pages. Define ("/html/chatpage.html ",{
Ready: Ready,
Updatelayout: updatelayout
});
})();

Complete example:/files/risk/windows8/riaapplication sample.rar

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.