Thomas Bruederli
2012-08-06 c41a86e5cc26dc8ae37ed4b3fddcaa195b1616a4
commit | author | age
48e9c1 1 <?php
T 2
3 /**
4  * jQuery UI
5  *
6  * Provide the jQuery UI library with according themes.
7  *
8  * @version 1.8.18
9  * @author Cor Bosman <roundcube@wa.ter.net>
10  * @author Thomas Bruederli <roundcube@gmail.com>
11  */
12 class jqueryui extends rcube_plugin
13 {
14     public $noajax = true;
15
16     public function init()
17     {
18         $version = '1.8.18';
19
20         $rcmail = rcmail::get_instance();
21         $this->load_config();
22
23         // include UI scripts
24         $this->include_script("js/jquery-ui-$version.custom.min.js");
25
26         // include UI stylesheet
9f1652 27         $skin = $rcmail->config->get('skin');
48e9c1 28         $ui_map = $rcmail->config->get('jquery_ui_skin_map', array());
T 29         $ui_theme = $ui_map[$skin] ? $ui_map[$skin] : $skin;
30
31         if (file_exists($this->home . "/themes/$ui_theme/jquery-ui-$version.custom.css")) {
32             $this->include_stylesheet("themes/$ui_theme/jquery-ui-$version.custom.css");
33         }
34         else {
9f1652 35             $this->include_stylesheet("themes/larry/jquery-ui-$version.custom.css");
48e9c1 36         }
T 37
f86ee5 38         if ($ui_theme == 'larry') {
TB 39             // patch dialog position function in order to fully fit the close button into the window
40             $rcmail->output->add_script("jQuery.extend(jQuery.ui.dialog.prototype.options.position, {
41                 using: function(pos) {
edd256 42                     var me = jQuery(this),
TB 43                         offset = me.css(pos).offset(),
44                         topOffset = offset.top - 12;
45                     if (topOffset < 0)
46                         me.css('top', pos.top - topOffset);
47                     if (offset.left + me.outerWidth() + 12 > jQuery(window).width())
48                         me.css('left', pos.left - 12);
f86ee5 49                 }
TB 50             });", 'foot');
51         }
52
48e9c1 53         // jquery UI localization
T 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
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
82 }