PageRenderTime 48ms CodeModel.GetById 19ms RepoModel.GetById 0ms app.codeStats 0ms

/plugins/jqueryui/jqueryui.php

https://github.com/trimbakgopalghare/roundcubemail
PHP | 137 lines | 99 code | 17 blank | 21 comment | 11 complexity | da4d290c1bf64f6dcf8f4fa7234af9c9 MD5 | raw file
Possible License(s): GPL-3.0, LGPL-2.1
  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. $this->load_config();
  22. // include UI scripts
  23. $this->include_script("js/jquery-ui-$this->version.custom.min.js");
  24. // include UI stylesheet
  25. $skin = $rcmail->config->get('skin');
  26. $ui_map = $rcmail->config->get('jquery_ui_skin_map', array());
  27. $ui_theme = $ui_map[$skin] ?: $skin;
  28. self::$ui_theme = $ui_theme;
  29. if (file_exists($this->home . "/themes/$ui_theme/jquery-ui-$this->version.custom.css")) {
  30. $this->include_stylesheet("themes/$ui_theme/jquery-ui-$this->version.custom.css");
  31. }
  32. else {
  33. $this->include_stylesheet("themes/larry/jquery-ui-$this->version.custom.css");
  34. }
  35. if ($ui_theme == 'larry') {
  36. // patch dialog position function in order to fully fit the close button into the window
  37. $rcmail->output->add_script("jQuery.extend(jQuery.ui.dialog.prototype.options.position, {
  38. using: function(pos) {
  39. var me = jQuery(this),
  40. offset = me.css(pos).offset(),
  41. topOffset = offset.top - 12;
  42. if (topOffset < 0)
  43. me.css('top', pos.top - topOffset);
  44. if (offset.left + me.outerWidth() + 12 > jQuery(window).width())
  45. me.css('left', pos.left - 12);
  46. }
  47. });", 'foot');
  48. }
  49. // jquery UI localization
  50. $jquery_ui_i18n = $rcmail->config->get('jquery_ui_i18n', array('datepicker'));
  51. if (count($jquery_ui_i18n) > 0) {
  52. $lang_l = str_replace('_', '-', substr($_SESSION['language'], 0, 5));
  53. $lang_s = substr($_SESSION['language'], 0, 2);
  54. foreach ($jquery_ui_i18n as $package) {
  55. if (file_exists($this->home . "/js/i18n/jquery.ui.$package-$lang_l.js")) {
  56. $this->include_script("js/i18n/jquery.ui.$package-$lang_l.js");
  57. }
  58. else
  59. if (file_exists($this->home . "/js/i18n/jquery.ui.$package-$lang_s.js")) {
  60. $this->include_script("js/i18n/jquery.ui.$package-$lang_s.js");
  61. }
  62. }
  63. }
  64. // Date format for datepicker
  65. $date_format = $rcmail->config->get('date_format', 'Y-m-d');
  66. $date_format = strtr($date_format, array(
  67. 'y' => 'y',
  68. 'Y' => 'yy',
  69. 'm' => 'mm',
  70. 'n' => 'm',
  71. 'd' => 'dd',
  72. 'j' => 'd',
  73. ));
  74. $rcmail->output->set_env('date_format', $date_format);
  75. }
  76. public static function miniColors()
  77. {
  78. if (in_array('miniColors', self::$features)) {
  79. return;
  80. }
  81. self::$features[] = 'miniColors';
  82. $ui_theme = self::$ui_theme;
  83. $rcube = rcube::get_instance();
  84. $script = 'plugins/jqueryui/js/jquery.miniColors.min.js';
  85. $css = "plugins/jqueryui/themes/$ui_theme/jquery.miniColors.css";
  86. if (!file_exists(INSTALL_PATH . $css)) {
  87. $css = "plugins/jqueryui/themes/larry/jquery.miniColors.css";
  88. }
  89. $rcube->output->include_css($css);
  90. $rcube->output->add_header(html::tag('script', array('type' => "text/javascript", 'src' => $script)));
  91. $rcube->output->add_script('$("input.colors").miniColors({colorValues: rcmail.env.mscolors})', 'docready');
  92. $rcube->output->set_env('mscolors', self::get_color_values());
  93. }
  94. /**
  95. * Return a (limited) list of color values to be used for calendar and category coloring
  96. *
  97. * @return mixed List for colors as hex values or false if no presets should be shown
  98. */
  99. public static function get_color_values()
  100. {
  101. // selection from http://msdn.microsoft.com/en-us/library/aa358802%28v=VS.85%29.aspx
  102. return array('000000','006400','2F4F4F','800000','808000','008000',
  103. '008080','000080','800080','4B0082','191970','8B0000','008B8B',
  104. '00008B','8B008B','556B2F','8B4513','228B22','6B8E23','2E8B57',
  105. 'B8860B','483D8B','A0522D','0000CD','A52A2A','00CED1','696969',
  106. '20B2AA','9400D3','B22222','C71585','3CB371','D2691E','DC143C',
  107. 'DAA520','00FA9A','4682B4','7CFC00','9932CC','FF0000','FF4500',
  108. 'FF8C00','FFA500','FFD700','FFFF00','9ACD32','32CD32','00FF00',
  109. '00FF7F','00FFFF','5F9EA0','00BFFF','0000FF','FF00FF','808080',
  110. '708090','CD853F','8A2BE2','778899','FF1493','48D1CC','1E90FF',
  111. '40E0D0','4169E1','6A5ACD','BDB76B','BA55D3','CD5C5C','ADFF2F',
  112. '66CDAA','FF6347','8FBC8B','DA70D6','BC8F8F','9370DB','DB7093',
  113. 'FF7F50','6495ED','A9A9A9','F4A460','7B68EE','D2B48C','E9967A',
  114. 'DEB887','FF69B4','FA8072','F08080','EE82EE','87CEEB','FFA07A',
  115. 'F0E68C','DDA0DD','90EE90','7FFFD4','C0C0C0','87CEFA','B0C4DE',
  116. '98FB98','ADD8E6','B0E0E6','D8BFD8','EEE8AA','AFEEEE','D3D3D3',
  117. 'FFDEAD'
  118. );
  119. }
  120. }