jquery.lp_minipanel.js 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. /*******************************************
  2. Learning Path minipanel - Chamilo 1.8.8
  3. Adding mini panel to browse Learning Paths
  4. Requirements: JQuery 1.4.4, JQuery UI 1.8.7
  5. Alberto Torreblanca @albert1t0
  6. *******************************************/
  7. function display_hide_toc(){
  8. // Copy little progress bar in <tr></tr>
  9. function minipb() {
  10. $('#learning_path_main #control tr').after('<tr></tr>');
  11. $('#learning_path_main #control tr:eq(1)').append($('#progress_bar').html());
  12. $('#learning_path_main #control tr:eq(1) #progress_img_limit_left').attr('height','5');
  13. $('#learning_path_main #control tr:eq(1) #progress_img_full').attr('height','5');
  14. $('#learning_path_main #control tr:eq(1) #progress_img_limit_middle').attr('height','5');
  15. $('#learning_path_main #control tr:eq(1) #progress_img_empty').attr('height','5');
  16. $('#learning_path_main #control tr:eq(1) #progress_bar_img_limit_right').attr('height','5');
  17. $('#learning_path_main #control tr:eq(1) #progress_text').remove();
  18. $('#learning_path_main #control tr:eq(1) div').css('width','');
  19. }
  20. (function($){
  21. $(document).ready(function() {
  22. //Adding div to hide panel
  23. $('#learning_path_right_zone').before('<div id="hide_bar" style="float: left; width: 10px; height: 100%;">' +
  24. '<table style="border: 0 none; width: 100%; height: 100%; cursor: pointer; background-color: #EEEEEE">' +
  25. '<tr><td></td></tr></table></div>');
  26. $('#hide_bar table').css({backgroundImage: "url(../img/hide0.png)", backgroundRepeat: "no-repeat", backgroundPosition: "center center"});
  27. //Adding effects to hide bar
  28. $('#hide_bar table').hover(function () {
  29. if($('#hide_bar').position().left == 280)
  30. $(this).css('backgroundImage','url(../img/hide1.png)').css('backgroundColor','#888888');
  31. else if($('#hide_bar').position().left == 0)
  32. $(this).css('backgroundImage','url(../img/hide3.png)').css('backgroundColor','#888888');
  33. },function (){
  34. if($('#hide_bar').position().left == 280)
  35. $(this).css('backgroundImage','url(../img/hide0.png)').css('backgroundColor','#EEEEEE');
  36. else if($('#hide_bar').position().left == 0)
  37. $(this).css('backgroundImage','url(../img/hide2.png)').css('backgroundColor','#EEEEEE');
  38. }
  39. );
  40. // Adding funcionality
  41. $('#hide_bar table').toggle(function(){
  42. if($('#hide_bar').position().left == 280){
  43. // Construct mini panel
  44. var panel = $('#lp_navigation_elem div:first').clone();
  45. $(panel).attr('id','control');
  46. $('#learning_path_main').append(panel);
  47. minipb();
  48. $('#learning_path_main #control .buttons').attr('align','center');
  49. $('#learning_path_main #control').css({
  50. margin: "auto",
  51. width: "132px",
  52. height: "34px",
  53. position: "absolute",
  54. top: "5px",
  55. left:"15px",
  56. backgroundColor: "white",
  57. backgroundImage: "url(../img/minipanelback.png)",
  58. paddingTop: "8px",
  59. paddingBottom: "8px",
  60. borderRadius: "4px 4px 4px 4px",
  61. opacity: "0.8",
  62. cursor: "move"
  63. });
  64. $('#learning_path_main #control table').attr('align','center');
  65. $('#learning_path_main #control').draggable({
  66. iframeFix: true,
  67. stack: "#learning_path_right_zone",
  68. cursor: "move"
  69. });
  70. $('#learning_path_main #control .buttons img').click(function(){
  71. $('#learning_path_main #control tr:eq(1)').remove();
  72. minipb();
  73. });
  74. // Hiding navigation left zone
  75. $('#learning_path_left_zone').hide(50);
  76. $('#learning_path_right_zone').css('margin-left','10px');
  77. $('#hide_bar table').css('backgroundImage','url(../img/hide2.png)').css('backgroundColor','#EEEEEE');
  78. },function(){
  79. // Show navigation left zone
  80. $('#hide_bar table').css('backgroundImage','url(../img/hide0.png)').css('backgroundColor','#EEEEEE');
  81. $('#learning_path_right_zone').css('marginLeft','290px');
  82. $('#learning_path_left_zone').show(50);
  83. $('#learning_path_main #control').remove();
  84. });
  85. });
  86. })(jQuery);