Merge branch 'master' into tizen_2.1
[platform/framework/web/web-ui-fw.git] / demos / tizen-winsets / widgets / popupwindow / popupwindow.js
1 $( document ).one( "pageinit", "#popupwindow-demo", function () {
2         $("#btn_textbox_popup_cancel").on("vclick", function ( ev ) {
3                 $("#textbox_popup").find("input").val("");
4                 $("#textbox_popup").popup("close");
5                 return false;
6         });
7
8        if ( $.tizen.__tizen__.util.isMobileBrowser() ) {
9                 var direction = window.screen.orientation;
10                 if ( direction === "landscape-primary" || direction === "landscape-secondary" ) {
11                         $( "#go_textbox_popup a" ).attr( "href", "#textbox_popup_landscape" );
12                 }
13         }
14 });
15
16 function onSuccessPopupCallback ( ori ) {
17         if ( ori.status === "PORTRAIT_PRIMARY" || ori.status === "PORTRAIT_SECONDARY" ) {
18                 if( $( "#textbox_popup_landscape" ).parents( ".ui-popup-container" ).is( ".ui-popup-active" ) ) {
19                         $( "#textbox_popup_landscape" ).popup( "close" );
20                 }
21                 $( "#go_textbox_popup a" ).attr( "href", "#textbox_popup" );
22         }
23         else if ( ori.status === "LANDSCAPE_PRIMARY" || ori.status === "LANDSCAPE_SECONDARY" ) {
24                 if( $( "#textbox_popup" ).parents( ".ui-popup-container" ).is( ".ui-popup-active" ) ) {
25                         $( "#textbox_popup" ).popup( "close" );
26                 }
27                 $( "#go_textbox_popup a" ).attr( "href", "#textbox_popup_landscape" );
28         }
29 }
30
31 function onErrorPopupCallback ( error ) {
32         console.error( "An error occurred " + error.message );
33 }
34
35 if ( $.tizen.__tizen__.util.isMobileBrowser() ) {
36         tizen.systeminfo.addPropertyValueChangeListener( "DEVICE_ORIENTATION", onSuccessPopupCallback, onErrorPopupCallback );
37 }
38