1/**
2 * Refresh tab page
3 * @param page
4 */
5function dwpl_ti_refresh(_this, page){
6    if(page){
7        var content = jQuery(_this).closest('#dwpl-ti-container').find('#dwpl-ti-content');
8        var loading = jQuery(_this).closest('#dwpl-ti-container').find('#dwpl-ti-loading');
9        // show loading
10        content.css({visibility:'hidden'});
11        loading.css({display:'block'});
12        // POST AJAX
13        jQuery.post(DOKU_BASE + 'lib/plugins/tabinclude/ajax.php', { call: 'content', page: page })
14            .done(function(data) {
15                // Refresh tab page
16                content.html(data);
17                loading.css({display:'none'});
18                content.css({visibility:'visible'});
19            });
20    }
21}
22/**
23 * Initial process
24 */
25function dwpl_ti_init(){
26    // Click event for AJAX tabs
27    jQuery('ul.dwpl-ti li div.dwpl-ti-tab-title').click(function(){
28        jQuery('.dwpl-ti-tab-title').removeClass('selected');
29        jQuery(this).addClass('selected');
30        dwpl_ti_refresh(jQuery(this), jQuery(this).attr('value'));
31    });
32    // Show initial page if necessary
33    var init_ajax=jQuery('#dwpl-ti-read-init-page');
34    if(init_ajax){
35        dwpl_ti_refresh(init_ajax,init_ajax.attr('value'));
36    }
37
38    // Click event for Embedded tabs
39    jQuery(".dwpl-ti-tab-embd-title").click(function() {
40        var num = jQuery(".dwpl-ti-tab-embd-title").index(this);
41        jQuery(".dwpl-ti-tab-embd-title").removeClass('selected');
42        jQuery(this).addClass('selected');
43        jQuery(".dwpl-ti-tab-embd").addClass('hidden');
44        jQuery(".dwpl-ti-tab-embd").eq(num).removeClass('hidden');
45    });
46}
47jQuery(function(){dwpl_ti_init();});
48
49