Merge branch 'master' into tizen_2.1
[platform/framework/web/web-ui-fw.git] / demos / tizen-winsets / widgets / tokentextarea / tokentextarea-demo.js
1 ( function ( $, window ) {
2         $( document ).one( "pagecreate", "#tokentextarea", function () {
3                 $( "#MBTaddItemTest" ).on( "click", function () {
4                         $( ":jqmData(role='tokentextarea')" ).tokentextarea( "add", "additem" );
5                 });
6
7                 $( "#MBTremoveItemTest" ).on( "click", function () {
8                         $( ":jqmData(role='tokentextarea')" ).tokentextarea( "remove", 0 );
9                 });
10
11                 $( "#MBTinputTextTest" ).on( "click", function () {
12                         $( ":jqmData(role='tokentextarea')" ).tokentextarea( "inputText", "Hello~~~" );
13                 });
14
15                 $( "#MBTgetInputTextTest" ).on( "click", function () {
16                         var input = $( ":jqmData(role='tokentextarea')" ).tokentextarea( "inputText" );
17                         window.alert( "input String : " + input );
18                 });
19
20                 $( "#MBTremoveAllItemTest" ).on( "click", function () {
21                         $( ":jqmData(role='tokentextarea')" ).tokentextarea( "remove" );
22                         $( ":jqmData(role='tokentextarea')" ).parents( ".ui-scrollview-view" ).parent().scrollview( "scrollTo", 0, 0 );
23                 });
24
25                 $( "#MBTgetSelectedItemTest" ).on( "click", function () {
26                         var content = $( ":jqmData(role='tokentextarea')" ).tokentextarea( "select" );
27                         window.alert( "Select content : " + content );
28                 });
29
30                 $( "#MBTselectItemTest" ).on( "click", function () {
31                         $( ":jqmData(role='tokentextarea')" ).tokentextarea( "select", 0 );
32                 });
33
34                 $( "#MBTlengthTest" ).on( "click", function () {
35                         var length = $( ":jqmData(role='tokentextarea')" ).tokentextarea( "length" );
36                         window.alert( "length : " + length );
37                 });
38
39                 $( "#MBTfocusInTest" ).on( "click", function () {
40                         $( ":jqmData(role='tokentextarea')" ).tokentextarea( "focusIn", 0 );
41                         $( ":jqmData(role='tokentextarea')" ).parents( ".ui-scrollview-view" ).parent().scrollview( "scrollTo", 0, 0 );
42                 });
43
44                 $( "#MBTfocusOutTest" ).on( "click", function () {
45                         $( ":jqmData(role='tokentextarea')" ).tokentextarea( "focusOut", 0 );
46                         $( ":jqmData(role='tokentextarea')" ).parents( ".ui-scrollview-view" ).parent().scrollview( "scrollTo", 0, 0 );
47                 });
48
49                 $( "#MBTdestroyTest" ).on( "click", function () {
50                         $( ":jqmData(role='tokentextarea')" ).tokentextarea( "destroy" );
51                 });
52         });
53
54         $( document ).one( "pagecreate", "#addressbook", function () {
55                 var self = this;
56                 self.itemSelected = false;
57
58                 $( "#addressbook" ).on( "mousedown", function () {
59                         self.itemSelected = false;
60                 });
61
62                 $( "#addressbook" ).on( "mouseup", function () {
63                         self.itemSelected = true;
64                 });
65
66                 $( "#contentList a" ).on( "click", function () {
67                         if ( self.itemSelected ) {
68                                 var arg = $( this ).text();
69                                 $( ":jqmData(role='tokentextarea')" ).tokentextarea( "add", arg );
70                                 history.back();
71                         }
72                 });
73         });
74 } ( jQuery, window ) );