From ac6f010ebe7993ac28220d99d27cdb4cbe1a3015 Mon Sep 17 00:00:00 2001 From: Julio Montoya Date: Fri, 10 Apr 2015 12:30:51 +0200 Subject: [PATCH] Use bootstrap tab instead of jquery-ui. --- main/document/upload.php | 2 +- main/inc/lib/display.lib.php | 27 +++++++++++++++++++------ main/newscorm/lp_add_item.php | 12 ++++------- main/template/default/layout/footer.tpl | 7 +++++++ 4 files changed, 33 insertions(+), 15 deletions(-) diff --git a/main/document/upload.php b/main/document/upload.php index 873996dc3f..1c2ddfeef9 100755 --- a/main/document/upload.php +++ b/main/document/upload.php @@ -78,8 +78,8 @@ $(function () { return $('' + file.name + '<\/td> ' + file.size + ' <\/td>  ' + file.result + ' <\/td> <\/tr>'); } }); - $('#tabs').tabs(); }); + "; // Variables diff --git a/main/inc/lib/display.lib.php b/main/inc/lib/display.lib.php index 36818b39d9..779a5a38e9 100755 --- a/main/inc/lib/display.lib.php +++ b/main/inc/lib/display.lib.php @@ -1018,21 +1018,36 @@ class Display $lis = ''; $i = 1; foreach ($header_list as $item) { - $item =self::tag('a', $item, array('href'=>'#'.$id.'-'.$i)); - $lis .=self::tag('li', $item, $ul_attributes); + $active = ''; + if ($i == 1) { + $active = ' active'; + } + $item = self::tag('a', $item, array('href'=>'#'.$id.'-'.$i, 'role'=> 'tab')); + $ul_attributes['data-toggle'] = 'tab'; + $ul_attributes['role'] = 'presentation'; + $ul_attributes['class'] = $active; + $lis .= self::tag('li', $item, $ul_attributes); $i++; } - $ul = self::tag('ul',$lis); + $ul = self::tag('ul', $lis, ['class' => 'nav nav-tabs', 'role'=> 'tablist']); $i = 1; $divs = ''; foreach ($content_list as $content) { - $content = self::tag('p',$content); - $divs .=self::tag('div', $content, array('id'=>$id.'-'.$i)); + $active = ''; + if ($i == 1) { + $active = ' active'; + } + $divs .= self::tag('div', $content, array('id'=> $id.'-'.$i, 'class' => 'tab-pane '.$active, 'role' => 'tabpanel')); $i++; } + $attributes['id'] = $id; - $main_div = self::tag('div',$ul.$divs, $attributes); + $attributes['role'] = 'tabpanel'; + $attributes['class'] = 'tab-wrapper'; + + $main_div = self::tag('div', $ul.self::tag('div', $divs, ['class' => 'tab-content']), $attributes); + return $main_div ; } diff --git a/main/newscorm/lp_add_item.php b/main/newscorm/lp_add_item.php index d9be65a53d..e349e346dc 100755 --- a/main/newscorm/lp_add_item.php +++ b/main/newscorm/lp_add_item.php @@ -48,9 +48,6 @@ $(function() { load_cbo($(\'#idParent\').val()); } } - //Loads LP item tabs - - $("#resource_tab").tabs(); $(\'.lp_resource_element\').click(function() { window.location.href = $(\'a\', this).attr(\'href\'); }); @@ -99,14 +96,14 @@ $interbreadcrumb[] = array('url' => api_get_self()."?action=build&lp_id=$learnpa switch ($type) { case 'chapter': - $interbreadcrumb[]= array ('url' => 'lp_controller.php?action=add_item&type=step&lp_id='.$learnPath->get_id(), 'name' => get_lang('NewStep')); - $interbreadcrumb[]= array ('url' => '#', 'name' => get_lang('NewChapter')); + $interbreadcrumb[]= array('url' => 'lp_controller.php?action=add_item&type=step&lp_id='.$learnPath->get_id(), 'name' => get_lang('NewStep')); + $interbreadcrumb[]= array('url' => '#', 'name' => get_lang('NewChapter')); break; case 'document': - $interbreadcrumb[]= array ('url' => 'lp_controller.php?action=add_item&type=step&lp_id='.$learnPath->get_id(), 'name' => get_lang('NewStep')); + $interbreadcrumb[]= array('url' => 'lp_controller.php?action=add_item&type=step&lp_id='.$learnPath->get_id(), 'name' => get_lang('NewStep')); break; default: - $interbreadcrumb[]= array ('url' => '#', 'name' => get_lang('NewStep')); + $interbreadcrumb[]= array('url' => '#', 'name' => get_lang('NewStep')); break; } @@ -194,7 +191,6 @@ if (in_array($message, array('ItemUpdated'))) { } if (isset($new_item_id) && is_numeric($new_item_id)) { - switch ($type) { case 'chapter': echo $learnPath->display_manipulate($new_item_id, $_POST['type']); diff --git a/main/template/default/layout/footer.tpl b/main/template/default/layout/footer.tpl index 365bc729e2..38097a82e5 100755 --- a/main/template/default/layout/footer.tpl +++ b/main/template/default/layout/footer.tpl @@ -90,6 +90,13 @@ $.datepicker.setDefaults($.datepicker.regional["{{ locale }}"]); $.datepicker.regional["local"] = $.datepicker.regional["{{ locale }}"]; + $('.tab-wrapper a').click(function (e) { + e.preventDefault() + $(this).tab('show'); + + //$('#tabs a:first').tab('show') // Select first tab + }) + /** * Advanced options * Usage