Export 0.1.45
[framework/web/web-ui-fw.git] / demos / tizen-winsets / main.js
1 $( document ).bind("pagecreate", function () {
2         /* Color widget demo */
3         $("input[type='checkbox'][data-widget-type-list]").bind("change", function() {
4                 var ls = $( this ).attr("data-widget-type-list").split(","),
5                         page = $( this ).closest(":jqmData(role='page')"),
6                         disabled = $( this ).is(":checked");
7
8                 $.each(ls, function( idx, widgetType ) {
9                         var ar = widgetType.split("-");
10
11                         if ( ar.length === 2 ) {
12                                 page.find(":" + widgetType)[ar[1]]( "option", "disabled", disabled );
13                         }
14                 });
15         });
16         
17         $("#checkHideInput").bind("change", function (e) {
18         $("#colorpickerbutton").colorpickerbutton("option", "hideInput", $("#checkHideInput").is(":checked"));
19     }); 
20
21         $('#scroller-demo').bind('pageshow', function ( e ) {
22                 $page = $( e.target );
23                 /*
24                  * many options cannot be set without subclassing since they're
25                  * used in the _create method - it seems as if these are for
26                  * internal use only and scrollDuration is only changable by
27                  * chance.
28                  */
29                 var $scroller2List = $('#scroller2').find('ul');
30                 $scroller2List.scrollview( 'option','scrollDuration','10000' );
31
32                 // only works by manipulating css
33                 // the only other way is to use attribute 'scroll-method="scroll"' in html
34                 $('#scroller2 .ui-scrollbar').css( 'visibility','hidden' );
35
36                 /*
37                  * make toggle button switch scroll bars on and off
38                  */
39                 var scrollBarVisible = $('#scroller2').find('.ui-scrollbar').css('visibility') === "visible";
40
41                 var $toggleScrollBars = $('#toggleScrollBars');
42                 $toggleScrollBars.attr( "checked", scrollBarVisible ).checkboxradio("refresh");
43
44                 /* the 'label' is the thing that is clicked, not the input element */
45                 var $label = $toggleScrollBars.siblings('label').attr( 'for', '#toggleScrollBars' );
46                 $label.bind("click", function () {
47                         var $scrollBar = $('#scroller2').find('.ui-scrollbar');
48                         var scrollBarVisible = $scrollBar.css('visibility') === "visible";
49                         var newVisibility = scrollBarVisible ? "hidden" : "visible";
50                         $scrollBar.css( 'visibility', scrollBarVisible ? "hidden" : "visible" );
51                 });
52         });
53
54         $("#demo-date").bind("date-changed", function ( e, newDate ) {
55                 $("#selected-date1").text( newDate.toString() );
56         });
57
58         $("#demo-date2").bind("date-changed", function ( e, newDate ) {
59                 $("#selected-date2").text( newDate.toString() );
60         });
61
62         $("#demo-date3").bind("date-changed", function ( e, newDate ) {
63                 $("#selected-date3").text( newDate.toString() );
64         });
65
66         $("#demo-date4").bind("date-changed", function ( e, newDate ) {
67                 $("#selected-date4").text( newDate.toString() );
68         });
69
70         $('#noti-demo').bind('vmouseup', function ( e ) {
71                 $('#notification').notification('open');
72         });
73
74         $('#noti-icon1').bind('vclick', function ( e ) {
75                 $('#notification').notification('icon', './test/icon02.png');
76         });
77
78         $('#noti-icon2').bind('vclick', function ( e ) {
79                 $('#notification').notification('icon', './test/icon01.png');
80         });
81
82         $('#imageslider-add').bind('vmouseup', function ( e ) {
83                 $('#imageslider').imageslider('add', './test/10.jpg');
84                 $('#imageslider').imageslider('add', './test/11.jpg');
85                 $('#imageslider').imageslider('refresh');
86         });
87
88         $('#imageslider-del').bind('vmouseup', function ( e ) {
89                 $('#imageslider').imageslider('delete');
90         });
91
92         $('#selectioninfo-demo').bind('vmouseup', function ( e ) {
93                 $('#smallpopup_selectioninfo').notification( "text",
94                         $("#dayselector1").find(".ui-checkbox-on").length + " items are selected" );
95                 $('#smallpopup_selectioninfo').notification('open');
96         });
97
98         $('#groupindex-demo').bind('pageshow', function () {
99                 $('#groupindex').scrolllistview();
100         });
101
102         $("#showVolumeButton").bind("vclick", function ( e ) {
103                 $("#myVolumeControl").volumecontrol("open");
104         });
105
106         $("#volumecontrol_setBasicTone").bind("change", function ( e ) {
107                 var basicTone = !($("#volumecontrol_setBasicTone").next('label')
108                                 .find(".ui-icon").hasClass("ui-icon-checkbox-on"));
109
110                 if ( basicTone ) {
111                         $("#myVolumeControl").volumecontrol( "option", "basicTone", true );
112                         $("#myVolumeControl").volumecontrol( "option", "title", "Basic Tone" );
113                 } else {
114                         $("#myVolumeControl").volumecontrol( "option", "basicTone", false );
115                         $("#myVolumeControl").volumecontrol( "option", "title", "Volume" );
116                 }
117         });
118
119         $("#myoptionheader").bind('collapse', function () {
120                 console.log('option header was collapsed');
121         });
122
123         $("#myoptionheader").bind('expand', function () {
124                 console.log('option header was expanded');
125         });
126
127         //day-selector codes...
128         $("#day-selector-check-all").live('vclick', function () {
129                 $("#dayselector1").dayselector('selectAll');
130         });
131
132         $("#day-selector-get-days").live('vclick', function () {
133                 var valuesStr = $("#dayselector1").dayselector('value').join(', ');
134                 $(".selectedDay").text( valuesStr );
135         });
136
137         /* Gen list : Dummy DB load */
138         $(".virtuallist_demo_page").live("pagecreate", function () {
139                 /* ?_=ts code for no cache mechanism */
140                 $.getScript( "./virtuallist-db-demo.js", function ( data, textStatus ) {
141                         $("ul").filter( function () {
142                                 return $( this ).data("role") == "virtuallistview";
143                         }).addClass("vlLoadSuccess");
144
145                         $(".virtuallist_demo_page").die();
146                         $("ul.ui-virtual-list-container").virtuallistview("create");
147                 });
148         });
149
150         /*Expandable list : Dummy DB load*/
151         $("#genlist_extendable_page").live("pagecreate", function () {
152                 /*?_=ts code for no cache mechanism*/
153                 $.getScript( "./virtuallist-db-demo.js", function ( data, textStatus ) {
154                         $("ul").filter( function () {
155                                 return $( this ).data("role") == "extendablelist";
156                         }).addClass("elLoadSuccess");
157
158                         $("#genlist-extendable-page").die();
159                         $("ul.ui-extendable-list-container").extendablelist("create");
160                 });
161         });
162
163         /* Color widget demo */
164         var clrWidgetsAreInit = false;
165         $("#colorwidgets-demo").bind("pageshow", function () {
166                 if ( clrWidgetsAreInit ) {
167                         return;
168                 }
169
170                 $("#colorpicker").bind("colorchanged", function ( e, clr ) {
171                         $("#colorpickerbutton").colorpickerbutton( "option", "color", clr );
172                         $("#colorpickerbutton-noform").colorpickerbutton( "option", "color", clr );
173                         $("#hsvpicker").hsvpicker( "option", "color", clr );
174                         $("#colortitle").colortitle( "option", "color", clr );
175                         $("#colorpalette").colorpalette( "option", "color", clr );
176                 });
177
178                 $("#colorpickerbutton").bind("colorchanged", function ( e, clr ) {
179                         $("#colorpicker").colorpicker( "option", "color", clr );
180                         $("#colorpickerbutton-noform").colorpickerbutton( "option", "color", clr );
181                         $("#hsvpicker").hsvpicker( "option", "color", clr );
182                         $("#colortitle").colortitle( "option", "color", clr );
183                         $("#colorpalette").colorpalette( "option", "color", clr );
184                 });
185
186                 $("#colorpickerbutton-noform").bind("colorchanged", function ( e, clr ) {
187                         $("#colorpicker").colorpicker( "option", "color", clr );
188                         $("#colorpickerbutton").colorpickerbutton( "option", "color", clr );
189                         $("#hsvpicker").hsvpicker( "option", "color", clr );
190                         $("#colortitle").colortitle( "option", "color", clr );
191                         $("#colorpalette").colorpalette( "option", "color", clr );
192                 });
193
194                 $("#hsvpicker").bind("colorchanged", function ( e, clr ) {
195                         $("#colorpicker").colorpicker( "option", "color", clr );
196                         $("#colorpickerbutton").colorpickerbutton( "option", "color", clr );
197                         $("#colorpickerbutton-noform").colorpickerbutton( "option", "color", clr );
198                         $("#colortitle").colortitle( "option", "color", clr );
199                         $("#colorpalette").colorpalette( "option", "color", clr );
200                 });
201
202                 $("#colortitle").bind("colorchanged", function ( e, clr ) {
203                         $("#colorpicker").colorpicker( "option", "color", clr );
204                         $("#colorpickerbutton").colorpickerbutton( "option", "color", clr );
205                         $("#colorpickerbutton-noform").colorpickerbutton( "option", "color", clr );
206                         $("#hsvpicker").hsvpicker( "option", "color", clr );
207                         $("#colorpalette").colorpalette( "option", "color", clr );
208                 });
209
210                 $("#colorpalette").bind("colorchanged", function ( e, clr ) {
211                         $("#colorpicker").colorpicker( "option", "color", clr );
212                         $("#colorpickerbutton").colorpickerbutton( "option", "color", clr );
213                         $("#colorpickerbutton-noform").colorpickerbutton( "option", "color", clr );
214                         $("#hsvpicker").hsvpicker( "option", "color", clr );
215                         $("#colortitle").colortitle( "option", "color", clr );
216                 });
217
218                 $("#colorpalette").colorpalette("option", "color", "#45cc98");
219
220                 clrWidgetsAreInit = true;
221         });
222 });
223
224 $(document).ready( function () {
225         // add current datetime with browser language format
226         // NOTE: Globalize.* functions must be run after docoument ready.
227         $('#current_date').html(Globalize.culture().name + " -- " +
228                                 Globalize.format( new Date(), "F" ));
229         $('#html_font_size').html('html font size:' + $('html').css('font-size'));
230 });