您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

jqueryui.php 4.6KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137
  1. <?php
  2. /**
  3. * jQuery UI
  4. *
  5. * Provide the jQuery UI library with according themes.
  6. *
  7. * @version 1.12.0
  8. * @author Cor Bosman <roundcube@wa.ter.net>
  9. * @author Thomas Bruederli <roundcube@gmail.com>
  10. * @author Aleksander Machniak <alec@alec.pl>
  11. * @license GNU GPLv3+
  12. */
  13. class jqueryui extends rcube_plugin
  14. {
  15. public $noajax = true;
  16. public $version = '1.12.0';
  17. private static $features = array();
  18. private static $ui_theme;
  19. public function init()
  20. {
  21. $rcmail = rcmail::get_instance();
  22. // the plugin might have been force-loaded so do some sanity check first
  23. if ($rcmail->output->type != 'html' || self::$ui_theme) {
  24. return;
  25. }
  26. $this->load_config();
  27. // include UI scripts
  28. $this->include_script("js/jquery-ui.min.js");
  29. // include UI stylesheet
  30. $skin = $rcmail->config->get('skin');
  31. $ui_map = $rcmail->config->get('jquery_ui_skin_map', array());
  32. $ui_theme = $ui_map[$skin] ?: $skin;
  33. self::$ui_theme = $ui_theme;
  34. if (file_exists($this->home . "/themes/$ui_theme/jquery-ui.css")) {
  35. $this->include_stylesheet("themes/$ui_theme/jquery-ui.css");
  36. }
  37. else {
  38. $this->include_stylesheet("themes/larry/jquery-ui.css");
  39. }
  40. if ($ui_theme == 'larry') {
  41. // patch dialog position function in order to fully fit the close button into the window
  42. $rcmail->output->add_script("jQuery.extend(jQuery.ui.dialog.prototype.options.position, {
  43. using: function(pos) {
  44. var me = jQuery(this),
  45. offset = me.css(pos).offset(),
  46. topOffset = offset.top - 12;
  47. if (topOffset < 0)
  48. me.css('top', pos.top - topOffset);
  49. if (offset.left + me.outerWidth() + 12 > jQuery(window).width())
  50. me.css('left', pos.left - 12);
  51. }
  52. });", 'foot');
  53. }
  54. // jquery UI localization
  55. $jquery_ui_i18n = $rcmail->config->get('jquery_ui_i18n', array('datepicker'));
  56. if (count($jquery_ui_i18n) > 0) {
  57. $lang_l = str_replace('_', '-', substr($_SESSION['language'], 0, 5));
  58. $lang_s = substr($_SESSION['language'], 0, 2);
  59. foreach ($jquery_ui_i18n as $package) {
  60. if (file_exists($this->home . "/js/i18n/jquery.ui.$package-$lang_l.js")) {
  61. $this->include_script("js/i18n/jquery.ui.$package-$lang_l.js");
  62. }
  63. else
  64. if (file_exists($this->home . "/js/i18n/jquery.ui.$package-$lang_s.js")) {
  65. $this->include_script("js/i18n/jquery.ui.$package-$lang_s.js");
  66. }
  67. }
  68. }
  69. // Date format for datepicker
  70. $date_format = $rcmail->config->get('date_format', 'Y-m-d');
  71. $date_format = strtr($date_format, array(
  72. 'y' => 'y',
  73. 'Y' => 'yy',
  74. 'm' => 'mm',
  75. 'n' => 'm',
  76. 'd' => 'dd',
  77. 'j' => 'd',
  78. ));
  79. $rcmail->output->set_env('date_format', $date_format);
  80. }
  81. public static function miniColors()
  82. {
  83. if (in_array('miniColors', self::$features)) {
  84. return;
  85. }
  86. self::$features[] = 'miniColors';
  87. $ui_theme = self::$ui_theme;
  88. $rcube = rcube::get_instance();
  89. $script = 'plugins/jqueryui/js/jquery.minicolors.min.js';
  90. $css = "plugins/jqueryui/themes/$ui_theme/jquery.minicolors.css";
  91. if (!file_exists(INSTALL_PATH . $css)) {
  92. $css = "plugins/jqueryui/themes/larry/jquery.minicolors.css";
  93. }
  94. $rcube->output->include_css($css);
  95. $rcube->output->add_header(html::tag('script', array('type' => "text/javascript", 'src' => $script)));
  96. $rcube->output->add_script('$.fn.miniColors = $.fn.minicolors; $("input.colors").minicolors()', 'docready');
  97. }
  98. public static function tagedit()
  99. {
  100. if (in_array('tagedit', self::$features)) {
  101. return;
  102. }
  103. self::$features[] = 'tagedit';
  104. $script = 'plugins/jqueryui/js/jquery.tagedit.js';
  105. $rcube = rcube::get_instance();
  106. $ui_theme = self::$ui_theme;
  107. $css = "plugins/jqueryui/themes/$ui_theme/tagedit.css";
  108. if (!file_exists(INSTALL_PATH . $css)) {
  109. $css = "plugins/jqueryui/themes/larry/tagedit.css";
  110. }
  111. $rcube->output->include_css($css);
  112. $rcube->output->add_header(html::tag('script', array('type' => "text/javascript", 'src' => $script)));
  113. }
  114. }