├── .gitignore
├── .mailmap
├── CHANGELOG.md
├── CREDITS
├── LICENSE
├── README.md
├── Snippets.php
├── core
├── SnippetAddCommand.php
├── SnippetDeleteCommand.php
├── SnippetGetCommand.php
├── SnippetSearchCommand.php
├── SnippetUpdateCommand.php
├── Snippets.API.php
└── install_functions.php
├── doc
├── create_snippet.png
├── usage_1_select_snippet.png
└── usage_2_snippet_inserted.png
├── files
├── README.md
├── jquery-textrange.js
├── jquery.qtip.min.css
├── jquery.qtip.min.js
├── snippets.css
└── snippets.js
├── lang
├── strings_english.txt
├── strings_french.txt
├── strings_german.txt
├── strings_korean.txt
└── strings_spanish.txt
└── pages
├── config.php
├── config_page.php
├── snippet_create.php
├── snippet_list.php
└── snippet_list_action.php
/.gitignore:
--------------------------------------------------------------------------------
1 | *.swp
2 | .idea/
3 | .DS_Store
4 |
5 |
--------------------------------------------------------------------------------
/.mailmap:
--------------------------------------------------------------------------------
1 | Amethyst Reese
2 |
--------------------------------------------------------------------------------
/CHANGELOG.md:
--------------------------------------------------------------------------------
1 | # Snippets Plugin Change Log
2 |
3 | All notable changes to this project will be documented in this file.
4 |
5 | The format is based on [Keep a Changelog](http://keepachangelog.com/)
6 | and this project adheres to [Semantic Versioning](http://semver.org/)
7 | specification.
8 |
9 | --------------------------------------------------------------------------------
10 |
11 | ## [2.5.0] - 2024-01-05
12 |
13 | ### Added
14 |
15 | - REST APIs, thanks to @vboctor
16 | [#66](https://github.com/mantisbt-plugins/snippets/issues/66)
17 | [#68](https://github.com/mantisbt-plugins/snippets/issues/68)
18 |
19 | ### Fixed
20 |
21 | - Page redirections trigger a deprecation warning since MantisBT 2.26.0
22 | [#70](https://github.com/mantisbt-plugins/snippets/issues/70)
23 |
24 |
25 | ## [2.4.1] - 2022-08-04
26 |
27 | ### Fixed
28 |
29 | - Snippet selects are not in expected tab order on Bug Update page
30 | [#63](https://github.com/mantisbt-plugins/snippets/issues/63)
31 |
32 |
33 | ## [2.4.0] - 2022-02-06
34 |
35 | ### Changed
36 |
37 | - Add button to jump to Create Snippet section from Edit Snippets page
38 | [#35](https://github.com/mantisbt-plugins/snippets/issues/35)
39 | - Replace select+Go button by Edit/Delete buttons
40 | [#36](https://github.com/mantisbt-plugins/snippets/issues/36)
41 | - Add tooltip to "Select all" checkbox
42 | [#59](https://github.com/mantisbt-plugins/snippets/issues/59)
43 | - Improve layout of Snippets list footer
44 | [#60](https://github.com/mantisbt-plugins/snippets/issues/60)
45 | - Display message when no snippets are selected
46 | [#61](https://github.com/mantisbt-plugins/snippets/issues/61)
47 | - Adapt Edit Snippets page layout to Mantis 2.x style
48 | [#62](https://github.com/mantisbt-plugins/snippets/issues/62)
49 |
50 |
51 | ## [2.3.2] - 2021-03-31
52 |
53 | ### Fixed
54 |
55 | - New 2.3.1 install (or upgrade from < 2.3.0 to 2.3.1) fails
56 | [#55](https://github.com/mantisbt-plugins/snippets/issues/55)
57 |
58 |
59 | ## [2.3.1] - 2021-03-05
60 |
61 | ### Fixed
62 |
63 | - MantisBT install page included instead of plugin's install functions
64 | [#53](https://github.com/mantisbt-plugins/snippets/issues/53)
65 | - Install functions always included even if not needed
66 | [#54](https://github.com/mantisbt-plugins/snippets/issues/54)
67 |
68 |
69 | ## [2.3.0] - 2021-02-12
70 |
71 | ### Changed
72 |
73 | - {handler} placeholder replaced by default string if issue is not assigned
74 | [#48](https://github.com/mantisbt-plugins/snippets/issues/48)
75 | - Added page titles
76 | [#50](https://github.com/mantisbt-plugins/snippets/issues/50)
77 | - Redirect to originating page from Config page
78 | [#51](https://github.com/mantisbt-plugins/snippets/issues/51)
79 |
80 | ### Fixed
81 |
82 | - {project} and {handler} placeholders in bug_reminder_page.php
83 | [#46](https://github.com/mantisbt-plugins/snippets/issues/46)
84 | - My/Global Snippets tabs are not marked as active
85 | [#49](https://github.com/mantisbt-plugins/snippets/issues/49)
86 | - Orphaned Snippet records in the database
87 | [#52](https://github.com/mantisbt-plugins/snippets/issues/52)
88 |
89 |
90 | ## [2.2.5] - 2018-03-18
91 |
92 | ### Added
93 |
94 | - Korean translation
95 | [#42](https://github.com/mantisbt-plugins/snippets/issues/42)
96 |
97 | ### Fixed
98 |
99 | - Hide Snippets selection list when none are available
100 | [#41](https://github.com/mantisbt-plugins/snippets/issues/41)
101 |
102 |
103 | ## [2.2.4] - 2018-03-18
104 |
105 | ### Fixed
106 |
107 | - Sort Snippets selection list by name
108 | [#34](https://github.com/mantisbt-plugins/snippets/issues/34)
109 |
110 |
111 | ## [2.2.3] - 2018-03-17
112 |
113 | ### Fixed
114 |
115 | - Always replace User Placeholders with username
116 | [#37](https://github.com/mantisbt-plugins/snippets/issues/37)
117 |
118 |
119 | ## [2.2.2] - 2018-02-26
120 |
121 | ### Fixed
122 |
123 | - qTip2 library throws 'Source map error' in browser console
124 | [#32](https://github.com/mantisbt-plugins/snippets/issues/32)
125 |
126 |
127 | ## [2.2.1] - 2018-01-31
128 |
129 | ### Fixed
130 |
131 | - Can't retrieve snippets data from REST API if URL rewriting is not working
132 | [#31](https://github.com/mantisbt-plugins/snippets/issues/31)
133 |
134 |
135 | ## [2.2.0] - 2018-01-14
136 |
137 | ### Changed
138 |
139 | - Require MantisBT 2.3 or later
140 | - Use REST API instead of xmlhttprequest
141 | [#16](https://github.com/mantisbt-plugins/snippets/issues/16)
142 | - Replaced simpletip.js library with qTip2
143 | [#25](https://github.com/mantisbt-plugins/snippets/issues/25)
144 |
145 | ### Removed
146 |
147 | - Unused version information from JSON payload
148 | [#27](https://github.com/mantisbt-plugins/snippets/issues/27)
149 |
150 | ### Fixed
151 |
152 | - Tooltip not shown on snippets list page
153 | [#19](https://github.com/mantisbt-plugins/snippets/issues/19)
154 |
155 |
156 | ## [2.1.0] - 2017-10-23
157 |
158 | ### Changed
159 |
160 | - Javascript refactoring and code cleanup
161 | - Increase spacing between checkbox and label on config page
162 | [#21](https://github.com/mantisbt-plugins/snippets/issues/21)
163 | - Update jquery-textrange library to 1.4.0
164 |
165 | ### Fixed
166 |
167 | - Ensure numeric JSON fields have correct data type
168 | - HTML syntax error in config page
169 |
170 |
171 | ## [2.0.0] - 2017-07-31
172 |
173 | ### Added
174 |
175 | - Support for MantisBT 2.0
176 |
177 | ### Changed
178 |
179 | - Add ‘Manage Global Snippets’ to account menu
180 | - Hide checkbox when editing a single Snippet
181 | [#13](https://github.com/mantisbt-plugins/snippets/issues/13)
182 |
183 | ### Removed
184 |
185 | - Support for MantisBT 1.3
186 |
187 |
188 | ## [1.2.0] - 2017-07-31
189 |
190 | ### Added
191 |
192 | - Spanish translation
193 | [#17](https://github.com/mantisbt-plugins/snippets/issues/17)
194 |
195 | ### Changed
196 |
197 | - Move plugin to root
198 |
199 |
200 | ## [1.1.0] - 2016-04-19
201 |
202 | ### Changed
203 |
204 | - Don't use `user0` for unassigned issues' handler
205 | - Use current user as reporter when reporting issues
206 | - Use more descriptive placeholders (e.g. `%u` -> `{user}`)
207 | [#10](https://github.com/mantisbt-plugins/snippets/issues/10)
208 |
209 |
210 | ### Fixed
211 |
212 | - PHP errors in config page
213 | - Fix snippets for additional info field
214 | - Replace deprecated db_query_bound() calls
215 |
216 |
217 | ## [1.0.0] - 2016-01-02
218 |
219 | ### Added
220 |
221 | - Support for MantisBT 1.3
222 |
223 | ### Removed
224 |
225 | - Support for MantisBT 1.2
226 | - jQuery plugin is no longer required
227 |
228 | ### Fixed
229 |
230 | - Tooltip position outside viewable area
231 | [#8](https://github.com/mantisbt-plugins/snippets/issues/8)
232 |
233 |
234 | ## [0.6] - 2014-10-30
235 |
236 | ### Added
237 |
238 | - Allowing selection of fields on which Snippets can be used in plugin configuration
239 | [#6](https://github.com/mantisbt-plugins/snippets/issues/6)
240 |
241 |
242 | ### Changed
243 |
244 | - Minified JavaScript
245 | - Bump minimum jQuery version to 1.6
246 |
247 | ### Fixed
248 |
249 | - Text duplicated when inserting snippet with caret at beginning of textarea
250 | [#4](https://github.com/mantisbt-plugins/snippets/issues/4)
251 | - Fix behavior of Select all check box in snippet lists
252 |
253 | ## [0.5] - 2013-04-05
254 |
255 | ### Fixed
256 |
257 | - Conditional Dependency for jQuery plugin (MantisBT 1.2/1.3 compatibility)
258 |
259 |
260 | ## [0.4] - 2012-10-12
261 |
262 | ### Added
263 |
264 | - French translation
265 | - German translation
266 |
267 | ### Fixed
268 |
269 | - Internet Explorer compatibility issue
270 | - Snippets containing single quotes are truncated
271 | [#2](https://github.com/mantisbt-plugins/snippets/issues/2)
272 |
273 |
274 | ## [0.3] - 2010-04-15
275 |
276 | ### Added
277 |
278 | - Access thresholds
279 | - Tooltip docs for placeholder patterns
280 | - Snippet insertion at cursor position
281 | - Error checking for blank names and values
282 |
283 | ### Fixed
284 |
285 | - bug_id sniffing on change status page
286 | - Language consistency
287 | - Prevent SQL errors when given empty arrays
288 |
289 |
290 | ## [0.2] - 2010-03-29
291 |
292 | ### Added
293 |
294 | - Implemented placeholder patterns for snippets
295 |
296 | ### Fixed
297 |
298 | - Problem with empty snippet lists
299 | - Proper cleaning of snippets for usage
300 |
301 |
302 | ## [0.1] - 2010-03-22
303 |
304 | ### Added
305 |
306 | - Initial release
307 |
308 |
309 | [Unreleased]: https://github.com/mantisbt-plugins/snippets/compare/v2.5.0...HEAD
310 |
311 | [2.5.0]: https://github.com/mantisbt-plugins/snippets/compare/v2.4.1...v2.5.0
312 | [2.4.1]: https://github.com/mantisbt-plugins/snippets/compare/v2.4.0...v2.4.1
313 | [2.4.0]: https://github.com/mantisbt-plugins/snippets/compare/v2.3.2...v2.4.0
314 | [2.3.2]: https://github.com/mantisbt-plugins/snippets/compare/v2.3.1...v2.3.2
315 | [2.3.1]: https://github.com/mantisbt-plugins/snippets/compare/v2.3.0...v2.3.1
316 | [2.3.0]: https://github.com/mantisbt-plugins/snippets/compare/v2.2.5...v2.3.0
317 | [2.2.5]: https://github.com/mantisbt-plugins/snippets/compare/v2.2.4...v2.2.5
318 | [2.2.4]: https://github.com/mantisbt-plugins/snippets/compare/v2.2.3...v2.2.4
319 | [2.2.3]: https://github.com/mantisbt-plugins/snippets/compare/v2.2.2...v2.2.3
320 | [2.2.2]: https://github.com/mantisbt-plugins/snippets/compare/v2.2.1...v2.2.2
321 | [2.2.1]: https://github.com/mantisbt-plugins/snippets/compare/v2.2.0...v2.2.1
322 | [2.2.0]: https://github.com/mantisbt-plugins/snippets/compare/v2.1.0...v2.2.0
323 | [2.1.0]: https://github.com/mantisbt-plugins/snippets/compare/v2.0.0...v2.1.0
324 | [2.0.0]: https://github.com/mantisbt-plugins/snippets/compare/v1.2.0...v2.0.0
325 |
326 | [1.2.0]: https://github.com/mantisbt-plugins/snippets/compare/v1.1.0...v1.2.0
327 | [1.1.0]: https://github.com/mantisbt-plugins/snippets/compare/v1.0.0...v1.1.0
328 | [1.0.0]: https://github.com/mantisbt-plugins/snippets/compare/v0.6...v1.0.0
329 |
330 | [0.6]: https://github.com/mantisbt-plugins/snippets/compare/v0.5...v0.6
331 | [0.5]: https://github.com/mantisbt-plugins/snippets/compare/v0.4...v0.5
332 | [0.4]: https://github.com/mantisbt-plugins/snippets/compare/v0.3...v0.4
333 | [0.3]: https://github.com/mantisbt-plugins/snippets/compare/v0.2...v0.3
334 | [0.2]: https://github.com/mantisbt-plugins/snippets/compare/v0.1...v0.2
335 | [0.1]: https://github.com/mantisbt-plugins/snippets/compare/25fd763c463de359cc7f83e9bdd30ea3e8f58cdd...v0.1
336 |
--------------------------------------------------------------------------------
/CREDITS:
--------------------------------------------------------------------------------
1 | Code
2 | ----
3 |
4 | See GitHub [Contributors](https://github.com/mantisbt-plugins/snippets/graphs/contributors) page.
5 |
6 |
7 | Translations
8 | ------------
9 |
10 | - French: Olivier Sannier
11 | - German: Roland Becker
12 | - Spanish: Dídac García
13 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | Copyright (c) 2010 - 2012 Amethyst Reese
2 | Copyright (c) 2012 - 2021 MantisBT Team - mantisbt-dev@lists.sourceforge.net
3 |
4 | Permission is hereby granted, free of charge, to any person
5 | obtaining a copy of this software and associated documentation
6 | files (the "Software"), to deal in the Software without
7 | restriction, including without limitation the rights to use,
8 | copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the
10 | Software is furnished to do so, subject to the following
11 | conditions:
12 |
13 | The above copyright notice and this permission notice shall be
14 | included in all copies or substantial portions of the Software.
15 |
16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
18 | OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
20 | HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
21 | WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
22 | FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
23 | OTHER DEALINGS IN THE SOFTWARE.
24 |
25 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # Snippets plugin for MantisBT
2 |
3 | Copyright (c) 2010 - 2012 Amethyst Reese - https://noswap.com
4 | Copyright (c) 2012 - 2021 MantisBT Team - mantisbt-dev@lists.sourceforge.net
5 |
6 | Released under the [MIT license](https://opensource.org/licenses/MIT)
7 |
8 | See the [Changelog](https://github.com/mantisbt-plugins/snippets/blob/master/CHANGELOG.md).
9 |
10 |
11 | ## Description
12 |
13 | Define snippets of text that can be easily pasted into text fields.
14 |
15 |
16 | ## Requirements
17 |
18 | The plugin requires [MantisBT](https://mantisbt.org/) version 2.3 or higher.
19 |
20 | If you need compatibility with older releases of MantisBT, please use [legacy
21 | versions](https://github.com/mantisbt-plugins/snippets/releases) of the plugin,
22 | as per table below:
23 |
24 | | MantisBT version | Plugin version |
25 | |:----------------:|:-------------------------------------------------------------------------------------------:|
26 | | 1.3 | 1.x ([master-1.3.x branch](https://github.com/mantisbt-plugins/snippets/tree/master-1.3.x)) |
27 | | 1.2 | [0.6](https://github.com/mantisbt-plugins/snippets/releases/tag/v0.6) |
28 |
29 |
30 | ## Installation
31 |
32 | 1. Download or clone a copy of the [plugin's code](https://github.com/mantisbt-plugins/snippets).
33 | 2. Copy the plugin (the `Snippets/` directory) into your Mantis
34 | installation's `plugins/` directory.
35 | 3. While logged into your Mantis installation as an administrator, go to
36 | *Manage -> Manage Plugins*.
37 | 4. In the *Available Plugins* list, you'll find the *Snippets* plugin;
38 | click the **Install** link.
39 | 5. In the *Installed Plugins* list, click on the **Snippets** plugin to configure it.
40 |
41 |
42 | ## Usage
43 |
44 | ### Managing Snippets
45 |
46 | Once the plugin is installed and configured, you need to define at least one
47 | Snippet, otherwise the selection list will not be shown.
48 |
49 | - Global snippets can be managed from *Manage > Manage Plugins*.
50 | - User-specific snippets can be managed from *My Account > My Snippets*.
51 |
52 | The following placeholders are supported in the Snippet's text; they will be
53 | replaced by the corresponding contents when inserted:
54 |
55 | | Placeholder | Description |
56 | |:------------:|-------------------------|
57 | | {user} | your username |
58 | | {reporter} | the bug reporter's name |
59 | | {handler} | the bug handler's name |
60 | | {project} | the project name |
61 |
62 | 
63 |
64 | ### Using Snippets
65 |
66 | Each configured text field will have a selection list above it, which can be
67 | used to pick the desired Snippet.
68 |
69 | 
70 |
71 | Once selection is made, the Snippet's text will be inserted in the field at the
72 | current position. If text is currently selected, the Snippet will replace the
73 | selection.
74 |
75 | 
76 |
77 | By default only the *Bug Note* field is configured to use Snippets.
78 | Other *text* fields (*Description*, *Steps To Reproduce* as well as *Additional
79 | Information*) can be setup to use Snippets via configuration page
80 | *Manage > Global Snippets > Configuration*.
81 |
82 | ### REST API
83 |
84 | The following public API endpoints can be used to manage Snippets.
85 |
86 | Base URL is https://example.com/mantisbt/api/rest/plugins/Snippets
87 |
88 | #### GET /search
89 |
90 | Search for and return a list of Snippets available to the user.
91 |
92 | Parameters:
93 | - `query`: Return only Snippets having a title or contents matching the given
94 | search string. Default is no filtering.
95 | - `limit`: Limit the number of Snippets returned. Default is 10.
96 |
97 | #### GET /
98 |
99 | Retrieve the list of Global or the user's Personal Snippets.
100 |
101 | Parameters:
102 | - `global`: 1 for global Snippets, 0 for personal Snippets. Default is 0.
103 |
104 | #### POST /
105 |
106 | Create a new snippet. Provide data as JSON body
107 |
108 | ```json
109 | {
110 | "name": "Snippet's name",
111 | "text": "Snippet's body",
112 | "global": true
113 | }
114 | ```
115 |
116 | If *global* is `false`, then a personal Snippet will be created for the user
117 | calling the API endpoint.
118 |
119 | #### PUT /{SnippetId}
120 |
121 | Update an existing Snippet.
122 | Note that *global* state cannot be changed.
123 |
124 | ```json
125 | {
126 | "name": "New name",
127 | "text": "New body"
128 | }
129 | ```
130 |
131 | #### DELETE /{SnippetId}
132 |
133 | Delete snippet.
134 |
135 |
136 | ## Support
137 |
138 | The following support channels are available if you wish to file a
139 | [bug report](https://github.com/mantisbt-plugins/snippets/issues/new),
140 | or have questions related to use and installation:
141 |
142 | - [GitHub issues tracker](https://github.com/mantisbt-plugins/snippets/issues)
143 | - MantisBT [Gitter chat room](https://matrix.to/#/#mantisbt-plugins:gitter.im)
144 | - If you feel lucky you may also want to try the legacy
145 | [#mantisbt IRC channel](https://webchat.freenode.net/?channels=%23mantisbt)
146 | on Freenode (irc://freenode.net/mantisbt)
147 | but since hardly anyone goes there nowadays, you may not get any response.
148 |
--------------------------------------------------------------------------------
/Snippets.php:
--------------------------------------------------------------------------------
1 | name = plugin_lang_get( "name" );
15 | $this->description = plugin_lang_get( "description" );
16 | $this->page = "config_page";
17 |
18 | $this->version = self::VERSION;
19 |
20 | $this->requires = array(
21 | "MantisCore" => "2.3.0",
22 | );
23 |
24 | $this->author = "Amethyst Reese, Damien Regad and MantisBT Team";
25 | $this->contact = "mantisbt-dev@lists.sourceforge.net";
26 | $this->url = "https://github.com/mantisbt-plugins/snippets";
27 | }
28 |
29 | public function config() {
30 | return array(
31 | "edit_global_threshold" => ADMINISTRATOR,
32 | "use_global_threshold" => REPORTER,
33 | "edit_own_threshold" => REPORTER,
34 | "textarea_names" => "bugnote_text",
35 | );
36 | }
37 |
38 | public function errors() {
39 | return array(
40 | "name_empty" => plugin_lang_get( "error_name_empty" ),
41 | "value_empty" => plugin_lang_get( "error_value_empty" ),
42 | );
43 | }
44 |
45 | public function hooks() {
46 | return array(
47 | "EVENT_MENU_ACCOUNT" => "menu_account",
48 | "EVENT_MENU_MANAGE" => "menu_manage",
49 |
50 | "EVENT_LAYOUT_RESOURCES" => "resources",
51 |
52 | "EVENT_MANAGE_USER_DELETE" => "user_delete",
53 |
54 | 'EVENT_REST_API_ROUTES' => 'routes',
55 | );
56 | }
57 |
58 | public function init() {
59 | $t_core_path = dirname( __FILE__ ) . '/core/';
60 | require_once( $t_core_path . 'Snippets.API.php' );
61 | require_once( $t_core_path . 'SnippetGetCommand.php' );
62 | require_once( $t_core_path . 'SnippetAddCommand.php' );
63 | require_once( $t_core_path . 'SnippetUpdateCommand.php' );
64 | require_once( $t_core_path . 'SnippetDeleteCommand.php' );
65 | require_once( $t_core_path . 'SnippetSearchCommand.php' );
66 | }
67 |
68 | /**
69 | * Hook for EVENT_MENU_ACCOUNT.
70 | *
71 | * Adds "My Snippets" and "Global Snippets" menu items.
72 | *
73 | * @return array
74 | *
75 | * @noinspection PhpUnused
76 | */
77 | public function menu_account() {
78 | $t_return = array();
79 |
80 | if( access_has_global_level( plugin_config_get( "edit_own_threshold" )
81 | ) ) {
82 | $page = plugin_page( "snippet_list" );
83 | $label = plugin_lang_get( "list_title" );
84 |
85 | $t_return[] = "$label";
86 | }
87 |
88 | $t_menu_item = $this->menu_manage();
89 | if( $t_menu_item ) {
90 | $t_return[] = $t_menu_item;
91 | }
92 |
93 | return $t_return;
94 | }
95 |
96 | /**
97 | * Hook for EVENT_MENU_MANAGE.
98 | *
99 | * Adds "Global Snippets" menu item.
100 | *
101 | * @return string
102 | */
103 | public function menu_manage() {
104 | if( access_has_global_level( plugin_config_get( "edit_global_threshold" ) ) ) {
105 | $page = plugin_page( "snippet_list" ) . Snippet::global_url();
106 | $label = plugin_lang_get( "list_global_title" );
107 |
108 | return '' . $label . '';
109 | }
110 | return '';
111 | }
112 |
113 | /**
114 | * Hook for EVENT_LAYOUT_RESOURCES.
115 | *
116 | * Adds "Global Snippets" menu item.
117 | *
118 | * @return string
119 | */
120 | public function resources() {
121 | return '
122 |
123 |
124 |
125 |
126 | ';
127 | }
128 |
129 | /**
130 | * Hook for EVENT_MANAGE_USER_DELETE.
131 | *
132 | * When deleting a user's account, cleanup their Snippets.
133 | *
134 | * @param string $event
135 | * @param int $user_id
136 | *
137 | * @noinspection PhpUnusedParameterInspection
138 | */
139 | public function user_delete( $event, $user_id ) {
140 | Snippet::delete_by_user_id( $user_id );
141 | }
142 |
143 | /**
144 | * Hook for EVENT_REST_API_ROUTES.
145 | *
146 | * Add the RESTful routes handled by this plugin.
147 | *
148 | * @param string $p_event_name The event name
149 | * @param array $p_event_args The event arguments
150 | * @return void
151 | *
152 | * @noinspection PhpUnusedParameterInspection, PhpVariableIsUsedOnlyInClosureInspection
153 | */
154 | public function routes( $p_event_name, $p_event_args ) {
155 | /** @var App $t_app */
156 | $t_app = $p_event_args['app'];
157 | $t_plugin = $this;
158 | $t_app->group(
159 | plugin_route_group(),
160 | function() use ( $t_app, $t_plugin ) {
161 | $t_app->get( '/help', [ $t_plugin, 'route_help' ] );
162 |
163 | $t_app->get( '/data', [ $t_plugin, 'route_data' ] );
164 | $t_app->get( '/data/{bug_id}', [ $t_plugin, 'route_data' ] );
165 |
166 | $t_app->get( '[/]', [ $t_plugin, 'route_snippet_get' ] );
167 | $t_app->post( '[/]', [ $t_plugin, 'route_snippet_add' ] );
168 | $t_app->put( '/{snippet_id}', [ $t_plugin, 'route_snippet_update' ] );
169 | $t_app->delete( '/{snippet_id}', [ $t_plugin, 'route_snippet_delete' ] );
170 | $t_app->get( '/search', [ $t_plugin, 'route_search' ] );
171 | }
172 | );
173 | }
174 |
175 | public function schema() {
176 | return array(
177 | # 2010-03-18
178 | 0 => array( "CreateTableSQL", array( plugin_table( "snippet" ), "
179 | id I NOTNULL UNSIGNED AUTOINCREMENT PRIMARY,
180 | user_id I NOTNULL UNSIGNED,
181 | type I NOTNULL UNSIGNED,
182 | name C(128) NOTNULL,
183 | value XL NOTNULL
184 | ")),
185 |
186 | # 2.3.0
187 | 1 => array( "UpdateFunction", "delete_orphans" ),
188 | );
189 | }
190 |
191 | public function upgrade( $p_schema ) {
192 | if( $p_schema == 1 ) {
193 | require_once( 'core/install_functions.php' );
194 | }
195 | return true;
196 | }
197 |
198 | /**
199 | * REST API for adding a snippet.
200 | *
201 | * @param Slim\Http\Request $p_request
202 | * @param Slim\Http\Response $p_response
203 | * @param array $p_args
204 | *
205 | * @return Slim\Http\Response
206 | * @throws ClientException
207 | *
208 | * @noinspection PhpUnusedParameterInspection
209 | */
210 | public function route_snippet_add( $p_request, $p_response, $p_args ) {
211 | plugin_push_current( $this->basename );
212 |
213 | $t_data = array(
214 | 'payload' => $p_request->getParsedBody()
215 | );
216 |
217 | $t_command = new SnippetAddCommand( $t_data );
218 | $t_result = $t_command->execute();
219 |
220 | plugin_pop_current();
221 |
222 | return $p_response
223 | ->withStatus( HTTP_STATUS_CREATED )
224 | ->withJson( $t_result );
225 | }
226 |
227 | /**
228 | * REST API for updating a snippet.
229 | *
230 | * @param Slim\Http\Request $p_request
231 | * @param Slim\Http\Response $p_response
232 | * @param array $p_args
233 | *
234 | * @return Slim\Http\Response
235 | * @throws ClientException
236 | */
237 | public function route_snippet_update( $p_request, $p_response, $p_args ) {
238 | plugin_push_current( $this->basename );
239 |
240 | $t_data = array(
241 | 'query' => array( 'id' => isset( $p_args['snippet_id'] ) ? (int)$p_args['snippet_id'] : 0 ),
242 | 'payload' => $p_request->getParsedBody()
243 | );
244 |
245 | $t_command = new SnippetUpdateCommand( $t_data );
246 | $t_result = $t_command->execute();
247 |
248 | plugin_pop_current();
249 |
250 | return $p_response
251 | ->withStatus( HTTP_STATUS_SUCCESS )
252 | ->withJson( $t_result );
253 | }
254 |
255 | /**
256 | * REST API for deleting a snippet by id.
257 | *
258 | * @param Slim\Http\Request $p_request
259 | * @param Slim\Http\Response $p_response
260 | * @param array $p_args
261 | *
262 | * @return Slim\Http\Response
263 | * @throws ClientException
264 | *
265 | * @noinspection PhpUnusedParameterInspection
266 | */
267 | public function route_snippet_delete( $p_request, $p_response, $p_args ) {
268 | plugin_push_current( $this->basename );
269 |
270 | $t_data = array(
271 | 'query' => array(
272 | 'id' => isset( $p_args['snippet_id'] ) ? (int)$p_args['snippet_id'] : 0
273 | )
274 | );
275 |
276 | $t_command = new SnippetDeleteCommand( $t_data );
277 | $t_command->execute();
278 |
279 | plugin_pop_current();
280 |
281 | return $p_response
282 | ->withStatus( HTTP_STATUS_NO_CONTENT );
283 | }
284 |
285 | /**
286 | * REST API for getting global or user specific snippets
287 | *
288 | * @param Slim\Http\Request $p_request
289 | * @param Slim\Http\Response $p_response
290 | * @param array $p_args
291 | *
292 | * @return Slim\Http\Response
293 | * @throws ClientException
294 | *
295 | * @noinspection PhpUnusedParameterInspection
296 | */
297 | public function route_snippet_get( $p_request, $p_response, $p_args ) {
298 | plugin_push_current( $this->basename );
299 |
300 | $t_query = array();
301 |
302 | $t_global = $p_request->getParam( 'global' );
303 | if( !is_null( $t_global ) ) {
304 | $t_query['global'] = $t_global;
305 | }
306 |
307 | $t_data = array(
308 | 'query' => $t_query
309 | );
310 |
311 | $t_command = new SnippetGetCommand( $t_data );
312 | $t_result = $t_command->execute();
313 |
314 | plugin_pop_current();
315 |
316 | return $p_response
317 | ->withStatus( HTTP_STATUS_SUCCESS )
318 | ->withJson( $t_result );
319 | }
320 |
321 | /**
322 | * REST API for searching accessible snippets.
323 | *
324 | * Caller can provide a search string `query` that will be matched for snippets
325 | * whose title or content contains the search string. Default is no filtering.
326 | *
327 | * Caller can provide a limit on number of snippets return. Default is 10.
328 | *
329 | * @param Slim\Http\Request $p_request
330 | * @param Slim\Http\Response $p_response
331 | * @param array $p_args
332 | *
333 | * @return Slim\Http\Response
334 | * @throws ClientException
335 | *
336 | * @noinspection PhpUnusedParameterInspection
337 | */
338 | public function route_search( $p_request, $p_response, $p_args ) {
339 | plugin_push_current( $this->basename );
340 |
341 | $t_query_data = array(
342 | 'query' => $p_request->getParam( 'query' )
343 | );
344 |
345 | $t_limit = $p_request->getParam( 'limit' );
346 | if( $t_limit ) {
347 | $t_query_data['limit'] = (int)$t_limit;
348 | }
349 |
350 | $t_data = array(
351 | 'query' => $t_query_data
352 | );
353 |
354 | $t_command = new SnippetSearchCommand( $t_data );
355 | $t_result = $t_command->execute();
356 |
357 | plugin_pop_current();
358 |
359 | return $p_response
360 | ->withStatus( HTTP_STATUS_SUCCESS )
361 | ->withJson( $t_result );
362 | }
363 |
364 | /**
365 | * RESTful route for Snippets Pattern Help (tooltip).
366 | *
367 | * Returned JSON structure
368 | * - {string} title
369 | * - {string} text
370 | *
371 | * @param Slim\Http\Request $request
372 | * @param Slim\Http\Response $response
373 | * @param array $args
374 | *
375 | * @return Slim\Http\Response
376 | *
377 | * @noinspection PhpUnused, PhpUnusedParameterInspection
378 | */
379 | public function route_help( $request, $response, $args ) {
380 | plugin_push_current( $this->basename );
381 |
382 | $t_help = array(
383 | 'title' => plugin_lang_get( 'pattern_title' ),
384 | 'text' => plugin_lang_get( 'pattern_help' ),
385 | );
386 |
387 | plugin_pop_current();
388 |
389 | return $response
390 | ->withStatus( HTTP_STATUS_SUCCESS )
391 | ->withJson( $t_help );
392 | }
393 |
394 | /**
395 | * RESTful route for Snippets data.
396 | *
397 | * Returned JSON structure:
398 | * - {string} version - Plugin version
399 | * - {string} selector - Configured jQuery selector for textareas
400 | * - {string} label - Language string for Snippets select's label
401 | * - {string} default - Language string for Snippets select's default
402 | * option
403 | * - {null|array} snippets - List of snippets, with following structure:
404 | * - {int} id
405 | * - {int} user_id
406 | * - {int} type
407 | * - {string} name - Snippet title
408 | * - {string} value - Snippet text
409 | *
410 | * @param Slim\Http\Request $request
411 | * @param Slim\Http\Response $response
412 | * @param array $args [bug_id = Bug Id for patterns
413 | * replacement]
414 | *
415 | * @return Slim\Http\Response
416 | *
417 | * @noinspection PhpUnused, PhpUnusedParameterInspection
418 | */
419 | public function route_data( $request, $response, $args ) {
420 | plugin_push_current( $this->basename );
421 |
422 | # Set the reference Bug Id for placeholders replacements
423 | if( isset( $args['bug_id'] ) ) {
424 | $t_bug_id = (int)$args['bug_id'];
425 | } else {
426 | $t_bug_id = 0;
427 | }
428 |
429 | # Load snippets available to the user
430 | $t_use_global = access_has_global_level( plugin_config_get( 'use_global_threshold' ) );
431 | $t_user_id = -1;
432 | if( access_has_global_level( plugin_config_get( 'edit_own_threshold' ) ) ) {
433 | $t_user_id = auth_get_current_user_id();
434 | }
435 | $t_snippets = Snippet::load_by_type_user( 0, $t_user_id, $t_use_global );
436 | $t_snippets = Snippet::clean( $t_snippets, Snippet::TARGET_FORM, $t_bug_id );
437 |
438 | # Split names of textareas found in 'textarea_names' option, and
439 | # make an array of "textarea[name='FIELD_NAME']" strings
440 | $t_selectors = array_map(
441 | function( $name ) {
442 | return "textarea[name='$name']";
443 | },
444 | Snippet::get_configured_field_names()
445 | );
446 |
447 | $t_data = array(
448 | # return configured jQuery selectors for textareas in "selector" field
449 | 'selector' => implode( ',', $t_selectors ),
450 | 'label' => plugin_lang_get( 'select_label' ),
451 | 'default' => plugin_lang_get( 'select_default' ),
452 | 'snippets' => array_values( $t_snippets ),
453 | );
454 |
455 | plugin_pop_current();
456 |
457 | return $response
458 | ->withStatus( HTTP_STATUS_SUCCESS )
459 | ->withJson( $t_data );
460 | }
461 | }
462 |
--------------------------------------------------------------------------------
/core/SnippetAddCommand.php:
--------------------------------------------------------------------------------
1 | name = $this->payload( 'name', '' );
52 | $this->text = $this->payload( 'text', '' );
53 | $t_global = (bool)$this->payload( 'global', true );
54 |
55 | if( is_blank( $this->name ) ) {
56 | throw new ClientException(
57 | 'Snippet name not specified',
58 | ERROR_EMPTY_FIELD,
59 | array( 'name' ) );
60 | }
61 |
62 | if( is_blank( $this->text ) ) {
63 | throw new ClientException(
64 | 'Snippet text not specified',
65 | ERROR_EMPTY_FIELD,
66 | array( 'text' ) );
67 | }
68 |
69 | if( $t_global ) {
70 | $t_threshold = plugin_config_get( 'edit_global_threshold' );
71 | if( !access_has_global_level( $t_threshold ) ) {
72 | throw new ClientException(
73 | 'User does not have access to add global snippets.',
74 | ERROR_ACCESS_DENIED );
75 | }
76 |
77 | $this->owner_id = NO_USER;
78 | } else {
79 | $t_threshold = plugin_config_get( 'edit_own_threshold' );
80 | if( !access_has_global_level( $t_threshold ) ) {
81 | throw new ClientException(
82 | 'User does not have access to add snippets.',
83 | ERROR_ACCESS_DENIED );
84 | }
85 |
86 | $this->owner_id = auth_get_current_user_id();
87 | }
88 | }
89 |
90 | /**
91 | * Execute the command.
92 | * @return array result
93 | */
94 | protected function process() {
95 | $t_snippet = new Snippet( /* type */ 0, $this->name, $this->text, $this->owner_id );
96 | $t_snippet->save();
97 |
98 | $t_results = array(
99 | 'snippets' => array(
100 | array(
101 | 'id' => $t_snippet->id,
102 | 'name' => $t_snippet->name,
103 | 'text' => $t_snippet->value
104 | )
105 | )
106 | );
107 |
108 | return $t_results;
109 | }
110 | }
111 |
--------------------------------------------------------------------------------
/core/SnippetDeleteCommand.php:
--------------------------------------------------------------------------------
1 | snippet_id = (int)$this->query( 'id' );
45 | if( !$this->snippet_id ) {
46 | throw new ClientException(
47 | 'Snippet id not specified',
48 | ERROR_EMPTY_FIELD,
49 | array( 'id' ) );
50 | }
51 |
52 | $t_snippet = Snippet::load_by_id( $this->snippet_id, /* user_id */ null );
53 | if( !$t_snippet ) {
54 | # TODO: ideally we should have a generic ENTITY_NOT_FOUND error to trigger 404 http status code
55 | # this error will trigger 500 http status code for now, it should trigge 404.
56 | # low priority since this is not used by the UI.
57 | throw new ClientException(
58 | "Snippet '" . $this->snippet_id . "' does not exist.",
59 | ERROR_GENERIC,
60 | array( $this->snippet_id )
61 | );
62 | }
63 |
64 | $t_global = $t_snippet->user_id == NO_USER;
65 |
66 | if( $t_global ) {
67 | $t_threshold = plugin_config_get( 'edit_global_threshold' );
68 | if( !access_has_global_level( $t_threshold ) ) {
69 | throw new ClientException(
70 | 'User does not have access to delete global snippets.',
71 | ERROR_ACCESS_DENIED );
72 | }
73 |
74 | $this->owner_id = NO_USER;
75 | } else {
76 | $t_threshold = plugin_config_get( 'edit_own_threshold' );
77 | if( !access_has_global_level( $t_threshold ) ) {
78 | throw new ClientException(
79 | 'User does not have access to delete snippets.',
80 | ERROR_ACCESS_DENIED );
81 | }
82 |
83 | $t_current_user_id = auth_get_current_user_id();
84 | $this->owner_id = $t_current_user_id;
85 |
86 | # users should only be able to delete their own snippets
87 | if( $t_snippet->user_id != $t_current_user_id ) {
88 | access_denied();
89 | }
90 | }
91 | }
92 |
93 | /**
94 | * Execute the command.
95 | *
96 | * @return array
97 | */
98 | protected function process() {
99 | Snippet::delete_by_id( array( $this->snippet_id ), $this->owner_id );
100 | return [];
101 | }
102 | }
103 |
--------------------------------------------------------------------------------
/core/SnippetGetCommand.php:
--------------------------------------------------------------------------------
1 | query( 'global', 0 );
43 |
44 | if( $t_global ) {
45 | $t_global_snippets_threshold = plugin_config_get( 'use_global_threshold', null, false, NO_USER );
46 | if( !access_has_global_level( $t_global_snippets_threshold ) ) {
47 | throw new ClientException(
48 | 'User does not have access to global snippets.',
49 | ERROR_ACCESS_DENIED );
50 | }
51 |
52 | $this->owner_id = NO_USER;
53 | } else {
54 | $this->owner_id = auth_get_current_user_id();
55 | }
56 | }
57 |
58 | /**
59 | * Execute the command.
60 | *
61 | * @return array result
62 | */
63 | protected function process() {
64 | $t_snippets_result = array();
65 |
66 | # global is always false, because we will explicitly include the global user id (NO_USER)
67 | # or the current user id, as appropriate
68 | $t_snippets = Snippet::load_by_type_user( 0, $this->owner_id, /* global */ false );
69 |
70 | foreach( $t_snippets as $t_snippet ) {
71 | $t_snippets_result[] = array(
72 | 'id' => $t_snippet->id,
73 | 'name' => $t_snippet->name,
74 | 'text' => $t_snippet->value
75 | );
76 | }
77 |
78 | $t_results = array(
79 | 'snippets' => $t_snippets_result,
80 | );
81 |
82 | return $t_results;
83 | }
84 | }
85 |
--------------------------------------------------------------------------------
/core/SnippetSearchCommand.php:
--------------------------------------------------------------------------------
1 | query = $this->query( 'query', '' );
60 | $this->limit = (int)$this->query( 'limit', 10 );
61 |
62 | $this->user_id = auth_get_current_user_id();
63 | }
64 |
65 | /**
66 | * Execute the command.
67 | * @return array result
68 | */
69 | protected function process() {
70 | $t_global_snippets_threshold = plugin_config_get( 'use_global_threshold', null, false, NO_USER );
71 | $t_use_global = access_has_global_level( $t_global_snippets_threshold );
72 |
73 | $t_snippets_result = array();
74 |
75 | $t_snippets = Snippet::load_by_type_user( 0, $this->user_id, $t_use_global );
76 |
77 | # Include matching snippets up to limit specified
78 | # - First start with ones where the query matches the title
79 | # - Then include ones where the query matches the content
80 | $t_included_snippets = array();
81 | $t_match_types = array( SNIPPETS_MATCH_TYPE_TITLE, SNIPPETS_MATCH_TYPE_CONTENT );
82 | foreach( $t_match_types as $t_match ) {
83 | foreach( $t_snippets as $t_snippet ) {
84 | if( isset( $t_included_snippets[$t_snippet->id] ) ) {
85 | continue;
86 | }
87 |
88 | if( self::match( $t_snippet, $this->query, $t_match ) ) {
89 | $t_snippets_result[] = array(
90 | 'id' => $t_snippet->id,
91 | 'name' => $t_snippet->name,
92 | 'text' => $t_snippet->value
93 | );
94 |
95 | $t_included_snippets[$t_snippet->id] = true;
96 | }
97 |
98 | if( count( $t_snippets_result ) >= $this->limit ) {
99 | break 2;
100 | }
101 | }
102 | }
103 |
104 | $t_results = array(
105 | 'snippets' => $t_snippets_result,
106 | );
107 |
108 | return $t_results;
109 | }
110 |
111 | private static function match( $p_snippet, $p_query, $p_match ) {
112 | if( is_blank( $p_query ) ) {
113 | return true;
114 | }
115 |
116 | if( $p_match == SNIPPETS_MATCH_TYPE_TITLE ) {
117 | if ( stripos( $p_snippet->name, $p_query ) !== false ) {
118 | return true;
119 | }
120 | }
121 |
122 | if( $p_match == SNIPPETS_MATCH_TYPE_CONTENT ) {
123 | if ( stripos( $p_snippet->value, $p_query ) !== false ) {
124 | return true;
125 | }
126 | }
127 |
128 | return false;
129 | }
130 | }
131 |
--------------------------------------------------------------------------------
/core/SnippetUpdateCommand.php:
--------------------------------------------------------------------------------
1 | snippet_id = (int)$this->query( 'id' );
59 | $this->name = $this->payload( 'name', '' );
60 | $this->text = $this->payload( 'text', '' );
61 |
62 | if( is_blank( $this->name ) ) {
63 | throw new ClientException(
64 | 'Snippet name not specified',
65 | ERROR_EMPTY_FIELD,
66 | array( 'name' ) );
67 | }
68 |
69 | if( is_blank( $this->text ) ) {
70 | throw new ClientException(
71 | 'Snippet text not specified',
72 | ERROR_EMPTY_FIELD,
73 | array( 'text' ) );
74 | }
75 |
76 | $this->snippet = Snippet::load_by_id( $this->snippet_id, /* user_id */ null );
77 | if( !$this->snippet ) {
78 | # TODO: ideally we should have a generic ENTITY_NOT_FOUND error to trigger 404 http status code
79 | # this error will trigger 500 http status code for now, it should trigge 404.
80 | # low priority since this is not used by the UI.
81 | throw new ClientException(
82 | "Snippet '" . $this->snippet_id . "' does not exist.",
83 | ERROR_GENERIC,
84 | array( $this->snippet_id )
85 | );
86 | }
87 |
88 | $t_global = $this->snippet->user_id == NO_USER;
89 |
90 | if( $t_global ) {
91 | access_ensure_global_level( plugin_config_get( 'edit_global_threshold' ) );
92 | } else {
93 | access_ensure_global_level( plugin_config_get( 'edit_own_threshold' ) );
94 | $t_current_user_id = auth_get_current_user_id();
95 |
96 | # users should only be able to delete their own snippets
97 | if( $this->snippet->user_id != $t_current_user_id ) {
98 | access_denied();
99 | }
100 | }
101 | }
102 |
103 | /**
104 | * Execute the command.
105 | * @return array result
106 | */
107 | protected function process() {
108 | $this->snippet->name = $this->name;
109 | $this->snippet->value = $this->text;
110 | $this->snippet->save();
111 |
112 | $t_results = array(
113 | 'snippets' => array(
114 | array(
115 | 'id' => $this->snippet->id,
116 | 'name' => $this->snippet->name,
117 | 'text' => $this->snippet->value
118 | )
119 | )
120 | );
121 |
122 | return $t_results;
123 | }
124 | }
125 |
--------------------------------------------------------------------------------
/core/Snippets.API.php:
--------------------------------------------------------------------------------
1 | type = $type;
36 | $this->name = $name;
37 | $this->value = $value;
38 | $this->user_id = $user_id;
39 | }
40 |
41 | /**
42 | * Create a copy of the given Snippet with strings cleaned for output.
43 | *
44 | * @param Snippet|Snippet[] $dirty Snippet object(s) to process
45 | * @param string $target Target format (VIEW or FORM)
46 | * @param int $bug_id Reference Bug Id for pattern
47 | * replacements
48 | *
49 | * @return Snippet[] Cleaned snippet objects
50 | */
51 | public static function clean( $dirty, $target = self::TARGET_VIEW, $bug_id = 0 ) {
52 | if( is_array( $dirty ) ) {
53 | $cleaned = array();
54 | foreach( $dirty as $id => $snippet ) {
55 | $cleaned[$id] = self::clean( $snippet, $target );
56 | }
57 | if( $bug_id ) {
58 | $cleaned = self::patterns( $cleaned, $bug_id );
59 | }
60 |
61 | }
62 | else {
63 | switch( $target ) {
64 | case self::TARGET_FORM:
65 | $dirty->name = string_attribute( $dirty->name );
66 | $dirty->value = string_textarea( $dirty->value );
67 | break;
68 | case self::TARGET_VIEW:
69 | default:
70 | $dirty->name = string_display_line( $dirty->name );
71 | $dirty->value = string_display( $dirty->value );
72 | break;
73 | }
74 |
75 | $cleaned = new Snippet(
76 | $dirty->type,
77 | $dirty->name,
78 | $dirty->value,
79 | $dirty->user_id
80 | );
81 | $cleaned->id = $dirty->id;
82 | }
83 |
84 | return $cleaned;
85 | }
86 |
87 | /**
88 | * Replace placeholder patterns in the snippet values with appropriate
89 | * strings before being sent to the client for usage.
90 | *
91 | * @param Snippet[] $snippets objects to process
92 | * @param int $bug_id Reference bug id; if 0, default values will
93 | * be used
94 | * (current user / current project)
95 | *
96 | * @return Snippet[] Updated snippet objects
97 | */
98 | public static function patterns( $snippets, $bug_id ) {
99 | $handler = null;
100 |
101 | $current_user = auth_get_current_user_id();
102 |
103 | if( is_int( $bug_id ) && $bug_id > 0 ) {
104 | $bug = bug_get( $bug_id );
105 | user_cache_array_rows( array(
106 | $bug->reporter_id,
107 | $bug->handler_id,
108 | $current_user,
109 | ) );
110 |
111 | $reporter = user_get_username( $bug->reporter_id );
112 |
113 | if( $bug->handler_id != NO_USER ) {
114 | $handler = user_get_username( $bug->handler_id );
115 | }
116 |
117 | $project = project_get_name( $bug->project_id );
118 | $username = user_get_username( $current_user );
119 | }
120 | else {
121 | $username = user_get_username( $current_user );
122 | $reporter = $username;
123 | $project = project_get_name( helper_get_current_project() );
124 | }
125 |
126 | if( !$handler ) {
127 | $handler = plugin_lang_get( 'no_handler' );
128 | }
129 |
130 | foreach( $snippets as $snippet ) {
131 | $snippet->value = str_replace(
132 | array(
133 | PLACEHOLDER_USER,
134 | PLACEHOLDER_REPORTER,
135 | PLACEHOLDER_HANDLER,
136 | PLACEHOLDER_PROJECT,
137 | ),
138 | array( $username, $reporter, $handler, $project ),
139 | $snippet->value
140 | );
141 | }
142 |
143 | return $snippets;
144 | }
145 |
146 | /**
147 | * Load snippets by ID.
148 | *
149 | * @param int|array Snippet ID (int or array)
150 | * @param int|null User ID or null if not to be included in the query
151 | *
152 | * @return Snippet|Snippet[] Snippet array with elements or empty array
153 | * Snippet if single id is provided and found.
154 | */
155 | public static function load_by_id( $id, $user_id ) {
156 | $snippet_table = plugin_table( "snippet" );
157 |
158 | if( is_array( $id ) ) {
159 | $ids = array_filter( $id, "is_int" );
160 |
161 | if( count( $ids ) < 1 ) {
162 | return array();
163 | }
164 |
165 | $ids = implode( ",", $ids );
166 | $t_params = array();
167 | $query = "SELECT * FROM $snippet_table WHERE id IN ($ids)";
168 |
169 | if( !is_null( $user_id ) ) {
170 | $query .= " AND user_id=" . db_param();
171 | $t_params[] = $user_id;
172 | }
173 |
174 | $result = db_query( $query, $t_params );
175 |
176 | return self::from_db_result( $result );
177 | }
178 | else {
179 | $t_params = array( $id );
180 | $query = "SELECT * FROM $snippet_table WHERE id=" . db_param();
181 |
182 | if( !is_null( $user_id ) ) {
183 | $query .= " AND user_id=" . db_param();
184 | $t_params[] = $user_id;
185 | }
186 |
187 | $result = db_query( $query, $t_params );
188 |
189 | $snippets = self::from_db_result( $result );
190 | return empty( $snippets ) ? [] : $snippets[$id];
191 | }
192 | }
193 |
194 | /**
195 | * Convert a database query result to an array of Snippet objects.
196 | *
197 | * @param IteratorAggregate $result Database query result
198 | *
199 | * @return Snippet[] objects
200 | */
201 | private static function from_db_result( $result ) {
202 | $snippets = array();
203 | while( $row = db_fetch_array( $result ) ) {
204 | $snippet = new Snippet(
205 | (int)$row['type'],
206 | $row['name'],
207 | Snippet::replace_legacy_placeholders( $row['value'] ),
208 | (int)$row['user_id']
209 | );
210 | $snippet->id = (int)$row["id"];
211 |
212 | $snippets[$snippet->id] = $snippet;
213 | }
214 |
215 | return $snippets;
216 | }
217 |
218 | /**
219 | * Replace legacy placeholders (e.g. %u) with modern ones (e.g. {user}).
220 | *
221 | * @param string $p_value The snippet to process.
222 | *
223 | * @return string The processed snippet.
224 | * @noinspection PhpUnnecessaryLocalVariableInspection
225 | */
226 | private static function replace_legacy_placeholders( $p_value ) {
227 | $t_value = $p_value;
228 | $t_value = str_replace( '%u', PLACEHOLDER_USER, $t_value );
229 | $t_value = str_replace( '%r', PLACEHOLDER_REPORTER, $t_value );
230 | $t_value = str_replace( '%h', PLACEHOLDER_HANDLER, $t_value );
231 | $t_value = str_replace( '%p', PLACEHOLDER_PROJECT, $t_value );
232 | return $t_value;
233 | }
234 |
235 | /**
236 | * Load text objects for a given field type and user id.
237 | *
238 | * @param int Field type
239 | * @param int User ID
240 | * @param boolean Include global text objects
241 | *
242 | * @return Snippet[]
243 | */
244 | public static function load_by_type_user(
245 | $type,
246 | $user_id,
247 | $include_global = true
248 | ) {
249 | $user_ids = array( (int)$user_id );
250 | if( $include_global ) {
251 | $user_ids[] = 0;
252 | }
253 | $user_ids = implode( ",", $user_ids );
254 |
255 | $snippet_table = plugin_table( "snippet" );
256 |
257 | $query = "SELECT * FROM $snippet_table WHERE type=" . db_param()
258 | . " AND user_id IN ($user_ids) ORDER BY name";
259 | $result = db_query( $query, array( $type ) );
260 |
261 | return self::from_db_result( $result );
262 | }
263 |
264 | /**
265 | * Load text objects for a given user id.
266 | *
267 | * @param int User ID
268 | *
269 | * @return Snippet[]
270 | */
271 | public static function load_by_user_id( $user_id ) {
272 | $snippet_table = plugin_table( "snippet" );
273 |
274 | $query = "SELECT * FROM $snippet_table WHERE user_id=" . db_param() . " ORDER BY name";
275 | $result = db_query( $query, array( $user_id ) );
276 |
277 | return self::from_db_result( $result );
278 | }
279 |
280 | /**
281 | * Delete snippets with the given ID.
282 | *
283 | * @param mixed $id Snippet ID (int or array)
284 | * @param int $user_id
285 | */
286 | public static function delete_by_id( $id, $user_id ) {
287 | $snippet_table = plugin_table( "snippet" );
288 |
289 | if( is_array( $id ) ) {
290 | $ids = array_filter( $id, "is_int" );
291 |
292 | if( count( $ids ) < 1 ) {
293 | return;
294 | }
295 |
296 | $ids = implode( ",", $ids );
297 |
298 | $query = "DELETE FROM $snippet_table WHERE id IN ($ids) AND user_id=" . db_param();
299 | db_query( $query, array( $user_id ) );
300 |
301 | }
302 | else {
303 | $query = "DELETE FROM $snippet_table WHERE id=" . db_param() . " AND user_id=" . db_param();
304 | db_query( $query, array( $id, $user_id ) );
305 | }
306 | }
307 |
308 | /**
309 | * Delete all text objects for a given user.
310 | *
311 | * @param int $user_id User ID
312 | */
313 | public static function delete_by_user_id( $user_id ) {
314 | $snippet_table = plugin_table( "snippet" );
315 | $query = "DELETE FROM $snippet_table WHERE user_id=" . db_param();
316 | db_query( $query, array( $user_id ) );
317 | }
318 |
319 | public static function global_url( $p_is_global = true ) {
320 | if( $p_is_global ) {
321 | return '&global=true';
322 | }
323 | return '';
324 | }
325 |
326 | /**
327 | * Returns an array with names of form fields (text areas) where snippets
328 | * should be available for selection.
329 | */
330 | public static function get_configured_field_names() {
331 | return preg_split( "/[,;\s]+/",
332 | plugin_config_get( "textarea_names", "bugnote_text" )
333 | );
334 | }
335 |
336 | /**
337 | * Returns an array of ('text area field name' => 'language resource
338 | * identifier') pairs that describe available (supported) text areas.
339 | * Values will be passed to lang_get().
340 | */
341 | public static function get_available_field_names() {
342 | return array(
343 | 'bugnote_text' => 'bugnote',
344 | 'description' => 'description',
345 | 'steps_to_reproduce' => 'steps_to_reproduce',
346 | 'additional_info' => 'additional_information',
347 | 'body' => 'reminder',
348 | );
349 | }
350 |
351 | /**
352 | * Create or update the database with the object's values.
353 | *
354 | * @return int Snippet ID if created
355 | */
356 | public function save() {
357 | $snippet_table = plugin_table( "snippet" );
358 |
359 | # create
360 | if( $this->id === null ) {
361 | $query = "INSERT INTO $snippet_table
362 | (
363 | type,
364 | name,
365 | value,
366 | user_id
367 | ) VALUES (
368 | " . db_param() . ",
369 | " . db_param() . ",
370 | " . db_param() . ",
371 | " . db_param() . "
372 | )";
373 |
374 | db_query( $query, array(
375 | $this->type,
376 | $this->name,
377 | $this->value,
378 | $this->user_id,
379 | ) );
380 |
381 | $this->id = db_insert_id( $snippet_table );
382 |
383 | # update
384 | }
385 | else {
386 | $query = "UPDATE $snippet_table SET
387 | type=" . db_param() . ",
388 | name=" . db_param() . ",
389 | value=" . db_param() . ",
390 | user_id=" . db_param() . "
391 | WHERE id=" . db_param();
392 |
393 | db_query( $query, array(
394 | $this->type,
395 | $this->name,
396 | $this->value,
397 | $this->user_id,
398 | $this->id,
399 | ) );
400 | }
401 |
402 | return $this->id;
403 | }
404 | }
405 |
--------------------------------------------------------------------------------
/core/install_functions.php:
--------------------------------------------------------------------------------
1 | 0";
21 |
22 | if( db_query( $t_query ) === false ) {
23 | return false;
24 | }
25 |
26 | return 2; // Success
27 | }
28 |
--------------------------------------------------------------------------------
/doc/create_snippet.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mantisbt-plugins/Snippets/c8cdaef7e978736c75343e688ed28f71d6c08ebd/doc/create_snippet.png
--------------------------------------------------------------------------------
/doc/usage_1_select_snippet.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mantisbt-plugins/Snippets/c8cdaef7e978736c75343e688ed28f71d6c08ebd/doc/usage_1_select_snippet.png
--------------------------------------------------------------------------------
/doc/usage_2_snippet_inserted.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mantisbt-plugins/Snippets/c8cdaef7e978736c75343e688ed28f71d6c08ebd/doc/usage_2_snippet_inserted.png
--------------------------------------------------------------------------------
/files/README.md:
--------------------------------------------------------------------------------
1 | jQuery libraries
2 | ================
3 |
4 | On top of the jQuery library itself, this plugin relies on the following
5 | bundled 3rd-party code :
6 |
7 | Name | Version | URL
8 | -----------------|----------|-------------------------------------------
9 | jquery-textrange | 1.4.0 | https://github.com/dwieeb/jquery-textrange
10 | qTip2 | 3.0.3 | http://qtip2.com/
11 |
--------------------------------------------------------------------------------
/files/jquery-textrange.js:
--------------------------------------------------------------------------------
1 | /**
2 | * jquery-textrange
3 | *
4 | * A jQuery plugin for getting, setting and replacing the selected text in input fields and textareas.
5 | * See the [README](https://github.com/dwieeb/jquery-textrange/blob/1.x/README.md) for usage and examples.
6 | *
7 | * (c) 2012-2017 Daniel Imhoff - dwieeb.com
8 | */
9 |
10 | (function(factory) {
11 |
12 | if (typeof define === 'function' && define.amd) {
13 | define(['jquery'], factory);
14 | } else if (typeof exports === 'object') {
15 | factory(require('jquery'));
16 | } else {
17 | factory(jQuery);
18 | }
19 |
20 | })(function($) {
21 |
22 | var browserType,
23 |
24 | textrange = {
25 |
26 | /**
27 | * $().textrange() or $().textrange('get')
28 | *
29 | * Retrieves an object containing the start and end location of the text range, the length of the range and the
30 | * substring of the range.
31 | *
32 | * @param (optional) property
33 | * @return An object of properties including position, start, end, length, and text or a specific property.
34 | */
35 | get: function(property) {
36 | return _textrange[browserType].get.apply(this, [property]);
37 | },
38 |
39 | /**
40 | * $().textrange('set')
41 | *
42 | * Sets the selected text of an object by specifying the start and length of the selection.
43 | *
44 | * The start and length parameters are identical to PHP's substr() function with the following changes:
45 | * - excluding start will select all the text in the field.
46 | * - passing 0 for length will set the cursor at start. See $().textrange('setcursor')
47 | *
48 | * @param (optional) start
49 | * @param (optional) length
50 | *
51 | * @see https://secure.php.net/manual/en/function.substr.php
52 | */
53 | set: function(start, length) {
54 | var s = parseInt(start),
55 | l = parseInt(length),
56 | e;
57 |
58 | if (typeof start === 'undefined') {
59 | s = 0;
60 | } else if (start < 0) {
61 | s = this[0].value.length + s;
62 | }
63 |
64 | if (typeof length !== 'undefined') {
65 | if (length >= 0) {
66 | e = s + l;
67 | } else {
68 | e = this[0].value.length + l;
69 | }
70 | }
71 |
72 | _textrange[browserType].set.apply(this, [s, e]);
73 |
74 | return this;
75 | },
76 |
77 | /**
78 | * $().textrange('setcursor')
79 | *
80 | * Sets the cursor at a position of the text field.
81 | *
82 | * @param position
83 | */
84 | setcursor: function(position) {
85 | return this.textrange('set', position, 0);
86 | },
87 |
88 | /**
89 | * $().textrange('replace')
90 | * Replaces the selected text in the input field or textarea with text.
91 | *
92 | * @param text The text to replace the selection with.
93 | */
94 | replace: function(text) {
95 | _textrange[browserType].replace.apply(this, [String(text)]);
96 |
97 | return this;
98 | },
99 |
100 | /**
101 | * Alias for $().textrange('replace')
102 | */
103 | insert: function(text) {
104 | return this.textrange('replace', text);
105 | }
106 | },
107 |
108 | _textrange = {
109 | xul: {
110 | get: function(property) {
111 | var props = {
112 | position: this[0].selectionStart,
113 | start: this[0].selectionStart,
114 | end: this[0].selectionEnd,
115 | length: this[0].selectionEnd - this[0].selectionStart,
116 | text: this.val().substring(this[0].selectionStart, this[0].selectionEnd)
117 | };
118 |
119 | return typeof property === 'undefined' ? props : props[property];
120 | },
121 |
122 | set: function(start, end) {
123 | if (typeof end === 'undefined') {
124 | end = this[0].value.length;
125 | }
126 |
127 | this[0].selectionStart = start;
128 | this[0].selectionEnd = end;
129 | },
130 |
131 | replace: function(text) {
132 | var start = this[0].selectionStart;
133 | var end = this[0].selectionEnd;
134 | var val = this.val();
135 | this.val(val.substring(0, start) + text + val.substring(end, val.length));
136 | this[0].selectionStart = start;
137 | this[0].selectionEnd = start + text.length;
138 | }
139 | },
140 |
141 | msie: {
142 | get: function(property) {
143 | var range = document.selection.createRange();
144 |
145 | if (typeof range === 'undefined') {
146 | var props = {
147 | position: 0,
148 | start: 0,
149 | end: this.val().length,
150 | length: this.val().length,
151 | text: this.val()
152 | };
153 |
154 | return typeof property === 'undefined' ? props : props[property];
155 | }
156 |
157 | var start = 0;
158 | var end = 0;
159 | var length = this[0].value.length;
160 | var lfValue = this[0].value.replace(/\r\n/g, '\n');
161 | var rangeText = this[0].createTextRange();
162 | var rangeTextEnd = this[0].createTextRange();
163 | rangeText.moveToBookmark(range.getBookmark());
164 | rangeTextEnd.collapse(false);
165 |
166 | if (rangeText.compareEndPoints('StartToEnd', rangeTextEnd) === -1) {
167 | start = -rangeText.moveStart('character', -length);
168 | start += lfValue.slice(0, start).split('\n').length - 1;
169 |
170 | if (rangeText.compareEndPoints('EndToEnd', rangeTextEnd) === -1) {
171 | end = -rangeText.moveEnd('character', -length);
172 | end += lfValue.slice(0, end).split('\n').length - 1;
173 | } else {
174 | end = length;
175 | }
176 | } else {
177 | start = length;
178 | end = length;
179 | }
180 |
181 | var props = {
182 | position: start,
183 | start: start,
184 | end: end,
185 | length: length,
186 | text: range.text
187 | };
188 |
189 | return typeof property === 'undefined' ? props : props[property];
190 | },
191 |
192 | set: function(start, end) {
193 | var range = this[0].createTextRange();
194 |
195 | if (typeof range === 'undefined') {
196 | return;
197 | }
198 |
199 | if (typeof end === 'undefined') {
200 | end = this[0].value.length;
201 | }
202 |
203 | var ieStart = start - (this[0].value.slice(0, start).split("\r\n").length - 1);
204 | var ieEnd = end - (this[0].value.slice(0, end).split("\r\n").length - 1);
205 |
206 | range.collapse(true);
207 |
208 | range.moveEnd('character', ieEnd);
209 | range.moveStart('character', ieStart);
210 |
211 | range.select();
212 | },
213 |
214 | replace: function(text) {
215 | document.selection.createRange().text = text;
216 | }
217 | }
218 | };
219 |
220 | $.fn.extend({
221 | textrange: function(arg) {
222 | var method = 'get';
223 | var options = {};
224 |
225 | if (typeof this[0] === 'undefined') {
226 | return this;
227 | }
228 |
229 | if (typeof arg === 'string') {
230 | method = arg;
231 | } else if (typeof arg === 'object') {
232 | method = arg.method || method;
233 | options = arg;
234 | }
235 |
236 | if (typeof browserType === 'undefined') {
237 | browserType = 'selectionStart' in this[0] ? 'xul' : document.selection ? 'msie' : 'unknown';
238 | }
239 |
240 | // I don't know how to support this browser. :c
241 | if (browserType === 'unknown') {
242 | return this;
243 | }
244 |
245 | // Focus on the element before operating upon it.
246 | if (!options.nofocus && document.activeElement !== this[0]) {
247 | this[0].focus();
248 | }
249 |
250 | if (typeof textrange[method] === 'function') {
251 | return textrange[method].apply(this, Array.prototype.slice.call(arguments, 1));
252 | } else {
253 | $.error("Method " + method + " does not exist in jQuery.textrange");
254 | }
255 | }
256 | });
257 | });
258 |
--------------------------------------------------------------------------------
/files/jquery.qtip.min.css:
--------------------------------------------------------------------------------
1 | #qtip-overlay.blurs,.qtip-close{cursor:pointer}.qtip{position:absolute;left:-28000px;top:-28000px;display:none;max-width:280px;min-width:50px;font-size:10.5px;line-height:12px;direction:ltr;box-shadow:none;padding:0}.qtip-content,.qtip-titlebar{position:relative;overflow:hidden}.qtip-content{padding:5px 9px;text-align:left;word-wrap:break-word}.qtip-titlebar{padding:5px 35px 5px 10px;border-width:0 0 1px;font-weight:700}.qtip-titlebar+.qtip-content{border-top-width:0!important}.qtip-close{position:absolute;right:-9px;top:-9px;z-index:11;outline:0;border:1px solid transparent}.qtip-titlebar .qtip-close{right:4px;top:50%;margin-top:-9px}* html .qtip-titlebar .qtip-close{top:16px}.qtip-icon .ui-icon,.qtip-titlebar .ui-icon{display:block;text-indent:-1000em;direction:ltr}.qtip-icon,.qtip-icon .ui-icon{-moz-border-radius:3px;-webkit-border-radius:3px;border-radius:3px;text-decoration:none}.qtip-icon .ui-icon{width:18px;height:14px;line-height:14px;text-align:center;text-indent:0;font:normal 700 10px/13px Tahoma,sans-serif;color:inherit;background:-100em -100em no-repeat}.qtip-default{border:1px solid #F1D031;background-color:#FFFFA3;color:#555}.qtip-default .qtip-titlebar{background-color:#FFEF93}.qtip-default .qtip-icon{border-color:#CCC;background:#F1F1F1;color:#777}.qtip-default .qtip-titlebar .qtip-close{border-color:#AAA;color:#111}.qtip-light{background-color:#fff;border-color:#E2E2E2;color:#454545}.qtip-light .qtip-titlebar{background-color:#f1f1f1}.qtip-dark{background-color:#505050;border-color:#303030;color:#f3f3f3}.qtip-dark .qtip-titlebar{background-color:#404040}.qtip-dark .qtip-icon{border-color:#444}.qtip-dark .qtip-titlebar .ui-state-hover{border-color:#303030}.qtip-cream{background-color:#FBF7AA;border-color:#F9E98E;color:#A27D35}.qtip-red,.qtip-red .qtip-icon,.qtip-red .qtip-titlebar .ui-state-hover{border-color:#D95252}.qtip-cream .qtip-titlebar{background-color:#F0DE7D}.qtip-cream .qtip-close .qtip-icon{background-position:-82px 0}.qtip-red{background-color:#F78B83;color:#912323}.qtip-red .qtip-titlebar{background-color:#F06D65}.qtip-red .qtip-close .qtip-icon{background-position:-102px 0}.qtip-green{background-color:#CAED9E;border-color:#90D93F;color:#3F6219}.qtip-green .qtip-titlebar{background-color:#B0DE78}.qtip-green .qtip-close .qtip-icon{background-position:-42px 0}.qtip-blue{background-color:#E5F6FE;border-color:#ADD9ED;color:#5E99BD}.qtip-blue .qtip-titlebar{background-color:#D0E9F5}.qtip-blue .qtip-close .qtip-icon{background-position:-2px 0}.qtip-shadow{-webkit-box-shadow:1px 1px 3px 1px rgba(0,0,0,.15);-moz-box-shadow:1px 1px 3px 1px rgba(0,0,0,.15);box-shadow:1px 1px 3px 1px rgba(0,0,0,.15)}.qtip-bootstrap,.qtip-rounded,.qtip-tipsy{-moz-border-radius:5px;-webkit-border-radius:5px;border-radius:5px}.qtip-rounded .qtip-titlebar{-moz-border-radius:4px 4px 0 0;-webkit-border-radius:4px 4px 0 0;border-radius:4px 4px 0 0}.qtip-youtube{-moz-border-radius:2px;-webkit-border-radius:2px;border-radius:2px;-webkit-box-shadow:0 0 3px #333;-moz-box-shadow:0 0 3px #333;box-shadow:0 0 3px #333;color:#fff;border:0 solid transparent;background:#4A4A4A;background-image:-webkit-gradient(linear,left top,left bottom,color-stop(0,#4A4A4A),color-stop(100%,#000));background-image:-webkit-linear-gradient(top,#4A4A4A 0,#000 100%);background-image:-moz-linear-gradient(top,#4A4A4A 0,#000 100%);background-image:-ms-linear-gradient(top,#4A4A4A 0,#000 100%);background-image:-o-linear-gradient(top,#4A4A4A 0,#000 100%)}.qtip-youtube .qtip-titlebar{background-color:#4A4A4A;background-color:rgba(0,0,0,0)}.qtip-youtube .qtip-content{padding:.75em;font:12px arial,sans-serif;filter:progid:DXImageTransform.Microsoft.Gradient(GradientType=0, StartColorStr=#4a4a4a, EndColorStr=#000000);-ms-filter:"progid:DXImageTransform.Microsoft.Gradient(GradientType=0,StartColorStr=#4a4a4a,EndColorStr=#000000);"}.qtip-youtube .qtip-icon{border-color:#222}.qtip-youtube .qtip-titlebar .ui-state-hover{border-color:#303030}.qtip-jtools{background:#232323;background:rgba(0,0,0,.7);background-image:-webkit-gradient(linear,left top,left bottom,from(#717171),to(#232323));background-image:-moz-linear-gradient(top,#717171,#232323);background-image:-webkit-linear-gradient(top,#717171,#232323);background-image:-ms-linear-gradient(top,#717171,#232323);background-image:-o-linear-gradient(top,#717171,#232323);border:2px solid #ddd;border:2px solid rgba(241,241,241,1);-moz-border-radius:2px;-webkit-border-radius:2px;border-radius:2px;-webkit-box-shadow:0 0 12px #333;-moz-box-shadow:0 0 12px #333;box-shadow:0 0 12px #333}.qtip-jtools .qtip-titlebar{background-color:transparent;filter:progid:DXImageTransform.Microsoft.gradient(startColorstr=#717171, endColorstr=#4A4A4A);-ms-filter:"progid:DXImageTransform.Microsoft.gradient(startColorstr=#717171,endColorstr=#4A4A4A)"}.qtip-jtools .qtip-content{filter:progid:DXImageTransform.Microsoft.gradient(startColorstr=#4A4A4A, endColorstr=#232323);-ms-filter:"progid:DXImageTransform.Microsoft.gradient(startColorstr=#4A4A4A,endColorstr=#232323)"}.qtip-jtools .qtip-content,.qtip-jtools .qtip-titlebar{background:0 0;color:#fff;border:0 dashed transparent}.qtip-jtools .qtip-icon{border-color:#555}.qtip-jtools .qtip-titlebar .ui-state-hover{border-color:#333}.qtip-cluetip{-webkit-box-shadow:4px 4px 5px rgba(0,0,0,.4);-moz-box-shadow:4px 4px 5px rgba(0,0,0,.4);box-shadow:4px 4px 5px rgba(0,0,0,.4);background-color:#D9D9C2;color:#111;border:0 dashed transparent}.qtip-cluetip .qtip-titlebar{background-color:#87876A;color:#fff;border:0 dashed transparent}.qtip-cluetip .qtip-icon{border-color:#808064}.qtip-cluetip .qtip-titlebar .ui-state-hover{border-color:#696952;color:#696952}.qtip-tipsy{background:#000;background:rgba(0,0,0,.87);color:#fff;border:0 solid transparent;font-size:11px;font-family:'Lucida Grande',sans-serif;font-weight:700;line-height:16px;text-shadow:0 1px #000}.qtip-tipsy .qtip-titlebar{padding:6px 35px 0 10px;background-color:transparent}.qtip-tipsy .qtip-content{padding:6px 10px}.qtip-tipsy .qtip-icon{border-color:#222;text-shadow:none}.qtip-tipsy .qtip-titlebar .ui-state-hover{border-color:#303030}.qtip-tipped{border:3px solid #959FA9;-moz-border-radius:3px;-webkit-border-radius:3px;border-radius:3px;background-color:#F9F9F9;color:#454545;font-weight:400;font-family:serif}.qtip-tipped .qtip-titlebar{border-bottom-width:0;color:#fff;background:#3A79B8;background-image:-webkit-gradient(linear,left top,left bottom,from(#3A79B8),to(#2E629D));background-image:-webkit-linear-gradient(top,#3A79B8,#2E629D);background-image:-moz-linear-gradient(top,#3A79B8,#2E629D);background-image:-ms-linear-gradient(top,#3A79B8,#2E629D);background-image:-o-linear-gradient(top,#3A79B8,#2E629D);filter:progid:DXImageTransform.Microsoft.gradient(startColorstr=#3A79B8, endColorstr=#2E629D);-ms-filter:"progid:DXImageTransform.Microsoft.gradient(startColorstr=#3A79B8,endColorstr=#2E629D)"}.qtip-tipped .qtip-icon{border:2px solid #285589;background:#285589}.qtip-tipped .qtip-icon .ui-icon{background-color:#FBFBFB;color:#555}.qtip-bootstrap{font-size:14px;line-height:20px;color:#333;padding:1px;background-color:#fff;border:1px solid #ccc;border:1px solid rgba(0,0,0,.2);-webkit-border-radius:6px;-moz-border-radius:6px;border-radius:6px;-webkit-box-shadow:0 5px 10px rgba(0,0,0,.2);-moz-box-shadow:0 5px 10px rgba(0,0,0,.2);box-shadow:0 5px 10px rgba(0,0,0,.2);-webkit-background-clip:padding-box;-moz-background-clip:padding;background-clip:padding-box}.qtip-bootstrap .qtip-titlebar{padding:8px 14px;margin:0;font-size:14px;font-weight:400;line-height:18px;background-color:#f7f7f7;border-bottom:1px solid #ebebeb;-webkit-border-radius:5px 5px 0 0;-moz-border-radius:5px 5px 0 0;border-radius:5px 5px 0 0}.qtip-bootstrap .qtip-titlebar .qtip-close{right:11px;top:45%;border-style:none}.qtip-bootstrap .qtip-content{padding:9px 14px}.qtip-bootstrap .qtip-icon{background:0 0}.qtip-bootstrap .qtip-icon .ui-icon{width:auto;height:auto;float:right;font-size:20px;font-weight:700;line-height:18px;color:#000;text-shadow:0 1px 0 #fff;opacity:.2;filter:alpha(opacity=20)}#qtip-overlay,#qtip-overlay div{left:0;top:0;width:100%;height:100%}.qtip-bootstrap .qtip-icon .ui-icon:hover{color:#000;text-decoration:none;cursor:pointer;opacity:.4;filter:alpha(opacity=40)}.qtip:not(.ie9haxors) div.qtip-content,.qtip:not(.ie9haxors) div.qtip-titlebar{filter:none;-ms-filter:none}.qtip .qtip-tip{margin:0 auto;overflow:hidden;z-index:10}.qtip .qtip-tip,x:-o-prefocus{visibility:hidden}.qtip .qtip-tip,.qtip .qtip-tip .qtip-vml,.qtip .qtip-tip canvas{position:absolute;color:#123456;background:0 0;border:0 dashed transparent}.qtip .qtip-tip canvas{top:0;left:0}.qtip .qtip-tip .qtip-vml{behavior:url(#default#VML);display:inline-block;visibility:visible}#qtip-overlay{position:fixed}#qtip-overlay div{position:absolute;background-color:#000;opacity:.7;filter:alpha(opacity=70);-ms-filter:"progid:DXImageTransform.Microsoft.Alpha(Opacity=70)"}.qtipmodal-ie6fix{position:absolute!important}
--------------------------------------------------------------------------------
/files/jquery.qtip.min.js:
--------------------------------------------------------------------------------
1 | /* qtip2 v3.0.3 | Plugins: tips modal viewport svg imagemap ie6 | Styles: core basic css3 | qtip2.com | Licensed MIT | Wed May 11 2016 22:31:31 */
2 |
3 | !function(a,b,c){!function(a){"use strict";"function"==typeof define&&define.amd?define(["jquery"],a):jQuery&&!jQuery.fn.qtip&&a(jQuery)}(function(d){"use strict";function e(a,b,c,e){this.id=c,this.target=a,this.tooltip=F,this.elements={target:a},this._id=S+"-"+c,this.timers={img:{}},this.options=b,this.plugins={},this.cache={event:{},target:d(),disabled:E,attr:e,onTooltip:E,lastClass:""},this.rendered=this.destroyed=this.disabled=this.waiting=this.hiddenDuringWait=this.positioning=this.triggering=E}function f(a){return a===F||"object"!==d.type(a)}function g(a){return!(d.isFunction(a)||a&&a.attr||a.length||"object"===d.type(a)&&(a.jquery||a.then))}function h(a){var b,c,e,h;return f(a)?E:(f(a.metadata)&&(a.metadata={type:a.metadata}),"content"in a&&(b=a.content,f(b)||b.jquery||b.done?(c=g(b)?E:b,b=a.content={text:c}):c=b.text,"ajax"in b&&(e=b.ajax,h=e&&e.once!==E,delete b.ajax,b.text=function(a,b){var f=c||d(this).attr(b.options.content.attr)||"Loading...",g=d.ajax(d.extend({},e,{context:b})).then(e.success,F,e.error).then(function(a){return a&&h&&b.set("content.text",a),a},function(a,c,d){b.destroyed||0===a.status||b.set("content.text",c+": "+d)});return h?f:(b.set("content.text",f),g)}),"title"in b&&(d.isPlainObject(b.title)&&(b.button=b.title.button,b.title=b.title.text),g(b.title||E)&&(b.title=E))),"position"in a&&f(a.position)&&(a.position={my:a.position,at:a.position}),"show"in a&&f(a.show)&&(a.show=a.show.jquery?{target:a.show}:a.show===D?{ready:D}:{event:a.show}),"hide"in a&&f(a.hide)&&(a.hide=a.hide.jquery?{target:a.hide}:{event:a.hide}),"style"in a&&f(a.style)&&(a.style={classes:a.style}),d.each(R,function(){this.sanitize&&this.sanitize(a)}),a)}function i(a,b){for(var c,d=0,e=a,f=b.split(".");e=e[f[d++]];)d0?setTimeout(d.proxy(a,this),b):void a.call(this)}function m(a){this.tooltip.hasClass(aa)||(clearTimeout(this.timers.show),clearTimeout(this.timers.hide),this.timers.show=l.call(this,function(){this.toggle(D,a)},this.options.show.delay))}function n(a){if(!this.tooltip.hasClass(aa)&&!this.destroyed){var b=d(a.relatedTarget),c=b.closest(W)[0]===this.tooltip[0],e=b[0]===this.options.show.target[0];if(clearTimeout(this.timers.show),clearTimeout(this.timers.hide),this!==b[0]&&"mouse"===this.options.position.target&&c||this.options.hide.fixed&&/mouse(out|leave|move)/.test(a.type)&&(c||e))try{a.preventDefault(),a.stopImmediatePropagation()}catch(f){}else this.timers.hide=l.call(this,function(){this.toggle(E,a)},this.options.hide.delay,this)}}function o(a){!this.tooltip.hasClass(aa)&&this.options.hide.inactive&&(clearTimeout(this.timers.inactive),this.timers.inactive=l.call(this,function(){this.hide(a)},this.options.hide.inactive))}function p(a){this.rendered&&this.tooltip[0].offsetWidth>0&&this.reposition(a)}function q(a,c,e){d(b.body).delegate(a,(c.split?c:c.join("."+S+" "))+"."+S,function(){var a=y.api[d.attr(this,U)];a&&!a.disabled&&e.apply(a,arguments)})}function r(a,c,f){var g,i,j,k,l,m=d(b.body),n=a[0]===b?m:a,o=a.metadata?a.metadata(f.metadata):F,p="html5"===f.metadata.type&&o?o[f.metadata.name]:F,q=a.data(f.metadata.name||"qtipopts");try{q="string"==typeof q?d.parseJSON(q):q}catch(r){}if(k=d.extend(D,{},y.defaults,f,"object"==typeof q?h(q):F,h(p||o)),i=k.position,k.id=c,"boolean"==typeof k.content.text){if(j=a.attr(k.content.attr),k.content.attr===E||!j)return E;k.content.text=j}if(i.container.length||(i.container=m),i.target===E&&(i.target=n),k.show.target===E&&(k.show.target=n),k.show.solo===D&&(k.show.solo=i.container.closest("body")),k.hide.target===E&&(k.hide.target=n),k.position.viewport===D&&(k.position.viewport=i.container),i.container=i.container.eq(0),i.at=new A(i.at,D),i.my=new A(i.my),a.data(S))if(k.overwrite)a.qtip("destroy",!0);else if(k.overwrite===E)return E;return a.attr(T,c),k.suppress&&(l=a.attr("title"))&&a.removeAttr("title").attr(ca,l).attr("title",""),g=new e(a,k,c,!!j),a.data(S,g),g}function s(a){return a.charAt(0).toUpperCase()+a.slice(1)}function t(a,b){var d,e,f=b.charAt(0).toUpperCase()+b.slice(1),g=(b+" "+va.join(f+" ")+f).split(" "),h=0;if(ua[b])return a.css(ua[b]);for(;d=g[h++];)if((e=a.css(d))!==c)return ua[b]=d,e}function u(a,b){return Math.ceil(parseFloat(t(a,b)))}function v(a,b){this._ns="tip",this.options=b,this.offset=b.offset,this.size=[b.width,b.height],this.qtip=a,this.init(a)}function w(a,b){this.options=b,this._ns="-modal",this.qtip=a,this.init(a)}function x(a){this._ns="ie6",this.qtip=a,this.init(a)}var y,z,A,B,C,D=!0,E=!1,F=null,G="x",H="y",I="width",J="height",K="top",L="left",M="bottom",N="right",O="center",P="flipinvert",Q="shift",R={},S="qtip",T="data-hasqtip",U="data-qtip-id",V=["ui-widget","ui-tooltip"],W="."+S,X="click dblclick mousedown mouseup mousemove mouseleave mouseenter".split(" "),Y=S+"-fixed",Z=S+"-default",$=S+"-focus",_=S+"-hover",aa=S+"-disabled",ba="_replacedByqTip",ca="oldtitle",da={ie:function(){var a,c;for(a=4,c=b.createElement("div");(c.innerHTML="")&&c.getElementsByTagName("i")[0];a+=1);return a>4?a:NaN}(),iOS:parseFloat((""+(/CPU.*OS ([0-9_]{1,5})|(CPU like).*AppleWebKit.*Mobile/i.exec(navigator.userAgent)||[0,""])[1]).replace("undefined","3_2").replace("_",".").replace("_",""))||E};z=e.prototype,z._when=function(a){return d.when.apply(d,a)},z.render=function(a){if(this.rendered||this.destroyed)return this;var b=this,c=this.options,e=this.cache,f=this.elements,g=c.content.text,h=c.content.title,i=c.content.button,j=c.position,k=[];return d.attr(this.target[0],"aria-describedby",this._id),e.posClass=this._createPosClass((this.position={my:j.my,at:j.at}).my),this.tooltip=f.tooltip=d("",{id:this._id,"class":[S,Z,c.style.classes,e.posClass].join(" "),width:c.style.width||"",height:c.style.height||"",tracking:"mouse"===j.target&&j.adjust.mouse,role:"alert","aria-live":"polite","aria-atomic":E,"aria-describedby":this._id+"-content","aria-hidden":D}).toggleClass(aa,this.disabled).attr(U,this.id).data(S,this).appendTo(j.container).append(f.content=d("",{"class":S+"-content",id:this._id+"-content","aria-atomic":D})),this.rendered=-1,this.positioning=D,h&&(this._createTitle(),d.isFunction(h)||k.push(this._updateTitle(h,E))),i&&this._createButton(),d.isFunction(g)||k.push(this._updateContent(g,E)),this.rendered=D,this._setWidget(),d.each(R,function(a){var c;"render"===this.initialize&&(c=this(b))&&(b.plugins[a]=c)}),this._unassignEvents(),this._assignEvents(),this._when(k).then(function(){b._trigger("render"),b.positioning=E,b.hiddenDuringWait||!c.show.ready&&!a||b.toggle(D,e.event,E),b.hiddenDuringWait=E}),y.api[this.id]=this,this},z.destroy=function(a){function b(){if(!this.destroyed){this.destroyed=D;var a,b=this.target,c=b.attr(ca);this.rendered&&this.tooltip.stop(1,0).find("*").remove().end().remove(),d.each(this.plugins,function(){this.destroy&&this.destroy()});for(a in this.timers)this.timers.hasOwnProperty(a)&&clearTimeout(this.timers[a]);b.removeData(S).removeAttr(U).removeAttr(T).removeAttr("aria-describedby"),this.options.suppress&&c&&b.attr("title",c).removeAttr(ca),this._unassignEvents(),this.options=this.elements=this.cache=this.timers=this.plugins=this.mouse=F,delete y.api[this.id]}}return this.destroyed?this.target:(a===D&&"hide"!==this.triggering||!this.rendered?b.call(this):(this.tooltip.one("tooltiphidden",d.proxy(b,this)),!this.triggering&&this.hide()),this.target)},B=z.checks={builtin:{"^id$":function(a,b,c,e){var f=c===D?y.nextid:c,g=S+"-"+f;f!==E&&f.length>0&&!d("#"+g).length?(this._id=g,this.rendered&&(this.tooltip[0].id=this._id,this.elements.content[0].id=this._id+"-content",this.elements.title[0].id=this._id+"-title")):a[b]=e},"^prerender":function(a,b,c){c&&!this.rendered&&this.render(this.options.show.ready)},"^content.text$":function(a,b,c){this._updateContent(c)},"^content.attr$":function(a,b,c,d){this.options.content.text===this.target.attr(d)&&this._updateContent(this.target.attr(c))},"^content.title$":function(a,b,c){return c?(c&&!this.elements.title&&this._createTitle(),void this._updateTitle(c)):this._removeTitle()},"^content.button$":function(a,b,c){this._updateButton(c)},"^content.title.(text|button)$":function(a,b,c){this.set("content."+b,c)},"^position.(my|at)$":function(a,b,c){"string"==typeof c&&(this.position[b]=a[b]=new A(c,"at"===b))},"^position.container$":function(a,b,c){this.rendered&&this.tooltip.appendTo(c)},"^show.ready$":function(a,b,c){c&&(!this.rendered&&this.render(D)||this.toggle(D))},"^style.classes$":function(a,b,c,d){this.rendered&&this.tooltip.removeClass(d).addClass(c)},"^style.(width|height)":function(a,b,c){this.rendered&&this.tooltip.css(b,c)},"^style.widget|content.title":function(){this.rendered&&this._setWidget()},"^style.def":function(a,b,c){this.rendered&&this.tooltip.toggleClass(Z,!!c)},"^events.(render|show|move|hide|focus|blur)$":function(a,b,c){this.rendered&&this.tooltip[(d.isFunction(c)?"":"un")+"bind"]("tooltip"+b,c)},"^(show|hide|position).(event|target|fixed|inactive|leave|distance|viewport|adjust)":function(){if(this.rendered){var a=this.options.position;this.tooltip.attr("tracking","mouse"===a.target&&a.adjust.mouse),this._unassignEvents(),this._assignEvents()}}}},z.get=function(a){if(this.destroyed)return this;var b=i(this.options,a.toLowerCase()),c=b[0][b[1]];return c.precedance?c.string():c};var ea=/^position\.(my|at|adjust|target|container|viewport)|style|content|show\.ready/i,fa=/^prerender|show\.ready/i;z.set=function(a,b){if(this.destroyed)return this;var c,e=this.rendered,f=E,g=this.options;return"string"==typeof a?(c=a,a={},a[c]=b):a=d.extend({},a),d.each(a,function(b,c){if(e&&fa.test(b))return void delete a[b];var h,j=i(g,b.toLowerCase());h=j[0][j[1]],j[0][j[1]]=c&&c.nodeType?d(c):c,f=ea.test(b)||f,a[b]=[j[0],j[1],c,h]}),h(g),this.positioning=D,d.each(a,d.proxy(j,this)),this.positioning=E,this.rendered&&this.tooltip[0].offsetWidth>0&&f&&this.reposition("mouse"===g.position.target?F:this.cache.event),this},z._update=function(a,b){var c=this,e=this.cache;return this.rendered&&a?(d.isFunction(a)&&(a=a.call(this.elements.target,e.event,this)||""),d.isFunction(a.then)?(e.waiting=D,a.then(function(a){return e.waiting=E,c._update(a,b)},F,function(a){return c._update(a,b)})):a===E||!a&&""!==a?E:(a.jquery&&a.length>0?b.empty().append(a.css({display:"block",visibility:"visible"})):b.html(a),this._waitForContent(b).then(function(a){c.rendered&&c.tooltip[0].offsetWidth>0&&c.reposition(e.event,!a.length)}))):E},z._waitForContent=function(a){var b=this.cache;return b.waiting=D,(d.fn.imagesLoaded?a.imagesLoaded():(new d.Deferred).resolve([])).done(function(){b.waiting=E}).promise()},z._updateContent=function(a,b){this._update(a,this.elements.content,b)},z._updateTitle=function(a,b){this._update(a,this.elements.title,b)===E&&this._removeTitle(E)},z._createTitle=function(){var a=this.elements,b=this._id+"-title";a.titlebar&&this._removeTitle(),a.titlebar=d("",{"class":S+"-titlebar "+(this.options.style.widget?k("header"):"")}).append(a.title=d("",{id:b,"class":S+"-title","aria-atomic":D})).insertBefore(a.content).delegate(".qtip-close","mousedown keydown mouseup keyup mouseout",function(a){d(this).toggleClass("ui-state-active ui-state-focus","down"===a.type.substr(-4))}).delegate(".qtip-close","mouseover mouseout",function(a){d(this).toggleClass("ui-state-hover","mouseover"===a.type)}),this.options.content.button&&this._createButton()},z._removeTitle=function(a){var b=this.elements;b.title&&(b.titlebar.remove(),b.titlebar=b.title=b.button=F,a!==E&&this.reposition())},z._createPosClass=function(a){return S+"-pos-"+(a||this.options.position.my).abbrev()},z.reposition=function(c,e){if(!this.rendered||this.positioning||this.destroyed)return this;this.positioning=D;var f,g,h,i,j=this.cache,k=this.tooltip,l=this.options.position,m=l.target,n=l.my,o=l.at,p=l.viewport,q=l.container,r=l.adjust,s=r.method.split(" "),t=k.outerWidth(E),u=k.outerHeight(E),v=0,w=0,x=k.css("position"),y={left:0,top:0},z=k[0].offsetWidth>0,A=c&&"scroll"===c.type,B=d(a),C=q[0].ownerDocument,F=this.mouse;if(d.isArray(m)&&2===m.length)o={x:L,y:K},y={left:m[0],top:m[1]};else if("mouse"===m)o={x:L,y:K},(!r.mouse||this.options.hide.distance)&&j.origin&&j.origin.pageX?c=j.origin:!c||c&&("resize"===c.type||"scroll"===c.type)?c=j.event:F&&F.pageX&&(c=F),"static"!==x&&(y=q.offset()),C.body.offsetWidth!==(a.innerWidth||C.documentElement.clientWidth)&&(g=d(b.body).offset()),y={left:c.pageX-y.left+(g&&g.left||0),top:c.pageY-y.top+(g&&g.top||0)},r.mouse&&A&&F&&(y.left-=(F.scrollX||0)-B.scrollLeft(),y.top-=(F.scrollY||0)-B.scrollTop());else{if("event"===m?c&&c.target&&"scroll"!==c.type&&"resize"!==c.type?j.target=d(c.target):c.target||(j.target=this.elements.target):"event"!==m&&(j.target=d(m.jquery?m:this.elements.target)),m=j.target,m=d(m).eq(0),0===m.length)return this;m[0]===b||m[0]===a?(v=da.iOS?a.innerWidth:m.width(),w=da.iOS?a.innerHeight:m.height(),m[0]===a&&(y={top:(p||m).scrollTop(),left:(p||m).scrollLeft()})):R.imagemap&&m.is("area")?f=R.imagemap(this,m,o,R.viewport?s:E):R.svg&&m&&m[0].ownerSVGElement?f=R.svg(this,m,o,R.viewport?s:E):(v=m.outerWidth(E),w=m.outerHeight(E),y=m.offset()),f&&(v=f.width,w=f.height,g=f.offset,y=f.position),y=this.reposition.offset(m,y,q),(da.iOS>3.1&&da.iOS<4.1||da.iOS>=4.3&&da.iOS<4.33||!da.iOS&&"fixed"===x)&&(y.left-=B.scrollLeft(),y.top-=B.scrollTop()),(!f||f&&f.adjustable!==E)&&(y.left+=o.x===N?v:o.x===O?v/2:0,y.top+=o.y===M?w:o.y===O?w/2:0)}return y.left+=r.x+(n.x===N?-t:n.x===O?-t/2:0),y.top+=r.y+(n.y===M?-u:n.y===O?-u/2:0),R.viewport?(h=y.adjusted=R.viewport(this,y,l,v,w,t,u),g&&h.left&&(y.left+=g.left),g&&h.top&&(y.top+=g.top),h.my&&(this.position.my=h.my)):y.adjusted={left:0,top:0},j.posClass!==(i=this._createPosClass(this.position.my))&&(j.posClass=i,k.removeClass(j.posClass).addClass(i)),this._trigger("move",[y,p.elem||p],c)?(delete y.adjusted,e===E||!z||isNaN(y.left)||isNaN(y.top)||"mouse"===m||!d.isFunction(l.effect)?k.css(y):d.isFunction(l.effect)&&(l.effect.call(k,this,d.extend({},y)),k.queue(function(a){d(this).css({opacity:"",height:""}),da.ie&&this.style.removeAttribute("filter"),a()})),this.positioning=E,this):this},z.reposition.offset=function(a,c,e){function f(a,b){c.left+=b*a.scrollLeft(),c.top+=b*a.scrollTop()}if(!e[0])return c;var g,h,i,j,k=d(a[0].ownerDocument),l=!!da.ie&&"CSS1Compat"!==b.compatMode,m=e[0];do"static"!==(h=d.css(m,"position"))&&("fixed"===h?(i=m.getBoundingClientRect(),f(k,-1)):(i=d(m).position(),i.left+=parseFloat(d.css(m,"borderLeftWidth"))||0,i.top+=parseFloat(d.css(m,"borderTopWidth"))||0),c.left-=i.left+(parseFloat(d.css(m,"marginLeft"))||0),c.top-=i.top+(parseFloat(d.css(m,"marginTop"))||0),g||"hidden"===(j=d.css(m,"overflow"))||"visible"===j||(g=d(m)));while(m=m.offsetParent);return g&&(g[0]!==k[0]||l)&&f(g,1),c};var ga=(A=z.reposition.Corner=function(a,b){a=(""+a).replace(/([A-Z])/," $1").replace(/middle/gi,O).toLowerCase(),this.x=(a.match(/left|right/i)||a.match(/center/)||["inherit"])[0].toLowerCase(),this.y=(a.match(/top|bottom|center/i)||["inherit"])[0].toLowerCase(),this.forceY=!!b;var c=a.charAt(0);this.precedance="t"===c||"b"===c?H:G}).prototype;ga.invert=function(a,b){this[a]=this[a]===L?N:this[a]===N?L:b||this[a]},ga.string=function(a){var b=this.x,c=this.y,d=b!==c?"center"===b||"center"!==c&&(this.precedance===H||this.forceY)?[c,b]:[b,c]:[b];return a!==!1?d.join(" "):d},ga.abbrev=function(){var a=this.string(!1);return a[0].charAt(0)+(a[1]&&a[1].charAt(0)||"")},ga.clone=function(){return new A(this.string(),this.forceY)},z.toggle=function(a,c){var e=this.cache,f=this.options,g=this.tooltip;if(c){if(/over|enter/.test(c.type)&&e.event&&/out|leave/.test(e.event.type)&&f.show.target.add(c.target).length===f.show.target.length&&g.has(c.relatedTarget).length)return this;e.event=d.event.fix(c)}if(this.waiting&&!a&&(this.hiddenDuringWait=D),!this.rendered)return a?this.render(1):this;if(this.destroyed||this.disabled)return this;var h,i,j,k=a?"show":"hide",l=this.options[k],m=this.options.position,n=this.options.content,o=this.tooltip.css("width"),p=this.tooltip.is(":visible"),q=a||1===l.target.length,r=!c||l.target.length<2||e.target[0]===c.target;return(typeof a).search("boolean|number")&&(a=!p),h=!g.is(":animated")&&p===a&&r,i=h?F:!!this._trigger(k,[90]),this.destroyed?this:(i!==E&&a&&this.focus(c),!i||h?this:(d.attr(g[0],"aria-hidden",!a),a?(this.mouse&&(e.origin=d.event.fix(this.mouse)),d.isFunction(n.text)&&this._updateContent(n.text,E),d.isFunction(n.title)&&this._updateTitle(n.title,E),!C&&"mouse"===m.target&&m.adjust.mouse&&(d(b).bind("mousemove."+S,this._storeMouse),C=D),o||g.css("width",g.outerWidth(E)),this.reposition(c,arguments[2]),o||g.css("width",""),l.solo&&("string"==typeof l.solo?d(l.solo):d(W,l.solo)).not(g).not(l.target).qtip("hide",new d.Event("tooltipsolo"))):(clearTimeout(this.timers.show),delete e.origin,C&&!d(W+'[tracking="true"]:visible',l.solo).not(g).length&&(d(b).unbind("mousemove."+S),C=E),this.blur(c)),j=d.proxy(function(){a?(da.ie&&g[0].style.removeAttribute("filter"),g.css("overflow",""),"string"==typeof l.autofocus&&d(this.options.show.autofocus,g).focus(),this.options.show.target.trigger("qtip-"+this.id+"-inactive")):g.css({display:"",visibility:"",opacity:"",left:"",top:""}),this._trigger(a?"visible":"hidden")},this),l.effect===E||q===E?(g[k](),j()):d.isFunction(l.effect)?(g.stop(1,1),l.effect.call(g,this),g.queue("fx",function(a){j(),a()})):g.fadeTo(90,a?1:0,j),a&&l.target.trigger("qtip-"+this.id+"-inactive"),this))},z.show=function(a){return this.toggle(D,a)},z.hide=function(a){return this.toggle(E,a)},z.focus=function(a){if(!this.rendered||this.destroyed)return this;var b=d(W),c=this.tooltip,e=parseInt(c[0].style.zIndex,10),f=y.zindex+b.length;return c.hasClass($)||this._trigger("focus",[f],a)&&(e!==f&&(b.each(function(){this.style.zIndex>e&&(this.style.zIndex=this.style.zIndex-1)}),b.filter("."+$).qtip("blur",a)),c.addClass($)[0].style.zIndex=f),this},z.blur=function(a){return!this.rendered||this.destroyed?this:(this.tooltip.removeClass($),this._trigger("blur",[this.tooltip.css("zIndex")],a),this)},z.disable=function(a){return this.destroyed?this:("toggle"===a?a=!(this.rendered?this.tooltip.hasClass(aa):this.disabled):"boolean"!=typeof a&&(a=D),this.rendered&&this.tooltip.toggleClass(aa,a).attr("aria-disabled",a),this.disabled=!!a,this)},z.enable=function(){return this.disable(E)},z._createButton=function(){var a=this,b=this.elements,c=b.tooltip,e=this.options.content.button,f="string"==typeof e,g=f?e:"Close tooltip";b.button&&b.button.remove(),e.jquery?b.button=e:b.button=d("",{"class":"qtip-close "+(this.options.style.widget?"":S+"-icon"),title:g,"aria-label":g}).prepend(d("",{"class":"ui-icon ui-icon-close",html:"×"})),b.button.appendTo(b.titlebar||c).attr("role","button").click(function(b){return c.hasClass(aa)||a.hide(b),E})},z._updateButton=function(a){if(!this.rendered)return E;var b=this.elements.button;a?this._createButton():b.remove()},z._setWidget=function(){var a=this.options.style.widget,b=this.elements,c=b.tooltip,d=c.hasClass(aa);c.removeClass(aa),aa=a?"ui-state-disabled":"qtip-disabled",c.toggleClass(aa,d),c.toggleClass("ui-helper-reset "+k(),a).toggleClass(Z,this.options.style.def&&!a),b.content&&b.content.toggleClass(k("content"),a),b.titlebar&&b.titlebar.toggleClass(k("header"),a),b.button&&b.button.toggleClass(S+"-icon",!a)},z._storeMouse=function(a){return(this.mouse=d.event.fix(a)).type="mousemove",this},z._bind=function(a,b,c,e,f){if(a&&c&&b.length){var g="."+this._id+(e?"-"+e:"");return d(a).bind((b.split?b:b.join(g+" "))+g,d.proxy(c,f||this)),this}},z._unbind=function(a,b){return a&&d(a).unbind("."+this._id+(b?"-"+b:"")),this},z._trigger=function(a,b,c){var e=new d.Event("tooltip"+a);return e.originalEvent=c&&d.extend({},c)||this.cache.event||F,this.triggering=a,this.tooltip.trigger(e,[this].concat(b||[])),this.triggering=E,!e.isDefaultPrevented()},z._bindEvents=function(a,b,c,e,f,g){var h=c.filter(e).add(e.filter(c)),i=[];h.length&&(d.each(b,function(b,c){var e=d.inArray(c,a);e>-1&&i.push(a.splice(e,1)[0])}),i.length&&(this._bind(h,i,function(a){var b=this.rendered?this.tooltip[0].offsetWidth>0:!1;(b?g:f).call(this,a)}),c=c.not(h),e=e.not(h))),this._bind(c,a,f),this._bind(e,b,g)},z._assignInitialEvents=function(a){function b(a){return this.disabled||this.destroyed?E:(this.cache.event=a&&d.event.fix(a),this.cache.target=a&&d(a.target),clearTimeout(this.timers.show),void(this.timers.show=l.call(this,function(){this.render("object"==typeof a||c.show.ready)},c.prerender?0:c.show.delay)))}var c=this.options,e=c.show.target,f=c.hide.target,g=c.show.event?d.trim(""+c.show.event).split(" "):[],h=c.hide.event?d.trim(""+c.hide.event).split(" "):[];this._bind(this.elements.target,["remove","removeqtip"],function(){this.destroy(!0)},"destroy"),/mouse(over|enter)/i.test(c.show.event)&&!/mouse(out|leave)/i.test(c.hide.event)&&h.push("mouseleave"),this._bind(e,"mousemove",function(a){this._storeMouse(a),this.cache.onTarget=D}),this._bindEvents(g,h,e,f,b,function(){return this.timers?void clearTimeout(this.timers.show):E}),(c.show.ready||c.prerender)&&b.call(this,a)},z._assignEvents=function(){var c=this,e=this.options,f=e.position,g=this.tooltip,h=e.show.target,i=e.hide.target,j=f.container,k=f.viewport,l=d(b),q=d(a),r=e.show.event?d.trim(""+e.show.event).split(" "):[],s=e.hide.event?d.trim(""+e.hide.event).split(" "):[];d.each(e.events,function(a,b){c._bind(g,"toggle"===a?["tooltipshow","tooltiphide"]:["tooltip"+a],b,null,g)}),/mouse(out|leave)/i.test(e.hide.event)&&"window"===e.hide.leave&&this._bind(l,["mouseout","blur"],function(a){/select|option/.test(a.target.nodeName)||a.relatedTarget||this.hide(a)}),e.hide.fixed?i=i.add(g.addClass(Y)):/mouse(over|enter)/i.test(e.show.event)&&this._bind(i,"mouseleave",function(){clearTimeout(this.timers.show)}),(""+e.hide.event).indexOf("unfocus")>-1&&this._bind(j.closest("html"),["mousedown","touchstart"],function(a){var b=d(a.target),c=this.rendered&&!this.tooltip.hasClass(aa)&&this.tooltip[0].offsetWidth>0,e=b.parents(W).filter(this.tooltip[0]).length>0;b[0]===this.target[0]||b[0]===this.tooltip[0]||e||this.target.has(b[0]).length||!c||this.hide(a)}),"number"==typeof e.hide.inactive&&(this._bind(h,"qtip-"+this.id+"-inactive",o,"inactive"),this._bind(i.add(g),y.inactiveEvents,o)),this._bindEvents(r,s,h,i,m,n),this._bind(h.add(g),"mousemove",function(a){if("number"==typeof e.hide.distance){var b=this.cache.origin||{},c=this.options.hide.distance,d=Math.abs;(d(a.pageX-b.pageX)>=c||d(a.pageY-b.pageY)>=c)&&this.hide(a)}this._storeMouse(a)}),"mouse"===f.target&&f.adjust.mouse&&(e.hide.event&&this._bind(h,["mouseenter","mouseleave"],function(a){return this.cache?void(this.cache.onTarget="mouseenter"===a.type):E}),this._bind(l,"mousemove",function(a){this.rendered&&this.cache.onTarget&&!this.tooltip.hasClass(aa)&&this.tooltip[0].offsetWidth>0&&this.reposition(a)})),(f.adjust.resize||k.length)&&this._bind(d.event.special.resize?k:q,"resize",p),f.adjust.scroll&&this._bind(q.add(f.container),"scroll",p)},z._unassignEvents=function(){var c=this.options,e=c.show.target,f=c.hide.target,g=d.grep([this.elements.target[0],this.rendered&&this.tooltip[0],c.position.container[0],c.position.viewport[0],c.position.container.closest("html")[0],a,b],function(a){return"object"==typeof a});e&&e.toArray&&(g=g.concat(e.toArray())),f&&f.toArray&&(g=g.concat(f.toArray())),this._unbind(g)._unbind(g,"destroy")._unbind(g,"inactive")},d(function(){q(W,["mouseenter","mouseleave"],function(a){var b="mouseenter"===a.type,c=d(a.currentTarget),e=d(a.relatedTarget||a.target),f=this.options;b?(this.focus(a),c.hasClass(Y)&&!c.hasClass(aa)&&clearTimeout(this.timers.hide)):"mouse"===f.position.target&&f.position.adjust.mouse&&f.hide.event&&f.show.target&&!e.closest(f.show.target[0]).length&&this.hide(a),c.toggleClass(_,b)}),q("["+U+"]",X,o)}),y=d.fn.qtip=function(a,b,e){var f=(""+a).toLowerCase(),g=F,i=d.makeArray(arguments).slice(1),j=i[i.length-1],k=this[0]?d.data(this[0],S):F;return!arguments.length&&k||"api"===f?k:"string"==typeof a?(this.each(function(){var a=d.data(this,S);if(!a)return D;if(j&&j.timeStamp&&(a.cache.event=j),!b||"option"!==f&&"options"!==f)a[f]&&a[f].apply(a,i);else{if(e===c&&!d.isPlainObject(b))return g=a.get(b),E;a.set(b,e)}}),g!==F?g:this):"object"!=typeof a&&arguments.length?void 0:(k=h(d.extend(D,{},a)),this.each(function(a){var b,c;return c=d.isArray(k.id)?k.id[a]:k.id,c=!c||c===E||c.length<1||y.api[c]?y.nextid++:c,b=r(d(this),c,k),b===E?D:(y.api[c]=b,d.each(R,function(){"initialize"===this.initialize&&this(b)}),void b._assignInitialEvents(j))}))},d.qtip=e,y.api={},d.each({attr:function(a,b){if(this.length){var c=this[0],e="title",f=d.data(c,"qtip");if(a===e&&f&&f.options&&"object"==typeof f&&"object"==typeof f.options&&f.options.suppress)return arguments.length<2?d.attr(c,ca):(f&&f.options.content.attr===e&&f.cache.attr&&f.set("content.text",b),this.attr(ca,b))}return d.fn["attr"+ba].apply(this,arguments)},clone:function(a){var b=d.fn["clone"+ba].apply(this,arguments);return a||b.filter("["+ca+"]").attr("title",function(){return d.attr(this,ca)}).removeAttr(ca),b}},function(a,b){if(!b||d.fn[a+ba])return D;var c=d.fn[a+ba]=d.fn[a];d.fn[a]=function(){return b.apply(this,arguments)||c.apply(this,arguments)}}),d.ui||(d["cleanData"+ba]=d.cleanData,d.cleanData=function(a){for(var b,c=0;(b=d(a[c])).length;c++)if(b.attr(T))try{b.triggerHandler("removeqtip")}catch(e){}d["cleanData"+ba].apply(this,arguments)}),y.version="3.0.3",y.nextid=0,y.inactiveEvents=X,y.zindex=15e3,y.defaults={prerender:E,id:E,overwrite:D,suppress:D,content:{text:D,attr:"title",title:E,button:E},position:{my:"top left",at:"bottom right",target:E,container:E,viewport:E,adjust:{x:0,y:0,mouse:D,scroll:D,resize:D,method:"flipinvert flipinvert"},effect:function(a,b){d(this).animate(b,{duration:200,queue:E})}},show:{target:E,event:"mouseenter",effect:D,delay:90,solo:E,ready:E,autofocus:E},hide:{target:E,event:"mouseleave",effect:D,delay:0,fixed:E,inactive:E,leave:"window",distance:E},style:{classes:"",widget:E,width:E,height:E,def:D},events:{render:F,move:F,show:F,hide:F,toggle:F,visible:F,hidden:F,focus:F,blur:F}};var ha,ia,ja,ka,la,ma="margin",na="border",oa="color",pa="background-color",qa="transparent",ra=" !important",sa=!!b.createElement("canvas").getContext,ta=/rgba?\(0, 0, 0(, 0)?\)|transparent|#123456/i,ua={},va=["Webkit","O","Moz","ms"];sa?(ka=a.devicePixelRatio||1,la=function(){var a=b.createElement("canvas").getContext("2d");return a.backingStorePixelRatio||a.webkitBackingStorePixelRatio||a.mozBackingStorePixelRatio||a.msBackingStorePixelRatio||a.oBackingStorePixelRatio||1}(),ja=ka/la):ia=function(a,b,c){return"'},d.extend(v.prototype,{init:function(a){var b,c;c=this.element=a.elements.tip=d("",{"class":S+"-tip"}).prependTo(a.tooltip),sa?(b=d("").appendTo(this.element)[0].getContext("2d"),b.lineJoin="miter",b.miterLimit=1e5,b.save()):(b=ia("shape",'coordorigin="0,0"',"position:absolute;"),this.element.html(b+b),a._bind(d("*",c).add(c),["click","mousedown"],function(a){a.stopPropagation()},this._ns)),a._bind(a.tooltip,"tooltipmove",this.reposition,this._ns,this),this.create()},_swapDimensions:function(){this.size[0]=this.options.height,this.size[1]=this.options.width},_resetDimensions:function(){this.size[0]=this.options.width,this.size[1]=this.options.height},_useTitle:function(a){var b=this.qtip.elements.titlebar;return b&&(a.y===K||a.y===O&&this.element.position().top+this.size[1]/2+this.options.offsetl&&!ta.test(e[1])&&(e[0]=e[1]),this.border=l=p.border!==D?p.border:l):this.border=l=0,k=this.size=this._calculateSize(b),n.css({width:k[0],height:k[1],lineHeight:k[1]+"px"}),j=b.precedance===H?[s(r.x===L?l:r.x===N?k[0]-q[0]-l:(k[0]-q[0])/2),s(r.y===K?k[1]-q[1]:0)]:[s(r.x===L?k[0]-q[0]:0),s(r.y===K?l:r.y===M?k[1]-q[1]-l:(k[1]-q[1])/2)],sa?(g=o[0].getContext("2d"),g.restore(),g.save(),g.clearRect(0,0,6e3,6e3),h=this._calculateTip(r,q,ja),i=this._calculateTip(r,this.size,ja),o.attr(I,k[0]*ja).attr(J,k[1]*ja),o.css(I,k[0]).css(J,k[1]),this._drawCoords(g,i),g.fillStyle=e[1],g.fill(),g.translate(j[0]*ja,j[1]*ja),this._drawCoords(g,h),g.fillStyle=e[0],g.fill()):(h=this._calculateTip(r),h="m"+h[0]+","+h[1]+" l"+h[2]+","+h[3]+" "+h[4]+","+h[5]+" xe",j[2]=l&&/^(r|b)/i.test(b.string())?8===da.ie?2:1:0,o.css({coordsize:k[0]+l+" "+k[1]+l,antialias:""+(r.string().indexOf(O)>-1),left:j[0]-j[2]*Number(f===G),top:j[1]-j[2]*Number(f===H),width:k[0]+l,height:k[1]+l}).each(function(a){var b=d(this);b[b.prop?"prop":"attr"]({coordsize:k[0]+l+" "+k[1]+l,path:h,fillcolor:e[0],filled:!!a,stroked:!a}).toggle(!(!l&&!a)),!a&&b.html(ia("stroke",'weight="'+2*l+'px" color="'+e[1]+'" miterlimit="1000" joinstyle="miter"'))})),a.opera&&setTimeout(function(){m.tip.css({display:"inline-block",visibility:"visible"})},1),c!==E&&this.calculate(b,k)},calculate:function(a,b){if(!this.enabled)return E;var c,e,f=this,g=this.qtip.elements,h=this.element,i=this.options.offset,j={};
4 | return a=a||this.corner,c=a.precedance,b=b||this._calculateSize(a),e=[a.x,a.y],c===G&&e.reverse(),d.each(e,function(d,e){var h,k,l;e===O?(h=c===H?L:K,j[h]="50%",j[ma+"-"+h]=-Math.round(b[c===H?0:1]/2)+i):(h=f._parseWidth(a,e,g.tooltip),k=f._parseWidth(a,e,g.content),l=f._parseRadius(a),j[e]=Math.max(-f.border,d?k:i+(l>h?l:-h)))}),j[a[c]]-=b[c===G?0:1],h.css({margin:"",top:"",bottom:"",left:"",right:""}).css(j),j},reposition:function(a,b,d){function e(a,b,c,d,e){a===Q&&j.precedance===b&&k[d]&&j[c]!==O?j.precedance=j.precedance===G?H:G:a!==Q&&k[d]&&(j[b]=j[b]===O?k[d]>0?d:e:j[b]===d?e:d)}function f(a,b,e){j[a]===O?p[ma+"-"+b]=o[a]=g[ma+"-"+b]-k[b]:(h=g[e]!==c?[k[b],-g[b]]:[-k[b],g[b]],(o[a]=Math.max(h[0],h[1]))>h[0]&&(d[b]-=k[b],o[b]=E),p[g[e]!==c?e:b]=o[a])}if(this.enabled){var g,h,i=b.cache,j=this.corner.clone(),k=d.adjusted,l=b.options.position.adjust.method.split(" "),m=l[0],n=l[1]||l[0],o={left:E,top:E,x:0,y:0},p={};this.corner.fixed!==D&&(e(m,G,H,L,N),e(n,H,G,K,M),j.string()===i.corner.string()&&i.cornerTop===k.top&&i.cornerLeft===k.left||this.update(j,E)),g=this.calculate(j),g.right!==c&&(g.left=-g.right),g.bottom!==c&&(g.top=-g.bottom),g.user=this.offset,o.left=m===Q&&!!k.left,o.left&&f(G,L,N),o.top=n===Q&&!!k.top,o.top&&f(H,K,M),this.element.css(p).toggle(!(o.x&&o.y||j.x===O&&o.y||j.y===O&&o.x)),d.left-=g.left.charAt?g.user:m!==Q||o.top||!o.left&&!o.top?g.left+this.border:0,d.top-=g.top.charAt?g.user:n!==Q||o.left||!o.left&&!o.top?g.top+this.border:0,i.cornerLeft=k.left,i.cornerTop=k.top,i.corner=j.clone()}},destroy:function(){this.qtip._unbind(this.qtip.tooltip,this._ns),this.qtip.elements.tip&&this.qtip.elements.tip.find("*").remove().end().remove()}}),ha=R.tip=function(a){return new v(a,a.options.style.tip)},ha.initialize="render",ha.sanitize=function(a){if(a.style&&"tip"in a.style){var b=a.style.tip;"object"!=typeof b&&(b=a.style.tip={corner:b}),/string|boolean/i.test(typeof b.corner)||(b.corner=D)}},B.tip={"^position.my|style.tip.(corner|mimic|border)$":function(){this.create(),this.qtip.reposition()},"^style.tip.(height|width)$":function(a){this.size=[a.width,a.height],this.update(),this.qtip.reposition()},"^content.title|style.(classes|widget)$":function(){this.update()}},d.extend(D,y.defaults,{style:{tip:{corner:D,mimic:E,width:6,height:6,border:D,offset:0}}});var wa,xa,ya="qtip-modal",za="."+ya;xa=function(){function a(a){if(d.expr[":"].focusable)return d.expr[":"].focusable;var b,c,e,f=!isNaN(d.attr(a,"tabindex")),g=a.nodeName&&a.nodeName.toLowerCase();return"area"===g?(b=a.parentNode,c=b.name,a.href&&c&&"map"===b.nodeName.toLowerCase()?(e=d("img[usemap=#"+c+"]")[0],!!e&&e.is(":visible")):!1):/input|select|textarea|button|object/.test(g)?!a.disabled:"a"===g?a.href||f:f}function c(a){j.length<1&&a.length?a.not("body").blur():j.first().focus()}function e(a){if(h.is(":visible")){var b,e=d(a.target),g=f.tooltip,i=e.closest(W);b=i.length<1?E:parseInt(i[0].style.zIndex,10)>parseInt(g[0].style.zIndex,10),b||e.closest(W)[0]===g[0]||c(e)}}var f,g,h,i=this,j={};d.extend(i,{init:function(){return h=i.elem=d("",{id:"qtip-overlay",html:"",mousedown:function(){return E}}).hide(),d(b.body).bind("focusin"+za,e),d(b).bind("keydown"+za,function(a){f&&f.options.show.modal.escape&&27===a.keyCode&&f.hide(a)}),h.bind("click"+za,function(a){f&&f.options.show.modal.blur&&f.hide(a)}),i},update:function(b){f=b,j=b.options.show.modal.stealfocus!==E?b.tooltip.find("*").filter(function(){return a(this)}):[]},toggle:function(a,e,j){var k=a.tooltip,l=a.options.show.modal,m=l.effect,n=e?"show":"hide",o=h.is(":visible"),p=d(za).filter(":visible:not(:animated)").not(k);return i.update(a),e&&l.stealfocus!==E&&c(d(":focus")),h.toggleClass("blurs",l.blur),e&&h.appendTo(b.body),h.is(":animated")&&o===e&&g!==E||!e&&p.length?i:(h.stop(D,E),d.isFunction(m)?m.call(h,e):m===E?h[n]():h.fadeTo(parseInt(j,10)||90,e?1:0,function(){e||h.hide()}),e||h.queue(function(a){h.css({left:"",top:""}),d(za).length||h.detach(),a()}),g=e,f.destroyed&&(f=F),i)}}),i.init()},xa=new xa,d.extend(w.prototype,{init:function(a){var b=a.tooltip;return this.options.on?(a.elements.overlay=xa.elem,b.addClass(ya).css("z-index",y.modal_zindex+d(za).length),a._bind(b,["tooltipshow","tooltiphide"],function(a,c,e){var f=a.originalEvent;if(a.target===b[0])if(f&&"tooltiphide"===a.type&&/mouse(leave|enter)/.test(f.type)&&d(f.relatedTarget).closest(xa.elem[0]).length)try{a.preventDefault()}catch(g){}else(!f||f&&"tooltipsolo"!==f.type)&&this.toggle(a,"tooltipshow"===a.type,e)},this._ns,this),a._bind(b,"tooltipfocus",function(a,c){if(!a.isDefaultPrevented()&&a.target===b[0]){var e=d(za),f=y.modal_zindex+e.length,g=parseInt(b[0].style.zIndex,10);xa.elem[0].style.zIndex=f-1,e.each(function(){this.style.zIndex>g&&(this.style.zIndex-=1)}),e.filter("."+$).qtip("blur",a.originalEvent),b.addClass($)[0].style.zIndex=f,xa.update(c);try{a.preventDefault()}catch(h){}}},this._ns,this),void a._bind(b,"tooltiphide",function(a){a.target===b[0]&&d(za).filter(":visible").not(b).last().qtip("focus",a)},this._ns,this)):this},toggle:function(a,b,c){return a&&a.isDefaultPrevented()?this:void xa.toggle(this.qtip,!!b,c)},destroy:function(){this.qtip.tooltip.removeClass(ya),this.qtip._unbind(this.qtip.tooltip,this._ns),xa.toggle(this.qtip,E),delete this.qtip.elements.overlay}}),wa=R.modal=function(a){return new w(a,a.options.show.modal)},wa.sanitize=function(a){a.show&&("object"!=typeof a.show.modal?a.show.modal={on:!!a.show.modal}:"undefined"==typeof a.show.modal.on&&(a.show.modal.on=D))},y.modal_zindex=y.zindex-200,wa.initialize="render",B.modal={"^show.modal.(on|blur)$":function(){this.destroy(),this.init(),this.qtip.elems.overlay.toggle(this.qtip.tooltip[0].offsetWidth>0)}},d.extend(D,y.defaults,{show:{modal:{on:E,effect:D,blur:D,stealfocus:D,escape:D}}}),R.viewport=function(c,d,e,f,g,h,i){function j(a,b,c,e,f,g,h,i,j){var k=d[f],s=u[a],t=v[a],w=c===Q,x=s===f?j:s===g?-j:-j/2,y=t===f?i:t===g?-i:-i/2,z=q[f]+r[f]-(n?0:m[f]),A=z-k,B=k+j-(h===I?o:p)-z,C=x-(u.precedance===a||s===u[b]?y:0)-(t===O?i/2:0);return w?(C=(s===f?1:-1)*x,d[f]+=A>0?A:B>0?-B:0,d[f]=Math.max(-m[f]+r[f],k-C,Math.min(Math.max(-m[f]+r[f]+(h===I?o:p),k+C),d[f],"center"===s?k-x:1e9))):(e*=c===P?2:0,A>0&&(s!==f||B>0)?(d[f]-=C+e,l.invert(a,f)):B>0&&(s!==g||A>0)&&(d[f]-=(s===O?-C:C)+e,l.invert(a,g)),d[f]B&&(d[f]=k,l=u.clone())),d[f]-k}var k,l,m,n,o,p,q,r,s=e.target,t=c.elements.tooltip,u=e.my,v=e.at,w=e.adjust,x=w.method.split(" "),y=x[0],z=x[1]||x[0],A=e.viewport,B=e.container,C={left:0,top:0};return A.jquery&&s[0]!==a&&s[0]!==b.body&&"none"!==w.method?(m=B.offset()||C,n="static"===B.css("position"),k="fixed"===t.css("position"),o=A[0]===a?A.width():A.outerWidth(E),p=A[0]===a?A.height():A.outerHeight(E),q={left:k?0:A.scrollLeft(),top:k?0:A.scrollTop()},r=A.offset()||C,"shift"===y&&"shift"===z||(l=u.clone()),C={left:"none"!==y?j(G,H,y,w.x,L,N,I,f,h):0,top:"none"!==z?j(H,G,z,w.y,K,M,J,g,i):0,my:l}):C},R.polys={polygon:function(a,b){var c,d,e,f={width:0,height:0,position:{top:1e10,right:0,bottom:0,left:1e10},adjustable:E},g=0,h=[],i=1,j=1,k=0,l=0;for(g=a.length;g--;)c=[parseInt(a[--g],10),parseInt(a[g+1],10)],c[0]>f.position.right&&(f.position.right=c[0]),c[0]f.position.bottom&&(f.position.bottom=c[1]),c[1]0&&e>0&&i>0&&j>0;)for(d=Math.floor(d/2),e=Math.floor(e/2),b.x===L?i=d:b.x===N?i=f.width-d:i+=Math.floor(d/2),b.y===K?j=e:b.y===M?j=f.height-e:j+=Math.floor(e/2),g=h.length;g--&&!(h.length<2);)k=h[g][0]-f.position.left,l=h[g][1]-f.position.top,(b.x===L&&k>=i||b.x===N&&i>=k||b.x===O&&(i>k||k>f.width-i)||b.y===K&&l>=j||b.y===M&&j>=l||b.y===O&&(j>l||l>f.height-j))&&h.splice(g,1);f.position={left:h[0][0],top:h[0][1]}}return f},rect:function(a,b,c,d){return{width:Math.abs(c-a),height:Math.abs(d-b),position:{left:Math.min(a,c),top:Math.min(b,d)}}},_angles:{tc:1.5,tr:7/4,tl:5/4,bc:.5,br:.25,bl:.75,rc:2,lc:1,c:0},ellipse:function(a,b,c,d,e){var f=R.polys._angles[e.abbrev()],g=0===f?0:c*Math.cos(f*Math.PI),h=d*Math.sin(f*Math.PI);return{width:2*c-Math.abs(g),height:2*d-Math.abs(h),position:{left:a+g,top:b+h},adjustable:E}},circle:function(a,b,c,d){return R.polys.ellipse(a,b,c,c,d)}},R.svg=function(a,c,e){for(var f,g,h,i,j,k,l,m,n,o=c[0],p=d(o.ownerSVGElement),q=o.ownerDocument,r=(parseInt(c.css("stroke-width"),10)||0)/2;!o.getBBox;)o=o.parentNode;if(!o.getBBox||!o.parentNode)return E;switch(o.nodeName){case"ellipse":case"circle":m=R.polys.ellipse(o.cx.baseVal.value,o.cy.baseVal.value,(o.rx||o.r).baseVal.value+r,(o.ry||o.r).baseVal.value+r,e);break;case"line":case"polygon":case"polyline":for(l=o.points||[{x:o.x1.baseVal.value,y:o.y1.baseVal.value},{x:o.x2.baseVal.value,y:o.y2.baseVal.value}],m=[],k=-1,i=l.numberOfItems||l.length;++k';d.extend(x.prototype,{_scroll:function(){var b=this.qtip.elements.overlay;b&&(b[0].style.top=d(a).scrollTop()+"px")},init:function(c){var e=c.tooltip;d("select, object").length<1&&(this.bgiframe=c.elements.bgiframe=d(Ba).appendTo(e),c._bind(e,"tooltipmove",this.adjustBGIFrame,this._ns,this)),this.redrawContainer=d("",{id:S+"-rcontainer"}).appendTo(b.body),c.elements.overlay&&c.elements.overlay.addClass("qtipmodal-ie6fix")&&(c._bind(a,["scroll","resize"],this._scroll,this._ns,this),c._bind(e,["tooltipshow"],this._scroll,this._ns,this)),this.redraw()},adjustBGIFrame:function(){var a,b,c=this.qtip.tooltip,d={height:c.outerHeight(E),width:c.outerWidth(E)},e=this.qtip.plugins.tip,f=this.qtip.elements.tip;b=parseInt(c.css("borderLeftWidth"),10)||0,b={left:-b,top:-b},e&&f&&(a="x"===e.corner.precedance?[I,L]:[J,K],b[a[1]]-=f[a[0]]()),this.bgiframe.css(b).css(d)},redraw:function(){if(this.qtip.rendered<1||this.drawing)return this;var a,b,c,d,e=this.qtip.tooltip,f=this.qtip.options.style,g=this.qtip.options.position.container;return this.qtip.drawing=1,f.height&&e.css(J,f.height),f.width?e.css(I,f.width):(e.css(I,"").appendTo(this.redrawContainer),b=e.width(),1>b%2&&(b+=1),c=e.css("maxWidth")||"",d=e.css("minWidth")||"",a=(c+d).indexOf("%")>-1?g.width()/100:0,c=(c.indexOf("%")>-1?a:1*parseInt(c,10))||b,d=(d.indexOf("%")>-1?a:1*parseInt(d,10))||0,b=c+d?Math.min(Math.max(b,d),c):b,e.css(I,Math.round(b)).appendTo(g)),this.drawing=0,this},destroy:function(){this.bgiframe&&this.bgiframe.remove(),this.qtip._unbind([a,this.qtip.tooltip],this._ns)}}),Aa=R.ie6=function(a){return 6===da.ie?new x(a):E},Aa.initialize="render",B.ie6={"^content|style$":function(){this.redraw()}}})}(window,document);
5 |
--------------------------------------------------------------------------------
/files/snippets.css:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2010 - 2012 Amethyst Reese
3 | * Copyright (c) 2012 - 2021 MantisBT Team - mantisbt-dev@lists.sourceforge.net
4 | * Licensed under the MIT license
5 | */
6 |
7 | .snippetsTooltip {
8 | position: fixed;
9 | top: 0;
10 | left: 0;
11 | z-index: 3;
12 | background: #FAF3AA;
13 | border: 1px dotted #000;
14 | padding: 4px;
15 | display: none;
16 | font-size: 8pt;
17 | }
18 |
19 | .snippetsTooltip table {
20 | margin: 5px;
21 | padding: 0px;
22 | }
23 | .snippetsTooltip td {
24 | padding: 1px;
25 | font-size: 8pt;
26 | }
27 |
28 | .qtip-content table {
29 | background-color: transparent !important;
30 | }
31 | .qtip-content table td {
32 | padding: 0 5px;
33 | }
34 |
35 | /* Snippets list layout */
36 | .width-5 {
37 | width: 5%;
38 | }
39 |
40 | table#snippets-list-footer {
41 | background-color: transparent !important;
42 | margin-bottom: 0 !important;
43 | }
44 |
45 | tr.spacer > td {
46 | border-bottom-width: 0 !important;
47 | }
48 |
--------------------------------------------------------------------------------
/files/snippets.js:
--------------------------------------------------------------------------------
1 | // Copyright (c) 2010 - 2012 Amethyst Reese
2 | // Copyright (c) 2012 - 2021 MantisBT Team - mantisbt-dev@lists.sourceforge.net
3 | // Licensed under the MIT license
4 |
5 | jQuery(function($) {
6 | "use strict";
7 |
8 | /**
9 | * Return MantisBT REST API URL for given endpoint
10 | * @param {string} endpoint
11 | * @returns {string} REST API URL
12 | */
13 | function rest_api(endpoint) {
14 | // Using the full URL (through index.php) to avoid issues on sites
15 | // where URL rewriting is not working (#31)
16 | return "api/rest/index.php/plugins/Snippets/" + endpoint;
17 | }
18 |
19 | /**
20 | * Primary Snippets functionality.
21 | * Use an AJAX request to retrieve the user's available snippets, and
22 | * then insert select boxes into the DOM for each supported textarea.
23 | */
24 | function SnippetsInit() {
25 | /**
26 | * Initialize Snippets user interface.
27 | * Adds a selection list before each textarea.
28 | * @param {object} data - JSON object returned by REST API (see PHPDoc
29 | * for Snippets::route_data() for details)
30 | * @param {string} data.selector
31 | * @param {string} data.label
32 | * @param {string} data.default
33 | * @param {object} data.snippets - Snippets list
34 | */
35 | function SnippetsUI(data) {
36 | $(data.selector).each(function() {
37 | const textarea = $(this);
38 |
39 | // Only display snippets selector if there are any
40 | if (Array.isArray(data.snippets) && data.snippets.length > 0) {
41 | try {
42 | // Create Snippets select
43 | const select = $("");
44 |
45 | // Set the Tab index equal to the associated textareas
46 | select.attr('tabindex', textarea.attr('tabindex'));
47 |
48 | select.append("");
49 |
50 | $.each(data.snippets, function(key, snippet) {
51 | // Escape single quotes
52 | const value = snippet.value.replace(/'/g, "'");
53 |
54 | select.append(
55 | ""
56 | );
57 | });
58 |
59 | select.on('change', function() {
60 | const text = $(this).val();
61 | textarea.textrange('replace', text);
62 | $(this).val("");
63 | });
64 |
65 | const label = $("");
66 | label.append(select);
67 |
68 | textarea.before(label);
69 | textarea.before('');
70 | } catch(e) {
71 | console.error('Error occurred while generating Snippets UI', e);
72 | }
73 | }
74 | });
75 | }
76 |
77 | // If we have any textareas (excluding those in the plugin's own
78 | // edit pages) then fetch Snippets
79 | if ($("textarea").not(".snippetspatternhelp textarea").length > 0) {
80 | // Retrieve the bug id from the known forms where we know
81 | // Snippets-supported textareas exist.
82 | const known_forms = ['bug_update.php', 'bugnote_add.php', 'bug_reminder.php'];
83 | let selector = '';
84 | known_forms.forEach(function (value) {
85 | selector += "form[action='" + value + "'], ";
86 | });
87 | selector = selector.replace(/, $/, '');
88 | const bug_id = $('input[name="bug_id"]', selector).val();
89 |
90 | let url = rest_api('data');
91 | if (bug_id > 0) {
92 | url += "/" + bug_id;
93 | }
94 |
95 | $.getJSON(url)
96 | .done(SnippetsUI)
97 | .fail(function() {
98 | console.error('Error occurred while retrieving Snippets');
99 | });
100 | }
101 | }
102 |
103 | /**
104 | * Initialize Placeholder help tooltip for given object
105 | * @param {object} domObject
106 | * @param {object} data - JSON object returned by XHR
107 | */
108 | function AddTooltip(domObject, data) {
109 | domObject.qtip({
110 | content: {
111 | text: data.text,
112 | title: data.title,
113 | button: true
114 | },
115 | position: {
116 | target: domObject.children('textarea'),
117 | my: 'bottom right',
118 | at: 'top right',
119 | viewport: $(window),
120 | adjust: {
121 | method: 'flip'
122 | }
123 | },
124 | hide: {
125 | fixed: true
126 | }
127 | });
128 | }
129 |
130 |
131 | try {
132 | SnippetsInit();
133 | } catch(e) {
134 | alert(e);
135 | }
136 |
137 | // Snippet list behaviors
138 | $("input.snippets_select_all").on('change', function() {
139 | $("input[name='snippet_list[]']").prop("checked", $(this).prop("checked"));
140 | });
141 |
142 | // Snippet pattern help
143 | const selector = $(".snippetspatternhelp");
144 | if (selector.length > 0 ) {
145 | $.get(rest_api('help'))
146 | .done(function (data) {
147 | selector.each(function() {
148 | AddTooltip($(this), data);
149 | });
150 | })
151 | .fail(function () {
152 | console.error('Error occurred while retrieving Snippets pattern help');
153 | });
154 | }
155 |
156 | });
157 |
--------------------------------------------------------------------------------
/lang/strings_english.txt:
--------------------------------------------------------------------------------
1 | Snippets can contain placeholder patterns that will be replaced
50 | with contextual data when pasted into a text field.
51 |
The following placeholders are supported:
52 |
53 |
{user}
Your username
54 |
{reporter}
Bug reporter\'s name
55 |
{handler}
Bug handler\'s name
56 |
{project}
Project name
57 |
58 | ';
59 |
60 | # String to use for {handler} placeholder when issue is not assigned
61 | $s_plugin_Snippets_no_handler = '[Nobody]';
62 |
63 | $s_plugin_Snippets_textarea_names = 'Use Snippets For';
64 |
--------------------------------------------------------------------------------
/lang/strings_french.txt:
--------------------------------------------------------------------------------
1 | Les bribes peuvent contenir des marqueurs qui seront remplacés par
47 | des données contextuelles lors de leur insertion dans un champ texte.
48 |
Les marqueurs suivants sont pris en compte :
49 |
50 |
{user}
Votre nom d\'utilisateur
51 |
{reporter}
Le nom du rapporteur de la demande
52 |
{handler}
Le nom de celui à qui la demande est affectée
53 |
{project}
Le nom du projet
54 |
55 | ';
56 |
57 | $s_plugin_Snippets_no_handler = '[personne]';
58 |
59 | $s_plugin_Snippets_textarea_names = 'Utiliser Bribes Pour';
60 |
--------------------------------------------------------------------------------
/lang/strings_german.txt:
--------------------------------------------------------------------------------
1 | Textbausteine können Platzhalter enthalten, die beim Einfügen in
47 | ein Textfeld durch einen aktuellen Wert ersetzt werden.
48 |
Die folgenden Platzhalter werden unterstützt:
49 |
50 |
{user}
Ihr Benutzername
51 |
{reporter}
Benutzername des Reporters
52 |
{handler}
Benutzername dem der Eintrag zugeordnet ist
53 |
{project}
Projektname
54 |
55 | ';
56 |
57 | $s_plugin_Snippets_textarea_names = 'Verwende Textbausteinen in';
58 |
--------------------------------------------------------------------------------
/lang/strings_korean.txt:
--------------------------------------------------------------------------------
1 | Snippets can contain placeholder patterns that will be replaced
47 | with contextual data when pasted into a text field.
48 |
The following placeholders are supported:
49 |
50 |
{user}
Your username
51 |
{reporter}
Bug reporter\'s name
52 |
{handler}
Bug handler\'s name
53 |
{project}
Project name
54 |
55 | ';
56 |
57 | $s_plugin_Snippets_textarea_names = 'Use Snippets For';
58 |
--------------------------------------------------------------------------------
/lang/strings_spanish.txt:
--------------------------------------------------------------------------------
1 | Los Snippets pueden contener patrones de marcador de posición que se reemplazarán
47 | con datos contextuales cuando se use en un campo de texto.
48 |