systemmodeswitch.html.php 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  1. <style>
  2. .block-guide .tab-pane .mode-switch {padding-bottom: 10px;}
  3. .block-guide .tab-pane .mode-switch .mode-title {padding-top: 14px; padding-left: 20px;}
  4. .block-guide .tab-pane .mode-switch .mode-content {display: flex;}
  5. .block-guide .tab-pane .mode-switch .dataTitle {padding: 14px 20px;}
  6. .block-guide .tab-pane .mode-switch .mode-block {background: rgba(230, 240, 255, 0.4); margin-left: 10px; cursor: pointer; padding-top: 8px;}
  7. .block-guide .tab-pane .mode-switch .mode-block:nth-child(2) {margin-left: 8%;}
  8. .block-guide .tab-pane .mode-switch .mode-block:hover {box-shadow: 0 0 14px rgba(0, 0, 0, 0.12);}
  9. .block-guide .tab-pane .mode-switch .mode-block.active {box-shadow: 0 0 0 2px #2E7FFF; border-radius: 2px;}
  10. .block-guide .tab-pane .mode-switch .mode-desc {padding: 4px 4px 10px; font-size: 12px; color: #5E626D;}
  11. #selectProgramModal .modal-header {border-bottom: 0;}
  12. #selectProgramModal .modal-header h4.modal-title {font-weight: 700;}
  13. #selectProgramModal .modal-dialog {width: 550px;}
  14. .modal-body {padding: 20px;}
  15. #selectProgramModal .modal-footer {border-top: 0px; text-align: center;}
  16. <?php if(common::checkNotCN()):?>
  17. .block-guide .tab-pane .mode-switch .mode-block:nth-child(1) {padding-bottom: 18px;}
  18. @media screen and (max-width: 988px) {.block-guide .tab-pane .mode-switch .mode-content .mode-block:nth-child(2) img {max-width: 74%;}}
  19. <?php endif;?>
  20. </style>
  21. <?php $usedMode = zget($this->config->global, 'mode', 'light');?>
  22. <?php js::set('usedMode', $usedMode);?>
  23. <?php js::set('hasProgram', !empty($programs));?>
  24. <?php js::set('changeModeTips', sprintf($lang->custom->changeModeTips, $lang->custom->modeList[$usedMode == 'light' ? 'ALM' : 'light']));?>
  25. <div class='table-row mode-switch'>
  26. <div class="col-4">
  27. <p class="col mode-title"><?php echo $lang->block->customModeTip->common;?></p>
  28. <div class='col pull-left col-md-12 mode-content'>
  29. <?php foreach($lang->block->customModes as $mode => $modeName):?>
  30. <div class="pull-left col-md-5 mode-block<?php if($usedMode == $mode) echo ' active';?>" data-mode='<?php echo $mode;?>'>
  31. <div style="width: 100%;"><?php echo html::image($config->webRoot . "theme/default/images/guide/{$mode}_" . (common::checkNotCN() ? 'en' : 'cn') . ".png");?></div>
  32. <div class='mode-desc'>
  33. <h4><?php echo $modeName;?></h4>
  34. <?php echo $lang->block->customModeTip->$mode;?>
  35. </div>
  36. </div>
  37. <?php endforeach;?>
  38. </div>
  39. </div>
  40. </div>
  41. <div class='modal fade' id='selectProgramModal'>
  42. <div class='modal-dialog'>
  43. <div class='modal-content'>
  44. <div class='modal-header'>
  45. <button type='button' class='close' data-dismiss='modal'><span aria-hidden='true'>× </span><span class='sr-only'><?php echo $this->lang->close;?></span></button>
  46. <h4 class='modal-title'><?php echo $lang->custom->selectDefaultProgram;?></h4>
  47. </div>
  48. <div class='modal-body'>
  49. <div class='alert alert-primary'>
  50. <p class='text-info'><?php echo $lang->custom->selectProgramTips;?></p>
  51. </div>
  52. <table class='table table-form'>
  53. <tr>
  54. <th><?php echo $lang->custom->defaultProgram;?></th>
  55. <td><?php echo html::select('defaultProgram', $programs, $programID, "class='form-control chosen'");?></td>
  56. </tr>
  57. </table>
  58. </div>
  59. <div class='modal-footer'>
  60. <button type='button' class='btn btn-primary btn-wide btn-save'><?php echo $lang->save;?></button>
  61. </div>
  62. </div>
  63. </div>
  64. </div>
  65. <script>
  66. $(function()
  67. {
  68. var selectedMode = usedMode;
  69. /**
  70. * Switch system mode.
  71. *
  72. * @access public
  73. * @return void
  74. */
  75. function switchMode(mode)
  76. {
  77. if(mode == usedMode) return;
  78. var postData = {mode: mode};
  79. if(mode == 'light' && hasProgram) postData.program = $('#defaultProgram').val();
  80. $.post(createLink('custom', 'mode'), postData, function(result)
  81. {
  82. $('#selectProgramModal').modal('hide');
  83. parent.location.reload();
  84. });
  85. }
  86. var $block = $('#block<?php echo $blockID;?>');
  87. var systemModePosition = "<?php echo 'systemModePosition-' . $blockID;?>";
  88. $block.on('click', '.mode-block', function()
  89. {
  90. selectedMode = $(this).data('mode');
  91. if(selectedMode == usedMode) return;
  92. var scrollTop = document.documentElement.scrollTop || window.pageYOffset || document.body.scrollTop || $block.find('#guideBody').offset().top;
  93. localStorage.setItem(systemModePosition, scrollTop);
  94. if(selectedMode == 'light' && hasProgram)
  95. {
  96. $('#selectProgramModal').modal('show');
  97. }
  98. else
  99. {
  100. bootbox.confirm(changeModeTips, function(result)
  101. {
  102. if(result) switchMode(selectedMode);
  103. });
  104. }
  105. }).on('click', '#selectProgramModal .btn-save', function()
  106. {
  107. switchMode('light');
  108. });
  109. });
  110. </script>