Export 0.1.41
[platform/framework/web/web-ui-fw.git] / src / widgets / listdivider / js / jquery.mobile.tizen.listdivider.js
1 /* ***************************************************************************
2
3 */
4
5 (function ( $, undefined ) {
6
7         $.widget( "tizen.listdivider", $.mobile.widget, {
8                 options: {
9                         initSelector: ":jqmData(role='list-divider')"
10                 },
11
12                 _create: function () {
13
14                         var $listdivider = this.element,
15                                 openStatus = true,
16                                 iconStatus,
17                                 expandSrc,
18                                 style = $listdivider.attr( "data-style" );
19
20                         if ( style === "expandable" || style === "checkexpandable" ) {
21                                 openStatus ? iconStatus = "opened" : iconStatus = "closed";
22                                 expandSrc = "<span class='ui-divider-expand-div'><span class='ui-icon-expandable-divider-" + iconStatus + "'/></span>";
23
24                                 $( expandSrc ).appendTo( $listdivider );
25                         }
26
27                         $listdivider.children( ".ui-divider-expand-div" ).bind( "vclick", function ( event, ui ) {
28                                 if ( openStatus ) {
29                                         $( this ).children( "span" ).removeClass( "ui-icon-expandable-divider-opened" );
30                                         $( this ).children( "span" ).addClass( "ui-icon-expandable-divider-closed" );
31                                         openStatus = false;
32                                 } else {
33                                         $( this ).children( "span" ).removeClass( "ui-icon-expandable-divider-closed" );
34                                         $( this ).children( "span" ).addClass( "ui-icon-expandable-divider-opened" );
35                                         openStatus = true;
36                                 }
37                         });
38                 },
39         });
40
41         //auto self-init widgets
42         $( document ).bind( "pagecreate create", function ( e ) {
43                 $( $.tizen.listdivider.prototype.options.initSelector, e.target ).listdivider();
44         });
45 }( jQuery ) );