Ви не можете вибрати більше 25 тем Теми мають розпочинатися з літери або цифри, можуть містити дефіси (-) і не повинні перевищувати 35 символів.

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164
  1. <?php
  2. /**
  3. * jQuery UI
  4. *
  5. * Provide the jQuery UI library with according themes.
  6. *
  7. * @version 1.10.4
  8. * @author Cor Bosman <roundcube@wa.ter.net>
  9. * @author Thomas Bruederli <roundcube@gmail.com>
  10. * @license GNU GPLv3+
  11. */
  12. class jqueryui extends rcube_plugin
  13. {
  14. public $noajax = true;
  15. public $version = '1.10.4';
  16. private static $features = array();
  17. private static $ui_theme;
  18. public function init()
  19. {
  20. $rcmail = rcmail::get_instance();
  21. // the plugin might have been force-loaded so do some sanity check first
  22. if ($rcmail->output->type != 'html' || self::$ui_theme) {
  23. return;
  24. }
  25. $this->load_config();
  26. // include UI scripts
  27. $this->include_script("js/jquery-ui-$this->version.custom.min.js");
  28. // include UI stylesheet
  29. $skin = $rcmail->config->get('skin');
  30. $ui_map = $rcmail->config->get('jquery_ui_skin_map', array());
  31. $ui_theme = $ui_map[$skin] ?: $skin;
  32. self::$ui_theme = $ui_theme;
  33. if (file_exists($this->home . "/themes/$ui_theme/jquery-ui-$this->version.custom.css")) {
  34. $this->include_stylesheet("themes/$ui_theme/jquery-ui-$this->version.custom.css");
  35. }
  36. else {
  37. $this->include_stylesheet("themes/larry/jquery-ui-$this->version.custom.css");
  38. }
  39. if ($ui_theme == 'larry') {
  40. // patch dialog position function in order to fully fit the close button into the window
  41. $rcmail->output->add_script("jQuery.extend(jQuery.ui.dialog.prototype.options.position, {
  42. using: function(pos) {
  43. var me = jQuery(this),
  44. offset = me.css(pos).offset(),
  45. topOffset = offset.top - 12;
  46. if (topOffset < 0)
  47. me.css('top', pos.top - topOffset);
  48. if (offset.left + me.outerWidth() + 12 > jQuery(window).width())
  49. me.css('left', pos.left - 12);
  50. }
  51. });", 'foot');
  52. }
  53. // jquery UI localization
  54. $jquery_ui_i18n = $rcmail->config->get('jquery_ui_i18n', array('datepicker'));
  55. if (count($jquery_ui_i18n) > 0) {
  56. $lang_l = str_replace('_', '-', substr($_SESSION['language'], 0, 5));
  57. $lang_s = substr($_SESSION['language'], 0, 2);
  58. foreach ($jquery_ui_i18n as $package) {
  59. if (file_exists($this->home . "/js/i18n/jquery.ui.$package-$lang_l.js")) {
  60. $this->include_script("js/i18n/jquery.ui.$package-$lang_l.js");
  61. }
  62. else
  63. if (file_exists($this->home . "/js/i18n/jquery.ui.$package-$lang_s.js")) {
  64. $this->include_script("js/i18n/jquery.ui.$package-$lang_s.js");
  65. }
  66. }
  67. }
  68. // Date format for datepicker
  69. $date_format = $rcmail->config->get('date_format', 'Y-m-d');
  70. $date_format = strtr($date_format, array(
  71. 'y' => 'y',
  72. 'Y' => 'yy',
  73. 'm' => 'mm',
  74. 'n' => 'm',
  75. 'd' => 'dd',
  76. 'j' => 'd',
  77. ));
  78. $rcmail->output->set_env('date_format', $date_format);
  79. }
  80. public static function miniColors()
  81. {
  82. if (in_array('miniColors', self::$features)) {
  83. return;
  84. }
  85. self::$features[] = 'miniColors';
  86. $ui_theme = self::$ui_theme;
  87. $rcube = rcube::get_instance();
  88. $script = 'plugins/jqueryui/js/jquery.miniColors.min.js';
  89. $css = "plugins/jqueryui/themes/$ui_theme/jquery.miniColors.css";
  90. if (!file_exists(INSTALL_PATH . $css)) {
  91. $css = "plugins/jqueryui/themes/larry/jquery.miniColors.css";
  92. }
  93. $rcube->output->include_css($css);
  94. $rcube->output->add_header(html::tag('script', array('type' => "text/javascript", 'src' => $script)));
  95. $rcube->output->add_script('$("input.colors").miniColors({colorValues: rcmail.env.mscolors})', 'docready');
  96. $rcube->output->set_env('mscolors', self::get_color_values());
  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. /**
  115. * Return a (limited) list of color values to be used for calendar and category coloring
  116. *
  117. * @return mixed List for colors as hex values or false if no presets should be shown
  118. */
  119. public static function get_color_values()
  120. {
  121. // selection from http://msdn.microsoft.com/en-us/library/aa358802%28v=VS.85%29.aspx
  122. return array('000000','006400','2F4F4F','800000','808000','008000',
  123. '008080','000080','800080','4B0082','191970','8B0000','008B8B',
  124. '00008B','8B008B','556B2F','8B4513','228B22','6B8E23','2E8B57',
  125. 'B8860B','483D8B','A0522D','0000CD','A52A2A','00CED1','696969',
  126. '20B2AA','9400D3','B22222','C71585','3CB371','D2691E','DC143C',
  127. 'DAA520','00FA9A','4682B4','7CFC00','9932CC','FF0000','FF4500',
  128. 'FF8C00','FFA500','FFD700','FFFF00','9ACD32','32CD32','00FF00',
  129. '00FF7F','00FFFF','5F9EA0','00BFFF','0000FF','FF00FF','808080',
  130. '708090','CD853F','8A2BE2','778899','FF1493','48D1CC','1E90FF',
  131. '40E0D0','4169E1','6A5ACD','BDB76B','BA55D3','CD5C5C','ADFF2F',
  132. '66CDAA','FF6347','8FBC8B','DA70D6','BC8F8F','9370DB','DB7093',
  133. 'FF7F50','6495ED','A9A9A9','F4A460','7B68EE','D2B48C','E9967A',
  134. 'DEB887','FF69B4','FA8072','F08080','EE82EE','87CEEB','FFA07A',
  135. 'F0E68C','DDA0DD','90EE90','7FFFD4','C0C0C0','87CEFA','B0C4DE',
  136. '98FB98','ADD8E6','B0E0E6','D8BFD8','EEE8AA','AFEEEE','D3D3D3',
  137. 'FFDEAD'
  138. );
  139. }
  140. }