PageRenderTime 55ms CodeModel.GetById 30ms RepoModel.GetById 1ms app.codeStats 0ms

/plugins/jqueryui/jqueryui.php

https://github.com/fretelweb/roundcubemail
PHP | 83 lines | 58 code | 10 blank | 15 comment | 9 complexity | 2c5a947ef1f7196c91306590698a80c8 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.9.1
  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 function init()
  16. {
  17. $version = '1.9.1';
  18. $rcmail = rcmail::get_instance();
  19. $this->load_config();
  20. // include UI scripts
  21. $this->include_script("js/jquery-ui-$version.custom.min.js");
  22. // include UI stylesheet
  23. $skin = $rcmail->config->get('skin');
  24. $ui_map = $rcmail->config->get('jquery_ui_skin_map', array());
  25. $ui_theme = $ui_map[$skin] ? $ui_map[$skin] : $skin;
  26. if (file_exists($this->home . "/themes/$ui_theme/jquery-ui-$version.custom.css")) {
  27. $this->include_stylesheet("themes/$ui_theme/jquery-ui-$version.custom.css");
  28. }
  29. else {
  30. $this->include_stylesheet("themes/larry/jquery-ui-$version.custom.css");
  31. }
  32. if ($ui_theme == 'larry') {
  33. // patch dialog position function in order to fully fit the close button into the window
  34. $rcmail->output->add_script("jQuery.extend(jQuery.ui.dialog.prototype.options.position, {
  35. using: function(pos) {
  36. var me = jQuery(this),
  37. offset = me.css(pos).offset(),
  38. topOffset = offset.top - 12;
  39. if (topOffset < 0)
  40. me.css('top', pos.top - topOffset);
  41. if (offset.left + me.outerWidth() + 12 > jQuery(window).width())
  42. me.css('left', pos.left - 12);
  43. }
  44. });", 'foot');
  45. }
  46. // jquery UI localization
  47. $jquery_ui_i18n = $rcmail->config->get('jquery_ui_i18n', array('datepicker'));
  48. if (count($jquery_ui_i18n) > 0) {
  49. $lang_l = str_replace('_', '-', substr($_SESSION['language'], 0, 5));
  50. $lang_s = substr($_SESSION['language'], 0, 2);
  51. foreach ($jquery_ui_i18n as $package) {
  52. if (file_exists($this->home . "/js/i18n/jquery.ui.$package-$lang_l.js")) {
  53. $this->include_script("js/i18n/jquery.ui.$package-$lang_l.js");
  54. }
  55. else
  56. if (file_exists($this->home . "/js/i18n/jquery.ui.$package-$lang_s.js")) {
  57. $this->include_script("js/i18n/jquery.ui.$package-$lang_s.js");
  58. }
  59. }
  60. }
  61. // Date format for datepicker
  62. $date_format = $rcmail->config->get('date_format', 'Y-m-d');
  63. $date_format = strtr($date_format, array(
  64. 'y' => 'y',
  65. 'Y' => 'yy',
  66. 'm' => 'mm',
  67. 'n' => 'm',
  68. 'd' => 'dd',
  69. 'j' => 'd',
  70. ));
  71. $rcmail->output->set_env('date_format', $date_format);
  72. }
  73. }