Replace boostrap/jquery tab with alpine js tab in Display::tabs

pull/3959/head
Julio 4 years ago
parent fdac6a92a8
commit 0e23f3da16
  1. 6
      assets/js/app.js
  2. 19
      public/main/inc/lib/display.lib.php
  3. 16
      public/main/lp/learnpath.class.php
  4. 30
      public/main/lp/lp_add_item.php

@ -315,13 +315,13 @@ $(function () {
// }); // });
// Bootstrap tabs. // Bootstrap tabs.
$('.tab_wrapper .nav a').on('click', function (e) { /*$('.tab_wrapper .nav a').on('click', function (e) {
e.preventDefault() e.preventDefault()
$(this).tab('show') $(this).tab('show')
}); });*/
// Fixes bug when loading links inside a tab. // Fixes bug when loading links inside a tab.
$('.tab_wrapper .tab-pane a').unbind(); //$('.tab_wrapper .tab-pane a').unbind();
/** /**
* Advanced options * Advanced options

@ -1077,7 +1077,7 @@ class Display
$ul_attributes = [], $ul_attributes = [],
$selected = '' $selected = ''
) { ) {
if (empty($headers) || 0 == count($headers)) { if (empty($headers) || 0 === count($headers)) {
return ''; return '';
} }
@ -1100,8 +1100,9 @@ class Display
'a', 'a',
$item, $item,
[ [
'href' => '#'.$id.'-'.$i, //'href' => '#'.$id.'-'.$i,
'class' => 'nav-item nav-link '.$active, 'class' => 'nav-item nav-link '.$active,
'@click' => "openTab = $i",
'id' => $id.$i.'-tab', 'id' => $id.$i.'-tab',
'data-toggle' => 'tab', 'data-toggle' => 'tab',
'role' => 'tab', 'role' => 'tab',
@ -1117,7 +1118,7 @@ class Display
'nav', 'nav',
$lis, $lis,
[ [
'id' => 'ul_'.$id, 'id' => 'nav_'.$id,
'class' => 'nav nav-tabs', 'class' => 'nav nav-tabs',
'role' => 'tablist', 'role' => 'tablist',
] ]
@ -1143,21 +1144,23 @@ class Display
$content, $content,
[ [
'id' => $id.'-'.$i, 'id' => $id.'-'.$i,
'class' => 'tab-pane fade '.$active, 'x-show' => "openTab === $i"
'role' => 'tabpanel', //'class' => 'tab-pane fade '.$active,
'aria-labelledby' => $id.$i.'-tab', //'role' => 'tabpanel',
//'aria-labelledby' => $id.$i.'-tab',
] ]
); );
$i++; $i++;
} }
$attributes['id'] = $id; $attributes['id'] = ''.$id;
$attributes['class'] = 'tab_wrapper '; $attributes['class'] = 'tab_wrapper ';
$attributes['x-data'] = ' { openTab: 1 } ';
return self::tag( return self::tag(
'div', 'div',
$ul. $ul.
self::tag('div', $divs, ['class' => 'tab-content']), $divs,
$attributes $attributes
); );
} }

@ -4557,7 +4557,6 @@ class learnpath
}, },
}); });
}); });
}); });
</script>'; </script>';
@ -4583,12 +4582,13 @@ class learnpath
$(function () { $(function () {
//$('.scrollbar-inner').scrollbar(); //$('.scrollbar-inner').scrollbar();
$('#subtab').on('click', 'a:first', function() { /*$('#subtab').on('click', 'a:first', function() {
window.location.reload(); window.location.reload();
}); });
$('#subtab ').on('click', 'a:first', function () { $('#subtab ').on('click', 'a:first', function () {
window.location.reload(); window.location.reload();
}); });*/
expandColumnToggle('#hide_bar_template', { expandColumnToggle('#hide_bar_template', {
selector: '#lp_sidebar' selector: '#lp_sidebar'
}, { }, {
@ -4614,17 +4614,16 @@ class learnpath
}); });
// document template for new document tab handler // document template for new document tab handler
$(document).on('shown.bs.tab', 'a[data-toggle=\"tab\"]', function (e) { /*$(document).on('shown.bs.tab', 'a[data-toggle=\"tab\"]', function (e) {
var id = e.target.id; var id = e.target.id;
if (id == 'subtab2') { if (id == 'subtab2') {
$('#frmModel').show(); $('#frmModel').show();
} else { } else {
$('#frmModel').hide(); $('#frmModel').hide();
} }
}); });*/
function deleteItem(event) { function deleteItem(event) {
console.log($(event));
var id = $(event).attr('data-id'); var id = $(event).attr('data-id');
var title = $(event).attr('data-title'); var title = $(event).attr('data-title');
var params = '&a=delete_item&id=' + id; var params = '&a=delete_item&id=' + id;
@ -6139,10 +6138,10 @@ class learnpath
} }
var cbo = document.getElementById('previous'); var cbo = document.getElementById('previous');
if (cbo) {
for(var i = cbo.length - 1; i > 0; i--) { for(var i = cbo.length - 1; i > 0; i--) {
cbo.options[i] = null; cbo.options[i] = null;
} }
var k=0; var k=0;
for (var i = 1; i <= child_name[id].length; i++){ for (var i = 1; i <= child_name[id].length; i++){
var option = new Option(child_name[id][i - 1], child_value[id][i - 1]); var option = new Option(child_name[id][i - 1], child_value[id][i - 1]);
@ -6150,8 +6149,9 @@ class learnpath
cbo.options[i] = option; cbo.options[i] = option;
k = i; k = i;
} }
cbo.options[k].selected = true; cbo.options[k].selected = true;
}
//$('#previous').selectpicker('refresh'); //$('#previous').selectpicker('refresh');
}"; }";

@ -43,41 +43,15 @@ if ($learnPath->get_lp_session_id() != api_get_session_id()) {
} }
$htmlHeadXtra[] = '<script>'.$learnPath->get_js_dropdown_array()." $htmlHeadXtra[] = '<script>'.$learnPath->get_js_dropdown_array()."
function load_cbo(id, previousId) {
if (!id) {
return false;
}
previousId = previousId || 'previous';
var cbo = document.getElementById(previousId);
if (cbo) {
for (var i = cbo.length - 1; i > 0; i--) {
cbo.options[i] = null;
}
var k=0;
for (var i = 1; i <= child_name[id].length; i++){
var option = new Option(child_name[id][i - 1], child_value[id][i - 1]);
option.style.paddingLeft = '40px';
cbo.options[i] = option;
k = i;
}
cbo.options[k].selected = true;
}
//$('#' + previousId).selectpicker('refresh');
}
$(function() { $(function() {
if ($('#previous')) { if ($('#previous')) {
if('parent is'+$('#idParent').val()) { if('parent is'+$('#idParent').val()) {
load_cbo($('#idParent').val()); load_cbo($('#idParent').val());
} }
} }
$('.lp_resource_element').click(function() { $('.lp_resource_element').click(function() {
window.location.href = $('a', this).attr('href'); //window.location.href = $('a', this).attr('href');
}); });
/*CKEDITOR.on('instanceReady', function (e) { /*CKEDITOR.on('instanceReady', function (e) {
showTemplates('content_lp'); showTemplates('content_lp');

Loading…
Cancel
Save