Converting js into a tpl

skala
Julio Montoya 13 years ago
parent a145cf95db
commit cb3eec4c3d
  1. 87
      main/inc/lib/javascript/jquery.lp_minipanel.js
  2. 8
      main/newscorm/lp_add_item.php
  3. 5
      main/newscorm/lp_view.php
  4. 88
      main/template/default/javascript/newscorm/minipanel.tpl

@ -1,86 +1 @@
/* For licensing terms, see /license.txt */
/*
Learning Path minipanel - Chamilo 1.8.8
Adding mini panel to browse Learning Paths
Requirements: JQuery 1.4.4, JQuery UI 1.8.7
@author Alberto Torreblanca @albert1t0
@author Julio Montoya Cleaning/fixing some code
**/
// Copy little progress bar in <tr></tr>
function toogle_minipanel() {
// Construct mini panel
var panel = $('#lp_navigation_elem div:first').clone();
$(panel).attr('id', 'control');
$('#learning_path_main').append(panel);
$('#learning_path_main #control tr').after('<tr></tr>');
$('#learning_path_main #control tr:eq(1)').append($('#progress_bar').html());
$('#learning_path_main #control tr:eq(1) #progress_img_limit_left').attr('height','5');
$('#learning_path_main #control tr:eq(1) #progress_img_full').attr('height','5');
$('#learning_path_main #control tr:eq(1) #progress_img_limit_middle').attr('height','5');
$('#learning_path_main #control tr:eq(1) #progress_img_empty').attr('height','5');
$('#learning_path_main #control tr:eq(1) #progress_bar_img_limit_right').attr('height','5');
$('#learning_path_main #control tr:eq(1) #progress_text').remove();
$('#learning_path_main #control tr:eq(1) div').css('width','');
$('#learning_path_main #control .buttons').attr('text-align','center');
$('#content_id').css({ height: $('#content_id').height() - ($('#control').height() + 10) });
$('#learning_path_main #control .buttons img').click(function(){
$('#learning_path_main #control tr:eq(1)').remove();
toogle_minipanel();
});
// Hiding navigation left zone
$('#learning_path_left_zone').hide(50);
$('#learning_path_right_zone').css('margin-left','10px');
$('#hide_bar table').css('backgroundImage','url(../img/hide2.png)').css('backgroundColor','#EEEEEE');
}
var left_width = 292; // (relative) hide_bar position
$(document).ready(function() {
//Adding div to hide panel
$('#learning_path_right_zone').before('<div id="hide_bar" style="float: left; width: 10px; height: 1000px;">' +
'<table style="border: 0 none; width: 100%; height: 100%; cursor: pointer; background-color: #EEEEEE">' +
'<tr><td></td></tr></table></div>');
$('#hide_bar table').css({backgroundImage: "url(../img/hide0.png)", backgroundRepeat: "no-repeat", backgroundPosition: "center center"});
//Adding effects to hide bar
$('#hide_bar table').hover(function () {
if ($('#hide_bar').position().left >= left_width)
$(this).css('backgroundImage','url(../img/hide1.png)').css('backgroundColor','#888888');
else if($('#hide_bar').position().left == 0)
$(this).css('backgroundImage','url(../img/hide3.png)').css('backgroundColor','#888888');
},function (){
if($('#hide_bar').position().left >= left_width)
$(this).css('backgroundImage','url(../img/hide0.png)').css('backgroundColor','#EEEEEE');
else if($('#hide_bar').position().left == 0)
$(this).css('backgroundImage','url(../img/hide2.png)').css('backgroundColor','#EEEEEE');
}
);
var original = $('#content_id').height();
// Adding funcionality
$( "#hide_bar" ).click(function() {
$('#hide_bar table').toggle(function() {
if ($('#hide_bar').position().left >= left_width) {
toogle_minipanel();
}
},
function(){
// Show navigation left zone
$('#learning_path_left_zone').show(50);
$('#learning_path_right_zone').css('marginLeft', left_width + 10 + 'px');
$('#hide_bar table').css('backgroundImage','url(../img/hide0.png)').css('backgroundColor','#EEEEEE');
$('#learning_path_main #control').remove();
$('#content_id').css({ height: original});
}
);
});
});
/* File moved to template/default/javascript/newscorm/minipanel.tpl

@ -189,6 +189,8 @@ Display::display_header(null, 'Path');
$suredel = trim(get_lang('AreYouSureToDelete'));
//@todo move this somewhere else css/fix.css
$iconUrl = api_get_path(WEB_CODE_PATH).'img/';
?>
<style>
#feedback { font-size: 1.4em; }
@ -224,7 +226,7 @@ $(document).ready(function() {
$("#hide_bar_template").toggle(
function() {
$("#lp_sidebar").hide();
$(this).css({'background-image' : 'url("../img/hide2.png")'})
$(this).css({'background-image' : 'url("<?php echo $iconUrl; ?>hide2.png")'})
$("#doc_form").removeClass("span8");
$("#doc_form").addClass("span11");
},
@ -232,7 +234,7 @@ $(document).ready(function() {
$("#lp_sidebar").show();
$("#doc_form").removeClass("span11");
$("#doc_form").addClass("span8");
$(this).css('background-image', 'url("../img/hide0.png")');
$(this).css('background-image', 'url("<?php echo $iconUrl; ?>hide0.png")');
}
);
});
@ -348,4 +350,4 @@ echo '</div>';
echo '</div>';
/* FOOTER */
Display::display_footer();
Display::display_footer();

@ -76,7 +76,9 @@ $user_id = api_get_user_id();
$platform_theme = api_get_setting('stylesheets');
$my_style = $platform_theme;
$htmlHeadXtra[] = '<script src="'.api_get_path(WEB_LIBRARY_PATH).'javascript/jquery.lp_minipanel.js" type="text/javascript" language="javascript"></script>';
//$htmlHeadXtra[] = '<script src="'.api_get_path(WEB_LIBRARY_PATH).'javascript/lp_minipanel/jquery.lp_minipanel.js" type="text/javascript"></script>';
$htmlHeadXtra[] = $app['template']->fetch('default/javascript/newscorm/minipanel.tpl');
$htmlHeadXtra[] = '<script>
$(document).ready(function(){
$("div#log_content_cleaner").bind("click", function() {
@ -287,7 +289,6 @@ if ($_SESSION['oLP']->mode == 'fullscreen') {
$htmlHeadXtra[] = "<script>window.open('$src','content_id','toolbar=0,location=0,status=0,scrollbars=1,resizable=1');</script>";
}
// Not in fullscreen mode.
Display::display_reduced_header($nameTools);

@ -0,0 +1,88 @@
<script>
/*
Learning Path minipanel - Chamilo 1.8.8
Adding mini panel to browse Learning Paths
Requirements: JQuery 1.4.4, JQuery UI 1.8.7
@author Alberto Torreblanca @albert1t0
@author Julio Montoya Cleaning/fixing some code + script converted in a twig template
**/
// Copy little progress bar in <tr></tr>
function toogle_minipanel() {
// Construct mini panel
var panel = $('#lp_navigation_elem div:first').clone();
$(panel).attr('id', 'control');
$('#learning_path_main').append(panel);
$('#learning_path_main #control tr').after('<tr></tr>');
$('#learning_path_main #control tr:eq(1)').append($('#progress_bar').html());
$('#learning_path_main #control tr:eq(1) #progress_img_limit_left').attr('height','5');
$('#learning_path_main #control tr:eq(1) #progress_img_full').attr('height','5');
$('#learning_path_main #control tr:eq(1) #progress_img_limit_middle').attr('height','5');
$('#learning_path_main #control tr:eq(1) #progress_img_empty').attr('height','5');
$('#learning_path_main #control tr:eq(1) #progress_bar_img_limit_right').attr('height','5');
$('#learning_path_main #control tr:eq(1) #progress_text').remove();
$('#learning_path_main #control tr:eq(1) div').css('width','');
$('#learning_path_main #control .buttons').attr('text-align','center');
$('#content_id').css({ height: $('#content_id').height() - ($('#control').height() + 10) });
$('#learning_path_main #control .buttons img').click(function(){
$('#learning_path_main #control tr:eq(1)').remove();
toogle_minipanel();
});
// Hiding navigation left zone
$('#learning_path_left_zone').hide(50);
$('#learning_path_right_zone').css('margin-left','10px');
$('#hide_bar table').css('backgroundImage','url({{ _p.web_main }}img/hide2.png)').css('backgroundColor','#EEEEEE');
}
var left_width = 292; // (relative) hide_bar position
$(document).ready(function() {
//Adding div to hide panel
$('#learning_path_right_zone').before('<div id="hide_bar" style="float: left; width: 10px; height: 1000px;">' +
'<table style="border: 0 none; width: 100%; height: 100%; cursor: pointer; background-color: #EEEEEE">' +
'<tr><td></td></tr></table></div>');
$('#hide_bar table').css({backgroundImage: "url({{ _p.web_main }}img/hide0.png)", backgroundRepeat: "no-repeat", backgroundPosition: "center center"});
//Adding effects to hide bar
$('#hide_bar table').hover(function () {
if ($('#hide_bar').position().left >= left_width)
$(this).css('backgroundImage','url({{ _p.web_main }}img/hide1.png)').css('backgroundColor','#888888');
else if($('#hide_bar').position().left == 0)
$(this).css('backgroundImage','url({{ _p.web_main }}img/hide3.png)').css('backgroundColor','#888888');
},function (){
if($('#hide_bar').position().left >= left_width)
$(this).css('backgroundImage','url({{ _p.web_main }}img/hide0.png)').css('backgroundColor','#EEEEEE');
else if($('#hide_bar').position().left == 0)
$(this).css('backgroundImage','url({{ _p.web_main }}img/hide2.png)').css('backgroundColor','#EEEEEE');
}
);
var original = $('#content_id').height();
// Adding funcionality
$( "#hide_bar" ).click(function() {
$('#hide_bar table').toggle(function() {
if ($('#hide_bar').position().left >= left_width) {
toogle_minipanel();
}
},
function(){
// Show navigation left zone
$('#learning_path_left_zone').show(50);
$('#learning_path_right_zone').css('marginLeft', left_width + 10 + 'px');
$('#hide_bar table').css('backgroundImage','url({{ _p.web_main }}img/hide0.png)').css('backgroundColor','#EEEEEE');
$('#learning_path_main #control').remove();
$('#content_id').css({ height: original});
}
);
});
});
</script>
Loading…
Cancel
Save