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