Version Description
Highlights:
- Better import/export functionality
- New settings page with code editor settings
- Code rewritten for cleaner and more efficient code
Lots of new translations
Removed old admin style support
Removed backwards-compatible support
Added braces to single-line conditionals in line with new coding standards
Split up large classes into separate functions
Improved plugin file structure
Replaced uninstall hook with single file method
Added link to Code Snippets importer under Snippets admin menu
Added settings component and admin page
Added support for different CodeMirror themes
Integrated tags component into main plugin. Current users of the Code Snippets Tags plugin can safely uninstall it.
Added Auto Close Brackets CodeMirror addon (props to TronicLabs)
Fixed incompatibility errors with PHP 5.2
Added Serbo-Croatian translation by Borisa Djuraskovic from Web Hosting Hub
Fixed empty MO translation files
Added Highlight Selection Matches CodeMirror addon (props to TronicLabs)
Added Chinese translation thanks to Jincheng Shan
Updated CodeMirror library to version 4.6
Added Russian translation by Alexander Samsonov
Added Slovak translation by [Jn Fajk] from WordPress Slovakia
Added setting to always save and activate snippets by default
Updated CodeMirror library to version 5.0
Rewritten import/export functionality to use DOMDocument
Merged Code_Snippets_Export_PHP class into Code_Snippets_Export class
Removed duplicate MySQL primary key indexing
Release Info
Developer | bungeshea |
Plugin | Code Snippets |
Version | 2.0 |
Comparing to | |
See all releases |
Code changes from version 1.9.1.1 to 2.0
- code-snippets.php +119 -1219
- css/build/edit-snippet.css +53 -0
- css/build/manage-snippets.css +80 -0
- css/build/menu-icon.css +16 -0
- css/edit-snippet.scss +51 -0
- css/font/code-snippets.eot +0 -0
- css/font/code-snippets.svg +11 -0
- css/font/code-snippets.ttf +0 -0
- css/font/code-snippets.woff +0 -0
- css/manage-snippets.scss +84 -0
- css/menu-icon.scss +19 -0
- css/min/edit-snippet.css +1 -0
- css/min/manage-snippets.css +1 -0
- css/min/menu-icon.css +1 -0
- includes/admin.php +224 -0
- includes/caps.php +60 -0
- includes/class-export.php +254 -190
- includes/db.php +146 -0
- includes/edit/admin-help.php +47 -0
- includes/edit/admin-messages.php +36 -0
- includes/edit/admin.php +146 -0
- includes/edit/edit.php +370 -0
- includes/editor.php +40 -0
- includes/import/admin-help.php +41 -0
- includes/import/admin-messages.php +32 -0
- includes/import/admin.php +45 -0
- includes/import/import.php +115 -0
- includes/manage/admin-help.php +41 -0
- includes/manage/admin-messages.php +42 -0
- includes/manage/admin.php +51 -0
- includes/manage/class-list-table.php +815 -0
- includes/manage/manage.php +106 -0
- includes/settings/admin.php +54 -0
- includes/settings/editor-preview.php +156 -0
- includes/settings/settings-fields.php +41 -0
- includes/settings/settings.php +243 -0
- includes/snippet-ops.php +493 -0
- includes/upgrade.php +61 -0
- js/vendor/jquery.tagit.css +67 -0
- js/vendor/tag-it.min.js +16 -0
- js/vendor/tagit.ui-zendesk.css +56 -0
- languages/code-snippets-de_DE.mo +0 -0
- languages/code-snippets-it_IT.mo +0 -0
- languages/code-snippets-it_IT.po +502 -0
- languages/code-snippets-ja_JP.mo +0 -0
- languages/code-snippets-ja_JP.po +569 -0
- languages/code-snippets-ru_RU.mo +0 -0
- languages/code-snippets-ru_RU.po +610 -0
- languages/code-snippets-sk_SK.mo +0 -0
- languages/code-snippets-sk_SK.po +596 -0
- languages/code-snippets-sr_RS.mo +0 -0
- languages/code-snippets-sr_RS.po +571 -0
- languages/code-snippets-zh_CN.mo +0 -0
- languages/code-snippets-zh_CN.po +517 -0
- languages/code-snippets.mo +0 -0
- languages/code-snippets.pot +675 -419
- license.txt +7 -7
- readme.txt +355 -319
- uninstall.php +74 -0
- vendor/codemirror/addon/edit/matchbrackets.js +120 -87
- vendor/codemirror/addon/search/search.js +164 -133
- vendor/codemirror/addon/search/searchcursor.js +189 -143
- vendor/codemirror/lib/codemirror.css +309 -263
- vendor/codemirror/lib/codemirror.js +8045 -5942
- vendor/codemirror/mode/clike/clike.js +489 -362
- vendor/codemirror/mode/php/php.js +129 -132
@@ -1,1219 +1,119 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/**
|
4 |
-
* Code Snippets - An easy, clean and simple way to add code snippets to your site.
|
5 |
-
*
|
6 |
-
* If you're interested in helping to develop Code Snippets, or perhaps
|
7 |
-
* contribute to the localization, please see http://code-snippets.bungeshea.com
|
8 |
-
*
|
9 |
-
* @package Code_Snippets
|
10 |
-
* @version
|
11 |
-
* @author Shea Bunge <http://bungeshea.com/>
|
12 |
-
* @copyright Copyright (c) 2012-2014, Shea Bunge
|
13 |
-
* @link http://code-snippets.bungeshea.com
|
14 |
-
* @license http://opensource.org/licenses/MIT
|
15 |
-
*/
|
16 |
-
|
17 |
-
/*
|
18 |
-
Plugin Name: Code Snippets
|
19 |
-
Plugin URI: http://code-snippets.bungeshea.com
|
20 |
-
Description: An easy, clean and simple way to add code snippets to your site. No need to edit to your theme's functions.php file again!
|
21 |
-
Author: Shea Bunge
|
22 |
-
Author URI: http://bungeshea.com
|
23 |
-
Version:
|
24 |
-
License: MIT
|
25 |
-
License URI: license.txt
|
26 |
-
Text Domain: code-snippets
|
27 |
-
Domain Path: /languages/
|
28 |
-
*/
|
29 |
-
|
30 |
-
/* Exit if accessed directly */
|
31 |
-
if ( ! defined( 'ABSPATH' ) )
|
32 |
-
exit;
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
*
|
38 |
-
*
|
39 |
-
*
|
40 |
-
*
|
41 |
-
*
|
42 |
-
*
|
43 |
-
*
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
* @var string
|
121 |
-
*/
|
122 |
-
public $admin_manage, $admin_single, $admin_import,
|
123 |
-
$admin_manage_url, $admin_single_url, $admin_import_url = '';
|
124 |
-
|
125 |
-
/**
|
126 |
-
* The constructor function for our class
|
127 |
-
*
|
128 |
-
* This method is called just as this plugin is included,
|
129 |
-
* so other plugins may not have loaded yet. Only do stuff
|
130 |
-
* here that really can't wait
|
131 |
-
*
|
132 |
-
* @since 1.0
|
133 |
-
* @access private
|
134 |
-
* @return void
|
135 |
-
*/
|
136 |
-
function __construct() {
|
137 |
-
|
138 |
-
/* Initialize the variables holding the snippet table names */
|
139 |
-
$this->set_table_vars();
|
140 |
-
|
141 |
-
/* Add backwards-compatibly for the CS_SAFE_MODE constant */
|
142 |
-
if ( defined( 'CS_SAFE_MODE' ) && ! defined( 'CODE_SNIPPETS_SAFE_MODE' ) ) {
|
143 |
-
define( 'CODE_SNIPPETS_SAFE_MODE', CS_SAFE_MODE );
|
144 |
-
}
|
145 |
-
|
146 |
-
/* Execute the snippets once the plugins are loaded */
|
147 |
-
add_action( 'plugins_loaded', array( $this, 'run_snippets' ), 1 );
|
148 |
-
|
149 |
-
/* Hook our initialize function to the plugins_loaded action */
|
150 |
-
add_action( 'plugins_loaded', array( $this, 'init' ) );
|
151 |
-
|
152 |
-
}
|
153 |
-
|
154 |
-
/**
|
155 |
-
* Load the plugin completely
|
156 |
-
*
|
157 |
-
* This method is called *after* other plugins
|
158 |
-
* have been run
|
159 |
-
*
|
160 |
-
* @since 1.7
|
161 |
-
* @access public
|
162 |
-
* @return void
|
163 |
-
*/
|
164 |
-
public function init() {
|
165 |
-
|
166 |
-
/* Initialize core variables */
|
167 |
-
$this->setup_vars();
|
168 |
-
|
169 |
-
/* Check if we need to change some stuff */
|
170 |
-
$this->upgrade();
|
171 |
-
|
172 |
-
/*
|
173 |
-
* Load up the localization file if we're using WordPress in a different language.
|
174 |
-
* Place it in this plugin's "languages" folder and name it "code-snippets-[value in wp-config].mo"
|
175 |
-
*
|
176 |
-
* If you wish to contribute a language file to be included in the Code Snippets package,
|
177 |
-
* please see create an issue on GitHub: https://github.com/bungeshea/code-snippets/issues
|
178 |
-
*/
|
179 |
-
load_plugin_textdomain( 'code-snippets', false, dirname( $this->basename ) . '/languages/' );
|
180 |
-
|
181 |
-
/* Cleanup the plugin data on uninstall */
|
182 |
-
register_uninstall_hook( $this->file, array( __CLASS__, 'uninstall' ) );
|
183 |
-
|
184 |
-
/* Load the global functions file */
|
185 |
-
$this->get_include( 'functions' );
|
186 |
-
|
187 |
-
/* Add and remove capabilities from Super Admins if their statuses change */
|
188 |
-
add_action( 'grant_super_admin', array( $this, 'add_ms_cap_to_user' ) );
|
189 |
-
add_action( 'remove_super_admin', array( $this, 'remove_ms_cap_from_user' ) );
|
190 |
-
|
191 |
-
/* Let extension plugins know that it's okay to load */
|
192 |
-
do_action( 'code_snippets_init' );
|
193 |
-
}
|
194 |
-
|
195 |
-
/**
|
196 |
-
* Initialize variables
|
197 |
-
*
|
198 |
-
* @since 1.2
|
199 |
-
* @access private
|
200 |
-
* @return void
|
201 |
-
*/
|
202 |
-
function setup_vars() {
|
203 |
-
|
204 |
-
/* Plugin directory variables */
|
205 |
-
$this->file = __FILE__;
|
206 |
-
$this->basename = plugin_basename( $this->file );
|
207 |
-
$this->plugin_dir = plugin_dir_path( $this->file );
|
208 |
-
$this->plugin_url = plugin_dir_url ( $this->file );
|
209 |
-
|
210 |
-
/* Roles and capabilities variables */
|
211 |
-
$this->role = apply_filters( 'code_snippets_role', 'administrator' );
|
212 |
-
$this->cap = apply_filters( 'code_snippets_cap', 'manage_snippets' );
|
213 |
-
$this->network_cap = apply_filters( 'code_snippets_network_cap', 'manage_network_snippets' );
|
214 |
-
|
215 |
-
if ( is_admin() ) {
|
216 |
-
|
217 |
-
/* Load our administration class */
|
218 |
-
$this->get_include( 'class-admin' );
|
219 |
-
$this->admin = new Code_Snippets_Admin;
|
220 |
-
|
221 |
-
/* Remap deprecated variables */
|
222 |
-
$this->admin_manage_url = &$this->admin->manage_url;
|
223 |
-
$this->admin_single_url = &$this->admin->single_url;
|
224 |
-
$this->admin_import_url = &$this->admin->import_url;
|
225 |
-
|
226 |
-
$this->admin_manage = &$this->admin->manage_page;
|
227 |
-
$this->admin_single = &$this->admin->single_page;
|
228 |
-
$this->admin_import = &$this->admin->import_page;
|
229 |
-
}
|
230 |
-
}
|
231 |
-
|
232 |
-
/**
|
233 |
-
* Require a PHP file from the includes directory
|
234 |
-
* @since 1.8
|
235 |
-
* @param string $slug The file slug (filename with no path or extension) to load
|
236 |
-
* @return void
|
237 |
-
*/
|
238 |
-
public function get_include( $slug ) {
|
239 |
-
require_once $this->plugin_dir . "includes/{$slug}.php";
|
240 |
-
}
|
241 |
-
|
242 |
-
/**
|
243 |
-
* Register the snippet table names with WordPress
|
244 |
-
*
|
245 |
-
* @since 1.7
|
246 |
-
* @access public
|
247 |
-
* @uses $wpdb
|
248 |
-
* @return void
|
249 |
-
*/
|
250 |
-
public function set_table_vars() {
|
251 |
-
global $wpdb;
|
252 |
-
|
253 |
-
/* Register the snippet table names with WordPress */
|
254 |
-
$wpdb->tables[] = 'snippets';
|
255 |
-
$wpdb->ms_global_tables[] = 'ms_snippets';
|
256 |
-
|
257 |
-
/* Setup initial table variables */
|
258 |
-
$wpdb->snippets = $wpdb->prefix . 'snippets';
|
259 |
-
$wpdb->ms_snippets = $wpdb->base_prefix . 'ms_snippets';
|
260 |
-
|
261 |
-
/* Add a pointer to the old variables */
|
262 |
-
$this->table = &$wpdb->snippets;
|
263 |
-
$this->ms_table = &$wpdb->ms_snippets;
|
264 |
-
}
|
265 |
-
|
266 |
-
/**
|
267 |
-
* Return the appropriate snippet table name
|
268 |
-
*
|
269 |
-
* @since 1.6
|
270 |
-
* @access public
|
271 |
-
* @param string $scope Retrieve the multisite table name or the site table name?
|
272 |
-
* @param boolean $check_screen Query the current screen if no scope passed?
|
273 |
-
* @return string The snippet table name
|
274 |
-
*/
|
275 |
-
public function get_table_name( $scope = '', $check_screen = true ) {
|
276 |
-
global $wpdb;
|
277 |
-
|
278 |
-
/* If multisite is not active, always return the site-wide table name */
|
279 |
-
if ( ! is_multisite() ) {
|
280 |
-
$network = false;
|
281 |
-
}
|
282 |
-
|
283 |
-
/* If the scope is 'multisite' or 'network', return the network-wide table name */
|
284 |
-
elseif ( in_array( $scope, array( 'multisite', 'network' ) ) ) {
|
285 |
-
$network = true;
|
286 |
-
}
|
287 |
-
|
288 |
-
/* If no scope is set, query the current screen to see if in network admin */
|
289 |
-
elseif ( empty( $scope ) && $check_screen && function_exists( 'get_current_screen' ) ) {
|
290 |
-
$network = get_current_screen()->is_network;
|
291 |
-
}
|
292 |
-
|
293 |
-
/* If none of the above conditions match, just use the site-wide table name */
|
294 |
-
else {
|
295 |
-
$network = false;
|
296 |
-
}
|
297 |
-
|
298 |
-
/* Retrieve the table name from $wpdb depending on the above conditionals */
|
299 |
-
return ( $network ? $wpdb->ms_snippets : $wpdb->snippets );
|
300 |
-
}
|
301 |
-
|
302 |
-
/**
|
303 |
-
* Create the snippet tables if they do not already exist
|
304 |
-
*
|
305 |
-
* @since 1.7.1
|
306 |
-
* @access public
|
307 |
-
*
|
308 |
-
* @uses $this->create_table() To create a single snippet table
|
309 |
-
* @staticvar boolean $tables_created Used to check if we've already done this or not
|
310 |
-
* @param boolean $redo Skip the already-done-this check
|
311 |
-
* @param boolean $always_create_table Always create the site-wide table if it doesn't exist
|
312 |
-
* @return void
|
313 |
-
*/
|
314 |
-
public function maybe_create_tables( $redo = false, $always_create_table = false ) {
|
315 |
-
|
316 |
-
/* Bail early if we've done this already */
|
317 |
-
if ( ! $redo && true === self::$tables_created )
|
318 |
-
return;
|
319 |
-
|
320 |
-
global $wpdb;
|
321 |
-
|
322 |
-
/* Set the table name variables if not yet defined */
|
323 |
-
if ( ! isset( $wpdb->snippets, $wpdb->ms_snippets ) ) {
|
324 |
-
$this->set_table_vars();
|
325 |
-
}
|
326 |
-
|
327 |
-
/* Always create the network-wide snippet table */
|
328 |
-
if ( is_multisite() ) {
|
329 |
-
$this->create_table( $wpdb->ms_snippets );
|
330 |
-
}
|
331 |
-
|
332 |
-
/* Create the site-specific table if we're on the main site */
|
333 |
-
if ( $always_create_table || is_main_site() ) {
|
334 |
-
$this->create_table( $wpdb->snippets );
|
335 |
-
}
|
336 |
-
|
337 |
-
/* Set the flag so we don't have to do this again */
|
338 |
-
self::$tables_created = true;
|
339 |
-
}
|
340 |
-
|
341 |
-
/**
|
342 |
-
* Create the snippet tables if they do not already exist
|
343 |
-
*
|
344 |
-
* @since Code Snippets 1.2
|
345 |
-
* @deprecated Code Snippets 1.7.1
|
346 |
-
* @access public
|
347 |
-
* @return void
|
348 |
-
*/
|
349 |
-
public function create_tables() {
|
350 |
-
_deprecated_function(
|
351 |
-
'$code_snippets->create_tables()',
|
352 |
-
'Code Snippets 1.7.1',
|
353 |
-
'$code_snippets->maybe_create_tables()'
|
354 |
-
);
|
355 |
-
$this->maybe_create_tables();
|
356 |
-
}
|
357 |
-
|
358 |
-
/**
|
359 |
-
* Create a single snippet table
|
360 |
-
* if one of the same name does not already exist
|
361 |
-
*
|
362 |
-
* @since 1.6
|
363 |
-
* @access private
|
364 |
-
*
|
365 |
-
* @uses dbDelta() To add the table to the database
|
366 |
-
*
|
367 |
-
* @param string $table_name The name of the table to create
|
368 |
-
* @param boolean $force_creation Skip the table exists check
|
369 |
-
* @return void
|
370 |
-
*/
|
371 |
-
function create_table( $table_name, $force_creation = false ) {
|
372 |
-
require_once ABSPATH . 'wp-admin/includes/upgrade.php';
|
373 |
-
|
374 |
-
global $wpdb;
|
375 |
-
|
376 |
-
if ( ! $force_creation && $wpdb->get_var( "SHOW TABLES LIKE '$wpdb->snippets'" ) === $wpdb->snippets ) {
|
377 |
-
return; // bail if the table already exists
|
378 |
-
}
|
379 |
-
|
380 |
-
/* Set the database charset */
|
381 |
-
|
382 |
-
$charset_collate = '';
|
383 |
-
|
384 |
-
if ( ! empty( $wpdb->charset ) ) {
|
385 |
-
$charset_collate = "DEFAULT CHARACTER SET $wpdb->charset";
|
386 |
-
}
|
387 |
-
|
388 |
-
if ( ! empty( $wpdb->collate ) ) {
|
389 |
-
$charset_collate .= " COLLATE $wpdb->collate";
|
390 |
-
}
|
391 |
-
|
392 |
-
/* Set the snippet data columns */
|
393 |
-
|
394 |
-
$table_columns = apply_filters( 'code_snippets/database_table_columns', array(
|
395 |
-
'name tinytext not null',
|
396 |
-
'description text',
|
397 |
-
'code longtext not null',
|
398 |
-
) );
|
399 |
-
|
400 |
-
$table_columns_sql = implode( ",\n", $table_columns ); // convert the array into SQL code
|
401 |
-
|
402 |
-
/* Create the database table */
|
403 |
-
|
404 |
-
$sql = "CREATE TABLE $table_name (
|
405 |
-
id bigint(20) unsigned not null auto_increment,
|
406 |
-
{$table_columns_sql},
|
407 |
-
active tinyint(1) not null default 0,
|
408 |
-
PRIMARY KEY (id),
|
409 |
-
KEY id (id)
|
410 |
-
|
411 |
-
) {$charset_collate};";
|
412 |
-
|
413 |
-
dbDelta( apply_filters( 'code_snippets/table_sql', $sql ) );
|
414 |
-
|
415 |
-
do_action( 'code_snippets/create_table', $table_name );
|
416 |
-
}
|
417 |
-
|
418 |
-
/**
|
419 |
-
* Preform upgrade tasks such as deleting and updating options
|
420 |
-
*
|
421 |
-
* @since 1.2
|
422 |
-
* @access private
|
423 |
-
* @return void
|
424 |
-
*/
|
425 |
-
function upgrade() {
|
426 |
-
global $wpdb;
|
427 |
-
|
428 |
-
/* Get the current plugin version from the database */
|
429 |
-
|
430 |
-
$current_version = get_option( 'code_snippets_version' );
|
431 |
-
|
432 |
-
if ( ! $current_version && get_option( 'cs_db_version' ) ) {
|
433 |
-
$current_version = get_option( 'cs_db_version' );
|
434 |
-
delete_option( 'cs_db_version' );
|
435 |
-
add_option( 'code_snippets_version', $current_version );
|
436 |
-
}
|
437 |
-
|
438 |
-
$previous_version = ( $current_version ? $current_version : $this->version );
|
439 |
-
|
440 |
-
/* Skip this if we're on the latest version */
|
441 |
-
if ( version_compare( $current_version, $this->version, '<' ) ) {
|
442 |
-
|
443 |
-
/* Remove capabilities that were deprecated in 1.9 */
|
444 |
-
if ( version_compare( $current_version, '1.9', '<' ) ) {
|
445 |
-
$role = get_role( $this->role );
|
446 |
-
|
447 |
-
$role->remove_cap( 'install_network_snippets' );
|
448 |
-
$role->remove_cap( 'edit_network_snippets' );
|
449 |
-
}
|
450 |
-
|
451 |
-
/* Data in database is unescaped in 1.8; slashes removed in 1.9 */
|
452 |
-
if ( version_compare( $current_version, '1.9', '<' ) ) {
|
453 |
-
|
454 |
-
$tables = array();
|
455 |
-
|
456 |
-
if ( $wpdb->get_var( "SHOW TABLES LIKE '$wpdb->snippets'" ) === $wpdb->snippets ) {
|
457 |
-
$tables[] = $wpdb->snippets;
|
458 |
-
}
|
459 |
-
|
460 |
-
if ( is_multisite() && is_main_site() && $wpdb->get_var( "SHOW TABLES LIKE '$wpdb->ms_snippets'" ) === $wpdb->ms_snippets ) {
|
461 |
-
$tables[] = $wpdb->ms_snippets;
|
462 |
-
}
|
463 |
-
|
464 |
-
foreach ( $tables as $table ) {
|
465 |
-
$snippets = $wpdb->get_results( "SELECT * FROM $table" );
|
466 |
-
|
467 |
-
foreach ( $snippets as $snippet ) {
|
468 |
-
|
469 |
-
$snippet->name = stripslashes( $snippet->name );
|
470 |
-
$snippet->code = stripslashes( $snippet->code );
|
471 |
-
$snippet->description = stripslashes( $snippet->description );
|
472 |
-
|
473 |
-
if ( version_compare( $current_version, '1.8', '<' ) ) {
|
474 |
-
$snippet->name = htmlspecialchars_decode( $snippet->name );
|
475 |
-
$snippet->code = htmlspecialchars_decode( $snippet->code );
|
476 |
-
$snippet->description = htmlspecialchars_decode( $snippet->description );
|
477 |
-
}
|
478 |
-
|
479 |
-
$wpdb->update( $table,
|
480 |
-
array(
|
481 |
-
'name' => $snippet->name,
|
482 |
-
'code' => $snippet->code,
|
483 |
-
'description' => $snippet->description
|
484 |
-
),
|
485 |
-
array( 'id' => $snippet->id ),
|
486 |
-
array( '%s' ),
|
487 |
-
array( '%d' )
|
488 |
-
);
|
489 |
-
}
|
490 |
-
} // end $table foreach
|
491 |
-
|
492 |
-
} // end < 1.8 version check
|
493 |
-
|
494 |
-
/* Register the capabilities once only */
|
495 |
-
if ( version_compare( $current_version, '1.5', '<' ) ) {
|
496 |
-
$this->add_cap();
|
497 |
-
}
|
498 |
-
|
499 |
-
if ( version_compare( $previous_version, '1.2', '<' ) ) {
|
500 |
-
/* The 'Complete Uninstall' option was removed in version 1.2 */
|
501 |
-
delete_option( 'cs_complete_uninstall' );
|
502 |
-
}
|
503 |
-
|
504 |
-
/* Update the current version stored in the database */
|
505 |
-
update_option( 'code_snippets_version', $this->version );
|
506 |
-
}
|
507 |
-
|
508 |
-
/* Multisite-only upgrades */
|
509 |
-
|
510 |
-
if ( is_multisite() && is_main_site() ) {
|
511 |
-
|
512 |
-
$current_ms_version = get_site_option( 'code_snippets_version' );
|
513 |
-
|
514 |
-
if ( version_compare( $current_ms_version, $this->version, '<' ) ) {
|
515 |
-
|
516 |
-
/* Remove capabilities that were deprecated in 1.9 */
|
517 |
-
if ( version_compare( $current_version, '1.9', '<' ) ) {
|
518 |
-
$supers = get_super_admins();
|
519 |
-
|
520 |
-
foreach ( $supers as $admin ) {
|
521 |
-
$user = new WP_User( 0, $admin );
|
522 |
-
$user->remove_cap( 'install_network_snippets' );
|
523 |
-
$user->remove_cap( 'edit_network_snippets' );
|
524 |
-
}
|
525 |
-
}
|
526 |
-
|
527 |
-
/* Add custom capabilities introduced in 1.5 */
|
528 |
-
if ( version_compare( $current_ms_version, '1.5', '<' ) ) {
|
529 |
-
$this->setup_ms_roles( true );
|
530 |
-
}
|
531 |
-
|
532 |
-
/* Migrate recently_network_activated_snippets to the site options */
|
533 |
-
if ( get_option( 'recently_network_activated_snippets' ) ) {
|
534 |
-
|
535 |
-
add_site_option(
|
536 |
-
'recently_activated_snippets',
|
537 |
-
get_option( 'recently_network_activated_snippets', array() )
|
538 |
-
);
|
539 |
-
|
540 |
-
delete_option( 'recently_network_activated_snippets' );
|
541 |
-
}
|
542 |
-
|
543 |
-
}
|
544 |
-
|
545 |
-
update_site_option( 'code_snippets_version', $this->version );
|
546 |
-
}
|
547 |
-
|
548 |
-
}
|
549 |
-
|
550 |
-
/**
|
551 |
-
* Register the user roles and capabilities
|
552 |
-
*
|
553 |
-
* @since 1.9 Removed uninstall functionality into a separate method
|
554 |
-
* @since 1.5
|
555 |
-
* @access private
|
556 |
-
* @return void
|
557 |
-
*/
|
558 |
-
function add_cap() {
|
559 |
-
|
560 |
-
/* Retrieve the role object */
|
561 |
-
$role = get_role( $this->role );
|
562 |
-
|
563 |
-
/* Add the capability */
|
564 |
-
$role->add_cap( $this->cap );
|
565 |
-
}
|
566 |
-
|
567 |
-
/**
|
568 |
-
* Deregister the user roles and capabilities
|
569 |
-
*
|
570 |
-
* @since 1.9
|
571 |
-
* @access private
|
572 |
-
* @return void
|
573 |
-
*/
|
574 |
-
function remove_cap() {
|
575 |
-
|
576 |
-
/* Retrieve the role object */
|
577 |
-
$role = get_role( $this->role );
|
578 |
-
|
579 |
-
/* Remove the capability */
|
580 |
-
$role->remove_cap( $this->cap );
|
581 |
-
}
|
582 |
-
|
583 |
-
/**
|
584 |
-
* Register or deregister the multisite user roles and capabilities
|
585 |
-
*
|
586 |
-
* @since 1.5
|
587 |
-
* @access private
|
588 |
-
* @param boolean $install true to add the capabilities, false to remove
|
589 |
-
* @return void
|
590 |
-
*/
|
591 |
-
function setup_ms_roles( $install = true ) {
|
592 |
-
|
593 |
-
if ( ! is_multisite() )
|
594 |
-
return;
|
595 |
-
|
596 |
-
$supers = get_super_admins();
|
597 |
-
|
598 |
-
foreach ( $supers as $admin ) {
|
599 |
-
$user = new WP_User( 0, $admin );
|
600 |
-
|
601 |
-
if ( $install )
|
602 |
-
$user->add_cap( $this->network_cap );
|
603 |
-
else
|
604 |
-
$user->remove_cap( $this->network_cap );
|
605 |
-
}
|
606 |
-
|
607 |
-
}
|
608 |
-
|
609 |
-
/**
|
610 |
-
* Add the multisite capabilities to a user
|
611 |
-
*
|
612 |
-
* @since 1.9
|
613 |
-
* @param integer $user_id The ID of the user to add the cap to
|
614 |
-
* @return void
|
615 |
-
*/
|
616 |
-
function add_ms_cap_to_user( $user_id ) {
|
617 |
-
|
618 |
-
/* Get the user from the ID */
|
619 |
-
$user = new WP_User( $user_id );
|
620 |
-
|
621 |
-
/* Add the capability */
|
622 |
-
$user->add_cap( $this->network_cap );
|
623 |
-
}
|
624 |
-
|
625 |
-
/**
|
626 |
-
* Remove the multisite capabilities from a user
|
627 |
-
*
|
628 |
-
* @since 1.9
|
629 |
-
* @param integer $user_id The ID of the user to remove the cap from
|
630 |
-
* @return void
|
631 |
-
*/
|
632 |
-
function remove_ms_cap_from_user( $user_id ) {
|
633 |
-
|
634 |
-
/* Get the user from the ID */
|
635 |
-
$user = new WP_User( $user_id );
|
636 |
-
|
637 |
-
/* Remove the capability */
|
638 |
-
$user->remove_cap( $this->network_cap );
|
639 |
-
}
|
640 |
-
|
641 |
-
/**
|
642 |
-
* Check if the current user can perform some action on snippets or not
|
643 |
-
*
|
644 |
-
* @uses current_user_can() To check if the current user can perform a task
|
645 |
-
* @uses $this->get_cap() To get the required capability
|
646 |
-
*
|
647 |
-
* @param string $deprecated Deprecated in 1.9
|
648 |
-
* @return boolean Whether the current user can perform this task or not
|
649 |
-
*
|
650 |
-
* @since 1.9 Removed multiple capability support
|
651 |
-
* @since 1.7.1.1 Moved logic to $this->get_cap() method
|
652 |
-
* @since 1.7.1
|
653 |
-
* @access public
|
654 |
-
*/
|
655 |
-
public function user_can( $deprecated = '' ) {
|
656 |
-
return current_user_can( $this->get_cap() );
|
657 |
-
}
|
658 |
-
|
659 |
-
/**
|
660 |
-
* Get the required capability to perform a certain action on snippets.
|
661 |
-
* Does not check if the user has this capability or not.
|
662 |
-
*
|
663 |
-
* If multisite, checks if *Enable Administration Menus: Snippets* is active
|
664 |
-
* under the *Settings > Network Settings* network admin menu
|
665 |
-
*
|
666 |
-
* @param string $deprecated Deprecated in 1.9
|
667 |
-
* @since 1.9 Removed first parameter
|
668 |
-
* @since 1.7.1.1
|
669 |
-
* @access public
|
670 |
-
* @return void
|
671 |
-
*/
|
672 |
-
public function get_cap( $deprecated = '' ) {
|
673 |
-
|
674 |
-
if ( is_multisite() ) {
|
675 |
-
$menu_perms = get_site_option( 'menu_items', array() );
|
676 |
-
|
677 |
-
/* If multisite is enabled and the snippet menu is not activated,
|
678 |
-
restrict snippet operations to super admins only */
|
679 |
-
if ( ! empty( $menu_perms['snippets'] ) ) {
|
680 |
-
return $this->cap;
|
681 |
-
} else {
|
682 |
-
/* The snippet menu is not activated, only allow super admins */
|
683 |
-
return $this->network_cap;
|
684 |
-
}
|
685 |
-
}
|
686 |
-
|
687 |
-
return $this->cap;
|
688 |
-
}
|
689 |
-
|
690 |
-
/**
|
691 |
-
* Converts an array of snippet data into a snippet object
|
692 |
-
*
|
693 |
-
* @since 1.7
|
694 |
-
* @access public
|
695 |
-
*
|
696 |
-
* @param mixed $data The snippet data to convert
|
697 |
-
* @return object The resulting snippet object
|
698 |
-
*/
|
699 |
-
public function build_snippet_object( $data = null ) {
|
700 |
-
|
701 |
-
$snippet = new stdClass;
|
702 |
-
|
703 |
-
/* Define an empty snippet object (or one with default values ) */
|
704 |
-
$snippet->id = 0;
|
705 |
-
$snippet->name = '';
|
706 |
-
$snippet->description = '';
|
707 |
-
$snippet->code = '';
|
708 |
-
$snippet->active = 0;
|
709 |
-
$snippet = apply_filters( 'code_snippets/build_default_snippet', $snippet );
|
710 |
-
|
711 |
-
if ( ! isset( $data ) ) {
|
712 |
-
return $snippet;
|
713 |
-
}
|
714 |
-
elseif ( is_object( $data ) ) {
|
715 |
-
/* If we already have a snippet object, merge it with the default */
|
716 |
-
return (object) array_merge( (array) $snippet, (array) $data );
|
717 |
-
}
|
718 |
-
elseif ( is_array( $data ) ) {
|
719 |
-
|
720 |
-
if ( isset( $data['id'] ) )
|
721 |
-
$snippet->id = $data['id'];
|
722 |
-
elseif ( isset( $data['snippet_id'] ) )
|
723 |
-
$snippet->id = $data['snippet_id'];
|
724 |
-
|
725 |
-
if ( isset( $data['name'] ) )
|
726 |
-
$snippet->name = $data['name'];
|
727 |
-
elseif ( isset( $data['snippet_name'] ) )
|
728 |
-
$snippet->name = $data['snippet_name'];
|
729 |
-
|
730 |
-
if ( isset( $data['description'] ) )
|
731 |
-
$snippet->description = $data['description'];
|
732 |
-
elseif ( isset( $data['snippet_description'] ) )
|
733 |
-
$snippet->description = $data['snippet_description'];
|
734 |
-
|
735 |
-
if ( isset( $data['code'] ) )
|
736 |
-
$snippet->code = $data['code'];
|
737 |
-
elseif ( isset( $data['snippet_code'] ) )
|
738 |
-
$snippet->code = $data['snippet_code'];
|
739 |
-
|
740 |
-
|
741 |
-
if ( isset( $data['active' ] ) )
|
742 |
-
$snippet->active = $data['active'];
|
743 |
-
elseif ( isset( $data['snippet_active'] ) )
|
744 |
-
$snippet->active = $data['snippet_active'];
|
745 |
-
|
746 |
-
return apply_filters( 'code_snippets/build_snippet_object', $snippet, $data );
|
747 |
-
}
|
748 |
-
|
749 |
-
return $snippet;
|
750 |
-
}
|
751 |
-
|
752 |
-
/**
|
753 |
-
* Retrieve a list of snippets from the database
|
754 |
-
*
|
755 |
-
* @since 1.7
|
756 |
-
* @access public
|
757 |
-
*
|
758 |
-
* @uses $wpdb To query the database for snippets
|
759 |
-
* @uses $this->get_table_name() To dynamically retrieve the snippet table name
|
760 |
-
*
|
761 |
-
* @param string $scope Retrieve multisite-wide or site-wide snippets?
|
762 |
-
* @return array An array of snippet objects
|
763 |
-
*/
|
764 |
-
public function get_snippets( $scope = '' ) {
|
765 |
-
global $wpdb;
|
766 |
-
|
767 |
-
$table = $this->get_table_name( $scope );
|
768 |
-
$snippets = $wpdb->get_results( "SELECT * FROM $table", ARRAY_A );
|
769 |
-
|
770 |
-
foreach ( $snippets as $index => $snippet ) {
|
771 |
-
$snippets[ $index ] = $this->unescape_snippet_data( $snippet );
|
772 |
-
}
|
773 |
-
|
774 |
-
return apply_filters( 'code_snippets/get_snippets', $snippets, $scope );
|
775 |
-
}
|
776 |
-
|
777 |
-
/**
|
778 |
-
* Escape snippet data for inserting into the database
|
779 |
-
*
|
780 |
-
* @since 1.7
|
781 |
-
* @access public
|
782 |
-
*
|
783 |
-
* @param mixed $snippet An object or array containing the data to escape
|
784 |
-
* @return object The resulting snippet object, with data escaped
|
785 |
-
*/
|
786 |
-
public function escape_snippet_data( $snippet ) {
|
787 |
-
|
788 |
-
$snippet = $this->build_snippet_object( $snippet );
|
789 |
-
|
790 |
-
/* Remove <?php and <? from beginning of snippet */
|
791 |
-
$snippet->code = preg_replace( '|^[\s]*<\?(php)?|', '', $snippet->code );
|
792 |
-
|
793 |
-
/* Remove ?> from end of snippet */
|
794 |
-
$snippet->code = preg_replace( '|\?>[\s]*$|', '', $snippet->code );
|
795 |
-
|
796 |
-
/* Escape the data */
|
797 |
-
$snippet->id = absint ( $snippet->id );
|
798 |
-
|
799 |
-
return apply_filters( 'code_snippets/escape_snippet_data', $snippet );
|
800 |
-
}
|
801 |
-
|
802 |
-
/**
|
803 |
-
* Unescape snippet data after retrieval from the database
|
804 |
-
* ready for use
|
805 |
-
*
|
806 |
-
* @since 1.7
|
807 |
-
* @access public
|
808 |
-
*
|
809 |
-
* @param mixed $snippet An object or array containing the data to unescape
|
810 |
-
* @return object The resulting snippet object, with data unescaped
|
811 |
-
*/
|
812 |
-
public function unescape_snippet_data( $snippet ) {
|
813 |
-
$snippet = $this->build_snippet_object( $snippet );
|
814 |
-
return apply_filters( 'code_snippets/unescape_snippet_data', $snippet );
|
815 |
-
}
|
816 |
-
|
817 |
-
/**
|
818 |
-
* Retrieve a single snippets from the database.
|
819 |
-
* Will return empty snippet object if no snippet
|
820 |
-
* ID is specified
|
821 |
-
*
|
822 |
-
* @since 1.7
|
823 |
-
* @access public
|
824 |
-
*
|
825 |
-
* @uses $wpdb To query the database for snippets
|
826 |
-
* @uses $this->get_table_name() To dynamically retrieve the snippet table name
|
827 |
-
*
|
828 |
-
* @param int $id The ID of the snippet to retrieve. 0 to build a new snippet
|
829 |
-
* @param string $scope Retrieve a multisite-wide or site-wide snippet?
|
830 |
-
* @return object A single snippet object
|
831 |
-
*/
|
832 |
-
public function get_snippet( $id = 0, $scope = '' ) {
|
833 |
-
global $wpdb;
|
834 |
-
$table = $this->get_table_name( $scope );
|
835 |
-
$id = absint( $id );
|
836 |
-
|
837 |
-
if ( 0 !== $id ) {
|
838 |
-
/* Retrieve the snippet from the database */
|
839 |
-
$snippet = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM $table WHERE id = %d", $id ) );
|
840 |
-
/* Unescape the snippet data, ready for use */
|
841 |
-
$snippet = $this->unescape_snippet_data( $snippet );
|
842 |
-
} else {
|
843 |
-
/* Get an empty snippet object */
|
844 |
-
$snippet = $this->build_snippet_object();
|
845 |
-
}
|
846 |
-
return apply_filters( 'code_snippets/get_snippet', $snippet, $id, $scope );
|
847 |
-
}
|
848 |
-
|
849 |
-
/**
|
850 |
-
* Activates a snippet
|
851 |
-
*
|
852 |
-
* @since 1.5
|
853 |
-
* @access public
|
854 |
-
*
|
855 |
-
* @uses $wpdb To set the snippets' active status
|
856 |
-
*
|
857 |
-
* @param array $ids The ids of the snippets to activate
|
858 |
-
* @param string $scope Are the snippets multisite-wide or site-wide?
|
859 |
-
* @return void
|
860 |
-
*/
|
861 |
-
public function activate( $ids, $scope = '' ) {
|
862 |
-
global $wpdb;
|
863 |
-
|
864 |
-
$ids = (array) $ids;
|
865 |
-
|
866 |
-
$table = $this->get_table_name( $scope );
|
867 |
-
|
868 |
-
foreach ( $ids as $id ) {
|
869 |
-
$wpdb->update(
|
870 |
-
$table,
|
871 |
-
array( 'active' => '1' ),
|
872 |
-
array( 'id' => $id ),
|
873 |
-
array( '%d' ),
|
874 |
-
array( '%d' )
|
875 |
-
);
|
876 |
-
|
877 |
-
do_action( 'code_snippets/activate_snippet', $id, $scope );
|
878 |
-
}
|
879 |
-
|
880 |
-
do_action( 'code_snippets/activate', $ids, $scope );
|
881 |
-
}
|
882 |
-
|
883 |
-
/**
|
884 |
-
* Deactivates selected snippets
|
885 |
-
*
|
886 |
-
* @since 1.5
|
887 |
-
* @access public
|
888 |
-
*
|
889 |
-
* @uses $wpdb To set the snippets' active status
|
890 |
-
*
|
891 |
-
* @param array $ids The IDs of the snippets to deactivate
|
892 |
-
* @param string $scope Are the snippets multisite-wide or site-wide?
|
893 |
-
* @return void
|
894 |
-
*/
|
895 |
-
public function deactivate( $ids, $scope = '' ) {
|
896 |
-
global $wpdb;
|
897 |
-
|
898 |
-
$ids = (array) $ids;
|
899 |
-
$recently_active = array();
|
900 |
-
|
901 |
-
$table = $this->get_table_name( $scope );
|
902 |
-
|
903 |
-
foreach ( $ids as $id ) {
|
904 |
-
$wpdb->update(
|
905 |
-
$table,
|
906 |
-
array( 'active' => '0' ),
|
907 |
-
array( 'id' => $id ),
|
908 |
-
array( '%d' ),
|
909 |
-
array( '%d' )
|
910 |
-
);
|
911 |
-
$recently_active = array( $id => time() ) + (array) $recently_active;
|
912 |
-
|
913 |
-
do_action( 'code_snippets/deactivate_snippet', $id, $scope );
|
914 |
-
}
|
915 |
-
|
916 |
-
if ( $table === $wpdb->ms_snippets )
|
917 |
-
update_site_option(
|
918 |
-
'recently_activated_snippets',
|
919 |
-
$recently_active + (array) get_site_option( 'recently_activated_snippets' )
|
920 |
-
);
|
921 |
-
elseif ( $table === $wpdb->snippets )
|
922 |
-
update_option(
|
923 |
-
'recently_activated_snippets',
|
924 |
-
$recently_active + (array) get_option( 'recently_activated_snippets' )
|
925 |
-
);
|
926 |
-
|
927 |
-
do_action( 'code_snippets/deactivate', $ids, $scope );
|
928 |
-
}
|
929 |
-
|
930 |
-
/**
|
931 |
-
* Deletes a snippet from the database
|
932 |
-
*
|
933 |
-
* @since 1.5
|
934 |
-
* @access public
|
935 |
-
*
|
936 |
-
* @uses $wpdb To access the database
|
937 |
-
* @uses $this->get_table_name() To dynamically retrieve the name of the snippet table
|
938 |
-
*
|
939 |
-
* @param int $id The ID of the snippet to delete
|
940 |
-
* @param string $scope Delete from site-wide or network-wide table?
|
941 |
-
*/
|
942 |
-
public function delete_snippet( $id, $scope = '' ) {
|
943 |
-
global $wpdb;
|
944 |
-
|
945 |
-
$wpdb->delete(
|
946 |
-
$this->get_table_name( $scope ),
|
947 |
-
array( 'id' => $id ),
|
948 |
-
array( '%d' )
|
949 |
-
);
|
950 |
-
|
951 |
-
do_action( 'code_snippets/delete_snippet', $id, $scope );
|
952 |
-
}
|
953 |
-
|
954 |
-
/**
|
955 |
-
* Saves a snippet to the database.
|
956 |
-
*
|
957 |
-
* @since 1.5
|
958 |
-
* @access public
|
959 |
-
*
|
960 |
-
* @uses $wpdb To update/add the snippet to the database
|
961 |
-
* @uses $this->get_table_name() To dynamically retrieve the name of the snippet table
|
962 |
-
*
|
963 |
-
* @param object $snippet The snippet to add/update to the database
|
964 |
-
* @param string $scope Save the snippet to the site-wide or network-wide table?
|
965 |
-
* @return int|boolean The ID of the snippet on success, false on failure
|
966 |
-
*/
|
967 |
-
public function save_snippet( $snippet, $scope = '' ) {
|
968 |
-
global $wpdb;
|
969 |
-
|
970 |
-
$snippet = $this->escape_snippet_data( $snippet );
|
971 |
-
$table = $this->get_table_name( $scope );
|
972 |
-
$data = array();
|
973 |
-
|
974 |
-
foreach ( get_object_vars( $snippet ) as $field => $value ) {
|
975 |
-
if ( 'id' === $field )
|
976 |
-
continue;
|
977 |
-
|
978 |
-
if ( is_array( $value ) )
|
979 |
-
$value = maybe_serialize( $value );
|
980 |
-
|
981 |
-
$data[ $field ] = $value;
|
982 |
-
}
|
983 |
-
|
984 |
-
if ( isset( $snippet->id ) && 0 !== $snippet->id ) {
|
985 |
-
|
986 |
-
$wpdb->update( $table, $data, array( 'id' => $snippet->id ), null, array( '%d' ) );
|
987 |
-
do_action( 'code_snippets/update_snippet', $snippet, $table );
|
988 |
-
return $snippet->id;
|
989 |
-
|
990 |
-
} else {
|
991 |
-
|
992 |
-
$wpdb->insert( $table, $data, '%s' );
|
993 |
-
do_action( 'code_snippets/create_snippet', $snippet, $table );
|
994 |
-
return $wpdb->insert_id;
|
995 |
-
}
|
996 |
-
}
|
997 |
-
|
998 |
-
/**
|
999 |
-
* Imports snippets from an XML file
|
1000 |
-
*
|
1001 |
-
* @since 1.5
|
1002 |
-
* @access public
|
1003 |
-
*
|
1004 |
-
* @uses $this->save_snippet() To add the snippets to the database
|
1005 |
-
*
|
1006 |
-
* @param string $file The path to the XML file to import
|
1007 |
-
* @param string $scope Import into network-wide table or site-wide table?
|
1008 |
-
* @return integer|boolean The number of snippets imported on success, false on failure
|
1009 |
-
*/
|
1010 |
-
public function import( $file, $scope = '' ) {
|
1011 |
-
|
1012 |
-
if ( ! file_exists( $file ) || ! is_file( $file ) )
|
1013 |
-
return false;
|
1014 |
-
|
1015 |
-
$xml = simplexml_load_file( $file );
|
1016 |
-
|
1017 |
-
if ( ! is_object( $xml ) || ! method_exists( $xml, 'children' ) )
|
1018 |
-
return false;
|
1019 |
-
|
1020 |
-
foreach ( $xml->children() as $snippet ) {
|
1021 |
-
/* force manual build of object to strip out unsupported fields
|
1022 |
-
by converting snippet object into an array */
|
1023 |
-
$snippet = get_object_vars( $snippet );
|
1024 |
-
$snippet = array_map( 'htmlspecialchars_decode', $snippet );
|
1025 |
-
$this->save_snippet( $snippet, $scope );
|
1026 |
-
}
|
1027 |
-
|
1028 |
-
do_action( 'code_snippets/import', $xml, $scope );
|
1029 |
-
|
1030 |
-
return $xml->count();
|
1031 |
-
}
|
1032 |
-
|
1033 |
-
/**
|
1034 |
-
* Exports snippets as an XML file
|
1035 |
-
*
|
1036 |
-
* @since 1.5
|
1037 |
-
* @access public
|
1038 |
-
*
|
1039 |
-
* @uses Code_Snippets_Export To export selected snippets
|
1040 |
-
* @uses $this->get_table_name() To dynamically retrieve the name of the snippet table
|
1041 |
-
*
|
1042 |
-
* @param array $ids The IDs of the snippets to export
|
1043 |
-
* @param string $scope Is the snippet a network-wide or site-wide snippet?
|
1044 |
-
* @return void
|
1045 |
-
*/
|
1046 |
-
public function export( $ids, $scope = '' ) {
|
1047 |
-
|
1048 |
-
$table = $this->get_table_name( $scope );
|
1049 |
-
|
1050 |
-
if ( ! class_exists( 'Code_Snippets_Export' ) )
|
1051 |
-
$this->get_include( 'class-export' );
|
1052 |
-
|
1053 |
-
$class = new Code_Snippets_Export( $ids, $table );
|
1054 |
-
$class->do_export();
|
1055 |
-
}
|
1056 |
-
|
1057 |
-
/**
|
1058 |
-
* Exports snippets as a PHP file
|
1059 |
-
*
|
1060 |
-
* @since 1.5
|
1061 |
-
* @access public
|
1062 |
-
*
|
1063 |
-
* @uses Code_Snippets_Export_PHP To export selected snippets
|
1064 |
-
* @uses $this->get_table_name() To dynamically retrieve the name of the snippet table
|
1065 |
-
*
|
1066 |
-
* @param array $ids The IDs of the snippets to export
|
1067 |
-
* @param string $scope Is the snippet a network-wide or site-wide snippet?
|
1068 |
-
* @return void
|
1069 |
-
*/
|
1070 |
-
public function export_php( $ids, $scope = '' ) {
|
1071 |
-
|
1072 |
-
$table = $this->get_table_name( $scope );
|
1073 |
-
|
1074 |
-
if ( ! class_exists( 'Code_Snippets_Export' ) )
|
1075 |
-
$this->get_include( 'class-export' );
|
1076 |
-
|
1077 |
-
if ( ! class_exists( 'Code_Snippets_Export_PHP' ) ) {
|
1078 |
-
$this->get_include( 'class-export-php' );
|
1079 |
-
}
|
1080 |
-
|
1081 |
-
$class = new Code_Snippets_Export_PHP( $ids, $table );
|
1082 |
-
$class->do_export();
|
1083 |
-
}
|
1084 |
-
|
1085 |
-
/**
|
1086 |
-
* Execute a snippet
|
1087 |
-
*
|
1088 |
-
* Code must NOT be escaped, as
|
1089 |
-
* it will be executed directly
|
1090 |
-
*
|
1091 |
-
* @since 1.5
|
1092 |
-
* @access public
|
1093 |
-
*
|
1094 |
-
* @param string $code The snippet code to execute
|
1095 |
-
* @return mixed The result of the code execution
|
1096 |
-
*/
|
1097 |
-
public function execute_snippet( $code ) {
|
1098 |
-
|
1099 |
-
if ( empty( $code ) )
|
1100 |
-
return;
|
1101 |
-
|
1102 |
-
ob_start();
|
1103 |
-
$result = eval( $code );
|
1104 |
-
$output = ob_get_contents();
|
1105 |
-
ob_end_clean();
|
1106 |
-
|
1107 |
-
do_action( 'code_snippets/execute_snippet', $code );
|
1108 |
-
return $result;
|
1109 |
-
}
|
1110 |
-
|
1111 |
-
/**
|
1112 |
-
* Run the active snippets
|
1113 |
-
*
|
1114 |
-
* @since 1.0
|
1115 |
-
* @access public
|
1116 |
-
*
|
1117 |
-
* @uses $wpdb To grab the active snippets from the database
|
1118 |
-
* @uses $this->execute_snippet() To execute a snippet
|
1119 |
-
*
|
1120 |
-
* @return boolean true on success, false on failure
|
1121 |
-
*/
|
1122 |
-
public function run_snippets() {
|
1123 |
-
|
1124 |
-
/* Bail early if safe mode is active */
|
1125 |
-
if ( defined( 'CODE_SNIPPETS_SAFE_MODE' ) && CODE_SNIPPETS_SAFE_MODE )
|
1126 |
-
return false;
|
1127 |
-
|
1128 |
-
global $wpdb;
|
1129 |
-
|
1130 |
-
if ( ! isset( $wpdb->snippets, $wpdb->ms_snippets ) )
|
1131 |
-
$this->set_table_vars();
|
1132 |
-
|
1133 |
-
/* Check if the snippets table exists */
|
1134 |
-
if ( $wpdb->get_var( "SHOW TABLES LIKE '$wpdb->snippets'" ) === $wpdb->snippets )
|
1135 |
-
$sql = "SELECT code FROM {$wpdb->snippets} WHERE active=1";
|
1136 |
-
|
1137 |
-
/* Check if the multisite snippets table exists */
|
1138 |
-
if ( is_multisite() && $wpdb->get_var( "SHOW TABLES LIKE '$wpdb->ms_snippets'" ) === $wpdb->ms_snippets ) {
|
1139 |
-
$sql = ( isset( $sql ) ? $sql . "\nUNION ALL\n" : '' );
|
1140 |
-
$sql .= "SELECT code FROM {$wpdb->ms_snippets} WHERE active=1;";
|
1141 |
-
}
|
1142 |
-
|
1143 |
-
if ( ! empty( $sql ) ) {
|
1144 |
-
|
1145 |
-
/* Grab the active snippets from the database */
|
1146 |
-
$active_snippets = $wpdb->get_col( $sql );
|
1147 |
-
|
1148 |
-
foreach ( $active_snippets as $snippet ) {
|
1149 |
-
/* Execute the PHP code */
|
1150 |
-
$this->execute_snippet( $snippet );
|
1151 |
-
}
|
1152 |
-
|
1153 |
-
return true;
|
1154 |
-
}
|
1155 |
-
|
1156 |
-
/* If we're made it this far without returning true, assume failure */
|
1157 |
-
return false;
|
1158 |
-
}
|
1159 |
-
|
1160 |
-
/**
|
1161 |
-
* Cleans up data created by the Code_Snippets class
|
1162 |
-
*
|
1163 |
-
* @since 1.2
|
1164 |
-
* @access private
|
1165 |
-
*
|
1166 |
-
* @uses $wpdb To remove tables from the database
|
1167 |
-
* @uses $code_snippets->get_table_name() To find out which table to drop
|
1168 |
-
* @uses is_multisite() To check the type of installation
|
1169 |
-
* @uses switch_to_blog() To switch between blogs
|
1170 |
-
* @uses restore_current_blog() To switch between blogs
|
1171 |
-
* @uses delete_option() To remove site options
|
1172 |
-
*
|
1173 |
-
* @return void
|
1174 |
-
*/
|
1175 |
-
static function uninstall() {
|
1176 |
-
global $wpdb, $code_snippets;
|
1177 |
-
if ( is_multisite() ) {
|
1178 |
-
$blog_ids = $wpdb->get_col( "SELECT blog_id FROM $wpdb->blogs" );
|
1179 |
-
if ( $blog_ids ) {
|
1180 |
-
foreach ( $blog_ids as $blog_id ) {
|
1181 |
-
switch_to_blog( $blog_id );
|
1182 |
-
$wpdb->query( "DROP TABLE IF EXISTS $wpdb->snippets" );
|
1183 |
-
delete_option( 'cs_db_version' );
|
1184 |
-
delete_option( 'recently_activated_snippets' );
|
1185 |
-
delete_option( 'code_snippets_version' );
|
1186 |
-
$code_snippets->remove_cap();
|
1187 |
-
}
|
1188 |
-
restore_current_blog();
|
1189 |
-
}
|
1190 |
-
$wpdb->query( "DROP TABLE IF EXISTS $wpdb->ms_snippets" );
|
1191 |
-
delete_site_option( 'code_snippets_version' );
|
1192 |
-
delete_site_option( 'recently_activated_snippets' );
|
1193 |
-
$code_snippets->setup_ms_roles( false );
|
1194 |
-
} else {
|
1195 |
-
$wpdb->query( "DROP TABLE IF EXISTS $wpdb->snippets" );
|
1196 |
-
delete_option( 'code_snippets_version' );
|
1197 |
-
delete_option( 'recently_activated_snippets' );
|
1198 |
-
$code_snippets->remove_cap();
|
1199 |
-
}
|
1200 |
-
}
|
1201 |
-
|
1202 |
-
}
|
1203 |
-
|
1204 |
-
/**
|
1205 |
-
* The global variable in which the Code_Snippets class is stored
|
1206 |
-
*
|
1207 |
-
* @var object
|
1208 |
-
* @since 1.0
|
1209 |
-
* @access public
|
1210 |
-
* @see Code_Snippets
|
1211 |
-
*/
|
1212 |
-
global $code_snippets;
|
1213 |
-
$code_snippets = new Code_Snippets;
|
1214 |
-
|
1215 |
-
/* Set up a pointer in the old variable (for backwards-compatibility) */
|
1216 |
-
global $cs;
|
1217 |
-
$cs = &$code_snippets;
|
1218 |
-
|
1219 |
-
endif; // class exists check
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* Code Snippets - An easy, clean and simple way to add code snippets to your site.
|
5 |
+
*
|
6 |
+
* If you're interested in helping to develop Code Snippets, or perhaps
|
7 |
+
* contribute to the localization, please see http://code-snippets.bungeshea.com
|
8 |
+
*
|
9 |
+
* @package Code_Snippets
|
10 |
+
* @version 2.0
|
11 |
+
* @author Shea Bunge <http://bungeshea.com/>
|
12 |
+
* @copyright Copyright (c) 2012-2014, Shea Bunge
|
13 |
+
* @link http://code-snippets.bungeshea.com
|
14 |
+
* @license http://opensource.org/licenses/MIT
|
15 |
+
*/
|
16 |
+
|
17 |
+
/*
|
18 |
+
Plugin Name: Code Snippets
|
19 |
+
Plugin URI: http://code-snippets.bungeshea.com
|
20 |
+
Description: An easy, clean and simple way to add code snippets to your site. No need to edit to your theme's functions.php file again!
|
21 |
+
Author: Shea Bunge
|
22 |
+
Author URI: http://bungeshea.com
|
23 |
+
Version: 2.0
|
24 |
+
License: MIT
|
25 |
+
License URI: license.txt
|
26 |
+
Text Domain: code-snippets
|
27 |
+
Domain Path: /languages/
|
28 |
+
*/
|
29 |
+
|
30 |
+
/* Exit if accessed directly */
|
31 |
+
if ( ! defined( 'ABSPATH' ) ) {
|
32 |
+
exit;
|
33 |
+
}
|
34 |
+
|
35 |
+
/**
|
36 |
+
* The version number for this release of the plugin.
|
37 |
+
* This will later be used for upgrades and enqueueing files
|
38 |
+
*
|
39 |
+
* This should be set to the 'Plugin Version' value,
|
40 |
+
* as defined above in the plugin header
|
41 |
+
*
|
42 |
+
* @since 2.0
|
43 |
+
* @var string A PHP-standardized version number string
|
44 |
+
*/
|
45 |
+
define( 'CODE_SNIPPETS_VERSION', '2.0' );
|
46 |
+
|
47 |
+
/**
|
48 |
+
* The full path to the main file of this plugin
|
49 |
+
*
|
50 |
+
* This can later be passed to functions such as
|
51 |
+
* plugin_dir_path(), plugins_url() and plugin_basename()
|
52 |
+
* to retrieve information about plugin paths
|
53 |
+
*
|
54 |
+
* @since 2.0
|
55 |
+
* @var string
|
56 |
+
*/
|
57 |
+
define( 'CODE_SNIPPETS_FILE', __FILE__ );
|
58 |
+
|
59 |
+
/**
|
60 |
+
* Load plugin files
|
61 |
+
*/
|
62 |
+
foreach ( array(
|
63 |
+
|
64 |
+
/* Database operations functions */
|
65 |
+
'db.php',
|
66 |
+
|
67 |
+
/* Capability functions */
|
68 |
+
'caps.php',
|
69 |
+
|
70 |
+
/* Snippet operations functions */
|
71 |
+
'snippet-ops.php',
|
72 |
+
|
73 |
+
/* Upgrade function */
|
74 |
+
'upgrade.php',
|
75 |
+
|
76 |
+
/* General Administration functions */
|
77 |
+
'admin.php',
|
78 |
+
|
79 |
+
/* CodeMirror editor functions */
|
80 |
+
'editor.php',
|
81 |
+
|
82 |
+
/* Manage snippets component */
|
83 |
+
'manage/manage.php',
|
84 |
+
|
85 |
+
/* Edit snippet component */
|
86 |
+
'edit/edit.php',
|
87 |
+
|
88 |
+
/* Import snippets component */
|
89 |
+
'import/import.php',
|
90 |
+
|
91 |
+
/* Settings component */
|
92 |
+
'settings/editor-preview.php',
|
93 |
+
'settings/settings-fields.php',
|
94 |
+
'settings/settings.php',
|
95 |
+
'settings/admin.php',
|
96 |
+
|
97 |
+
) as $include ) {
|
98 |
+
|
99 |
+
require plugin_dir_path( __FILE__ ) . "includes/$include";
|
100 |
+
}
|
101 |
+
|
102 |
+
/* Initialize database table variables */
|
103 |
+
set_snippet_table_vars();
|
104 |
+
|
105 |
+
/* Execute the snippets once the plugins are loaded */
|
106 |
+
add_action( 'plugins_loaded', 'execute_active_snippets', 1 );
|
107 |
+
|
108 |
+
/**
|
109 |
+
* Load up the localization file if we're using WordPress in a different language.
|
110 |
+
* Place it in this plugin's "languages" folder and name it "code-snippets-[value in wp-config].mo"
|
111 |
+
*
|
112 |
+
* If you wish to contribute a language file to be included in the Code Snippets package,
|
113 |
+
* please see create an issue on GitHub: https://github.com/bungeshea/code-snippets/issues
|
114 |
+
*/
|
115 |
+
function code_snippets_load_textdomain() {
|
116 |
+
load_plugin_textdomain( 'code-snippets', false, dirname( basename( __FILE__ ) ) . '/languages/' );
|
117 |
+
}
|
118 |
+
|
119 |
+
add_action( 'plugins_loaded', 'code_snippets_load_textdomain' );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@@ -0,0 +1,53 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
/**
|
2 |
+
* Custom styling for the single snippet admin page
|
3 |
+
*/
|
4 |
+
|
5 |
+
h3 {
|
6 |
+
/* Provide some decent space between the fields and titles */
|
7 |
+
margin: 1em 0;
|
8 |
+
}
|
9 |
+
|
10 |
+
label {
|
11 |
+
/* What's with the pointer mouse on labels? */
|
12 |
+
cursor: auto;
|
13 |
+
}
|
14 |
+
|
15 |
+
/* Position the description heading on the same level as the editor buttons */
|
16 |
+
|
17 |
+
label[for='snippet_description'] h3 div {
|
18 |
+
position: absolute;
|
19 |
+
}
|
20 |
+
|
21 |
+
/* Add spacing in between the action buttons */
|
22 |
+
|
23 |
+
.submit .button {
|
24 |
+
margin-right: 0.5em;
|
25 |
+
}
|
26 |
+
|
27 |
+
/**
|
28 |
+
* Customize the CodeMirror editor
|
29 |
+
* to look nice and support auto-resizing
|
30 |
+
*/
|
31 |
+
|
32 |
+
.CodeMirror {
|
33 |
+
width: 100%;
|
34 |
+
height: auto;
|
35 |
+
min-height: 300px;
|
36 |
+
border: 1px solid #dfdfdf;
|
37 |
+
border-radius: 3px;
|
38 |
+
background-color: white;
|
39 |
+
}
|
40 |
+
|
41 |
+
.CodeMirror-scroll {
|
42 |
+
overflow-x: auto;
|
43 |
+
overflow-y: hidden;
|
44 |
+
}
|
45 |
+
|
46 |
+
.CodeMirror-sizer {
|
47 |
+
min-height: 300px !important;
|
48 |
+
}
|
49 |
+
|
50 |
+
.CodeMirror-focused .cm-matchhighlight {
|
51 |
+
color: white !important;
|
52 |
+
outline: 1px solid green;
|
53 |
+
}
|
@@ -0,0 +1,80 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
/**
|
2 |
+
* Custom styling for the snippets table
|
3 |
+
*/
|
4 |
+
|
5 |
+
.snippets th,
|
6 |
+
.snippets td {
|
7 |
+
color: black;
|
8 |
+
}
|
9 |
+
|
10 |
+
.snippets tr {
|
11 |
+
background: white;
|
12 |
+
}
|
13 |
+
|
14 |
+
.snippets .row-actions {
|
15 |
+
color: #dddddd;
|
16 |
+
}
|
17 |
+
|
18 |
+
.snippets .clear-filters {
|
19 |
+
vertical-align: middle;
|
20 |
+
}
|
21 |
+
|
22 |
+
.snippets tfoot th {
|
23 |
+
border-top: none !important;
|
24 |
+
}
|
25 |
+
|
26 |
+
.snippets tfoot th.check-column {
|
27 |
+
padding: 13px 0 0 3px;
|
28 |
+
}
|
29 |
+
|
30 |
+
.snippets thead th.check-column,
|
31 |
+
.snippets tfoot th.check-column,
|
32 |
+
.snippets .inactive th.check-column {
|
33 |
+
padding-left: 5px;
|
34 |
+
}
|
35 |
+
|
36 |
+
.snippets .column-description p {
|
37 |
+
color: #333333;
|
38 |
+
}
|
39 |
+
|
40 |
+
.snippets .inactive a {
|
41 |
+
color: #557799;
|
42 |
+
}
|
43 |
+
|
44 |
+
.snippets .inactive td,
|
45 |
+
.snippets .inactive th,
|
46 |
+
.snippets .active td,
|
47 |
+
.snippets .active th {
|
48 |
+
padding: 10px 9px;
|
49 |
+
border: none;
|
50 |
+
-webkit-box-shadow: inset 0 -1px 0 rgba(0, 0, 0, 0.1);
|
51 |
+
box-shadow: inset 0 -1px 0 rgba(0, 0, 0, 0.1);
|
52 |
+
}
|
53 |
+
|
54 |
+
.snippets .active td,
|
55 |
+
.snippets .active th {
|
56 |
+
background-color: rgba(120, 200, 230, 0.06);
|
57 |
+
}
|
58 |
+
|
59 |
+
.snippets .active th.check-column {
|
60 |
+
border-left: 2px solid #2ea2cc;
|
61 |
+
}
|
62 |
+
|
63 |
+
.snippets tr.active + tr.inactive th,
|
64 |
+
.snippets tr.active + tr.inactive td {
|
65 |
+
border-top: 1px solid rgba(0, 0, 0, 0.03);
|
66 |
+
-webkit-box-shadow: inset 0px 1px 0 rgba(0, 0, 0, 0.02), inset 0 -1px 0 #e1e1e1;
|
67 |
+
box-shadow: inset 0px 1px 0 rgba(0, 0, 0, 0.02), inset 0 -1px 0 #e1e1e1;
|
68 |
+
}
|
69 |
+
|
70 |
+
.snippets a.delete:hover,
|
71 |
+
.snippets #all-snippets-table a.delete:hover,
|
72 |
+
.snippets #search-snippets-table a.delete:hover {
|
73 |
+
border-bottom: 1px solid red;
|
74 |
+
color: red;
|
75 |
+
}
|
76 |
+
|
77 |
+
#wpbody-content .snippets .column-name {
|
78 |
+
white-space: nowrap;
|
79 |
+
/* prevents wrapping of snippet title */
|
80 |
+
}
|
@@ -0,0 +1,16 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
/**
|
2 |
+
* Add the snippets icon to the admin menu
|
3 |
+
*/
|
4 |
+
|
5 |
+
@font-face {
|
6 |
+
font-family: 'code-snippets';
|
7 |
+
src: url('../font/code-snippets.eot');
|
8 |
+
src: url('../font/code-snippets.eot?#iefix') format('embedded-opentype'), url('../font/code-snippets.ttf') format('truetype'), url('../font/code-snippets.woff') format('woff'), url('../font/code-snippets.svg#code-snippets') format('svg');
|
9 |
+
font-weight: normal;
|
10 |
+
font-style: normal;
|
11 |
+
}
|
12 |
+
|
13 |
+
#toplevel_page_snippets div.wp-menu-image:before {
|
14 |
+
font-family: 'code-snippets' !important;
|
15 |
+
content: '\e600';
|
16 |
+
}
|
@@ -0,0 +1,51 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
/**
|
2 |
+
* Custom styling for the single snippet admin page
|
3 |
+
*/
|
4 |
+
|
5 |
+
h3 {
|
6 |
+
/* Provide some decent space between the fields and titles */
|
7 |
+
margin: 1em 0;
|
8 |
+
}
|
9 |
+
|
10 |
+
label {
|
11 |
+
/* What's with the pointer mouse on labels? */
|
12 |
+
cursor: auto;
|
13 |
+
}
|
14 |
+
|
15 |
+
/* Position the description heading on the same level as the editor buttons */
|
16 |
+
label[for='snippet_description'] h3 div {
|
17 |
+
position: absolute;
|
18 |
+
}
|
19 |
+
|
20 |
+
/* Add spacing in between the action buttons */
|
21 |
+
.submit .button {
|
22 |
+
margin-right: .5em;
|
23 |
+
}
|
24 |
+
|
25 |
+
/**
|
26 |
+
* Customize the CodeMirror editor
|
27 |
+
* to look nice and support auto-resizing
|
28 |
+
*/
|
29 |
+
.CodeMirror {
|
30 |
+
width: 100%;
|
31 |
+
height: auto;
|
32 |
+
min-height: 300px;
|
33 |
+
|
34 |
+
border: 1px solid #dfdfdf;
|
35 |
+
border-radius: 3px;
|
36 |
+
background-color: #fff;;
|
37 |
+
}
|
38 |
+
|
39 |
+
.CodeMirror-scroll {
|
40 |
+
overflow-x: auto;
|
41 |
+
overflow-y: hidden;
|
42 |
+
}
|
43 |
+
|
44 |
+
.CodeMirror-sizer {
|
45 |
+
min-height: 300px !important;
|
46 |
+
}
|
47 |
+
|
48 |
+
.CodeMirror-focused .cm-matchhighlight {
|
49 |
+
color: white !important;
|
50 |
+
outline: 1px solid green;
|
51 |
+
}
|
Binary file
|
@@ -0,0 +1,11 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0" standalone="no"?>
|
2 |
+
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd" >
|
3 |
+
<svg xmlns="http://www.w3.org/2000/svg">
|
4 |
+
<metadata>Generated by IcoMoon</metadata>
|
5 |
+
<defs>
|
6 |
+
<font id="code-snippets" horiz-adv-x="1024">
|
7 |
+
<font-face units-per-em="1024" ascent="960" descent="-64" />
|
8 |
+
<missing-glyph horiz-adv-x="1024" />
|
9 |
+
<glyph unicode=" " d="" horiz-adv-x="512" />
|
10 |
+
<glyph unicode="" d="M191.968 495.776h158.912c23.68 0 42.656-19.2 42.656-42.656 0-11.488-4.48-21.984-11.968-29.632l0.192-0.448-108.768-108.736c-75.104-75.136-75.104-196.512 0-271.584 74.88-74.848 196.448-74.848 271.552 0 74.88 75.104 74.88 196.48 0 271.584-21.76 21.504-47.36 37.12-74.464 46.272l28.608 28.576h365.248c87.040 0 157.856 74.016 159.968 166.4 0 1.472 0.224 2.752 0 4.256-2.112 23.904-22.368 42.656-46.912 42.656h-264.96l191.328 191.328c17.504 17.504 18.56 45.024 3.2 63.36-1.024 1.28-2.080 2.144-3.2 3.2-66.528 63.552-169.152 65.92-230.56 4.48l-262.368-262.368h-46.528c12.8 25.6 20.032 54.624 20.032 85.344 0 106.016-85.952 192-192 192-106.016 0-191.968-85.984-191.968-192 0.032-106.080 85.984-192.032 192-192.032zM277.312 687.744c0-47.136-38.176-85.344-85.344-85.344-47.136 0-85.312 38.176-85.312 85.344s38.176 85.344 85.312 85.344c47.168 0 85.344-38.208 85.344-85.344zM469.088 238.688c33.28-33.248 33.28-87.264 0-120.512-33.28-33.472-87.264-33.472-120.736 0-33.28 33.248-33.28 87.264 0 120.512 33.472 33.504 87.456 33.504 120.736 0z" />
|
11 |
+
</font></defs></svg>
|
Binary file
|
Binary file
|
@@ -0,0 +1,84 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
/**
|
2 |
+
* Custom styling for the snippets table
|
3 |
+
*/
|
4 |
+
|
5 |
+
.snippets {
|
6 |
+
|
7 |
+
th, td {
|
8 |
+
color: #000;
|
9 |
+
}
|
10 |
+
|
11 |
+
tr {
|
12 |
+
background: #fff;
|
13 |
+
}
|
14 |
+
|
15 |
+
.row-actions {
|
16 |
+
color: #ddd;
|
17 |
+
}
|
18 |
+
|
19 |
+
.clear-filters {
|
20 |
+
vertical-align: middle;
|
21 |
+
}
|
22 |
+
|
23 |
+
tfoot th {
|
24 |
+
border-top: none !important;
|
25 |
+
|
26 |
+
&.check-column {
|
27 |
+
padding: 13px 0 0 3px;
|
28 |
+
}
|
29 |
+
}
|
30 |
+
|
31 |
+
thead th.check-column,
|
32 |
+
tfoot th.check-column,
|
33 |
+
.inactive th.check-column {
|
34 |
+
padding-left: 5px;
|
35 |
+
}
|
36 |
+
|
37 |
+
.column-description p {
|
38 |
+
color: #333;
|
39 |
+
}
|
40 |
+
|
41 |
+
.inactive {
|
42 |
+
|
43 |
+
a {
|
44 |
+
color: #579;
|
45 |
+
}
|
46 |
+
}
|
47 |
+
|
48 |
+
.inactive, .active {
|
49 |
+
td, th {
|
50 |
+
padding: 10px 9px;
|
51 |
+
border: none;
|
52 |
+
box-shadow: inset 0 -1px 0 rgba(0,0,0,0.1);
|
53 |
+
}
|
54 |
+
}
|
55 |
+
|
56 |
+
.active {
|
57 |
+
|
58 |
+
td, th {
|
59 |
+
background-color: rgba(120,200,230,0.06);
|
60 |
+
}
|
61 |
+
|
62 |
+
th.check-column {
|
63 |
+
border-left: 2px solid #2ea2cc;
|
64 |
+
}
|
65 |
+
|
66 |
+
}
|
67 |
+
|
68 |
+
tr.active + tr.inactive th,
|
69 |
+
tr.active + tr.inactive td {
|
70 |
+
border-top: 1px solid rgba(0,0,0,0.03);
|
71 |
+
box-shadow: inset 0px 1px 0 rgba(0,0,0,0.02), inset 0 -1px 0 #e1e1e1;
|
72 |
+
}
|
73 |
+
|
74 |
+
&, #all-snippets-table, #search-snippets-table {
|
75 |
+
a.delete:hover {
|
76 |
+
border-bottom: 1px solid #f00;
|
77 |
+
color: #f00;
|
78 |
+
}
|
79 |
+
}
|
80 |
+
|
81 |
+
#wpbody-content & .column-name {
|
82 |
+
white-space: nowrap; /* prevents wrapping of snippet title */
|
83 |
+
}
|
84 |
+
}
|
@@ -0,0 +1,19 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
/**
|
2 |
+
* Add the snippets icon to the admin menu
|
3 |
+
*/
|
4 |
+
|
5 |
+
@font-face {
|
6 |
+
font-family: 'code-snippets';
|
7 |
+
src: url('../font/code-snippets.eot');
|
8 |
+
src: url('../font/code-snippets.eot?#iefix') format('embedded-opentype'),
|
9 |
+
url('../font/code-snippets.ttf') format('truetype'),
|
10 |
+
url('../font/code-snippets.woff') format('woff'),
|
11 |
+
url('../font/code-snippets.svg#code-snippets') format('svg');
|
12 |
+
font-weight: normal;
|
13 |
+
font-style: normal;
|
14 |
+
}
|
15 |
+
|
16 |
+
#toplevel_page_snippets div.wp-menu-image:before {
|
17 |
+
font-family: 'code-snippets' !important;
|
18 |
+
content: '\e600';
|
19 |
+
}
|
@@ -0,0 +1 @@
|
|
|
1 |
+
h3{margin:1em 0}label{cursor:auto}label[for='snippet_description'] h3 div{position:absolute}.submit .button{margin-right:.5em}.CodeMirror{width:100%;height:auto;min-height:300px;border:1px solid #dfdfdf;border-radius:3px;background-color:#fff}.CodeMirror-scroll{overflow-x:auto;overflow-y:hidden}.CodeMirror-sizer{min-height:300px!important}.CodeMirror-focused .cm-matchhighlight{color:#fff!important;outline:1px solid green}
|
@@ -0,0 +1 @@
|
|
|
1 |
+
.snippets th,.snippets td{color:#000}.snippets tr{background:#fff}.snippets .row-actions{color:#ddd}.snippets .clear-filters{vertical-align:middle}.snippets tfoot th{border-top:none!important}.snippets tfoot th.check-column{padding:13px 0 0 3px}.snippets thead th.check-column,.snippets tfoot th.check-column,.snippets .inactive th.check-column{padding-left:5px}.snippets .column-description p{color:#333}.snippets .inactive a{color:#579}.snippets .inactive td,.snippets .inactive th,.snippets .active td,.snippets .active th{padding:10px 9px;border:none;-webkit-box-shadow:inset 0 -1px 0 rgba(0,0,0,.1);box-shadow:inset 0 -1px 0 rgba(0,0,0,.1)}.snippets .active td,.snippets .active th{background-color:rgba(120,200,230,.06)}.snippets .active th.check-column{border-left:2px solid #2ea2cc}.snippets tr.active+tr.inactive th,.snippets tr.active+tr.inactive td{border-top:1px solid rgba(0,0,0,.03);-webkit-box-shadow:inset 0 1px 0 rgba(0,0,0,.02),inset 0 -1px 0 #e1e1e1;box-shadow:inset 0 1px 0 rgba(0,0,0,.02),inset 0 -1px 0 #e1e1e1}.snippets a.delete:hover,.snippets #all-snippets-table a.delete:hover,.snippets #search-snippets-table a.delete:hover{border-bottom:1px solid red;color:red}#wpbody-content .snippets .column-name{white-space:nowrap}
|
@@ -0,0 +1 @@
|
|
|
1 |
+
@font-face{font-family:'code-snippets';src:url('../font/code-snippets.eot');src:url('../font/code-snippets.eot?#iefix') format('embedded-opentype'),url('../font/code-snippets.ttf') format('truetype'),url('../font/code-snippets.woff') format('woff'),url('../font/code-snippets.svg#code-snippets') format('svg');font-weight:400;font-style:normal}#toplevel_page_snippets div.wp-menu-image:before{font-family:'code-snippets'!important;content:'\e600'}
|
@@ -0,0 +1,224 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* Load the functions for handling the administration interface
|
5 |
+
*
|
6 |
+
* @package Code_Snippets
|
7 |
+
* @subpackage Administration
|
8 |
+
*/
|
9 |
+
|
10 |
+
/* Bail if not in admin area */
|
11 |
+
if ( ! is_admin() ) {
|
12 |
+
return;
|
13 |
+
}
|
14 |
+
|
15 |
+
/**
|
16 |
+
* Fetch the admin menu slug for a snippets menu
|
17 |
+
* @param string $menu The menu to retrieve the slug for
|
18 |
+
* @return string The menu's slug
|
19 |
+
*/
|
20 |
+
function code_snippets_get_menu_slug( $menu = '' ) {
|
21 |
+
$add = array( 'single', 'add', 'add-new', 'add-snippet', 'new-snippet', 'add-new-snippet' );
|
22 |
+
$edit = array( 'edit', 'edit-snippet' );
|
23 |
+
$import = array( 'import', 'import-snippets' );
|
24 |
+
$settings = array( 'settings', 'snippets-settings' );
|
25 |
+
|
26 |
+
if ( in_array( $menu, $edit ) ) {
|
27 |
+
return 'edit-snippet';
|
28 |
+
} elseif ( in_array( $menu, $add ) ) {
|
29 |
+
return 'add-snippet';
|
30 |
+
} elseif ( in_array( $menu, $import ) ) {
|
31 |
+
return 'import-snippets';
|
32 |
+
} elseif ( in_array( $menu, $settings ) ) {
|
33 |
+
return 'snippets-settings';
|
34 |
+
} else {
|
35 |
+
return 'snippets';
|
36 |
+
}
|
37 |
+
}
|
38 |
+
|
39 |
+
/**
|
40 |
+
* Fetch the URL to a snippets admin menu
|
41 |
+
* @param string $menu The menu to retrieve the URL to
|
42 |
+
* @return string The menu's URL
|
43 |
+
*/
|
44 |
+
function code_snippets_get_menu_url( $menu = '', $context = 'self' ) {
|
45 |
+
$slug = code_snippets_get_menu_slug( $menu );
|
46 |
+
$url = 'admin.php?page=' . $slug;
|
47 |
+
|
48 |
+
if ( 'network' === $context ) {
|
49 |
+
return network_admin_url( $url );
|
50 |
+
} elseif ( 'admin' === $context ) {
|
51 |
+
return admin_url( $url );
|
52 |
+
} else {
|
53 |
+
return self_admin_url( $url );
|
54 |
+
}
|
55 |
+
}
|
56 |
+
|
57 |
+
/**
|
58 |
+
* Fetch the admin menu hook for a snippets menu
|
59 |
+
* @param string $menu The menu to retrieve the hook for
|
60 |
+
* @return string The menu's hook
|
61 |
+
*/
|
62 |
+
function code_snippets_get_menu_hook( $menu = '' ) {
|
63 |
+
$slug = code_snippets_get_menu_slug( $menu );
|
64 |
+
return get_plugin_page_hookname( $slug, 'snippets' );
|
65 |
+
}
|
66 |
+
|
67 |
+
/**
|
68 |
+
* Allow super admins to control site admin access to
|
69 |
+
* snippet admin menus
|
70 |
+
*
|
71 |
+
* Adds a checkbox to the *Settings > Network Settings*
|
72 |
+
* network admin menu
|
73 |
+
*
|
74 |
+
* @since 1.7.1
|
75 |
+
* @access private
|
76 |
+
*
|
77 |
+
* @param array $menu_items The current mu menu items
|
78 |
+
* @return array The modified mu menu items
|
79 |
+
*/
|
80 |
+
function code_snippets_mu_menu_items( $menu_items ) {
|
81 |
+
$menu_items['snippets'] = __( 'Snippets', 'code-snippets' );
|
82 |
+
return $menu_items;
|
83 |
+
}
|
84 |
+
|
85 |
+
add_filter( 'mu_menu_items', 'code_snippets_mu_menu_items' );
|
86 |
+
|
87 |
+
/**
|
88 |
+
* Enqueue the icon stylesheet globally in the admin
|
89 |
+
*
|
90 |
+
* @since 1.0
|
91 |
+
* @access private
|
92 |
+
* @uses wp_enqueue_style() To add the stylesheet to the queue
|
93 |
+
* @uses get_user_option() To check if MP6 mode is active
|
94 |
+
* @uses plugins_url() To retrieve a URL to assets
|
95 |
+
*/
|
96 |
+
function code_snippets_load_admin_icon_style() {
|
97 |
+
|
98 |
+
wp_enqueue_style(
|
99 |
+
'menu-icon-snippets',
|
100 |
+
plugins_url( 'css/min/menu-icon.css', CODE_SNIPPETS_FILE ),
|
101 |
+
false,
|
102 |
+
CODE_SNIPPETS_VERSION
|
103 |
+
);
|
104 |
+
}
|
105 |
+
|
106 |
+
add_action( 'admin_enqueue_scripts', 'code_snippets_load_admin_icon_style' );
|
107 |
+
|
108 |
+
/**
|
109 |
+
* Adds a link pointing to the Manage Snippets page
|
110 |
+
*
|
111 |
+
* @since 2.0
|
112 |
+
* @access private
|
113 |
+
* @param array $links The existing plugin action links
|
114 |
+
* @return array The modified plugin action links
|
115 |
+
*/
|
116 |
+
function code_snippets_plugin_settings_link( $links ) {
|
117 |
+
array_unshift( $links, sprintf(
|
118 |
+
'<a href="%1$s" title="%2$s">%3$s</a>',
|
119 |
+
code_snippets_get_menu_url(),
|
120 |
+
__( 'Manage your existing snippets', 'code-snippets' ),
|
121 |
+
__( 'Manage', 'code-snippets' )
|
122 |
+
) );
|
123 |
+
return $links;
|
124 |
+
}
|
125 |
+
|
126 |
+
add_filter( 'plugin_action_links_' . plugin_basename( CODE_SNIPPETS_FILE ), 'code_snippets_plugin_settings_link' );
|
127 |
+
|
128 |
+
/**
|
129 |
+
* Adds extra links related to the plugin
|
130 |
+
*
|
131 |
+
* @since 2.0
|
132 |
+
* @access private
|
133 |
+
* @param array $links The existing plugin info links
|
134 |
+
* @param string $file The plugin the links are for
|
135 |
+
* @return array The modified plugin info links
|
136 |
+
*/
|
137 |
+
function code_snippets_plugin_meta( $links, $file ) {
|
138 |
+
|
139 |
+
/* We only want to affect the Code Snippets plugin listing */
|
140 |
+
if ( $file !== plugin_basename( CODE_SNIPPETS_FILE ) ) {
|
141 |
+
return $links;
|
142 |
+
}
|
143 |
+
|
144 |
+
$format = '<a href="%1$s" title="%2$s">%3$s</a>';
|
145 |
+
|
146 |
+
/* array_merge appends the links to the end */
|
147 |
+
return array_merge( $links, array(
|
148 |
+
sprintf( $format,
|
149 |
+
'http://wordpress.org/plugins/code-snippets/',
|
150 |
+
__( 'Visit the WordPress.org plugin page', 'code-snippets' ),
|
151 |
+
__( 'About', 'code-snippets' )
|
152 |
+
),
|
153 |
+
sprintf( $format,
|
154 |
+
'http://wordpress.org/support/plugin/code-snippets/',
|
155 |
+
__( 'Visit the support forums', 'code-snippets' ),
|
156 |
+
__( 'Support', 'code-snippets' )
|
157 |
+
),
|
158 |
+
sprintf( $format,
|
159 |
+
'http://code-snippets.bungeshea.com/donate/',
|
160 |
+
__("Support this plugin's development", 'code-snippets' ),
|
161 |
+
__( 'Donate', 'code-snippets' )
|
162 |
+
)
|
163 |
+
) );
|
164 |
+
}
|
165 |
+
|
166 |
+
add_filter( 'plugin_row_meta', 'code_snippets_plugin_meta', 10, 2 );
|
167 |
+
|
168 |
+
/**
|
169 |
+
* Print a notice inviting people to participate in the Code Snippets Survey
|
170 |
+
*
|
171 |
+
* @since 1.9
|
172 |
+
* @return void
|
173 |
+
*/
|
174 |
+
function code_snippets_survey_message() {
|
175 |
+
global $current_user;
|
176 |
+
|
177 |
+
$key = 'ignore_code_snippets_survey_message';
|
178 |
+
|
179 |
+
/* Bail now if the user has dismissed the message */
|
180 |
+
if ( get_user_meta( $current_user->ID, $key ) ) {
|
181 |
+
return;
|
182 |
+
}
|
183 |
+
elseif ( isset( $_GET[ $key ], $_REQUEST['_wpnonce'] ) && wp_verify_nonce( $_REQUEST['_wpnonce'], $key ) ) {
|
184 |
+
add_user_meta( $current_user->ID, $key, true, true );
|
185 |
+
return;
|
186 |
+
}
|
187 |
+
|
188 |
+
?>
|
189 |
+
|
190 |
+
<br />
|
191 |
+
|
192 |
+
<div class="updated"><p>
|
193 |
+
|
194 |
+
<?php _e( "<strong>Have feedback on Code Snippets?</strong> Please take the time to answer a short survey on how you use this plugin and what you'd like to see changed or added in the future.", 'code-snippets' ); ?>
|
195 |
+
|
196 |
+
<a href="http://code-snippets.bungeshea.com/survey/" class="button secondary" target="_blank" style="margin: auto .5em;">
|
197 |
+
<?php _e( 'Take the survey now', 'code-snippets' ); ?>
|
198 |
+
</a>
|
199 |
+
|
200 |
+
<a href="<?php echo wp_nonce_url( add_query_arg( $key, true ), $key ); ?>">Dismiss</a>
|
201 |
+
|
202 |
+
</p></div>
|
203 |
+
|
204 |
+
<?php
|
205 |
+
}
|
206 |
+
|
207 |
+
add_action( 'code_snippets/admin/manage', 'code_snippets_survey_message' );
|
208 |
+
|
209 |
+
/**
|
210 |
+
* Remove the old CodeMirror version used by the Debug Bar Console
|
211 |
+
* plugin that is messing up the snippet editor
|
212 |
+
* @since 1.9
|
213 |
+
*/
|
214 |
+
function code_snippets_remove_debug_bar_codemirror() {
|
215 |
+
global $pagenow;
|
216 |
+
|
217 |
+
/* Try to discern if we are on the single snippet page as best as we can at this early time */
|
218 |
+
is_admin() && 'admin.php' === $pagenow && isset( $_GET['page' ] ) && 'snippet' === $_GET['page']
|
219 |
+
|
220 |
+
/* Remove the action and stop all Debug Bar Console scripts */
|
221 |
+
&& remove_action( 'debug_bar_enqueue_scripts', 'debug_bar_console_scripts' );
|
222 |
+
}
|
223 |
+
|
224 |
+
add_action( 'init', 'code_snippets_remove_debug_bar_codemirror' );
|
@@ -0,0 +1,60 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* Get the required capability to perform a certain action on snippets.
|
5 |
+
* Does not check if the user has this capability or not.
|
6 |
+
*
|
7 |
+
* If multisite, checks if *Enable Administration Menus: Snippets* is active
|
8 |
+
* under the *Settings > Network Settings* network admin menu
|
9 |
+
*
|
10 |
+
* @since 2.0
|
11 |
+
* @return string The capability required to manage snippets
|
12 |
+
*/
|
13 |
+
function get_snippets_cap() {
|
14 |
+
|
15 |
+
if ( is_multisite() ) {
|
16 |
+
$menu_perms = get_site_option( 'menu_items', array() );
|
17 |
+
|
18 |
+
/* If multisite is enabled and the snippet menu is not activated,
|
19 |
+
restrict snippet operations to super admins only */
|
20 |
+
if ( empty( $menu_perms['snippets'] ) ) {
|
21 |
+
return apply_filters( 'code_snippets_network_cap', 'manage_network_snippets' );
|
22 |
+
}
|
23 |
+
}
|
24 |
+
|
25 |
+
return apply_filters( 'code_snippets_cap', 'manage_snippets' );
|
26 |
+
}
|
27 |
+
|
28 |
+
/**
|
29 |
+
* Add the multisite capabilities to a user
|
30 |
+
*
|
31 |
+
* @since 2.0
|
32 |
+
* @param integer $user_id The ID of the user to add the cap to
|
33 |
+
*/
|
34 |
+
function grant_network_snippets_cap( $user_id ) {
|
35 |
+
|
36 |
+
/* Get the user from the ID */
|
37 |
+
$user = new WP_User( $user_id );
|
38 |
+
|
39 |
+
/* Add the capability */
|
40 |
+
$user->add_cap( apply_filters( 'code_snippets_network_cap', 'manage_network_snippets' ) );
|
41 |
+
}
|
42 |
+
|
43 |
+
add_action( 'grant_super_admin', 'grant_network_snippets_cap' );
|
44 |
+
|
45 |
+
/**
|
46 |
+
* Remove the multisite capabilities from a user
|
47 |
+
*
|
48 |
+
* @since 2.0
|
49 |
+
* @param integer $user_id The ID of the user to remove the cap from
|
50 |
+
*/
|
51 |
+
function remove_network_snippets_cap( $user_id ) {
|
52 |
+
|
53 |
+
/* Get the user from the ID */
|
54 |
+
$user = new WP_User( $user_id );
|
55 |
+
|
56 |
+
/* Remove the capability */
|
57 |
+
$user->remove_cap( apply_filters( 'code_snippets_network_cap', 'manage_network_snippets' ) );
|
58 |
+
}
|
59 |
+
|
60 |
+
add_action( 'remove_super_admin', 'remove_network_snippets_cap' );
|
@@ -1,190 +1,254 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/**
|
4 |
-
* This file handles exporting snippets in XML format
|
5 |
-
*
|
6 |
-
* It's better to call the
|
7 |
-
*
|
8 |
-
*
|
9 |
-
* @since 1.9
|
10 |
-
* @package Code_Snippets
|
11 |
-
* @subpackage Export
|
12 |
-
*/
|
13 |
-
|
14 |
-
if ( ! class_exists( 'Code_Snippets_Export' ) ) :
|
15 |
-
|
16 |
-
/**
|
17 |
-
* Exports selected snippets to a XML or PHP file.
|
18 |
-
*
|
19 |
-
* @since 1.3
|
20 |
-
* @param array $ids The IDs of the snippets to export
|
21 |
-
* @param string $format The format of the export file
|
22 |
-
* @return void
|
23 |
-
*/
|
24 |
-
class Code_Snippets_Export {
|
25 |
-
|
26 |
-
/**
|
27 |
-
* The IDs
|
28 |
-
* @var array
|
29 |
-
*/
|
30 |
-
public $snippet_ids = array();
|
31 |
-
|
32 |
-
/**
|
33 |
-
* The name of the table to fetch snippets from
|
34 |
-
* @var string
|
35 |
-
*/
|
36 |
-
protected $table_name = '';
|
37 |
-
|
38 |
-
/**
|
39 |
-
*
|
40 |
-
*
|
41 |
-
* @
|
42 |
-
*/
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
$
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
|
136 |
-
|
137 |
-
|
138 |
-
|
139 |
-
|
140 |
-
|
141 |
-
|
142 |
-
|
143 |
-
|
144 |
-
|
145 |
-
|
146 |
-
|
147 |
-
|
148 |
-
|
149 |
-
|
150 |
-
|
151 |
-
|
152 |
-
|
153 |
-
|
154 |
-
|
155 |
-
|
156 |
-
|
157 |
-
|
158 |
-
|
159 |
-
|
160 |
-
|
161 |
-
|
162 |
-
|
163 |
-
|
164 |
-
|
165 |
-
|
166 |
-
|
167 |
-
|
168 |
-
|
169 |
-
|
170 |
-
|
171 |
-
|
172 |
-
|
173 |
-
|
174 |
-
|
175 |
-
|
176 |
-
|
177 |
-
|
178 |
-
|
179 |
-
|
180 |
-
|
181 |
-
|
182 |
-
|
183 |
-
|
184 |
-
|
185 |
-
|
186 |
-
|
187 |
-
|
188 |
-
|
189 |
-
|
190 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* This file handles exporting snippets in XML format
|
5 |
+
*
|
6 |
+
* It's better to call the export_snippets()
|
7 |
+
* function than directly using this class
|
8 |
+
*
|
9 |
+
* @since 1.9
|
10 |
+
* @package Code_Snippets
|
11 |
+
* @subpackage Export
|
12 |
+
*/
|
13 |
+
|
14 |
+
if ( ! class_exists( 'Code_Snippets_Export' ) ) :
|
15 |
+
|
16 |
+
/**
|
17 |
+
* Exports selected snippets to a XML or PHP file.
|
18 |
+
*
|
19 |
+
* @since 1.3
|
20 |
+
* @param array $ids The IDs of the snippets to export
|
21 |
+
* @param string $format The format of the export file
|
22 |
+
* @return void
|
23 |
+
*/
|
24 |
+
class Code_Snippets_Export {
|
25 |
+
|
26 |
+
/**
|
27 |
+
* The IDs
|
28 |
+
* @var array
|
29 |
+
*/
|
30 |
+
public $snippet_ids = array();
|
31 |
+
|
32 |
+
/**
|
33 |
+
* The name of the table to fetch snippets from
|
34 |
+
* @var string
|
35 |
+
*/
|
36 |
+
protected $table_name = '';
|
37 |
+
|
38 |
+
/**
|
39 |
+
* The export file format.
|
40 |
+
* Either 'xml' or 'php'
|
41 |
+
* @var object
|
42 |
+
*/
|
43 |
+
public $format;
|
44 |
+
|
45 |
+
/**
|
46 |
+
* The DOM document.
|
47 |
+
* Only used in XML exports
|
48 |
+
* @var object
|
49 |
+
*/
|
50 |
+
public $dom;
|
51 |
+
|
52 |
+
/**
|
53 |
+
* The DOM document root element
|
54 |
+
* Only used in XML exports
|
55 |
+
* @var object
|
56 |
+
*/
|
57 |
+
public $root;
|
58 |
+
|
59 |
+
/**
|
60 |
+
* Constructor function
|
61 |
+
* @param array $ids The IDs of the snippets to export
|
62 |
+
* @param string $table The name of the table to fetch snippets from
|
63 |
+
* @param string $format The format of the export file
|
64 |
+
*/
|
65 |
+
function __construct( $ids, $table, $format = 'xml' ) {
|
66 |
+
$this->snippet_ids = (array) $ids;
|
67 |
+
$this->table_name = $table;
|
68 |
+
$this->format = 'php' === $format ? 'php' : 'xml';
|
69 |
+
$this->exclude_fields = apply_filters( 'code_snippets/export/exclude_from_export', array( 'id', 'active' ) );
|
70 |
+
}
|
71 |
+
|
72 |
+
/**
|
73 |
+
* Build the export file name
|
74 |
+
* @return string
|
75 |
+
*/
|
76 |
+
function get_filename() {
|
77 |
+
|
78 |
+
if ( 1 == count( $this->snippet_ids ) ) {
|
79 |
+
/* If there is only snippet to export, use its name instead of the site name */
|
80 |
+
$snippet = get_snippet( $this->snippet_ids[0], $this->table_name );
|
81 |
+
$sitename = strtolower( $snippet->name );
|
82 |
+
} else {
|
83 |
+
/* Otherwise, use the site name as set in Settings > General */
|
84 |
+
$sitename = strtolower( get_bloginfo( 'name' ) );
|
85 |
+
}
|
86 |
+
|
87 |
+
/* Filter and sanitize the filename */
|
88 |
+
$filename = sanitize_file_name( apply_filters(
|
89 |
+
'code_snippets/export/filename',
|
90 |
+
"{$sitename}.code-snippets.{$this->format}",
|
91 |
+
$sitename
|
92 |
+
) );
|
93 |
+
|
94 |
+
return $filename;
|
95 |
+
}
|
96 |
+
|
97 |
+
/**
|
98 |
+
* Append header comments to the DOM document
|
99 |
+
*/
|
100 |
+
protected function do_header_comments() {
|
101 |
+
|
102 |
+
/* Array of translated comment lines */
|
103 |
+
$lines = array(
|
104 |
+
__( 'This is a code snippets export file generated by the Code Snippets WordPress plugin.', 'code-snippets' ),
|
105 |
+
__( 'http://wordpress.org/plugins/code-snippets', 'code-snippets' ),
|
106 |
+
__( 'To import these snippets a WordPress site follow these steps:', 'code-snippets' ),
|
107 |
+
__( '1. Log in to that site as an administrator.', 'code-snippets' ),
|
108 |
+
__( '2. Install the Code Snippets plugin using the directions provided at the above link.', 'code-snippets' ),
|
109 |
+
__( "3. Go to 'Tools: Import' in the WordPress admin panel.", 'code-snippets' ),
|
110 |
+
__( '4. Click on the "Code Snippets" importer in the list', 'code-snippets' ),
|
111 |
+
__( '5. Upload this file using the form provided on that page.', 'code-snippets' ),
|
112 |
+
__( '6. Code Snippets will then import all of the snippets and associated information contained in this file into your site.', 'code-snippets' ),
|
113 |
+
__( "7. You will then have to visit the 'Snippets: Manage' admin menu and activate desired snippets.", 'code-snippets' ),
|
114 |
+
);
|
115 |
+
|
116 |
+
/* Add each line as a comment element */
|
117 |
+
foreach ( $lines as $line ) {
|
118 |
+
$comment = $this->dom->createComment( " $line " );
|
119 |
+
$this->dom->appendChild( $comment );
|
120 |
+
}
|
121 |
+
|
122 |
+
/* Build a generator line, like the WordPress export files */
|
123 |
+
$gen = sprintf (
|
124 |
+
'generator="Code Snippets/%s" created="%s"',
|
125 |
+
CODE_SNIPPETS_VERSION,
|
126 |
+
date('Y-m-d H:i')
|
127 |
+
);
|
128 |
+
|
129 |
+
/* Run the generator line through the standard WordPress filter */
|
130 |
+
$type = 'code_snippets_export';
|
131 |
+
$gen = apply_filters( "get_the_generator_$type", $gen, $type );
|
132 |
+
|
133 |
+
/* Add it to the file as a comment */
|
134 |
+
$gen = $this->dom->createComment( " $gen " );
|
135 |
+
$this->dom->appendChild( $gen );
|
136 |
+
}
|
137 |
+
|
138 |
+
|
139 |
+
|
140 |
+
/**
|
141 |
+
* Process all snippet items
|
142 |
+
*/
|
143 |
+
protected function do_items() {
|
144 |
+
global $wpdb;
|
145 |
+
|
146 |
+
if ( 'xml' === $this->format ) {
|
147 |
+
|
148 |
+
/* Create the root element */
|
149 |
+
$this->root = $this->dom->createElement( 'snippets' );
|
150 |
+
$this->root = $this->dom->appendChild( $this->root );
|
151 |
+
}
|
152 |
+
|
153 |
+
/* Loop through the snippets */
|
154 |
+
foreach ( $this->snippet_ids as $id ) {
|
155 |
+
|
156 |
+
/* Grab the snippet from the database */
|
157 |
+
$snippet = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM {$this->table_name} WHERE id = %d", $id ), ARRAY_A );
|
158 |
+
|
159 |
+
/* Process the snippet item */
|
160 |
+
if ( 'php' === $this->format ) {
|
161 |
+
$this->do_item_php( $snippet );
|
162 |
+
} else {
|
163 |
+
$this->do_item( $snippet );
|
164 |
+
}
|
165 |
+
}
|
166 |
+
}
|
167 |
+
|
168 |
+
/**
|
169 |
+
* Append a single snippet item to the document
|
170 |
+
* @param array $snippet
|
171 |
+
*/
|
172 |
+
protected function do_item( $snippet ) {
|
173 |
+
$item = $this->dom->createElement( 'snippet' );
|
174 |
+
$item = $this->root->appendChild( $item );
|
175 |
+
|
176 |
+
foreach ( $snippet as $field_name => $field_value ) {
|
177 |
+
|
178 |
+
/* Don't export certain fields */
|
179 |
+
if ( in_array( $field_name, $this->exclude_fields ) ) {
|
180 |
+
continue;
|
181 |
+
}
|
182 |
+
|
183 |
+
/* Create a new element for each field */
|
184 |
+
$field = $this->dom->createElement( $field_name );
|
185 |
+
$field = $item->appendChild( $field );
|
186 |
+
|
187 |
+
/* Add the field's content */
|
188 |
+
$value = $this->dom->createTextNode( $field_value );
|
189 |
+
$value = $field->appendChild( $value );
|
190 |
+
}
|
191 |
+
}
|
192 |
+
|
193 |
+
/**
|
194 |
+
* Format single snippet item as PHP code
|
195 |
+
* @param array $snippet
|
196 |
+
*/
|
197 |
+
protected function do_item_php( $snippet ) {
|
198 |
+
|
199 |
+
echo "\n/**\n * {$snippet['name']}\n";
|
200 |
+
|
201 |
+
if ( ! empty( $snippet['description'] ) ) {
|
202 |
+
|
203 |
+
/* Convert description to PhpDoc */
|
204 |
+
$desc = strip_tags( str_replace( "\n", "\n * ", $snippet['description'] ) );
|
205 |
+
|
206 |
+
echo " *\n * $desc\n";
|
207 |
+
}
|
208 |
+
|
209 |
+
echo " */\n{$snippet['code']}\n";
|
210 |
+
}
|
211 |
+
|
212 |
+
/**
|
213 |
+
* Export the snippets
|
214 |
+
*/
|
215 |
+
public function do_export() {
|
216 |
+
|
217 |
+
/* Make the page act like a downloadable file instead of being shown in the browser */
|
218 |
+
$filename = $this->get_filename();
|
219 |
+
header( 'Content-Disposition: attachment; filename=' . $filename );
|
220 |
+
|
221 |
+
if ( 'xml' === $this->format ) {
|
222 |
+
|
223 |
+
/* Set the HTTP content type header */
|
224 |
+
header( 'Content-Type: text/xml; charset=' . get_bloginfo( 'charset' ) );
|
225 |
+
|
226 |
+
/* Create DOM document and root element */
|
227 |
+
$this->dom = new DOMDocument( '1.0', get_bloginfo( 'charset' ) );
|
228 |
+
$this->dom->formatOutput = true;
|
229 |
+
|
230 |
+
/* Add file header comments */
|
231 |
+
$this->do_header_comments();
|
232 |
+
}
|
233 |
+
|
234 |
+
elseif ( 'php' === $this->format ) {
|
235 |
+
echo '<?php';
|
236 |
+
}
|
237 |
+
|
238 |
+
/* Process the snippet items */
|
239 |
+
$this->do_items();
|
240 |
+
|
241 |
+
if ( 'xml' === $this->format ) {
|
242 |
+
|
243 |
+
/* Filter DOM document */
|
244 |
+
apply_filters( 'code_snippets/export_dom_document', $this->dom, $this->snippet_ids, $filename );
|
245 |
+
|
246 |
+
/* Send the document to the browser */
|
247 |
+
echo $this->dom->saveXML();
|
248 |
+
}
|
249 |
+
|
250 |
+
exit;
|
251 |
+
}
|
252 |
+
}
|
253 |
+
|
254 |
+
endif; // class exists check
|
@@ -0,0 +1,146 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* Functions used to manage the database tables
|
5 |
+
*/
|
6 |
+
|
7 |
+
/**
|
8 |
+
* Register the snippet table names with WordPress
|
9 |
+
*
|
10 |
+
* @since 2.0
|
11 |
+
* @uses $wpdb
|
12 |
+
*/
|
13 |
+
function set_snippet_table_vars() {
|
14 |
+
global $wpdb;
|
15 |
+
|
16 |
+
/* Register the snippet table names with WordPress */
|
17 |
+
$wpdb->tables[] = 'snippets';
|
18 |
+
$wpdb->ms_global_tables[] = 'ms_snippets';
|
19 |
+
|
20 |
+
/* Setup initial table variables */
|
21 |
+
$wpdb->snippets = $wpdb->prefix . 'snippets';
|
22 |
+
$wpdb->ms_snippets = $wpdb->base_prefix . 'ms_snippets';
|
23 |
+
}
|
24 |
+
|
25 |
+
/**
|
26 |
+
* Return the appropriate snippet table name
|
27 |
+
*
|
28 |
+
* @since 2.0
|
29 |
+
* @param string|boolean|null $multisite Retrieve the multisite table name or the site table name?
|
30 |
+
* @return string The snippet table name
|
31 |
+
*/
|
32 |
+
function get_snippets_table_name( $multisite = null ) {
|
33 |
+
global $wpdb;
|
34 |
+
|
35 |
+
/* If $multisite is null, try to base it on the current admin page */
|
36 |
+
if ( ! isset( $multisite ) && function_exists( 'get_current_screen' ) ) {
|
37 |
+
$multisite = get_current_screen()->is_network;
|
38 |
+
}
|
39 |
+
|
40 |
+
/* If the first parameter is a string, assume it is a table name */
|
41 |
+
elseif ( is_string( $multisite ) ) {
|
42 |
+
return $multisite;
|
43 |
+
}
|
44 |
+
|
45 |
+
/* If multisite is not active, always return the site-wide table name */
|
46 |
+
if ( ! is_multisite() ) {
|
47 |
+
$multisire = false;
|
48 |
+
}
|
49 |
+
|
50 |
+
/* Retrieve the table name from $wpdb depending on the above conditionals */
|
51 |
+
return ( $multisite ? $wpdb->ms_snippets : $wpdb->snippets );
|
52 |
+
}
|
53 |
+
|
54 |
+
/**
|
55 |
+
* Create the snippet tables if they do not already exist
|
56 |
+
*
|
57 |
+
* @since 1.7.1
|
58 |
+
* @staticvar boolean $tables_created Used to check if we've already done this or not
|
59 |
+
* @param boolean $redo Skip the already-done-this check
|
60 |
+
* @param boolean $always_create_table Always create the site-wide table if it doesn't exist
|
61 |
+
*/
|
62 |
+
function create_code_snippets_tables( $redo = false, $always_create_table = false ) {
|
63 |
+
|
64 |
+
/* Bail early if we've done this already */
|
65 |
+
if ( ! $redo && true === wp_cache_get( 'snippet_tables_created', 'code_snippets' ) ) {
|
66 |
+
return;
|
67 |
+
}
|
68 |
+
|
69 |
+
global $wpdb;
|
70 |
+
|
71 |
+
/* Set the table name variables if not yet defined */
|
72 |
+
if ( ! isset( $wpdb->snippets, $wpdb->ms_snippets ) ) {
|
73 |
+
set_snippets_table_vars();
|
74 |
+
}
|
75 |
+
|
76 |
+
/* Always create the network-wide snippet table */
|
77 |
+
if ( is_multisite() ) {
|
78 |
+
create_code_snippets_table( $wpdb->ms_snippets );
|
79 |
+
}
|
80 |
+
|
81 |
+
/* Create the site-specific table if we're on the main site */
|
82 |
+
if ( $always_create_table || is_main_site() ) {
|
83 |
+
create_code_snippets_table( $wpdb->snippets );
|
84 |
+
}
|
85 |
+
|
86 |
+
/* Set the flag so we don't have to do this again */
|
87 |
+
wp_cache_set( 'snippet_tables_created', true, 'code_snippets' );
|
88 |
+
}
|
89 |
+
|
90 |
+
/**
|
91 |
+
* Create a single snippet table
|
92 |
+
* if one of the same name does not already exist
|
93 |
+
*
|
94 |
+
* @since 1.6
|
95 |
+
* @access private
|
96 |
+
*
|
97 |
+
* @uses dbDelta() To add the table to the database
|
98 |
+
*
|
99 |
+
* @param string $table_name The name of the table to create
|
100 |
+
* @param boolean $force_creation Skip the table exists check
|
101 |
+
*/
|
102 |
+
function create_code_snippets_table( $table_name, $force_creation = false ) {
|
103 |
+
require_once ABSPATH . 'wp-admin/includes/upgrade.php';
|
104 |
+
|
105 |
+
global $wpdb;
|
106 |
+
|
107 |
+
if ( ! $force_creation && $wpdb->get_var( "SHOW TABLES LIKE '$wpdb->snippets'" ) === $wpdb->snippets ) {
|
108 |
+
return; // bail if the table already exists
|
109 |
+
}
|
110 |
+
|
111 |
+
/* Set the database charset */
|
112 |
+
|
113 |
+
$charset_collate = '';
|
114 |
+
|
115 |
+
if ( ! empty( $wpdb->charset ) ) {
|
116 |
+
$charset_collate = "DEFAULT CHARACTER SET $wpdb->charset";
|
117 |
+
}
|
118 |
+
|
119 |
+
if ( ! empty( $wpdb->collate ) ) {
|
120 |
+
$charset_collate .= " COLLATE $wpdb->collate";
|
121 |
+
}
|
122 |
+
|
123 |
+
/* Set the snippet data columns */
|
124 |
+
|
125 |
+
$table_columns = apply_filters( 'code_snippets/database_table_columns', array(
|
126 |
+
'name tinytext not null',
|
127 |
+
'description text',
|
128 |
+
'code longtext not null',
|
129 |
+
'tags longtext',
|
130 |
+
) );
|
131 |
+
|
132 |
+
$table_columns_sql = implode( ",\n", $table_columns ); // convert the array into SQL code
|
133 |
+
|
134 |
+
/* Create the database table */
|
135 |
+
|
136 |
+
$sql = "CREATE TABLE $table_name (
|
137 |
+
id bigint(20) unsigned not null auto_increment,
|
138 |
+
{$table_columns_sql},
|
139 |
+
active tinyint(1) not null default 0,
|
140 |
+
PRIMARY KEY (id)
|
141 |
+
) {$charset_collate};";
|
142 |
+
|
143 |
+
dbDelta( apply_filters( 'code_snippets/table_sql', $sql ) );
|
144 |
+
|
145 |
+
do_action( 'code_snippets/create_table', $table_name );
|
146 |
+
}
|
@@ -0,0 +1,47 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* Register and handle the help tabs for the
|
5 |
+
* single snippet admin page
|
6 |
+
*
|
7 |
+
* @package Code_Snippets
|
8 |
+
* @subpackage Contextual_Help
|
9 |
+
*/
|
10 |
+
|
11 |
+
$screen = get_current_screen();
|
12 |
+
|
13 |
+
$screen->add_help_tab( array(
|
14 |
+
'id' => 'overview',
|
15 |
+
'title' => __( 'Overview', 'code-snippets' ),
|
16 |
+
'content' =>
|
17 |
+
'<p>' . __( 'Snippets are similar to plugins - they both extend and expand the functionality of WordPress. Snippets are more light-weight, just a few lines of code, and do not put as much load on your server. Here you can add a new snippet, or edit an existing one.', 'code-snippets' ) . '</p>',
|
18 |
+
) );
|
19 |
+
|
20 |
+
$screen->add_help_tab( array(
|
21 |
+
'id' => 'finding',
|
22 |
+
'title' => __( 'Finding Snippets', 'code-snippets' ),
|
23 |
+
'content' =>
|
24 |
+
'<p>' . __( 'Here are some links to websites which host a large number of snippets that you can add to your site.
|
25 |
+
<ul>
|
26 |
+
<li><a href="http://wp-snippets.com" title="WordPress Snippets">WP-Snippets</a></li>
|
27 |
+
<li><a href="http://wpsnipp.com" title="WP Snipp">WP Snipp</a></li>
|
28 |
+
<li><a href="http://www.catswhocode.com/blog/snippets" title="Cats Who Code Snippet Library">Cats Who Code</a></li>
|
29 |
+
<li><a href="http://www.wpfunction.me">WP Function Me</a></li>
|
30 |
+
</ul>', 'code-snippets' ) .
|
31 |
+
__( 'More places to find snippets, as well as a selection of example snippets, can be found in the <a href="http://code-snippets.bungeshea.com/docs/finding-snippets/">plugin documentation</a>', 'code-snippets' ) . '</p>'
|
32 |
+
) );
|
33 |
+
|
34 |
+
$screen->add_help_tab( array(
|
35 |
+
'id' => 'adding',
|
36 |
+
'title' => __( 'Adding Snippets', 'code-snippets' ),
|
37 |
+
'content' =>
|
38 |
+
'<p>' . __( 'You need to fill out the name and code fields for your snippet to be added. While the description field will add more information about how your snippet works, what is does and where you found it, it is completely optional.', 'code-snippets' ) . '</p>' .
|
39 |
+
'<p>' . __( 'Please be sure to check that your snippet is valid PHP code and will not produce errors before adding it through this page. While doing so will not become active straight away, it will help to minimise the chance of a faulty snippet becoming active on your site.', 'code-snippets' ) . '</p>'
|
40 |
+
) );
|
41 |
+
|
42 |
+
$screen->set_help_sidebar(
|
43 |
+
'<p><strong>' . __( 'For more information:', 'code-snippets' ) . '</strong></p>' .
|
44 |
+
'<p>' . __( '<a href="http://wordpress.org/plugins/code-snippets" target="_blank">WordPress Extend</a>', 'code-snippets' ) . '</p>' .
|
45 |
+
'<p>' . __( '<a href="http://wordpress.org/support/plugin/code-snippets" target="_blank">Support Forums</a>', 'code-snippets' ) . '</p>' .
|
46 |
+
'<p>' . __( '<a href="http://code-snippets.bungeshea.com/" target="_blank">Project Website</a>', 'code-snippets' ) . '</p>'
|
47 |
+
);
|
@@ -0,0 +1,36 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* Status and error messages for the single snippet page
|
5 |
+
*
|
6 |
+
* @package Code_Snippets
|
7 |
+
* @subpackage Admin_Messages
|
8 |
+
*/
|
9 |
+
|
10 |
+
$_f = '<div id="message" class="%2$s fade"><p>%1$s</p></div>';
|
11 |
+
|
12 |
+
if ( isset( $_REQUEST['invalid'] ) && $_REQUEST['invalid'] ) :
|
13 |
+
|
14 |
+
printf ( $_f, __( 'An error occurred when saving the snippet.', 'code-snippets' ), 'error' );
|
15 |
+
|
16 |
+
elseif ( isset( $_REQUEST['activated'], $_REQUEST['updated'] ) && $_REQUEST['activated'] && $_REQUEST['updated'] ) :
|
17 |
+
|
18 |
+
printf ( $_f, __( 'Snippet <strong>updated</strong> and <strong>activated</strong>.', 'code-snippets' ), 'updated' );
|
19 |
+
|
20 |
+
elseif ( isset( $_REQUEST['activated'], $_REQUEST['added'] ) && $_REQUEST['activated'] && $_REQUEST['added'] ) :
|
21 |
+
|
22 |
+
printf ( $_f, __( 'Snippet <strong>added</strong> and <strong>activated</strong>.', 'code-snippets' ), 'updated' );
|
23 |
+
|
24 |
+
elseif ( isset( $_REQUEST['deactivated'], $_REQUEST['updated'] ) && $_REQUEST['deactivated'] && $_REQUEST['updated'] ) :
|
25 |
+
|
26 |
+
printf ( $_f, __( 'Snippet <strong>updated</strong> and <strong>deactivated</strong>.', 'code-snippets' ), 'updated' );
|
27 |
+
|
28 |
+
elseif ( isset( $_REQUEST['updated'] ) && $_REQUEST['updated'] ) :
|
29 |
+
|
30 |
+
printf ( $_f, __( 'Snippet <strong>updated</strong>.', 'code-snippets' ), 'updated' );
|
31 |
+
|
32 |
+
elseif ( isset( $_REQUEST['added'] ) && $_REQUEST['added'] ) :
|
33 |
+
|
34 |
+
printf ( $_f, __( 'Snippet <strong>added</strong>.', 'code-snippets' ), 'updated' );
|
35 |
+
|
36 |
+
endif;
|
@@ -0,0 +1,146 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* HTML code for the Add New/Edit Snippet page
|
5 |
+
*
|
6 |
+
* @package Code_Snippets
|
7 |
+
* @subpackage Edit
|
8 |
+
*/
|
9 |
+
|
10 |
+
/* Bail if accessed directly */
|
11 |
+
if ( ! defined( 'ABSPATH' ) ) {
|
12 |
+
return;
|
13 |
+
}
|
14 |
+
|
15 |
+
global $pagenow;
|
16 |
+
|
17 |
+
$table = get_snippets_table_name();
|
18 |
+
$edit_id = code_snippets_get_menu_slug( 'edit' ) === $_REQUEST['page'] ? absint( $_REQUEST['id'] ) : 0;
|
19 |
+
$snippet = get_snippet( $edit_id );
|
20 |
+
|
21 |
+
?>
|
22 |
+
<div class="wrap">
|
23 |
+
<?php screen_icon(); ?>
|
24 |
+
<h2><?php
|
25 |
+
if ( $edit_id ) {
|
26 |
+
esc_html_e( 'Edit Snippet', 'code-snippets' );
|
27 |
+
|
28 |
+
if ( current_user_can( get_snippets_cap() ) ) {
|
29 |
+
printf( ' <a href="%1$s" class="add-new-h2">%2$s</a>',
|
30 |
+
code_snippets_get_menu_url( 'add' ),
|
31 |
+
esc_html_x( 'Add New', 'snippet', 'code-snippets' )
|
32 |
+
);
|
33 |
+
}
|
34 |
+
} else {
|
35 |
+
esc_html_e( 'Add New Snippet', 'code-snippets' );
|
36 |
+
}
|
37 |
+
?></h2>
|
38 |
+
|
39 |
+
<form method="post" action="" style="margin-top: 10px;">
|
40 |
+
<?php
|
41 |
+
|
42 |
+
/* Output the hidden fields */
|
43 |
+
|
44 |
+
if ( 0 !== $snippet->id ) {
|
45 |
+
printf ( '<input type="hidden" name="snippet_id" value="%d" />', $snippet->id );
|
46 |
+
}
|
47 |
+
|
48 |
+
printf ( '<input type="hidden" name="snippet_active" value="%d" />', $snippet->active );
|
49 |
+
?>
|
50 |
+
<div id="titlediv">
|
51 |
+
<div id="titlewrap">
|
52 |
+
<label for="title" style="display: none;"><?php _e( 'Name (short title)', 'code-snippets' ); ?></label>
|
53 |
+
<input id="title" type="text" autocomplete="off" name="snippet_name" value="<?php echo $snippet->name; ?>" placeholder="<?php _e( 'Name (short title)', 'code-snippets' ); ?>" />
|
54 |
+
</div>
|
55 |
+
</div>
|
56 |
+
|
57 |
+
<label for="snippet_code">
|
58 |
+
<h3><?php _e( 'Code', 'code-snippets' ); ?></h3>
|
59 |
+
</label>
|
60 |
+
|
61 |
+
<textarea id="snippet_code" name="snippet_code" rows="20" spellcheck="false" style="font-family: monospace; width: 100%;"><?php echo esc_textarea( $snippet->code ); ?></textarea>
|
62 |
+
|
63 |
+
<?php
|
64 |
+
|
65 |
+
/* Allow addon plugins (and us!) to add fields and content to this page */
|
66 |
+
do_action( 'code_snippets/admin/single', $snippet );
|
67 |
+
|
68 |
+
/* Add a nonce for security */
|
69 |
+
wp_nonce_field( 'save_snippet' );
|
70 |
+
?>
|
71 |
+
|
72 |
+
<p class="submit">
|
73 |
+
<?php
|
74 |
+
|
75 |
+
/* Make the 'Save and Activate' button the default if the setting is enabled */
|
76 |
+
if ( ! $snippet->active && code_snippets_get_setting( 'general', 'activate_by_default' ) ) {
|
77 |
+
|
78 |
+
submit_button(
|
79 |
+
__( 'Save Changes and Activate', 'code-snippets' ),
|
80 |
+
'primary', 'save_snippet_activate', false
|
81 |
+
);
|
82 |
+
|
83 |
+
submit_button( null, 'secondary', 'save_snippet', false );
|
84 |
+
|
85 |
+
} else {
|
86 |
+
|
87 |
+
/* Save Snippet button */
|
88 |
+
submit_button( null, 'primary', 'save_snippet', false );
|
89 |
+
|
90 |
+
/* Save Snippet and Activate/Deactivate button */
|
91 |
+
if ( ! $snippet->active ) {
|
92 |
+
submit_button(
|
93 |
+
__( 'Save Changes and Activate', 'code-snippets' ),
|
94 |
+
'secondary', 'save_snippet_activate', false
|
95 |
+
);
|
96 |
+
|
97 |
+
} else {
|
98 |
+
submit_button(
|
99 |
+
__( 'Save Changes and Deactivate', 'code-snippets' ),
|
100 |
+
'secondary', 'save_snippet_deactivate', false
|
101 |
+
);
|
102 |
+
}
|
103 |
+
}
|
104 |
+
|
105 |
+
if ( 0 !== $snippet->id ) {
|
106 |
+
|
107 |
+
/* Export button */
|
108 |
+
|
109 |
+
submit_button( __( 'Export', 'code-snippets' ), 'secondary', 'export_snippet', false );
|
110 |
+
|
111 |
+
/* Delete button */
|
112 |
+
|
113 |
+
$confirm_delete_js = esc_js(
|
114 |
+
sprintf (
|
115 |
+
'return confirm("%s");',
|
116 |
+
__( "You are about to permanently delete this snippet.\n'Cancel' to stop, 'OK' to delete.", 'code-snippets' )
|
117 |
+
)
|
118 |
+
);
|
119 |
+
|
120 |
+
submit_button(
|
121 |
+
__( 'Delete', 'code-snippets' ),
|
122 |
+
'secondary', 'delete_snippet', false,
|
123 |
+
sprintf ( 'onclick="%s"', $confirm_delete_js )
|
124 |
+
);
|
125 |
+
}
|
126 |
+
|
127 |
+
?>
|
128 |
+
</p>
|
129 |
+
|
130 |
+
</form>
|
131 |
+
</div>
|
132 |
+
|
133 |
+
<script>
|
134 |
+
/**
|
135 |
+
* Loads CodeMirror on the snippet editor
|
136 |
+
*/
|
137 |
+
(function() {
|
138 |
+
|
139 |
+
var atts = <?php
|
140 |
+
$atts = array( 'mode' => 'text/x-php' );
|
141 |
+
echo code_snippets_get_editor_atts( $atts, true );
|
142 |
+
?>;
|
143 |
+
var editor = CodeMirror.fromTextArea(document.getElementById('snippet_code'), atts);
|
144 |
+
|
145 |
+
})();
|
146 |
+
</script>
|
@@ -0,0 +1,370 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* Functions to handle the single snippet menu
|
5 |
+
*
|
6 |
+
* @package Code_Snippets
|
7 |
+
* @subpackage Administration
|
8 |
+
*/
|
9 |
+
|
10 |
+
/**
|
11 |
+
* Fetch the admin menu slug for a snippets menu
|
12 |
+
* @param integer $id The snippet
|
13 |
+
* @return string The URL to the edit snippet page for that snippet
|
14 |
+
*/
|
15 |
+
function get_snippet_edit_url( $snippet_id ) {
|
16 |
+
return add_query_arg(
|
17 |
+
'id', absint( $snippet_id ),
|
18 |
+
code_snippets_get_menu_url( 'edit' )
|
19 |
+
);
|
20 |
+
}
|
21 |
+
|
22 |
+
/**
|
23 |
+
* Register the single snippet admin menu
|
24 |
+
*
|
25 |
+
* @since 2.0
|
26 |
+
* @access private
|
27 |
+
* @uses add_submenu_page() To register a sub-menu
|
28 |
+
*/
|
29 |
+
function code_snippets_add_single_menu() {
|
30 |
+
|
31 |
+
/* Add New Snippet menu */
|
32 |
+
$add_hook = add_submenu_page(
|
33 |
+
code_snippets_get_menu_slug(),
|
34 |
+
__( 'Add New Snippet', 'code-snippets' ),
|
35 |
+
__( 'Add New', 'code-snippets' ),
|
36 |
+
get_snippets_cap(),
|
37 |
+
code_snippets_get_menu_slug( 'add' ),
|
38 |
+
'code_snippets_render_single_menu'
|
39 |
+
);
|
40 |
+
|
41 |
+
/* Check if we are currently editing a snippet */
|
42 |
+
if ( isset( $_REQUEST['page'] ) && code_snippets_get_menu_slug( 'edit' ) === $_REQUEST['page'] ) {
|
43 |
+
|
44 |
+
$edit_hook = add_submenu_page(
|
45 |
+
code_snippets_get_menu_slug(),
|
46 |
+
__( 'Edit Snippet', 'code-snippets' ),
|
47 |
+
__( 'Edit Snippet', 'code-snippets' ),
|
48 |
+
get_snippets_cap(),
|
49 |
+
code_snippets_get_menu_slug( 'edit' ),
|
50 |
+
'code_snippets_render_single_menu'
|
51 |
+
);
|
52 |
+
|
53 |
+
add_action( 'load-' . $edit_hook, 'code_snippets_load_single_menu' );
|
54 |
+
}
|
55 |
+
|
56 |
+
add_action( 'load-' . $add_hook, 'code_snippets_load_single_menu' );
|
57 |
+
}
|
58 |
+
|
59 |
+
add_action( 'admin_menu', 'code_snippets_add_single_menu', 5 );
|
60 |
+
add_action( 'network_admin_menu', 'code_snippets_add_single_menu', 5 );
|
61 |
+
|
62 |
+
/**
|
63 |
+
* Displays the single snippet menu
|
64 |
+
*
|
65 |
+
* @since 2.0
|
66 |
+
*/
|
67 |
+
function code_snippets_render_single_menu() {
|
68 |
+
require plugin_dir_path( __FILE__ ) . 'admin-messages.php';
|
69 |
+
require plugin_dir_path( __FILE__ ) . 'admin.php';
|
70 |
+
}
|
71 |
+
|
72 |
+
/**
|
73 |
+
* Loads the help tabs for the Edit Snippets page
|
74 |
+
*
|
75 |
+
* @since 1.0
|
76 |
+
* @access private
|
77 |
+
* @uses wp_redirect To pass the results to the page
|
78 |
+
*/
|
79 |
+
function code_snippets_load_single_menu() {
|
80 |
+
|
81 |
+
/* Make sure the user has permission to be here */
|
82 |
+
if ( ! current_user_can( get_snippets_cap() ) ) {
|
83 |
+
wp_die( __( 'You are not authorized to access this page.', 'code-snippets' ) );
|
84 |
+
}
|
85 |
+
|
86 |
+
/* Create the snippet tables if they don't exist */
|
87 |
+
create_code_snippets_tables( true, true );
|
88 |
+
|
89 |
+
/* Load the screen help tabs */
|
90 |
+
require plugin_dir_path( __FILE__ ) . 'admin-help.php';
|
91 |
+
|
92 |
+
/* Enqueue the code editor and other scripts and styles */
|
93 |
+
add_filter( 'admin_enqueue_scripts', 'code_snippets_enqueue_codemirror' );
|
94 |
+
|
95 |
+
/* Don't allow visiting the edit snippet page without a valid ID */
|
96 |
+
if ( code_snippets_get_menu_slug( 'edit' ) === $_REQUEST['page'] ) {
|
97 |
+
if ( ! isset( $_REQUEST['id'] ) || 0 == $_REQUEST['id'] ) {
|
98 |
+
wp_redirect( code_snippets_get_menu_url( 'add' ) );
|
99 |
+
exit;
|
100 |
+
}
|
101 |
+
}
|
102 |
+
|
103 |
+
/* Make sure the nonce validates before we do any snippet ops */
|
104 |
+
if ( ! isset( $_REQUEST['_wpnonce'] ) || ! wp_verify_nonce( $_REQUEST['_wpnonce'], 'save_snippet' ) ) {
|
105 |
+
return;
|
106 |
+
}
|
107 |
+
|
108 |
+
/* Save the snippet if one has been submitted */
|
109 |
+
if ( isset( $_POST['save_snippet'] ) || isset( $_POST['save_snippet_activate'] ) || isset( $_POST['save_snippet_deactivate'] ) ) {
|
110 |
+
|
111 |
+
/* Activate or deactivate the snippet before saving if we clicked the button */
|
112 |
+
if ( isset( $_POST['save_snippet_activate'] ) ) {
|
113 |
+
$_POST['snippet_active'] = 1;
|
114 |
+
} elseif ( isset( $_POST['save_snippet_deactivate'] ) ) {
|
115 |
+
$_POST['snippet_active'] = 0;
|
116 |
+
}
|
117 |
+
|
118 |
+
/* Save the snippet to the database */
|
119 |
+
$result = save_snippet( stripslashes_deep( $_POST ) );
|
120 |
+
|
121 |
+
/* Build the status message and redirect */
|
122 |
+
$query_args = array();
|
123 |
+
|
124 |
+
if ( $result && isset( $_POST['save_snippet_activate'] ) ) {
|
125 |
+
/* Snippet was activated addition to saving*/
|
126 |
+
$query_args['activated'] = true;
|
127 |
+
}
|
128 |
+
elseif ( $result && isset( $_POST['save_snippet_deactivate'] ) ) {
|
129 |
+
/* Snippet was deactivated addition to saving*/
|
130 |
+
$query_args['deactivated'] = true;
|
131 |
+
}
|
132 |
+
|
133 |
+
if ( ! $result || $result < 1 ) {
|
134 |
+
/* An error occurred */
|
135 |
+
$query_args['invalid'] = true;
|
136 |
+
}
|
137 |
+
elseif ( isset( $_POST['snippet_id'] ) ) {
|
138 |
+
/* Existing snippet was updated */
|
139 |
+
$query_args['id'] = $result;
|
140 |
+
$query_args['updated'] = true;
|
141 |
+
}
|
142 |
+
else {
|
143 |
+
/* New snippet was added */
|
144 |
+
$query_args['id'] = $result;
|
145 |
+
$query_args['added'] = true;
|
146 |
+
}
|
147 |
+
|
148 |
+
/* Redirect to edit snippet page */
|
149 |
+
wp_redirect( add_query_arg( $query_args, code_snippets_get_menu_url( 'edit' ) ) );
|
150 |
+
}
|
151 |
+
|
152 |
+
/* Delete the snippet if the button was clicked */
|
153 |
+
elseif ( isset( $_POST['snippet_id'], $_POST['delete_snippet'] ) ) {
|
154 |
+
delete_snippet( $_POST['snippet_id'] );
|
155 |
+
wp_redirect( add_query_arg( 'delete', true, $this->manage_url ) );
|
156 |
+
}
|
157 |
+
|
158 |
+
/* Export the snippet if the button was clicked */
|
159 |
+
elseif ( isset( $_POST['snippet_id'], $_POST['export_snippet'] ) ) {
|
160 |
+
export_snippet( $_POST['snippet_id'] );
|
161 |
+
}
|
162 |
+
}
|
163 |
+
|
164 |
+
/**
|
165 |
+
* Add a description editor to the single snippet page
|
166 |
+
*
|
167 |
+
* @since 1.7
|
168 |
+
* @access private
|
169 |
+
* @param object $snippet The snippet being used for this page
|
170 |
+
*/
|
171 |
+
function code_snippets_description_editor_box( $snippet ) {
|
172 |
+
|
173 |
+
?>
|
174 |
+
|
175 |
+
<label for="snippet_description">
|
176 |
+
<h3><div><?php _e( 'Description', 'code-snippets' ); ?></div></h3>
|
177 |
+
</label>
|
178 |
+
|
179 |
+
<?php
|
180 |
+
|
181 |
+
remove_editor_styles(); // stop custom theme styling interfering with the editor
|
182 |
+
|
183 |
+
wp_editor(
|
184 |
+
$snippet->description,
|
185 |
+
'description',
|
186 |
+
apply_filters( 'code_snippets/admin/description_editor_settings', array(
|
187 |
+
'textarea_name' => 'snippet_description',
|
188 |
+
'textarea_rows' => 10,
|
189 |
+
'teeny' => true,
|
190 |
+
'media_buttons' => false,
|
191 |
+
) )
|
192 |
+
);
|
193 |
+
}
|
194 |
+
|
195 |
+
add_action( 'code_snippets/admin/single', 'code_snippets_description_editor_box', 5 );
|
196 |
+
|
197 |
+
/**
|
198 |
+
* Output the interface for editing snippet tags
|
199 |
+
* @since 2.0
|
200 |
+
* @param object $snippet The snippet currently being edited
|
201 |
+
*/
|
202 |
+
function code_snippets_tags_editor( $snippet ) {
|
203 |
+
?>
|
204 |
+
<label for="snippet_tags" style="cursor: auto;">
|
205 |
+
<h3><?php esc_html_e( 'Tags', 'code-snippets' ); ?></h3>
|
206 |
+
</label>
|
207 |
+
|
208 |
+
<input type="text" id="snippet_tags" name="snippet_tags" style="width: 100%;"
|
209 |
+
placeholder="Enter a list of tags; separated by commas" value="<?php echo implode( ', ', $snippet->tags ); ?>" />
|
210 |
+
|
211 |
+
<script type="text/javascript">
|
212 |
+
jQuery('#snippet_tags').tagit({
|
213 |
+
availableTags: ['<?php echo implode( "','", get_all_snippet_tags() ); ?>'],
|
214 |
+
allowSpaces: true,
|
215 |
+
removeConfirmation: true
|
216 |
+
});
|
217 |
+
</script>
|
218 |
+
<?php
|
219 |
+
}
|
220 |
+
|
221 |
+
add_action( 'code_snippets/admin/single', 'code_snippets_tags_editor' );
|
222 |
+
|
223 |
+
/**
|
224 |
+
* Registers and loads the code editor's assets
|
225 |
+
*
|
226 |
+
* @since 1.7
|
227 |
+
* @access private
|
228 |
+
*
|
229 |
+
* @uses wp_register_script()
|
230 |
+
* @uses wp_register_style()
|
231 |
+
* @uses wp_enqueue_script() To add the scripts to the queue
|
232 |
+
* @uses wp_enqueue_style() To add the stylesheets to the queue
|
233 |
+
*
|
234 |
+
* @param string $hook The current page hook, to be compared with the single snippet page hook
|
235 |
+
*/
|
236 |
+
function code_snippets_enqueue_codemirror() {
|
237 |
+
|
238 |
+
/* Remove other CodeMirror styles */
|
239 |
+
wp_deregister_style( 'codemirror' );
|
240 |
+
wp_deregister_style( 'wpeditor' );
|
241 |
+
|
242 |
+
/* CodeMirror */
|
243 |
+
|
244 |
+
$codemirror_version = '5.0';
|
245 |
+
$codemirror_url = plugins_url( 'vendor/codemirror/', CODE_SNIPPETS_FILE );
|
246 |
+
|
247 |
+
wp_enqueue_style(
|
248 |
+
'code-snippets-codemirror',
|
249 |
+
$codemirror_url . 'lib/codemirror.css',
|
250 |
+
false,
|
251 |
+
$codemirror_version
|
252 |
+
);
|
253 |
+
|
254 |
+
wp_enqueue_script(
|
255 |
+
'code-snippets-codemirror',
|
256 |
+
$codemirror_url . 'lib/codemirror.js',
|
257 |
+
false,
|
258 |
+
$codemirror_version
|
259 |
+
);
|
260 |
+
|
261 |
+
/* CodeMirror Modes */
|
262 |
+
|
263 |
+
wp_enqueue_script(
|
264 |
+
'code-snippets-codemirror-mode-clike',
|
265 |
+
$codemirror_url . 'mode/clike/clike.js',
|
266 |
+
array( 'code-snippets-codemirror' ),
|
267 |
+
$codemirror_version
|
268 |
+
);
|
269 |
+
|
270 |
+
wp_enqueue_script(
|
271 |
+
'code-snippets-codemirror-mode-php',
|
272 |
+
$codemirror_url . 'mode/php/php.js',
|
273 |
+
array( 'code-snippets-codemirror', 'code-snippets-codemirror-mode-clike' ),
|
274 |
+
$codemirror_version
|
275 |
+
);
|
276 |
+
|
277 |
+
|
278 |
+
/* CodeMirror Addons */
|
279 |
+
|
280 |
+
wp_enqueue_script(
|
281 |
+
'code-snippets-codemirror-addon-searchcursor',
|
282 |
+
$codemirror_url . 'addon/search/searchcursor.js',
|
283 |
+
array( 'code-snippets-codemirror' ),
|
284 |
+
$codemirror_version
|
285 |
+
);
|
286 |
+
|
287 |
+
wp_enqueue_script(
|
288 |
+
'code-snippets-codemirror-addon-search',
|
289 |
+
$codemirror_url . 'addon/search/search.js',
|
290 |
+
array( 'code-snippets-codemirror', 'code-snippets-codemirror-addon-searchcursor' ),
|
291 |
+
$codemirror_version
|
292 |
+
);
|
293 |
+
|
294 |
+
wp_enqueue_script(
|
295 |
+
'code-snippets-codemirror-addon-matchbrackets',
|
296 |
+
$codemirror_url . 'addon/edit/matchbrackets.js',
|
297 |
+
array( 'code-snippets-codemirror' ),
|
298 |
+
$codemirror_version
|
299 |
+
);
|
300 |
+
|
301 |
+
wp_enqueue_script(
|
302 |
+
'code-snippets-codemirror-addon-closebrackets',
|
303 |
+
$codemirror_url . 'addon/edit/closebrackets.js',
|
304 |
+
array( 'code-snippets-codemirror' ),
|
305 |
+
$codemirror_version
|
306 |
+
);
|
307 |
+
|
308 |
+
wp_enqueue_script(
|
309 |
+
'code-snippets-codemirror-addon-match-highlighter',
|
310 |
+
$codemirror_url . 'addon/search/match-highlighter.js',
|
311 |
+
array( 'code-snippets-codemirror', 'code-snippets-codemirror-addon-searchcursor' ),
|
312 |
+
$codemirror_version
|
313 |
+
);
|
314 |
+
|
315 |
+
/* Plugin Assets */
|
316 |
+
|
317 |
+
wp_enqueue_style(
|
318 |
+
'code-snippets-edit',
|
319 |
+
plugins_url( 'css/min/edit-snippet.css', CODE_SNIPPETS_FILE ),
|
320 |
+
false,
|
321 |
+
CODE_SNIPPETS_VERSION
|
322 |
+
);
|
323 |
+
|
324 |
+
/* CodeMirror Theme */
|
325 |
+
|
326 |
+
$theme = code_snippets_get_setting( 'editor', 'theme' );
|
327 |
+
|
328 |
+
if ( 'default' !== $theme ) {
|
329 |
+
|
330 |
+
wp_enqueue_style(
|
331 |
+
'code-snippets-codemirror-theme-' . $theme,
|
332 |
+
$codemirror_url . "theme/$theme.css",
|
333 |
+
array( 'code-snippets-codemirror' ),
|
334 |
+
$codemirror_version
|
335 |
+
);
|
336 |
+
}
|
337 |
+
|
338 |
+
/* Tag It UI */
|
339 |
+
|
340 |
+
$tagit_version = '2.0';
|
341 |
+
|
342 |
+
wp_enqueue_script(
|
343 |
+
'code-snippets-tag-it',
|
344 |
+
plugins_url( 'js/vendor/tag-it.min.js', CODE_SNIPPETS_FILE ),
|
345 |
+
array(
|
346 |
+
'jquery-ui-core',
|
347 |
+
'jquery-ui-widget',
|
348 |
+
'jquery-ui-position',
|
349 |
+
'jquery-ui-autocomplete',
|
350 |
+
'jquery-effects-blind',
|
351 |
+
'jquery-effects-highlight',
|
352 |
+
),
|
353 |
+
$tagit_version
|
354 |
+
);
|
355 |
+
|
356 |
+
wp_enqueue_style(
|
357 |
+
'code-snippets-tagit',
|
358 |
+
plugins_url( 'js/vendor/jquery.tagit.css', CODE_SNIPPETS_FILE ),
|
359 |
+
false,
|
360 |
+
$tagit_version
|
361 |
+
);
|
362 |
+
|
363 |
+
wp_enqueue_style(
|
364 |
+
'code-snippets-tagit-zendesk-ui',
|
365 |
+
plugins_url( 'js/vendor/tagit.ui-zendesk.css', CODE_SNIPPETS_FILE ),
|
366 |
+
array( 'code-snippets-tagit' ),
|
367 |
+
$tagit_version
|
368 |
+
);
|
369 |
+
|
370 |
+
}
|
@@ -0,0 +1,40 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* Get the attributes for the code editor
|
5 |
+
* @param array $override_atts Pass an array of attributes to override the saved ones
|
6 |
+
* @param boolean $json_encode Encode the data as JSON
|
7 |
+
* @return array|string Array if $json_encode is false, JSON string if it is true
|
8 |
+
*/
|
9 |
+
function code_snippets_get_editor_atts( $override_atts, $json_encode ) {
|
10 |
+
$settings = code_snippets_get_settings();
|
11 |
+
$settings = $settings['editor'];
|
12 |
+
|
13 |
+
$fields = code_snippets_get_settings_fields();
|
14 |
+
$fields = $fields['editor'];
|
15 |
+
|
16 |
+
$saved_atts = array(
|
17 |
+
'matchBrackets' => true,
|
18 |
+
);
|
19 |
+
|
20 |
+
foreach ( $fields as $field ) {
|
21 |
+
$saved_atts[ $field['codemirror'] ] = $settings[ $field['id'] ];
|
22 |
+
|
23 |
+
}
|
24 |
+
|
25 |
+
$atts = wp_parse_args( $override_atts, $saved_atts );
|
26 |
+
$atts = apply_filters( 'code_snippets_codemirror_atts', $atts );
|
27 |
+
|
28 |
+
if ( $json_encode ) {
|
29 |
+
|
30 |
+
/* JSON_UNESCAPED_SLASHES was added in PHP 5.4 */
|
31 |
+
if ( version_compare( phpversion(), '5.4.0', '>=' ) ) {
|
32 |
+
$atts = json_encode( $atts, JSON_UNESCAPED_SLASHES );
|
33 |
+
} else {
|
34 |
+
/* Use a fallback for < 5.4 */
|
35 |
+
$atts = str_replace('\\/', '/', json_encode( $atts ) );
|
36 |
+
}
|
37 |
+
}
|
38 |
+
|
39 |
+
return $atts;
|
40 |
+
}
|
@@ -0,0 +1,41 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* Register and handle the help tabs for the
|
5 |
+
* import snippets admin page
|
6 |
+
*
|
7 |
+
* @package Code_Snippets
|
8 |
+
* @subpackage Import
|
9 |
+
*/
|
10 |
+
|
11 |
+
$screen = get_current_screen();
|
12 |
+
$manage_url = code_snippets_get_menu_url( 'manage' );
|
13 |
+
|
14 |
+
$screen->add_help_tab( array(
|
15 |
+
'id' => 'overview',
|
16 |
+
'title' => __( 'Overview', 'code-snippets' ),
|
17 |
+
'content' =>
|
18 |
+
'<p>' . __( 'Snippets are similar to plugins - they both extend and expand the functionality of WordPress. Snippets are more light-weight, just a few lines of code, and do not put as much load on your server. Here you can load snippets from a Code Snippets (.xml) import file into the database with your existing snippets.', 'code-snippets' ) . '</p>'
|
19 |
+
) );
|
20 |
+
|
21 |
+
$screen->add_help_tab( array(
|
22 |
+
'id' => 'import',
|
23 |
+
'title' => __( 'Importing', 'code-snippets' ),
|
24 |
+
'content' =>
|
25 |
+
'<p>' . __( 'You can load your snippets from a code snippets (.xml) export file using this page.', 'code-snippets' ) .
|
26 |
+
sprintf( __( 'Snippets will be added to the database along with your existing snippets. Regardless of whether the snippets were active on the previous site, imported snippets are always inactive until activated using the <a href="%s">Manage Snippets</a> page.</p>', 'code-snippets' ), $manage_url ) . '</p>'
|
27 |
+
) );
|
28 |
+
|
29 |
+
$screen->add_help_tab( array(
|
30 |
+
'id' => 'export',
|
31 |
+
'title' => __( 'Exporting', 'code-snippets' ),
|
32 |
+
'content' =>
|
33 |
+
'<p>' . sprintf( __( 'You can save your snippets to a Code Snippets (.xml) export file using the <a href="%s">Manage Snippets</a> page.', 'code-snippets' ), $manage_url ) . '</p>'
|
34 |
+
) );
|
35 |
+
|
36 |
+
$screen->set_help_sidebar(
|
37 |
+
'<p><strong>' . __( 'For more information:', 'code-snippets' ) . '</strong></p>' .
|
38 |
+
'<p>' . __( '<a href="http://wordpress.org/plugins/code-snippets" target="_blank">WordPress Extend</a>', 'code-snippets' ) . '</p>' .
|
39 |
+
'<p>' . __( '<a href="http://wordpress.org/support/plugin/code-snippets" target="_blank">Support Forums</a>', 'code-snippets' ) . '</p>' .
|
40 |
+
'<p>' . __( '<a href="http://code-snippets.bungeshea.com/" target="_blank">Project Website</a>', 'code-snippets' ) . '</p>'
|
41 |
+
);
|
@@ -0,0 +1,32 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* Status and error messages for the import snippets page
|
5 |
+
*
|
6 |
+
* @package Code_Snippets
|
7 |
+
* @subpackage Admin_Messages
|
8 |
+
*/
|
9 |
+
|
10 |
+
if ( isset( $_REQUEST['imported'] ) && 0 !== intval( $_REQUEST['imported'] ) ) {
|
11 |
+
|
12 |
+
echo '<div id="message" class="updated fade"><p>';
|
13 |
+
|
14 |
+
printf(
|
15 |
+
_n(
|
16 |
+
'Successfully imported <strong>%d</strong> snippet. <a href="%s">Have fun!</a>',
|
17 |
+
'Successfully imported <strong>%d</strong> snippets. <a href="%s">Have fun!</a>',
|
18 |
+
$_REQUEST['imported'],
|
19 |
+
'code-snippets'
|
20 |
+
),
|
21 |
+
$_REQUEST['imported'],
|
22 |
+
code_snippets_get_menu_url( 'manage' )
|
23 |
+
);
|
24 |
+
|
25 |
+
echo '</p></div>';
|
26 |
+
}
|
27 |
+
elseif ( isset( $_REQUEST['error'] ) && $_REQUEST['error'] ) {
|
28 |
+
printf (
|
29 |
+
'<div id="message" class="error fade"><p>%s</p></div>',
|
30 |
+
__( 'An error occurred when processing the import file.', 'code-snippets' )
|
31 |
+
);
|
32 |
+
}
|
@@ -0,0 +1,45 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* HTML code for the Import Snippets page
|
5 |
+
*
|
6 |
+
* @package Code_Snippets
|
7 |
+
* @subpackage Import
|
8 |
+
*/
|
9 |
+
|
10 |
+
/* Bail if accessed directly */
|
11 |
+
if ( ! defined( 'ABSPATH' ) ) {
|
12 |
+
return;
|
13 |
+
}
|
14 |
+
|
15 |
+
?>
|
16 |
+
<div class="wrap">
|
17 |
+
<?php screen_icon(); ?>
|
18 |
+
<h2><?php _e( 'Import Snippets', 'code-snippets' ); ?></h2>
|
19 |
+
|
20 |
+
<div class="narrow">
|
21 |
+
|
22 |
+
<p><?php _e( 'Howdy! Upload your Code Snippets export file and we’ll import the snippets to this site.', 'code-snippets' ); ?></p>
|
23 |
+
|
24 |
+
<p><?php printf( __( 'You will need to go to the <a href="%s">Manage Snippets</a> page to activate the imported snippets.', 'code-snippets' ), code_snippets_get_menu_url( 'manage' ) ); ?></p>
|
25 |
+
|
26 |
+
<p><?php _e( 'Choose a Code Snippets (.xml) file to upload, then click Upload file and import.', 'code-snippets' ); ?></p>
|
27 |
+
|
28 |
+
<form enctype="multipart/form-data" method="post" action="" id="import-upload-form" name="code_snippets_import">
|
29 |
+
<p>
|
30 |
+
<input type="hidden" name="action" value="save" />
|
31 |
+
<input type="hidden" name="max_file_size" value="8388608" />
|
32 |
+
|
33 |
+
<label for="upload"><?php _e( 'Choose a file from your computer:', 'code-snippets' ); ?></label>
|
34 |
+
<?php _e( '(Maximum size: 8MB)', 'code-snippets' ); ?>
|
35 |
+
<input type="file" id="upload" name="code_snippets_import_file" size="25" accept="text/xml" />
|
36 |
+
</p>
|
37 |
+
|
38 |
+
<?php
|
39 |
+
do_action( 'code_snippets/admin/import_form' );
|
40 |
+
submit_button( __( 'Upload file and import', 'code-snippets' ) );
|
41 |
+
?>
|
42 |
+
|
43 |
+
</form>
|
44 |
+
</div>
|
45 |
+
</div>
|
@@ -0,0 +1,115 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* Functions to handle the import snippets menu
|
5 |
+
*
|
6 |
+
* @package Code_Snippets
|
7 |
+
* @subpackage Administration
|
8 |
+
*/
|
9 |
+
|
10 |
+
/**
|
11 |
+
* Add the importer to the Tools > Import menu
|
12 |
+
*
|
13 |
+
* @since 1.6
|
14 |
+
* @access private
|
15 |
+
*/
|
16 |
+
function code_snippets_register_importer() {
|
17 |
+
|
18 |
+
/* Only register the importer if the current user can manage snippets */
|
19 |
+
if ( defined( 'WP_LOAD_IMPORTERS' ) && current_user_can( get_snippets_cap() ) ) {
|
20 |
+
|
21 |
+
/* Load Importer API */
|
22 |
+
require_once ABSPATH . 'wp-admin/includes/import.php';
|
23 |
+
|
24 |
+
if ( ! class_exists( 'WP_Importer' ) ) {
|
25 |
+
$class_wp_importer = ABSPATH . 'wp-admin/includes/class-wp-importer.php';
|
26 |
+
if ( file_exists( $class_wp_importer ) ) {
|
27 |
+
require_once $class_wp_importer;
|
28 |
+
}
|
29 |
+
}
|
30 |
+
|
31 |
+
/* Register the Code Snippets importer with WordPress */
|
32 |
+
register_importer(
|
33 |
+
'code-snippets',
|
34 |
+
__( 'Code Snippets', 'code-snippets' ),
|
35 |
+
__( 'Import snippets from a code snippets export file', 'code-snippets' ),
|
36 |
+
'code_snippets_render_import_menu'
|
37 |
+
);
|
38 |
+
}
|
39 |
+
|
40 |
+
add_action( 'load-importer-code-snippets', 'code_snippets_load_import_menu' );
|
41 |
+
}
|
42 |
+
|
43 |
+
add_action( 'admin_init', 'code_snippets_register_importer' );
|
44 |
+
|
45 |
+
/**
|
46 |
+
* Add an Import Snippets page to the admin menu.
|
47 |
+
*
|
48 |
+
* @since 1.6
|
49 |
+
* @uses add_submenu_page() To register the menu page
|
50 |
+
*/
|
51 |
+
function code_snippets_add_import_menu() {
|
52 |
+
|
53 |
+
$hook = add_submenu_page(
|
54 |
+
code_snippets_get_menu_slug(),
|
55 |
+
__( 'Import Snippets', 'code-snippets' ),
|
56 |
+
__( 'Import', 'code-snippets' ),
|
57 |
+
get_snippets_cap(),
|
58 |
+
code_snippets_get_menu_slug( 'import' ),
|
59 |
+
'code_snippets_render_import_menu'
|
60 |
+
);
|
61 |
+
|
62 |
+
add_action( 'load-' . $hook, 'code_snippets_load_import_menu' );
|
63 |
+
}
|
64 |
+
|
65 |
+
add_action( 'admin_menu', 'code_snippets_add_import_menu' );
|
66 |
+
add_action( 'network_admin_menu', 'code_snippets_add_import_menu' );
|
67 |
+
|
68 |
+
/**
|
69 |
+
* Displays the import snippets page
|
70 |
+
*
|
71 |
+
* @since 2.0
|
72 |
+
*/
|
73 |
+
function code_snippets_render_import_menu() {
|
74 |
+
require_once plugin_dir_path( __FILE__ ) . 'admin-messages.php';
|
75 |
+
require_once plugin_dir_path( __FILE__ ) . 'admin.php';
|
76 |
+
}
|
77 |
+
|
78 |
+
/**
|
79 |
+
* Processes import files and loads the help tabs for the Import Snippets page
|
80 |
+
*
|
81 |
+
* @since 1.3
|
82 |
+
*
|
83 |
+
* @uses import_snippets() To process the import file
|
84 |
+
* @uses wp_redirect() To pass the import results to the page
|
85 |
+
* @uses add_query_arg() To append the results to the current URI
|
86 |
+
*/
|
87 |
+
function code_snippets_load_import_menu() {
|
88 |
+
$network = get_current_screen()->is_network;
|
89 |
+
|
90 |
+
/* Make sure the user has permission to be here */
|
91 |
+
if ( ! current_user_can( get_snippets_cap() ) ) {
|
92 |
+
wp_die( __( 'You are not access this page.', 'code-snippets' ) );
|
93 |
+
}
|
94 |
+
|
95 |
+
/* Create the snippet tables if they don't exist */
|
96 |
+
create_code_snippets_tables( true, true );
|
97 |
+
|
98 |
+
/* Process import files */
|
99 |
+
|
100 |
+
if ( isset( $_FILES['code_snippets_import_file']['tmp_name'] ) ) {
|
101 |
+
|
102 |
+
/* Import the snippets. The result is the number of snippets that were imported */
|
103 |
+
$result = import_snippets( $_FILES['code_snippets_import_file']['tmp_name'], $network );
|
104 |
+
|
105 |
+
/* Send the amount of imported snippets to the page */
|
106 |
+
if ( false === $result ) {
|
107 |
+
wp_redirect( add_query_arg( 'error', true ) );
|
108 |
+
} else {
|
109 |
+
wp_redirect( add_query_arg( 'imported', $result ) );
|
110 |
+
}
|
111 |
+
}
|
112 |
+
|
113 |
+
/* Load the screen help tabs */
|
114 |
+
require plugin_dir_path( __FILE__ ) . 'admin-help.php';
|
115 |
+
}
|
@@ -0,0 +1,41 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* Register and handle the help tabs for the
|
5 |
+
* manage snippets admin page
|
6 |
+
*
|
7 |
+
* @package Code_Snippets
|
8 |
+
* @subpackage Manage
|
9 |
+
*/
|
10 |
+
|
11 |
+
$screen = get_current_screen();
|
12 |
+
|
13 |
+
$screen->add_help_tab( array(
|
14 |
+
'id' => 'overview',
|
15 |
+
'title' => __( 'Overview', 'code-snippets' ),
|
16 |
+
'content' =>
|
17 |
+
'<p>' . __( 'Snippets are similar to plugins - they both extend and expand the functionality of WordPress. Snippets are more light-weight, just a few lines of code, and do not put as much load on your server. Here you can manage your existing snippets and preform tasks on them such as activating, deactivating, deleting and exporting.', 'code-snippets' ) . '</p>'
|
18 |
+
) );
|
19 |
+
|
20 |
+
$screen->add_help_tab( array(
|
21 |
+
'id' => 'safe-mode',
|
22 |
+
'title' => __( 'Safe Mode', 'code-snippets' ),
|
23 |
+
'content' =>
|
24 |
+
'<p>' . __( 'Be sure to check your snippets for errors before you activate them, as a faulty snippet could bring your whole blog down. If your site starts doing strange things, deactivate all your snippets and activate them one at a time.', 'code-snippets' ) . '</p>' .
|
25 |
+
'<p>' . __("If something goes wrong with a snippet and you can't use WordPress, you can cause all snippets to stop executing by adding <code>define('CODE_SNIPPETS_SAFE_MODE', true);</code> to your <code>wp-config.php</code> file. After you have deactivated the offending snippet, you can turn off safe mode by removing this line or replacing <strong>true</strong> with <strong>false</strong>.", 'code-snippets' ) . '</p>'
|
26 |
+
) );
|
27 |
+
|
28 |
+
$screen->add_help_tab( array(
|
29 |
+
'id' => 'uninstall',
|
30 |
+
'title' => __( 'Uninstall', 'code-snippets' ),
|
31 |
+
'content' =>
|
32 |
+
'<p>' . sprintf( __( 'When you delete Code Snippets through the Plugins menu in WordPress it will clear up the <code>%1$s</code> table and a few other bits of data stored in the database. If you want to keep this data (ie: you are only temporally uninstalling Code Snippets) then remove the <code>%2$s</code> folder using FTP.', 'code-snippets' ), get_snippets_table_name(), dirname( CODE_SNIPPETS_FILE ) ) .
|
33 |
+
'<p>' . __("Even if you're sure that you don't want to use Code Snippets ever again on this WordPress installation, you may want to use the export feature to back up your snippets.", 'code-snippets' ) . '</p>'
|
34 |
+
) );
|
35 |
+
|
36 |
+
$screen->set_help_sidebar(
|
37 |
+
'<p><strong>' . __( 'For more information:', 'code-snippets' ) . '</strong></p>' .
|
38 |
+
'<p>' . __( '<a href="http://wordpress.org/plugins/code-snippets" target="_blank">WordPress Extend</a></p>', 'code-snippets' ) . '</p>' .
|
39 |
+
'<p>' . __( '<a href="http://wordpress.org/support/plugin/code-snippets" target="_blank">Support Forums</a>', 'code-snippets' ) . '</p>' .
|
40 |
+
'<p>' . __( '<a href="http://code-snippets.bungeshea.com/" target="_blank">Project Website</a>', 'code-snippets' ) . '</p>'
|
41 |
+
);
|
@@ -0,0 +1,42 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* Status and error messages for the manage snippets page
|
5 |
+
*
|
6 |
+
* @package Code_Snippets
|
7 |
+
* @subpackage Manage
|
8 |
+
*/
|
9 |
+
|
10 |
+
$_f = '<div id="message" class="%2$s fade"><p>%1$s</p></div>';
|
11 |
+
|
12 |
+
if ( defined( 'CODE_SNIPPETS_SAFE_MODE' ) && CODE_SNIPPETS_SAFE_MODE ) :
|
13 |
+
|
14 |
+
printf ( $_f, __( '<strong>Warning:</strong> Safe mode is active and snippets will not execute! Remove the <code>CODE_SNIPPETS_SAFE_MODE</code> constant from <code>wp-config.php</code> to turn off safe mode. <a href="http://code-snippets.bungeshea.com/docs/safe-mode/" target="_blank">Help</a>', 'code-snippets' ), 'error' );
|
15 |
+
|
16 |
+
endif;
|
17 |
+
|
18 |
+
if ( isset( $_REQUEST['activate'] ) ) :
|
19 |
+
|
20 |
+
printf ( $_f, __( 'Snippet <strong>activated</strong>.', 'code-snippets' ), 'updated' );
|
21 |
+
|
22 |
+
elseif ( isset( $_REQUEST['activate-multi'] ) ) :
|
23 |
+
|
24 |
+
printf ( $_f, __( 'Selected snippets <strong>activated</strong>.', 'code-snippets' ), 'updated' );
|
25 |
+
|
26 |
+
elseif ( isset( $_REQUEST['deactivate'] ) ) :
|
27 |
+
|
28 |
+
printf ( $_f, __( 'Snippet <strong>deactivated</strong>.', 'code-snippets' ), 'updated' );
|
29 |
+
|
30 |
+
elseif ( isset( $_REQUEST['deactivate-multi'] ) ) :
|
31 |
+
|
32 |
+
printf ( $_f, __( 'Selected snippets <strong>deactivated</strong>.', 'code-snippets' ), 'updated' );
|
33 |
+
|
34 |
+
elseif ( isset( $_REQUEST['delete'] ) ) :
|
35 |
+
|
36 |
+
printf ( $_f, __( 'Snippet <strong>deleted</strong>.', 'code-snippets' ), 'updated' );
|
37 |
+
|
38 |
+
elseif ( isset( $_REQUEST['delete-multi'] ) ) :
|
39 |
+
|
40 |
+
printf ( $_f, __( 'Selected snippets <strong>deleted</strong>.', 'code-snippets' ), 'updated' );
|
41 |
+
|
42 |
+
endif;
|
@@ -0,0 +1,51 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* HTML code for the Manage Snippets page
|
5 |
+
*
|
6 |
+
* @package Code_Snippets
|
7 |
+
* @subpackage Manage
|
8 |
+
*/
|
9 |
+
|
10 |
+
/* Bail if accessed directly */
|
11 |
+
if ( ! defined( 'ABSPATH' ) ) {
|
12 |
+
return;
|
13 |
+
}
|
14 |
+
|
15 |
+
global $code_snippets_list_table;
|
16 |
+
?>
|
17 |
+
|
18 |
+
<div class="wrap">
|
19 |
+
<?php screen_icon(); ?>
|
20 |
+
<h2><?php
|
21 |
+
esc_html_e( 'Snippets', 'code-snippets' );
|
22 |
+
|
23 |
+
if ( current_user_can( get_snippets_cap() ) ) {
|
24 |
+
|
25 |
+
printf ( '<a href="%2$s" class="add-new-h2">%1$s</a>',
|
26 |
+
esc_html_x( 'Add New', 'snippet', 'code-snippets' ),
|
27 |
+
code_snippets_get_menu_url( 'add' )
|
28 |
+
);
|
29 |
+
}
|
30 |
+
|
31 |
+
$code_snippets_list_table->search_notice();
|
32 |
+
?></h2>
|
33 |
+
|
34 |
+
<?php $code_snippets_list_table->views(); ?>
|
35 |
+
|
36 |
+
<form method="get" action="">
|
37 |
+
<?php
|
38 |
+
$code_snippets_list_table->required_form_fields( 'search_box' );
|
39 |
+
$code_snippets_list_table->search_box( __( 'Search Installed Snippets', 'code-snippets' ), 'search_id' );
|
40 |
+
?>
|
41 |
+
</form>
|
42 |
+
<form method="post" action="">
|
43 |
+
<?php
|
44 |
+
$code_snippets_list_table->required_form_fields();
|
45 |
+
$code_snippets_list_table->display();
|
46 |
+
?>
|
47 |
+
</form>
|
48 |
+
|
49 |
+
<?php do_action( 'code_snippets/admin/manage' ); ?>
|
50 |
+
|
51 |
+
</div>
|
@@ -0,0 +1,815 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* Contains the class for handling the snippets table
|
5 |
+
*
|
6 |
+
* @package Code_Snippets
|
7 |
+
* @subpackage Administration
|
8 |
+
*/
|
9 |
+
|
10 |
+
/* The WP_List_Table base class is not included by default, so we need to load it */
|
11 |
+
if ( ! class_exists( 'WP_List_Table' ) ) {
|
12 |
+
require_once ABSPATH . 'wp-admin/includes/class-wp-list-table.php';
|
13 |
+
}
|
14 |
+
|
15 |
+
/**
|
16 |
+
* This class handles the table for the manage snippets menu
|
17 |
+
*
|
18 |
+
* @since 1.5
|
19 |
+
* @access private
|
20 |
+
* @package Code_Snippets
|
21 |
+
*/
|
22 |
+
class Code_Snippets_List_Table extends WP_List_Table {
|
23 |
+
|
24 |
+
/**#@+
|
25 |
+
* @since 1.5
|
26 |
+
* @access private
|
27 |
+
*/
|
28 |
+
|
29 |
+
/**
|
30 |
+
* The constructor function for our class.
|
31 |
+
* Adds hooks, initializes variables, setups class.
|
32 |
+
*/
|
33 |
+
function __construct() {
|
34 |
+
global $status, $page;
|
35 |
+
$screen = get_current_screen();
|
36 |
+
|
37 |
+
/* Determine the status */
|
38 |
+
$status = 'all';
|
39 |
+
if ( isset( $_REQUEST['status'] ) && in_array( $_REQUEST['status'], array( 'active', 'inactive', 'recently_activated' ) ) )
|
40 |
+
$status = $_REQUEST['status'];
|
41 |
+
|
42 |
+
/* Add the search query to the URL */
|
43 |
+
if ( isset( $_REQUEST['s'] ) ) {
|
44 |
+
$_SERVER['REQUEST_URI'] = add_query_arg( 's', stripslashes($_REQUEST['s'] ) );
|
45 |
+
}
|
46 |
+
|
47 |
+
/* Add a snippets per page screen option */
|
48 |
+
$page = $this->get_pagenum();
|
49 |
+
|
50 |
+
add_screen_option( 'per_page', array(
|
51 |
+
'label' => __( 'Snippets per page', 'code-snippets' ),
|
52 |
+
'default' => 10,
|
53 |
+
'option' => 'snippets_per_page'
|
54 |
+
) );
|
55 |
+
|
56 |
+
add_filter( 'set-screen-option', array( $this, 'set_screen_option' ), 10, 3 );
|
57 |
+
|
58 |
+
/* Set the table columns hidden in Screen Options by default */
|
59 |
+
add_filter( "get_user_option_manage{$screen->id}columnshidden", array( $this, 'get_default_hidden_columns' ), 15 );
|
60 |
+
|
61 |
+
/* Strip once-off query args from the URL */
|
62 |
+
$_SERVER['REQUEST_URI'] = remove_query_arg( array( 'activate', 'activate-multi', 'deactivate', 'deactivate-multi', 'delete', 'delete-multi' ) );
|
63 |
+
|
64 |
+
/* Add filters to format the snippet description in the same way the post content is formatted */
|
65 |
+
$filters = array( 'wptexturize', 'convert_smilies', 'convert_chars', 'wpautop', 'shortcode_unautop', 'capital_P_dangit' );
|
66 |
+
|
67 |
+
foreach ( $filters as $filter ) {
|
68 |
+
add_filter( 'code_snippets/list_table/print_snippet_description', $filter );
|
69 |
+
}
|
70 |
+
|
71 |
+
/* Setup the class */
|
72 |
+
parent::__construct( array(
|
73 |
+
'singular' => 'snippet',
|
74 |
+
'plural' => 'snippets',
|
75 |
+
'ajax' => true,
|
76 |
+
) );
|
77 |
+
}
|
78 |
+
|
79 |
+
/**
|
80 |
+
* Handles saving the user's snippets per page preference
|
81 |
+
*
|
82 |
+
* @param unknown $status
|
83 |
+
* @param string $option
|
84 |
+
* @param unknown $value
|
85 |
+
* @return unknown
|
86 |
+
*/
|
87 |
+
function set_screen_option( $status, $option, $value ) {
|
88 |
+
if ( 'snippets_per_page' === $option ) {
|
89 |
+
return $value;
|
90 |
+
}
|
91 |
+
|
92 |
+
return $status;
|
93 |
+
}
|
94 |
+
|
95 |
+
/**
|
96 |
+
* Define the output of all columns that have no callback function
|
97 |
+
* @param object $snippet The snippet object used for the current row
|
98 |
+
* @param string $column_name The name of the column being printed
|
99 |
+
* @return string The content of the column to output
|
100 |
+
*/
|
101 |
+
function column_default( $snippet, $column_name ) {
|
102 |
+
|
103 |
+
switch( $column_name ) {
|
104 |
+
case 'id':
|
105 |
+
return $snippet->id;
|
106 |
+
case 'description':
|
107 |
+
if ( ! empty( $snippet->description ) ) {
|
108 |
+
return apply_filters( 'code_snippets/list_table/print_snippet_description', $snippet->description );
|
109 |
+
} else {
|
110 |
+
return '—';
|
111 |
+
}
|
112 |
+
default:
|
113 |
+
return do_action( "code_snippets/list_table/column_{$column_name}", $snippet );
|
114 |
+
}
|
115 |
+
}
|
116 |
+
|
117 |
+
/**
|
118 |
+
* Builds content of the snippet name column
|
119 |
+
* @param object $snippet The snippet object being used for the current row
|
120 |
+
* @return string The content of the column to output
|
121 |
+
*/
|
122 |
+
function column_name( $snippet ) {
|
123 |
+
|
124 |
+
/* Build row actions */
|
125 |
+
|
126 |
+
$actions = array();
|
127 |
+
$screen = get_current_screen();
|
128 |
+
|
129 |
+
if ( $snippet->active ) {
|
130 |
+
$actions['deactivate'] = sprintf(
|
131 |
+
'<a href="%2$s">%1$s</a>',
|
132 |
+
$screen->is_network ? __( 'Network Deactivate', 'code-snippets' ) : __( 'Deactivate', 'code-snippets' ),
|
133 |
+
add_query_arg( array(
|
134 |
+
'action' => 'deactivate',
|
135 |
+
'id' => $snippet->id
|
136 |
+
) )
|
137 |
+
);
|
138 |
+
} else {
|
139 |
+
$actions['activate'] = sprintf(
|
140 |
+
'<a href="%2$s">%1$s</a>',
|
141 |
+
$screen->is_network ? __( 'Network Activate', 'code-snippets' ) : __( 'Activate', 'code-snippets' ),
|
142 |
+
add_query_arg( array(
|
143 |
+
'action' => 'activate',
|
144 |
+
'id' => $snippet->id
|
145 |
+
) )
|
146 |
+
);
|
147 |
+
}
|
148 |
+
|
149 |
+
$actions['edit'] = sprintf(
|
150 |
+
'<a href="%2$s">%1$s</a>',
|
151 |
+
__( 'Edit', 'code-snippets' ),
|
152 |
+
get_snippet_edit_url( $snippet->id )
|
153 |
+
);
|
154 |
+
|
155 |
+
$actions['export'] = sprintf(
|
156 |
+
'<a href="%2$s">%1$s</a>',
|
157 |
+
__( 'Export', 'code-snippets' ),
|
158 |
+
add_query_arg( array(
|
159 |
+
'action' => 'export',
|
160 |
+
'id' => $snippet->id
|
161 |
+
) )
|
162 |
+
);
|
163 |
+
|
164 |
+
$actions['delete'] = sprintf(
|
165 |
+
'<a href="%2$s" class="delete" onclick="%3$s">%1$s</a>',
|
166 |
+
__( 'Delete', 'code-snippets' ),
|
167 |
+
add_query_arg( array(
|
168 |
+
'action' => 'delete',
|
169 |
+
'id' => $snippet->id
|
170 |
+
) ),
|
171 |
+
esc_js( sprintf(
|
172 |
+
'return confirm("%s");',
|
173 |
+
__("You are about to permanently delete the selected item.
|
174 |
+
'Cancel' to stop, 'OK' to delete.", 'code-snippets' )
|
175 |
+
) )
|
176 |
+
);
|
177 |
+
|
178 |
+
if ( ! empty( $snippet->name ) ) {
|
179 |
+
$title = $snippet->name;
|
180 |
+
} else {
|
181 |
+
$title = sprintf ( __( 'Untitled #%d', 'code-snippets' ), $snippet->id );
|
182 |
+
}
|
183 |
+
|
184 |
+
$row_actions = $this->row_actions( $actions,
|
185 |
+
apply_filters( 'code_snippets/list_table/row_actions_always_visiable', false )
|
186 |
+
);
|
187 |
+
|
188 |
+
/* Return the name contents */
|
189 |
+
return apply_filters(
|
190 |
+
'code_snippets/list_table/column_name',
|
191 |
+
sprintf ( '<a href="%2$s"><strong>%1$s</strong></a>', $title,
|
192 |
+
get_snippet_edit_url( $snippet->id )
|
193 |
+
) . $row_actions,
|
194 |
+
$snippet
|
195 |
+
);
|
196 |
+
}
|
197 |
+
|
198 |
+
/**
|
199 |
+
* Builds the checkbox column content
|
200 |
+
* @param object $snippet The snippet object being used for the current row
|
201 |
+
* @return string The column content to be printed
|
202 |
+
*/
|
203 |
+
function column_cb( $snippet ) {
|
204 |
+
return apply_filters(
|
205 |
+
'code_snippets/list_table/column_cb',
|
206 |
+
sprintf( '<input type="checkbox" name="ids[]" value="%s" />', $snippet->id ),
|
207 |
+
$snippet
|
208 |
+
);
|
209 |
+
}
|
210 |
+
|
211 |
+
/**
|
212 |
+
* Output the content of the tags column
|
213 |
+
* This function is used once for each row
|
214 |
+
* @since 2.0
|
215 |
+
* @param object $snippet
|
216 |
+
*/
|
217 |
+
function column_tags( $snippet ) {
|
218 |
+
|
219 |
+
if ( ! empty( $snippet->tags ) ) {
|
220 |
+
|
221 |
+
foreach ( $snippet->tags as $tag ) {
|
222 |
+
$out[] = sprintf( '<a href="%s">%s</a>',
|
223 |
+
add_query_arg( 'tag', esc_attr( $tag ) ),
|
224 |
+
esc_html( $tag )
|
225 |
+
);
|
226 |
+
}
|
227 |
+
echo join( ', ', $out );
|
228 |
+
} else {
|
229 |
+
echo '—';
|
230 |
+
}
|
231 |
+
}
|
232 |
+
|
233 |
+
/**
|
234 |
+
* Define the column headers for the table
|
235 |
+
* @return array The column headers, ID paired with label
|
236 |
+
*/
|
237 |
+
function get_columns() {
|
238 |
+
$columns = array(
|
239 |
+
'cb' => '<input type="checkbox" />',
|
240 |
+
'name' => __( 'Name', 'code-snippets' ),
|
241 |
+
'id' => __( 'ID', 'code-snippets' ),
|
242 |
+
'description' => __( 'Description', 'code-snippets' ),
|
243 |
+
'tags' => __( 'Tags', 'code-snippets' ),
|
244 |
+
);
|
245 |
+
return apply_filters( 'code_snippets/list_table/columns', $columns );
|
246 |
+
}
|
247 |
+
|
248 |
+
/**
|
249 |
+
* Define the columns that can be sorted
|
250 |
+
* @return array The IDs of the columns that can be sorted
|
251 |
+
*/
|
252 |
+
function get_sortable_columns() {
|
253 |
+
$sortable_columns = array(
|
254 |
+
'id' => array( 'id', true ),
|
255 |
+
'name' => array( 'name', false ),
|
256 |
+
);
|
257 |
+
return apply_filters( 'code_snippets/list_table/sortable_columns', $sortable_columns );
|
258 |
+
}
|
259 |
+
|
260 |
+
/**
|
261 |
+
* Define the columns that are hidden by default
|
262 |
+
* @param unknown $result
|
263 |
+
* @return unknown
|
264 |
+
*/
|
265 |
+
function get_default_hidden_columns( $result ) {
|
266 |
+
if ( ! $result ) {
|
267 |
+
return array( 'id' );
|
268 |
+
} else {
|
269 |
+
return $result;
|
270 |
+
}
|
271 |
+
}
|
272 |
+
|
273 |
+
/**
|
274 |
+
* Define the bulk actions to include in the drop-down menus
|
275 |
+
* @return array An array of menu items with the ID paired to the label
|
276 |
+
*/
|
277 |
+
function get_bulk_actions() {
|
278 |
+
$screen = get_current_screen();
|
279 |
+
$actions = array(
|
280 |
+
'activate-selected' => $screen->is_network ? __( 'Network Activate', 'code-snippets' ) : __( 'Activate', 'code-snippets' ),
|
281 |
+
'deactivate-selected' => $screen->is_network ? __( 'Network Deactivate', 'code-snippets' ) : __( 'Deactivate', 'code-snippets' ),
|
282 |
+
'export-selected' => __( 'Export', 'code-snippets' ),
|
283 |
+
'delete-selected' => __( 'Delete', 'code-snippets' ),
|
284 |
+
'export-php-selected' => __( 'Export to PHP', 'code-snippets' ),
|
285 |
+
);
|
286 |
+
return apply_filters( 'code_snippets/list_table/bulk_actions', $actions );
|
287 |
+
}
|
288 |
+
|
289 |
+
/**
|
290 |
+
* Retrieve the classes for the table
|
291 |
+
*
|
292 |
+
* We override this in order to add 'snippets' as a class
|
293 |
+
* for custom styling
|
294 |
+
*
|
295 |
+
* @return array The classes to include on the table element
|
296 |
+
*/
|
297 |
+
function get_table_classes() {
|
298 |
+
$classes = array( 'widefat', $this->_args['plural'] );
|
299 |
+
return apply_filters( 'code_snippets/list_table/table_classes', $classes );
|
300 |
+
}
|
301 |
+
|
302 |
+
/**
|
303 |
+
* Retrieve the 'views' of the table
|
304 |
+
*
|
305 |
+
* Example: active, inactive, recently active
|
306 |
+
*
|
307 |
+
* @return array A list of the view labels linked to the view
|
308 |
+
*/
|
309 |
+
function get_views() {
|
310 |
+
global $totals, $status;
|
311 |
+
|
312 |
+
$status_links = array();
|
313 |
+
foreach ( $totals as $type => $count ) {
|
314 |
+
|
315 |
+
if ( ! $count ) {
|
316 |
+
continue;
|
317 |
+
}
|
318 |
+
|
319 |
+
switch ( $type ) {
|
320 |
+
case 'all':
|
321 |
+
$text = _n( 'All <span class="count">(%s)</span>', 'All <span class="count">(%s)</span>', $count, 'code-snippets' );
|
322 |
+
break;
|
323 |
+
case 'active':
|
324 |
+
$text = _n( 'Active <span class="count">(%s)</span>', 'Active <span class="count">(%s)</span>', $count, 'code-snippets' );
|
325 |
+
break;
|
326 |
+
case 'recently_activated':
|
327 |
+
$text = _n( 'Recently Active <span class="count">(%s)</span>', 'Recently Active <span class="count">(%s)</span>', $count, 'code-snippets' );
|
328 |
+
break;
|
329 |
+
case 'inactive':
|
330 |
+
$text = _n( 'Inactive <span class="count">(%s)</span>', 'Inactive <span class="count">(%s)</span>', $count, 'code-snippets' );
|
331 |
+
break;
|
332 |
+
}
|
333 |
+
|
334 |
+
$status_links[$type] = sprintf( '<a href="%s"%s>%s</a>',
|
335 |
+
add_query_arg( 'status', $type ),
|
336 |
+
( $type === $status ) ? ' class="current"' : '',
|
337 |
+
sprintf( $text, number_format_i18n( $count ) )
|
338 |
+
);
|
339 |
+
|
340 |
+
}
|
341 |
+
|
342 |
+
return apply_filters( 'code_snippets/list_table/views', $status_links );
|
343 |
+
}
|
344 |
+
|
345 |
+
/**
|
346 |
+
* Gets the tags of the snippets currently being viewed in the table
|
347 |
+
* @since 2.0
|
348 |
+
*/
|
349 |
+
function get_current_tags() {
|
350 |
+
global $snippets, $status;
|
351 |
+
|
352 |
+
/* If we're not viewing a snippets table, get all used tags instead */
|
353 |
+
if ( ! isset( $snippets, $status ) ) {
|
354 |
+
return get_all_snippet_tags();
|
355 |
+
}
|
356 |
+
|
357 |
+
$tags = array();
|
358 |
+
|
359 |
+
/* Merge all tags into a single array */
|
360 |
+
foreach ( $snippets[ $status ] as $snippet ) {
|
361 |
+
$tags = array_merge( $snippet->tags, $tags );
|
362 |
+
}
|
363 |
+
|
364 |
+
/* Remove duplicate tags */
|
365 |
+
return array_values( array_unique( $tags, SORT_REGULAR ) );
|
366 |
+
}
|
367 |
+
|
368 |
+
/**
|
369 |
+
* Add filters and extra actions above and below the table
|
370 |
+
* @param string $which Are the actions displayed on the table top or bottom
|
371 |
+
*/
|
372 |
+
function extra_tablenav( $which ) {
|
373 |
+
global $status, $wpdb;
|
374 |
+
|
375 |
+
$screen = get_current_screen();
|
376 |
+
|
377 |
+
if ( 'top' === $which ) {
|
378 |
+
|
379 |
+
/* Tags dropdown filter */
|
380 |
+
$tags = $this->get_current_tags();
|
381 |
+
|
382 |
+
if ( count( $tags ) ) {
|
383 |
+
$query = isset( $_GET['tag'] ) ? $_GET['tag'] : '';
|
384 |
+
|
385 |
+
echo '<div class="alignleft actions">';
|
386 |
+
echo '<select name="tag">';
|
387 |
+
|
388 |
+
printf ( "<option %s value=''>%s</option>\n",
|
389 |
+
selected( $query, '', false ),
|
390 |
+
__( 'Show all tags', 'code-snippets' )
|
391 |
+
);
|
392 |
+
|
393 |
+
foreach ( $tags as $tag ) {
|
394 |
+
|
395 |
+
printf( "<option %s value='%s'>%s</option>\n",
|
396 |
+
selected( $query, $tag, false ),
|
397 |
+
esc_attr( $tag ),
|
398 |
+
$tag
|
399 |
+
);
|
400 |
+
}
|
401 |
+
|
402 |
+
echo '</select>';
|
403 |
+
|
404 |
+
submit_button( __( 'Filter', 'code-snippets' ), 'button', false, false );
|
405 |
+
echo '</div>';
|
406 |
+
}
|
407 |
+
}
|
408 |
+
|
409 |
+
echo '<div class="alignleft actions">';
|
410 |
+
|
411 |
+
if ( 'recently_activated' === $status )
|
412 |
+
submit_button( __( 'Clear List', 'code-snippets' ), 'secondary', 'clear-recent-list', false );
|
413 |
+
|
414 |
+
do_action( 'code_snippets/list_table/actions', $which );
|
415 |
+
|
416 |
+
echo '</div>';
|
417 |
+
}
|
418 |
+
|
419 |
+
/**
|
420 |
+
* Output form fields needed to preserve important
|
421 |
+
* query vars over form submissions
|
422 |
+
*
|
423 |
+
* @param string $context In what context are the fields being outputted?
|
424 |
+
*/
|
425 |
+
function required_form_fields( $context = 'main' ) {
|
426 |
+
|
427 |
+
$vars = apply_filters(
|
428 |
+
'code_snippets/list_table/required_form_fields',
|
429 |
+
array( 'page', 's', 'status', 'paged', 'tag' ),
|
430 |
+
$context
|
431 |
+
);
|
432 |
+
|
433 |
+
if ( 'search_box' === $context ) {
|
434 |
+
/* Remove the 's' var if we're doing this for the search box */
|
435 |
+
$vars = array_diff( $vars, array( 's' ) );
|
436 |
+
}
|
437 |
+
|
438 |
+
foreach ( $vars as $var ) {
|
439 |
+
if ( ! empty( $_REQUEST[ $var ] ) ) {
|
440 |
+
printf ( '<input type="hidden" name="%s" value="%s" />', $var, $_REQUEST[ $var ] );
|
441 |
+
print "\n";
|
442 |
+
}
|
443 |
+
}
|
444 |
+
|
445 |
+
do_action( 'code_snippets/list_table/print_required_form_fields', $context );
|
446 |
+
}
|
447 |
+
|
448 |
+
|
449 |
+
/**
|
450 |
+
* Clear the recently activated snippets list if we've clicked the button
|
451 |
+
* @return string The action to execute
|
452 |
+
*/
|
453 |
+
function current_action() {
|
454 |
+
if ( isset( $_POST['clear-recent-list'] ) ) {
|
455 |
+
$action = 'clear-recent-list';
|
456 |
+
} else {
|
457 |
+
$action = parent::current_action();
|
458 |
+
}
|
459 |
+
return apply_filters( 'code_snippets/list_table/current_action', $action );
|
460 |
+
}
|
461 |
+
|
462 |
+
/**
|
463 |
+
* Processes a bulk action
|
464 |
+
*
|
465 |
+
* @uses activate_snippet() To activate snippets
|
466 |
+
* @uses deactivate_snippet() To deactivate snippets
|
467 |
+
* @uses delete_snippet() To delete snippets
|
468 |
+
* @uses export_snippet() To export selected snippets
|
469 |
+
* @uses wp_redirect() To pass the results to the current page
|
470 |
+
* @uses add_query_arg() To append the results to the current URI
|
471 |
+
*/
|
472 |
+
function process_bulk_actions() {
|
473 |
+
$network = get_current_screen()->is_network;
|
474 |
+
|
475 |
+
if ( isset( $_GET['action'], $_GET['id'] ) ) :
|
476 |
+
|
477 |
+
$id = absint( $_GET['id'] );
|
478 |
+
$action = sanitize_key( $_GET['action'] );
|
479 |
+
$_SERVER['REQUEST_URI'] = remove_query_arg( array( 'action', 'id' ) );
|
480 |
+
|
481 |
+
if ( 'activate' === $action ) {
|
482 |
+
activate_snippet( $id, $network );
|
483 |
+
}
|
484 |
+
elseif ( 'deactivate' === $action ) {
|
485 |
+
deactivate_snippet( $id, $network );
|
486 |
+
}
|
487 |
+
elseif ( 'delete' === $action ) {
|
488 |
+
delete_snippet( $id, $network );
|
489 |
+
}
|
490 |
+
elseif ( 'export' === $action ) {
|
491 |
+
export_snippets( $id, $network );
|
492 |
+
}
|
493 |
+
elseif ( 'export-php' === $action ) {
|
494 |
+
export_snippets( $id, $network, 'php');
|
495 |
+
}
|
496 |
+
|
497 |
+
if ( ! in_array( $action, array( 'export', 'export-php' ) ) ) {
|
498 |
+
wp_redirect( apply_filters(
|
499 |
+
"code_snippets/{$action}_redirect",
|
500 |
+
add_query_arg( $action, true )
|
501 |
+
) );
|
502 |
+
}
|
503 |
+
|
504 |
+
endif;
|
505 |
+
|
506 |
+
if ( ! isset( $_POST['ids'] ) ) {
|
507 |
+
return;
|
508 |
+
}
|
509 |
+
|
510 |
+
$ids = $_POST['ids'];
|
511 |
+
|
512 |
+
$_SERVER['REQUEST_URI'] = remove_query_arg( array( 'activate', 'deactivate', 'delete', 'activate-multi', 'deactivate-multi', 'delete-multi' ) );
|
513 |
+
|
514 |
+
switch( $this->current_action() ) {
|
515 |
+
|
516 |
+
case 'activate-selected':
|
517 |
+
foreach ( $ids as $id ) {
|
518 |
+
activate_snippet( $id, $network );
|
519 |
+
}
|
520 |
+
wp_redirect( add_query_arg( 'activate-multi', true ) );
|
521 |
+
break;
|
522 |
+
|
523 |
+
case 'deactivate-selected':
|
524 |
+
foreach ( $ids as $id ) {
|
525 |
+
deactivate_snippet( $id, $network );
|
526 |
+
}
|
527 |
+
wp_redirect( add_query_arg( 'deactivate-multi', true ) );
|
528 |
+
break;
|
529 |
+
|
530 |
+
case 'export-selected':
|
531 |
+
export_snippets( $ids, $network );
|
532 |
+
break;
|
533 |
+
|
534 |
+
case 'export-php-selected':
|
535 |
+
export_snippets( $ids, $network, 'php');
|
536 |
+
break;
|
537 |
+
|
538 |
+
case 'delete-selected':
|
539 |
+
foreach( $ids as $id ) {
|
540 |
+
delete_snippet( $id, $network );
|
541 |
+
}
|
542 |
+
wp_redirect( add_query_arg( 'delete-multi', true ) );
|
543 |
+
break;
|
544 |
+
|
545 |
+
case 'clear-recent-list':
|
546 |
+
if ( $network ) {
|
547 |
+
update_site_option( 'recently_activated_snippets', array() );
|
548 |
+
} else {
|
549 |
+
update_option( 'recently_activated_snippets', array() );
|
550 |
+
}
|
551 |
+
break;
|
552 |
+
}
|
553 |
+
}
|
554 |
+
|
555 |
+
/**
|
556 |
+
* Message to display if no snippets are found
|
557 |
+
*/
|
558 |
+
function no_items() {
|
559 |
+
printf(
|
560 |
+
__( 'You do not appear to have any snippets available at this time. <a href="%s">Add New→</a>', 'code-snippets' ),
|
561 |
+
code_snippets_get_menu_url( 'add' )
|
562 |
+
);
|
563 |
+
}
|
564 |
+
|
565 |
+
/**
|
566 |
+
* Prepares the items to later display in the table.
|
567 |
+
* Should run before any headers are sent.
|
568 |
+
*/
|
569 |
+
function prepare_items() {
|
570 |
+
global $status, $snippets, $totals, $page, $orderby, $order, $s;
|
571 |
+
|
572 |
+
wp_reset_vars( array( 'orderby', 'order', 's' ) );
|
573 |
+
|
574 |
+
$screen = get_current_screen();
|
575 |
+
$user = get_current_user_id();
|
576 |
+
|
577 |
+
/* First, lets process the bulk actions */
|
578 |
+
$this->process_bulk_actions();
|
579 |
+
|
580 |
+
$snippets = array(
|
581 |
+
'all' => apply_filters( 'code_snippets/list_table/get_snippets', get_snippets( $screen->is_network ) ),
|
582 |
+
'active' => array(),
|
583 |
+
'inactive' => array(),
|
584 |
+
'recently_activated' => array(),
|
585 |
+
);
|
586 |
+
|
587 |
+
/* Filter snippets by tag */
|
588 |
+
if ( isset( $_POST['tag'] ) ) {
|
589 |
+
|
590 |
+
if ( ! empty( $_POST['tag'] ) ) {
|
591 |
+
wp_redirect( add_query_arg( 'tag', $_POST['tag'] ) );
|
592 |
+
}
|
593 |
+
else {
|
594 |
+
wp_redirect( remove_query_arg( 'tag' ) );
|
595 |
+
}
|
596 |
+
}
|
597 |
+
|
598 |
+
if ( ! empty( $_GET['tag'] ) ) {
|
599 |
+
$snippets['all'] = array_filter( $snippets['all'], array( $this, '_tags_filter_callback' ) );
|
600 |
+
}
|
601 |
+
|
602 |
+
/* Filter snippets based on search query */
|
603 |
+
if ( $s ) {
|
604 |
+
$snippets['all'] = array_filter( $snippets['all'], array( $this, '_search_callback' ) );
|
605 |
+
}
|
606 |
+
|
607 |
+
if ( $screen->is_network ) {
|
608 |
+
$recently_activated = get_site_option( 'recently_activated_snippets', array() );
|
609 |
+
} else {
|
610 |
+
$recently_activated = get_option( 'recently_activated_snippets', array() );
|
611 |
+
}
|
612 |
+
|
613 |
+
$one_week = 7*24*60*60;
|
614 |
+
foreach ( $recently_activated as $key => $time ) {
|
615 |
+
|
616 |
+
if ( $time + $one_week < time() ) {
|
617 |
+
unset( $recently_activated[$key] );
|
618 |
+
}
|
619 |
+
}
|
620 |
+
|
621 |
+
if ( $screen->is_network ) {
|
622 |
+
update_site_option( 'recently_activated_snippets', $recently_activated );
|
623 |
+
} else {
|
624 |
+
update_option( 'recently_activated_snippets', $recently_activated );
|
625 |
+
}
|
626 |
+
|
627 |
+
foreach ( (array) $snippets['all'] as $snippet ) {
|
628 |
+
/* Filter into individual sections */
|
629 |
+
if ( $snippet->active ) {
|
630 |
+
$snippets['active'][] = $snippet;
|
631 |
+
} else {
|
632 |
+
if ( isset( $recently_activated[ $snippet->id ] ) ) // Was the snippet recently activated?
|
633 |
+
$snippets['recently_activated'][] = $snippet;
|
634 |
+
$snippets['inactive'][] = $snippet;
|
635 |
+
}
|
636 |
+
}
|
637 |
+
|
638 |
+
$totals = array();
|
639 |
+
foreach ( $snippets as $type => $list ) {
|
640 |
+
$totals[ $type ] = count( $list );
|
641 |
+
}
|
642 |
+
|
643 |
+
if ( empty( $snippets[ $status ] ) ) {
|
644 |
+
$status = 'all';
|
645 |
+
}
|
646 |
+
|
647 |
+
$data = $snippets[ $status ];
|
648 |
+
|
649 |
+
/*
|
650 |
+
* First, lets decide how many records per page to show
|
651 |
+
* by getting the user's setting in the Screen Options
|
652 |
+
* panel.
|
653 |
+
*/
|
654 |
+
$sort_by = $screen->get_option( 'per_page', 'option' );
|
655 |
+
$screen_option = $screen->get_option( 'per_page', 'option' );
|
656 |
+
$per_page = get_user_meta( $user, $screen_option, true );
|
657 |
+
|
658 |
+
if ( empty ( $per_page ) || $per_page < 1 ) {
|
659 |
+
$per_page = $screen->get_option( 'per_page', 'default' );
|
660 |
+
}
|
661 |
+
|
662 |
+
$per_page = (int) $per_page;
|
663 |
+
|
664 |
+
$this->_column_headers = $this->get_column_info();
|
665 |
+
|
666 |
+
/**
|
667 |
+
* This checks for sorting input and sorts the data in our array accordingly.
|
668 |
+
*
|
669 |
+
* @ignore
|
670 |
+
*/
|
671 |
+
function usort_reorder( $a, $b ) {
|
672 |
+
|
673 |
+
/* If no sort, default to ID */
|
674 |
+
$orderby = (
|
675 |
+
! empty( $_REQUEST['orderby'] )
|
676 |
+
? $_REQUEST['orderby']
|
677 |
+
: apply_filters( 'code_snippets/list_table/default_orderby', 'id' )
|
678 |
+
);
|
679 |
+
|
680 |
+
/* If no order, default to ascending */
|
681 |
+
$order = (
|
682 |
+
! empty( $_REQUEST['order'] )
|
683 |
+
? $_REQUEST['order']
|
684 |
+
: apply_filters( 'code_snippets/list_table/default_order', 'asc' )
|
685 |
+
);
|
686 |
+
|
687 |
+
/* Determine sort order */
|
688 |
+
if ( 'id' === $orderby ) {
|
689 |
+
$result = $a->$orderby - $b->$orderby; // get the result for numerical data
|
690 |
+
} else {
|
691 |
+
$result = strcmp( $a->$orderby, $b->$orderby ); // get the result for string data
|
692 |
+
}
|
693 |
+
|
694 |
+
/* Send final sort direction to usort */
|
695 |
+
return ( 'asc' === $order ) ? $result : -$result;
|
696 |
+
}
|
697 |
+
|
698 |
+
usort( $data, 'usort_reorder' );
|
699 |
+
|
700 |
+
/*
|
701 |
+
* Let's figure out what page the user is currently
|
702 |
+
* looking at.
|
703 |
+
*/
|
704 |
+
$current_page = $this->get_pagenum();
|
705 |
+
|
706 |
+
/*
|
707 |
+
* Let's check how many items are in our data array.
|
708 |
+
*/
|
709 |
+
$total_items = count( $data );
|
710 |
+
|
711 |
+
/*
|
712 |
+
* The WP_List_Table class does not handle pagination for us, so we need
|
713 |
+
* to ensure that the data is trimmed to only the current page.
|
714 |
+
*/
|
715 |
+
$data = array_slice( $data, ( ( $current_page - 1 ) * $per_page ), $per_page );
|
716 |
+
|
717 |
+
/*
|
718 |
+
* Now we can add our *sorted* data to the items property, where
|
719 |
+
* it can be used by the rest of the class.
|
720 |
+
*/
|
721 |
+
$this->items = $data;
|
722 |
+
|
723 |
+
/*
|
724 |
+
* We also have to register our pagination options & calculations.
|
725 |
+
*/
|
726 |
+
$this->set_pagination_args( array(
|
727 |
+
'total_items' => $total_items, // WE have to calculate the total number of items
|
728 |
+
'per_page' => $per_page, // WE have to determine how many items to show on a page
|
729 |
+
'total_pages' => ceil($total_items/$per_page) // WE have to calculate the total number of pages
|
730 |
+
) );
|
731 |
+
}
|
732 |
+
|
733 |
+
/**
|
734 |
+
* Used internally
|
735 |
+
* @ignore
|
736 |
+
*/
|
737 |
+
function _search_callback( $snippet ) {
|
738 |
+
static $term;
|
739 |
+
if ( is_null( $term ) ) {
|
740 |
+
$term = stripslashes( $_REQUEST['s'] );
|
741 |
+
}
|
742 |
+
|
743 |
+
foreach ( $snippet as $value ) {
|
744 |
+
|
745 |
+
if ( is_string( $value ) ) {
|
746 |
+
if ( false !== stripos( $value, $term ) ) {
|
747 |
+
return true;
|
748 |
+
}
|
749 |
+
}
|
750 |
+
elseif ( is_array( $value ) ) {
|
751 |
+
if ( false !== in_array( $term, $value ) ) {
|
752 |
+
return true;
|
753 |
+
}
|
754 |
+
}
|
755 |
+
}
|
756 |
+
|
757 |
+
return false;
|
758 |
+
}
|
759 |
+
|
760 |
+
|
761 |
+
/**
|
762 |
+
* Used internally
|
763 |
+
* @ignore
|
764 |
+
*/
|
765 |
+
function _tags_filter_callback( $snippet ) {
|
766 |
+
$tags = explode( ',', $_GET['tag'] );
|
767 |
+
|
768 |
+
foreach ( $tags as $tag ) {
|
769 |
+
if ( in_array( $tag, $snippet->tags ) ) {
|
770 |
+
return true;
|
771 |
+
}
|
772 |
+
}
|
773 |
+
}
|
774 |
+
|
775 |
+
/**
|
776 |
+
* Display a notice showing the current search terms
|
777 |
+
*
|
778 |
+
* @since 1.7
|
779 |
+
* @access public
|
780 |
+
*/
|
781 |
+
public function search_notice() {
|
782 |
+
if ( ! empty( $_REQUEST['s'] ) || ! empty( $_GET['tag'] ) ) {
|
783 |
+
|
784 |
+
echo '<span class="subtitle">' . __( 'Search results', 'code-snippets' );
|
785 |
+
|
786 |
+
if ( ! empty ( $_REQUEST['s'] ) ) {
|
787 |
+
echo sprintf ( __( ' for “%s”', 'code-snippets' ), esc_html( $_REQUEST['s'] ) );
|
788 |
+
}
|
789 |
+
|
790 |
+
if ( ! empty( $_GET['tag'] ) ) {
|
791 |
+
echo sprintf ( __(' in tag “%s”', 'code-snippets' ), $_GET['tag'] );
|
792 |
+
}
|
793 |
+
|
794 |
+
echo '</span>';
|
795 |
+
|
796 |
+
printf (
|
797 |
+
' <a class="button clear-filters" href="%s">' . __( 'Clear Filters', 'code-snippets' ) . '</a>',
|
798 |
+
remove_query_arg( array( 's', 'tag' ) )
|
799 |
+
);
|
800 |
+
}
|
801 |
+
}
|
802 |
+
|
803 |
+
/**
|
804 |
+
* Outputs content for a single row of the table
|
805 |
+
* @param object $snippet The snippet being used for the current row
|
806 |
+
*/
|
807 |
+
function single_row( $snippet ) {
|
808 |
+
static $row_class = '';
|
809 |
+
$row_class = ( $snippet->active ? 'active' : 'inactive' );
|
810 |
+
printf ( '<tr class="%s">', $row_class );
|
811 |
+
$this->single_row_columns( $snippet );
|
812 |
+
echo '</tr>';
|
813 |
+
}
|
814 |
+
|
815 |
+
} // end of class
|
@@ -0,0 +1,106 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* Functions to handle the manage snippets menu
|
5 |
+
*
|
6 |
+
* @package Code_Snippets
|
7 |
+
* @subpackage Manage
|
8 |
+
*/
|
9 |
+
|
10 |
+
/**
|
11 |
+
* Register the top-level 'Snippets' menu and associated 'Manage' subpage
|
12 |
+
*
|
13 |
+
* @since 1.0
|
14 |
+
* @access private
|
15 |
+
*
|
16 |
+
* @uses add_menu_page() To register a top-level menu
|
17 |
+
* @uses add_submenu_page() To register a sub-menu
|
18 |
+
*/
|
19 |
+
function code_snippets_add_manage_menu() {
|
20 |
+
|
21 |
+
$hook = add_menu_page(
|
22 |
+
__( 'Snippets', 'code-snippets' ),
|
23 |
+
__( 'Snippets', 'code-snippets' ),
|
24 |
+
get_snippets_cap(),
|
25 |
+
code_snippets_get_menu_slug(),
|
26 |
+
'code_snippets_render_manage_menu',
|
27 |
+
'div', // icon is added through CSS
|
28 |
+
is_network_admin() ? 21 : 67
|
29 |
+
);
|
30 |
+
|
31 |
+
add_submenu_page(
|
32 |
+
code_snippets_get_menu_slug(),
|
33 |
+
__( 'Snippets', 'code-snippets' ),
|
34 |
+
__( 'Manage', 'code-snippets' ),
|
35 |
+
get_snippets_cap(),
|
36 |
+
code_snippets_get_menu_slug(),
|
37 |
+
'code_snippets_render_manage_menu'
|
38 |
+
);
|
39 |
+
|
40 |
+
add_action( 'load-' . $hook, 'code_snippets_load_manage_menu' );
|
41 |
+
}
|
42 |
+
|
43 |
+
add_action( 'admin_menu', 'code_snippets_add_manage_menu', 5 );
|
44 |
+
add_action( 'network_admin_menu', 'code_snippets_add_manage_menu', 5 );
|
45 |
+
|
46 |
+
/**
|
47 |
+
* Displays the manage snippets menu
|
48 |
+
*
|
49 |
+
* @since 2.0
|
50 |
+
*/
|
51 |
+
function code_snippets_render_manage_menu() {
|
52 |
+
require plugin_dir_path( __FILE__ ) . 'admin-messages.php';
|
53 |
+
require plugin_dir_path( __FILE__ ) . 'admin.php';
|
54 |
+
}
|
55 |
+
|
56 |
+
/**
|
57 |
+
* Initializes the list table class and loads the help tabs
|
58 |
+
* for the Manage Snippets page
|
59 |
+
*
|
60 |
+
* @since 1.0
|
61 |
+
* @access private
|
62 |
+
*/
|
63 |
+
function code_snippets_load_manage_menu() {
|
64 |
+
|
65 |
+
/* Make sure the user has permission to be here */
|
66 |
+
if ( ! current_user_can( get_snippets_cap() ) ) {
|
67 |
+
wp_die( __( 'You are not authorized to access this page.', 'code-snippets' ) );
|
68 |
+
}
|
69 |
+
|
70 |
+
/* Load stylesheet for this page */
|
71 |
+
add_action( 'admin_enqueue_scripts', 'code_snippets_manage_menu_assets' );
|
72 |
+
|
73 |
+
/* Create the snippet tables if they don't exist */
|
74 |
+
create_code_snippets_tables( true, true );
|
75 |
+
|
76 |
+
/* Load the screen help tabs */
|
77 |
+
require plugin_dir_path( __FILE__ ) . 'admin-help.php';
|
78 |
+
|
79 |
+
/* Initialize the snippet table class */
|
80 |
+
require_once plugin_dir_path( __FILE__ ) . 'class-list-table.php';
|
81 |
+
global $code_snippets_list_table;
|
82 |
+
$code_snippets_list_table = new Code_Snippets_List_Table();
|
83 |
+
$code_snippets_list_table->prepare_items();
|
84 |
+
}
|
85 |
+
|
86 |
+
/**
|
87 |
+
* Enqueue the manage menu stylesheet
|
88 |
+
*
|
89 |
+
* @since 2.0
|
90 |
+
* @uses wp_enqueue_style() To add the stylesheet to the queue
|
91 |
+
* @param string $hook The current page hook, to be compared with the manage snippets page hook
|
92 |
+
*/
|
93 |
+
function code_snippets_manage_menu_assets( $hook ) {
|
94 |
+
|
95 |
+
/* Only load the stylesheet on the manage snippets page */
|
96 |
+
if ( $hook !== code_snippets_get_menu_hook() ) {
|
97 |
+
return;
|
98 |
+
}
|
99 |
+
|
100 |
+
wp_enqueue_style(
|
101 |
+
'code-snippets-manage',
|
102 |
+
plugins_url( 'css/min/manage-snippets.css', CODE_SNIPPETS_FILE ),
|
103 |
+
false,
|
104 |
+
CODE_SNIPPETS_VERSION
|
105 |
+
);
|
106 |
+
}
|
@@ -0,0 +1,54 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* This file handles the settings admin menu
|
5 |
+
* @package Code_Snippets
|
6 |
+
*/
|
7 |
+
|
8 |
+
/**
|
9 |
+
* Register the setting sub-menu
|
10 |
+
*
|
11 |
+
* @since 2.0
|
12 |
+
* @access private
|
13 |
+
*
|
14 |
+
* @uses add_submenu_page() To register a sub-menu
|
15 |
+
*/
|
16 |
+
function code_snippets_add_settings_menu() {
|
17 |
+
|
18 |
+
add_submenu_page(
|
19 |
+
code_snippets_get_menu_slug(),
|
20 |
+
__( 'Snippets Settings', 'code-snippets' ),
|
21 |
+
__( 'Settings', 'code-snippets' ),
|
22 |
+
get_snippets_cap(),
|
23 |
+
code_snippets_get_menu_slug( 'settings' ),
|
24 |
+
'code_snippets_render_settings_menu'
|
25 |
+
);
|
26 |
+
}
|
27 |
+
|
28 |
+
add_action( 'admin_menu', 'code_snippets_add_settings_menu' );
|
29 |
+
|
30 |
+
/**
|
31 |
+
* Displays the settings menu
|
32 |
+
*
|
33 |
+
* @since 2.0
|
34 |
+
*/
|
35 |
+
function code_snippets_render_settings_menu() {
|
36 |
+
?>
|
37 |
+
<div class="wrap">
|
38 |
+
|
39 |
+
<?php screen_icon(); ?>
|
40 |
+
<h2><?php esc_html_e( 'Settings', 'code-snippets' ); ?></h2>
|
41 |
+
|
42 |
+
<?php settings_errors( 'code-snippets-settings-notices' ); ?>
|
43 |
+
|
44 |
+
<form action="options.php" method="post">
|
45 |
+
<?php settings_fields( 'code-snippets' ); ?>
|
46 |
+
<table class="form-table">
|
47 |
+
<?php do_settings_sections( 'code-snippets' ); ?>
|
48 |
+
</table>
|
49 |
+
<?php submit_button(); ?>
|
50 |
+
</form>
|
51 |
+
|
52 |
+
</div>
|
53 |
+
<?php
|
54 |
+
}
|
@@ -0,0 +1,156 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
function code_snippets_editor_settings_preview_assets( $hook ) {
|
4 |
+
|
5 |
+
/* Only load on the settings page */
|
6 |
+
if ( code_snippets_get_menu_hook( 'settings' ) !== $hook ) {
|
7 |
+
return;
|
8 |
+
}
|
9 |
+
|
10 |
+
/* Enqueue scripts for the editor preview */
|
11 |
+
code_snippets_enqueue_codemirror();
|
12 |
+
|
13 |
+
/* Enqueue ALL themes */
|
14 |
+
$themes_dir = plugin_dir_path( CODE_SNIPPETS_FILE ) . 'vendor/codemirror/theme/';
|
15 |
+
$themes = glob( $themes_dir . '*.css' );
|
16 |
+
|
17 |
+
foreach ( $themes as $theme ) {
|
18 |
+
$theme = str_replace( $themes_dir, '', $theme );
|
19 |
+
$theme = str_replace( '.css', '', $theme );
|
20 |
+
|
21 |
+
wp_enqueue_style(
|
22 |
+
'code-snippets-codemirror-theme-' . $theme,
|
23 |
+
plugins_url( "vendor/codemirror/theme/$theme.css", CODE_SNIPPETS_FILE ),
|
24 |
+
array( 'code-snippets-codemirror' )
|
25 |
+
);
|
26 |
+
}
|
27 |
+
|
28 |
+
/* Enqueue jQuery */
|
29 |
+
wp_enqueue_script( 'jquery' );
|
30 |
+
}
|
31 |
+
|
32 |
+
add_action( 'admin_enqueue_scripts', 'code_snippets_editor_settings_preview_assets' );
|
33 |
+
|
34 |
+
/**
|
35 |
+
* Render a theme select field
|
36 |
+
*/
|
37 |
+
function code_snippets_codemirror_theme_select_field( $atts ) {
|
38 |
+
|
39 |
+
$saved_value = code_snippets_get_setting( $atts['section'], $atts['id'] );
|
40 |
+
|
41 |
+
echo '<select name="code_snippets_settings[editor][theme]">';
|
42 |
+
|
43 |
+
echo '<option value="default"' . selected( 'default', $saved_value, false ) . '>default</option>';
|
44 |
+
|
45 |
+
/* Fetch all theme CSS files */
|
46 |
+
$themes_dir = plugin_dir_path( CODE_SNIPPETS_FILE ) . 'vendor/codemirror/theme/';
|
47 |
+
$themes = glob( $themes_dir . '*.css' );
|
48 |
+
|
49 |
+
/* Print dropdown entry for each theme */
|
50 |
+
foreach ( $themes as $theme ) {
|
51 |
+
|
52 |
+
/* Extract theme name from path */
|
53 |
+
$theme = str_replace( $themes_dir, '', $theme );
|
54 |
+
$theme = str_replace( '.css', '', $theme );
|
55 |
+
|
56 |
+
/* Skip mobile themes */
|
57 |
+
if ( 'ambiance-mobile' === $theme ) {
|
58 |
+
continue;
|
59 |
+
}
|
60 |
+
|
61 |
+
printf (
|
62 |
+
'<option value="%1$s"%2$s>%1$s</option>',
|
63 |
+
$theme,
|
64 |
+
selected( $theme, $saved_value, false )
|
65 |
+
);
|
66 |
+
}
|
67 |
+
|
68 |
+
echo '</select>';
|
69 |
+
}
|
70 |
+
|
71 |
+
function code_snippets_settings_editor_preview() {
|
72 |
+
|
73 |
+
$example_content = "
|
74 |
+
function example_custom_admin_footer_text( \$text ) {
|
75 |
+
return 'Thank you for visiting <a href=\"' . get_home_url() . '\">' . get_bloginfo( 'name' ) . '</a>.';
|
76 |
+
}
|
77 |
+
|
78 |
+
add_filter( 'admin_footer_text', 'example_custom_admin_footer_text' );";
|
79 |
+
|
80 |
+
$atts = array(
|
81 |
+
'mode' => 'text/x-php',
|
82 |
+
'value' => $example_content
|
83 |
+
);
|
84 |
+
|
85 |
+
?>
|
86 |
+
|
87 |
+
<div style="max-width: 800px" id="code_snippets_editor_preview"></div>
|
88 |
+
|
89 |
+
<script>
|
90 |
+
(function( $ ) {
|
91 |
+
'use strict';
|
92 |
+
|
93 |
+
$(function() {
|
94 |
+
|
95 |
+
// Load CodeMirror
|
96 |
+
var atts = <?php echo code_snippets_get_editor_atts( $atts, true ); ?>;
|
97 |
+
var editor = CodeMirror(document.getElementById('code_snippets_editor_preview'), atts);
|
98 |
+
|
99 |
+
// Dynamically change editor settings
|
100 |
+
|
101 |
+
<?php
|
102 |
+
|
103 |
+
$fields = code_snippets_get_settings_fields();
|
104 |
+
$fields = $fields['editor'];
|
105 |
+
|
106 |
+
$types = wp_list_pluck( $fields, 'type', 'id' );
|
107 |
+
$codemirror_atts = wp_list_pluck( $fields, 'codemirror', 'id' );
|
108 |
+
|
109 |
+
foreach ( $codemirror_atts as $setting => $att_name ) {
|
110 |
+
|
111 |
+
switch ( $types[ $setting ] ) {
|
112 |
+
|
113 |
+
case 'codemirror_theme_select':
|
114 |
+
?>
|
115 |
+
|
116 |
+
$( 'select[name="code_snippets_settings[editor][<?php echo $setting; ?>]"]' ).change( function () {
|
117 |
+
editor.setOption( '<?php echo $att_name; ?>', $(this).val() );
|
118 |
+
} );
|
119 |
+
|
120 |
+
<?php
|
121 |
+
break;
|
122 |
+
|
123 |
+
case 'checkbox':
|
124 |
+
?>
|
125 |
+
|
126 |
+
$( 'input[name="code_snippets_settings[editor][<?php echo $setting; ?>]"]' ).change( function () {
|
127 |
+
editor.setOption( '<?php echo $att_name; ?>', $(this).is(':checked') );
|
128 |
+
} );
|
129 |
+
|
130 |
+
<?php
|
131 |
+
break;
|
132 |
+
|
133 |
+
|
134 |
+
case 'number':
|
135 |
+
?>
|
136 |
+
|
137 |
+
$( 'input[name="code_snippets_settings[editor][<?php echo $setting; ?>]"]' ).change( function () {
|
138 |
+
editor.setOption( '<?php echo $att_name; ?>', $(this).val() );
|
139 |
+
} );
|
140 |
+
|
141 |
+
<?php
|
142 |
+
break;
|
143 |
+
|
144 |
+
}
|
145 |
+
|
146 |
+
}
|
147 |
+
|
148 |
+
?>
|
149 |
+
|
150 |
+
});
|
151 |
+
|
152 |
+
}(jQuery));
|
153 |
+
</script>
|
154 |
+
|
155 |
+
<?php
|
156 |
+
}
|
@@ -0,0 +1,41 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* This file handles outputting the settings fields
|
5 |
+
* @package Code_Snippets
|
6 |
+
*/
|
7 |
+
|
8 |
+
/**
|
9 |
+
* Render a checkbox field for a setting
|
10 |
+
* @param array $atts The setting field's attributes
|
11 |
+
*/
|
12 |
+
function code_snippets_checkbox_field( $atts ) {
|
13 |
+
$saved_value = code_snippets_get_setting( $atts['section'], $atts['id'] );
|
14 |
+
$input_name = sprintf( 'code_snippets_settings[%s][%s]', $atts['section'], $atts['id'] );
|
15 |
+
|
16 |
+
$output = sprintf (
|
17 |
+
'<input type="checkbox" name="%s"%s>',
|
18 |
+
$input_name,
|
19 |
+
checked( $saved_value, true, false )
|
20 |
+
);
|
21 |
+
|
22 |
+
if ( isset( $atts['label'] ) ) {
|
23 |
+
printf ( '<label for="%s">%s %s</label>', $input_name, $output, $atts['label'] );
|
24 |
+
} else {
|
25 |
+
echo $output;
|
26 |
+
}
|
27 |
+
}
|
28 |
+
|
29 |
+
/**
|
30 |
+
* Render a number select field for an editor setting
|
31 |
+
* @param array $atts The setting field's attributes
|
32 |
+
*/
|
33 |
+
function code_snippets_number_field( $atts ) {
|
34 |
+
|
35 |
+
printf (
|
36 |
+
'<input type="number" name="code_snippets_settings[%s][%s]" value="%s">',
|
37 |
+
$atts['section'],
|
38 |
+
$atts['id'],
|
39 |
+
code_snippets_get_setting( $atts['section'], $atts['id'] )
|
40 |
+
);
|
41 |
+
}
|
@@ -0,0 +1,243 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* This file registers the settings
|
5 |
+
* @package Code_Snippets
|
6 |
+
*/
|
7 |
+
|
8 |
+
/**
|
9 |
+
* Retrieve the default setting values
|
10 |
+
* @return array
|
11 |
+
*/
|
12 |
+
function code_snippets_get_default_settings() {
|
13 |
+
$fields = code_snippets_get_settings_fields();
|
14 |
+
$defaults = array();
|
15 |
+
|
16 |
+
foreach ( $fields as $section_id => $section_fields ) {
|
17 |
+
$defaults[ $section_id ] = wp_list_pluck( $section_fields, 'default', 'id' );
|
18 |
+
}
|
19 |
+
|
20 |
+
return $defaults;
|
21 |
+
}
|
22 |
+
|
23 |
+
/*
|
24 |
+
* Retrieve the setting values from the database.
|
25 |
+
* If a setting does not exist in the database, the default value will be returned.
|
26 |
+
* @return array
|
27 |
+
*/
|
28 |
+
function code_snippets_get_settings() {
|
29 |
+
$saved = get_option( 'code_snippets_settings', array() );
|
30 |
+
$default = code_snippets_get_default_settings();
|
31 |
+
return wp_parse_args( $saved, $default );
|
32 |
+
}
|
33 |
+
|
34 |
+
/**
|
35 |
+
* Retrieve an individual setting field value
|
36 |
+
* @param string $section The ID of the section the setting belongs to
|
37 |
+
* @param string $field The ID of the setting field
|
38 |
+
* @return array
|
39 |
+
*/
|
40 |
+
function code_snippets_get_setting( $section, $field ) {
|
41 |
+
$settings = code_snippets_get_settings();
|
42 |
+
return $settings[ $section ][ $field ];
|
43 |
+
}
|
44 |
+
|
45 |
+
/**
|
46 |
+
* Retrieve the settings sections
|
47 |
+
* @return array
|
48 |
+
*/
|
49 |
+
function code_snippets_get_settings_sections() {
|
50 |
+
$sections = array(
|
51 |
+
'general' => __( 'General', 'code-snippets' ),
|
52 |
+
'editor' => __( 'Editor', 'code-snippets' ),
|
53 |
+
);
|
54 |
+
|
55 |
+
return apply_filters( 'code_snippets_settings_sections', $sections );
|
56 |
+
}
|
57 |
+
|
58 |
+
/**
|
59 |
+
* Retrieve the settings fields
|
60 |
+
* @return array
|
61 |
+
*/
|
62 |
+
function code_snippets_get_settings_fields() {
|
63 |
+
$settings = array();
|
64 |
+
|
65 |
+
$settings['general'] = array(
|
66 |
+
array(
|
67 |
+
'id' => 'activate_by_default',
|
68 |
+
'name' =>__( 'Activate by Default', 'code-snippets' ),
|
69 |
+
'type' => 'checkbox',
|
70 |
+
'label' => __( "Make the 'Save and Activate' button the default action when saving a snippet.", 'code-snippets' ),
|
71 |
+
'default' => false,
|
72 |
+
),
|
73 |
+
);
|
74 |
+
|
75 |
+
/* Editor settings section */
|
76 |
+
|
77 |
+
$settings['editor'] = array(
|
78 |
+
array(
|
79 |
+
'id' => 'theme',
|
80 |
+
'name' => __( 'Theme', 'code-snippets' ),
|
81 |
+
'type' => 'codemirror_theme_select',
|
82 |
+
'default' => 'default',
|
83 |
+
'codemirror' => 'theme',
|
84 |
+
),
|
85 |
+
|
86 |
+
array(
|
87 |
+
'id' => 'indent_with_tabs',
|
88 |
+
'name' => __( 'Indent With Tabs', 'code-snippets' ),
|
89 |
+
'type' => 'checkbox',
|
90 |
+
'label' => __( 'Use hard tabs (not spaces) for indentation.', 'code-snippets' ),
|
91 |
+
'default' => true,
|
92 |
+
'codemirror' => 'indentWithTabs',
|
93 |
+
),
|
94 |
+
|
95 |
+
array(
|
96 |
+
'id' => 'tab_size',
|
97 |
+
'name' => __( 'Tab Size', 'code-snippets' ),
|
98 |
+
'type' => 'number',
|
99 |
+
'label' => __( 'The width of a tab character.', 'code-snippets' ),
|
100 |
+
'default' => 4,
|
101 |
+
'codemirror' => 'tabSize',
|
102 |
+
),
|
103 |
+
|
104 |
+
array(
|
105 |
+
'id' => 'indent_unit',
|
106 |
+
'name' => __( 'Indent Unit', 'code-snippets' ),
|
107 |
+
'type' => 'number',
|
108 |
+
'label' => __( 'How many spaces a block should be indented.', 'code-snippets' ),
|
109 |
+
'default' => 2,
|
110 |
+
'codemirror' => 'indentUnit',
|
111 |
+
),
|
112 |
+
|
113 |
+
array(
|
114 |
+
'id' => 'wrap_lines',
|
115 |
+
'name' => __( 'Wrap Lines', 'code-snippets' ),
|
116 |
+
'type' => 'checkbox',
|
117 |
+
'label' => __( 'Whether the editor should scroll or wrap for long lines.', 'code-snippets' ),
|
118 |
+
'default' => true,
|
119 |
+
'codemirror' => 'lineWrapping',
|
120 |
+
),
|
121 |
+
|
122 |
+
array(
|
123 |
+
'id' => 'line_numbers',
|
124 |
+
'name' => __( 'Line Numbers', 'code-snippets' ),
|
125 |
+
'type' => 'checkbox',
|
126 |
+
'label' => __( 'Show line numbers to the left of the editor.', 'code-snippets' ),
|
127 |
+
'default' => true,
|
128 |
+
'codemirror' => 'lineNumbers',
|
129 |
+
),
|
130 |
+
|
131 |
+
array(
|
132 |
+
'id' => 'auto_close_brackets',
|
133 |
+
'name' => __( 'Auto Close Brackets', 'code-snippets' ),
|
134 |
+
'type' => 'checkbox',
|
135 |
+
'label' => __( 'Auto-close brackets and quotes when typed.', 'code-snippets' ),
|
136 |
+
'default' => true,
|
137 |
+
'codemirror' => 'autoCloseBrackets',
|
138 |
+
),
|
139 |
+
|
140 |
+
array(
|
141 |
+
'id' => 'highlight_selection_matches',
|
142 |
+
'name' => __( 'Highlight Selection Matches', 'code-snippets' ),
|
143 |
+
'label' => __( 'Highlight all instances of a currently selected word.', 'code-snippets' ),
|
144 |
+
'type' => 'checkbox',
|
145 |
+
'default' => true,
|
146 |
+
'codemirror' => 'highlightSelectionMatches',
|
147 |
+
),
|
148 |
+
);
|
149 |
+
|
150 |
+
return apply_filters( 'code_snippets_settings_fields', $settings );
|
151 |
+
}
|
152 |
+
|
153 |
+
/**
|
154 |
+
* Register settings sections, fields, etc
|
155 |
+
*/
|
156 |
+
function code_snippets_register_settings() {
|
157 |
+
|
158 |
+
/* Register the setting */
|
159 |
+
register_setting( 'code-snippets', 'code_snippets_settings', 'code_snippets_settings_validate' );
|
160 |
+
|
161 |
+
/* Register settings sections */
|
162 |
+
foreach ( code_snippets_get_settings_sections() as $section_id => $section_name ) {
|
163 |
+
add_settings_section(
|
164 |
+
'code-snippets-' . $section_id,
|
165 |
+
$section_name,
|
166 |
+
'__return_empty_string',
|
167 |
+
'code-snippets'
|
168 |
+
);
|
169 |
+
}
|
170 |
+
|
171 |
+
/* Register settings fields */
|
172 |
+
foreach ( code_snippets_get_settings_fields() as $section_id => $fields ) {
|
173 |
+
|
174 |
+
foreach ( $fields as $field ) {
|
175 |
+
add_settings_field(
|
176 |
+
'code_snippets_' . $field['id'],
|
177 |
+
$field['name'],
|
178 |
+
"code_snippets_{$field['type']}_field",
|
179 |
+
'code-snippets',
|
180 |
+
'code-snippets-' . $section_id,
|
181 |
+
array_merge( $field, array( 'section' => $section_id ) )
|
182 |
+
);
|
183 |
+
}
|
184 |
+
|
185 |
+
}
|
186 |
+
|
187 |
+
/* Add editor preview as a field */
|
188 |
+
add_settings_field(
|
189 |
+
'code_snippets_' . $field['id'],
|
190 |
+
__( 'Editor Preview', 'code-snippets' ),
|
191 |
+
'code_snippets_settings_editor_preview',
|
192 |
+
'code-snippets',
|
193 |
+
'code-snippets-editor'
|
194 |
+
);
|
195 |
+
}
|
196 |
+
|
197 |
+
add_action( 'admin_init', 'code_snippets_register_settings' );
|
198 |
+
|
199 |
+
/**
|
200 |
+
* Validate the settings
|
201 |
+
* @param array $input
|
202 |
+
* @return array
|
203 |
+
*/
|
204 |
+
function code_snippets_settings_validate( array $input ) {
|
205 |
+
$settings = code_snippets_get_settings();
|
206 |
+
$settings_fields = code_snippets_get_settings_fields();
|
207 |
+
|
208 |
+
// Don't directly loop through $input as it does not include as deselected checkboxes
|
209 |
+
foreach ( $settings_fields as $section_id => $fields ) {
|
210 |
+
|
211 |
+
// Loop through fields
|
212 |
+
foreach ( $fields as $field ) {
|
213 |
+
$field_id = $field['id'];
|
214 |
+
|
215 |
+
// Checkbox field
|
216 |
+
if ( 'checkbox' === $field['type'] ) {
|
217 |
+
|
218 |
+
$settings[ $section_id ][ $field_id ] = (
|
219 |
+
isset( $input[ $section_id ][ $field_id ] ) &&
|
220 |
+
'on' === $input[ $section_id ][ $field_id ]
|
221 |
+
);
|
222 |
+
|
223 |
+
// Number field
|
224 |
+
} elseif ( 'number' == $field['type'] ) {
|
225 |
+
$settings[ $section_id ][ $field_id ] = absint( $input[ $section_id ][ $field_id ] );
|
226 |
+
|
227 |
+
// Other fields
|
228 |
+
} else {
|
229 |
+
$settings[ $section_id ][ $field_id ] = $input[ $section_id ][ $field_id ];
|
230 |
+
}
|
231 |
+
}
|
232 |
+
}
|
233 |
+
|
234 |
+
/* Add an updated message */
|
235 |
+
add_settings_error(
|
236 |
+
'code-snippets-settings-notices',
|
237 |
+
'settings-saved',
|
238 |
+
__( 'Settings saved.', 'code-snippets' ),
|
239 |
+
'updated'
|
240 |
+
);
|
241 |
+
|
242 |
+
return $settings;
|
243 |
+
}
|
@@ -0,0 +1,493 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* Functions to preform snippet operations
|
5 |
+
*
|
6 |
+
* @package Code_Snippets
|
7 |
+
*/
|
8 |
+
|
9 |
+
/**
|
10 |
+
* Converts an array of snippet data into a snippet object
|
11 |
+
*
|
12 |
+
* @since 2.0
|
13 |
+
* @param mixed $data The snippet data to convert
|
14 |
+
* @return object The resulting snippet object
|
15 |
+
*/
|
16 |
+
function build_snippet_object( $data = null ) {
|
17 |
+
|
18 |
+
$snippet = new stdClass;
|
19 |
+
|
20 |
+
/* Define an empty snippet object with default values */
|
21 |
+
$snippet->id = 0;
|
22 |
+
$snippet->name = '';
|
23 |
+
$snippet->description = '';
|
24 |
+
$snippet->code = '';
|
25 |
+
$snippet->tags = array();
|
26 |
+
$snippet->active = 0;
|
27 |
+
$snippet = apply_filters( 'code_snippets/build_default_snippet', $snippet );
|
28 |
+
|
29 |
+
if ( ! isset( $data ) ) {
|
30 |
+
return $snippet;
|
31 |
+
}
|
32 |
+
elseif ( is_object( $data ) ) {
|
33 |
+
|
34 |
+
/* If we already have a snippet object, merge it with the default */
|
35 |
+
return (object) array_merge( (array) $snippet, (array) $data );
|
36 |
+
}
|
37 |
+
elseif ( is_array( $data ) ) {
|
38 |
+
|
39 |
+
foreach ( $data as $field => $value ) {
|
40 |
+
|
41 |
+
/* Remove 'snippet_' prefix */
|
42 |
+
if ( 'snippet_' === substr( $field, 0, 8 ) ) {
|
43 |
+
$field = substr( $field, 8 );
|
44 |
+
}
|
45 |
+
|
46 |
+
/* Check the field is whitelisted */
|
47 |
+
if ( ! isset( $snippet->$field ) ) {
|
48 |
+
continue;
|
49 |
+
}
|
50 |
+
|
51 |
+
/* Update the field */
|
52 |
+
$snippet->$field = $value;
|
53 |
+
}
|
54 |
+
|
55 |
+
return apply_filters( 'code_snippets/build_snippet_object', $snippet, $data );
|
56 |
+
}
|
57 |
+
|
58 |
+
return $snippet;
|
59 |
+
}
|
60 |
+
|
61 |
+
/**
|
62 |
+
* Retrieve a list of snippets from the database
|
63 |
+
*
|
64 |
+
* @since 2.0
|
65 |
+
*
|
66 |
+
* @uses $wpdb To query the database for snippets
|
67 |
+
* @uses get_snippets_table_name() To dynamically retrieve the snippet table name
|
68 |
+
*
|
69 |
+
* @param boolean|null $multisite Retrieve multisite-wide or site-wide snippets?
|
70 |
+
* @return array An array of snippet objects
|
71 |
+
*/
|
72 |
+
function get_snippets( $multisite = null ) {
|
73 |
+
global $wpdb;
|
74 |
+
|
75 |
+
$table = get_snippets_table_name( $multisite );
|
76 |
+
$snippets = $wpdb->get_results( "SELECT * FROM $table", ARRAY_A );
|
77 |
+
|
78 |
+
foreach ( $snippets as $index => $snippet ) {
|
79 |
+
$snippets[ $index ] = unescape_snippet_data( $snippet );
|
80 |
+
}
|
81 |
+
|
82 |
+
return apply_filters( 'code_snippets/get_snippets', $snippets, $multisite );
|
83 |
+
}
|
84 |
+
|
85 |
+
/**
|
86 |
+
* Gets all of the used tags from the database
|
87 |
+
* @since 2.0
|
88 |
+
*/
|
89 |
+
function get_all_snippet_tags() {
|
90 |
+
global $wpdb;
|
91 |
+
|
92 |
+
/* Grab all tags from the database */
|
93 |
+
$tags = array();
|
94 |
+
$table = get_snippets_table_name();
|
95 |
+
$all_tags = $wpdb->get_col( "SELECT `tags` FROM $table" );
|
96 |
+
|
97 |
+
/* Merge all tags into a single array */
|
98 |
+
foreach ( $all_tags as $snippet_tags ) {
|
99 |
+
$snippet_tags = maybe_unserialize( $snippet_tags );
|
100 |
+
$snippet_tags = code_snippets_build_tags_array( $snippet_tags );
|
101 |
+
$tags = array_merge( $snippet_tags, $tags );
|
102 |
+
}
|
103 |
+
|
104 |
+
/* Remove duplicate tags */
|
105 |
+
return array_values( array_unique( $tags, SORT_REGULAR ) );
|
106 |
+
}
|
107 |
+
|
108 |
+
/**
|
109 |
+
* Make sure that the tags are a valid array
|
110 |
+
* @since 2.0
|
111 |
+
*
|
112 |
+
* @param mixed $tags The tags to convert into an array
|
113 |
+
* @return array The converted tags
|
114 |
+
*/
|
115 |
+
function code_snippets_build_tags_array( $tags ) {
|
116 |
+
|
117 |
+
/* If there are no tags set, create a default empty array */
|
118 |
+
if ( empty( $tags ) ) {
|
119 |
+
$tags = array();
|
120 |
+
}
|
121 |
+
|
122 |
+
/* If the tags are set as a string, convert them into an array */
|
123 |
+
elseif ( is_string( $tags ) ) {
|
124 |
+
$tags = str_replace( ', ', ',', $tags );
|
125 |
+
$tags = explode( ',', $tags );
|
126 |
+
}
|
127 |
+
|
128 |
+
/* If we still don't have an array, just convert whatever we do have into one */
|
129 |
+
if ( ! is_array( $tags ) ) {
|
130 |
+
$tags = (array) $tags;
|
131 |
+
}
|
132 |
+
|
133 |
+
return $tags;
|
134 |
+
}
|
135 |
+
|
136 |
+
/**
|
137 |
+
* Escape snippet data for inserting into the database
|
138 |
+
*
|
139 |
+
* @since 2.0
|
140 |
+
* @param mixed $snippet An object or array containing the data to escape
|
141 |
+
* @return object The resulting snippet object, with data escaped
|
142 |
+
*/
|
143 |
+
function escape_snippet_data( $snippet ) {
|
144 |
+
|
145 |
+
$snippet = build_snippet_object( $snippet );
|
146 |
+
|
147 |
+
/* Remove <?php and <? from beginning of snippet */
|
148 |
+
$snippet->code = preg_replace( '|^[\s]*<\?(php)?|', '', $snippet->code );
|
149 |
+
|
150 |
+
/* Remove ?> from end of snippet */
|
151 |
+
$snippet->code = preg_replace( '|\?>[\s]*$|', '', $snippet->code );
|
152 |
+
|
153 |
+
/* Escape the data */
|
154 |
+
$snippet->id = absint( $snippet->id );
|
155 |
+
|
156 |
+
/* Store tags as a string, with tags separated by commas */
|
157 |
+
$snippet->tags = code_snippets_build_tags_array( $snippet->tags );
|
158 |
+
$snippet->tags = implode( ', ', $snippet->tags );
|
159 |
+
|
160 |
+
return apply_filters( 'code_snippets/escape_snippet_data', $snippet );
|
161 |
+
}
|
162 |
+
|
163 |
+
/**
|
164 |
+
* Unescape snippet data after retrieval from the database
|
165 |
+
* ready for use
|
166 |
+
*
|
167 |
+
* @since 2.0
|
168 |
+
* @param mixed $snippet An object or array containing the data to unescape
|
169 |
+
* @return object The resulting snippet object, with data unescaped
|
170 |
+
*/
|
171 |
+
function unescape_snippet_data( $snippet ) {
|
172 |
+
$snippet = build_snippet_object( $snippet );
|
173 |
+
|
174 |
+
/* Ensure the tags are a valid array */
|
175 |
+
$snippet->tags = code_snippets_build_tags_array( $snippet->tags );
|
176 |
+
|
177 |
+
return apply_filters( 'code_snippets/unescape_snippet_data', $snippet );
|
178 |
+
}
|
179 |
+
|
180 |
+
/**
|
181 |
+
* Retrieve a single snippets from the database.
|
182 |
+
* Will return empty snippet object if no snippet
|
183 |
+
* ID is specified
|
184 |
+
*
|
185 |
+
* @since 2.0
|
186 |
+
*
|
187 |
+
* @uses $wpdb To query the database for snippets
|
188 |
+
* @uses get_snippets_table_name() To dynamically retrieve the snippet table name
|
189 |
+
*
|
190 |
+
* @param int $id The ID of the snippet to retrieve. 0 to build a new snippet
|
191 |
+
* @param boolean|null $multisite Retrieve a multisite-wide or site-wide snippet?
|
192 |
+
* @return object A single snippet object
|
193 |
+
*/
|
194 |
+
function get_snippet( $id = 0, $multisite = null ) {
|
195 |
+
global $wpdb;
|
196 |
+
|
197 |
+
$id = absint( $id );
|
198 |
+
$table = get_snippets_table_name( $multisite );
|
199 |
+
|
200 |
+
if ( 0 !== $id ) {
|
201 |
+
|
202 |
+
/* Retrieve the snippet from the database */
|
203 |
+
$snippet = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM $table WHERE id = %d", $id ) );
|
204 |
+
|
205 |
+
/* Unescape the snippet data, ready for use */
|
206 |
+
$snippet = unescape_snippet_data( $snippet );
|
207 |
+
|
208 |
+
} else {
|
209 |
+
|
210 |
+
/* Get an empty snippet object */
|
211 |
+
$snippet = build_snippet_object();
|
212 |
+
}
|
213 |
+
return apply_filters( 'code_snippets/get_snippet', $snippet, $id, $multisite );
|
214 |
+
}
|
215 |
+
|
216 |
+
/**
|
217 |
+
* Activates a snippet
|
218 |
+
*
|
219 |
+
* @since 2.0
|
220 |
+
*
|
221 |
+
* @uses $wpdb To set the snippet's active status
|
222 |
+
*
|
223 |
+
* @param array $id The ID of the snippet to activate
|
224 |
+
* @param boolean|null $multisite Are the snippets multisite-wide or site-wide?
|
225 |
+
*/
|
226 |
+
function activate_snippet( $id, $multisite = null ) {
|
227 |
+
global $wpdb;
|
228 |
+
$table = get_snippets_table_name( $multisite );
|
229 |
+
|
230 |
+
$wpdb->update(
|
231 |
+
$table,
|
232 |
+
array( 'active' => '1' ),
|
233 |
+
array( 'id' => $id ),
|
234 |
+
array( '%d' ),
|
235 |
+
array( '%d' )
|
236 |
+
);
|
237 |
+
|
238 |
+
do_action( 'code_snippets/activate_snippet', $id, $multisite );
|
239 |
+
}
|
240 |
+
|
241 |
+
/**
|
242 |
+
* Deactivate a snippet
|
243 |
+
*
|
244 |
+
* @since 2.0
|
245 |
+
*
|
246 |
+
* @uses $wpdb To set the snippets' active status
|
247 |
+
*
|
248 |
+
* @param array $id The ID of the snippet to deactivate
|
249 |
+
* @param boolean|null $multisite Are the snippets multisite-wide or site-wide?
|
250 |
+
*/
|
251 |
+
function deactivate_snippet( $id, $multisite = null ) {
|
252 |
+
global $wpdb;
|
253 |
+
$table = get_snippets_table_name( $multisite );
|
254 |
+
|
255 |
+
/* Set the snippet to active */
|
256 |
+
|
257 |
+
$wpdb->update(
|
258 |
+
$table,
|
259 |
+
array( 'active' => '0' ),
|
260 |
+
array( 'id' => $id ),
|
261 |
+
array( '%d' ),
|
262 |
+
array( '%d' )
|
263 |
+
);
|
264 |
+
|
265 |
+
/* Update the recently active list */
|
266 |
+
|
267 |
+
$recently_active = array( $id => time() );
|
268 |
+
|
269 |
+
if ( $table === $wpdb->ms_snippets ) {
|
270 |
+
|
271 |
+
update_site_option(
|
272 |
+
'recently_activated_snippets',
|
273 |
+
$recently_active + (array) get_site_option( 'recently_activated_snippets' )
|
274 |
+
);
|
275 |
+
} elseif ( $table === $wpdb->snippets ) {
|
276 |
+
|
277 |
+
update_option(
|
278 |
+
'recently_activated_snippets',
|
279 |
+
$recently_active + (array) get_option( 'recently_activated_snippets' )
|
280 |
+
);
|
281 |
+
}
|
282 |
+
|
283 |
+
do_action( 'code_snippets/deactivate_snippet', $id, $multisite );
|
284 |
+
}
|
285 |
+
|
286 |
+
/**
|
287 |
+
* Deletes a snippet from the database
|
288 |
+
*
|
289 |
+
* @since 2.0
|
290 |
+
* @uses $wpdb To access the database
|
291 |
+
* @uses get_snippets_table_name() To dynamically retrieve the name of the snippet table
|
292 |
+
*
|
293 |
+
* @param int $id The ID of the snippet to delete
|
294 |
+
* @param boolean|null $multisite Delete from site-wide or network-wide table?
|
295 |
+
*/
|
296 |
+
function delete_snippet( $id, $multisite = null ) {
|
297 |
+
global $wpdb;
|
298 |
+
|
299 |
+
$wpdb->delete(
|
300 |
+
get_snippets_table_name( $multisite ),
|
301 |
+
array( 'id' => $id ),
|
302 |
+
array( '%d' )
|
303 |
+
);
|
304 |
+
|
305 |
+
do_action( 'code_snippets/delete_snippet', $id, $multisite );
|
306 |
+
}
|
307 |
+
|
308 |
+
/**
|
309 |
+
* Saves a snippet to the database.
|
310 |
+
*
|
311 |
+
* @since 2.0
|
312 |
+
* @uses $wpdb To update/add the snippet to the database
|
313 |
+
* @uses get_snippets_table_name() To dynamically retrieve the name of the snippet table
|
314 |
+
*
|
315 |
+
* @param object $snippet The snippet to add/update to the database
|
316 |
+
* @param boolean|null $multisite Save the snippet to the site-wide or network-wide table?
|
317 |
+
* @return int|boolean The ID of the snippet on success, false on failure
|
318 |
+
*/
|
319 |
+
function save_snippet( $snippet, $multisite = null ) {
|
320 |
+
global $wpdb;
|
321 |
+
|
322 |
+
$data = array();
|
323 |
+
$table = get_snippets_table_name( $multisite );
|
324 |
+
$snippet = escape_snippet_data( $snippet );
|
325 |
+
|
326 |
+
foreach ( get_object_vars( $snippet ) as $field => $value ) {
|
327 |
+
if ( 'id' === $field ) {
|
328 |
+
continue;
|
329 |
+
}
|
330 |
+
|
331 |
+
if ( is_array( $value ) ) {
|
332 |
+
$value = maybe_serialize( $value );
|
333 |
+
}
|
334 |
+
|
335 |
+
$data[ $field ] = $value;
|
336 |
+
}
|
337 |
+
|
338 |
+
if ( isset( $snippet->id ) && 0 !== $snippet->id ) {
|
339 |
+
|
340 |
+
$wpdb->update( $table, $data, array( 'id' => $snippet->id ), null, array( '%d' ) );
|
341 |
+
do_action( 'code_snippets/update_snippet', $snippet, $table );
|
342 |
+
return $snippet->id;
|
343 |
+
|
344 |
+
} else {
|
345 |
+
|
346 |
+
$wpdb->insert( $table, $data, '%s' );
|
347 |
+
do_action( 'code_snippets/create_snippet', $snippet, $table );
|
348 |
+
return $wpdb->insert_id;
|
349 |
+
}
|
350 |
+
}
|
351 |
+
|
352 |
+
/**
|
353 |
+
* Imports snippets from an XML file
|
354 |
+
*
|
355 |
+
* @since 2.0
|
356 |
+
* @uses save_snippet() To add the snippets to the database
|
357 |
+
*
|
358 |
+
* @param string $file The path to the XML file to import
|
359 |
+
* @param boolean|null $multisite Import into network-wide table or site-wide table?
|
360 |
+
* @return integer|boolean The number of snippets imported on success, false on failure
|
361 |
+
*/
|
362 |
+
function import_snippets( $file, $multisite = null ) {
|
363 |
+
|
364 |
+
if ( ! file_exists( $file ) || ! is_file( $file ) ) {
|
365 |
+
return false;
|
366 |
+
}
|
367 |
+
|
368 |
+
$dom = new DOMDocument( '1.0', get_bloginfo( 'charset' ) );
|
369 |
+
$dom->load( $file );
|
370 |
+
|
371 |
+
$snippets_xml = $dom->getElementsByTagName( 'snippet' );
|
372 |
+
$fields = array( 'name', 'description', 'code', 'tags' );
|
373 |
+
$count = 0;
|
374 |
+
|
375 |
+
/* Loop through all snippets */
|
376 |
+
foreach ( $snippets_xml as $snippet_xml ) {
|
377 |
+
$snippet = new stdClass;
|
378 |
+
|
379 |
+
/* Build a snippet object by looping through the field names */
|
380 |
+
foreach ( $fields as $field_name ) {
|
381 |
+
|
382 |
+
/* Fetch the field element from the document */
|
383 |
+
$field = $snippet_xml->getElementsByTagName( $field_name )->item(0);
|
384 |
+
|
385 |
+
/* If the field element exists, add it to the snippet object */
|
386 |
+
if ( isset( $field->nodeValue ) ) {
|
387 |
+
$snippet->$field_name = $field->nodeValue;
|
388 |
+
}
|
389 |
+
}
|
390 |
+
|
391 |
+
/* Save the snippet and increase the counter if successful */
|
392 |
+
if ( save_snippet( $snippet, $multisite ) ) {
|
393 |
+
$count += 1;
|
394 |
+
}
|
395 |
+
}
|
396 |
+
|
397 |
+
do_action( 'code_snippets/import', $dom, $multisite );
|
398 |
+
return $count;
|
399 |
+
}
|
400 |
+
|
401 |
+
/**
|
402 |
+
* Exports snippets as an XML file
|
403 |
+
*
|
404 |
+
* @since 2.0
|
405 |
+
* @uses Code_Snippets_Export To export selected snippets
|
406 |
+
* @uses get_snippets_table_name() To dynamically retrieve the name of the snippet table
|
407 |
+
*
|
408 |
+
* @param array $ids The IDs of the snippets to export
|
409 |
+
* @param boolean|null $multisite Is the snippet a network-wide or site-wide snippet?
|
410 |
+
* @param string $format Export to xml or php?
|
411 |
+
*/
|
412 |
+
function export_snippets( $ids, $multisite = null, $format = 'xml' ) {
|
413 |
+
$table = get_snippets_table_name( $multisite );
|
414 |
+
|
415 |
+
if ( ! class_exists( 'Code_Snippets_Export' ) ) {
|
416 |
+
require_once plugin_dir_path( CODE_SNIPPETS_FILE ) . 'includes/class-export.php';
|
417 |
+
}
|
418 |
+
|
419 |
+
$class = new Code_Snippets_Export( $ids, $table, $format );
|
420 |
+
$class->do_export();
|
421 |
+
}
|
422 |
+
|
423 |
+
/**
|
424 |
+
* Execute a snippet
|
425 |
+
*
|
426 |
+
* Code must NOT be escaped, as
|
427 |
+
* it will be executed directly
|
428 |
+
*
|
429 |
+
* @since 2.0
|
430 |
+
* @param string $code The snippet code to execute
|
431 |
+
* @return mixed The result of the code execution
|
432 |
+
*/
|
433 |
+
function execute_snippet( $code ) {
|
434 |
+
|
435 |
+
if ( empty( $code ) ) {
|
436 |
+
return false;
|
437 |
+
}
|
438 |
+
|
439 |
+
ob_start();
|
440 |
+
$result = eval( $code );
|
441 |
+
$output = ob_get_contents();
|
442 |
+
ob_end_clean();
|
443 |
+
|
444 |
+
do_action( 'code_snippets/execute_snippet', $code );
|
445 |
+
return $result;
|
446 |
+
}
|
447 |
+
|
448 |
+
/**
|
449 |
+
* Run the active snippets
|
450 |
+
*
|
451 |
+
* @since 2.0
|
452 |
+
* @return boolean true on success, false on failure
|
453 |
+
*/
|
454 |
+
function execute_active_snippets() {
|
455 |
+
|
456 |
+
/* Bail early if safe mode is active */
|
457 |
+
if ( defined( 'CODE_SNIPPETS_SAFE_MODE' ) && CODE_SNIPPETS_SAFE_MODE ) {
|
458 |
+
return false;
|
459 |
+
}
|
460 |
+
|
461 |
+
global $wpdb;
|
462 |
+
|
463 |
+
if ( ! isset( $wpdb->snippets, $wpdb->ms_snippets ) ) {
|
464 |
+
set_snippet_table_vars();
|
465 |
+
}
|
466 |
+
|
467 |
+
/* Check if the snippets table exists */
|
468 |
+
if ( $wpdb->get_var( "SHOW TABLES LIKE '$wpdb->snippets'" ) === $wpdb->snippets ) {
|
469 |
+
$sql = "SELECT code FROM {$wpdb->snippets} WHERE active=1";
|
470 |
+
}
|
471 |
+
|
472 |
+
/* Check if the multisite snippets table exists */
|
473 |
+
if ( is_multisite() && $wpdb->get_var( "SHOW TABLES LIKE '$wpdb->ms_snippets'" ) === $wpdb->ms_snippets ) {
|
474 |
+
$sql = ( isset( $sql ) ? $sql . "\nUNION ALL\n" : '' );
|
475 |
+
$sql .= "SELECT code FROM {$wpdb->ms_snippets} WHERE active=1;";
|
476 |
+
}
|
477 |
+
|
478 |
+
if ( ! empty( $sql ) ) {
|
479 |
+
|
480 |
+
/* Grab the active snippets from the database */
|
481 |
+
$active_snippets = $wpdb->get_col( $sql );
|
482 |
+
|
483 |
+
foreach ( $active_snippets as $snippet_code ) {
|
484 |
+
/* Execute the PHP code */
|
485 |
+
execute_snippet( $snippet_code );
|
486 |
+
}
|
487 |
+
|
488 |
+
return true;
|
489 |
+
}
|
490 |
+
|
491 |
+
/* If we're made it this far without returning true, assume failure */
|
492 |
+
return false;
|
493 |
+
}
|
@@ -0,0 +1,61 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/* Bail on direct access */
|
4 |
+
if ( ! defined( 'ABSPATH' ) ) {
|
5 |
+
return;
|
6 |
+
}
|
7 |
+
|
8 |
+
/**
|
9 |
+
* Preform upgrade tasks such as deleting and updating options
|
10 |
+
* @since 2.0
|
11 |
+
*/
|
12 |
+
function code_snippets_upgrader() {
|
13 |
+
|
14 |
+
/* Get the current plugin version from the database */
|
15 |
+
$prev_version = get_option( 'code_snippets_version' );
|
16 |
+
|
17 |
+
/* Check if this is the first plugin run */
|
18 |
+
if ( ! $prev_version ) {
|
19 |
+
|
20 |
+
/* Register capabilities */
|
21 |
+
$role = get_role( apply_filters( 'code_snippets_role', 'administrator' ) );
|
22 |
+
$role->add_cap( apply_filters( 'code_snippets_cap', 'manage_snippets' ) );
|
23 |
+
}
|
24 |
+
|
25 |
+
/* Check if we have upgraded from an older version */
|
26 |
+
if ( version_compare( $prev_version, CODE_SNIPPETS_VERSION, '<' ) ) {
|
27 |
+
|
28 |
+
/* Update the plugin version stored in the database */
|
29 |
+
update_option( 'code_snippets_version', CODE_SNIPPETS_VERSION );
|
30 |
+
}
|
31 |
+
|
32 |
+
/* Run multisite-only upgrades */
|
33 |
+
|
34 |
+
if ( is_multisite() && is_main_site() ) {
|
35 |
+
|
36 |
+
/* Get the current plugin version from the database */
|
37 |
+
$prev_ms_version = get_site_option( 'code_snippets_version' );
|
38 |
+
|
39 |
+
/* Check if this is the first plugin run */
|
40 |
+
if ( ! $prev_ms_version ) {
|
41 |
+
|
42 |
+
/* Register multisite capabilities */
|
43 |
+
$network_cap = apply_filters( 'code_snippets_network_cap', 'manage_network_snippets' );
|
44 |
+
$supers = get_super_admins();
|
45 |
+
|
46 |
+
foreach ( $supers as $admin ) {
|
47 |
+
$user = new WP_User( 0, $admin );
|
48 |
+
$user->add_cap( $network_cap );
|
49 |
+
}
|
50 |
+
}
|
51 |
+
|
52 |
+
/* Check if we have upgraded from an older version */
|
53 |
+
if ( version_compare( $prev_ms_version, CODE_SNIPPETS_VERSION, '<' ) ) {
|
54 |
+
|
55 |
+
/* Update the plugin version stored in the database */
|
56 |
+
update_site_option( 'code_snippets_version', CODE_SNIPPETS_VERSION );
|
57 |
+
}
|
58 |
+
}
|
59 |
+
}
|
60 |
+
|
61 |
+
add_action( 'plugins_loaded', 'code_snippets_upgrader', 0 );
|
@@ -0,0 +1,67 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
ul.tagit {
|
2 |
+
padding: 1px 5px;
|
3 |
+
overflow: auto;
|
4 |
+
margin-left: inherit; /* usually we don't want the regular ul margins. */
|
5 |
+
margin-right: inherit;
|
6 |
+
}
|
7 |
+
ul.tagit li {
|
8 |
+
display: block;
|
9 |
+
float: left;
|
10 |
+
margin: 2px 5px 2px 0;
|
11 |
+
}
|
12 |
+
ul.tagit li.tagit-choice {
|
13 |
+
position: relative;
|
14 |
+
line-height: inherit;
|
15 |
+
}
|
16 |
+
|
17 |
+
ul.tagit li.tagit-choice-read-only {
|
18 |
+
padding: .2em .5em .2em .5em;
|
19 |
+
}
|
20 |
+
|
21 |
+
ul.tagit li.tagit-choice-editable {
|
22 |
+
padding: .2em 18px .2em .5em;
|
23 |
+
}
|
24 |
+
|
25 |
+
ul.tagit li.tagit-new {
|
26 |
+
padding: .25em 4px .25em 0;
|
27 |
+
}
|
28 |
+
|
29 |
+
ul.tagit li.tagit-choice a.tagit-label {
|
30 |
+
cursor: pointer;
|
31 |
+
text-decoration: none;
|
32 |
+
}
|
33 |
+
ul.tagit li.tagit-choice .tagit-close {
|
34 |
+
cursor: pointer;
|
35 |
+
position: absolute;
|
36 |
+
right: .1em;
|
37 |
+
top: 50%;
|
38 |
+
margin-top: -8px;
|
39 |
+
line-height: 17px;
|
40 |
+
}
|
41 |
+
|
42 |
+
/* used for some custom themes that don't need image icons */
|
43 |
+
ul.tagit li.tagit-choice .tagit-close .text-icon {
|
44 |
+
display: none;
|
45 |
+
}
|
46 |
+
|
47 |
+
ul.tagit li.tagit-choice input {
|
48 |
+
display: block;
|
49 |
+
float: left;
|
50 |
+
margin: 2px 5px 2px 0;
|
51 |
+
}
|
52 |
+
ul.tagit input[type="text"] {
|
53 |
+
-moz-box-sizing: border-box;
|
54 |
+
-webkit-box-sizing: border-box;
|
55 |
+
box-sizing: border-box;
|
56 |
+
|
57 |
+
-moz-box-shadow: none;
|
58 |
+
-webkit-box-shadow: none;
|
59 |
+
box-shadow: none;
|
60 |
+
|
61 |
+
border: none;
|
62 |
+
margin: 0;
|
63 |
+
padding: 0;
|
64 |
+
width: inherit;
|
65 |
+
background-color: inherit;
|
66 |
+
outline: none;
|
67 |
+
}
|
@@ -0,0 +1,16 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
(function(b){b.widget("ui.tagit",{options:{allowDuplicates:!1,caseSensitive:!0,fieldName:"tags",placeholderText:null,readOnly:!1,removeConfirmation:!1,tagLimit:null,availableTags:[],autocomplete:{},showAutocompleteOnFocus:!1,allowSpaces:!1,singleField:!1,singleFieldDelimiter:",",singleFieldNode:null,animate:!0,tabIndex:null,beforeTagAdded:null,afterTagAdded:null,beforeTagRemoved:null,afterTagRemoved:null,onTagClicked:null,onTagLimitExceeded:null,onTagAdded:null,onTagRemoved:null,tagSource:null},_create:function(){var a=
|
2 |
+
this;this.element.is("input")?(this.tagList=b("<ul></ul>").insertAfter(this.element),this.options.singleField=!0,this.options.singleFieldNode=this.element,this.element.css("display","none")):this.tagList=this.element.find("ul, ol").andSelf().last();this.tagInput=b('<input type="text" />').addClass("ui-widget-content");this.options.readOnly&&this.tagInput.attr("disabled","disabled");this.options.tabIndex&&this.tagInput.attr("tabindex",this.options.tabIndex);this.options.placeholderText&&this.tagInput.attr("placeholder",
|
3 |
+
this.options.placeholderText);this.options.autocomplete.source||(this.options.autocomplete.source=function(a,c){var d=a.term.toLowerCase(),e=b.grep(this.options.availableTags,function(a){return 0===a.toLowerCase().indexOf(d)});c(this._subtractArray(e,this.assignedTags()))});this.options.showAutocompleteOnFocus&&(this.tagInput.focus(function(){a._showAutocomplete()}),"undefined"===typeof this.options.autocomplete.minLength&&(this.options.autocomplete.minLength=0));b.isFunction(this.options.autocomplete.source)&&
|
4 |
+
(this.options.autocomplete.source=b.proxy(this.options.autocomplete.source,this));b.isFunction(this.options.tagSource)&&(this.options.tagSource=b.proxy(this.options.tagSource,this));this.tagList.addClass("tagit").addClass("ui-widget ui-widget-content ui-corner-all").append(b('<li class="tagit-new"></li>').append(this.tagInput)).click(function(c){var d=b(c.target);d.hasClass("tagit-label")?(d=d.closest(".tagit-choice"),d.hasClass("removed")||a._trigger("onTagClicked",c,{tag:d,tagLabel:a.tagLabel(d)})):
|
5 |
+
a.tagInput.focus()});var d=!1;if(this.options.singleField)if(this.options.singleFieldNode){var c=b(this.options.singleFieldNode),e=c.val().split(this.options.singleFieldDelimiter);c.val("");b.each(e,function(b,c){a.createTag(c,null,!0);d=!0})}else this.options.singleFieldNode=b('<input type="hidden" style="display:none;" value="" name="'+this.options.fieldName+'" />'),this.tagList.after(this.options.singleFieldNode);d||this.tagList.children("li").each(function(){b(this).hasClass("tagit-new")||(a.createTag(b(this).text(),
|
6 |
+
b(this).attr("class"),!0),b(this).remove())});this.tagInput.keydown(function(c){if(c.which==b.ui.keyCode.BACKSPACE&&""===a.tagInput.val()){var d=a._lastTag();!a.options.removeConfirmation||d.hasClass("remove")?a.removeTag(d):a.options.removeConfirmation&&d.addClass("remove ui-state-highlight")}else a.options.removeConfirmation&&a._lastTag().removeClass("remove ui-state-highlight");if(c.which===b.ui.keyCode.COMMA||c.which===b.ui.keyCode.ENTER||c.which==b.ui.keyCode.TAB&&""!==a.tagInput.val()||c.which==
|
7 |
+
b.ui.keyCode.SPACE&&!0!==a.options.allowSpaces&&('"'!=b.trim(a.tagInput.val()).replace(/^s*/,"").charAt(0)||'"'==b.trim(a.tagInput.val()).charAt(0)&&'"'==b.trim(a.tagInput.val()).charAt(b.trim(a.tagInput.val()).length-1)&&0!==b.trim(a.tagInput.val()).length-1))c.which===b.ui.keyCode.ENTER&&""===a.tagInput.val()||c.preventDefault(),a.createTag(a._cleanedInput()),a.tagInput.autocomplete("close")}).blur(function(){a.tagInput.data("autocomplete-open")||a.createTag(a._cleanedInput())});if(this.options.availableTags||
|
8 |
+
this.options.tagSource||this.options.autocomplete.source)c={select:function(b,c){a.createTag(c.item.value);return!1}},b.extend(c,this.options.autocomplete),c.source=this.options.tagSource||c.source,this.tagInput.autocomplete(c).bind("autocompleteopen",function(){a.tagInput.data("autocomplete-open",!0)}).bind("autocompleteclose",function(){a.tagInput.data("autocomplete-open",!1)})},_cleanedInput:function(){return b.trim(this.tagInput.val().replace(/^"(.*)"$/,"$1"))},_lastTag:function(){return this.tagList.find(".tagit-choice:last:not(.removed)")},
|
9 |
+
_tags:function(){return this.tagList.find(".tagit-choice:not(.removed)")},assignedTags:function(){var a=this,d=[];this.options.singleField?(d=b(this.options.singleFieldNode).val().split(this.options.singleFieldDelimiter),""===d[0]&&(d=[])):this._tags().each(function(){d.push(a.tagLabel(this))});return d},_updateSingleTagsField:function(a){b(this.options.singleFieldNode).val(a.join(this.options.singleFieldDelimiter)).trigger("change")},_subtractArray:function(a,d){for(var c=[],e=0;e<a.length;e++)-1==
|
10 |
+
b.inArray(a[e],d)&&c.push(a[e]);return c},tagLabel:function(a){return this.options.singleField?b(a).find(".tagit-label:first").text():b(a).find("input:first").val()},_showAutocomplete:function(){this.tagInput.autocomplete("search","")},_findTagByLabel:function(a){var d=this,c=null;this._tags().each(function(){if(d._formatStr(a)==d._formatStr(d.tagLabel(this)))return c=b(this),!1});return c},_isNew:function(a){return!this._findTagByLabel(a)},_formatStr:function(a){return this.options.caseSensitive?
|
11 |
+
a:b.trim(a.toLowerCase())},_effectExists:function(a){return Boolean(b.effects&&(b.effects[a]||b.effects.effect&&b.effects.effect[a]))},createTag:function(a,d,c){var e=this;a=b.trim(a);this.options.preprocessTag&&(a=this.options.preprocessTag(a));if(""===a)return!1;if(!this.options.allowDuplicates&&!this._isNew(a))return a=this._findTagByLabel(a),!1!==this._trigger("onTagExists",null,{existingTag:a,duringInitialization:c})&&this._effectExists("highlight")&&a.effect("highlight"),!1;if(this.options.tagLimit&&
|
12 |
+
this._tags().length>=this.options.tagLimit)return this._trigger("onTagLimitExceeded",null,{duringInitialization:c}),!1;var g=b(this.options.onTagClicked?'<a class="tagit-label"></a>':'<span class="tagit-label"></span>').text(a),f=b("<li></li>").addClass("tagit-choice ui-widget-content ui-state-default ui-corner-all").addClass(d).append(g);this.options.readOnly?f.addClass("tagit-choice-read-only"):(f.addClass("tagit-choice-editable"),d=b("<span></span>").addClass("ui-icon ui-icon-close"),d=b('<a><span class="text-icon">\u00d7</span></a>').addClass("tagit-close").append(d).click(function(){e.removeTag(f)}),
|
13 |
+
f.append(d));this.options.singleField||(g=g.html(),f.append('<input type="hidden" style="display:none;" value="'+g+'" name="'+this.options.fieldName+'" />'));!1!==this._trigger("beforeTagAdded",null,{tag:f,tagLabel:this.tagLabel(f),duringInitialization:c})&&(this.options.singleField&&(g=this.assignedTags(),g.push(a),this._updateSingleTagsField(g)),this._trigger("onTagAdded",null,f),this.tagInput.val(""),this.tagInput.parent().before(f),this._trigger("afterTagAdded",null,{tag:f,tagLabel:this.tagLabel(f),
|
14 |
+
duringInitialization:c}),this.options.showAutocompleteOnFocus&&!c&&setTimeout(function(){e._showAutocomplete()},0))},removeTag:function(a,d){d="undefined"===typeof d?this.options.animate:d;a=b(a);this._trigger("onTagRemoved",null,a);if(!1!==this._trigger("beforeTagRemoved",null,{tag:a,tagLabel:this.tagLabel(a)})){if(this.options.singleField){var c=this.assignedTags(),e=this.tagLabel(a),c=b.grep(c,function(a){return a!=e});this._updateSingleTagsField(c)}if(d){a.addClass("removed");var c=this._effectExists("blind")?
|
15 |
+
["blind",{direction:"horizontal"},"fast"]:["fast"],g=this;c.push(function(){a.remove();g._trigger("afterTagRemoved",null,{tag:a,tagLabel:g.tagLabel(a)})});a.fadeOut("fast").hide.apply(a,c).dequeue()}else a.remove(),this._trigger("afterTagRemoved",null,{tag:a,tagLabel:this.tagLabel(a)})}},removeTagByLabel:function(a,b){var c=this._findTagByLabel(a);if(!c)throw"No such tag exists with the name '"+a+"'";this.removeTag(c,b)},removeAll:function(){var a=this;this._tags().each(function(b,c){a.removeTag(c,
|
16 |
+
!1)})}})})(jQuery);
|
@@ -0,0 +1,56 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
|
2 |
+
/* Optional scoped theme for tag-it which mimics the zendesk widget. */
|
3 |
+
|
4 |
+
|
5 |
+
ul.tagit {
|
6 |
+
border-style: solid;
|
7 |
+
border-width: 1px;
|
8 |
+
border-color: #C6C6C6;
|
9 |
+
background: #fff;
|
10 |
+
}
|
11 |
+
ul.tagit li.tagit-choice {
|
12 |
+
-moz-border-radius: 6px;
|
13 |
+
border-radius: 6px;
|
14 |
+
-webkit-border-radius: 6px;
|
15 |
+
border: 1px solid #CAD8F3;
|
16 |
+
|
17 |
+
background: none;
|
18 |
+
background-color: #DEE7F8;
|
19 |
+
|
20 |
+
font-weight: normal;
|
21 |
+
}
|
22 |
+
ul.tagit li.tagit-choice .tagit-label:not(a) {
|
23 |
+
color: #555;
|
24 |
+
}
|
25 |
+
ul.tagit li.tagit-choice a.tagit-close {
|
26 |
+
text-decoration: none;
|
27 |
+
}
|
28 |
+
ul.tagit li.tagit-choice .tagit-close {
|
29 |
+
right: .4em;
|
30 |
+
}
|
31 |
+
ul.tagit li.tagit-choice .ui-icon {
|
32 |
+
display: none;
|
33 |
+
}
|
34 |
+
ul.tagit li.tagit-choice .tagit-close .text-icon {
|
35 |
+
display: inline;
|
36 |
+
font-family: arial, sans-serif;
|
37 |
+
font-size: 16px;
|
38 |
+
line-height: 16px;
|
39 |
+
color: #777;
|
40 |
+
}
|
41 |
+
ul.tagit li.tagit-choice:hover, ul.tagit li.tagit-choice.remove {
|
42 |
+
background-color: #bbcef1;
|
43 |
+
border-color: #6d95e0;
|
44 |
+
}
|
45 |
+
ul.tagit li.tagit-choice a.tagLabel:hover,
|
46 |
+
ul.tagit li.tagit-choice a.tagit-close .text-icon:hover {
|
47 |
+
color: #222;
|
48 |
+
}
|
49 |
+
ul.tagit input[type="text"] {
|
50 |
+
color: #333333;
|
51 |
+
background: none;
|
52 |
+
}
|
53 |
+
.ui-widget {
|
54 |
+
font-size: 1.1em;
|
55 |
+
}
|
56 |
+
|
Binary file
|
Binary file
|
@@ -0,0 +1,502 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# This file is distributed under the same license as the Code Snippets package.
|
2 |
+
# Marco <troniclabs.crew@gmail.com>, 2014.
|
3 |
+
msgid ""
|
4 |
+
msgstr ""
|
5 |
+
"Project-Id-Version: Code Snippets\n"
|
6 |
+
"PO-Revision-Date: 2014-08-08 09:26+0200\n"
|
7 |
+
"Last-Translator: Marco <troniclabs.crew@gmail.com>\n"
|
8 |
+
"Language-Team: Tronic Labs\n"
|
9 |
+
"Language: it\n"
|
10 |
+
"MIME-Version: 1.0\n"
|
11 |
+
"Content-Type: text/plain; charset=UTF-8\n"
|
12 |
+
"Content-Transfer-Encoding: 8bit\n"
|
13 |
+
"Plural-Forms: nplurals=2; plural=(n != 1);\n"
|
14 |
+
"X-Generator: Virtaal 0.7.1\n"
|
15 |
+
|
16 |
+
#: code-snippets.php:0 code-snippets.php:262
|
17 |
+
msgid "Code Snippets"
|
18 |
+
msgstr "Code Snippets"
|
19 |
+
|
20 |
+
#: code-snippets.php:0
|
21 |
+
msgid "An easy, clean and simple way to add code snippets to your site. No need to edit to your theme's functions.php file again!"
|
22 |
+
msgstr ""
|
23 |
+
"Un facile, semplice e pulito modo di aggiungere Snippet, frammenti di codice "
|
24 |
+
"al tuo sito. Senza editare il tuo tema e il tuo file functions.php."
|
25 |
+
|
26 |
+
#: code-snippets.php:0
|
27 |
+
msgid "Shea Bunge"
|
28 |
+
msgstr "Shea Bunge"
|
29 |
+
|
30 |
+
#: code-snippets.php:0
|
31 |
+
msgid "http://bungeshea.com"
|
32 |
+
msgstr "http://bungeshea.com"
|
33 |
+
|
34 |
+
#: code-snippets.php:577 code-snippets.php:578 code-snippets.php:588
|
35 |
+
#: includes/admin/manage.php:36
|
36 |
+
msgid "Snippets"
|
37 |
+
msgstr "Snippets"
|
38 |
+
|
39 |
+
#: code-snippets.php:612 code-snippets.php:1145 includes/admin/single.php:45
|
40 |
+
msgid "Add New Snippet"
|
41 |
+
msgstr "Aggiungi nuovo Snippet"
|
42 |
+
|
43 |
+
#: code-snippets.php:613
|
44 |
+
msgid "Add New"
|
45 |
+
msgstr "Aggiungi Nuovo"
|
46 |
+
|
47 |
+
#: code-snippets.php:641 includes/admin/import.php:34
|
48 |
+
msgid "Import Snippets"
|
49 |
+
msgstr "Importa Snippet"
|
50 |
+
|
51 |
+
#: code-snippets.php:642
|
52 |
+
msgid "Import"
|
53 |
+
msgstr "Importa"
|
54 |
+
|
55 |
+
#: code-snippets.php:601 code-snippets.php:1146 includes/admin/single.php:37
|
56 |
+
msgid "Edit Snippet"
|
57 |
+
msgstr "Edita Snippet"
|
58 |
+
|
59 |
+
#: code-snippets.php:1465
|
60 |
+
msgid "Manage your existing snippets"
|
61 |
+
msgstr "Gestisci i tuoi snippets esistenti"
|
62 |
+
|
63 |
+
#: code-snippets.php:589 code-snippets.php:1466
|
64 |
+
msgid "Manage"
|
65 |
+
msgstr "Gestisci"
|
66 |
+
|
67 |
+
#: code-snippets.php:1486
|
68 |
+
msgid "Visit the WordPress.org plugin page"
|
69 |
+
msgstr "Visita la pagina del plugin su WordPress.org"
|
70 |
+
|
71 |
+
#: code-snippets.php:1487
|
72 |
+
msgid "About"
|
73 |
+
msgstr "Info"
|
74 |
+
|
75 |
+
#: code-snippets.php:1491
|
76 |
+
msgid "Visit the support forums"
|
77 |
+
msgstr "Visita il forum di supporto"
|
78 |
+
|
79 |
+
#: code-snippets.php:1492
|
80 |
+
msgid "Support"
|
81 |
+
msgstr "Supporto"
|
82 |
+
|
83 |
+
#: code-snippets.php:1496
|
84 |
+
msgid "Support this plugin's development"
|
85 |
+
msgstr "Supporta lo sviluppo di questo plugin"
|
86 |
+
|
87 |
+
#: code-snippets.php:1497
|
88 |
+
msgid "Donate"
|
89 |
+
msgstr "Donazione"
|
90 |
+
|
91 |
+
#: includes/admin/import.php:38
|
92 |
+
msgid "Howdy! Upload your Code Snippets export file and we’ll import the snippets to this site."
|
93 |
+
msgstr ""
|
94 |
+
"Wella! Carica i tuoi Snippets di codice dal file esportato e li importeremo "
|
95 |
+
"nel tuo sito. "
|
96 |
+
|
97 |
+
#: includes/admin/import.php:40
|
98 |
+
msgid "You will need to go to the <a href=\"%s\">Manage Snippets</a> page to activate the imported snippets."
|
99 |
+
msgstr ""
|
100 |
+
"Dovrai andare nella pagina <a href=\"%s\">Gestisci Snippets</a> per attivare "
|
101 |
+
"gli snippets importati."
|
102 |
+
|
103 |
+
#: includes/admin/import.php:42
|
104 |
+
msgid "Choose a Code Snippets (.xml) file to upload, then click Upload file and import."
|
105 |
+
msgstr ""
|
106 |
+
"Scegli un file di Codice Snippets (.xml) da caricare, quindi clicca su "
|
107 |
+
"Carica file e Importa."
|
108 |
+
|
109 |
+
#: includes/admin/import.php:46
|
110 |
+
msgid "Choose a file from your computer:"
|
111 |
+
msgstr "Scegli un file dal computer:"
|
112 |
+
|
113 |
+
#: includes/admin/import.php:46
|
114 |
+
msgid "(Maximum size: 8MB)"
|
115 |
+
msgstr "(Grandezza massima: 8MB)"
|
116 |
+
|
117 |
+
#: includes/admin/import.php:55
|
118 |
+
msgid "Upload file and import"
|
119 |
+
msgstr "Carica un file e importa"
|
120 |
+
|
121 |
+
#: includes/admin/manage.php:21
|
122 |
+
msgid "Snippet <strong>activated</strong>."
|
123 |
+
msgstr "Snippet <strong>attivato</strong>."
|
124 |
+
|
125 |
+
#: includes/admin/manage.php:23
|
126 |
+
msgid "Selected snippets <strong>activated</strong>."
|
127 |
+
msgstr "Snippet selezionato <strong>attivato</strong>."
|
128 |
+
|
129 |
+
#: includes/admin/manage.php:25
|
130 |
+
msgid "Snippet <strong>deactivated</strong>."
|
131 |
+
msgstr "Snippet <strong>disattivato</strong>."
|
132 |
+
|
133 |
+
#: includes/admin/manage.php:27
|
134 |
+
msgid "Selected snippets <strong>deactivated</strong>."
|
135 |
+
msgstr "Snippet selezionato <strong>disattivato</strong>."
|
136 |
+
|
137 |
+
#: includes/admin/manage.php:29
|
138 |
+
msgid "Snippet <strong>deleted</strong>."
|
139 |
+
msgstr "Snippet <strong>cancellato</strong>."
|
140 |
+
|
141 |
+
#: includes/admin/manage.php:31
|
142 |
+
msgid "Selected snippets <strong>deleted</strong>."
|
143 |
+
msgstr "Snippet selezionato <strong>cancellato</strong>."
|
144 |
+
|
145 |
+
#: includes/admin/manage.php:38 includes/admin/single.php:42
|
146 |
+
msgctxt "snippet"
|
147 |
+
msgid "Add New"
|
148 |
+
msgstr "Aggiungi Nuovo"
|
149 |
+
|
150 |
+
#: includes/admin/manage.php:47
|
151 |
+
msgid "Search Installed Snippets"
|
152 |
+
msgstr "Cerca Snippets Installati"
|
153 |
+
|
154 |
+
#: includes/admin/single.php:22
|
155 |
+
msgid "Please provide a name for the snippet and its code."
|
156 |
+
msgstr "Per favore dai un nome allo snippet e al suo codice."
|
157 |
+
|
158 |
+
#: includes/admin/single.php:28
|
159 |
+
msgid "Snippet <strong>updated</strong>."
|
160 |
+
msgstr "Snippet <strong>aggiornato</strong>."
|
161 |
+
|
162 |
+
#: includes/admin/single.php:30
|
163 |
+
msgid "Snippet <strong>added</strong>."
|
164 |
+
msgstr "Snippet <strong>aggiunto</strong>."
|
165 |
+
|
166 |
+
#: includes/admin/single.php:55 includes/admin/single.php:56
|
167 |
+
msgid "Name (short title)"
|
168 |
+
msgstr "Nome (titolo corto)"
|
169 |
+
|
170 |
+
#: includes/admin/single.php:61
|
171 |
+
msgid "Code"
|
172 |
+
msgstr "Codice"
|
173 |
+
|
174 |
+
#: code-snippets.php:1433 includes/class-list-table.php:189
|
175 |
+
msgid "Description"
|
176 |
+
msgstr "Descizione"
|
177 |
+
|
178 |
+
#: code-snippets.php:1434
|
179 |
+
msgid "(Optional)"
|
180 |
+
msgstr "(Opzionale)"
|
181 |
+
|
182 |
+
#: includes/class-list-table.php:36
|
183 |
+
msgid "Snippets per page"
|
184 |
+
msgstr "Snippets per pagina"
|
185 |
+
|
186 |
+
#: code-snippets.php:1118 includes/class-list-table.php:127
|
187 |
+
#: includes/class-list-table.php:213
|
188 |
+
msgid "Network Deactivate"
|
189 |
+
msgstr "Network Disattivato"
|
190 |
+
|
191 |
+
#: code-snippets.php:1118 includes/class-list-table.php:127
|
192 |
+
#: includes/class-list-table.php:213
|
193 |
+
msgid "Deactivate"
|
194 |
+
msgstr "Disattivato"
|
195 |
+
|
196 |
+
#: code-snippets.php:1127 includes/class-list-table.php:137
|
197 |
+
#: includes/class-list-table.php:212
|
198 |
+
msgid "Network Activate"
|
199 |
+
msgstr "Network Attivato"
|
200 |
+
|
201 |
+
#: code-snippets.php:1127 includes/class-list-table.php:137
|
202 |
+
#: includes/class-list-table.php:212
|
203 |
+
msgid "Activate"
|
204 |
+
msgstr "Attivato"
|
205 |
+
|
206 |
+
#: includes/class-list-table.php:187
|
207 |
+
msgid "Name"
|
208 |
+
msgstr "Nome"
|
209 |
+
|
210 |
+
#: includes/class-list-table.php:188
|
211 |
+
msgid "ID"
|
212 |
+
msgstr "ID"
|
213 |
+
|
214 |
+
#: includes/class-list-table.php:147 includes/class-list-table.php:214
|
215 |
+
msgid "Export"
|
216 |
+
msgstr "Esporta"
|
217 |
+
|
218 |
+
#: includes/class-list-table.php:155 includes/class-list-table.php:215
|
219 |
+
msgid "Delete"
|
220 |
+
msgstr "Cancella"
|
221 |
+
|
222 |
+
#: includes/class-list-table.php:216
|
223 |
+
msgid "Export to PHP"
|
224 |
+
msgstr "Esporta in PHP"
|
225 |
+
|
226 |
+
#: includes/class-list-table.php:236
|
227 |
+
msgid "All <span class=\"count\">(%s)</span>"
|
228 |
+
msgid_plural "All <span class=\"count\">(%s)</span>"
|
229 |
+
msgstr[0] "Tutto <span class=\"count\">(%s)</span>"
|
230 |
+
msgstr[1] "Tutti <span class=\"count\">(%s)</span>"
|
231 |
+
|
232 |
+
#: includes/class-list-table.php:239
|
233 |
+
msgid "Active <span class=\"count\">(%s)</span>"
|
234 |
+
msgid_plural "Active <span class=\"count\">(%s)</span>"
|
235 |
+
msgstr[0] "Attivo <span class=\"count\">(%s)</span>"
|
236 |
+
msgstr[1] "Attivi <span class=\"count\">(%s)</span>"
|
237 |
+
|
238 |
+
#: includes/class-list-table.php:242
|
239 |
+
msgid "Recently Active <span class=\"count\">(%s)</span>"
|
240 |
+
msgid_plural "Recently Active <span class=\"count\">(%s)</span>"
|
241 |
+
msgstr[0] "Recentemente Attivo <span class=\"count\">(%s)</span>"
|
242 |
+
msgstr[1] "Recentemente Attivi <span class=\"count\">(%s)</span>"
|
243 |
+
|
244 |
+
#: includes/class-list-table.php:245
|
245 |
+
msgid "Inactive <span class=\"count\">(%s)</span>"
|
246 |
+
msgid_plural "Inactive <span class=\"count\">(%s)</span>"
|
247 |
+
msgstr[0] "Inattivo <span class=\"count\">(%s)</span>"
|
248 |
+
msgstr[1] "Inattivi <span class=\"count\">(%s)</span>"
|
249 |
+
|
250 |
+
#: includes/class-list-table.php:279
|
251 |
+
msgid "Clear List"
|
252 |
+
msgstr "Cancella Lista"
|
253 |
+
|
254 |
+
#: includes/class-list-table.php:374
|
255 |
+
msgid "You do not appear to have any snippets available at this time. <a href=\"%s\">Add New→</a>"
|
256 |
+
msgstr ""
|
257 |
+
"Sembra che tu non abbia nessuno snippets disponibile fino ad ora. <a href=\"%"
|
258 |
+
"s\">Aggiungi Nuovo→</a>"
|
259 |
+
|
260 |
+
#: includes/help/import.php:5 includes/help/manage.php:5
|
261 |
+
#: includes/help/single.php:5
|
262 |
+
msgid "Overview"
|
263 |
+
msgstr "Panoramica"
|
264 |
+
|
265 |
+
#: includes/help/import.php:7
|
266 |
+
msgid "Snippets are similar to plugins - they both extend and expand the functionality of WordPress. Snippets are more light-weight, just a few lines of code, and do not put as much load on your server. Here you can load snippets from a Code Snippets (.xml) import file into the database with your existing snippets."
|
267 |
+
msgstr ""
|
268 |
+
"Gli Snippets sono simili ai Plugin - tutti e due espandono le funzionalità "
|
269 |
+
"di WordPress. Gli Snippets sono più leggeri, giusto poche righe di codice, e "
|
270 |
+
"non appesantiscono il server. Qui tu puoi caricare snippet da un file di "
|
271 |
+
"codice Snippets (.xml) ed importarli nel database aggiungendoli a gli altri "
|
272 |
+
"esistenti."
|
273 |
+
|
274 |
+
#: includes/help/import.php:12
|
275 |
+
msgid "Importing"
|
276 |
+
msgstr "Importando"
|
277 |
+
|
278 |
+
#: includes/help/import.php:15
|
279 |
+
msgid "Snippets will be added to the database along with your existing snippets. Regardless of whether the snippets were active on the previous site, imported snippets are always inactive until activated using the <a href=\"%s\">Manage Snippets</a> page.</p>"
|
280 |
+
msgstr ""
|
281 |
+
"Gli Snippets saranno aggiunti al database insieme ai quelli esistenti. "
|
282 |
+
"Indipendentemente dal fatto che gli snippets erano attivi sul sito "
|
283 |
+
"precedente, gli snippets importati sono sempre inattivi finché non vengono "
|
284 |
+
"attivati utilizzando la <a href=\"%s\">Gestisci Snippets</a> pagina.</p>"
|
285 |
+
|
286 |
+
#: includes/help/import.php:20
|
287 |
+
msgid "Exporting"
|
288 |
+
msgstr "Esportando"
|
289 |
+
|
290 |
+
#: includes/help/import.php:22
|
291 |
+
msgid "You can save your snippets to a Code Snippets (.xml) export file using the <a href=\"%s\">Manage Snippets</a> page."
|
292 |
+
msgstr ""
|
293 |
+
"Tu puoi salvare i tuoi snippets in un file di codice Snippets (.xml) usando "
|
294 |
+
"la <a href=\"%s\">Gestisci Snippets</a> pagina."
|
295 |
+
|
296 |
+
#: includes/help/import.php:26 includes/help/manage.php:27
|
297 |
+
#: includes/help/single.php:31
|
298 |
+
msgid "For more information:"
|
299 |
+
msgstr "Per maggiori informazioni:"
|
300 |
+
|
301 |
+
#: includes/help/import.php:27 includes/help/single.php:32
|
302 |
+
msgid "<a href=\"http://wordpress.org/plugins/code-snippets\" target=\"_blank\">WordPress Extend</a>"
|
303 |
+
msgstr ""
|
304 |
+
"<a href=\"http://wordpress.org/plugins/code-snippets\" "
|
305 |
+
"target=\"_blank\">WordPress Extend</a>"
|
306 |
+
|
307 |
+
#: includes/help/import.php:28 includes/help/manage.php:29
|
308 |
+
#: includes/help/single.php:33
|
309 |
+
msgid "<a href=\"http://wordpress.org/support/plugin/code-snippets\" target=\"_blank\">Support Forums</a>"
|
310 |
+
msgstr ""
|
311 |
+
"<a href=\"http://wordpress.org/support/plugin/code-snippets\" "
|
312 |
+
"target=\"_blank\">Support Forums</a>"
|
313 |
+
|
314 |
+
#: includes/help/manage.php:7
|
315 |
+
msgid "Snippets are similar to plugins - they both extend and expand the functionality of WordPress. Snippets are more light-weight, just a few lines of code, and do not put as much load on your server. Here you can manage your existing snippets and preform tasks on them such as activating, deactivating, deleting and exporting."
|
316 |
+
msgstr ""
|
317 |
+
"Gli Snippets sono simili ai Plugin - tutti e due espandono le funzionalità "
|
318 |
+
"di WordPress. Gli Snippets sono più leggeri, giusto poche righe di codice, e "
|
319 |
+
"non appesantiscono il server. Qui tu puoi gestire i tuoi snippets, "
|
320 |
+
"attivarli, disattivarli, cancellarli ed esportarli."
|
321 |
+
|
322 |
+
#: includes/help/manage.php:12
|
323 |
+
msgid "Safe Mode"
|
324 |
+
msgstr "Modalità Sicura"
|
325 |
+
|
326 |
+
#: includes/help/manage.php:14
|
327 |
+
msgid "Be sure to check your snippets for errors before you activate them, as a faulty snippet could bring your whole blog down. If your site starts doing strange things, deactivate all your snippets and activate them one at a time."
|
328 |
+
msgstr ""
|
329 |
+
"Assicuratevi di controllare i vostri snippets da errori prima di attivarli, "
|
330 |
+
"uno snippet difettoso potrebbe bloccare tutto il tuo blog. Se il tuo sito "
|
331 |
+
"inizia a fare cose strane, disattivare tutti gli snippets e attivarli uno "
|
332 |
+
"alla volta."
|
333 |
+
|
334 |
+
#: includes/help/manage.php:20
|
335 |
+
msgid "Uninstall"
|
336 |
+
msgstr "Disinstalla"
|
337 |
+
|
338 |
+
#: includes/help/manage.php:22
|
339 |
+
msgid "When you delete Code Snippets through the Plugins menu in WordPress it will clear up the <code>%1$s</code> table and a few other bits of data stored in the database. If you want to keep this data (ie: you are only temporally uninstalling Code Snippets) then remove the <code>%2$s</code> folder using FTP."
|
340 |
+
msgstr ""
|
341 |
+
"Quando tu disinstalli il Code Snippets dal Plugins menu in WordPress, esso "
|
342 |
+
"cancellerà la <code>%1$s</code> tavola e pochi altri bit di dati "
|
343 |
+
"memorizzati nel tuo database. Se tu vuoi mantenere questi dati (es. tu stai "
|
344 |
+
"solo temporaneamente disinstallando il Code Snippets) allora rimuovi la "
|
345 |
+
"<code>%2$s</code> cartella usando lo FTP."
|
346 |
+
|
347 |
+
#: includes/help/manage.php:23
|
348 |
+
msgid "Even if you're sure that you don't want to use Code Snippets ever again on this WordPress installation, you may want to use the export feature to back up your snippets."
|
349 |
+
msgstr ""
|
350 |
+
"Anche se sei sicuro che non vuoi più utilizzare Code Snippets in WordPress, "
|
351 |
+
"è possibile utilizzare la funzione di esportazione per il backup degli "
|
352 |
+
"snippets."
|
353 |
+
|
354 |
+
#: includes/help/manage.php:28
|
355 |
+
msgid "<a href=\"http://wordpress.org/plugins/code-snippets\" target=\"_blank\">WordPress Extend</a></p>"
|
356 |
+
msgstr ""
|
357 |
+
"<a href=\"http://wordpress.org/plugins/code-snippets\" "
|
358 |
+
"target=\"_blank\">WordPress Extend</a></p>"
|
359 |
+
|
360 |
+
#: includes/help/single.php:7
|
361 |
+
msgid "Snippets are similar to plugins - they both extend and expand the functionality of WordPress. Snippets are more light-weight, just a few lines of code, and do not put as much load on your server. Here you can add a new snippet, or edit an existing one."
|
362 |
+
msgstr ""
|
363 |
+
"Gli Snippets sono simili ai Plugin - tutti e due espandono le funzionalità "
|
364 |
+
"di WordPress. Gli Snippets sono più leggeri, giusto poche righe di codice, e "
|
365 |
+
"non appesantiscono il server. Qui tu puoi aggiungere un nuovo snippet o "
|
366 |
+
"modificarne uno esistente."
|
367 |
+
|
368 |
+
#: includes/help/single.php:11
|
369 |
+
msgid "Finding Snippets"
|
370 |
+
msgstr "Cercando Snippets"
|
371 |
+
|
372 |
+
#: includes/help/single.php:13
|
373 |
+
msgid ""
|
374 |
+
"Here are some links to websites which host a large number of snippets that you can add to your site.\n"
|
375 |
+
"\t\t<ul>\n"
|
376 |
+
"\t\t\t<li><a href=\"http://wp-snippets.com\" title=\"WordPress Snippets\">WP-Snippets</a></li>\n"
|
377 |
+
"\t\t\t<li><a href=\"http://wpsnipp.com\" title=\"WP Snipp\">WP Snipp</a></li>\n"
|
378 |
+
"\t\t\t<li><a href=\"http://www.catswhocode.com/blog/snippets\" title=\"Cats Who Code Snippet Library\">Cats Who Code</a></li>\n"
|
379 |
+
"\t\t\t<li><a href=\"http://www.wpfunction.me\">WP Function Me</a></li>\n"
|
380 |
+
"\t\t</ul>"
|
381 |
+
msgstr ""
|
382 |
+
"Qui ci sono alcuni link a siti web che ospitano un largo numero di snippets "
|
383 |
+
"che puoi aggiungere al tuo sito.\n"
|
384 |
+
"\t\t<ul>\n"
|
385 |
+
"\t\t\t<li><a href=\"http://wp-snippets.com\" title=\"WordPress Snippets\">WP-"
|
386 |
+
"Snippets</a></li>\n"
|
387 |
+
"\t\t\t<li><a href=\"http://wpsnipp.com\" title=\"WP Snipp\">WP Snipp</a></li>\n"
|
388 |
+
"\t\t\t<li><a href=\"http://www.catswhocode.com/blog/snippets\" title=\"Cats Who "
|
389 |
+
"Code Snippet Library\">Cats Who Code</a></li>\n"
|
390 |
+
"\t\t\t<li><a href=\"http://www.wpfunction.me\">WP Function Me</a></li>"
|
391 |
+
|
392 |
+
#: includes/help/single.php:24
|
393 |
+
msgid "Adding Snippets"
|
394 |
+
msgstr "Aggiungendo Snippets"
|
395 |
+
|
396 |
+
#: includes/help/single.php:26
|
397 |
+
msgid "You need to fill out the name and code fields for your snippet to be added. While the description field will add more information about how your snippet works, what is does and where you found it, it is completely optional."
|
398 |
+
msgstr ""
|
399 |
+
"Devi riempire il campo del nome e il codice per aggiungere lo snippet. "
|
400 |
+
"Mentre il campo della descrizione aggiungerà più informazioni riguardo a "
|
401 |
+
"come lavora il tuo snippet, cosa fa e dove lo ritroviamo, ed è completamente "
|
402 |
+
"opzionale. "
|
403 |
+
|
404 |
+
#: includes/help/single.php:27
|
405 |
+
msgid "Please be sure to check that your snippet is valid PHP code and will not produce errors before adding it through this page. While doing so will not become active straight away, it will help to minimise the chance of a faulty snippet becoming active on your site."
|
406 |
+
msgstr ""
|
407 |
+
"Per favore accertati che lo snippet abbia un codice PHP valido e non produca "
|
408 |
+
"errori aggiungendolo a questa pagina. Facendo così, e non attivandolo "
|
409 |
+
"immediatamente, ci assicureremo di minimizzare le probabilità che uno "
|
410 |
+
"snippet difettoso sia attivato nel sito. "
|
411 |
+
|
412 |
+
#: code-snippets.php:0
|
413 |
+
msgid "http://code-snippets.bungeshea.com"
|
414 |
+
msgstr "http://code-snippets.bungeshea.com"
|
415 |
+
|
416 |
+
#: code-snippets.php:263
|
417 |
+
msgid "Import snippets from a <strong>Code Snippets</strong> export file"
|
418 |
+
msgstr "Importa snippets da un file <strong>Code Snippets</strong> esportato"
|
419 |
+
|
420 |
+
#: includes/admin/import.php:20
|
421 |
+
msgid "Imported <strong>%d</strong> snippet."
|
422 |
+
msgid_plural "Imported <strong>%d</strong> snippets."
|
423 |
+
msgstr[0] "Importato <strong>%d</strong> snippet."
|
424 |
+
msgstr[1] "Importati <strong>%d</strong> snippets."
|
425 |
+
|
426 |
+
#: includes/help/import.php:29 includes/help/manage.php:30
|
427 |
+
#: includes/help/single.php:34
|
428 |
+
msgid "<a href=\"http://code-snippets.bungeshea.com/\" target=\"_blank\">Project Website</a>"
|
429 |
+
msgstr ""
|
430 |
+
"<a href=\"http://code-snippets.bungeshea.com/\" target=\"_blank\">Project "
|
431 |
+
"Website</a>"
|
432 |
+
|
433 |
+
#: includes/help/manage.php:15
|
434 |
+
msgid "If something goes wrong with a snippet and you can't use WordPress, you can cause all snippets to stop executing by adding <code>define('CODE_SNIPPETS_SAFE_MODE', true);</code> to your <code>wp-config.php</code> file. After you have deactivated the offending snippet, you can turn off safe mode by removing this line or replacing <strong>true</strong> with <strong>false</strong>."
|
435 |
+
msgstr ""
|
436 |
+
"Se qualcosa va storto con uno snippet e non puoi più usare WordPress, puoi "
|
437 |
+
"bloccare la esecuzione di tutti gli snippets aggiungendo "
|
438 |
+
"<code>define('CODE_SNIPPETS_SAFE_MODE', true);</code> al tuo file <code>wp-"
|
439 |
+
"config.php</code>. Dopo aver disattivato lo snippet difettoso, puoi uscire "
|
440 |
+
"dalla modalità sicura rimuovendo la linea oppure cambiando "
|
441 |
+
"<strong>true</strong> con <strong>false</strong>."
|
442 |
+
|
443 |
+
#: includes/help/single.php:20
|
444 |
+
msgid "More places to find snippets, as well as a selection of example snippets, can be found in the <a href=\"http://code-snippets.bungeshea.com/docs/finding-snippets/\">plugin documentation</a>"
|
445 |
+
msgstr ""
|
446 |
+
"Un po' di posti dove cercare snippets, una selezione e alcuni esempi li pui "
|
447 |
+
"trovare nella <a href=\"http://code-snippets.bungeshea.com/docs/finding-"
|
448 |
+
"snippets/\">documentazione del plugin</a>"
|
449 |
+
|
450 |
+
#: code-snippets.php:0
|
451 |
+
msgid "1.7"
|
452 |
+
msgstr "1.7"
|
453 |
+
|
454 |
+
#: code-snippets.php:602 includes/class-list-table.php:142
|
455 |
+
msgid "Edit"
|
456 |
+
msgstr "Modifica"
|
457 |
+
|
458 |
+
#: code-snippets.php:1227
|
459 |
+
msgid "Sorry, you're not allowed to edit snippets"
|
460 |
+
msgstr "Scusa, tu non sei abilitato a modificare questo snippets"
|
461 |
+
|
462 |
+
#: includes/admin/single.php:24
|
463 |
+
msgid "Snippet <strong>updated</strong> and <strong>activated</strong>."
|
464 |
+
msgstr "Snippet <strong>aggiornato</strong> e <strong>attivato</strong>."
|
465 |
+
|
466 |
+
#: includes/admin/single.php:26
|
467 |
+
msgid "Snippet <strong>added</strong> and <strong>activated</strong>."
|
468 |
+
msgstr "Snippet <strong>aggiunto</strong> e <strong>attivato</strong>."
|
469 |
+
|
470 |
+
#: includes/class-list-table.php:163
|
471 |
+
msgid ""
|
472 |
+
"You are about to permanently delete the selected item.\n"
|
473 |
+
"\t\t\t\t'Cancel' to stop, 'OK' to delete."
|
474 |
+
msgstr ""
|
475 |
+
"Tu stai per cancellare in modo permanente questo elemento.\n"
|
476 |
+
"\t\t\t\t'Cancella' per fermarti, 'OK' per cancellare."
|
477 |
+
|
478 |
+
#: includes/class-list-table.php:270
|
479 |
+
msgid "Filter"
|
480 |
+
msgstr "Filtro"
|
481 |
+
|
482 |
+
#: includes/class-list-table.php:541
|
483 |
+
msgid "Search results"
|
484 |
+
msgstr "Risultati ricerca"
|
485 |
+
|
486 |
+
#: includes/class-list-table.php:544
|
487 |
+
msgid " for “%s”"
|
488 |
+
msgstr " per “%s”"
|
489 |
+
|
490 |
+
#: includes/class-list-table.php:550
|
491 |
+
msgid "Clear Filters"
|
492 |
+
msgstr "Cancella Filtri"
|
493 |
+
|
494 |
+
#: includes/help/import.php:14
|
495 |
+
msgid "You can load your snippets from a code snippets (.xml) export file using this page."
|
496 |
+
msgstr ""
|
497 |
+
"Tu non puoi caricare i tuoi snippets da un file di codice snippets (.xml) "
|
498 |
+
"usando questa pagina."
|
499 |
+
|
500 |
+
#: includes/admin/single.php:74
|
501 |
+
msgid "Save Changes & Activate"
|
502 |
+
msgstr "Salva Cambiamenti e Attivare"
|
Binary file
|
@@ -0,0 +1,569 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# This file is distributed under the same license as the Code Snippets package.
|
2 |
+
msgid ""
|
3 |
+
msgstr ""
|
4 |
+
"PO-Revision-Date: 2013-11-30 10:44+0900\n"
|
5 |
+
"MIME-Version: 1.0\n"
|
6 |
+
"Content-Type: text/plain; charset=UTF-8\n"
|
7 |
+
"Content-Transfer-Encoding: 8bit\n"
|
8 |
+
"Plural-Forms: nplurals=2; plural=n != 1;\n"
|
9 |
+
"X-Generator: Poedit 1.5.7\n"
|
10 |
+
"Project-Id-Version: Code Snippets\n"
|
11 |
+
"POT-Creation-Date: \n"
|
12 |
+
"Last-Translator: \n"
|
13 |
+
"Language-Team: \n"
|
14 |
+
|
15 |
+
#: code-snippets.php:0 code-snippets.php:262
|
16 |
+
msgid "Code Snippets"
|
17 |
+
msgstr "Code Snippets"
|
18 |
+
|
19 |
+
#: code-snippets.php:0
|
20 |
+
msgid ""
|
21 |
+
"An easy, clean and simple way to add code snippets to your site. No need to "
|
22 |
+
"edit to your theme's functions.php file again!"
|
23 |
+
msgstr ""
|
24 |
+
"簡単に、あなたのサイトにコードスニペットを追加する方法です。もうテーマの"
|
25 |
+
"functions.phpを編集する必要はありません!"
|
26 |
+
|
27 |
+
#: code-snippets.php:0
|
28 |
+
msgid "Shea Bunge"
|
29 |
+
msgstr "Shea Bunge"
|
30 |
+
|
31 |
+
#: code-snippets.php:0
|
32 |
+
msgid "http://bungeshea.com"
|
33 |
+
msgstr "http://bungeshea.com"
|
34 |
+
|
35 |
+
#: code-snippets.php:577 code-snippets.php:578 code-snippets.php:588
|
36 |
+
#: includes/admin/manage.php:36
|
37 |
+
msgid "Snippets"
|
38 |
+
msgstr "スニペット"
|
39 |
+
|
40 |
+
#: code-snippets.php:612 code-snippets.php:1145 includes/admin/single.php:45
|
41 |
+
msgid "Add New Snippet"
|
42 |
+
msgstr "スニペット新規追加"
|
43 |
+
|
44 |
+
#: code-snippets.php:613
|
45 |
+
msgid "Add New"
|
46 |
+
msgstr "新規追加"
|
47 |
+
|
48 |
+
#: code-snippets.php:641 includes/admin/import.php:34
|
49 |
+
msgid "Import Snippets"
|
50 |
+
msgstr "スニペットインポート"
|
51 |
+
|
52 |
+
#: code-snippets.php:642
|
53 |
+
msgid "Import"
|
54 |
+
msgstr "インポート"
|
55 |
+
|
56 |
+
#: code-snippets.php:601 code-snippets.php:1146 includes/admin/single.php:37
|
57 |
+
msgid "Edit Snippet"
|
58 |
+
msgstr "スニペット編集"
|
59 |
+
|
60 |
+
#: code-snippets.php:1465
|
61 |
+
msgid "Manage your existing snippets"
|
62 |
+
msgstr "登録されているスニペットを管理"
|
63 |
+
|
64 |
+
#: code-snippets.php:589 code-snippets.php:1466
|
65 |
+
msgid "Manage"
|
66 |
+
msgstr "管理"
|
67 |
+
|
68 |
+
#: code-snippets.php:1486
|
69 |
+
msgid "Visit the WordPress.org plugin page"
|
70 |
+
msgstr "WordPress.orgプラグインページへ"
|
71 |
+
|
72 |
+
#: code-snippets.php:1487
|
73 |
+
msgid "About"
|
74 |
+
msgstr "このプラグインについて"
|
75 |
+
|
76 |
+
#: code-snippets.php:1491
|
77 |
+
msgid "Visit the support forums"
|
78 |
+
msgstr "サポートフォーラムへ"
|
79 |
+
|
80 |
+
#: code-snippets.php:1492
|
81 |
+
msgid "Support"
|
82 |
+
msgstr "サポート"
|
83 |
+
|
84 |
+
#: code-snippets.php:1496
|
85 |
+
msgid "Support this plugin's development"
|
86 |
+
msgstr "このプラグインの開発をサポート"
|
87 |
+
|
88 |
+
#: code-snippets.php:1497
|
89 |
+
msgid "Donate"
|
90 |
+
msgstr "寄付"
|
91 |
+
|
92 |
+
#: includes/admin/import.php:38
|
93 |
+
msgid ""
|
94 |
+
"Howdy! Upload your Code Snippets export file and we’ll import the "
|
95 |
+
"snippets to this site."
|
96 |
+
msgstr ""
|
97 |
+
"こんにちは!あなたのコードスニペットエクスポートファイルをアップロードして、"
|
98 |
+
"このサイトにスニペットをインポートします。"
|
99 |
+
|
100 |
+
#: includes/admin/import.php:40
|
101 |
+
msgid ""
|
102 |
+
"You will need to go to the <a href=\"%s\">Manage Snippets</a> page to "
|
103 |
+
"activate the imported snippets."
|
104 |
+
msgstr ""
|
105 |
+
"<a href=\"%s\">スニペットの管理</a> ページでインポートしたスニペットを有効に"
|
106 |
+
"する必要があります。"
|
107 |
+
|
108 |
+
#: includes/admin/import.php:42
|
109 |
+
msgid ""
|
110 |
+
"Choose a Code Snippets (.xml) file to upload, then click Upload file and "
|
111 |
+
"import."
|
112 |
+
msgstr ""
|
113 |
+
"アップロードするスニペットファイル(.xml)を選択し、クリックしてファイルをアッ"
|
114 |
+
"プロードし、インポートして下さい。"
|
115 |
+
|
116 |
+
#: includes/admin/import.php:46
|
117 |
+
msgid "Choose a file from your computer:"
|
118 |
+
msgstr "ファイルをコンピュータから選択:"
|
119 |
+
|
120 |
+
#: includes/admin/import.php:46
|
121 |
+
msgid "(Maximum size: 8MB)"
|
122 |
+
msgstr "(最大ファイルサイズ: 8MB)"
|
123 |
+
|
124 |
+
#: includes/admin/import.php:55
|
125 |
+
msgid "Upload file and import"
|
126 |
+
msgstr "ファイルをアップロードし、インポート"
|
127 |
+
|
128 |
+
#: includes/admin/manage.php:21
|
129 |
+
msgid "Snippet <strong>activated</strong>."
|
130 |
+
msgstr "スニペットを <strong>有効化</strong>。"
|
131 |
+
|
132 |
+
#: includes/admin/manage.php:23
|
133 |
+
msgid "Selected snippets <strong>activated</strong>."
|
134 |
+
msgstr "選択されたスニペットを <strong>有効化</strong>。"
|
135 |
+
|
136 |
+
#: includes/admin/manage.php:25
|
137 |
+
msgid "Snippet <strong>deactivated</strong>."
|
138 |
+
msgstr "スニペットを <strong>停止</strong>。"
|
139 |
+
|
140 |
+
#: includes/admin/manage.php:27
|
141 |
+
msgid "Selected snippets <strong>deactivated</strong>."
|
142 |
+
msgstr "選択したスニペットを <strong>停止</strong>。"
|
143 |
+
|
144 |
+
#: includes/admin/manage.php:29
|
145 |
+
msgid "Snippet <strong>deleted</strong>."
|
146 |
+
msgstr "スニペットを <strong>削除</strong>。"
|
147 |
+
|
148 |
+
#: includes/admin/manage.php:31
|
149 |
+
msgid "Selected snippets <strong>deleted</strong>."
|
150 |
+
msgstr "選択されたスニペットを <strong>削除</strong>。"
|
151 |
+
|
152 |
+
#: includes/admin/manage.php:38 includes/admin/single.php:42
|
153 |
+
msgctxt "snippet"
|
154 |
+
msgid "Add New"
|
155 |
+
msgstr "新規追加"
|
156 |
+
|
157 |
+
#: includes/admin/manage.php:47
|
158 |
+
msgid "Search Installed Snippets"
|
159 |
+
msgstr "インストールされているスニペットを検索"
|
160 |
+
|
161 |
+
#: includes/admin/single.php:22
|
162 |
+
msgid "Please provide a name for the snippet and its code."
|
163 |
+
msgstr "スニペットもしくはコードに名前をつけて下さい。"
|
164 |
+
|
165 |
+
#: includes/admin/single.php:28
|
166 |
+
msgid "Snippet <strong>updated</strong>."
|
167 |
+
msgstr "スニペットを <strong>更新</strong>。"
|
168 |
+
|
169 |
+
#: includes/admin/single.php:30
|
170 |
+
msgid "Snippet <strong>added</strong>."
|
171 |
+
msgstr "スニペットを <strong>追加</strong>。"
|
172 |
+
|
173 |
+
#: includes/admin/single.php:55 includes/admin/single.php:56
|
174 |
+
msgid "Name (short title)"
|
175 |
+
msgstr "名前 (短いタイトル)"
|
176 |
+
|
177 |
+
#: includes/admin/single.php:61
|
178 |
+
msgid "Code"
|
179 |
+
msgstr "コード"
|
180 |
+
|
181 |
+
#: code-snippets.php:1433 includes/class-list-table.php:189
|
182 |
+
msgid "Description"
|
183 |
+
msgstr "説明"
|
184 |
+
|
185 |
+
#: code-snippets.php:1434
|
186 |
+
msgid "(Optional)"
|
187 |
+
msgstr "(オプション)"
|
188 |
+
|
189 |
+
#: includes/class-list-table.php:36
|
190 |
+
msgid "Snippets per page"
|
191 |
+
msgstr "1ページあたりのスニペット表示件数"
|
192 |
+
|
193 |
+
#: code-snippets.php:1118 includes/class-list-table.php:127
|
194 |
+
#: includes/class-list-table.php:213
|
195 |
+
msgid "Network Deactivate"
|
196 |
+
msgstr "ネットワーク 無効"
|
197 |
+
|
198 |
+
#: code-snippets.php:1118 includes/class-list-table.php:127
|
199 |
+
#: includes/class-list-table.php:213
|
200 |
+
msgid "Deactivate"
|
201 |
+
msgstr "無効"
|
202 |
+
|
203 |
+
#: code-snippets.php:1127 includes/class-list-table.php:137
|
204 |
+
#: includes/class-list-table.php:212
|
205 |
+
msgid "Network Activate"
|
206 |
+
msgstr "ネットワーク 有効"
|
207 |
+
|
208 |
+
#: code-snippets.php:1127 includes/class-list-table.php:137
|
209 |
+
#: includes/class-list-table.php:212
|
210 |
+
msgid "Activate"
|
211 |
+
msgstr "有効"
|
212 |
+
|
213 |
+
#: includes/class-list-table.php:187
|
214 |
+
msgid "Name"
|
215 |
+
msgstr "名前"
|
216 |
+
|
217 |
+
#: includes/class-list-table.php:188
|
218 |
+
msgid "ID"
|
219 |
+
msgstr "ID"
|
220 |
+
|
221 |
+
#: includes/class-list-table.php:147 includes/class-list-table.php:214
|
222 |
+
msgid "Export"
|
223 |
+
msgstr "エクスポート"
|
224 |
+
|
225 |
+
#: includes/class-list-table.php:155 includes/class-list-table.php:215
|
226 |
+
msgid "Delete"
|
227 |
+
msgstr "削除"
|
228 |
+
|
229 |
+
#: includes/class-list-table.php:216
|
230 |
+
msgid "Export to PHP"
|
231 |
+
msgstr "PHPにエクスポート"
|
232 |
+
|
233 |
+
#: includes/class-list-table.php:236
|
234 |
+
msgid "All <span class=\"count\">(%s)</span>"
|
235 |
+
msgid_plural "All <span class=\"count\">(%s)</span>"
|
236 |
+
msgstr[0] "全て <span class=\"count\">(%s)</span>"
|
237 |
+
msgstr[1] "全て <span class=\"count\">(%s)</span>"
|
238 |
+
|
239 |
+
#: includes/class-list-table.php:239
|
240 |
+
msgid "Active <span class=\"count\">(%s)</span>"
|
241 |
+
msgid_plural "Active <span class=\"count\">(%s)</span>"
|
242 |
+
msgstr[0] "有効 <span class=\"count\">(%s)</span>"
|
243 |
+
msgstr[1] "有効 <span class=\"count\">(%s)</span>"
|
244 |
+
|
245 |
+
#: includes/class-list-table.php:242
|
246 |
+
msgid "Recently Active <span class=\"count\">(%s)</span>"
|
247 |
+
msgid_plural "Recently Active <span class=\"count\">(%s)</span>"
|
248 |
+
msgstr[0] "最近まで使用 <span class=\"count\">(%s)</span>"
|
249 |
+
msgstr[1] "最近の有効 <span class=\"count\">(%s)</span>"
|
250 |
+
|
251 |
+
#: includes/class-list-table.php:245
|
252 |
+
msgid "Inactive <span class=\"count\">(%s)</span>"
|
253 |
+
msgid_plural "Inactive <span class=\"count\">(%s)</span>"
|
254 |
+
msgstr[0] "停止 <span class=\"count\">(%s)</span>"
|
255 |
+
msgstr[1] "停止 <span class=\"count\">(%s)</span>"
|
256 |
+
|
257 |
+
#: includes/class-list-table.php:279
|
258 |
+
msgid "Clear List"
|
259 |
+
msgstr "一覧をクリア"
|
260 |
+
|
261 |
+
#: includes/class-list-table.php:374
|
262 |
+
msgid ""
|
263 |
+
"You do not appear to have any snippets available at this time. <a href=\"%s"
|
264 |
+
"\">Add New→</a>"
|
265 |
+
msgstr "表示するスニペットがまだありません。<a href=\"%s\">新規追加→</a>"
|
266 |
+
|
267 |
+
#: includes/help/import.php:5 includes/help/manage.php:5
|
268 |
+
#: includes/help/single.php:5
|
269 |
+
msgid "Overview"
|
270 |
+
msgstr "概要"
|
271 |
+
|
272 |
+
#: includes/help/import.php:7
|
273 |
+
msgid ""
|
274 |
+
"Snippets are similar to plugins - they both extend and expand the "
|
275 |
+
"functionality of WordPress. Snippets are more light-weight, just a few lines "
|
276 |
+
"of code, and do not put as much load on your server. Here you can load "
|
277 |
+
"snippets from a Code Snippets (.xml) import file into the database with your "
|
278 |
+
"existing snippets."
|
279 |
+
msgstr ""
|
280 |
+
"スニペットはプラグインに似ています。両方ともWordPressの機能を拡張します。スニ"
|
281 |
+
"ペットは、より軽量、わずか数行のコードであり、サーバに負荷をかけません。ここ"
|
282 |
+
"であなたが持つスニペットを Code Snippets のインポートファイル(.xml) からデー"
|
283 |
+
"タベースに登録できます。"
|
284 |
+
|
285 |
+
#: includes/help/import.php:12
|
286 |
+
msgid "Importing"
|
287 |
+
msgstr "インポート中"
|
288 |
+
|
289 |
+
#: includes/help/import.php:15
|
290 |
+
msgid ""
|
291 |
+
"Snippets will be added to the database along with your existing snippets. "
|
292 |
+
"Regardless of whether the snippets were active on the previous site, "
|
293 |
+
"imported snippets are always inactive until activated using the <a href=\"%s"
|
294 |
+
"\">Manage Snippets</a> page.</p>"
|
295 |
+
msgstr ""
|
296 |
+
"スニペットは、既存のスニペットと一緒にデータベースに追加されます。<a href="
|
297 |
+
"\"%s\">スニペット管理</a> ページを使用して有効化されるまで、スニペットは、以"
|
298 |
+
"前のサイト上でアクティブになっていたかどうかにかかわらず、インポートされたス"
|
299 |
+
"ニペットは常に停止状態となります。</p>"
|
300 |
+
|
301 |
+
#: includes/help/import.php:20
|
302 |
+
msgid "Exporting"
|
303 |
+
msgstr "エクスポート中"
|
304 |
+
|
305 |
+
#: includes/help/import.php:22
|
306 |
+
msgid ""
|
307 |
+
"You can save your snippets to a Code Snippets (.xml) export file using the "
|
308 |
+
"<a href=\"%s\">Manage Snippets</a> page."
|
309 |
+
msgstr ""
|
310 |
+
"<a href=\"%s\">スニペット管理</a> ページでスニペットをCode Snippetsエクスポー"
|
311 |
+
"トファイル(.xml)に保存することができます。"
|
312 |
+
|
313 |
+
#: includes/help/import.php:26 includes/help/manage.php:27
|
314 |
+
#: includes/help/single.php:31
|
315 |
+
msgid "For more information:"
|
316 |
+
msgstr "より多くの情報:"
|
317 |
+
|
318 |
+
#: includes/help/import.php:27 includes/help/single.php:32
|
319 |
+
msgid ""
|
320 |
+
"<a href=\"http://wordpress.org/plugins/code-snippets\" target=\"_blank"
|
321 |
+
"\">WordPress Extend</a>"
|
322 |
+
msgstr ""
|
323 |
+
"<a href=\"http://wordpress.org/plugins/code-snippets\" target=\"_blank"
|
324 |
+
"\">WordPress Extend</a>"
|
325 |
+
|
326 |
+
#: includes/help/import.php:28 includes/help/manage.php:29
|
327 |
+
#: includes/help/single.php:33
|
328 |
+
msgid ""
|
329 |
+
"<a href=\"http://wordpress.org/support/plugin/code-snippets\" target=\"_blank"
|
330 |
+
"\">Support Forums</a>"
|
331 |
+
msgstr ""
|
332 |
+
"<a href=\"http://wordpress.org/support/plugin/code-snippets\" target=\"_blank"
|
333 |
+
"\">サポートフォラム</a>"
|
334 |
+
|
335 |
+
#: includes/help/manage.php:7
|
336 |
+
msgid ""
|
337 |
+
"Snippets are similar to plugins - they both extend and expand the "
|
338 |
+
"functionality of WordPress. Snippets are more light-weight, just a few lines "
|
339 |
+
"of code, and do not put as much load on your server. Here you can manage "
|
340 |
+
"your existing snippets and preform tasks on them such as activating, "
|
341 |
+
"deactivating, deleting and exporting."
|
342 |
+
msgstr ""
|
343 |
+
"スニペットはプラグインに似ています。両方ともWordPressの機能を拡張します。スニ"
|
344 |
+
"ペットは、より軽量、わずか数行のコードであり、サーバに負荷をかけません。ここ"
|
345 |
+
"では、既存のスニペットなどの有効化、停止、削除、エクスポートなど、それらのタ"
|
346 |
+
"スクを管理することができます。"
|
347 |
+
|
348 |
+
#: includes/help/manage.php:12
|
349 |
+
msgid "Safe Mode"
|
350 |
+
msgstr "セーフモード"
|
351 |
+
|
352 |
+
#: includes/help/manage.php:14
|
353 |
+
msgid ""
|
354 |
+
"Be sure to check your snippets for errors before you activate them, as a "
|
355 |
+
"faulty snippet could bring your whole blog down. If your site starts doing "
|
356 |
+
"strange things, deactivate all your snippets and activate them one at a time."
|
357 |
+
msgstr ""
|
358 |
+
"サイト全体が障害のあるスニペットで停止しないように、それらを有効化する前にス"
|
359 |
+
"ニペットを確認して下さい。サイトが奇妙な動作をした場合は、すべてのスニペット"
|
360 |
+
"を無効化し、それらを一度に1をアクティブにします。"
|
361 |
+
|
362 |
+
#: includes/help/manage.php:20
|
363 |
+
msgid "Uninstall"
|
364 |
+
msgstr "アンインストール"
|
365 |
+
|
366 |
+
#: includes/help/manage.php:22
|
367 |
+
msgid ""
|
368 |
+
"When you delete Code Snippets through the Plugins menu in WordPress it will "
|
369 |
+
"clear up the <code>%1$s</code> table and a few other bits of data stored in "
|
370 |
+
"the database. If you want to keep this data (ie: you are only temporally "
|
371 |
+
"uninstalling Code Snippets) then remove the <code>%2$s</code> folder using "
|
372 |
+
"FTP."
|
373 |
+
msgstr ""
|
374 |
+
"あなたがワードプレスでのプラグインメニューからコードスニペットを削除すると"
|
375 |
+
"き、<code>%1$s</code>テーブルと、データベースに格納されたデータのいくつかをク"
|
376 |
+
"リアします。(例:あなただけの一時的コードスニペットをアンインストールする)"
|
377 |
+
"このデータを保持する場合は、FTPを使用して <code>%2$s</code> フォルダを削除し"
|
378 |
+
"ます。"
|
379 |
+
|
380 |
+
#: includes/help/manage.php:23
|
381 |
+
msgid ""
|
382 |
+
"Even if you're sure that you don't want to use Code Snippets ever again on "
|
383 |
+
"this WordPress installation, you may want to use the export feature to back "
|
384 |
+
"up your snippets."
|
385 |
+
msgstr ""
|
386 |
+
"インストールされたスニペットコードをこのWordPressで使用しないとしても、スニ"
|
387 |
+
"ペットをエクスポート機能でバックアップして使用することができます。"
|
388 |
+
|
389 |
+
#: includes/help/manage.php:28
|
390 |
+
msgid ""
|
391 |
+
"<a href=\"http://wordpress.org/plugins/code-snippets\" target=\"_blank"
|
392 |
+
"\">WordPress Extend</a></p>"
|
393 |
+
msgstr ""
|
394 |
+
"<a href=\"http://wordpress.org/plugins/code-snippets\" target=\"_blank"
|
395 |
+
"\">WordPress Extend</a></p>"
|
396 |
+
|
397 |
+
#: includes/help/single.php:7
|
398 |
+
msgid ""
|
399 |
+
"Snippets are similar to plugins - they both extend and expand the "
|
400 |
+
"functionality of WordPress. Snippets are more light-weight, just a few lines "
|
401 |
+
"of code, and do not put as much load on your server. Here you can add a new "
|
402 |
+
"snippet, or edit an existing one."
|
403 |
+
msgstr ""
|
404 |
+
"スニペットはプラグインに似ています。両方ともWordPressの機能を拡張します。スニ"
|
405 |
+
"ペットは、より軽量、わずか数行のコードであり、サーバに負荷をかけません。ここ"
|
406 |
+
"では、新しいスニペットを追加するか、既存のものを編集することができます。"
|
407 |
+
|
408 |
+
#: includes/help/single.php:11
|
409 |
+
msgid "Finding Snippets"
|
410 |
+
msgstr "スニペットを探す"
|
411 |
+
|
412 |
+
#: includes/help/single.php:13
|
413 |
+
msgid ""
|
414 |
+
"Here are some links to websites which host a large number of snippets that "
|
415 |
+
"you can add to your site.\n"
|
416 |
+
"\t\t<ul>\n"
|
417 |
+
"\t\t\t<li><a href=\"http://wp-snippets.com\" title=\"WordPress Snippets\">WP-"
|
418 |
+
"Snippets</a></li>\n"
|
419 |
+
"\t\t\t<li><a href=\"http://wpsnipp.com\" title=\"WP Snipp\">WP Snipp</a></"
|
420 |
+
"li>\n"
|
421 |
+
"\t\t\t<li><a href=\"http://www.catswhocode.com/blog/snippets\" title=\"Cats "
|
422 |
+
"Who Code Snippet Library\">Cats Who Code</a></li>\n"
|
423 |
+
"\t\t\t<li><a href=\"http://www.wpfunction.me\">WP Function Me</a></li>\n"
|
424 |
+
"\t\t</ul>"
|
425 |
+
msgstr ""
|
426 |
+
"ここにあなたのサイトに追加できるスニペットをホストしているWebサイトを挙げま"
|
427 |
+
"す。\n"
|
428 |
+
"\t\t<ul>\n"
|
429 |
+
"\t\t\t<li><a href=\"http://wp-snippets.com\" title=\"WordPress Snippets\">WP-"
|
430 |
+
"Snippets</a></li>\n"
|
431 |
+
"\t\t\t<li><a href=\"http://wpsnipp.com\" title=\"WP Snipp\">WP Snipp</a></"
|
432 |
+
"li>\n"
|
433 |
+
"\t\t\t<li><a href=\"http://www.catswhocode.com/blog/snippets\" title=\"Cats "
|
434 |
+
"Who Code Snippet Library\">Cats Who Code</a></li>\n"
|
435 |
+
"\t\t\t<li><a href=\"http://www.wpfunction.me\">WP Function Me</a></li>\n"
|
436 |
+
"\t\t</ul>"
|
437 |
+
|
438 |
+
#: includes/help/single.php:24
|
439 |
+
msgid "Adding Snippets"
|
440 |
+
msgstr "スニペットを追加"
|
441 |
+
|
442 |
+
#: includes/help/single.php:26
|
443 |
+
msgid ""
|
444 |
+
"You need to fill out the name and code fields for your snippet to be added. "
|
445 |
+
"While the description field will add more information about how your snippet "
|
446 |
+
"works, what is does and where you found it, it is completely optional."
|
447 |
+
msgstr ""
|
448 |
+
"あなたは、追加するスニペットの名前とコードのフィールドに必要事項を記入する必"
|
449 |
+
"要があります。説明フィールドには、あなたのスニペットがどのように機能するかに"
|
450 |
+
"ついての詳細情報を記入しますが、これは任意です。"
|
451 |
+
|
452 |
+
#: includes/help/single.php:27
|
453 |
+
msgid ""
|
454 |
+
"Please be sure to check that your snippet is valid PHP code and will not "
|
455 |
+
"produce errors before adding it through this page. While doing so will not "
|
456 |
+
"become active straight away, it will help to minimise the chance of a faulty "
|
457 |
+
"snippet becoming active on your site."
|
458 |
+
msgstr ""
|
459 |
+
"このページで追加するスニペットのPHPコードがエラーを起こさないことを確認して下"
|
460 |
+
"さい。そうすることですぐに有効になりませんが、障害のあるスニペットは、サイト"
|
461 |
+
"上で有効になる可能性を最小限に抑えるのに役立ちます。"
|
462 |
+
|
463 |
+
#: code-snippets.php:0
|
464 |
+
msgid "http://code-snippets.bungeshea.com"
|
465 |
+
msgstr "http://code-snippets.bungeshea.com"
|
466 |
+
|
467 |
+
#: code-snippets.php:263
|
468 |
+
msgid "Import snippets from a <strong>Code Snippets</strong> export file"
|
469 |
+
msgstr ""
|
470 |
+
"スニペットを<strong>Code Snippets</strong>のエクスポートファイルからインポー"
|
471 |
+
"ト"
|
472 |
+
|
473 |
+
#: includes/admin/import.php:20
|
474 |
+
msgid "Imported <strong>%d</strong> snippet."
|
475 |
+
msgid_plural "Imported <strong>%d</strong> snippets."
|
476 |
+
msgstr[0] "スニペットを <strong>%d</strong> 件インポートしました。"
|
477 |
+
msgstr[1] "スニペットを <strong>%d</strong> 件インポートしました。"
|
478 |
+
|
479 |
+
#: includes/help/import.php:29 includes/help/manage.php:30
|
480 |
+
#: includes/help/single.php:34
|
481 |
+
msgid ""
|
482 |
+
"<a href=\"http://code-snippets.bungeshea.com/\" target=\"_blank\">Project "
|
483 |
+
"Website</a>"
|
484 |
+
msgstr ""
|
485 |
+
"<a href=\"http://code-snippets.bungeshea.com/\" target=\"_blank\">プロジェク"
|
486 |
+
"トサイト</a>"
|
487 |
+
|
488 |
+
#: includes/help/manage.php:15
|
489 |
+
msgid ""
|
490 |
+
"If something goes wrong with a snippet and you can't use WordPress, you can "
|
491 |
+
"cause all snippets to stop executing by adding <code>define"
|
492 |
+
"('CODE_SNIPPETS_SAFE_MODE', true);</code> to your <code>wp-config.php</code> "
|
493 |
+
"file. After you have deactivated the offending snippet, you can turn off "
|
494 |
+
"safe mode by removing this line or replacing <strong>true</strong> with "
|
495 |
+
"<strong>false</strong>."
|
496 |
+
msgstr ""
|
497 |
+
"もしもスニペットに何か問題があってWordPressが使えなくなったら、<code>wp-"
|
498 |
+
"config.php</code>ファイルに <code>define('CODE_SNIPPETS_SAFE_MODE', true);</"
|
499 |
+
"code> と記述することでスニペットの実行を停止します。あなたが問題のスニペット"
|
500 |
+
"を無効にした後は、この行を削除するか、<strong>true</strong> を "
|
501 |
+
"<strong>false</strong> に置き換えることでセーフモードをオフにすることができま"
|
502 |
+
"す。"
|
503 |
+
|
504 |
+
#: includes/help/single.php:20
|
505 |
+
msgid ""
|
506 |
+
"More places to find snippets, as well as a selection of example snippets, "
|
507 |
+
"can be found in the <a href=\"http://code-snippets.bungeshea.com/docs/"
|
508 |
+
"finding-snippets/\">plugin documentation</a>"
|
509 |
+
msgstr ""
|
510 |
+
"スニペットの例は、<a href=\"http://code-snippets.bungeshea.com/docs/finding-"
|
511 |
+
"snippets/\">プラグインドキュメント</a> に記載されています。"
|
512 |
+
|
513 |
+
#: code-snippets.php:0
|
514 |
+
msgid "1.7"
|
515 |
+
msgstr "1.7"
|
516 |
+
|
517 |
+
#: code-snippets.php:602 includes/class-list-table.php:142
|
518 |
+
msgid "Edit"
|
519 |
+
msgstr "編集"
|
520 |
+
|
521 |
+
#: code-snippets.php:1227
|
522 |
+
msgid "Sorry, you're not allowed to edit snippets"
|
523 |
+
msgstr "申し訳ありません、スニペット編集の許可がないようです"
|
524 |
+
|
525 |
+
#: includes/admin/single.php:24
|
526 |
+
msgid "Snippet <strong>updated</strong> and <strong>activated</strong>."
|
527 |
+
msgstr ""
|
528 |
+
"スニペットを <strong>更新</strong> し、 <strong>有効化</strong>しました。"
|
529 |
+
|
530 |
+
#: includes/admin/single.php:26
|
531 |
+
msgid "Snippet <strong>added</strong> and <strong>activated</strong>."
|
532 |
+
msgstr ""
|
533 |
+
"スニペットを <strong>追加</strong> し、 <strong>有効化</strong>しました。"
|
534 |
+
|
535 |
+
#: includes/class-list-table.php:163
|
536 |
+
msgid ""
|
537 |
+
"You are about to permanently delete the selected item.\n"
|
538 |
+
"\t\t\t\t'Cancel' to stop, 'OK' to delete."
|
539 |
+
msgstr ""
|
540 |
+
"あなたは永久に選択した項目を削除しようとしています。\n"
|
541 |
+
"\t\t\t\t 削除するには、'OK'を、中止するには 'Cancel'をクリックして下さい。"
|
542 |
+
|
543 |
+
#: includes/class-list-table.php:270
|
544 |
+
msgid "Filter"
|
545 |
+
msgstr "検索条件"
|
546 |
+
|
547 |
+
#: includes/class-list-table.php:541
|
548 |
+
msgid "Search results"
|
549 |
+
msgstr "検索結果"
|
550 |
+
|
551 |
+
#: includes/class-list-table.php:544
|
552 |
+
msgid " for “%s”"
|
553 |
+
msgstr " for “%s”"
|
554 |
+
|
555 |
+
#: includes/class-list-table.php:550
|
556 |
+
msgid "Clear Filters"
|
557 |
+
msgstr "検索条件を解除"
|
558 |
+
|
559 |
+
#: includes/help/import.php:14
|
560 |
+
msgid ""
|
561 |
+
"You can load your snippets from a code snippets (.xml) export file using "
|
562 |
+
"this page."
|
563 |
+
msgstr ""
|
564 |
+
"このページでスニペットコードをエクスポートファイル(.xml)から読み込むことがで"
|
565 |
+
"きます。"
|
566 |
+
|
567 |
+
#: includes/admin/single.php:74
|
568 |
+
msgid "Save Changes & Activate"
|
569 |
+
msgstr "変更を保存 & 有効化"
|
Binary file
|
@@ -0,0 +1,610 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# This file is distributed under the same license as the Code Snippets package.
|
2 |
+
msgid ""
|
3 |
+
msgstr ""
|
4 |
+
"Project-Id-Version: Code Snippets\n"
|
5 |
+
"POT-Creation-Date: 2014-10-11 15:52+0300\n"
|
6 |
+
"PO-Revision-Date: 2014-10-11 16:25+0300\n"
|
7 |
+
"Last-Translator: Flector <rlector@gmail.com>\n"
|
8 |
+
"Language-Team: Flector <rlector@gmail.com>\n"
|
9 |
+
"Language: ru\n"
|
10 |
+
"MIME-Version: 1.0\n"
|
11 |
+
"Content-Type: text/plain; charset=UTF-8\n"
|
12 |
+
"Content-Transfer-Encoding: 8bit\n"
|
13 |
+
"Plural-Forms: nplurals=3; plural=(n%10==1 && n%100!=11 ? 0 : n%10>=2 && n"
|
14 |
+
"%10<=4 && (n%100<10 || n%100>=20) ? 1 : 2);\n"
|
15 |
+
"X-Generator: Poedit 1.6.9\n"
|
16 |
+
"X-Poedit-SourceCharset: UTF-8\n"
|
17 |
+
"X-Poedit-Basepath: ../\n"
|
18 |
+
"X-Poedit-KeywordsList: __;_e;__ngettext:1,2;_n:1,2;_x:1,2c;_n;_nx:4c,1,2;"
|
19 |
+
"_nx_noop:4c,1,2;_ex:1,2c;__ngettext_noop:1,2;_n_noop:1,2;_x;esc_html_x;"
|
20 |
+
"esc_html_e\n"
|
21 |
+
"X-Poedit-SearchPath-0: .\n"
|
22 |
+
|
23 |
+
#: admin/help/import.php:16 admin/help/manage.php:16 admin/help/single.php:15
|
24 |
+
msgid "Overview"
|
25 |
+
msgstr "Обзор"
|
26 |
+
|
27 |
+
#: admin/help/import.php:18
|
28 |
+
msgid ""
|
29 |
+
"Snippets are similar to plugins - they both extend and expand the "
|
30 |
+
"functionality of WordPress. Snippets are more light-weight, just a few lines "
|
31 |
+
"of code, and do not put as much load on your server. Here you can load "
|
32 |
+
"snippets from a Code Snippets (.xml) import file into the database with your "
|
33 |
+
"existing snippets."
|
34 |
+
msgstr ""
|
35 |
+
"Сниппеты похожи на плагины - и те и другие расширяют функциональность движка "
|
36 |
+
"WordPress. Сниппеты зачастую маленькие, состоят лишь из нескольких строк "
|
37 |
+
"кода и не вызывают нагрузки на ваш сервер. Здесь вы можете загрузить ваши "
|
38 |
+
"сниппеты из файла экспорта плагина (.xml), чтобы добавить их на ваш сайт."
|
39 |
+
|
40 |
+
#: admin/help/import.php:23
|
41 |
+
msgid "Importing"
|
42 |
+
msgstr "Импортирование"
|
43 |
+
|
44 |
+
#: admin/help/import.php:25
|
45 |
+
msgid ""
|
46 |
+
"You can load your snippets from a code snippets (.xml) export file using "
|
47 |
+
"this page."
|
48 |
+
msgstr "Вы можете загрузить ваши сниппеты из файла экспорта (.xml)."
|
49 |
+
|
50 |
+
#: admin/help/import.php:26
|
51 |
+
#, php-format
|
52 |
+
msgid ""
|
53 |
+
"Snippets will be added to the database along with your existing snippets. "
|
54 |
+
"Regardless of whether the snippets were active on the previous site, "
|
55 |
+
"imported snippets are always inactive until activated using the <a href=\"%s"
|
56 |
+
"\">Manage Snippets</a> page.</p>"
|
57 |
+
msgstr ""
|
58 |
+
"Сниппеты будут добавлены в вашу базу (они не будут работать до тех пор, пока "
|
59 |
+
"вы их не активируете на странице <a href=\"%s\">Управление сниппетами</a>)</"
|
60 |
+
"p>"
|
61 |
+
|
62 |
+
#: admin/help/import.php:31
|
63 |
+
msgid "Exporting"
|
64 |
+
msgstr "Экспортирование"
|
65 |
+
|
66 |
+
#: admin/help/import.php:33
|
67 |
+
#, php-format
|
68 |
+
msgid ""
|
69 |
+
"You can save your snippets to a Code Snippets (.xml) export file using the "
|
70 |
+
"<a href=\"%s\">Manage Snippets</a> page."
|
71 |
+
msgstr ""
|
72 |
+
"Вы можете сохранить ваши сниппеты в файл экспорта (.xml) на странице <a href="
|
73 |
+
"\"%s\">Управление сниппетами</a>."
|
74 |
+
|
75 |
+
#: admin/help/import.php:37 admin/help/manage.php:38 admin/help/single.php:43
|
76 |
+
msgid "For more information:"
|
77 |
+
msgstr "Больше информации:"
|
78 |
+
|
79 |
+
#: admin/help/import.php:38 admin/help/single.php:44
|
80 |
+
msgid ""
|
81 |
+
"<a href=\"http://wordpress.org/plugins/code-snippets\" target=\"_blank"
|
82 |
+
"\">WordPress Extend</a>"
|
83 |
+
msgstr ""
|
84 |
+
"<a href=\"http://wordpress.org/plugins/code-snippets\" target=\"_blank"
|
85 |
+
"\">Страница плагина</a>"
|
86 |
+
|
87 |
+
#: admin/help/import.php:39 admin/help/manage.php:40 admin/help/single.php:45
|
88 |
+
msgid ""
|
89 |
+
"<a href=\"http://wordpress.org/support/plugin/code-snippets\" target=\"_blank"
|
90 |
+
"\">Support Forums</a>"
|
91 |
+
msgstr ""
|
92 |
+
"<a href=\"http://wordpress.org/support/plugin/code-snippets\" target=\"_blank"
|
93 |
+
"\">Форумы поддержки</a>"
|
94 |
+
|
95 |
+
#: admin/help/import.php:40 admin/help/manage.php:41 admin/help/single.php:46
|
96 |
+
msgid ""
|
97 |
+
"<a href=\"http://code-snippets.bungeshea.com/\" target=\"_blank\">Project "
|
98 |
+
"Website</a>"
|
99 |
+
msgstr ""
|
100 |
+
"<a href=\"http://code-snippets.bungeshea.com/\" target=\"_blank\">Сайт "
|
101 |
+
"плагина</a>"
|
102 |
+
|
103 |
+
#: admin/help/manage.php:18
|
104 |
+
msgid ""
|
105 |
+
"Snippets are similar to plugins - they both extend and expand the "
|
106 |
+
"functionality of WordPress. Snippets are more light-weight, just a few lines "
|
107 |
+
"of code, and do not put as much load on your server. Here you can manage "
|
108 |
+
"your existing snippets and preform tasks on them such as activating, "
|
109 |
+
"deactivating, deleting and exporting."
|
110 |
+
msgstr ""
|
111 |
+
"Сниппеты похожи на плагины - и те и другие расширяют функциональность движка "
|
112 |
+
"WordPress. Сниппеты зачастую маленькие, состоят лишь из нескольких строк "
|
113 |
+
"кода и не вызывают нагрузки на ваш сервер. Здесь вы можете управлять вашими "
|
114 |
+
"сниппетами (добавлять, редактировать, активировать и деактивировать)."
|
115 |
+
|
116 |
+
#: admin/help/manage.php:23
|
117 |
+
msgid "Safe Mode"
|
118 |
+
msgstr "Safe Mode"
|
119 |
+
|
120 |
+
#: admin/help/manage.php:25
|
121 |
+
msgid ""
|
122 |
+
"Be sure to check your snippets for errors before you activate them, as a "
|
123 |
+
"faulty snippet could bring your whole blog down. If your site starts doing "
|
124 |
+
"strange things, deactivate all your snippets and activate them one at a time."
|
125 |
+
msgstr ""
|
126 |
+
"Прежде чем активировать сниппеты убедитесь, что они не содержат ошибок. "
|
127 |
+
"Некорректные сниппеты могут испортить вам сайт!"
|
128 |
+
|
129 |
+
#: admin/help/manage.php:26
|
130 |
+
msgid ""
|
131 |
+
"If something goes wrong with a snippet and you can't use WordPress, you can "
|
132 |
+
"cause all snippets to stop executing by adding "
|
133 |
+
"<code>define('CODE_SNIPPETS_SAFE_MODE', true);</code> to your <code>wp-"
|
134 |
+
"config.php</code> file. After you have deactivated the offending snippet, "
|
135 |
+
"you can turn off safe mode by removing this line or replacing <strong>true</"
|
136 |
+
"strong> with <strong>false</strong>."
|
137 |
+
msgstr ""
|
138 |
+
"В случае любых проблем со сниппетами плагина вы можете их все "
|
139 |
+
"деактивировать, добавив строчку <code>define('CODE_SNIPPETS_SAFE_MODE', "
|
140 |
+
"true);</code> в ваш файл конфигурации <code>wp-config.php</code> . После "
|
141 |
+
"этого вы сможете деактивировать глючный сниппет, а потом снова включить "
|
142 |
+
"плагин, удалив указанную строчку."
|
143 |
+
|
144 |
+
#: admin/help/manage.php:31
|
145 |
+
msgid "Uninstall"
|
146 |
+
msgstr "Удаление"
|
147 |
+
|
148 |
+
#: admin/help/manage.php:33
|
149 |
+
#, php-format
|
150 |
+
msgid ""
|
151 |
+
"When you delete Code Snippets through the Plugins menu in WordPress it will "
|
152 |
+
"clear up the <code>%1$s</code> table and a few other bits of data stored in "
|
153 |
+
"the database. If you want to keep this data (ie: you are only temporally "
|
154 |
+
"uninstalling Code Snippets) then remove the <code>%2$s</code> folder using "
|
155 |
+
"FTP."
|
156 |
+
msgstr ""
|
157 |
+
"При удалении плагина через меню \"Плагины\" в админке блога таблица <code>"
|
158 |
+
"%1$s</code> в базе данных будет удалена. Если вы хотите сохранить настройки "
|
159 |
+
"(сниппеты) плагина, то удаляйте плагин (<code>%2$s</code>) через FTP, а не "
|
160 |
+
"через админку. Только в этом случае ваши сниппеты не будут потеряны (но вы, "
|
161 |
+
"конечно, можете сделать экспорт сниппетов во внешний .xml файл)."
|
162 |
+
|
163 |
+
#: admin/help/manage.php:34
|
164 |
+
msgid ""
|
165 |
+
"Even if you're sure that you don't want to use Code Snippets ever again on "
|
166 |
+
"this WordPress installation, you may want to use the export feature to back "
|
167 |
+
"up your snippets."
|
168 |
+
msgstr ""
|
169 |
+
"Даже если вы уверены, что не будете использовать данный плагин, то все равно "
|
170 |
+
"на всякий случай сделайте экспорт всех сниппетов кода."
|
171 |
+
|
172 |
+
#: admin/help/manage.php:39
|
173 |
+
msgid ""
|
174 |
+
"<a href=\"http://wordpress.org/plugins/code-snippets\" target=\"_blank"
|
175 |
+
"\">WordPress Extend</a></p>"
|
176 |
+
msgstr ""
|
177 |
+
"<a href=\"http://wordpress.org/plugins/code-snippets\" target=\"_blank"
|
178 |
+
"\">Страница плагина</a></p>"
|
179 |
+
|
180 |
+
#: admin/help/single.php:17
|
181 |
+
msgid ""
|
182 |
+
"Snippets are similar to plugins - they both extend and expand the "
|
183 |
+
"functionality of WordPress. Snippets are more light-weight, just a few lines "
|
184 |
+
"of code, and do not put as much load on your server. Here you can add a new "
|
185 |
+
"snippet, or edit an existing one."
|
186 |
+
msgstr ""
|
187 |
+
"Сниппеты похожи на плагины - и те и другие расширяют функциональность движка "
|
188 |
+
"WordPress. Сниппеты зачастую маленькие, состоят лишь из нескольких строк "
|
189 |
+
"кода и не вызывают нагрузки на ваш сервер. Здесь вы можете добавить новый "
|
190 |
+
"сниппет или отредактировать уже существующий."
|
191 |
+
|
192 |
+
#: admin/help/single.php:22
|
193 |
+
msgid "Finding Snippets"
|
194 |
+
msgstr "Поиск сниппетов"
|
195 |
+
|
196 |
+
#: admin/help/single.php:24
|
197 |
+
msgid ""
|
198 |
+
"Here are some links to websites which host a large number of snippets that "
|
199 |
+
"you can add to your site.\n"
|
200 |
+
"\t\t<ul>\n"
|
201 |
+
"\t\t\t<li><a href=\"http://wp-snippets.com\" title=\"WordPress Snippets\">WP-"
|
202 |
+
"Snippets</a></li>\n"
|
203 |
+
"\t\t\t<li><a href=\"http://wpsnipp.com\" title=\"WP Snipp\">WP Snipp</a></"
|
204 |
+
"li>\n"
|
205 |
+
"\t\t\t<li><a href=\"http://www.catswhocode.com/blog/snippets\" title=\"Cats "
|
206 |
+
"Who Code Snippet Library\">Cats Who Code</a></li>\n"
|
207 |
+
"\t\t\t<li><a href=\"http://www.wpfunction.me\">WP Function Me</a></li>\n"
|
208 |
+
"\t\t</ul>"
|
209 |
+
msgstr ""
|
210 |
+
"Здесь указаны ссылки на некоторые сайты со сниппетами:\n"
|
211 |
+
"\t\t<ul>\n"
|
212 |
+
"\t\t\t<li><a href=\"http://www.wphook.ru\" title=\"WPHook.ru\">WPHook.ru</"
|
213 |
+
"a></li>\n"
|
214 |
+
"\t\t\t<li><a href=\"http://wp-snippets.com\" title=\"WordPress Snippets\">WP-"
|
215 |
+
"Snippets</a></li>\n"
|
216 |
+
"\t\t\t<li><a href=\"http://wpsnipp.com\" title=\"WP Snipp\">WP Snipp</a></"
|
217 |
+
"li>\n"
|
218 |
+
"\t\t\t<li><a href=\"http://www.catswhocode.com/blog/snippets\" title=\"Cats "
|
219 |
+
"Who Code Snippet Library\">Cats Who Code</a></li>\n"
|
220 |
+
"\t\t\t<li><a href=\"http://www.wpfunction.me\">WP Function Me</a></li>\n"
|
221 |
+
"\t\t</ul>"
|
222 |
+
|
223 |
+
#: admin/help/single.php:31
|
224 |
+
msgid ""
|
225 |
+
"More places to find snippets, as well as a selection of example snippets, "
|
226 |
+
"can be found in the <a href=\"http://code-snippets.bungeshea.com/docs/"
|
227 |
+
"finding-snippets/\">plugin documentation</a>"
|
228 |
+
msgstr ""
|
229 |
+
"Другие ссылки вы можете найти на <a href=\"http://code-snippets.bungeshea."
|
230 |
+
"com/docs/finding-snippets/\">странице плагина</a>"
|
231 |
+
|
232 |
+
#: admin/help/single.php:36
|
233 |
+
msgid "Adding Snippets"
|
234 |
+
msgstr "Добавление сниппетов"
|
235 |
+
|
236 |
+
#: admin/help/single.php:38
|
237 |
+
msgid ""
|
238 |
+
"You need to fill out the name and code fields for your snippet to be added. "
|
239 |
+
"While the description field will add more information about how your snippet "
|
240 |
+
"works, what is does and where you found it, it is completely optional."
|
241 |
+
msgstr "Вы должны заполнить имя и "
|
242 |
+
|
243 |
+
#: admin/help/single.php:39
|
244 |
+
msgid ""
|
245 |
+
"Please be sure to check that your snippet is valid PHP code and will not "
|
246 |
+
"produce errors before adding it through this page. While doing so will not "
|
247 |
+
"become active straight away, it will help to minimise the chance of a faulty "
|
248 |
+
"snippet becoming active on your site."
|
249 |
+
msgstr ""
|
250 |
+
"Пожалуйста, убедитесь в том, что добавляемый вами сниппет является "
|
251 |
+
"корректным PHP кодом, так как иначе могут возникнуть проблемы с "
|
252 |
+
"работоспособностью вашего сайта."
|
253 |
+
|
254 |
+
#: admin/messages/import.php:18
|
255 |
+
#, php-format
|
256 |
+
msgid ""
|
257 |
+
"Successfully imported <strong>%d</strong> snippet. <a href=\"%s\">Have fun!</"
|
258 |
+
"a>"
|
259 |
+
msgid_plural ""
|
260 |
+
"Successfully imported <strong>%d</strong> snippets. <a href=\"%s\">Have fun!"
|
261 |
+
"</a>"
|
262 |
+
msgstr[0] ""
|
263 |
+
"Удачно импортирован <strong>%d</strong> сниппет. <a href=\"%s\">Удачи!</a>"
|
264 |
+
msgstr[1] ""
|
265 |
+
"Удачно импортировано <strong>%d</strong> сниппета. <a href=\"%s\">Удачи!</a>"
|
266 |
+
msgstr[2] ""
|
267 |
+
"Удачно импортировано <strong>%d</strong> сниппетов. <a href=\"%s\">Удачи!</a>"
|
268 |
+
|
269 |
+
#: admin/messages/import.php:32
|
270 |
+
msgid "An error occurred when processing the import file."
|
271 |
+
msgstr "Произошла ошибка при импортировании сниппета."
|
272 |
+
|
273 |
+
#: admin/messages/manage.php:14
|
274 |
+
msgid ""
|
275 |
+
"<strong>Warning:</strong> Safe mode is active and snippets will not execute! "
|
276 |
+
"Remove the <code>CODE_SNIPPETS_SAFE_MODE</code> constant from <code>wp-"
|
277 |
+
"config.php</code> to turn off safe mode. <a href=\"http://code-snippets."
|
278 |
+
"bungeshea.com/docs/safe-mode/\" target=\"_blank\">Help</a>"
|
279 |
+
msgstr ""
|
280 |
+
"<strong>Внимание:</strong> активирован режим Safe mode и поэтому сниппеты не "
|
281 |
+
"будут выполняться! Удалите константу <code>CODE_SNIPPETS_SAFE_MODE</code> из "
|
282 |
+
"файла <code>wp-config.php</code>, чтобы выключить режим Safe mode. <a href="
|
283 |
+
"\"http://code-snippets.bungeshea.com/docs/safe-mode/\" target=\"_blank"
|
284 |
+
"\">Помощь</a>"
|
285 |
+
|
286 |
+
#: admin/messages/manage.php:20
|
287 |
+
msgid "Snippet <strong>activated</strong>."
|
288 |
+
msgstr "Сниппет <strong>активирован</strong>."
|
289 |
+
|
290 |
+
#: admin/messages/manage.php:24
|
291 |
+
msgid "Selected snippets <strong>activated</strong>."
|
292 |
+
msgstr "Выбранные сниппеты <strong>активированы</strong>."
|
293 |
+
|
294 |
+
#: admin/messages/manage.php:28
|
295 |
+
msgid "Snippet <strong>deactivated</strong>."
|
296 |
+
msgstr "Сниппет <strong>деактивирован</strong>."
|
297 |
+
|
298 |
+
#: admin/messages/manage.php:32
|
299 |
+
msgid "Selected snippets <strong>deactivated</strong>."
|
300 |
+
msgstr "Выбранные сниппеты <strong>деактивированы</strong>."
|
301 |
+
|
302 |
+
#: admin/messages/manage.php:36
|
303 |
+
msgid "Snippet <strong>deleted</strong>."
|
304 |
+
msgstr "Сниппет <strong>удален</strong>."
|
305 |
+
|
306 |
+
#: admin/messages/manage.php:40
|
307 |
+
msgid "Selected snippets <strong>deleted</strong>."
|
308 |
+
msgstr "Выбранные сниппеты <strong>удалены</strong>."
|
309 |
+
|
310 |
+
#: admin/messages/single.php:14
|
311 |
+
msgid "An error occurred when saving the snippet."
|
312 |
+
msgstr "Произошла ошибка при сохранении сниппета."
|
313 |
+
|
314 |
+
#: admin/messages/single.php:18
|
315 |
+
msgid "Snippet <strong>updated</strong> and <strong>activated</strong>."
|
316 |
+
msgstr "Сниппет <strong>обновлен</strong> и <strong>активирован</strong>."
|
317 |
+
|
318 |
+
#: admin/messages/single.php:22
|
319 |
+
msgid "Snippet <strong>added</strong> and <strong>activated</strong>."
|
320 |
+
msgstr "Сниппет <strong>добавлен</strong> и <strong>активирован</strong>."
|
321 |
+
|
322 |
+
#: admin/messages/single.php:26
|
323 |
+
msgid "Snippet <strong>updated</strong> and <strong>deactivated</strong>."
|
324 |
+
msgstr "Сниппет <strong>обновлен</strong> и <strong>деактивирован</strong>."
|
325 |
+
|
326 |
+
#: admin/messages/single.php:30
|
327 |
+
msgid "Snippet <strong>updated</strong>."
|
328 |
+
msgstr "Сниппет <strong>обновлен</strong>."
|
329 |
+
|
330 |
+
#: admin/messages/single.php:34
|
331 |
+
msgid "Snippet <strong>added</strong>."
|
332 |
+
msgstr "Сниппет <strong>добавлен</strong>."
|
333 |
+
|
334 |
+
#: admin/views/import.php:20 includes/class-admin.php:327
|
335 |
+
msgid "Import Snippets"
|
336 |
+
msgstr "Импортирование сниппетов"
|
337 |
+
|
338 |
+
#: admin/views/import.php:24
|
339 |
+
msgid ""
|
340 |
+
"Howdy! Upload your Code Snippets export file and we’ll import the "
|
341 |
+
"snippets to this site."
|
342 |
+
msgstr ""
|
343 |
+
"Привет! Загрузите файл экспорта, чтобы импортировать сниппеты на этот сайт."
|
344 |
+
|
345 |
+
#: admin/views/import.php:26
|
346 |
+
#, php-format
|
347 |
+
msgid ""
|
348 |
+
"You will need to go to the <a href=\"%s\">Manage Snippets</a> page to "
|
349 |
+
"activate the imported snippets."
|
350 |
+
msgstr ""
|
351 |
+
"Вы должны будете зайти в <a href=\"%s\">Управление сниппетами</a>, чтобы "
|
352 |
+
"активировать импортированные сниппеты."
|
353 |
+
|
354 |
+
#: admin/views/import.php:28
|
355 |
+
msgid ""
|
356 |
+
"Choose a Code Snippets (.xml) file to upload, then click Upload file and "
|
357 |
+
"import."
|
358 |
+
msgstr ""
|
359 |
+
"Выберите файл экспорта (.xml), а затем кликните на \"Загрузить файл и "
|
360 |
+
"импортировать\"."
|
361 |
+
|
362 |
+
#: admin/views/import.php:35
|
363 |
+
msgid "Choose a file from your computer:"
|
364 |
+
msgstr "Выберите файл на вашем компьютере:"
|
365 |
+
|
366 |
+
#: admin/views/import.php:36
|
367 |
+
msgid "(Maximum size: 8MB)"
|
368 |
+
msgstr "(Максимальный размер: 8MB)"
|
369 |
+
|
370 |
+
#: admin/views/import.php:42
|
371 |
+
msgid "Upload file and import"
|
372 |
+
msgstr "Загрузить файл и импортировать"
|
373 |
+
|
374 |
+
#: admin/views/manage.php:21 includes/class-admin.php:152
|
375 |
+
#: includes/class-admin.php:276 includes/class-admin.php:277
|
376 |
+
#: includes/class-admin.php:287
|
377 |
+
msgid "Snippets"
|
378 |
+
msgstr "Сниппеты"
|
379 |
+
|
380 |
+
#: admin/views/manage.php:26 admin/views/single.php:34
|
381 |
+
#: includes/class-admin.php:300
|
382 |
+
msgid "Add New"
|
383 |
+
msgstr "Добавить новый"
|
384 |
+
|
385 |
+
#: admin/views/manage.php:39
|
386 |
+
msgid "Search Installed Snippets"
|
387 |
+
msgstr "Искать установленные сниппеты"
|
388 |
+
|
389 |
+
#: admin/views/single.php:29 includes/class-admin.php:299
|
390 |
+
msgid "Edit Snippet"
|
391 |
+
msgstr "Редактирование сниппета"
|
392 |
+
|
393 |
+
#: admin/views/single.php:37 includes/class-admin.php:299
|
394 |
+
msgid "Add New Snippet"
|
395 |
+
msgstr "Добавление нового сниппета"
|
396 |
+
|
397 |
+
#: admin/views/single.php:53 admin/views/single.php:54
|
398 |
+
msgid "Name (short title)"
|
399 |
+
msgstr "Имя (короткое название на английском)"
|
400 |
+
|
401 |
+
#: admin/views/single.php:59
|
402 |
+
msgid "Code"
|
403 |
+
msgstr "Код"
|
404 |
+
|
405 |
+
#: admin/views/single.php:85
|
406 |
+
msgid "Save Changes & Activate"
|
407 |
+
msgstr "Сохранить изменения & Активировать"
|
408 |
+
|
409 |
+
#: admin/views/single.php:91
|
410 |
+
msgid "Save Changes & Deactivate"
|
411 |
+
msgstr "Сохранить изменения & Деактивировать"
|
412 |
+
|
413 |
+
#: admin/views/single.php:100 includes/class-list-table.php:166
|
414 |
+
#: includes/class-list-table.php:265
|
415 |
+
msgid "Export"
|
416 |
+
msgstr "Экспорт"
|
417 |
+
|
418 |
+
#: admin/views/single.php:107 includes/class-list-table.php:182
|
419 |
+
msgid "Вы действительно хотите удалить выбранный сниппет?"
|
420 |
+
msgstr "Вы действительно хотите удалить выбранный сниппет?"
|
421 |
+
|
422 |
+
#: admin/views/single.php:112 includes/class-list-table.php:175
|
423 |
+
#: includes/class-list-table.php:266
|
424 |
+
msgid "Delete"
|
425 |
+
msgstr "Удалить"
|
426 |
+
|
427 |
+
#: includes/class-admin.php:185
|
428 |
+
msgid "Code Snippets"
|
429 |
+
msgstr "Code Snippets"
|
430 |
+
|
431 |
+
#: includes/class-admin.php:186
|
432 |
+
msgid "Import snippets from a Code Snippets export file"
|
433 |
+
msgstr "Импортировать сниппеты из файла экспорта плагина \"Code Snippets\"."
|
434 |
+
|
435 |
+
#: includes/class-admin.php:246
|
436 |
+
msgid "You are not authorized to access this page."
|
437 |
+
msgstr "У вас нет доступа к этой странице."
|
438 |
+
|
439 |
+
#: includes/class-admin.php:288 includes/class-admin.php:695
|
440 |
+
msgid "Manage"
|
441 |
+
msgstr "Управление сниппетами"
|
442 |
+
|
443 |
+
#: includes/class-admin.php:300 includes/class-list-table.php:160
|
444 |
+
msgid "Edit"
|
445 |
+
msgstr "Редактировать"
|
446 |
+
|
447 |
+
#: includes/class-admin.php:328
|
448 |
+
msgid "Import"
|
449 |
+
msgstr "Импорт"
|
450 |
+
|
451 |
+
#: includes/class-admin.php:663 includes/class-list-table.php:227
|
452 |
+
msgid "Description"
|
453 |
+
msgstr "Описание"
|
454 |
+
|
455 |
+
#: includes/class-admin.php:694
|
456 |
+
msgid "Manage your existing snippets"
|
457 |
+
msgstr "Управление вашими сниппетами"
|
458 |
+
|
459 |
+
#: includes/class-admin.php:722
|
460 |
+
msgid "Visit the WordPress.org plugin page"
|
461 |
+
msgstr "Посетить страницу плагина на WordPress.org"
|
462 |
+
|
463 |
+
#: includes/class-admin.php:723
|
464 |
+
msgid "About"
|
465 |
+
msgstr "О плагине"
|
466 |
+
|
467 |
+
#: includes/class-admin.php:727
|
468 |
+
msgid "Visit the support forums"
|
469 |
+
msgstr "Посетить форумы поддержки"
|
470 |
+
|
471 |
+
#: includes/class-admin.php:728
|
472 |
+
msgid "Support"
|
473 |
+
msgstr "Поддержка"
|
474 |
+
|
475 |
+
#: includes/class-admin.php:732
|
476 |
+
msgid "Support this plugin's development"
|
477 |
+
msgstr "Поддержите развитие плагина"
|
478 |
+
|
479 |
+
#: includes/class-admin.php:733
|
480 |
+
msgid "Donate"
|
481 |
+
msgstr "Пожертвования"
|
482 |
+
|
483 |
+
#: includes/class-admin.php:764
|
484 |
+
msgid ""
|
485 |
+
"<strong>Have feedback on Code Snippets?</strong> Please take the time to "
|
486 |
+
"answer a short survey on how you use this plugin and what you'd like to see "
|
487 |
+
"changed or added in the future."
|
488 |
+
msgstr ""
|
489 |
+
"<strong>У вас есть замечания по работе Code Snippets?</strong> Тогда "
|
490 |
+
"пожалуйста заполните анкету на сайте плагина."
|
491 |
+
|
492 |
+
#: includes/class-admin.php:767
|
493 |
+
msgid "Take the survey now"
|
494 |
+
msgstr "Оставить отзыв"
|
495 |
+
|
496 |
+
#: includes/class-list-table.php:49
|
497 |
+
msgid "Snippets per page"
|
498 |
+
msgstr "Сниппетов на страницу"
|
499 |
+
|
500 |
+
#: includes/class-list-table.php:141 includes/class-list-table.php:264
|
501 |
+
msgid "Network Deactivate"
|
502 |
+
msgstr "Деактивировать в сети"
|
503 |
+
|
504 |
+
#: includes/class-list-table.php:141 includes/class-list-table.php:264
|
505 |
+
msgid "Deactivate"
|
506 |
+
msgstr "Деактивировать"
|
507 |
+
|
508 |
+
#: includes/class-list-table.php:150 includes/class-list-table.php:263
|
509 |
+
msgid "Network Activate"
|
510 |
+
msgstr "Активировать в сети"
|
511 |
+
|
512 |
+
#: includes/class-list-table.php:150 includes/class-list-table.php:263
|
513 |
+
msgid "Activate"
|
514 |
+
msgstr "Активировать"
|
515 |
+
|
516 |
+
#: includes/class-list-table.php:189
|
517 |
+
#, php-format
|
518 |
+
msgid "Untitled #%d"
|
519 |
+
msgstr "Untitled #%d"
|
520 |
+
|
521 |
+
#: includes/class-list-table.php:225
|
522 |
+
msgid "Name"
|
523 |
+
msgstr "Имя"
|
524 |
+
|
525 |
+
#: includes/class-list-table.php:226
|
526 |
+
msgid "ID"
|
527 |
+
msgstr "ID"
|
528 |
+
|
529 |
+
#: includes/class-list-table.php:267
|
530 |
+
msgid "Export to PHP"
|
531 |
+
msgstr "Экспорт в PHP"
|
532 |
+
|
533 |
+
#: includes/class-list-table.php:303
|
534 |
+
#, php-format
|
535 |
+
msgid "All <span class=\"count\">(%s)</span>"
|
536 |
+
msgid_plural "All <span class=\"count\">(%s)</span>"
|
537 |
+
msgstr[0] "Все <span class=\"count\">(%s)</span>"
|
538 |
+
msgstr[1] "Все <span class=\"count\">(%s)</span>"
|
539 |
+
msgstr[2] "Все <span class=\"count\">(%s)</span>"
|
540 |
+
|
541 |
+
#: includes/class-list-table.php:306
|
542 |
+
#, php-format
|
543 |
+
msgid "Active <span class=\"count\">(%s)</span>"
|
544 |
+
msgid_plural "Active <span class=\"count\">(%s)</span>"
|
545 |
+
msgstr[0] "Активные <span class=\"count\">(%s)</span>"
|
546 |
+
msgstr[1] "Активные <span class=\"count\">(%s)</span>"
|
547 |
+
msgstr[2] "Активные <span class=\"count\">(%s)</span>"
|
548 |
+
|
549 |
+
#: includes/class-list-table.php:309
|
550 |
+
#, php-format
|
551 |
+
msgid "Recently Active <span class=\"count\">(%s)</span>"
|
552 |
+
msgid_plural "Recently Active <span class=\"count\">(%s)</span>"
|
553 |
+
msgstr[0] "Недавно активные <span class=\"count\">(%s)</span>"
|
554 |
+
msgstr[1] "Недавно активные <span class=\"count\">(%s)</span>"
|
555 |
+
msgstr[2] "Недавно активные <span class=\"count\">(%s)</span>"
|
556 |
+
|
557 |
+
#: includes/class-list-table.php:312
|
558 |
+
#, php-format
|
559 |
+
msgid "Inactive <span class=\"count\">(%s)</span>"
|
560 |
+
msgid_plural "Inactive <span class=\"count\">(%s)</span>"
|
561 |
+
msgstr[0] "Неактивные <span class=\"count\">(%s)</span>"
|
562 |
+
msgstr[1] "Неактивные <span class=\"count\">(%s)</span>"
|
563 |
+
msgstr[2] "Неактивные <span class=\"count\">(%s)</span>"
|
564 |
+
|
565 |
+
#: includes/class-list-table.php:341
|
566 |
+
msgid "Filter"
|
567 |
+
msgstr "Фильтр"
|
568 |
+
|
569 |
+
#: includes/class-list-table.php:349
|
570 |
+
msgid "Clear List"
|
571 |
+
msgstr "Очистить лист"
|
572 |
+
|
573 |
+
#: includes/class-list-table.php:491
|
574 |
+
#, php-format
|
575 |
+
msgid ""
|
576 |
+
"You do not appear to have any snippets available at this time. <a href=\"%s"
|
577 |
+
"\">Add New→</a>"
|
578 |
+
msgstr "Нет доступных сниппетов. <a href=\"%s\">Добавить новый→</a>"
|
579 |
+
|
580 |
+
#: includes/class-list-table.php:675
|
581 |
+
msgid "Search results"
|
582 |
+
msgstr "Результаты поиска"
|
583 |
+
|
584 |
+
#: includes/class-list-table.php:678
|
585 |
+
#, php-format
|
586 |
+
msgid " for “%s”"
|
587 |
+
msgstr " по запросу “%s”"
|
588 |
+
|
589 |
+
#: includes/class-list-table.php:684
|
590 |
+
msgid "Clear Filters"
|
591 |
+
msgstr "Очистить фильтры"
|
592 |
+
|
593 |
+
#~ msgid ""
|
594 |
+
#~ "You are about to permanently delete the selected item.\n"
|
595 |
+
#~ "\t\t\t\t'Cancel' to stop, 'OK' to delete."
|
596 |
+
#~ msgstr ""
|
597 |
+
#~ "Вы действительно хотите удалить выбранный сниппет?\n"
|
598 |
+
#~ "\t\t\t\t"
|
599 |
+
|
600 |
+
#~ msgid ""
|
601 |
+
#~ "You are about to permanently delete this snippet.\n"
|
602 |
+
#~ "'Cancel' to stop, 'OK' to delete."
|
603 |
+
#~ msgstr "Вы действительно хотите удалить выбранный сниппет?\n"
|
604 |
+
|
605 |
+
#, fuzzy
|
606 |
+
#~ msgid "Все <span class=\"count\">(%s)</span>"
|
607 |
+
#~ msgid_plural "Все <span class=\"count\">(%s)</span>"
|
608 |
+
#~ msgstr[0] "All <span class=\"count\">(%s)</span>"
|
609 |
+
#~ msgstr[1] "All <span class=\"count\">(%s)</span>"
|
610 |
+
#~ msgstr[2] "All <span class=\"count\">(%s)</span>"
|
Binary file
|
@@ -0,0 +1,596 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
msgid ""
|
2 |
+
msgstr ""
|
3 |
+
"Project-Id-Version: Code Snippets SK\n"
|
4 |
+
"POT-Creation-Date: 2014-12-09 06:55+0100\n"
|
5 |
+
"PO-Revision-Date: 2014-12-09 07:10+0100\n"
|
6 |
+
"Last-Translator: Jan Fajcak <ja@fajo.name>\n"
|
7 |
+
"Language-Team: WordPress Slovensko <info@wp.sk>\n"
|
8 |
+
"Language: sk\n"
|
9 |
+
"MIME-Version: 1.0\n"
|
10 |
+
"Content-Type: text/plain; charset=UTF-8\n"
|
11 |
+
"Content-Transfer-Encoding: 8bit\n"
|
12 |
+
"X-Generator: Poedit 1.7.1\n"
|
13 |
+
"X-Poedit-KeywordsList: __;_e;esc_html_e;gettext;gettext_noop\n"
|
14 |
+
"X-Poedit-Basepath: .\n"
|
15 |
+
"Plural-Forms: nplurals=3; plural=(n==1) ? 0 : (n>=2 && n<=4) ? 1 : 2;\n"
|
16 |
+
"X-Poedit-SourceCharset: UTF-8\n"
|
17 |
+
"X-Poedit-SearchPath-0: .\n"
|
18 |
+
"X-Poedit-SearchPath-1: ..\n"
|
19 |
+
|
20 |
+
#: ../admin/help/import.php:16 ../admin/help/manage.php:16
|
21 |
+
#: ../admin/help/single.php:15
|
22 |
+
msgid "Overview"
|
23 |
+
msgstr "Prehľad"
|
24 |
+
|
25 |
+
#: ../admin/help/import.php:18
|
26 |
+
msgid ""
|
27 |
+
"Snippets are similar to plugins - they both extend and expand the "
|
28 |
+
"functionality of WordPress. Snippets are more light-weight, just a few lines "
|
29 |
+
"of code, and do not put as much load on your server. Here you can load "
|
30 |
+
"snippets from a Code Snippets (.xml) import file into the database with your "
|
31 |
+
"existing snippets."
|
32 |
+
msgstr ""
|
33 |
+
"Snippety sa podobajú modulom- oba rozširujú a prehlbujú funkčnosť WordPress. "
|
34 |
+
"Snippety sú jednoduché kusy kódu veľké len pár riadkov, ktoré svojim objemom "
|
35 |
+
"nezaťažujú server. Tu môžete nahrať snippety z Code Snippets (.xml) súboru "
|
36 |
+
"do databáze k už existujúcim snippetom."
|
37 |
+
|
38 |
+
#: ../admin/help/import.php:23
|
39 |
+
msgid "Importing"
|
40 |
+
msgstr "Import"
|
41 |
+
|
42 |
+
#: ../admin/help/import.php:25
|
43 |
+
msgid ""
|
44 |
+
"You can load your snippets from a code snippets (.xml) export file using "
|
45 |
+
"this page."
|
46 |
+
msgstr ""
|
47 |
+
"Môžete nahrať vaše snippety zo súboru Code Snippets (.xml) prostredníctvom "
|
48 |
+
"tejto stránky."
|
49 |
+
|
50 |
+
#: ../admin/help/import.php:26
|
51 |
+
#, php-format
|
52 |
+
msgid ""
|
53 |
+
"Snippets will be added to the database along with your existing snippets. "
|
54 |
+
"Regardless of whether the snippets were active on the previous site, "
|
55 |
+
"imported snippets are always inactive until activated using the <a href=\"%s"
|
56 |
+
"\">Manage Snippets</a> page.</p>"
|
57 |
+
msgstr ""
|
58 |
+
"Snippety budú pridané do databáze k už existujúcim snippetom. Bez ohľadu na "
|
59 |
+
"to, že na predchádzajúcom webe boli aktívne, po importe je potrebné ich opäť "
|
60 |
+
"aktivovať na stránke <a href=\"%s\">Spravovať snippety</a>.</p>"
|
61 |
+
|
62 |
+
#: ../admin/help/import.php:31
|
63 |
+
msgid "Exporting"
|
64 |
+
msgstr "Export"
|
65 |
+
|
66 |
+
#: ../admin/help/import.php:33
|
67 |
+
#, php-format
|
68 |
+
msgid ""
|
69 |
+
"You can save your snippets to a Code Snippets (.xml) export file using the "
|
70 |
+
"<a href=\"%s\">Manage Snippets</a> page."
|
71 |
+
msgstr ""
|
72 |
+
"Vaše snippety môžete uložiť pomocou súboru Code Snippets (.xml) na stránke "
|
73 |
+
"<a href=\"%s\">Spravovať snippety</a>."
|
74 |
+
|
75 |
+
#: ../admin/help/import.php:37 ../admin/help/manage.php:38
|
76 |
+
#: ../admin/help/single.php:43
|
77 |
+
msgid "For more information:"
|
78 |
+
msgstr "Viac informácií:"
|
79 |
+
|
80 |
+
#: ../admin/help/import.php:38 ../admin/help/single.php:44
|
81 |
+
msgid ""
|
82 |
+
"<a href=\"http://wordpress.org/plugins/code-snippets\" target=\"_blank"
|
83 |
+
"\">WordPress Extend</a>"
|
84 |
+
msgstr ""
|
85 |
+
"<a href=\"http://wordpress.org/plugins/code-snippets\" target=\"_blank"
|
86 |
+
"\">WordPress Extend</a>"
|
87 |
+
|
88 |
+
#: ../admin/help/import.php:39 ../admin/help/manage.php:40
|
89 |
+
#: ../admin/help/single.php:45
|
90 |
+
msgid ""
|
91 |
+
"<a href=\"http://wordpress.org/support/plugin/code-snippets\" target=\"_blank"
|
92 |
+
"\">Support Forums</a>"
|
93 |
+
msgstr ""
|
94 |
+
"<a href=\"http://wordpress.org/support/plugin/code-snippets\" target=\"_blank"
|
95 |
+
"\">Fórum podpory</a>"
|
96 |
+
|
97 |
+
#: ../admin/help/import.php:40 ../admin/help/manage.php:41
|
98 |
+
#: ../admin/help/single.php:46
|
99 |
+
msgid ""
|
100 |
+
"<a href=\"http://code-snippets.bungeshea.com/\" target=\"_blank\">Project "
|
101 |
+
"Website</a>"
|
102 |
+
msgstr ""
|
103 |
+
"<a href=\"http://code-snippets.bungeshea.com/\" target=\"_blank\">Webová "
|
104 |
+
"stránka projektu</a>"
|
105 |
+
|
106 |
+
#: ../admin/help/manage.php:18
|
107 |
+
msgid ""
|
108 |
+
"Snippets are similar to plugins - they both extend and expand the "
|
109 |
+
"functionality of WordPress. Snippets are more light-weight, just a few lines "
|
110 |
+
"of code, and do not put as much load on your server. Here you can manage "
|
111 |
+
"your existing snippets and preform tasks on them such as activating, "
|
112 |
+
"deactivating, deleting and exporting."
|
113 |
+
msgstr ""
|
114 |
+
"Snippety sa podobajú modulom- oba rozširujú a prehlbujú funkčnosť WordPress. "
|
115 |
+
"Snippety sú jednoduché kusy kódu veľké len pár riadkov, ktoré svojim objemom "
|
116 |
+
"nezaťažujú server. Tu môžete spravovať svoje snippety: aktivovať ich a "
|
117 |
+
"deaktivovať, mazať alebo exportovať."
|
118 |
+
|
119 |
+
#: ../admin/help/manage.php:23
|
120 |
+
msgid "Safe Mode"
|
121 |
+
msgstr "Safe Mode"
|
122 |
+
|
123 |
+
#: ../admin/help/manage.php:25
|
124 |
+
msgid ""
|
125 |
+
"Be sure to check your snippets for errors before you activate them, as a "
|
126 |
+
"faulty snippet could bring your whole blog down. If your site starts doing "
|
127 |
+
"strange things, deactivate all your snippets and activate them one at a time."
|
128 |
+
msgstr ""
|
129 |
+
"Pred aktivovaním vašich snippetov sa uistite, že neobsahujú žiadne chyby, "
|
130 |
+
"inak riskujete pád vašich stránok. Ak sa začne diať niečo neočakávané, "
|
131 |
+
"deaktivujte všetky snippety a aktivujte ich ešte raz."
|
132 |
+
|
133 |
+
#: ../admin/help/manage.php:26
|
134 |
+
msgid ""
|
135 |
+
"If something goes wrong with a snippet and you can't use WordPress, you can "
|
136 |
+
"cause all snippets to stop executing by adding "
|
137 |
+
"<code>define('CODE_SNIPPETS_SAFE_MODE', true);</code> to your <code>wp-"
|
138 |
+
"config.php</code> file. After you have deactivated the offending snippet, "
|
139 |
+
"you can turn off safe mode by removing this line or replacing <strong>true</"
|
140 |
+
"strong> with <strong>false</strong>."
|
141 |
+
msgstr ""
|
142 |
+
"Ak došlo k problému a nie je možné použiť WordPress, môžete zastaviť všetky "
|
143 |
+
"snippety vložením <code>define('CODE_SNIPPETS_SAFE_MODE', true);</code> do "
|
144 |
+
"súboru <code>wp-config.php</code>. Potom, ako deaktivujete problémový "
|
145 |
+
"snippet, môžete tento kus kódu opäť odobrať alebo prepísať hodnotu "
|
146 |
+
"<strong>true</strong> na <strong>false</strong>."
|
147 |
+
|
148 |
+
#: ../admin/help/manage.php:31
|
149 |
+
msgid "Uninstall"
|
150 |
+
msgstr "Odinštalovať"
|
151 |
+
|
152 |
+
#: ../admin/help/manage.php:33
|
153 |
+
#, php-format
|
154 |
+
msgid ""
|
155 |
+
"When you delete Code Snippets through the Plugins menu in WordPress it will "
|
156 |
+
"clear up the <code>%1$s</code> table and a few other bits of data stored in "
|
157 |
+
"the database. If you want to keep this data (ie: you are only temporally "
|
158 |
+
"uninstalling Code Snippets) then remove the <code>%2$s</code> folder using "
|
159 |
+
"FTP."
|
160 |
+
msgstr ""
|
161 |
+
"Keď zmažete modul Code Snippets štandardnou cestou cez položku Moduly v "
|
162 |
+
"administrácii WordPress, bude zmazaná aj tabuľka <code>%1$s</code> a ďalšie "
|
163 |
+
"dáta, uložené v databáze. Ak chcete tieto dáta uchovať (napr. odinštalujete "
|
164 |
+
"Code Snippets len dočasne), potom odstráňte zložku <code>%2$s</code> cez FTP "
|
165 |
+
"ručne."
|
166 |
+
|
167 |
+
#: ../admin/help/manage.php:34
|
168 |
+
msgid ""
|
169 |
+
"Even if you're sure that you don't want to use Code Snippets ever again on "
|
170 |
+
"this WordPress installation, you may want to use the export feature to back "
|
171 |
+
"up your snippets."
|
172 |
+
msgstr ""
|
173 |
+
"Ak máte istotu, že už v tejto inštalácii nechcete používať Code Snippets, "
|
174 |
+
"môžete vaše snippety pomocou funkcie Export zálohovať."
|
175 |
+
|
176 |
+
#: ../admin/help/manage.php:39
|
177 |
+
msgid ""
|
178 |
+
"<a href=\"http://wordpress.org/plugins/code-snippets\" target=\"_blank"
|
179 |
+
"\">WordPress Extend</a></p>"
|
180 |
+
msgstr ""
|
181 |
+
"<a href=\"http://wordpress.org/plugins/code-snippets\" target=\"_blank"
|
182 |
+
"\">WordPress Extend</a></p>"
|
183 |
+
|
184 |
+
#: ../admin/help/single.php:17
|
185 |
+
msgid ""
|
186 |
+
"Snippets are similar to plugins - they both extend and expand the "
|
187 |
+
"functionality of WordPress. Snippets are more light-weight, just a few lines "
|
188 |
+
"of code, and do not put as much load on your server. Here you can add a new "
|
189 |
+
"snippet, or edit an existing one."
|
190 |
+
msgstr ""
|
191 |
+
"Snippety sa podobajú modulom- oba rozširujú a prehlbujú funkčnosť WordPress. "
|
192 |
+
"Snippety sú jednoduché kusy kódu veľké len pár riadkov, ktoré svojim objemom "
|
193 |
+
"nezaťažujú server. Tu môžete pridávať nové snippety, alebo upravovať už "
|
194 |
+
"existujúce."
|
195 |
+
|
196 |
+
#: ../admin/help/single.php:22
|
197 |
+
msgid "Finding Snippets"
|
198 |
+
msgstr "Nájsť snippety"
|
199 |
+
|
200 |
+
#: ../admin/help/single.php:24
|
201 |
+
msgid ""
|
202 |
+
"Here are some links to websites which host a large number of snippets that "
|
203 |
+
"you can add to your site.\n"
|
204 |
+
"\t\t<ul>\n"
|
205 |
+
"\t\t\t<li><a href=\"http://wp-snippets.com\" title=\"WordPress Snippets\">WP-"
|
206 |
+
"Snippets</a></li>\n"
|
207 |
+
"\t\t\t<li><a href=\"http://wpsnipp.com\" title=\"WP Snipp\">WP Snipp</a></"
|
208 |
+
"li>\n"
|
209 |
+
"\t\t\t<li><a href=\"http://www.catswhocode.com/blog/snippets\" title=\"Cats "
|
210 |
+
"Who Code Snippet Library\">Cats Who Code</a></li>\n"
|
211 |
+
"\t\t\t<li><a href=\"http://www.wpfunction.me\">WP Function Me</a></li>\n"
|
212 |
+
"\t\t</ul>"
|
213 |
+
msgstr ""
|
214 |
+
"Tu je niekoľko odkazov na weby, kde môžete nájsť množstvo snippetov, "
|
215 |
+
"použiteľných aj na vašich stránkach.\n"
|
216 |
+
"\t\t<ul>\n"
|
217 |
+
"\t\t\t<li><a href=\"http://wp-snippets.com\" title=\"WordPress Snippets\">WP-"
|
218 |
+
"Snippets</a></li>\n"
|
219 |
+
"\t\t\t<li><a href=\"http://wpsnipp.com\" title=\"WP Snipp\">WP Snipp</a></"
|
220 |
+
"li>\n"
|
221 |
+
"\t\t\t<li><a href=\"http://www.catswhocode.com/blog/snippets\" title=\"Cats "
|
222 |
+
"Who Code Snippet Library\">Cats Who Code</a></li>\n"
|
223 |
+
"\t\t\t<li><a href=\"http://www.wpfunction.me\">WP Function Me</a></li>\n"
|
224 |
+
"\t\t</ul>"
|
225 |
+
|
226 |
+
#: ../admin/help/single.php:31
|
227 |
+
msgid ""
|
228 |
+
"More places to find snippets, as well as a selection of example snippets, "
|
229 |
+
"can be found in the <a href=\"http://code-snippets.bungeshea.com/docs/"
|
230 |
+
"finding-snippets/\">plugin documentation</a>"
|
231 |
+
msgstr ""
|
232 |
+
"Viac miest, kde nájdete snippety a niekoľko ukážok snippetov nájdete v <a "
|
233 |
+
"href=\"http://code-snippets.bungeshea.com/docs/finding-snippets/"
|
234 |
+
"\">dokumentácii modulu</a>"
|
235 |
+
|
236 |
+
#: ../admin/help/single.php:36
|
237 |
+
msgid "Adding Snippets"
|
238 |
+
msgstr "Ako pridať snippet?"
|
239 |
+
|
240 |
+
#: ../admin/help/single.php:38
|
241 |
+
msgid ""
|
242 |
+
"You need to fill out the name and code fields for your snippet to be added. "
|
243 |
+
"While the description field will add more information about how your snippet "
|
244 |
+
"works, what is does and where you found it, it is completely optional."
|
245 |
+
msgstr "Je potrebné vyplniť názov snippetu a vložiť jeho kód."
|
246 |
+
|
247 |
+
#: ../admin/help/single.php:39
|
248 |
+
msgid ""
|
249 |
+
"Please be sure to check that your snippet is valid PHP code and will not "
|
250 |
+
"produce errors before adding it through this page. While doing so will not "
|
251 |
+
"become active straight away, it will help to minimise the chance of a faulty "
|
252 |
+
"snippet becoming active on your site."
|
253 |
+
msgstr ""
|
254 |
+
"Prosím skontrolujte, či vaše snippety obsahujú overený PHP kód a nespôsobia "
|
255 |
+
"na tejto stránke chyby. Keďže nebudú hneď aktívne, nemusíte sa obávať "
|
256 |
+
"možného pádu stránky po ich nahratí."
|
257 |
+
|
258 |
+
#: ../admin/messages/import.php:32
|
259 |
+
msgid "An error occurred when processing the import file."
|
260 |
+
msgstr "Pri importe došlo ku chybe."
|
261 |
+
|
262 |
+
#: ../admin/messages/manage.php:14
|
263 |
+
msgid ""
|
264 |
+
"<strong>Warning:</strong> Safe mode is active and snippets will not execute! "
|
265 |
+
"Remove the <code>CODE_SNIPPETS_SAFE_MODE</code> constant from <code>wp-"
|
266 |
+
"config.php</code> to turn off safe mode. <a href=\"http://code-snippets."
|
267 |
+
"bungeshea.com/docs/safe-mode/\" target=\"_blank\">Help</a>"
|
268 |
+
msgstr ""
|
269 |
+
"<strong>Upozornenie:</strong> Safe mode je aktívny a snippety nebudú "
|
270 |
+
"fungovať! Odstráňte konštantu <code>CODE_SNIPPETS_SAFE_MODE</code> z "
|
271 |
+
"<code>wp-config.php</code> pre vypnutie safe mode. <a href=\"http://code-"
|
272 |
+
"snippets.bungeshea.com/docs/safe-mode/\" target=\"_blank\">Pomoc</a>"
|
273 |
+
|
274 |
+
#: ../admin/messages/manage.php:20
|
275 |
+
msgid "Snippet <strong>activated</strong>."
|
276 |
+
msgstr "Snippet <strong>aktivovaný</strong>."
|
277 |
+
|
278 |
+
#: ../admin/messages/manage.php:24
|
279 |
+
msgid "Selected snippets <strong>activated</strong>."
|
280 |
+
msgstr "Vybrané snippety <strong>aktivované</strong>."
|
281 |
+
|
282 |
+
#: ../admin/messages/manage.php:28
|
283 |
+
msgid "Snippet <strong>deactivated</strong>."
|
284 |
+
msgstr "Snippet <strong>deaktivovaný</strong>."
|
285 |
+
|
286 |
+
#: ../admin/messages/manage.php:32
|
287 |
+
msgid "Selected snippets <strong>deactivated</strong>."
|
288 |
+
msgstr "Vybrané snippety <strong>deaktivované</strong>."
|
289 |
+
|
290 |
+
#: ../admin/messages/manage.php:36
|
291 |
+
msgid "Snippet <strong>deleted</strong>."
|
292 |
+
msgstr "Snippet <strong>zmazaný</strong>."
|
293 |
+
|
294 |
+
#: ../admin/messages/manage.php:40
|
295 |
+
msgid "Selected snippets <strong>deleted</strong>."
|
296 |
+
msgstr "Vybrané snippety <strong>zmazané</strong>."
|
297 |
+
|
298 |
+
#: ../admin/messages/single.php:14
|
299 |
+
msgid "An error occurred when saving the snippet."
|
300 |
+
msgstr "Pri ukladaní snippetu došlo ku chybe."
|
301 |
+
|
302 |
+
#: ../admin/messages/single.php:18
|
303 |
+
msgid "Snippet <strong>updated</strong> and <strong>activated</strong>."
|
304 |
+
msgstr "Snippet <strong>aktualizovaný</strong> a <strong>aktivovaný</strong>."
|
305 |
+
|
306 |
+
#: ../admin/messages/single.php:22
|
307 |
+
msgid "Snippet <strong>added</strong> and <strong>activated</strong>."
|
308 |
+
msgstr "Snippet <strong>pridaný</strong> a <strong>aktivovaný</strong>."
|
309 |
+
|
310 |
+
#: ../admin/messages/single.php:26
|
311 |
+
msgid "Snippet <strong>updated</strong> and <strong>deactivated</strong>."
|
312 |
+
msgstr ""
|
313 |
+
"Snippet <strong>aktualizovaný</strong> a <strong>deaktivovaný</strong>."
|
314 |
+
|
315 |
+
#: ../admin/messages/single.php:30
|
316 |
+
msgid "Snippet <strong>updated</strong>."
|
317 |
+
msgstr "Snippet <strong>aktualizovaný</strong>."
|
318 |
+
|
319 |
+
#: ../admin/messages/single.php:34
|
320 |
+
msgid "Snippet <strong>added</strong>."
|
321 |
+
msgstr "Snippet <strong>pridaný</strong>."
|
322 |
+
|
323 |
+
#: ../admin/views/import.php:20 ../includes/class-admin.php:327
|
324 |
+
msgid "Import Snippets"
|
325 |
+
msgstr "Importovať snippety"
|
326 |
+
|
327 |
+
#: ../admin/views/import.php:24
|
328 |
+
msgid ""
|
329 |
+
"Howdy! Upload your Code Snippets export file and we’ll import the "
|
330 |
+
"snippets to this site."
|
331 |
+
msgstr ""
|
332 |
+
"Nahrajte súbor Code Snippets (.xml) a naimportujte snippety na túto stránku."
|
333 |
+
|
334 |
+
#: ../admin/views/import.php:26
|
335 |
+
#, php-format
|
336 |
+
msgid ""
|
337 |
+
"You will need to go to the <a href=\"%s\">Manage Snippets</a> page to "
|
338 |
+
"activate the imported snippets."
|
339 |
+
msgstr ""
|
340 |
+
"Po ukončení importu musíte ísť na stránku <a href=\"%s\">Spravovať snippety</"
|
341 |
+
"a> a aktivovať importované snippety."
|
342 |
+
|
343 |
+
#: ../admin/views/import.php:28
|
344 |
+
msgid ""
|
345 |
+
"Choose a Code Snippets (.xml) file to upload, then click Upload file and "
|
346 |
+
"import."
|
347 |
+
msgstr ""
|
348 |
+
"Zvoľte súbor Code Snippets (.xml) a kliknite na tlačidlo Nahrať súbor a "
|
349 |
+
"importovať."
|
350 |
+
|
351 |
+
#: ../admin/views/import.php:35
|
352 |
+
msgid "Choose a file from your computer:"
|
353 |
+
msgstr "Zvoľte súbor vo vašom počítači:"
|
354 |
+
|
355 |
+
#: ../admin/views/import.php:36
|
356 |
+
msgid "(Maximum size: 8MB)"
|
357 |
+
msgstr "(Maximálna veľkosť: 8MB)"
|
358 |
+
|
359 |
+
#: ../admin/views/import.php:42
|
360 |
+
msgid "Upload file and import"
|
361 |
+
msgstr "Nahrať súbor a importovať"
|
362 |
+
|
363 |
+
#: ../admin/views/manage.php:21 ../includes/class-admin.php:152
|
364 |
+
#: ../includes/class-admin.php:276 ../includes/class-admin.php:277
|
365 |
+
#: ../includes/class-admin.php:287
|
366 |
+
msgid "Snippets"
|
367 |
+
msgstr "Snippety"
|
368 |
+
|
369 |
+
#: ../admin/views/manage.php:39
|
370 |
+
msgid "Search Installed Snippets"
|
371 |
+
msgstr "Hľadať nainštalované snippety"
|
372 |
+
|
373 |
+
#: ../admin/views/single.php:29 ../includes/class-admin.php:299
|
374 |
+
msgid "Edit Snippet"
|
375 |
+
msgstr "Upraviť snippety"
|
376 |
+
|
377 |
+
#: ../admin/views/single.php:37 ../includes/class-admin.php:299
|
378 |
+
msgid "Add New Snippet"
|
379 |
+
msgstr "Pridať nový snippet"
|
380 |
+
|
381 |
+
#: ../admin/views/single.php:53 ../admin/views/single.php:54
|
382 |
+
msgid "Name (short title)"
|
383 |
+
msgstr "Názov (krátky nadpis)"
|
384 |
+
|
385 |
+
#: ../admin/views/single.php:59
|
386 |
+
msgid "Code"
|
387 |
+
msgstr "Kód"
|
388 |
+
|
389 |
+
#: ../admin/views/single.php:85
|
390 |
+
msgid "Save Changes & Activate"
|
391 |
+
msgstr "Uložiť zmeny a aktivovať"
|
392 |
+
|
393 |
+
#: ../admin/views/single.php:91
|
394 |
+
msgid "Save Changes & Deactivate"
|
395 |
+
msgstr "Uložiť zmeny a deaktivovať"
|
396 |
+
|
397 |
+
#: ../admin/views/single.php:100 ../includes/class-list-table.php:166
|
398 |
+
#: ../includes/class-list-table.php:266
|
399 |
+
msgid "Export"
|
400 |
+
msgstr "Export"
|
401 |
+
|
402 |
+
#: ../admin/views/single.php:107
|
403 |
+
msgid ""
|
404 |
+
"You are about to permanently delete this snippet.\n"
|
405 |
+
"'Cancel' to stop, 'OK' to delete."
|
406 |
+
msgstr ""
|
407 |
+
"Chcete navždy zmazať tento snippet. \n"
|
408 |
+
"'Cancel' pre zrušenie, 'OK' pre zmazanie."
|
409 |
+
|
410 |
+
#: ../admin/views/single.php:112 ../includes/class-list-table.php:175
|
411 |
+
#: ../includes/class-list-table.php:267
|
412 |
+
msgid "Delete"
|
413 |
+
msgstr "Zmazať"
|
414 |
+
|
415 |
+
#: ../includes/class-admin.php:185
|
416 |
+
msgid "Code Snippets"
|
417 |
+
msgstr "Code Snippets"
|
418 |
+
|
419 |
+
#: ../includes/class-admin.php:186
|
420 |
+
msgid "Import snippets from a Code Snippets export file"
|
421 |
+
msgstr "Importovať snippety zo súboru Code Snippets"
|
422 |
+
|
423 |
+
#: ../includes/class-admin.php:246
|
424 |
+
msgid "You are not authorized to access this page."
|
425 |
+
msgstr "Nemáte prístup na túto stránku."
|
426 |
+
|
427 |
+
#: ../includes/class-admin.php:288 ../includes/class-admin.php:695
|
428 |
+
msgid "Manage"
|
429 |
+
msgstr "Spravovať"
|
430 |
+
|
431 |
+
#: ../includes/class-admin.php:300 ../includes/class-list-table.php:160
|
432 |
+
msgid "Edit"
|
433 |
+
msgstr "Upraviť"
|
434 |
+
|
435 |
+
#: ../includes/class-admin.php:300
|
436 |
+
msgid "Add New"
|
437 |
+
msgstr "Pridať nový"
|
438 |
+
|
439 |
+
#: ../includes/class-admin.php:328
|
440 |
+
msgid "Import"
|
441 |
+
msgstr "Import"
|
442 |
+
|
443 |
+
#: ../includes/class-admin.php:663 ../includes/class-list-table.php:228
|
444 |
+
msgid "Description"
|
445 |
+
msgstr "Popis"
|
446 |
+
|
447 |
+
#: ../includes/class-admin.php:694
|
448 |
+
msgid "Manage your existing snippets"
|
449 |
+
msgstr "Spravovať existujúce snippety"
|
450 |
+
|
451 |
+
#: ../includes/class-admin.php:722
|
452 |
+
msgid "Visit the WordPress.org plugin page"
|
453 |
+
msgstr "Navštíviť stránku modulu na WordPress.org"
|
454 |
+
|
455 |
+
#: ../includes/class-admin.php:723
|
456 |
+
msgid "About"
|
457 |
+
msgstr "O module"
|
458 |
+
|
459 |
+
#: ../includes/class-admin.php:727
|
460 |
+
msgid "Visit the support forums"
|
461 |
+
msgstr "Navštíviť fórum podpory"
|
462 |
+
|
463 |
+
#: ../includes/class-admin.php:728
|
464 |
+
msgid "Support"
|
465 |
+
msgstr "Podpora"
|
466 |
+
|
467 |
+
#: ../includes/class-admin.php:732
|
468 |
+
msgid "Support this plugin's development"
|
469 |
+
msgstr "Podporiť vývoj tohoto modulu"
|
470 |
+
|
471 |
+
#: ../includes/class-admin.php:733
|
472 |
+
msgid "Donate"
|
473 |
+
msgstr "Podporiť"
|
474 |
+
|
475 |
+
#: ../includes/class-admin.php:764
|
476 |
+
msgid ""
|
477 |
+
"<strong>Have feedback on Code Snippets?</strong> Please take the time to "
|
478 |
+
"answer a short survey on how you use this plugin and what you'd like to see "
|
479 |
+
"changed or added in the future."
|
480 |
+
msgstr ""
|
481 |
+
"<strong>Máte spätnú väzbu na Code Snippets?</strong>Prosím, nájdite si čas a "
|
482 |
+
"zúčastnite sa prieskumu o tom, ako používate tento modul a čo by ste na ňom "
|
483 |
+
"v budúcnosti zmenili, alebo čím ho doplnili."
|
484 |
+
|
485 |
+
#: ../includes/class-admin.php:767
|
486 |
+
msgid "Take the survey now"
|
487 |
+
msgstr "Zúčastnite sa prieskumu"
|
488 |
+
|
489 |
+
#: ../includes/class-list-table.php:49
|
490 |
+
msgid "Snippets per page"
|
491 |
+
msgstr "Počet snippetov na stránke"
|
492 |
+
|
493 |
+
#: ../includes/class-list-table.php:141 ../includes/class-list-table.php:265
|
494 |
+
msgid "Network Deactivate"
|
495 |
+
msgstr "Sieť deaktivovaná"
|
496 |
+
|
497 |
+
#: ../includes/class-list-table.php:141 ../includes/class-list-table.php:265
|
498 |
+
msgid "Deactivate"
|
499 |
+
msgstr "Deaktivovať"
|
500 |
+
|
501 |
+
#: ../includes/class-list-table.php:150 ../includes/class-list-table.php:264
|
502 |
+
msgid "Network Activate"
|
503 |
+
msgstr "Sieť aktivovaná"
|
504 |
+
|
505 |
+
#: ../includes/class-list-table.php:150 ../includes/class-list-table.php:264
|
506 |
+
msgid "Activate"
|
507 |
+
msgstr "Aktivovať"
|
508 |
+
|
509 |
+
#: ../includes/class-list-table.php:182
|
510 |
+
msgid ""
|
511 |
+
"You are about to permanently delete the selected item.\n"
|
512 |
+
"\t\t\t\t'Cancel' to stop, 'OK' to delete."
|
513 |
+
msgstr ""
|
514 |
+
"Chcete navždy zmazať túto položku. \n"
|
515 |
+
"\t\t\t\t'Cancel' pre zrušenie, 'OK' úre zmazanie."
|
516 |
+
|
517 |
+
#: ../includes/class-list-table.php:190
|
518 |
+
#, php-format
|
519 |
+
msgid "Untitled #%d"
|
520 |
+
msgstr "Bez názvu #%d"
|
521 |
+
|
522 |
+
#: ../includes/class-list-table.php:226
|
523 |
+
msgid "Name"
|
524 |
+
msgstr "Názov"
|
525 |
+
|
526 |
+
#: ../includes/class-list-table.php:227
|
527 |
+
msgid "ID"
|
528 |
+
msgstr "ID"
|
529 |
+
|
530 |
+
#: ../includes/class-list-table.php:268
|
531 |
+
msgid "Export to PHP"
|
532 |
+
msgstr "Export do PHP"
|
533 |
+
|
534 |
+
#: ../includes/class-list-table.php:342
|
535 |
+
msgid "Filter"
|
536 |
+
msgstr "Filter"
|
537 |
+
|
538 |
+
#: ../includes/class-list-table.php:350
|
539 |
+
msgid "Clear List"
|
540 |
+
msgstr "Vyčistiť zoznam"
|
541 |
+
|
542 |
+
#: ../includes/class-list-table.php:492
|
543 |
+
#, php-format
|
544 |
+
msgid ""
|
545 |
+
"You do not appear to have any snippets available at this time. <a href=\"%s"
|
546 |
+
"\">Add New→</a>"
|
547 |
+
msgstr ""
|
548 |
+
"Momentálne nemáte k dispozícii žiadne snippety. <a href=\"%s\">Pridať nový "
|
549 |
+
"→</a>"
|
550 |
+
|
551 |
+
#: ../includes/class-list-table.php:676
|
552 |
+
msgid "Search results"
|
553 |
+
msgstr "Výsledky hľadania"
|
554 |
+
|
555 |
+
#: ../includes/class-list-table.php:679
|
556 |
+
#, php-format
|
557 |
+
msgid " for “%s”"
|
558 |
+
msgstr "pre “%s”"
|
559 |
+
|
560 |
+
#: ../includes/class-list-table.php:685
|
561 |
+
msgid "Clear Filters"
|
562 |
+
msgstr "Vyčistiť filtre"
|
563 |
+
|
564 |
+
#~ msgid "Manage Snippets"
|
565 |
+
#~ msgstr "Spravovať snippety"
|
566 |
+
|
567 |
+
#~ msgid "Sorry, you’re not allowed to edit snippets"
|
568 |
+
#~ msgstr "Prepáčte, ale nemáte oprávnenie na úpravu snippetov"
|
569 |
+
|
570 |
+
#~ msgid "Please provide a name for the snippet and its code."
|
571 |
+
#~ msgstr "Prosím, uveďte názov snippetu a vložte jeho kód."
|
572 |
+
|
573 |
+
#~ msgid ""
|
574 |
+
#~ "Enter or paste the snippet code without the <code><?php</code> and "
|
575 |
+
#~ "<code>?></code> tags."
|
576 |
+
#~ msgstr ""
|
577 |
+
#~ "Napíšte alebo skopírujte kód snippetu bez značiek <code><?php</code> a "
|
578 |
+
#~ "<code>?></code>."
|
579 |
+
|
580 |
+
#~ msgid "(Optional)"
|
581 |
+
#~ msgstr "(voliteľné)"
|
582 |
+
|
583 |
+
#~ msgid "Save"
|
584 |
+
#~ msgstr "Uložiť"
|
585 |
+
|
586 |
+
#~ msgid "Cancel"
|
587 |
+
#~ msgstr "Zrušiť"
|
588 |
+
|
589 |
+
#~ msgid ""
|
590 |
+
#~ "Make sure that you don't add the <code><?php</code>, <code><?</"
|
591 |
+
#~ "code> or <code>?></code> the beginning and end of the code. You can "
|
592 |
+
#~ "however use these tags in the code to stop and start PHP sections"
|
593 |
+
#~ msgstr ""
|
594 |
+
#~ "Uistite sa, že ste nevložili <code><?php</code>, <code><?</code> "
|
595 |
+
#~ "alebo <code>?></code> v priebehu alebo na konci kódu. Tieto značky "
|
596 |
+
#~ "však môžete použiť pre zastavenie alebo spustenie úsekov PHP."
|
Binary file
|
@@ -0,0 +1,571 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# This file is distributed under the same license as the Code Snippets package.
|
2 |
+
msgid ""
|
3 |
+
msgstr ""
|
4 |
+
"PO-Revision-Date: 2014-08-11 10:18+0100\n"
|
5 |
+
"MIME-Version: 1.0\n"
|
6 |
+
"Content-Type: text/plain; charset=UTF-8\n"
|
7 |
+
"Content-Transfer-Encoding: 8bit\n"
|
8 |
+
"Plural-Forms: nplurals=2; plural=n != 1;\n"
|
9 |
+
"X-Generator: Poedit 1.5.5\n"
|
10 |
+
"Project-Id-Version: Code Snippets\n"
|
11 |
+
"POT-Creation-Date: \n"
|
12 |
+
"Last-Translator: jelena kovacevic <jecajeca260@gmail.com>\n"
|
13 |
+
"Language-Team: \n"
|
14 |
+
|
15 |
+
#: code-snippets.php:0 code-snippets.php:262
|
16 |
+
msgid "Code Snippets"
|
17 |
+
msgstr "Code Snippets"
|
18 |
+
|
19 |
+
#: code-snippets.php:0
|
20 |
+
msgid ""
|
21 |
+
"An easy, clean and simple way to add code snippets to your site. No need to "
|
22 |
+
"edit to your theme's functions.php file again!"
|
23 |
+
msgstr ""
|
24 |
+
"Lak, jednostavan i jasan način da svom sajtu dodate dodate isečke koda! Nema "
|
25 |
+
"potrebe da ponovo uređujete .php datoteku sa funkcijama teme! "
|
26 |
+
|
27 |
+
#: code-snippets.php:0
|
28 |
+
msgid "Shea Bunge"
|
29 |
+
msgstr "Shea Bunge"
|
30 |
+
|
31 |
+
#: code-snippets.php:0
|
32 |
+
msgid "http://bungeshea.com"
|
33 |
+
msgstr "http://bungeshea.com"
|
34 |
+
|
35 |
+
#: code-snippets.php:577 code-snippets.php:578 code-snippets.php:588
|
36 |
+
#: includes/admin/manage.php:36
|
37 |
+
msgid "Snippets"
|
38 |
+
msgstr "Isečci"
|
39 |
+
|
40 |
+
#: code-snippets.php:612 code-snippets.php:1145 includes/admin/single.php:45
|
41 |
+
msgid "Add New Snippet"
|
42 |
+
msgstr "Dodaj novi isečak"
|
43 |
+
|
44 |
+
#: code-snippets.php:613
|
45 |
+
msgid "Add New"
|
46 |
+
msgstr "Dodaj novi"
|
47 |
+
|
48 |
+
#: code-snippets.php:641 includes/admin/import.php:34
|
49 |
+
msgid "Import Snippets"
|
50 |
+
msgstr "Uvezi isečke"
|
51 |
+
|
52 |
+
#: code-snippets.php:642
|
53 |
+
msgid "Import"
|
54 |
+
msgstr "Uvezi"
|
55 |
+
|
56 |
+
#: code-snippets.php:601 code-snippets.php:1146 includes/admin/single.php:37
|
57 |
+
msgid "Edit Snippet"
|
58 |
+
msgstr "Uredi isečak"
|
59 |
+
|
60 |
+
#: code-snippets.php:1465
|
61 |
+
msgid "Manage your existing snippets"
|
62 |
+
msgstr "Upravljaj svojim postojećim isečcima"
|
63 |
+
|
64 |
+
#: code-snippets.php:589 code-snippets.php:1466
|
65 |
+
msgid "Manage"
|
66 |
+
msgstr "Upravljaj"
|
67 |
+
|
68 |
+
#: code-snippets.php:1486
|
69 |
+
msgid "Visit the WordPress.org plugin page"
|
70 |
+
msgstr "Posetite stranicu WordPress.org plugin"
|
71 |
+
|
72 |
+
#: code-snippets.php:1487
|
73 |
+
msgid "About"
|
74 |
+
msgstr "O"
|
75 |
+
|
76 |
+
#: code-snippets.php:1491
|
77 |
+
msgid "Visit the support forums"
|
78 |
+
msgstr "Posetite forume za podršku"
|
79 |
+
|
80 |
+
#: code-snippets.php:1492
|
81 |
+
msgid "Support"
|
82 |
+
msgstr "Podrška"
|
83 |
+
|
84 |
+
#: code-snippets.php:1496
|
85 |
+
msgid "Support this plugin's development"
|
86 |
+
msgstr "Podržite razvoj ovog plugin-a"
|
87 |
+
|
88 |
+
#: code-snippets.php:1497
|
89 |
+
msgid "Donate"
|
90 |
+
msgstr "Donirajte"
|
91 |
+
|
92 |
+
#: includes/admin/import.php:38
|
93 |
+
msgid ""
|
94 |
+
"Howdy! Upload your Code Snippets export file and we’ll import the "
|
95 |
+
"snippets to this site."
|
96 |
+
msgstr ""
|
97 |
+
"Ćao! Otpremite svoju izvoznu datoteku sa isečcima koda, a mi’ ćemo "
|
98 |
+
"uvesti isečke na sajt."
|
99 |
+
|
100 |
+
#: includes/admin/import.php:40
|
101 |
+
msgid ""
|
102 |
+
"You will need to go to the <a href=\"%s\">Manage Snippets</a> page to "
|
103 |
+
"activate the imported snippets."
|
104 |
+
msgstr ""
|
105 |
+
"Da biste aktivirali uvezene isečke, idite na stranicu: <a href=\"%s\">Manage "
|
106 |
+
"Snippets</a>. "
|
107 |
+
|
108 |
+
#: includes/admin/import.php:42
|
109 |
+
msgid ""
|
110 |
+
"Choose a Code Snippets (.xml) file to upload, then click Upload file and "
|
111 |
+
"import."
|
112 |
+
msgstr ""
|
113 |
+
"Izaberite (.xml) datoteku sa isečcima koda za otpremanje, a zatim kliknite "
|
114 |
+
"na Otpremi datoteku i Uvezi."
|
115 |
+
|
116 |
+
#: includes/admin/import.php:46
|
117 |
+
msgid "Choose a file from your computer:"
|
118 |
+
msgstr "Izaberite datoteku sa svog kompjutera:"
|
119 |
+
|
120 |
+
#: includes/admin/import.php:46
|
121 |
+
msgid "(Maximum size: 8MB)"
|
122 |
+
msgstr "(Maksimalna veličina: 8MB)"
|
123 |
+
|
124 |
+
#: includes/admin/import.php:55
|
125 |
+
msgid "Upload file and import"
|
126 |
+
msgstr "Otpremi datoteku i uvezi"
|
127 |
+
|
128 |
+
#: includes/admin/manage.php:21
|
129 |
+
msgid "Snippet <strong>activated</strong>."
|
130 |
+
msgstr "Isečak <strong>aktiviran</strong>."
|
131 |
+
|
132 |
+
#: includes/admin/manage.php:23
|
133 |
+
msgid "Selected snippets <strong>activated</strong>."
|
134 |
+
msgstr "Odabrani isečci <strong>aktivirani</strong>."
|
135 |
+
|
136 |
+
#: includes/admin/manage.php:25
|
137 |
+
msgid "Snippet <strong>deactivated</strong>."
|
138 |
+
msgstr "Isečak <strong>deaktiviran</strong>."
|
139 |
+
|
140 |
+
#: includes/admin/manage.php:27
|
141 |
+
msgid "Selected snippets <strong>deactivated</strong>."
|
142 |
+
msgstr "Odabrani isečci <strong>deaktivirani</strong>."
|
143 |
+
|
144 |
+
#: includes/admin/manage.php:29
|
145 |
+
msgid "Snippet <strong>deleted</strong>."
|
146 |
+
msgstr "Isečak <strong>obrisan</strong>."
|
147 |
+
|
148 |
+
#: includes/admin/manage.php:31
|
149 |
+
msgid "Selected snippets <strong>deleted</strong>."
|
150 |
+
msgstr "Odabrani isečci <strong>obrisani</strong>."
|
151 |
+
|
152 |
+
#: includes/admin/manage.php:38 includes/admin/single.php:42
|
153 |
+
msgctxt "snippet"
|
154 |
+
msgid "Add New"
|
155 |
+
msgstr "Dodaj novi"
|
156 |
+
|
157 |
+
#: includes/admin/manage.php:47
|
158 |
+
msgid "Search Installed Snippets"
|
159 |
+
msgstr "Pretraži instalirane isečke"
|
160 |
+
|
161 |
+
#: includes/admin/single.php:22
|
162 |
+
msgid "Please provide a name for the snippet and its code."
|
163 |
+
msgstr "Unesite naziv isečka i njegov kod."
|
164 |
+
|
165 |
+
#: includes/admin/single.php:28
|
166 |
+
msgid "Snippet <strong>updated</strong>."
|
167 |
+
msgstr "Isečak <strong>ažuriran</strong>."
|
168 |
+
|
169 |
+
#: includes/admin/single.php:30
|
170 |
+
msgid "Snippet <strong>added</strong>."
|
171 |
+
msgstr "Isećak <strong>dodat</strong>."
|
172 |
+
|
173 |
+
#: includes/admin/single.php:55 includes/admin/single.php:56
|
174 |
+
msgid "Name (short title)"
|
175 |
+
msgstr "Naziv (kratak naslov)"
|
176 |
+
|
177 |
+
#: includes/admin/single.php:61
|
178 |
+
msgid "Code"
|
179 |
+
msgstr "Kod"
|
180 |
+
|
181 |
+
#: code-snippets.php:1433 includes/class-list-table.php:189
|
182 |
+
msgid "Description"
|
183 |
+
msgstr "Opsi"
|
184 |
+
|
185 |
+
#: code-snippets.php:1434
|
186 |
+
msgid "(Optional)"
|
187 |
+
msgstr "(Opcioni)"
|
188 |
+
|
189 |
+
#: includes/class-list-table.php:36
|
190 |
+
msgid "Snippets per page"
|
191 |
+
msgstr "Isečci po stranici"
|
192 |
+
|
193 |
+
#: code-snippets.php:1118 includes/class-list-table.php:127
|
194 |
+
#: includes/class-list-table.php:213
|
195 |
+
msgid "Network Deactivate"
|
196 |
+
msgstr "Deaktiviraj mrežu"
|
197 |
+
|
198 |
+
#: code-snippets.php:1118 includes/class-list-table.php:127
|
199 |
+
#: includes/class-list-table.php:213
|
200 |
+
msgid "Deactivate"
|
201 |
+
msgstr "Deaktiviraj"
|
202 |
+
|
203 |
+
#: code-snippets.php:1127 includes/class-list-table.php:137
|
204 |
+
#: includes/class-list-table.php:212
|
205 |
+
msgid "Network Activate"
|
206 |
+
msgstr "Aktiviraj mrežu"
|
207 |
+
|
208 |
+
#: code-snippets.php:1127 includes/class-list-table.php:137
|
209 |
+
#: includes/class-list-table.php:212
|
210 |
+
msgid "Activate"
|
211 |
+
msgstr "Aktiviraj"
|
212 |
+
|
213 |
+
#: includes/class-list-table.php:187
|
214 |
+
msgid "Name"
|
215 |
+
msgstr "Naziv"
|
216 |
+
|
217 |
+
#: includes/class-list-table.php:188
|
218 |
+
msgid "ID"
|
219 |
+
msgstr "ID"
|
220 |
+
|
221 |
+
#: includes/class-list-table.php:147 includes/class-list-table.php:214
|
222 |
+
msgid "Export"
|
223 |
+
msgstr "Izvezi"
|
224 |
+
|
225 |
+
#: includes/class-list-table.php:155 includes/class-list-table.php:215
|
226 |
+
msgid "Delete"
|
227 |
+
msgstr "Obriši"
|
228 |
+
|
229 |
+
#: includes/class-list-table.php:216
|
230 |
+
msgid "Export to PHP"
|
231 |
+
msgstr "Izvezi u PHP"
|
232 |
+
|
233 |
+
#: includes/class-list-table.php:236
|
234 |
+
msgid "All <span class=\"count\">(%s)</span>"
|
235 |
+
msgid_plural "All <span class=\"count\">(%s)</span>"
|
236 |
+
msgstr[0] ""
|
237 |
+
msgstr[1] ""
|
238 |
+
|
239 |
+
#: includes/class-list-table.php:239
|
240 |
+
msgid "Active <span class=\"count\">(%s)</span>"
|
241 |
+
msgid_plural "Active <span class=\"count\">(%s)</span>"
|
242 |
+
msgstr[0] ""
|
243 |
+
msgstr[1] ""
|
244 |
+
|
245 |
+
#: includes/class-list-table.php:242
|
246 |
+
msgid "Recently Active <span class=\"count\">(%s)</span>"
|
247 |
+
msgid_plural "Recently Active <span class=\"count\">(%s)</span>"
|
248 |
+
msgstr[0] ""
|
249 |
+
msgstr[1] ""
|
250 |
+
|
251 |
+
#: includes/class-list-table.php:245
|
252 |
+
msgid "Inactive <span class=\"count\">(%s)</span>"
|
253 |
+
msgid_plural "Inactive <span class=\"count\">(%s)</span>"
|
254 |
+
msgstr[0] ""
|
255 |
+
msgstr[1] ""
|
256 |
+
|
257 |
+
#: includes/class-list-table.php:279
|
258 |
+
msgid "Clear List"
|
259 |
+
msgstr "Obriši listu"
|
260 |
+
|
261 |
+
#: includes/class-list-table.php:374
|
262 |
+
msgid ""
|
263 |
+
"You do not appear to have any snippets available at this time. <a href=\"%s"
|
264 |
+
"\">Add New→</a>"
|
265 |
+
msgstr ""
|
266 |
+
"Čini se da trenutno nemate raspoložive isečke. <a href=\"%s\">Add New→"
|
267 |
+
"</a>"
|
268 |
+
|
269 |
+
#: includes/help/import.php:5 includes/help/manage.php:5
|
270 |
+
#: includes/help/single.php:5
|
271 |
+
msgid "Overview"
|
272 |
+
msgstr "Pregled"
|
273 |
+
|
274 |
+
#: includes/help/import.php:7
|
275 |
+
msgid ""
|
276 |
+
"Snippets are similar to plugins - they both extend and expand the "
|
277 |
+
"functionality of WordPress. Snippets are more light-weight, just a few lines "
|
278 |
+
"of code, and do not put as much load on your server. Here you can load "
|
279 |
+
"snippets from a Code Snippets (.xml) import file into the database with your "
|
280 |
+
"existing snippets."
|
281 |
+
msgstr ""
|
282 |
+
"Isečci liče na plugin-ove - i jedni i drugi proširuju funkcije WordPress-a. "
|
283 |
+
"Isečci su lakši - sadrže samo nekoliko linija koda i ne opterećuju server. "
|
284 |
+
"Ovde možete učitati isečke iz Code Snippets (.xml) datoteke za uvoz u bazu "
|
285 |
+
"podataka sa svojim postojećim isečcima."
|
286 |
+
|
287 |
+
#: includes/help/import.php:12
|
288 |
+
msgid "Importing"
|
289 |
+
msgstr "Uvoz u toku..."
|
290 |
+
|
291 |
+
#: includes/help/import.php:15
|
292 |
+
msgid ""
|
293 |
+
"Snippets will be added to the database along with your existing snippets. "
|
294 |
+
"Regardless of whether the snippets were active on the previous site, "
|
295 |
+
"imported snippets are always inactive until activated using the <a href=\"%s"
|
296 |
+
"\">Manage Snippets</a> page.</p>"
|
297 |
+
msgstr ""
|
298 |
+
"Isečci će biti dodati bazi podataka zajedno s vašim postojećim isečcima. Bez "
|
299 |
+
"obzira na to da li su isečci bili aktivni na prethodnom sajtu, uvezeni "
|
300 |
+
"isečci uvek su neaktivni sve dok se ne aktiviraju uz pomoć stranice: <a href="
|
301 |
+
"\"%s\">Manage Snippets</a>."
|
302 |
+
|
303 |
+
#: includes/help/import.php:20
|
304 |
+
msgid "Exporting"
|
305 |
+
msgstr "Izvoz u toku..."
|
306 |
+
|
307 |
+
#: includes/help/import.php:22
|
308 |
+
msgid ""
|
309 |
+
"You can save your snippets to a Code Snippets (.xml) export file using the "
|
310 |
+
"<a href=\"%s\">Manage Snippets</a> page."
|
311 |
+
msgstr ""
|
312 |
+
"Možete sačuvati svoje isečke u Code Snippets (.xml) datoteci sa isečcima uz "
|
313 |
+
"pomoć stranice <a href=\"%s\">Manage Snippets</a>."
|
314 |
+
|
315 |
+
#: includes/help/import.php:26 includes/help/manage.php:27
|
316 |
+
#: includes/help/single.php:31
|
317 |
+
msgid "For more information:"
|
318 |
+
msgstr "Za više informacija:"
|
319 |
+
|
320 |
+
#: includes/help/import.php:27 includes/help/single.php:32
|
321 |
+
msgid ""
|
322 |
+
"<a href=\"http://wordpress.org/plugins/code-snippets\" target=\"_blank"
|
323 |
+
"\">WordPress Extend</a>"
|
324 |
+
msgstr ""
|
325 |
+
"<a href=\"http://wordpress.org/plugins/code-snippets\" target=\"_blank"
|
326 |
+
"\">WordPress Extend</a>"
|
327 |
+
|
328 |
+
#: includes/help/import.php:28 includes/help/manage.php:29
|
329 |
+
#: includes/help/single.php:33
|
330 |
+
msgid ""
|
331 |
+
"<a href=\"http://wordpress.org/support/plugin/code-snippets\" target=\"_blank"
|
332 |
+
"\">Support Forums</a>"
|
333 |
+
msgstr ""
|
334 |
+
"<a href=\"http://wordpress.org/support/plugin/code-snippets\" target=\"_blank"
|
335 |
+
"\">Support Forums</a>"
|
336 |
+
|
337 |
+
#: includes/help/manage.php:7
|
338 |
+
msgid ""
|
339 |
+
"Snippets are similar to plugins - they both extend and expand the "
|
340 |
+
"functionality of WordPress. Snippets are more light-weight, just a few lines "
|
341 |
+
"of code, and do not put as much load on your server. Here you can manage "
|
342 |
+
"your existing snippets and preform tasks on them such as activating, "
|
343 |
+
"deactivating, deleting and exporting."
|
344 |
+
msgstr ""
|
345 |
+
"Isečci liče na plugin-ove - i jedni i drugi proširuju funkcije WordPress-a. "
|
346 |
+
"Isečci su lakši - sadrže samo nekoliko linija koda i ne opterećuju server. "
|
347 |
+
"Ovde možete upravljati svojim postojećim isečcima i izvoditi operacije na "
|
348 |
+
"njima, kao što su: aktiviranje, deaktiviranje, brisanje i izvoz."
|
349 |
+
|
350 |
+
#: includes/help/manage.php:12
|
351 |
+
msgid "Safe Mode"
|
352 |
+
msgstr "Bezbedan režim"
|
353 |
+
|
354 |
+
#: includes/help/manage.php:14
|
355 |
+
msgid ""
|
356 |
+
"Be sure to check your snippets for errors before you activate them, as a "
|
357 |
+
"faulty snippet could bring your whole blog down. If your site starts doing "
|
358 |
+
"strange things, deactivate all your snippets and activate them one at a time."
|
359 |
+
msgstr ""
|
360 |
+
"Proverite da li u vašim isečcima ima grešaka pre nego što ih aktivirate jer "
|
361 |
+
"isečak sa greškom može da vam sruši ceo blog. Ako vam se sajt čudno ponaša, "
|
362 |
+
"deaktivirajte sve isečke i aktivirajte jedan po jedan."
|
363 |
+
|
364 |
+
#: includes/help/manage.php:20
|
365 |
+
msgid "Uninstall"
|
366 |
+
msgstr "Deinstaliraj"
|
367 |
+
|
368 |
+
#: includes/help/manage.php:22
|
369 |
+
msgid ""
|
370 |
+
"When you delete Code Snippets through the Plugins menu in WordPress it will "
|
371 |
+
"clear up the <code>%1$s</code> table and a few other bits of data stored in "
|
372 |
+
"the database. If you want to keep this data (ie: you are only temporally "
|
373 |
+
"uninstalling Code Snippets) then remove the <code>%2$s</code> folder using "
|
374 |
+
"FTP."
|
375 |
+
msgstr ""
|
376 |
+
"Kad brišete isečke koda kroz Plugins meni u WordPress-u, obrisaće vam se "
|
377 |
+
"<code>%1$s</code> tabela i još nekoliko bitova podataka sačuvanih u bazi "
|
378 |
+
"podataka. Ako želite da zadržite ove podatke (tj. ako samo privremeno "
|
379 |
+
"deinstalirate Code Snippets), uklonite <code>%2$s</code> folder koristeći "
|
380 |
+
"FTP."
|
381 |
+
|
382 |
+
#: includes/help/manage.php:23
|
383 |
+
msgid ""
|
384 |
+
"Even if you're sure that you don't want to use Code Snippets ever again on "
|
385 |
+
"this WordPress installation, you may want to use the export feature to back "
|
386 |
+
"up your snippets."
|
387 |
+
msgstr ""
|
388 |
+
"Čak i ako ste sigurni kako nikad više nećete poželeti da koristite Code "
|
389 |
+
"Snippets na ovoj WordPress instalaciji, možda ćete hteti da koristite "
|
390 |
+
"funkciju izvoza da biste obezbedili podršku za svoje isečke. "
|
391 |
+
|
392 |
+
#: includes/help/manage.php:28
|
393 |
+
msgid ""
|
394 |
+
"<a href=\"http://wordpress.org/plugins/code-snippets\" target=\"_blank"
|
395 |
+
"\">WordPress Extend</a></p>"
|
396 |
+
msgstr ""
|
397 |
+
"<a href=\"http://wordpress.org/plugins/code-snippets\" target=\"_blank"
|
398 |
+
"\">WordPress Extend</a></p>"
|
399 |
+
|
400 |
+
#: includes/help/single.php:7
|
401 |
+
msgid ""
|
402 |
+
"Snippets are similar to plugins - they both extend and expand the "
|
403 |
+
"functionality of WordPress. Snippets are more light-weight, just a few lines "
|
404 |
+
"of code, and do not put as much load on your server. Here you can add a new "
|
405 |
+
"snippet, or edit an existing one."
|
406 |
+
msgstr ""
|
407 |
+
"Isečci liče na plugin-ove - i jedni i drugi proširuju funkcije WordPress-a. "
|
408 |
+
"Isečci su lakši - sadrže samo nekoliko linija koda i ne opterećuju server. "
|
409 |
+
"Ovde možete dodati novi isečak ili urediti postojeći."
|
410 |
+
|
411 |
+
#: includes/help/single.php:11
|
412 |
+
msgid "Finding Snippets"
|
413 |
+
msgstr "Pretraživanje isečaka"
|
414 |
+
|
415 |
+
#: includes/help/single.php:13
|
416 |
+
msgid ""
|
417 |
+
"Here are some links to websites which host a large number of snippets that "
|
418 |
+
"you can add to your site.\n"
|
419 |
+
"\t\t<ul>\n"
|
420 |
+
"\t\t\t<li><a href=\"http://wp-snippets.com\" title=\"WordPress Snippets\">WP-"
|
421 |
+
"Snippets</a></li>\n"
|
422 |
+
"\t\t\t<li><a href=\"http://wpsnipp.com\" title=\"WP Snipp\">WP Snipp</a></"
|
423 |
+
"li>\n"
|
424 |
+
"\t\t\t<li><a href=\"http://www.catswhocode.com/blog/snippets\" title=\"Cats "
|
425 |
+
"Who Code Snippet Library\">Cats Who Code</a></li>\n"
|
426 |
+
"\t\t\t<li><a href=\"http://www.wpfunction.me\">WP Function Me</a></li>\n"
|
427 |
+
"\t\t</ul>"
|
428 |
+
msgstr ""
|
429 |
+
"Navedeni su linkovi za web sajtove sa velikim brojem isečaka koje možete "
|
430 |
+
"dodati svom sajtu: .\n"
|
431 |
+
"\t\t<ul>\n"
|
432 |
+
"\t\t\t<li><a href=\"http://wp-snippets.com\" title=\"WordPress Snippets\">WP-"
|
433 |
+
"Snippets</a></li>\n"
|
434 |
+
"\t\t\t<li><a href=\"http://wpsnipp.com\" title=\"WP Snipp\">WP Snipp</a></"
|
435 |
+
"li>\n"
|
436 |
+
"\t\t\t<li><a href=\"http://www.catswhocode.com/blog/snippets\" title=\"Cats "
|
437 |
+
"Who Code Snippet Library\">Cats Who Code</a></li>\n"
|
438 |
+
"\t\t\t<li><a href=\"http://www.wpfunction.me\">WP Function Me</a></li>\n"
|
439 |
+
"\t\t</ul>"
|
440 |
+
|
441 |
+
#: includes/help/single.php:24
|
442 |
+
msgid "Adding Snippets"
|
443 |
+
msgstr "Dodavanje isečaka"
|
444 |
+
|
445 |
+
#: includes/help/single.php:26
|
446 |
+
msgid ""
|
447 |
+
"You need to fill out the name and code fields for your snippet to be added. "
|
448 |
+
"While the description field will add more information about how your snippet "
|
449 |
+
"works, what is does and where you found it, it is completely optional."
|
450 |
+
msgstr ""
|
451 |
+
"Morate popuniti polja sa nazivom i kodom za isečak koji želite da dodate. "
|
452 |
+
"Iako opisno polje sadrži više podataka o tome kako vaš isečak funkcioniše, "
|
453 |
+
"šta radi i gde ga možete naći, potpuno je proizvoljno."
|
454 |
+
|
455 |
+
#: includes/help/single.php:27
|
456 |
+
msgid ""
|
457 |
+
"Please be sure to check that your snippet is valid PHP code and will not "
|
458 |
+
"produce errors before adding it through this page. While doing so will not "
|
459 |
+
"become active straight away, it will help to minimise the chance of a faulty "
|
460 |
+
"snippet becoming active on your site."
|
461 |
+
msgstr ""
|
462 |
+
"Proverite da li vam je isečak važeći PHP kod i uverite se da neće praviti "
|
463 |
+
"greške pre nego što ga dodate putem ove stranice. Dok to radite, neće odmah "
|
464 |
+
"postati aktivan; pomoći će vam da smanjite na minimum šanse da se na vašem "
|
465 |
+
"sajtu aktivira isečak sa greškom. "
|
466 |
+
|
467 |
+
#: code-snippets.php:0
|
468 |
+
msgid "http://code-snippets.bungeshea.com"
|
469 |
+
msgstr "http://code-snippets.bungeshea.com"
|
470 |
+
|
471 |
+
#: code-snippets.php:263
|
472 |
+
msgid "Import snippets from a <strong>Code Snippets</strong> export file"
|
473 |
+
msgstr "Uvezi isečke iz <strong>Code Snippets</strong> datoteke za izvoz."
|
474 |
+
|
475 |
+
#: includes/admin/import.php:20
|
476 |
+
msgid "Imported <strong>%d</strong> snippet."
|
477 |
+
msgid_plural "Imported <strong>%d</strong> snippets."
|
478 |
+
msgstr[0] ""
|
479 |
+
msgstr[1] ""
|
480 |
+
|
481 |
+
#: includes/help/import.php:29 includes/help/manage.php:30
|
482 |
+
#: includes/help/single.php:34
|
483 |
+
msgid ""
|
484 |
+
"<a href=\"http://code-snippets.bungeshea.com/\" target=\"_blank\">Project "
|
485 |
+
"Website</a>"
|
486 |
+
msgstr ""
|
487 |
+
"<a href=\"http://code-snippets.bungeshea.com/\" target=\"_blank\">Project "
|
488 |
+
"Website</a>"
|
489 |
+
|
490 |
+
#: includes/help/manage.php:15
|
491 |
+
msgid ""
|
492 |
+
"If something goes wrong with a snippet and you can't use WordPress, you can "
|
493 |
+
"cause all snippets to stop executing by adding <code>define"
|
494 |
+
"('CODE_SNIPPETS_SAFE_MODE', true);</code> to your <code>wp-config.php</code> "
|
495 |
+
"file. After you have deactivated the offending snippet, you can turn off "
|
496 |
+
"safe mode by removing this line or replacing <strong>true</strong> with "
|
497 |
+
"<strong>false</strong>."
|
498 |
+
msgstr ""
|
499 |
+
"Ako se nešto u vezi sa isečkom pokvari i ne možete da koristite WordPress, "
|
500 |
+
"možete deaktivirati sve isečke tako što ćete uneti: <code>define"
|
501 |
+
"('CODE_SNIPPETS_SAFE_MODE', true);</code> u svoju <code>wp-config.php</code> "
|
502 |
+
"datoteku. Kad deaktivirate pogrešan isečak, možete isključiti bezbedan režim "
|
503 |
+
"tako što ćete ukloniti ovu liniju ili zameniti <strong>true</strong> sa "
|
504 |
+
"<strong>false</strong>."
|
505 |
+
|
506 |
+
#: includes/help/single.php:20
|
507 |
+
msgid ""
|
508 |
+
"More places to find snippets, as well as a selection of example snippets, "
|
509 |
+
"can be found in the <a href=\"http://code-snippets.bungeshea.com/docs/"
|
510 |
+
"finding-snippets/\">plugin documentation</a>"
|
511 |
+
msgstr ""
|
512 |
+
"Više mesta za pronalaženje isečaka, kao i odabrane primere isečaka, možete "
|
513 |
+
"naći na: <a href=\"http://code-snippets.bungeshea.com/docs/finding-snippets/"
|
514 |
+
"\">plugin documentation</a>"
|
515 |
+
|
516 |
+
#: code-snippets.php:0
|
517 |
+
msgid "1.7"
|
518 |
+
msgstr "1.7"
|
519 |
+
|
520 |
+
#: code-snippets.php:602 includes/class-list-table.php:142
|
521 |
+
msgid "Edit"
|
522 |
+
msgstr "Uredi"
|
523 |
+
|
524 |
+
#: code-snippets.php:1227
|
525 |
+
msgid "Sorry, you're not allowed to edit snippets"
|
526 |
+
msgstr "Žao nam je, nije vam dozvoljeno da uređujete isečke."
|
527 |
+
|
528 |
+
#: includes/admin/single.php:24
|
529 |
+
msgid "Snippet <strong>updated</strong> and <strong>activated</strong>."
|
530 |
+
msgstr "Isečak <strong>ažuriran</strong> i <strong>aktiviran</strong>."
|
531 |
+
|
532 |
+
#: includes/admin/single.php:26
|
533 |
+
msgid "Snippet <strong>added</strong> and <strong>activated</strong>."
|
534 |
+
msgstr "Isečak <strong>dodat </strong> i <strong>aktiviran</strong>."
|
535 |
+
|
536 |
+
#: includes/class-list-table.php:163
|
537 |
+
msgid ""
|
538 |
+
"You are about to permanently delete the selected item.\n"
|
539 |
+
"\t\t\t\t'Cancel' to stop, 'OK' to delete."
|
540 |
+
msgstr ""
|
541 |
+
"Spremate se da trajno obrišete odabranu jedinicu. \n"
|
542 |
+
"\t\t\t\t Kliknite na 'Poništi' da biste otkazali ili na 'OK' da biste "
|
543 |
+
"obrisali. "
|
544 |
+
|
545 |
+
#: includes/class-list-table.php:270
|
546 |
+
msgid "Filter"
|
547 |
+
msgstr "Filter"
|
548 |
+
|
549 |
+
#: includes/class-list-table.php:541
|
550 |
+
msgid "Search results"
|
551 |
+
msgstr "Rezultati pretrage"
|
552 |
+
|
553 |
+
#: includes/class-list-table.php:544
|
554 |
+
msgid " for “%s”"
|
555 |
+
msgstr "za “%s”"
|
556 |
+
|
557 |
+
#: includes/class-list-table.php:550
|
558 |
+
msgid "Clear Filters"
|
559 |
+
msgstr "Obriši filtere"
|
560 |
+
|
561 |
+
#: includes/help/import.php:14
|
562 |
+
msgid ""
|
563 |
+
"You can load your snippets from a code snippets (.xml) export file using "
|
564 |
+
"this page."
|
565 |
+
msgstr ""
|
566 |
+
"Možete otpremiti svoje isečke iz code snippets (.xml) datoteke za izvoz uz "
|
567 |
+
"pomoć sledeće stranice. "
|
568 |
+
|
569 |
+
#: includes/admin/single.php:74
|
570 |
+
msgid "Save Changes & Activate"
|
571 |
+
msgstr "Sačuvaj izmene & Aktiviraj "
|
Binary file
|
@@ -0,0 +1,517 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# This file is distributed under the same license as the Code Snippets package.
|
2 |
+
msgid ""
|
3 |
+
msgstr ""
|
4 |
+
"PO-Revision-Date: 2014-09-06 15:42+0800\n"
|
5 |
+
"MIME-Version: 1.0\n"
|
6 |
+
"Content-Type: text/plain; charset=UTF-8\n"
|
7 |
+
"Content-Transfer-Encoding: 8bit\n"
|
8 |
+
"Plural-Forms: nplurals=2; plural=n != 1;\n"
|
9 |
+
"X-Generator: Poedit 1.6.9\n"
|
10 |
+
"Project-Id-Version: Code Snippets\n"
|
11 |
+
"POT-Creation-Date: \n"
|
12 |
+
"Last-Translator: \n"
|
13 |
+
"Language-Team: Jincheng Shan <hi@shanjincheng.com>\n"
|
14 |
+
"Language: zh_Hans_CN\n"
|
15 |
+
"X-Poedit-SourceCharset: UTF-8\n"
|
16 |
+
|
17 |
+
#: code-snippets.php:0 code-snippets.php:262
|
18 |
+
msgid "Code Snippets"
|
19 |
+
msgstr "Code Snippets"
|
20 |
+
|
21 |
+
#: code-snippets.php:0
|
22 |
+
msgid ""
|
23 |
+
"An easy, clean and simple way to add code snippets to your site. No need to "
|
24 |
+
"edit to your theme's functions.php file again!"
|
25 |
+
msgstr ""
|
26 |
+
"以简单、简洁、简约的方式添加代码片段到您的站点。再也没有必要去编辑主题的 "
|
27 |
+
"functions.php 文件!"
|
28 |
+
|
29 |
+
#: code-snippets.php:0
|
30 |
+
msgid "Shea Bunge"
|
31 |
+
msgstr "Shea Bunge"
|
32 |
+
|
33 |
+
#: code-snippets.php:0
|
34 |
+
msgid "http://bungeshea.com"
|
35 |
+
msgstr "http://bungeshea.com"
|
36 |
+
|
37 |
+
#: code-snippets.php:577 code-snippets.php:578 code-snippets.php:588
|
38 |
+
#: includes/admin/manage.php:36
|
39 |
+
msgid "Snippets"
|
40 |
+
msgstr "片段"
|
41 |
+
|
42 |
+
#: code-snippets.php:612 code-snippets.php:1145 includes/admin/single.php:45
|
43 |
+
msgid "Add New Snippet"
|
44 |
+
msgstr "添加片段"
|
45 |
+
|
46 |
+
#: code-snippets.php:613
|
47 |
+
msgid "Add New"
|
48 |
+
msgstr "添加"
|
49 |
+
|
50 |
+
#: code-snippets.php:641 includes/admin/import.php:34
|
51 |
+
msgid "Import Snippets"
|
52 |
+
msgstr "导入片段"
|
53 |
+
|
54 |
+
#: code-snippets.php:642
|
55 |
+
msgid "Import"
|
56 |
+
msgstr "导入"
|
57 |
+
|
58 |
+
#: code-snippets.php:601 code-snippets.php:1146 includes/admin/single.php:37
|
59 |
+
msgid "Edit Snippet"
|
60 |
+
msgstr "编辑片段"
|
61 |
+
|
62 |
+
#: code-snippets.php:1465
|
63 |
+
msgid "Manage your existing snippets"
|
64 |
+
msgstr "管理现有片段"
|
65 |
+
|
66 |
+
#: code-snippets.php:589 code-snippets.php:1466
|
67 |
+
msgid "Manage"
|
68 |
+
msgstr "管理"
|
69 |
+
|
70 |
+
#: code-snippets.php:1486
|
71 |
+
msgid "Visit the WordPress.org plugin page"
|
72 |
+
msgstr "访问往于 WordPress.org 的插件页面"
|
73 |
+
|
74 |
+
#: code-snippets.php:1487
|
75 |
+
msgid "About"
|
76 |
+
msgstr "关于"
|
77 |
+
|
78 |
+
#: code-snippets.php:1491
|
79 |
+
msgid "Visit the support forums"
|
80 |
+
msgstr "访问帮助论坛"
|
81 |
+
|
82 |
+
#: code-snippets.php:1492
|
83 |
+
msgid "Support"
|
84 |
+
msgstr "支持"
|
85 |
+
|
86 |
+
#: code-snippets.php:1496
|
87 |
+
msgid "Support this plugin's development"
|
88 |
+
msgstr "帮助此插件的开发"
|
89 |
+
|
90 |
+
#: code-snippets.php:1497
|
91 |
+
msgid "Donate"
|
92 |
+
msgstr "捐助"
|
93 |
+
|
94 |
+
#: includes/admin/import.php:38
|
95 |
+
msgid ""
|
96 |
+
"Howdy! Upload your Code Snippets export file and we’ll import the "
|
97 |
+
"snippets to this site."
|
98 |
+
msgstr "您好!请上传你的 Code Snippets 导出文件,我们会导入片段到此站点。"
|
99 |
+
|
100 |
+
#: includes/admin/import.php:40
|
101 |
+
msgid ""
|
102 |
+
"You will need to go to the <a href=\"%s\">Manage Snippets</a> page to "
|
103 |
+
"activate the imported snippets."
|
104 |
+
msgstr "您需要访问 <a href=\"%s\">管理片段</a> 页面来激活导入的片段。"
|
105 |
+
|
106 |
+
#: includes/admin/import.php:42
|
107 |
+
msgid ""
|
108 |
+
"Choose a Code Snippets (.xml) file to upload, then click Upload file and "
|
109 |
+
"import."
|
110 |
+
msgstr "选择一个 Code Snippets 导出文件(.xml)上传,并点击上传文件来导入。"
|
111 |
+
|
112 |
+
#: includes/admin/import.php:46
|
113 |
+
msgid "Choose a file from your computer:"
|
114 |
+
msgstr "选择一个您电脑上的文件:"
|
115 |
+
|
116 |
+
#: includes/admin/import.php:46
|
117 |
+
msgid "(Maximum size: 8MB)"
|
118 |
+
msgstr "(最大上传文件大小:8 MB)"
|
119 |
+
|
120 |
+
#: includes/admin/import.php:55
|
121 |
+
msgid "Upload file and import"
|
122 |
+
msgstr "上传文件并导入"
|
123 |
+
|
124 |
+
#: includes/admin/manage.php:21
|
125 |
+
msgid "Snippet <strong>activated</strong>."
|
126 |
+
msgstr "片段 <strong>已激活</strong>。"
|
127 |
+
|
128 |
+
#: includes/admin/manage.php:23
|
129 |
+
msgid "Selected snippets <strong>activated</strong>."
|
130 |
+
msgstr "选择的片段 <strong>已激活</strong>。"
|
131 |
+
|
132 |
+
#: includes/admin/manage.php:25
|
133 |
+
msgid "Snippet <strong>deactivated</strong>."
|
134 |
+
msgstr "片段 <strong>已禁用</strong>。"
|
135 |
+
|
136 |
+
#: includes/admin/manage.php:27
|
137 |
+
msgid "Selected snippets <strong>deactivated</strong>."
|
138 |
+
msgstr "选择的片段 <strong>已禁用</strong>。"
|
139 |
+
|
140 |
+
#: includes/admin/manage.php:29
|
141 |
+
msgid "Snippet <strong>deleted</strong>."
|
142 |
+
msgstr "片段 <strong>已删除</strong>。"
|
143 |
+
|
144 |
+
#: includes/admin/manage.php:31
|
145 |
+
msgid "Selected snippets <strong>deleted</strong>."
|
146 |
+
msgstr "选择的片段 <strong>已删除</strong>。"
|
147 |
+
|
148 |
+
#: includes/admin/manage.php:38 includes/admin/single.php:42
|
149 |
+
msgctxt "snippet"
|
150 |
+
msgid "Add New"
|
151 |
+
msgstr "添加片段"
|
152 |
+
|
153 |
+
#: includes/admin/manage.php:47
|
154 |
+
msgid "Search Installed Snippets"
|
155 |
+
msgstr "搜索已安装的片段"
|
156 |
+
|
157 |
+
#: includes/admin/single.php:22
|
158 |
+
msgid "Please provide a name for the snippet and its code."
|
159 |
+
msgstr "请为片段命名。"
|
160 |
+
|
161 |
+
#: includes/admin/single.php:28
|
162 |
+
msgid "Snippet <strong>updated</strong>."
|
163 |
+
msgstr "片段 <strong>已上传</strong>。"
|
164 |
+
|
165 |
+
#: includes/admin/single.php:30
|
166 |
+
msgid "Snippet <strong>added</strong>."
|
167 |
+
msgstr "片段 <strong>已添加</strong>。"
|
168 |
+
|
169 |
+
#: includes/admin/single.php:55 includes/admin/single.php:56
|
170 |
+
msgid "Name (short title)"
|
171 |
+
msgstr "名称(简称)"
|
172 |
+
|
173 |
+
#: includes/admin/single.php:61
|
174 |
+
msgid "Code"
|
175 |
+
msgstr "代码"
|
176 |
+
|
177 |
+
#: code-snippets.php:1433 includes/class-list-table.php:189
|
178 |
+
msgid "Description"
|
179 |
+
msgstr "简介"
|
180 |
+
|
181 |
+
#: code-snippets.php:1434
|
182 |
+
msgid "(Optional)"
|
183 |
+
msgstr "(可选)"
|
184 |
+
|
185 |
+
#: includes/class-list-table.php:36
|
186 |
+
msgid "Snippets per page"
|
187 |
+
msgstr "每页显示的片段数"
|
188 |
+
|
189 |
+
#: code-snippets.php:1118 includes/class-list-table.php:127
|
190 |
+
#: includes/class-list-table.php:213
|
191 |
+
msgid "Network Deactivate"
|
192 |
+
msgstr "网络禁用"
|
193 |
+
|
194 |
+
#: code-snippets.php:1118 includes/class-list-table.php:127
|
195 |
+
#: includes/class-list-table.php:213
|
196 |
+
msgid "Deactivate"
|
197 |
+
msgstr "禁用"
|
198 |
+
|
199 |
+
#: code-snippets.php:1127 includes/class-list-table.php:137
|
200 |
+
#: includes/class-list-table.php:212
|
201 |
+
msgid "Network Activate"
|
202 |
+
msgstr "网络启用"
|
203 |
+
|
204 |
+
#: code-snippets.php:1127 includes/class-list-table.php:137
|
205 |
+
#: includes/class-list-table.php:212
|
206 |
+
msgid "Activate"
|
207 |
+
msgstr "启用"
|
208 |
+
|
209 |
+
#: includes/class-list-table.php:187
|
210 |
+
msgid "Name"
|
211 |
+
msgstr "名称"
|
212 |
+
|
213 |
+
#: includes/class-list-table.php:188
|
214 |
+
msgid "ID"
|
215 |
+
msgstr "ID"
|
216 |
+
|
217 |
+
#: includes/class-list-table.php:147 includes/class-list-table.php:214
|
218 |
+
msgid "Export"
|
219 |
+
msgstr "导出"
|
220 |
+
|
221 |
+
#: includes/class-list-table.php:155 includes/class-list-table.php:215
|
222 |
+
msgid "Delete"
|
223 |
+
msgstr "删除"
|
224 |
+
|
225 |
+
#: includes/class-list-table.php:216
|
226 |
+
msgid "Export to PHP"
|
227 |
+
msgstr "导出到 PHP"
|
228 |
+
|
229 |
+
#: includes/class-list-table.php:236
|
230 |
+
msgid "All <span class=\"count\">(%s)</span>"
|
231 |
+
msgid_plural "All <span class=\"count\">(%s)</span>"
|
232 |
+
msgstr[0] "所有<span class=\"count\">(%s)</span>"
|
233 |
+
msgstr[1] "所有<span class=\"count\">(%s)</span>"
|
234 |
+
|
235 |
+
#: includes/class-list-table.php:239
|
236 |
+
msgid "Active <span class=\"count\">(%s)</span>"
|
237 |
+
msgid_plural "Active <span class=\"count\">(%s)</span>"
|
238 |
+
msgstr[0] "启用<span class=\"count\">(%s)</span>"
|
239 |
+
msgstr[1] "启用<span class=\"count\">(%s)</span>"
|
240 |
+
|
241 |
+
#: includes/class-list-table.php:242
|
242 |
+
msgid "Recently Active <span class=\"count\">(%s)</span>"
|
243 |
+
msgid_plural "Recently Active <span class=\"count\">(%s)</span>"
|
244 |
+
msgstr[0] "最近启用<span class=\"count\">(%s)</span>"
|
245 |
+
msgstr[1] "最近启用<span class=\"count\">(%s)</span>"
|
246 |
+
|
247 |
+
#: includes/class-list-table.php:245
|
248 |
+
msgid "Inactive <span class=\"count\">(%s)</span>"
|
249 |
+
msgid_plural "Inactive <span class=\"count\">(%s)</span>"
|
250 |
+
msgstr[0] "禁用<span class=\"count\">(%s)</span>"
|
251 |
+
msgstr[1] "禁用<span class=\"count\">(%s)</span>"
|
252 |
+
|
253 |
+
#: includes/class-list-table.php:279
|
254 |
+
msgid "Clear List"
|
255 |
+
msgstr "清除列表"
|
256 |
+
|
257 |
+
#: includes/class-list-table.php:374
|
258 |
+
msgid ""
|
259 |
+
"You do not appear to have any snippets available at this time. <a href=\"%s"
|
260 |
+
"\">Add New→</a>"
|
261 |
+
msgstr "目前还没有一个可用的代码片段。<a href=\"%s\">添加→</a>"
|
262 |
+
|
263 |
+
#: includes/help/import.php:5 includes/help/manage.php:5
|
264 |
+
#: includes/help/single.php:5
|
265 |
+
msgid "Overview"
|
266 |
+
msgstr "概述"
|
267 |
+
|
268 |
+
#: includes/help/import.php:7
|
269 |
+
msgid ""
|
270 |
+
"Snippets are similar to plugins - they both extend and expand the "
|
271 |
+
"functionality of WordPress. Snippets are more light-weight, just a few lines "
|
272 |
+
"of code, and do not put as much load on your server. Here you can load "
|
273 |
+
"snippets from a Code Snippets (.xml) import file into the database with your "
|
274 |
+
"existing snippets."
|
275 |
+
msgstr ""
|
276 |
+
|
277 |
+
#: includes/help/import.php:12
|
278 |
+
msgid "Importing"
|
279 |
+
msgstr "导入"
|
280 |
+
|
281 |
+
#: includes/help/import.php:15
|
282 |
+
msgid ""
|
283 |
+
"Snippets will be added to the database along with your existing snippets. "
|
284 |
+
"Regardless of whether the snippets were active on the previous site, "
|
285 |
+
"imported snippets are always inactive until activated using the <a href=\"%s"
|
286 |
+
"\">Manage Snippets</a> page.</p>"
|
287 |
+
msgstr ""
|
288 |
+
|
289 |
+
#: includes/help/import.php:20
|
290 |
+
msgid "Exporting"
|
291 |
+
msgstr "导出"
|
292 |
+
|
293 |
+
#: includes/help/import.php:22
|
294 |
+
msgid ""
|
295 |
+
"You can save your snippets to a Code Snippets (.xml) export file using the "
|
296 |
+
"<a href=\"%s\">Manage Snippets</a> page."
|
297 |
+
msgstr ""
|
298 |
+
|
299 |
+
#: includes/help/import.php:26 includes/help/manage.php:27
|
300 |
+
#: includes/help/single.php:31
|
301 |
+
msgid "For more information:"
|
302 |
+
msgstr "更多信息:"
|
303 |
+
|
304 |
+
#: includes/help/import.php:27 includes/help/single.php:32
|
305 |
+
msgid ""
|
306 |
+
"<a href=\"http://wordpress.org/plugins/code-snippets\" target=\"_blank"
|
307 |
+
"\">WordPress Extend</a>"
|
308 |
+
msgstr ""
|
309 |
+
"<a href=\"http://wordpress.org/plugins/code-snippets\" target=\"_blank"
|
310 |
+
"\">WordPress 插件页面</a>"
|
311 |
+
|
312 |
+
#: includes/help/import.php:28 includes/help/manage.php:29
|
313 |
+
#: includes/help/single.php:33
|
314 |
+
msgid ""
|
315 |
+
"<a href=\"http://wordpress.org/support/plugin/code-snippets\" target=\"_blank"
|
316 |
+
"\">Support Forums</a>"
|
317 |
+
msgstr ""
|
318 |
+
"<a href=\"http://wordpress.org/support/plugin/code-snippets\" target=\"_blank"
|
319 |
+
"\">帮助论坛</a>"
|
320 |
+
|
321 |
+
#: includes/help/manage.php:7
|
322 |
+
msgid ""
|
323 |
+
"Snippets are similar to plugins - they both extend and expand the "
|
324 |
+
"functionality of WordPress. Snippets are more light-weight, just a few lines "
|
325 |
+
"of code, and do not put as much load on your server. Here you can manage "
|
326 |
+
"your existing snippets and preform tasks on them such as activating, "
|
327 |
+
"deactivating, deleting and exporting."
|
328 |
+
msgstr ""
|
329 |
+
|
330 |
+
#: includes/help/manage.php:12
|
331 |
+
msgid "Safe Mode"
|
332 |
+
msgstr "安全模式"
|
333 |
+
|
334 |
+
#: includes/help/manage.php:14
|
335 |
+
msgid ""
|
336 |
+
"Be sure to check your snippets for errors before you activate them, as a "
|
337 |
+
"faulty snippet could bring your whole blog down. If your site starts doing "
|
338 |
+
"strange things, deactivate all your snippets and activate them one at a time."
|
339 |
+
msgstr ""
|
340 |
+
|
341 |
+
#: includes/help/manage.php:20
|
342 |
+
msgid "Uninstall"
|
343 |
+
msgstr "卸载"
|
344 |
+
|
345 |
+
#: includes/help/manage.php:22
|
346 |
+
msgid ""
|
347 |
+
"When you delete Code Snippets through the Plugins menu in WordPress it will "
|
348 |
+
"clear up the <code>%1$s</code> table and a few other bits of data stored in "
|
349 |
+
"the database. If you want to keep this data (ie: you are only temporally "
|
350 |
+
"uninstalling Code Snippets) then remove the <code>%2$s</code> folder using "
|
351 |
+
"FTP."
|
352 |
+
msgstr ""
|
353 |
+
|
354 |
+
#: includes/help/manage.php:23
|
355 |
+
msgid ""
|
356 |
+
"Even if you're sure that you don't want to use Code Snippets ever again on "
|
357 |
+
"this WordPress installation, you may want to use the export feature to back "
|
358 |
+
"up your snippets."
|
359 |
+
msgstr ""
|
360 |
+
|
361 |
+
#: includes/help/manage.php:28
|
362 |
+
msgid ""
|
363 |
+
"<a href=\"http://wordpress.org/plugins/code-snippets\" target=\"_blank"
|
364 |
+
"\">WordPress Extend</a></p>"
|
365 |
+
msgstr ""
|
366 |
+
"<a href=\"http://wordpress.org/plugins/code-snippets\" target=\"_blank"
|
367 |
+
"\">WordPress 插件页面</a></p>"
|
368 |
+
|
369 |
+
#: includes/help/single.php:7
|
370 |
+
msgid ""
|
371 |
+
"Snippets are similar to plugins - they both extend and expand the "
|
372 |
+
"functionality of WordPress. Snippets are more light-weight, just a few lines "
|
373 |
+
"of code, and do not put as much load on your server. Here you can add a new "
|
374 |
+
"snippet, or edit an existing one."
|
375 |
+
msgstr ""
|
376 |
+
|
377 |
+
#: includes/help/single.php:11
|
378 |
+
msgid "Finding Snippets"
|
379 |
+
msgstr "寻找片段"
|
380 |
+
|
381 |
+
#: includes/help/single.php:13
|
382 |
+
msgid ""
|
383 |
+
"Here are some links to websites which host a large number of snippets that "
|
384 |
+
"you can add to your site.\n"
|
385 |
+
"\t\t<ul>\n"
|
386 |
+
"\t\t\t<li><a href=\"http://wp-snippets.com\" title=\"WordPress Snippets\">WP-"
|
387 |
+
"Snippets</a></li>\n"
|
388 |
+
"\t\t\t<li><a href=\"http://wpsnipp.com\" title=\"WP Snipp\">WP Snipp</a></"
|
389 |
+
"li>\n"
|
390 |
+
"\t\t\t<li><a href=\"http://www.catswhocode.com/blog/snippets\" title=\"Cats "
|
391 |
+
"Who Code Snippet Library\">Cats Who Code</a></li>\n"
|
392 |
+
"\t\t\t<li><a href=\"http://www.wpfunction.me\">WP Function Me</a></li>\n"
|
393 |
+
"\t\t</ul>"
|
394 |
+
msgstr ""
|
395 |
+
"您可以将这里有着数量巨大的代码片段的网站中的片段添加到您的站点。\n"
|
396 |
+
"\t\t<ul>\n"
|
397 |
+
"\t\t\t<li><a href=\"http://wp-snippets.com\" title=\"WordPress Snippets\">WP-"
|
398 |
+
"Snippets</a></li>\n"
|
399 |
+
"\t\t\t<li><a href=\"http://wpsnipp.com\" title=\"WP Snipp\">WP Snipp</a></"
|
400 |
+
"li>\n"
|
401 |
+
"\t\t\t<li><a href=\"http://www.catswhocode.com/blog/snippets\" title=\"Cats "
|
402 |
+
"Who Code Snippet Library\">Cats Who Code</a></li>\n"
|
403 |
+
"\t\t\t<li><a href=\"http://www.wpfunction.me\">WP Function Me</a></li>\n"
|
404 |
+
"\t\t</ul>"
|
405 |
+
|
406 |
+
#: includes/help/single.php:24
|
407 |
+
msgid "Adding Snippets"
|
408 |
+
msgstr "添加片段"
|
409 |
+
|
410 |
+
#: includes/help/single.php:26
|
411 |
+
msgid ""
|
412 |
+
"You need to fill out the name and code fields for your snippet to be added. "
|
413 |
+
"While the description field will add more information about how your snippet "
|
414 |
+
"works, what is does and where you found it, it is completely optional."
|
415 |
+
msgstr ""
|
416 |
+
|
417 |
+
#: includes/help/single.php:27
|
418 |
+
msgid ""
|
419 |
+
"Please be sure to check that your snippet is valid PHP code and will not "
|
420 |
+
"produce errors before adding it through this page. While doing so will not "
|
421 |
+
"become active straight away, it will help to minimise the chance of a faulty "
|
422 |
+
"snippet becoming active on your site."
|
423 |
+
msgstr ""
|
424 |
+
|
425 |
+
#: code-snippets.php:0
|
426 |
+
msgid "http://code-snippets.bungeshea.com"
|
427 |
+
msgstr "http://code-snippets.bungeshea.com"
|
428 |
+
|
429 |
+
#: code-snippets.php:263
|
430 |
+
msgid "Import snippets from a <strong>Code Snippets</strong> export file"
|
431 |
+
msgstr "上传来自于 <strong>Code Snippets</strong> 导出文件的代码片段。"
|
432 |
+
|
433 |
+
#: includes/admin/import.php:20
|
434 |
+
msgid "Imported <strong>%d</strong> snippet."
|
435 |
+
msgid_plural "Imported <strong>%d</strong> snippets."
|
436 |
+
msgstr[0] "已上传 <strong>%d</strong> 个片段。"
|
437 |
+
msgstr[1] "已上传 <strong>%d</strong> 个片段。"
|
438 |
+
|
439 |
+
#: includes/help/import.php:29 includes/help/manage.php:30
|
440 |
+
#: includes/help/single.php:34
|
441 |
+
msgid ""
|
442 |
+
"<a href=\"http://code-snippets.bungeshea.com/\" target=\"_blank\">Project "
|
443 |
+
"Website</a>"
|
444 |
+
msgstr ""
|
445 |
+
"<a href=\"http://code-snippets.bungeshea.com/\" target=\"_blank\">项目站点</"
|
446 |
+
"a>"
|
447 |
+
|
448 |
+
#: includes/help/manage.php:15
|
449 |
+
msgid ""
|
450 |
+
"If something goes wrong with a snippet and you can't use WordPress, you can "
|
451 |
+
"cause all snippets to stop executing by adding "
|
452 |
+
"<code>define('CODE_SNIPPETS_SAFE_MODE', true);</code> to your <code>wp-"
|
453 |
+
"config.php</code> file. After you have deactivated the offending snippet, "
|
454 |
+
"you can turn off safe mode by removing this line or replacing <strong>true</"
|
455 |
+
"strong> with <strong>false</strong>."
|
456 |
+
msgstr ""
|
457 |
+
|
458 |
+
#: includes/help/single.php:20
|
459 |
+
msgid ""
|
460 |
+
"More places to find snippets, as well as a selection of example snippets, "
|
461 |
+
"can be found in the <a href=\"http://code-snippets.bungeshea.com/docs/"
|
462 |
+
"finding-snippets/\">plugin documentation</a>"
|
463 |
+
msgstr ""
|
464 |
+
|
465 |
+
#: code-snippets.php:0
|
466 |
+
msgid "1.7"
|
467 |
+
msgstr "1.7"
|
468 |
+
|
469 |
+
#: code-snippets.php:602 includes/class-list-table.php:142
|
470 |
+
msgid "Edit"
|
471 |
+
msgstr "编辑"
|
472 |
+
|
473 |
+
#: code-snippets.php:1227
|
474 |
+
msgid "Sorry, you're not allowed to edit snippets"
|
475 |
+
msgstr "对不起,您未被授予修改片段的权限。"
|
476 |
+
|
477 |
+
#: includes/admin/single.php:24
|
478 |
+
msgid "Snippet <strong>updated</strong> and <strong>activated</strong>."
|
479 |
+
msgstr "片段 <strong>已上传</strong> 并 <strong>已启用</strong>。"
|
480 |
+
|
481 |
+
#: includes/admin/single.php:26
|
482 |
+
msgid "Snippet <strong>added</strong> and <strong>activated</strong>."
|
483 |
+
msgstr "片段 <strong>已添加</strong> 并 <strong>已启用</strong>。"
|
484 |
+
|
485 |
+
#: includes/class-list-table.php:163
|
486 |
+
msgid ""
|
487 |
+
"You are about to permanently delete the selected item.\n"
|
488 |
+
"\t\t\t\t'Cancel' to stop, 'OK' to delete."
|
489 |
+
msgstr ""
|
490 |
+
"您即将彻底删除所选条目。\n"
|
491 |
+
"\t\t\t\t点击「取消」以停止, 「确认」以删除。"
|
492 |
+
|
493 |
+
#: includes/class-list-table.php:270
|
494 |
+
msgid "Filter"
|
495 |
+
msgstr "关键词"
|
496 |
+
|
497 |
+
#: includes/class-list-table.php:541
|
498 |
+
msgid "Search results"
|
499 |
+
msgstr "“%s”"
|
500 |
+
|
501 |
+
#: includes/class-list-table.php:544
|
502 |
+
msgid " for “%s”"
|
503 |
+
msgstr "的搜索结果"
|
504 |
+
|
505 |
+
#: includes/class-list-table.php:550
|
506 |
+
msgid "Clear Filters"
|
507 |
+
msgstr "清除关键词"
|
508 |
+
|
509 |
+
#: includes/help/import.php:14
|
510 |
+
msgid ""
|
511 |
+
"You can load your snippets from a code snippets (.xml) export file using "
|
512 |
+
"this page."
|
513 |
+
msgstr "您可以于此页加载 Code Snippets 导出文件(.xml)中的代码片段。"
|
514 |
+
|
515 |
+
#: includes/admin/single.php:74
|
516 |
+
msgid "Save Changes & Activate"
|
517 |
+
msgstr "保存设置并启用"
|
Binary file
|
@@ -1,419 +1,675 @@
|
|
1 |
-
#
|
2 |
-
|
3 |
-
|
4 |
-
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
"
|
10 |
-
"
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
#:
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
msgstr ""
|
64 |
-
|
65 |
-
#:
|
66 |
-
msgid "
|
67 |
-
msgstr ""
|
68 |
-
|
69 |
-
#:
|
70 |
-
msgid "
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
msgstr ""
|
92 |
-
|
93 |
-
#: includes/
|
94 |
-
msgid "
|
95 |
-
msgstr ""
|
96 |
-
|
97 |
-
#: includes/
|
98 |
-
msgid "
|
99 |
-
msgstr ""
|
100 |
-
|
101 |
-
#: includes/
|
102 |
-
msgid "
|
103 |
-
msgstr ""
|
104 |
-
|
105 |
-
#: includes/
|
106 |
-
msgid "
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
msgstr ""
|
116 |
-
|
117 |
-
#: includes/admin/
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
msgid "
|
136 |
-
|
137 |
-
|
138 |
-
|
139 |
-
|
140 |
-
|
141 |
-
|
142 |
-
|
143 |
-
|
144 |
-
|
145 |
-
|
146 |
-
|
147 |
-
|
148 |
-
|
149 |
-
|
150 |
-
|
151 |
-
|
152 |
-
|
153 |
-
|
154 |
-
|
155 |
-
|
156 |
-
|
157 |
-
|
158 |
-
|
159 |
-
|
160 |
-
|
161 |
-
|
162 |
-
|
163 |
-
|
164 |
-
|
165 |
-
|
166 |
-
|
167 |
-
|
168 |
-
|
169 |
-
|
170 |
-
|
171 |
-
|
172 |
-
|
173 |
-
|
174 |
-
|
175 |
-
#: includes/
|
176 |
-
|
177 |
-
|
178 |
-
|
179 |
-
|
180 |
-
#: includes/
|
181 |
-
msgid "
|
182 |
-
|
183 |
-
|
184 |
-
|
185 |
-
|
186 |
-
|
187 |
-
|
188 |
-
|
189 |
-
|
190 |
-
|
191 |
-
|
192 |
-
|
193 |
-
|
194 |
-
#: includes/
|
195 |
-
msgid "
|
196 |
-
|
197 |
-
|
198 |
-
|
199 |
-
|
200 |
-
|
201 |
-
|
202 |
-
|
203 |
-
|
204 |
-
|
205 |
-
|
206 |
-
|
207 |
-
|
208 |
-
|
209 |
-
|
210 |
-
|
211 |
-
|
212 |
-
|
213 |
-
|
214 |
-
|
215 |
-
|
216 |
-
|
217 |
-
|
218 |
-
msgstr
|
219 |
-
|
220 |
-
#: includes/
|
221 |
-
msgid "
|
222 |
-
|
223 |
-
|
224 |
-
|
225 |
-
|
226 |
-
|
227 |
-
|
228 |
-
|
229 |
-
|
230 |
-
|
231 |
-
|
232 |
-
|
233 |
-
|
234 |
-
|
235 |
-
|
236 |
-
msgstr
|
237 |
-
|
238 |
-
#: includes/
|
239 |
-
msgid "
|
240 |
-
msgstr ""
|
241 |
-
|
242 |
-
#: includes/
|
243 |
-
msgid "
|
244 |
-
msgstr ""
|
245 |
-
|
246 |
-
#: includes/
|
247 |
-
|
248 |
-
|
249 |
-
|
250 |
-
|
251 |
-
|
252 |
-
|
253 |
-
|
254 |
-
|
255 |
-
#: includes/
|
256 |
-
msgid "
|
257 |
-
msgstr ""
|
258 |
-
|
259 |
-
#: includes/
|
260 |
-
msgid "
|
261 |
-
|
262 |
-
|
263 |
-
|
264 |
-
|
265 |
-
|
266 |
-
|
267 |
-
|
268 |
-
|
269 |
-
|
270 |
-
|
271 |
-
|
272 |
-
|
273 |
-
|
274 |
-
|
275 |
-
|
276 |
-
|
277 |
-
|
278 |
-
|
279 |
-
|
280 |
-
|
281 |
-
|
282 |
-
|
283 |
-
|
284 |
-
|
285 |
-
|
286 |
-
|
287 |
-
|
288 |
-
|
289 |
-
|
290 |
-
|
291 |
-
|
292 |
-
|
293 |
-
|
294 |
-
|
295 |
-
|
296 |
-
|
297 |
-
|
298 |
-
|
299 |
-
msgstr ""
|
300 |
-
|
301 |
-
#: includes/help
|
302 |
-
|
303 |
-
|
304 |
-
|
305 |
-
|
306 |
-
|
307 |
-
|
308 |
-
|
309 |
-
|
310 |
-
|
311 |
-
|
312 |
-
|
313 |
-
|
314 |
-
|
315 |
-
|
316 |
-
|
317 |
-
|
318 |
-
|
319 |
-
msgstr ""
|
320 |
-
|
321 |
-
#: includes/
|
322 |
-
|
323 |
-
|
324 |
-
"
|
325 |
-
"
|
326 |
-
|
327 |
-
|
328 |
-
|
329 |
-
"
|
330 |
-
msgstr ""
|
331 |
-
|
332 |
-
#: includes/
|
333 |
-
msgid "
|
334 |
-
msgstr ""
|
335 |
-
|
336 |
-
#: includes/
|
337 |
-
msgid "
|
338 |
-
|
339 |
-
|
340 |
-
|
341 |
-
|
342 |
-
|
343 |
-
|
344 |
-
|
345 |
-
|
346 |
-
|
347 |
-
|
348 |
-
|
349 |
-
|
350 |
-
|
351 |
-
|
352 |
-
|
353 |
-
|
354 |
-
|
355 |
-
|
356 |
-
|
357 |
-
|
358 |
-
|
359 |
-
#: includes/
|
360 |
-
msgid "
|
361 |
-
msgstr ""
|
362 |
-
|
363 |
-
#: includes/
|
364 |
-
msgid "
|
365 |
-
msgstr ""
|
366 |
-
|
367 |
-
#: includes/
|
368 |
-
msgid "
|
369 |
-
msgstr ""
|
370 |
-
|
371 |
-
#:
|
372 |
-
msgid "
|
373 |
-
msgstr ""
|
374 |
-
|
375 |
-
#:
|
376 |
-
msgid "
|
377 |
-
msgstr ""
|
378 |
-
|
379 |
-
#:
|
380 |
-
msgid "
|
381 |
-
msgstr ""
|
382 |
-
|
383 |
-
#: includes/admin
|
384 |
-
msgid "
|
385 |
-
|
386 |
-
|
387 |
-
|
388 |
-
|
389 |
-
|
390 |
-
|
391 |
-
|
392 |
-
|
393 |
-
"
|
394 |
-
|
395 |
-
|
396 |
-
|
397 |
-
|
398 |
-
|
399 |
-
|
400 |
-
|
401 |
-
|
402 |
-
|
403 |
-
|
404 |
-
|
405 |
-
|
406 |
-
|
407 |
-
|
408 |
-
|
409 |
-
|
410 |
-
|
411 |
-
msgstr ""
|
412 |
-
|
413 |
-
#: includes/help
|
414 |
-
msgid "
|
415 |
-
msgstr ""
|
416 |
-
|
417 |
-
#: includes/admin
|
418 |
-
|
419 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# SOME DESCRIPTIVE TITLE.
|
2 |
+
# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER
|
3 |
+
# This file is distributed under the same license as the PACKAGE package.
|
4 |
+
# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
|
5 |
+
#
|
6 |
+
#, fuzzy
|
7 |
+
msgid ""
|
8 |
+
msgstr ""
|
9 |
+
"Project-Id-Version: code-snippets 2.0.0-dev\n"
|
10 |
+
"Report-Msgid-Bugs-To: \n"
|
11 |
+
"POT-Creation-Date: 2015-02-23 22:28+1030\n"
|
12 |
+
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
|
13 |
+
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
|
14 |
+
"Language-Team: LANGUAGE <LL@li.org>\n"
|
15 |
+
"Language: \n"
|
16 |
+
"MIME-Version: 1.0\n"
|
17 |
+
"Content-Type: text/plain; charset=CHARSET\n"
|
18 |
+
"Content-Transfer-Encoding: 8bit\n"
|
19 |
+
|
20 |
+
#: includes/admin.php:81 includes/manage/admin.php:21
|
21 |
+
#: includes/manage/manage.php:22 includes/manage/manage.php:23
|
22 |
+
#: includes/manage/manage.php:33
|
23 |
+
msgid "Snippets"
|
24 |
+
msgstr ""
|
25 |
+
|
26 |
+
#: includes/admin.php:120
|
27 |
+
msgid "Manage your existing snippets"
|
28 |
+
msgstr ""
|
29 |
+
|
30 |
+
#: includes/admin.php:121 includes/manage/manage.php:34
|
31 |
+
msgid "Manage"
|
32 |
+
msgstr ""
|
33 |
+
|
34 |
+
#: includes/admin.php:150
|
35 |
+
msgid "Visit the WordPress.org plugin page"
|
36 |
+
msgstr ""
|
37 |
+
|
38 |
+
#: includes/admin.php:151
|
39 |
+
msgid "About"
|
40 |
+
msgstr ""
|
41 |
+
|
42 |
+
#: includes/admin.php:155
|
43 |
+
msgid "Visit the support forums"
|
44 |
+
msgstr ""
|
45 |
+
|
46 |
+
#: includes/admin.php:156
|
47 |
+
msgid "Support"
|
48 |
+
msgstr ""
|
49 |
+
|
50 |
+
#: includes/admin.php:160
|
51 |
+
msgid "Support this plugin's development"
|
52 |
+
msgstr ""
|
53 |
+
|
54 |
+
#: includes/admin.php:161
|
55 |
+
msgid "Donate"
|
56 |
+
msgstr ""
|
57 |
+
|
58 |
+
#: includes/admin.php:194
|
59 |
+
msgid ""
|
60 |
+
"<strong>Have feedback on Code Snippets?</strong> Please take the time to "
|
61 |
+
"answer a short survey on how you use this plugin and what you'd like to see "
|
62 |
+
"changed or added in the future."
|
63 |
+
msgstr ""
|
64 |
+
|
65 |
+
#: includes/admin.php:197
|
66 |
+
msgid "Take the survey now"
|
67 |
+
msgstr ""
|
68 |
+
|
69 |
+
#: includes/class-export.php:104
|
70 |
+
msgid ""
|
71 |
+
"This is a code snippets export file generated by the Code Snippets WordPress "
|
72 |
+
"plugin."
|
73 |
+
msgstr ""
|
74 |
+
|
75 |
+
#: includes/class-export.php:105
|
76 |
+
msgid "http://wordpress.org/plugins/code-snippets"
|
77 |
+
msgstr ""
|
78 |
+
|
79 |
+
#: includes/class-export.php:106
|
80 |
+
msgid "To import these snippets a WordPress site follow these steps:"
|
81 |
+
msgstr ""
|
82 |
+
|
83 |
+
#: includes/class-export.php:107
|
84 |
+
msgid "1. Log in to that site as an administrator."
|
85 |
+
msgstr ""
|
86 |
+
|
87 |
+
#: includes/class-export.php:108
|
88 |
+
msgid ""
|
89 |
+
"2. Install the Code Snippets plugin using the directions provided at the "
|
90 |
+
"above link."
|
91 |
+
msgstr ""
|
92 |
+
|
93 |
+
#: includes/class-export.php:109
|
94 |
+
msgid "3. Go to 'Tools: Import' in the WordPress admin panel."
|
95 |
+
msgstr ""
|
96 |
+
|
97 |
+
#: includes/class-export.php:110
|
98 |
+
msgid "4. Click on the \"Code Snippets\" importer in the list"
|
99 |
+
msgstr ""
|
100 |
+
|
101 |
+
#: includes/class-export.php:111
|
102 |
+
msgid "5. Upload this file using the form provided on that page."
|
103 |
+
msgstr ""
|
104 |
+
|
105 |
+
#: includes/class-export.php:112
|
106 |
+
msgid ""
|
107 |
+
"6. Code Snippets will then import all of the snippets and associated "
|
108 |
+
"information contained in this file into your site."
|
109 |
+
msgstr ""
|
110 |
+
|
111 |
+
#: includes/class-export.php:113
|
112 |
+
msgid ""
|
113 |
+
"7. You will then have to visit the 'Snippets: Manage' admin menu and "
|
114 |
+
"activate desired snippets."
|
115 |
+
msgstr ""
|
116 |
+
|
117 |
+
#: includes/edit/admin-help.php:15 includes/import/admin-help.php:16
|
118 |
+
#: includes/manage/admin-help.php:15
|
119 |
+
msgid "Overview"
|
120 |
+
msgstr ""
|
121 |
+
|
122 |
+
#: includes/edit/admin-help.php:17
|
123 |
+
msgid ""
|
124 |
+
"Snippets are similar to plugins - they both extend and expand the "
|
125 |
+
"functionality of WordPress. Snippets are more light-weight, just a few lines "
|
126 |
+
"of code, and do not put as much load on your server. Here you can add a new "
|
127 |
+
"snippet, or edit an existing one."
|
128 |
+
msgstr ""
|
129 |
+
|
130 |
+
#: includes/edit/admin-help.php:22
|
131 |
+
msgid "Finding Snippets"
|
132 |
+
msgstr ""
|
133 |
+
|
134 |
+
#: includes/edit/admin-help.php:24
|
135 |
+
msgid ""
|
136 |
+
"Here are some links to websites which host a large number of snippets that "
|
137 |
+
"you can add to your site.\n"
|
138 |
+
"\t\t<ul>\n"
|
139 |
+
"\t\t\t<li><a href=\"http://wp-snippets.com\" title=\"WordPress Snippets\">WP-"
|
140 |
+
"Snippets</a></li>\n"
|
141 |
+
"\t\t\t<li><a href=\"http://wpsnipp.com\" title=\"WP Snipp\">WP Snipp</a></"
|
142 |
+
"li>\n"
|
143 |
+
"\t\t\t<li><a href=\"http://www.catswhocode.com/blog/snippets\" title=\"Cats "
|
144 |
+
"Who Code Snippet Library\">Cats Who Code</a></li>\n"
|
145 |
+
"\t\t\t<li><a href=\"http://www.wpfunction.me\">WP Function Me</a></li>\n"
|
146 |
+
"\t\t</ul>"
|
147 |
+
msgstr ""
|
148 |
+
|
149 |
+
#: includes/edit/admin-help.php:31
|
150 |
+
msgid ""
|
151 |
+
"More places to find snippets, as well as a selection of example snippets, "
|
152 |
+
"can be found in the <a href=\"http://code-snippets.bungeshea.com/docs/"
|
153 |
+
"finding-snippets/\">plugin documentation</a>"
|
154 |
+
msgstr ""
|
155 |
+
|
156 |
+
#: includes/edit/admin-help.php:36
|
157 |
+
msgid "Adding Snippets"
|
158 |
+
msgstr ""
|
159 |
+
|
160 |
+
#: includes/edit/admin-help.php:38
|
161 |
+
msgid ""
|
162 |
+
"You need to fill out the name and code fields for your snippet to be added. "
|
163 |
+
"While the description field will add more information about how your snippet "
|
164 |
+
"works, what is does and where you found it, it is completely optional."
|
165 |
+
msgstr ""
|
166 |
+
|
167 |
+
#: includes/edit/admin-help.php:39
|
168 |
+
msgid ""
|
169 |
+
"Please be sure to check that your snippet is valid PHP code and will not "
|
170 |
+
"produce errors before adding it through this page. While doing so will not "
|
171 |
+
"become active straight away, it will help to minimise the chance of a faulty "
|
172 |
+
"snippet becoming active on your site."
|
173 |
+
msgstr ""
|
174 |
+
|
175 |
+
#: includes/edit/admin-help.php:43 includes/import/admin-help.php:37
|
176 |
+
#: includes/manage/admin-help.php:37
|
177 |
+
msgid "For more information:"
|
178 |
+
msgstr ""
|
179 |
+
|
180 |
+
#: includes/edit/admin-help.php:44 includes/import/admin-help.php:38
|
181 |
+
msgid ""
|
182 |
+
"<a href=\"http://wordpress.org/plugins/code-snippets\" target=\"_blank"
|
183 |
+
"\">WordPress Extend</a>"
|
184 |
+
msgstr ""
|
185 |
+
|
186 |
+
#: includes/edit/admin-help.php:45 includes/import/admin-help.php:39
|
187 |
+
#: includes/manage/admin-help.php:39
|
188 |
+
msgid ""
|
189 |
+
"<a href=\"http://wordpress.org/support/plugin/code-snippets\" target=\"_blank"
|
190 |
+
"\">Support Forums</a>"
|
191 |
+
msgstr ""
|
192 |
+
|
193 |
+
#: includes/edit/admin-help.php:46 includes/import/admin-help.php:40
|
194 |
+
#: includes/manage/admin-help.php:40
|
195 |
+
msgid ""
|
196 |
+
"<a href=\"http://code-snippets.bungeshea.com/\" target=\"_blank\">Project "
|
197 |
+
"Website</a>"
|
198 |
+
msgstr ""
|
199 |
+
|
200 |
+
#: includes/edit/admin-messages.php:14
|
201 |
+
msgid "An error occurred when saving the snippet."
|
202 |
+
msgstr ""
|
203 |
+
|
204 |
+
#: includes/edit/admin-messages.php:18
|
205 |
+
msgid "Snippet <strong>updated</strong> and <strong>activated</strong>."
|
206 |
+
msgstr ""
|
207 |
+
|
208 |
+
#: includes/edit/admin-messages.php:22
|
209 |
+
msgid "Snippet <strong>added</strong> and <strong>activated</strong>."
|
210 |
+
msgstr ""
|
211 |
+
|
212 |
+
#: includes/edit/admin-messages.php:26
|
213 |
+
msgid "Snippet <strong>updated</strong> and <strong>deactivated</strong>."
|
214 |
+
msgstr ""
|
215 |
+
|
216 |
+
#: includes/edit/admin-messages.php:30
|
217 |
+
msgid "Snippet <strong>updated</strong>."
|
218 |
+
msgstr ""
|
219 |
+
|
220 |
+
#: includes/edit/admin-messages.php:34
|
221 |
+
msgid "Snippet <strong>added</strong>."
|
222 |
+
msgstr ""
|
223 |
+
|
224 |
+
#: includes/edit/admin.php:26 includes/edit/edit.php:46
|
225 |
+
#: includes/edit/edit.php:47
|
226 |
+
msgid "Edit Snippet"
|
227 |
+
msgstr ""
|
228 |
+
|
229 |
+
#: includes/edit/admin.php:31 includes/edit/edit.php:35
|
230 |
+
#: includes/manage/admin.php:26
|
231 |
+
msgid "Add New"
|
232 |
+
msgstr ""
|
233 |
+
|
234 |
+
#: includes/edit/admin.php:35 includes/edit/edit.php:34
|
235 |
+
msgid "Add New Snippet"
|
236 |
+
msgstr ""
|
237 |
+
|
238 |
+
#: includes/edit/admin.php:52 includes/edit/admin.php:53
|
239 |
+
msgid "Name (short title)"
|
240 |
+
msgstr ""
|
241 |
+
|
242 |
+
#: includes/edit/admin.php:58
|
243 |
+
msgid "Code"
|
244 |
+
msgstr ""
|
245 |
+
|
246 |
+
#: includes/edit/admin.php:79 includes/edit/admin.php:93
|
247 |
+
msgid "Save Changes and Activate"
|
248 |
+
msgstr ""
|
249 |
+
|
250 |
+
#: includes/edit/admin.php:99
|
251 |
+
msgid "Save Changes and Deactivate"
|
252 |
+
msgstr ""
|
253 |
+
|
254 |
+
#: includes/edit/admin.php:109 includes/manage/class-list-table.php:157
|
255 |
+
#: includes/manage/class-list-table.php:282
|
256 |
+
msgid "Export"
|
257 |
+
msgstr ""
|
258 |
+
|
259 |
+
#: includes/edit/admin.php:116
|
260 |
+
msgid ""
|
261 |
+
"You are about to permanently delete this snippet.\n"
|
262 |
+
"'Cancel' to stop, 'OK' to delete."
|
263 |
+
msgstr ""
|
264 |
+
|
265 |
+
#: includes/edit/admin.php:121 includes/manage/class-list-table.php:166
|
266 |
+
#: includes/manage/class-list-table.php:283
|
267 |
+
msgid "Delete"
|
268 |
+
msgstr ""
|
269 |
+
|
270 |
+
#: includes/edit/edit.php:83 includes/manage/manage.php:67
|
271 |
+
msgid "You are not authorized to access this page."
|
272 |
+
msgstr ""
|
273 |
+
|
274 |
+
#: includes/edit/edit.php:176 includes/manage/class-list-table.php:242
|
275 |
+
msgid "Description"
|
276 |
+
msgstr ""
|
277 |
+
|
278 |
+
#: includes/edit/edit.php:205 includes/manage/class-list-table.php:243
|
279 |
+
msgid "Tags"
|
280 |
+
msgstr ""
|
281 |
+
|
282 |
+
#: includes/import/admin-help.php:18
|
283 |
+
msgid ""
|
284 |
+
"Snippets are similar to plugins - they both extend and expand the "
|
285 |
+
"functionality of WordPress. Snippets are more light-weight, just a few lines "
|
286 |
+
"of code, and do not put as much load on your server. Here you can load "
|
287 |
+
"snippets from a Code Snippets (.xml) import file into the database with your "
|
288 |
+
"existing snippets."
|
289 |
+
msgstr ""
|
290 |
+
|
291 |
+
#: includes/import/admin-help.php:23
|
292 |
+
msgid "Importing"
|
293 |
+
msgstr ""
|
294 |
+
|
295 |
+
#: includes/import/admin-help.php:25
|
296 |
+
msgid ""
|
297 |
+
"You can load your snippets from a code snippets (.xml) export file using "
|
298 |
+
"this page."
|
299 |
+
msgstr ""
|
300 |
+
|
301 |
+
#: includes/import/admin-help.php:26
|
302 |
+
#, php-format
|
303 |
+
msgid ""
|
304 |
+
"Snippets will be added to the database along with your existing snippets. "
|
305 |
+
"Regardless of whether the snippets were active on the previous site, "
|
306 |
+
"imported snippets are always inactive until activated using the <a href=\"%s"
|
307 |
+
"\">Manage Snippets</a> page.</p>"
|
308 |
+
msgstr ""
|
309 |
+
|
310 |
+
#: includes/import/admin-help.php:31
|
311 |
+
msgid "Exporting"
|
312 |
+
msgstr ""
|
313 |
+
|
314 |
+
#: includes/import/admin-help.php:33
|
315 |
+
#, php-format
|
316 |
+
msgid ""
|
317 |
+
"You can save your snippets to a Code Snippets (.xml) export file using the "
|
318 |
+
"<a href=\"%s\">Manage Snippets</a> page."
|
319 |
+
msgstr ""
|
320 |
+
|
321 |
+
#: includes/import/admin-messages.php:16
|
322 |
+
#, php-format
|
323 |
+
msgid ""
|
324 |
+
"Successfully imported <strong>%d</strong> snippet. <a href=\"%s\">Have fun!</"
|
325 |
+
"a>"
|
326 |
+
msgstr ""
|
327 |
+
|
328 |
+
#: includes/import/admin-messages.php:30
|
329 |
+
msgid "An error occurred when processing the import file."
|
330 |
+
msgstr ""
|
331 |
+
|
332 |
+
#: includes/import/admin.php:18 includes/import/import.php:55
|
333 |
+
msgid "Import Snippets"
|
334 |
+
msgstr ""
|
335 |
+
|
336 |
+
#: includes/import/admin.php:22
|
337 |
+
msgid ""
|
338 |
+
"Howdy! Upload your Code Snippets export file and we’ll import the "
|
339 |
+
"snippets to this site."
|
340 |
+
msgstr ""
|
341 |
+
|
342 |
+
#: includes/import/admin.php:24
|
343 |
+
#, php-format
|
344 |
+
msgid ""
|
345 |
+
"You will need to go to the <a href=\"%s\">Manage Snippets</a> page to "
|
346 |
+
"activate the imported snippets."
|
347 |
+
msgstr ""
|
348 |
+
|
349 |
+
#: includes/import/admin.php:26
|
350 |
+
msgid ""
|
351 |
+
"Choose a Code Snippets (.xml) file to upload, then click Upload file and "
|
352 |
+
"import."
|
353 |
+
msgstr ""
|
354 |
+
|
355 |
+
#: includes/import/admin.php:33
|
356 |
+
msgid "Choose a file from your computer:"
|
357 |
+
msgstr ""
|
358 |
+
|
359 |
+
#: includes/import/admin.php:34
|
360 |
+
msgid "(Maximum size: 8MB)"
|
361 |
+
msgstr ""
|
362 |
+
|
363 |
+
#: includes/import/admin.php:40
|
364 |
+
msgid "Upload file and import"
|
365 |
+
msgstr ""
|
366 |
+
|
367 |
+
#: includes/import/import.php:34
|
368 |
+
msgid "Code Snippets"
|
369 |
+
msgstr ""
|
370 |
+
|
371 |
+
#: includes/import/import.php:35
|
372 |
+
msgid "Import snippets from a code snippets export file"
|
373 |
+
msgstr ""
|
374 |
+
|
375 |
+
#: includes/import/import.php:56
|
376 |
+
msgid "Import"
|
377 |
+
msgstr ""
|
378 |
+
|
379 |
+
#: includes/import/import.php:92
|
380 |
+
msgid "You are not access this page."
|
381 |
+
msgstr ""
|
382 |
+
|
383 |
+
#: includes/manage/admin-help.php:17
|
384 |
+
msgid ""
|
385 |
+
"Snippets are similar to plugins - they both extend and expand the "
|
386 |
+
"functionality of WordPress. Snippets are more light-weight, just a few lines "
|
387 |
+
"of code, and do not put as much load on your server. Here you can manage "
|
388 |
+
"your existing snippets and preform tasks on them such as activating, "
|
389 |
+
"deactivating, deleting and exporting."
|
390 |
+
msgstr ""
|
391 |
+
|
392 |
+
#: includes/manage/admin-help.php:22
|
393 |
+
msgid "Safe Mode"
|
394 |
+
msgstr ""
|
395 |
+
|
396 |
+
#: includes/manage/admin-help.php:24
|
397 |
+
msgid ""
|
398 |
+
"Be sure to check your snippets for errors before you activate them, as a "
|
399 |
+
"faulty snippet could bring your whole blog down. If your site starts doing "
|
400 |
+
"strange things, deactivate all your snippets and activate them one at a time."
|
401 |
+
msgstr ""
|
402 |
+
|
403 |
+
#: includes/manage/admin-help.php:25
|
404 |
+
msgid ""
|
405 |
+
"If something goes wrong with a snippet and you can't use WordPress, you can "
|
406 |
+
"cause all snippets to stop executing by adding "
|
407 |
+
"<code>define('CODE_SNIPPETS_SAFE_MODE', true);</code> to your <code>wp-"
|
408 |
+
"config.php</code> file. After you have deactivated the offending snippet, "
|
409 |
+
"you can turn off safe mode by removing this line or replacing <strong>true</"
|
410 |
+
"strong> with <strong>false</strong>."
|
411 |
+
msgstr ""
|
412 |
+
|
413 |
+
#: includes/manage/admin-help.php:30
|
414 |
+
msgid "Uninstall"
|
415 |
+
msgstr ""
|
416 |
+
|
417 |
+
#: includes/manage/admin-help.php:32
|
418 |
+
#, php-format
|
419 |
+
msgid ""
|
420 |
+
"When you delete Code Snippets through the Plugins menu in WordPress it will "
|
421 |
+
"clear up the <code>%1$s</code> table and a few other bits of data stored in "
|
422 |
+
"the database. If you want to keep this data (ie: you are only temporally "
|
423 |
+
"uninstalling Code Snippets) then remove the <code>%2$s</code> folder using "
|
424 |
+
"FTP."
|
425 |
+
msgstr ""
|
426 |
+
|
427 |
+
#: includes/manage/admin-help.php:33
|
428 |
+
msgid ""
|
429 |
+
"Even if you're sure that you don't want to use Code Snippets ever again on "
|
430 |
+
"this WordPress installation, you may want to use the export feature to back "
|
431 |
+
"up your snippets."
|
432 |
+
msgstr ""
|
433 |
+
|
434 |
+
#: includes/manage/admin-help.php:38
|
435 |
+
msgid ""
|
436 |
+
"<a href=\"http://wordpress.org/plugins/code-snippets\" target=\"_blank"
|
437 |
+
"\">WordPress Extend</a></p>"
|
438 |
+
msgstr ""
|
439 |
+
|
440 |
+
#: includes/manage/admin-messages.php:14
|
441 |
+
msgid ""
|
442 |
+
"<strong>Warning:</strong> Safe mode is active and snippets will not execute! "
|
443 |
+
"Remove the <code>CODE_SNIPPETS_SAFE_MODE</code> constant from <code>wp-"
|
444 |
+
"config.php</code> to turn off safe mode. <a href=\"http://code-snippets."
|
445 |
+
"bungeshea.com/docs/safe-mode/\" target=\"_blank\">Help</a>"
|
446 |
+
msgstr ""
|
447 |
+
|
448 |
+
#: includes/manage/admin-messages.php:20
|
449 |
+
msgid "Snippet <strong>activated</strong>."
|
450 |
+
msgstr ""
|
451 |
+
|
452 |
+
#: includes/manage/admin-messages.php:24
|
453 |
+
msgid "Selected snippets <strong>activated</strong>."
|
454 |
+
msgstr ""
|
455 |
+
|
456 |
+
#: includes/manage/admin-messages.php:28
|
457 |
+
msgid "Snippet <strong>deactivated</strong>."
|
458 |
+
msgstr ""
|
459 |
+
|
460 |
+
#: includes/manage/admin-messages.php:32
|
461 |
+
msgid "Selected snippets <strong>deactivated</strong>."
|
462 |
+
msgstr ""
|
463 |
+
|
464 |
+
#: includes/manage/admin-messages.php:36
|
465 |
+
msgid "Snippet <strong>deleted</strong>."
|
466 |
+
msgstr ""
|
467 |
+
|
468 |
+
#: includes/manage/admin-messages.php:40
|
469 |
+
msgid "Selected snippets <strong>deleted</strong>."
|
470 |
+
msgstr ""
|
471 |
+
|
472 |
+
#: includes/manage/admin.php:39
|
473 |
+
msgid "Search Installed Snippets"
|
474 |
+
msgstr ""
|
475 |
+
|
476 |
+
#: includes/manage/class-list-table.php:51
|
477 |
+
msgid "Snippets per page"
|
478 |
+
msgstr ""
|
479 |
+
|
480 |
+
#: includes/manage/class-list-table.php:132
|
481 |
+
#: includes/manage/class-list-table.php:281
|
482 |
+
msgid "Network Deactivate"
|
483 |
+
msgstr ""
|
484 |
+
|
485 |
+
#: includes/manage/class-list-table.php:132
|
486 |
+
#: includes/manage/class-list-table.php:281
|
487 |
+
msgid "Deactivate"
|
488 |
+
msgstr ""
|
489 |
+
|
490 |
+
#: includes/manage/class-list-table.php:141
|
491 |
+
#: includes/manage/class-list-table.php:280
|
492 |
+
msgid "Network Activate"
|
493 |
+
msgstr ""
|
494 |
+
|
495 |
+
#: includes/manage/class-list-table.php:141
|
496 |
+
#: includes/manage/class-list-table.php:280
|
497 |
+
msgid "Activate"
|
498 |
+
msgstr ""
|
499 |
+
|
500 |
+
#: includes/manage/class-list-table.php:151
|
501 |
+
msgid "Edit"
|
502 |
+
msgstr ""
|
503 |
+
|
504 |
+
#: includes/manage/class-list-table.php:173
|
505 |
+
msgid ""
|
506 |
+
"You are about to permanently delete the selected item.\n"
|
507 |
+
"\t\t\t\t'Cancel' to stop, 'OK' to delete."
|
508 |
+
msgstr ""
|
509 |
+
|
510 |
+
#: includes/manage/class-list-table.php:181
|
511 |
+
#, php-format
|
512 |
+
msgid "Untitled #%d"
|
513 |
+
msgstr ""
|
514 |
+
|
515 |
+
#: includes/manage/class-list-table.php:240
|
516 |
+
msgid "Name"
|
517 |
+
msgstr ""
|
518 |
+
|
519 |
+
#: includes/manage/class-list-table.php:241
|
520 |
+
msgid "ID"
|
521 |
+
msgstr ""
|
522 |
+
|
523 |
+
#: includes/manage/class-list-table.php:284
|
524 |
+
msgid "Export to PHP"
|
525 |
+
msgstr ""
|
526 |
+
|
527 |
+
#: includes/manage/class-list-table.php:321
|
528 |
+
#, php-format
|
529 |
+
msgid "All <span class=\"count\">(%s)</span>"
|
530 |
+
msgstr ""
|
531 |
+
|
532 |
+
#: includes/manage/class-list-table.php:324
|
533 |
+
#, php-format
|
534 |
+
msgid "Active <span class=\"count\">(%s)</span>"
|
535 |
+
msgstr ""
|
536 |
+
|
537 |
+
#: includes/manage/class-list-table.php:327
|
538 |
+
#, php-format
|
539 |
+
msgid "Recently Active <span class=\"count\">(%s)</span>"
|
540 |
+
msgstr ""
|
541 |
+
|
542 |
+
#: includes/manage/class-list-table.php:330
|
543 |
+
#, php-format
|
544 |
+
msgid "Inactive <span class=\"count\">(%s)</span>"
|
545 |
+
msgstr ""
|
546 |
+
|
547 |
+
#: includes/manage/class-list-table.php:390
|
548 |
+
msgid "Show all tags"
|
549 |
+
msgstr ""
|
550 |
+
|
551 |
+
#: includes/manage/class-list-table.php:404
|
552 |
+
msgid "Filter"
|
553 |
+
msgstr ""
|
554 |
+
|
555 |
+
#: includes/manage/class-list-table.php:412
|
556 |
+
msgid "Clear List"
|
557 |
+
msgstr ""
|
558 |
+
|
559 |
+
#: includes/manage/class-list-table.php:560
|
560 |
+
#, php-format
|
561 |
+
msgid ""
|
562 |
+
"You do not appear to have any snippets available at this time. <a href=\"%s"
|
563 |
+
"\">Add New→</a>"
|
564 |
+
msgstr ""
|
565 |
+
|
566 |
+
#: includes/manage/class-list-table.php:784
|
567 |
+
msgid "Search results"
|
568 |
+
msgstr ""
|
569 |
+
|
570 |
+
#: includes/manage/class-list-table.php:787
|
571 |
+
#, php-format
|
572 |
+
msgid " for “%s”"
|
573 |
+
msgstr ""
|
574 |
+
|
575 |
+
#: includes/manage/class-list-table.php:791
|
576 |
+
#, php-format
|
577 |
+
msgid " in tag “%s”"
|
578 |
+
msgstr ""
|
579 |
+
|
580 |
+
#: includes/manage/class-list-table.php:797
|
581 |
+
msgid "Clear Filters"
|
582 |
+
msgstr ""
|
583 |
+
|
584 |
+
#: includes/settings/admin.php:20
|
585 |
+
msgid "Snippets Settings"
|
586 |
+
msgstr ""
|
587 |
+
|
588 |
+
#: includes/settings/admin.php:21 includes/settings/admin.php:40
|
589 |
+
msgid "Settings"
|
590 |
+
msgstr ""
|
591 |
+
|
592 |
+
#: includes/settings/settings.php:51
|
593 |
+
msgid "General"
|
594 |
+
msgstr ""
|
595 |
+
|
596 |
+
#: includes/settings/settings.php:52
|
597 |
+
msgid "Editor"
|
598 |
+
msgstr ""
|
599 |
+
|
600 |
+
#: includes/settings/settings.php:68
|
601 |
+
msgid "Activate by Default"
|
602 |
+
msgstr ""
|
603 |
+
|
604 |
+
#: includes/settings/settings.php:70
|
605 |
+
msgid ""
|
606 |
+
"Make the 'Save and Activate' button the default action when saving a snippet."
|
607 |
+
msgstr ""
|
608 |
+
|
609 |
+
#: includes/settings/settings.php:80
|
610 |
+
msgid "Theme"
|
611 |
+
msgstr ""
|
612 |
+
|
613 |
+
#: includes/settings/settings.php:88
|
614 |
+
msgid "Indent With Tabs"
|
615 |
+
msgstr ""
|
616 |
+
|
617 |
+
#: includes/settings/settings.php:90
|
618 |
+
msgid "Use hard tabs (not spaces) for indentation."
|
619 |
+
msgstr ""
|
620 |
+
|
621 |
+
#: includes/settings/settings.php:97
|
622 |
+
msgid "Tab Size"
|
623 |
+
msgstr ""
|
624 |
+
|
625 |
+
#: includes/settings/settings.php:99
|
626 |
+
msgid "The width of a tab character."
|
627 |
+
msgstr ""
|
628 |
+
|
629 |
+
#: includes/settings/settings.php:106
|
630 |
+
msgid "Indent Unit"
|
631 |
+
msgstr ""
|
632 |
+
|
633 |
+
#: includes/settings/settings.php:108
|
634 |
+
msgid "How many spaces a block should be indented."
|
635 |
+
msgstr ""
|
636 |
+
|
637 |
+
#: includes/settings/settings.php:115
|
638 |
+
msgid "Wrap Lines"
|
639 |
+
msgstr ""
|
640 |
+
|
641 |
+
#: includes/settings/settings.php:117
|
642 |
+
msgid "Whether the editor should scroll or wrap for long lines."
|
643 |
+
msgstr ""
|
644 |
+
|
645 |
+
#: includes/settings/settings.php:124
|
646 |
+
msgid "Line Numbers"
|
647 |
+
msgstr ""
|
648 |
+
|
649 |
+
#: includes/settings/settings.php:126
|
650 |
+
msgid "Show line numbers to the left of the editor."
|
651 |
+
msgstr ""
|
652 |
+
|
653 |
+
#: includes/settings/settings.php:133
|
654 |
+
msgid "Auto Close Brackets"
|
655 |
+
msgstr ""
|
656 |
+
|
657 |
+
#: includes/settings/settings.php:135
|
658 |
+
msgid "Auto-close brackets and quotes when typed."
|
659 |
+
msgstr ""
|
660 |
+
|
661 |
+
#: includes/settings/settings.php:142
|
662 |
+
msgid "Highlight Selection Matches"
|
663 |
+
msgstr ""
|
664 |
+
|
665 |
+
#: includes/settings/settings.php:143
|
666 |
+
msgid "Highlight all instances of a currently selected word."
|
667 |
+
msgstr ""
|
668 |
+
|
669 |
+
#: includes/settings/settings.php:190
|
670 |
+
msgid "Editor Preview"
|
671 |
+
msgstr ""
|
672 |
+
|
673 |
+
#: includes/settings/settings.php:238
|
674 |
+
msgid "Settings saved."
|
675 |
+
msgstr ""
|
@@ -1,7 +1,7 @@
|
|
1 |
-
Copyright (c) 2012-2014 Shea Bunge
|
2 |
-
|
3 |
-
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
4 |
-
|
5 |
-
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
6 |
-
|
7 |
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
1 |
+
Copyright (c) 2012-2014 Shea Bunge
|
2 |
+
|
3 |
+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
4 |
+
|
5 |
+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
6 |
+
|
7 |
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
@@ -1,319 +1,355 @@
|
|
1 |
-
=== Code Snippets ===
|
2 |
-
Contributors: bungeshea
|
3 |
-
Donate link: http://code-snippets.bungeshea.com/donate/
|
4 |
-
Tags: code-snippets, snippets, code, php, network, multisite
|
5 |
-
Requires at least: 3.3
|
6 |
-
Tested up to: 4.1
|
7 |
-
Stable tag:
|
8 |
-
License: MIT
|
9 |
-
License URI: license.txt
|
10 |
-
|
11 |
-
An easy, clean and simple way to add code snippets to your site.
|
12 |
-
|
13 |
-
== Description ==
|
14 |
-
|
15 |
-
**Code Snippets** is an easy, clean and simple way to add code snippets to your site. No need to edit to your theme's `functions.php` file again!
|
16 |
-
|
17 |
-
A snippet is a small chunk of PHP code that you can use to extend the functionality of a WordPress-powered website; essentially a mini-plugin with a *lot* less load on your site.
|
18 |
-
Most snippet-hosting sites tell you to add snippet code to your active theme's `functions.php` file, which can get rather long and messy after a while.
|
19 |
-
Code Snippets changes that by providing a GUI interface for adding snippets and **actually running them on your site** as if they were in your theme's `functions.php` file.
|
20 |
-
|
21 |
-
You can use a graphical interface, similar to the Plugins menu, to manage, activate, deactivate, edit and delete your snippets. Easily organize your snippets by adding a name and description using the visual editor. Code Snippets includes built-in syntax highlighting and other features to help you write your code. Snippets can be exported for transfer to another side, either in XML for later importing by the Code Snippets plugin, or in PHP for creating your own plugin or theme.
|
22 |
-
|
23 |
-
Although Code Snippets is designed to be easy-to-use and its interface looks, feels and acts as if it was a native part of WordPress, each screen includes a help tab, just in case you get stuck.
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
-
|
134 |
-
*
|
135 |
-
*
|
136 |
-
|
137 |
-
|
138 |
-
*
|
139 |
-
*
|
140 |
-
*
|
141 |
-
*
|
142 |
-
*
|
143 |
-
*
|
144 |
-
*
|
145 |
-
*
|
146 |
-
*
|
147 |
-
*
|
148 |
-
*
|
149 |
-
*
|
150 |
-
*
|
151 |
-
*
|
152 |
-
*
|
153 |
-
*
|
154 |
-
*
|
155 |
-
*
|
156 |
-
|
157 |
-
|
158 |
-
*
|
159 |
-
*
|
160 |
-
*
|
161 |
-
*
|
162 |
-
|
163 |
-
|
164 |
-
|
165 |
-
|
166 |
-
|
167 |
-
*
|
168 |
-
*
|
169 |
-
*
|
170 |
-
*
|
171 |
-
*
|
172 |
-
|
173 |
-
|
174 |
-
|
175 |
-
|
176 |
-
*
|
177 |
-
|
178 |
-
|
179 |
-
*
|
180 |
-
|
181 |
-
|
182 |
-
*
|
183 |
-
*
|
184 |
-
*
|
185 |
-
*
|
186 |
-
*
|
187 |
-
*
|
188 |
-
*
|
189 |
-
|
190 |
-
|
191 |
-
*
|
192 |
-
*
|
193 |
-
* Updated
|
194 |
-
*
|
195 |
-
*
|
196 |
-
|
197 |
-
|
198 |
-
*
|
199 |
-
*
|
200 |
-
*
|
201 |
-
|
202 |
-
|
203 |
-
*
|
204 |
-
|
205 |
-
|
206 |
-
|
207 |
-
*
|
208 |
-
*
|
209 |
-
*
|
210 |
-
*
|
211 |
-
*
|
212 |
-
*
|
213 |
-
*
|
214 |
-
|
215 |
-
|
216 |
-
*
|
217 |
-
|
218 |
-
|
219 |
-
|
220 |
-
|
221 |
-
|
222 |
-
*
|
223 |
-
|
224 |
-
|
225 |
-
|
226 |
-
|
227 |
-
|
228 |
-
*
|
229 |
-
|
230 |
-
|
231 |
-
*
|
232 |
-
*
|
233 |
-
|
234 |
-
|
235 |
-
*
|
236 |
-
*
|
237 |
-
*
|
238 |
-
*
|
239 |
-
|
240 |
-
|
241 |
-
|
242 |
-
|
243 |
-
|
244 |
-
*
|
245 |
-
|
246 |
-
|
247 |
-
|
248 |
-
*
|
249 |
-
*
|
250 |
-
|
251 |
-
|
252 |
-
*
|
253 |
-
*
|
254 |
-
*
|
255 |
-
*
|
256 |
-
|
257 |
-
|
258 |
-
* Fixed
|
259 |
-
|
260 |
-
|
261 |
-
|
262 |
-
|
263 |
-
*
|
264 |
-
|
265 |
-
|
266 |
-
|
267 |
-
|
268 |
-
|
269 |
-
*
|
270 |
-
*
|
271 |
-
|
272 |
-
|
273 |
-
|
274 |
-
= 1.
|
275 |
-
|
276 |
-
|
277 |
-
|
278 |
-
|
279 |
-
|
280 |
-
= 1.
|
281 |
-
|
282 |
-
|
283 |
-
= 1.
|
284 |
-
|
285 |
-
|
286 |
-
|
287 |
-
|
288 |
-
|
289 |
-
|
290 |
-
|
291 |
-
|
292 |
-
|
293 |
-
Added
|
294 |
-
|
295 |
-
|
296 |
-
|
297 |
-
|
298 |
-
|
299 |
-
|
300 |
-
|
301 |
-
|
302 |
-
|
303 |
-
|
304 |
-
|
305 |
-
|
306 |
-
|
307 |
-
=
|
308 |
-
|
309 |
-
|
310 |
-
= 1.
|
311 |
-
|
312 |
-
|
313 |
-
= 1.
|
314 |
-
|
315 |
-
|
316 |
-
|
317 |
-
|
318 |
-
|
319 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
=== Code Snippets ===
|
2 |
+
Contributors: bungeshea
|
3 |
+
Donate link: http://code-snippets.bungeshea.com/donate/
|
4 |
+
Tags: code-snippets, snippets, code, php, network, multisite
|
5 |
+
Requires at least: 3.3
|
6 |
+
Tested up to: 4.1.1
|
7 |
+
Stable tag: 2.0
|
8 |
+
License: MIT
|
9 |
+
License URI: license.txt
|
10 |
+
|
11 |
+
An easy, clean and simple way to add code snippets to your site.
|
12 |
+
|
13 |
+
== Description ==
|
14 |
+
|
15 |
+
**Code Snippets** is an easy, clean and simple way to add code snippets to your site. No need to edit to your theme's `functions.php` file again!
|
16 |
+
|
17 |
+
A snippet is a small chunk of PHP code that you can use to extend the functionality of a WordPress-powered website; essentially a mini-plugin with a *lot* less load on your site.
|
18 |
+
Most snippet-hosting sites tell you to add snippet code to your active theme's `functions.php` file, which can get rather long and messy after a while.
|
19 |
+
Code Snippets changes that by providing a GUI interface for adding snippets and **actually running them on your site** as if they were in your theme's `functions.php` file.
|
20 |
+
|
21 |
+
You can use a graphical interface, similar to the Plugins menu, to manage, activate, deactivate, edit and delete your snippets. Easily organize your snippets by adding a name and description using the visual editor. Code Snippets includes built-in syntax highlighting and other features to help you write your code. Snippets can be exported for transfer to another side, either in XML for later importing by the Code Snippets plugin, or in PHP for creating your own plugin or theme.
|
22 |
+
|
23 |
+
Although Code Snippets is designed to be easy-to-use and its interface looks, feels and acts as if it was a native part of WordPress, each screen includes a help tab, just in case you get stuck.
|
24 |
+
|
25 |
+
Further information, documentation and updates are available on the [plugin homepage](http://code-snippets.bungeshea.com). You can also contribute to the code at [GitHub](https://github.com/bungeshea/code-snippets).
|
26 |
+
|
27 |
+
If you have any feedback, issues, or suggestions for improvements please leave a topic in the [Support Forum](http://wordpress.org/support/plugin/code-snippets). If you like the plugin, or it is useful to you in any way, please review it on [WordPress.org](http://wordpress.org/support/view/plugin-reviews/code-snippets).
|
28 |
+
|
29 |
+
=== Translations ===
|
30 |
+
|
31 |
+
Code Snippets can be used in these different languages thanks to the following translators:
|
32 |
+
|
33 |
+
* German - [David Decker](http://deckerweb.de)
|
34 |
+
* French - [oWEB](http://office-web.net)
|
35 |
+
* Japanese - [mt8](http://mt8.biz/)
|
36 |
+
* Serbo-Croatian - [Borisa Djuraskovic from Web Hosting Hub](http://www.webhostinghub.com/)
|
37 |
+
* Chinese - [Jincheng Shan](http://shanjincheng.com)
|
38 |
+
* Russian - [Alexander Samsonov](http://www.wordpressplugins.ru/administration/code-snippets.html)
|
39 |
+
* Slovak - [Ján Fajčák](http://wp.sk)
|
40 |
+
|
41 |
+
== Installation ==
|
42 |
+
|
43 |
+
= Automatic installation =
|
44 |
+
|
45 |
+
1. Log into your WordPress admin
|
46 |
+
2. Click __Plugins__
|
47 |
+
3. Click __Add New__
|
48 |
+
4. Search for __Code Snippets__
|
49 |
+
5. Click __Install Now__ under "Code Snippets"
|
50 |
+
6. Activate the plugin
|
51 |
+
|
52 |
+
= Manual installation =
|
53 |
+
|
54 |
+
1. Download the plugin
|
55 |
+
2. Extract the contents of the zip file
|
56 |
+
3. Upload the contents of the zip file to the `wp-content/plugins/` folder of your WordPress installation
|
57 |
+
4. Activate the Code Snippets plugin from 'Plugins' page.
|
58 |
+
|
59 |
+
**Network Activating** Code Snippets through the Network Dashboard will enable a special interface for running snippets across the entire network.
|
60 |
+
|
61 |
+
== Frequently Asked Questions ==
|
62 |
+
|
63 |
+
Further documentation is available on the [plugin website](http://code-snippets.bungeshea.com/).
|
64 |
+
|
65 |
+
= How can I insert my snippet into the post text editor? =
|
66 |
+
Snippets that you add to this plugin are not meant to be inserted into the text editor. Instead, they are run on your site just as if they were added to your functions.php file.
|
67 |
+
|
68 |
+
= Do I need to include the `<?php`, `<?` or `?>` tags in my snippet? =
|
69 |
+
No, just copy all the content inside those tags. If you accidentally forget (or just like being lazy), the tags will be stripped from the beginning and end of the snippet when you save it. You can, however, use those tags *inside* your snippets to start and end HTML sections
|
70 |
+
|
71 |
+
= Help! I just activated a snippet, and my whole site broke! =
|
72 |
+
You can try activating 'safe mode'. All snippets will not execute while safe mode is active, allowing you to access your site and deactivate the snippet that is causing the error. To activate safe mode, add the following line to your wp-config.php file, just before the line that reads `/* That's all, stop editing! Happy blogging. */`:
|
73 |
+
|
74 |
+
define('CODE_SNIPPETS_SAFE_MODE', true);
|
75 |
+
|
76 |
+
To turn safe mode off, either [comment out](http://php.net/manual/language.basic-syntax.comments.php) this line or delete it.
|
77 |
+
|
78 |
+
= Is there a way to add a snippet but not run it right away? =
|
79 |
+
Yes. Just add it but do not activate it yet.
|
80 |
+
|
81 |
+
= What do I use to write my snippets? =
|
82 |
+
The [CodeMirror](http://codemirror.net) source-code editor will add line numbers, syntax highlighting, bracket matching, search, tabulate and other cool features to the code editor.
|
83 |
+
|
84 |
+
= Can I preform search and replace commands in the code editor? =
|
85 |
+
|
86 |
+
* __Ctrl-F / Cmd-F__ : Start searching
|
87 |
+
* __Ctrl-G / Cmd-G__ : Find next
|
88 |
+
* __Shift-Ctrl-G / Shift-Cmd-G__ : Find previous
|
89 |
+
* __Shift-Ctrl-F / Cmd-Option-F__ : Replace
|
90 |
+
* __Shift-Ctrl-R / Shift-Cmd-Option-F__ : Replace all
|
91 |
+
|
92 |
+
= Will I lose my snippets if I change the theme or upgrade WordPress? =
|
93 |
+
No, the snippets are stored in the WordPress database and are independent of the theme and unaffected by WordPress upgrades.
|
94 |
+
|
95 |
+
= Can the plugin be completely uninstalled? =
|
96 |
+
Yes, when you delete Code Snippets using the 'Plugins' menu in WordPress it will clean up the database table and a few other bits of data. Be careful not to remove Code Snippets by deleting it from the Plugins menu unless you want this to happen.
|
97 |
+
|
98 |
+
= Can I copy any snippets I've created to another WordPress site? =
|
99 |
+
Yes! You can individually export a single snippet using the link below the snippet name on the 'Manage Snippets' page or bulk export multiple snippets using the 'Bulk Actions' feature. Snippets can later be imported using the 'Import Snippets' page by uploading the export file.
|
100 |
+
|
101 |
+
= Can I export my snippets to PHP for a site where I'm not using the Code Snippets plugin? =
|
102 |
+
Yes. Click the checkboxes next to the snippets you want to export, and then choose **Export to PHP** from the Bulk Actions menu and click Apply. The generated PHP file will contain the exported snippets' code, as well as their name and description in comments.
|
103 |
+
|
104 |
+
= Can I run network-wide snippets on a multisite installation? =
|
105 |
+
You can run snippets across an entire multisite network by **Network Activating** Code Snippets through the Network Dashboard. You can also activate Code Snippets just on the main site, and then individually on other sites of your choice.
|
106 |
+
|
107 |
+
## Where are the snippets stored in my WordPress database?
|
108 |
+
Snippets are stored in the `wp_snippets` table in the WordPress database. The table name may differ depending on what your table prefix is set to.
|
109 |
+
|
110 |
+
= I need help with Code Snippets =
|
111 |
+
You can get help with Code Snippets either on the [WordPress Support Forums][support], on [GithHub][issues], or on [WordPress Answers](http://wordpress.stackexchange.com).
|
112 |
+
|
113 |
+
= I have an idea for a cool feature for Code Snippets! =
|
114 |
+
That's great! Let me know by starting (or adding to) a topic in the [Support Forums][support] or open an issue on [GitHub][issues].
|
115 |
+
|
116 |
+
= I want to contribute to and help develop the Code Snippets plugin! =
|
117 |
+
That's fantastic! Join me on [GitHub](http://github.com/bungeshea/code-snippets), and also be sure to check out the [development page](http://code-snippets.bungeshea.com/development/) on the [project website](http://code-snippets.bungeshea.com).
|
118 |
+
|
119 |
+
== Screenshots ==
|
120 |
+
|
121 |
+
1. Managing existing snippets
|
122 |
+
2. Adding a new snippet
|
123 |
+
3. Editing a snippet
|
124 |
+
4. Importing snippets from an XML file
|
125 |
+
|
126 |
+
== Changelog ==
|
127 |
+
|
128 |
+
= 2.0 =
|
129 |
+
|
130 |
+
**Highlights:**
|
131 |
+
|
132 |
+
* Better import/export functionality
|
133 |
+
* New settings page with code editor settings
|
134 |
+
* Code rewritten for cleaner and more efficient code
|
135 |
+
* Lots of new translations
|
136 |
+
|
137 |
+
|
138 |
+
* Removed old admin style support
|
139 |
+
* Removed backwards-compatible support
|
140 |
+
* Added braces to single-line conditionals in line with [new coding standards](https://make.wordpress.org/core/2013/11/13/proposed-coding-standards-change-always-require-braces/)
|
141 |
+
* Split up large classes into separate functions
|
142 |
+
* Improved plugin file structure
|
143 |
+
* Replaced uninstall hook with single file method
|
144 |
+
* Added link to Code Snippets importer under Snippets admin menu
|
145 |
+
* Added settings component and admin page
|
146 |
+
* Added support for different CodeMirror themes
|
147 |
+
* Integrated tags component into main plugin. Current users of the Code Snippets Tags plugin can safely uninstall it.
|
148 |
+
* Added Auto Close Brackets CodeMirror addon (props to TronicLabs)
|
149 |
+
* Fixed incompatibility errors with PHP 5.2
|
150 |
+
* Added Serbo-Croatian translation by Borisa Djuraskovic from [Web Hosting Hub](http://www.webhostinghub.com)
|
151 |
+
* Fixed empty MO translation files
|
152 |
+
* Added Highlight Selection Matches CodeMirror addon (props to TronicLabs)
|
153 |
+
* Added Chinese translation thanks to Jincheng Shan
|
154 |
+
* Updated CodeMirror library to version 4.6
|
155 |
+
* Added Russian translation by Alexander Samsonov
|
156 |
+
* Added Slovak translation by [Ján Fajčák] from [WordPress Slovakia](http://wp.sk)
|
157 |
+
* Added setting to always save and activate snippets by default
|
158 |
+
* Updated CodeMirror library to version 5.0
|
159 |
+
* Rewritten import/export functionality to use DOMDocument
|
160 |
+
* Merged Code_Snippets_Export_PHP class into Code_Snippets_Export class
|
161 |
+
* Removed duplicate MySQL primary key indexing
|
162 |
+
|
163 |
+
= 1.9.1.1
|
164 |
+
* Add capability check to site snippets importer
|
165 |
+
|
166 |
+
= 1.9.1 =
|
167 |
+
* Use an icon font for menu icon instead of embedded SVG
|
168 |
+
* Use Sass (libsass) instead of Compass
|
169 |
+
* Unminify CodeMirror scripts
|
170 |
+
* Fixes for the WP 3.8 interface
|
171 |
+
* Fix 'enable snippets menu for site admins' multisite setting
|
172 |
+
|
173 |
+
= 1.9 =
|
174 |
+
* Add and remove network capabilities as super admins are added and removed
|
175 |
+
* Updated MP6 icon implementation
|
176 |
+
* Replaced buggy trim `<?php` and `?>` functionality with a much more reliable regex method ([#](http://wordpress.org/support/topic/character-gets-cut))
|
177 |
+
* Added French translation thanks to translator [oWEB](http://office-web.net)
|
178 |
+
* Fixed snippet failing to save when code contains `%` character, props to [nikan06](http://wordpress.org/support/profile/nikan06) ([#](http://wordpress.org/support/topic/percent-sign-bug))
|
179 |
+
* Added 'Save & Deactivate' button to the edit snippet page ([#](http://wordpress.org/support/topic/deactivate-button-in-edit-snippet-page))
|
180 |
+
* Removed edit and install capabilities (now only uses the manage capability)
|
181 |
+
* Fixed HTML breaking in export files ([#](http://wordpress.org/support/topic/import-problem-7))
|
182 |
+
* Make the title of each snippet on the manage page a clickable link to edit the snippet ([#](http://wordpress.org/support/topic/deactivate-button-in-edit-snippet-page?replies=9#post-4682757))
|
183 |
+
* Added nonce to edit snippet page
|
184 |
+
* Hide row actions on manage snippet page by default
|
185 |
+
* Removed screenshots from plugin
|
186 |
+
* Improved CodeMirror implementation
|
187 |
+
* Added a fallback MP6 icon
|
188 |
+
* Use the proper WordPress database APIs all of the time
|
189 |
+
* Rewritten export functionality
|
190 |
+
* Fixed incorrect export filename
|
191 |
+
* Updated CodeMirror to version 3.19
|
192 |
+
* Removed CodeMirror bundled with plugin
|
193 |
+
* Updated WordPress.org plugin banner
|
194 |
+
* Fixed CodeMirror incompatibility with the WP Editor plugin
|
195 |
+
* Fixed CodeMirror incompatibility with the Debug Bar Console plugin
|
196 |
+
|
197 |
+
= 1.8.1 =
|
198 |
+
* Compiled all CodeMirror scripts into a single file
|
199 |
+
* Use Sass + Compass for CSS
|
200 |
+
* Use Grunt for build automation
|
201 |
+
* Minify CSS
|
202 |
+
* Fixed code typo that was breaking export files
|
203 |
+
* Updated CodeMirror to 3.15
|
204 |
+
|
205 |
+
= 1.8 =
|
206 |
+
* Allow no snippet name or code to be set
|
207 |
+
* Prevented an error on fresh multisite installations
|
208 |
+
* Refactored code to use best practices
|
209 |
+
* Improved database table creation method: on a single-site install, the snippets table will always be created. On a multisite install, the network snippets table will always be created; the site-specific table will always be created for the main site; for sub-sites the snippets table will only be created on a visit to a snippets admin page.
|
210 |
+
* Updated to CodeMirror 3.14
|
211 |
+
* Changes to action and filter hook API
|
212 |
+
* Added error message handling for import snippets page
|
213 |
+
* Don't encode HTML entities in database
|
214 |
+
|
215 |
+
= 1.7.1.2 =
|
216 |
+
* Correct path to admin menu icon ([#](http://wordpress.org/support/topic/icon-disappears-with-mp6?replies=6#post-4148319))
|
217 |
+
|
218 |
+
= 1.7.1.1 =
|
219 |
+
* Fix a minor bug with custom capabilities and admin menus
|
220 |
+
|
221 |
+
= 1.7.1 =
|
222 |
+
* Fix a bug with snippet being set as deactivated when saved
|
223 |
+
* Updated PHP Documentation completely. [View online](http://bungeshea.github.io/code-snippets/api)
|
224 |
+
* Only load admin functions when viewing dashboard
|
225 |
+
* Added German translation thanks to [David Decker](http://deckerweb.de)
|
226 |
+
* Allow or deny site administrators access to snippet admin menus. Set your preference in the **Enable Administration Menus** setting under the *Settings > Network Settings* network admin menu.
|
227 |
+
* Improve database table creation and upgrade process
|
228 |
+
* Optimized to use less database queries
|
229 |
+
|
230 |
+
= 1.7 =
|
231 |
+
* Improved plugin API
|
232 |
+
* Fixed a bug with saving snippets per page option ([#](http://wordpress.org/support/topic/plugin-code-snippets-snippets-per-page-does-not-work#post-3710991))
|
233 |
+
* Updated CodeMirror to version 3.11
|
234 |
+
* Allow plugin to be activated on individual sites on multisite ([#](http://wordpress.org/support/topic/dont-work-at-multisite))
|
235 |
+
* Slimmed down the description visual editor
|
236 |
+
* Added icon for the new MP6 admin UI ([#](http://wordpress.org/support/topic/icon-disappears-with-mp6))
|
237 |
+
* Strip PHP tags from the beginning and end of a snippet in case someone forgets
|
238 |
+
* Changed to [MIT license](http://opensource.org/licenses/mit-license.php)
|
239 |
+
* Removed HTML, CSS and JavaScript CodeMirror modes that were messing things up
|
240 |
+
* Made everything leaner, faster, and better
|
241 |
+
|
242 |
+
= 1.6.1 =
|
243 |
+
* Fixed a bug with permissions not being applied on install ([#](http://wordpress.org/support/topic/permissions-problem-after-install))
|
244 |
+
* Fixed a bug in the uninstall method ([#](http://wordpress.org/support/topic/bug-in-delete-script))
|
245 |
+
|
246 |
+
= 1.6 =
|
247 |
+
* Updated code editor to use CodeMirror 3
|
248 |
+
* Improved compatibility with Clean Options plugin
|
249 |
+
* Code improvements and optimization
|
250 |
+
* Changed namespace from `cs` to `code_snippets`
|
251 |
+
* Move css and js under assets
|
252 |
+
* Organized CodeMirror scripts
|
253 |
+
* Improved updating process
|
254 |
+
* Current line of code editor is now highlighted
|
255 |
+
* Highlight matches of selected text in code editor
|
256 |
+
* Only create snippet tables when needed
|
257 |
+
* Store multisite only options in site options table
|
258 |
+
* Fixed compatibility bugs with WordPress 3.5
|
259 |
+
|
260 |
+
= 1.5 =
|
261 |
+
* Updated CodeMirror to version 2.33
|
262 |
+
* Updated the 'Manage Snippets' page to use the WP_List_Table class
|
263 |
+
* Added 'Screen Options' tab to 'Manage Snippets' page
|
264 |
+
* Added search capability to 'Manage Snippets' page
|
265 |
+
* Added views to easily filter activated, deactivated and recently activated snippets
|
266 |
+
* Added ID column to 'Manage Snippets' page
|
267 |
+
* Added sortable name and ID column on 'Manage Snippets' page ([#](http://wordpress.org/support/topic/plugin-code-snippets-suggestion-sort-by-snippet-name))
|
268 |
+
* Added custom capabilities
|
269 |
+
* Improved API
|
270 |
+
* Added 'Export to PHP' feature ([#](http://wordpress.org/support/topic/plugin-code-snippets-suggestion-bulk-export-to-php))
|
271 |
+
* Lengthened snippet name field to 64 characters ([#](http://wordpress.org/support/topic/plugin-code-snippets-snippet-title-limited-to-36-characters))
|
272 |
+
* Added i18n
|
273 |
+
|
274 |
+
= 1.4 =
|
275 |
+
* Added interface to Network Dashboard
|
276 |
+
* Updated uninstall to support multisite
|
277 |
+
* Replaced EditArea with [CodeMirror](http://codemirror.net)
|
278 |
+
* Small improvements
|
279 |
+
|
280 |
+
= 1.3.2 =
|
281 |
+
* Fixed a bug with version 1.3.1
|
282 |
+
|
283 |
+
= 1.3.1 =
|
284 |
+
* Changed plugin website URI
|
285 |
+
* Cleaned up some code
|
286 |
+
|
287 |
+
= 1.3 =
|
288 |
+
* Added export option to 'Manage Snippets' page
|
289 |
+
* Added 'Import Snippets' page
|
290 |
+
|
291 |
+
= 1.2 =
|
292 |
+
* Minor improvements
|
293 |
+
* Added code highlighting
|
294 |
+
* Removed 'Uninstall Plugin' page
|
295 |
+
* Data will now be cleaned up when plugin is deleted through WordPress admin
|
296 |
+
|
297 |
+
= 1.1 =
|
298 |
+
* Fixed a permissions bug with `DISALLOW_FILE_EDIT` being set to true ([#](http://wordpress.org/support/topic/plugin-code-snippets-cant-add-new))
|
299 |
+
* Fixed a bug with the page title reading 'Add New Snippet' on the 'Edit Snippets' page
|
300 |
+
* Fixed a bug not allowing the plugin to be Network Activated ([#](http://wordpress.org/support/topic/plugin-code-snippets-network-activate-does-not-create-snippets-tables))
|
301 |
+
|
302 |
+
= 1.0 =
|
303 |
+
* Stable version released.
|
304 |
+
|
305 |
+
== Upgrade Notice ==
|
306 |
+
|
307 |
+
= 2.0 =
|
308 |
+
Improved import/export; new settings page; improved core code; more translations
|
309 |
+
|
310 |
+
= 1.9.1.1 =
|
311 |
+
Add capability check to snippets importer
|
312 |
+
|
313 |
+
= 1.9.1 =
|
314 |
+
UI improvements for WordPress 3.8
|
315 |
+
|
316 |
+
= 1.8.1 =
|
317 |
+
Minimize CSS and JS; updated CodeMirror; fixed export files
|
318 |
+
|
319 |
+
= 1.8 =
|
320 |
+
Setting a snippet name and code are now optional; better table creation method; changes to API; bug fixes
|
321 |
+
|
322 |
+
= 1.7.1.2 =
|
323 |
+
Fixes the admin menu icon not loading
|
324 |
+
|
325 |
+
= 1.7.1.1 =
|
326 |
+
Fixes a minor bug with custom capabilities and admin menus
|
327 |
+
|
328 |
+
= 1.7.1 =
|
329 |
+
Added German translation thanks to David Decker; bug fixes and improvements
|
330 |
+
|
331 |
+
= 1.7 =
|
332 |
+
Many improvements and optimization. Download "Code Snippets Tags" plugin to add tags to snippets
|
333 |
+
|
334 |
+
= 1.6 =
|
335 |
+
Improvements and optimization with WordPress 3.5
|
336 |
+
|
337 |
+
= 1.5 =
|
338 |
+
Improvements on the 'Manage Snippets' page and localization
|
339 |
+
|
340 |
+
= 1.4 =
|
341 |
+
Better code highlighting and improved multisite support
|
342 |
+
|
343 |
+
= 1.3.2 =
|
344 |
+
Code Snippets has a new website: http://code-snippets.bungeshea.com/
|
345 |
+
|
346 |
+
= 1.3 =
|
347 |
+
Added import/export feature
|
348 |
+
|
349 |
+
= 1.2 =
|
350 |
+
Minor improvements |
|
351 |
+
Added code highlighting |
|
352 |
+
Plugin data will now be cleaned up when you delete the plugin.
|
353 |
+
|
354 |
+
= 1.1 =
|
355 |
+
Minor bug fixes and improvements on the the 'Edit Snippet' page
|
@@ -0,0 +1,74 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* Cleans up data created by this plugin
|
5 |
+
* @package Code_Snippets
|
6 |
+
* @since 2.0
|
7 |
+
*/
|
8 |
+
|
9 |
+
/* Ensure this plugin is actually being uninstalled */
|
10 |
+
if ( ! defined( 'WP_UNINSTALL_PLUGIN' ) ) {
|
11 |
+
exit();
|
12 |
+
}
|
13 |
+
|
14 |
+
/**
|
15 |
+
* Clean up data created by this plugin for a single site
|
16 |
+
* @since 2.0
|
17 |
+
*/
|
18 |
+
function code_snippets_uninstall_site() {
|
19 |
+
global $wpdb;
|
20 |
+
|
21 |
+
/* Remove snippets database table */
|
22 |
+
$wpdb->query( "DROP TABLE IF EXISTS $wpdb->snippets" );
|
23 |
+
|
24 |
+
/* Remove saved options */
|
25 |
+
delete_option( 'code_snippets_version' );
|
26 |
+
delete_option( 'recently_activated_snippets' );
|
27 |
+
|
28 |
+
/* Deregister capabilities */
|
29 |
+
$role = get_role( apply_filters( 'code_snippets_role', 'administrator' ) );
|
30 |
+
$role->remove_cap( apply_filters( 'code_snippets_cap', 'manage_snippets' ) );
|
31 |
+
}
|
32 |
+
|
33 |
+
|
34 |
+
global $wpdb;
|
35 |
+
|
36 |
+
$wpdb->snippets = $wpdb->prefix . 'snippets';
|
37 |
+
$wpdb->ms_snippets = $wpdb->prefix . 'ms_snippets';
|
38 |
+
|
39 |
+
/* Multisite uninstall */
|
40 |
+
|
41 |
+
if ( is_multisite() ) {
|
42 |
+
|
43 |
+
/* Loop through sites */
|
44 |
+
$blog_ids = $wpdb->get_col( "SELECT blog_id FROM $wpdb->blogs" );
|
45 |
+
|
46 |
+
if ( $blog_ids ) {
|
47 |
+
|
48 |
+
foreach ( $blog_ids as $blog_id ) {
|
49 |
+
switch_to_blog( $blog_id );
|
50 |
+
code_snippets_uninstall_site();
|
51 |
+
}
|
52 |
+
|
53 |
+
restore_current_blog();
|
54 |
+
}
|
55 |
+
|
56 |
+
/* Remove multisite snippets database table */
|
57 |
+
$wpdb->query( "DROP TABLE IF EXISTS $wpdb->ms_snippets" );
|
58 |
+
|
59 |
+
/* Remove saved options */
|
60 |
+
delete_site_option( 'code_snippets_version' );
|
61 |
+
delete_site_option( 'recently_activated_snippets' );
|
62 |
+
|
63 |
+
/* Remove multisite capabilities */
|
64 |
+
$network_cap = apply_filters( 'code_snippets_network_cap', 'manage_network_snippets' );
|
65 |
+
$supers = get_super_admins();
|
66 |
+
|
67 |
+
foreach ( $supers as $admin ) {
|
68 |
+
$user = new WP_User( 0, $admin );
|
69 |
+
$user->remove_cap( $network_cap );
|
70 |
+
}
|
71 |
+
|
72 |
+
} else {
|
73 |
+
code_snippets_uninstall_site();
|
74 |
+
}
|
@@ -1,87 +1,120 @@
|
|
1 |
-
(
|
2 |
-
|
3 |
-
|
4 |
-
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
var
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
var
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
function
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
// CodeMirror, copyright (c) by Marijn Haverbeke and others
|
2 |
+
// Distributed under an MIT license: http://codemirror.net/LICENSE
|
3 |
+
|
4 |
+
(function(mod) {
|
5 |
+
if (typeof exports == "object" && typeof module == "object") // CommonJS
|
6 |
+
mod(require("../../lib/codemirror"));
|
7 |
+
else if (typeof define == "function" && define.amd) // AMD
|
8 |
+
define(["../../lib/codemirror"], mod);
|
9 |
+
else // Plain browser env
|
10 |
+
mod(CodeMirror);
|
11 |
+
})(function(CodeMirror) {
|
12 |
+
var ie_lt8 = /MSIE \d/.test(navigator.userAgent) &&
|
13 |
+
(document.documentMode == null || document.documentMode < 8);
|
14 |
+
|
15 |
+
var Pos = CodeMirror.Pos;
|
16 |
+
|
17 |
+
var matching = {"(": ")>", ")": "(<", "[": "]>", "]": "[<", "{": "}>", "}": "{<"};
|
18 |
+
|
19 |
+
function findMatchingBracket(cm, where, strict, config) {
|
20 |
+
var line = cm.getLineHandle(where.line), pos = where.ch - 1;
|
21 |
+
var match = (pos >= 0 && matching[line.text.charAt(pos)]) || matching[line.text.charAt(++pos)];
|
22 |
+
if (!match) return null;
|
23 |
+
var dir = match.charAt(1) == ">" ? 1 : -1;
|
24 |
+
if (strict && (dir > 0) != (pos == where.ch)) return null;
|
25 |
+
var style = cm.getTokenTypeAt(Pos(where.line, pos + 1));
|
26 |
+
|
27 |
+
var found = scanForBracket(cm, Pos(where.line, pos + (dir > 0 ? 1 : 0)), dir, style || null, config);
|
28 |
+
if (found == null) return null;
|
29 |
+
return {from: Pos(where.line, pos), to: found && found.pos,
|
30 |
+
match: found && found.ch == match.charAt(0), forward: dir > 0};
|
31 |
+
}
|
32 |
+
|
33 |
+
// bracketRegex is used to specify which type of bracket to scan
|
34 |
+
// should be a regexp, e.g. /[[\]]/
|
35 |
+
//
|
36 |
+
// Note: If "where" is on an open bracket, then this bracket is ignored.
|
37 |
+
//
|
38 |
+
// Returns false when no bracket was found, null when it reached
|
39 |
+
// maxScanLines and gave up
|
40 |
+
function scanForBracket(cm, where, dir, style, config) {
|
41 |
+
var maxScanLen = (config && config.maxScanLineLength) || 10000;
|
42 |
+
var maxScanLines = (config && config.maxScanLines) || 1000;
|
43 |
+
|
44 |
+
var stack = [];
|
45 |
+
var re = config && config.bracketRegex ? config.bracketRegex : /[(){}[\]]/;
|
46 |
+
var lineEnd = dir > 0 ? Math.min(where.line + maxScanLines, cm.lastLine() + 1)
|
47 |
+
: Math.max(cm.firstLine() - 1, where.line - maxScanLines);
|
48 |
+
for (var lineNo = where.line; lineNo != lineEnd; lineNo += dir) {
|
49 |
+
var line = cm.getLine(lineNo);
|
50 |
+
if (!line) continue;
|
51 |
+
var pos = dir > 0 ? 0 : line.length - 1, end = dir > 0 ? line.length : -1;
|
52 |
+
if (line.length > maxScanLen) continue;
|
53 |
+
if (lineNo == where.line) pos = where.ch - (dir < 0 ? 1 : 0);
|
54 |
+
for (; pos != end; pos += dir) {
|
55 |
+
var ch = line.charAt(pos);
|
56 |
+
if (re.test(ch) && (style === undefined || cm.getTokenTypeAt(Pos(lineNo, pos + 1)) == style)) {
|
57 |
+
var match = matching[ch];
|
58 |
+
if ((match.charAt(1) == ">") == (dir > 0)) stack.push(ch);
|
59 |
+
else if (!stack.length) return {pos: Pos(lineNo, pos), ch: ch};
|
60 |
+
else stack.pop();
|
61 |
+
}
|
62 |
+
}
|
63 |
+
}
|
64 |
+
return lineNo - dir == (dir > 0 ? cm.lastLine() : cm.firstLine()) ? false : null;
|
65 |
+
}
|
66 |
+
|
67 |
+
function matchBrackets(cm, autoclear, config) {
|
68 |
+
// Disable brace matching in long lines, since it'll cause hugely slow updates
|
69 |
+
var maxHighlightLen = cm.state.matchBrackets.maxHighlightLineLength || 1000;
|
70 |
+
var marks = [], ranges = cm.listSelections();
|
71 |
+
for (var i = 0; i < ranges.length; i++) {
|
72 |
+
var match = ranges[i].empty() && findMatchingBracket(cm, ranges[i].head, false, config);
|
73 |
+
if (match && cm.getLine(match.from.line).length <= maxHighlightLen) {
|
74 |
+
var style = match.match ? "CodeMirror-matchingbracket" : "CodeMirror-nonmatchingbracket";
|
75 |
+
marks.push(cm.markText(match.from, Pos(match.from.line, match.from.ch + 1), {className: style}));
|
76 |
+
if (match.to && cm.getLine(match.to.line).length <= maxHighlightLen)
|
77 |
+
marks.push(cm.markText(match.to, Pos(match.to.line, match.to.ch + 1), {className: style}));
|
78 |
+
}
|
79 |
+
}
|
80 |
+
|
81 |
+
if (marks.length) {
|
82 |
+
// Kludge to work around the IE bug from issue #1193, where text
|
83 |
+
// input stops going to the textare whever this fires.
|
84 |
+
if (ie_lt8 && cm.state.focused) cm.display.input.focus();
|
85 |
+
|
86 |
+
var clear = function() {
|
87 |
+
cm.operation(function() {
|
88 |
+
for (var i = 0; i < marks.length; i++) marks[i].clear();
|
89 |
+
});
|
90 |
+
};
|
91 |
+
if (autoclear) setTimeout(clear, 800);
|
92 |
+
else return clear;
|
93 |
+
}
|
94 |
+
}
|
95 |
+
|
96 |
+
var currentlyHighlighted = null;
|
97 |
+
function doMatchBrackets(cm) {
|
98 |
+
cm.operation(function() {
|
99 |
+
if (currentlyHighlighted) {currentlyHighlighted(); currentlyHighlighted = null;}
|
100 |
+
currentlyHighlighted = matchBrackets(cm, false, cm.state.matchBrackets);
|
101 |
+
});
|
102 |
+
}
|
103 |
+
|
104 |
+
CodeMirror.defineOption("matchBrackets", false, function(cm, val, old) {
|
105 |
+
if (old && old != CodeMirror.Init)
|
106 |
+
cm.off("cursorActivity", doMatchBrackets);
|
107 |
+
if (val) {
|
108 |
+
cm.state.matchBrackets = typeof val == "object" ? val : {};
|
109 |
+
cm.on("cursorActivity", doMatchBrackets);
|
110 |
+
}
|
111 |
+
});
|
112 |
+
|
113 |
+
CodeMirror.defineExtension("matchBrackets", function() {matchBrackets(this, true);});
|
114 |
+
CodeMirror.defineExtension("findMatchingBracket", function(pos, strict, config){
|
115 |
+
return findMatchingBracket(this, pos, strict, config);
|
116 |
+
});
|
117 |
+
CodeMirror.defineExtension("scanForBracket", function(pos, dir, style, config){
|
118 |
+
return scanForBracket(this, pos, dir, style, config);
|
119 |
+
});
|
120 |
+
});
|
@@ -1,133 +1,164 @@
|
|
1 |
-
//
|
2 |
-
//
|
3 |
-
|
4 |
-
//
|
5 |
-
//
|
6 |
-
|
7 |
-
//
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
}
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
return
|
47 |
-
}
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
if
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
// CodeMirror, copyright (c) by Marijn Haverbeke and others
|
2 |
+
// Distributed under an MIT license: http://codemirror.net/LICENSE
|
3 |
+
|
4 |
+
// Define search commands. Depends on dialog.js or another
|
5 |
+
// implementation of the openDialog method.
|
6 |
+
|
7 |
+
// Replace works a little oddly -- it will do the replace on the next
|
8 |
+
// Ctrl-G (or whatever is bound to findNext) press. You prevent a
|
9 |
+
// replace by making sure the match is no longer selected when hitting
|
10 |
+
// Ctrl-G.
|
11 |
+
|
12 |
+
(function(mod) {
|
13 |
+
if (typeof exports == "object" && typeof module == "object") // CommonJS
|
14 |
+
mod(require("../../lib/codemirror"), require("./searchcursor"), require("../dialog/dialog"));
|
15 |
+
else if (typeof define == "function" && define.amd) // AMD
|
16 |
+
define(["../../lib/codemirror", "./searchcursor", "../dialog/dialog"], mod);
|
17 |
+
else // Plain browser env
|
18 |
+
mod(CodeMirror);
|
19 |
+
})(function(CodeMirror) {
|
20 |
+
"use strict";
|
21 |
+
function searchOverlay(query, caseInsensitive) {
|
22 |
+
if (typeof query == "string")
|
23 |
+
query = new RegExp(query.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g, "\\$&"), caseInsensitive ? "gi" : "g");
|
24 |
+
else if (!query.global)
|
25 |
+
query = new RegExp(query.source, query.ignoreCase ? "gi" : "g");
|
26 |
+
|
27 |
+
return {token: function(stream) {
|
28 |
+
query.lastIndex = stream.pos;
|
29 |
+
var match = query.exec(stream.string);
|
30 |
+
if (match && match.index == stream.pos) {
|
31 |
+
stream.pos += match[0].length;
|
32 |
+
return "searching";
|
33 |
+
} else if (match) {
|
34 |
+
stream.pos = match.index;
|
35 |
+
} else {
|
36 |
+
stream.skipToEnd();
|
37 |
+
}
|
38 |
+
}};
|
39 |
+
}
|
40 |
+
|
41 |
+
function SearchState() {
|
42 |
+
this.posFrom = this.posTo = this.query = null;
|
43 |
+
this.overlay = null;
|
44 |
+
}
|
45 |
+
function getSearchState(cm) {
|
46 |
+
return cm.state.search || (cm.state.search = new SearchState());
|
47 |
+
}
|
48 |
+
function queryCaseInsensitive(query) {
|
49 |
+
return typeof query == "string" && query == query.toLowerCase();
|
50 |
+
}
|
51 |
+
function getSearchCursor(cm, query, pos) {
|
52 |
+
// Heuristic: if the query string is all lowercase, do a case insensitive search.
|
53 |
+
return cm.getSearchCursor(query, pos, queryCaseInsensitive(query));
|
54 |
+
}
|
55 |
+
function dialog(cm, text, shortText, deflt, f) {
|
56 |
+
if (cm.openDialog) cm.openDialog(text, f, {value: deflt});
|
57 |
+
else f(prompt(shortText, deflt));
|
58 |
+
}
|
59 |
+
function confirmDialog(cm, text, shortText, fs) {
|
60 |
+
if (cm.openConfirm) cm.openConfirm(text, fs);
|
61 |
+
else if (confirm(shortText)) fs[0]();
|
62 |
+
}
|
63 |
+
function parseQuery(query) {
|
64 |
+
var isRE = query.match(/^\/(.*)\/([a-z]*)$/);
|
65 |
+
if (isRE) {
|
66 |
+
try { query = new RegExp(isRE[1], isRE[2].indexOf("i") == -1 ? "" : "i"); }
|
67 |
+
catch(e) {} // Not a regular expression after all, do a string search
|
68 |
+
}
|
69 |
+
if (typeof query == "string" ? query == "" : query.test(""))
|
70 |
+
query = /x^/;
|
71 |
+
return query;
|
72 |
+
}
|
73 |
+
var queryDialog =
|
74 |
+
'Search: <input type="text" style="width: 10em" class="CodeMirror-search-field"/> <span style="color: #888" class="CodeMirror-search-hint">(Use /re/ syntax for regexp search)</span>';
|
75 |
+
function doSearch(cm, rev) {
|
76 |
+
var state = getSearchState(cm);
|
77 |
+
if (state.query) return findNext(cm, rev);
|
78 |
+
dialog(cm, queryDialog, "Search for:", cm.getSelection(), function(query) {
|
79 |
+
cm.operation(function() {
|
80 |
+
if (!query || state.query) return;
|
81 |
+
state.query = parseQuery(query);
|
82 |
+
cm.removeOverlay(state.overlay, queryCaseInsensitive(state.query));
|
83 |
+
state.overlay = searchOverlay(state.query, queryCaseInsensitive(state.query));
|
84 |
+
cm.addOverlay(state.overlay);
|
85 |
+
if (cm.showMatchesOnScrollbar) {
|
86 |
+
if (state.annotate) { state.annotate.clear(); state.annotate = null; }
|
87 |
+
state.annotate = cm.showMatchesOnScrollbar(state.query, queryCaseInsensitive(state.query));
|
88 |
+
}
|
89 |
+
state.posFrom = state.posTo = cm.getCursor();
|
90 |
+
findNext(cm, rev);
|
91 |
+
});
|
92 |
+
});
|
93 |
+
}
|
94 |
+
function findNext(cm, rev) {cm.operation(function() {
|
95 |
+
var state = getSearchState(cm);
|
96 |
+
var cursor = getSearchCursor(cm, state.query, rev ? state.posFrom : state.posTo);
|
97 |
+
if (!cursor.find(rev)) {
|
98 |
+
cursor = getSearchCursor(cm, state.query, rev ? CodeMirror.Pos(cm.lastLine()) : CodeMirror.Pos(cm.firstLine(), 0));
|
99 |
+
if (!cursor.find(rev)) return;
|
100 |
+
}
|
101 |
+
cm.setSelection(cursor.from(), cursor.to());
|
102 |
+
cm.scrollIntoView({from: cursor.from(), to: cursor.to()});
|
103 |
+
state.posFrom = cursor.from(); state.posTo = cursor.to();
|
104 |
+
});}
|
105 |
+
function clearSearch(cm) {cm.operation(function() {
|
106 |
+
var state = getSearchState(cm);
|
107 |
+
if (!state.query) return;
|
108 |
+
state.query = null;
|
109 |
+
cm.removeOverlay(state.overlay);
|
110 |
+
if (state.annotate) { state.annotate.clear(); state.annotate = null; }
|
111 |
+
});}
|
112 |
+
|
113 |
+
var replaceQueryDialog =
|
114 |
+
'Replace: <input type="text" style="width: 10em" class="CodeMirror-search-field"/> <span style="color: #888" class="CodeMirror-search-hint">(Use /re/ syntax for regexp search)</span>';
|
115 |
+
var replacementQueryDialog = 'With: <input type="text" style="width: 10em" class="CodeMirror-search-field"/>';
|
116 |
+
var doReplaceConfirm = "Replace? <button>Yes</button> <button>No</button> <button>Stop</button>";
|
117 |
+
function replace(cm, all) {
|
118 |
+
if (cm.getOption("readOnly")) return;
|
119 |
+
dialog(cm, replaceQueryDialog, "Replace:", cm.getSelection(), function(query) {
|
120 |
+
if (!query) return;
|
121 |
+
query = parseQuery(query);
|
122 |
+
dialog(cm, replacementQueryDialog, "Replace with:", "", function(text) {
|
123 |
+
if (all) {
|
124 |
+
cm.operation(function() {
|
125 |
+
for (var cursor = getSearchCursor(cm, query); cursor.findNext();) {
|
126 |
+
if (typeof query != "string") {
|
127 |
+
var match = cm.getRange(cursor.from(), cursor.to()).match(query);
|
128 |
+
cursor.replace(text.replace(/\$(\d)/g, function(_, i) {return match[i];}));
|
129 |
+
} else cursor.replace(text);
|
130 |
+
}
|
131 |
+
});
|
132 |
+
} else {
|
133 |
+
clearSearch(cm);
|
134 |
+
var cursor = getSearchCursor(cm, query, cm.getCursor());
|
135 |
+
var advance = function() {
|
136 |
+
var start = cursor.from(), match;
|
137 |
+
if (!(match = cursor.findNext())) {
|
138 |
+
cursor = getSearchCursor(cm, query);
|
139 |
+
if (!(match = cursor.findNext()) ||
|
140 |
+
(start && cursor.from().line == start.line && cursor.from().ch == start.ch)) return;
|
141 |
+
}
|
142 |
+
cm.setSelection(cursor.from(), cursor.to());
|
143 |
+
cm.scrollIntoView({from: cursor.from(), to: cursor.to()});
|
144 |
+
confirmDialog(cm, doReplaceConfirm, "Replace?",
|
145 |
+
[function() {doReplace(match);}, advance]);
|
146 |
+
};
|
147 |
+
var doReplace = function(match) {
|
148 |
+
cursor.replace(typeof query == "string" ? text :
|
149 |
+
text.replace(/\$(\d)/g, function(_, i) {return match[i];}));
|
150 |
+
advance();
|
151 |
+
};
|
152 |
+
advance();
|
153 |
+
}
|
154 |
+
});
|
155 |
+
});
|
156 |
+
}
|
157 |
+
|
158 |
+
CodeMirror.commands.find = function(cm) {clearSearch(cm); doSearch(cm);};
|
159 |
+
CodeMirror.commands.findNext = doSearch;
|
160 |
+
CodeMirror.commands.findPrev = function(cm) {doSearch(cm, true);};
|
161 |
+
CodeMirror.commands.clearSearch = clearSearch;
|
162 |
+
CodeMirror.commands.replace = replace;
|
163 |
+
CodeMirror.commands.replaceAll = function(cm) {replace(cm, true);};
|
164 |
+
});
|
@@ -1,143 +1,189 @@
|
|
1 |
-
(
|
2 |
-
|
3 |
-
|
4 |
-
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
var
|
42 |
-
if (
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
if (
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
}
|
89 |
-
}
|
90 |
-
}
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
|
136 |
-
|
137 |
-
|
138 |
-
|
139 |
-
|
140 |
-
|
141 |
-
|
142 |
-
|
143 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
// CodeMirror, copyright (c) by Marijn Haverbeke and others
|
2 |
+
// Distributed under an MIT license: http://codemirror.net/LICENSE
|
3 |
+
|
4 |
+
(function(mod) {
|
5 |
+
if (typeof exports == "object" && typeof module == "object") // CommonJS
|
6 |
+
mod(require("../../lib/codemirror"));
|
7 |
+
else if (typeof define == "function" && define.amd) // AMD
|
8 |
+
define(["../../lib/codemirror"], mod);
|
9 |
+
else // Plain browser env
|
10 |
+
mod(CodeMirror);
|
11 |
+
})(function(CodeMirror) {
|
12 |
+
"use strict";
|
13 |
+
var Pos = CodeMirror.Pos;
|
14 |
+
|
15 |
+
function SearchCursor(doc, query, pos, caseFold) {
|
16 |
+
this.atOccurrence = false; this.doc = doc;
|
17 |
+
if (caseFold == null && typeof query == "string") caseFold = false;
|
18 |
+
|
19 |
+
pos = pos ? doc.clipPos(pos) : Pos(0, 0);
|
20 |
+
this.pos = {from: pos, to: pos};
|
21 |
+
|
22 |
+
// The matches method is filled in based on the type of query.
|
23 |
+
// It takes a position and a direction, and returns an object
|
24 |
+
// describing the next occurrence of the query, or null if no
|
25 |
+
// more matches were found.
|
26 |
+
if (typeof query != "string") { // Regexp match
|
27 |
+
if (!query.global) query = new RegExp(query.source, query.ignoreCase ? "ig" : "g");
|
28 |
+
this.matches = function(reverse, pos) {
|
29 |
+
if (reverse) {
|
30 |
+
query.lastIndex = 0;
|
31 |
+
var line = doc.getLine(pos.line).slice(0, pos.ch), cutOff = 0, match, start;
|
32 |
+
for (;;) {
|
33 |
+
query.lastIndex = cutOff;
|
34 |
+
var newMatch = query.exec(line);
|
35 |
+
if (!newMatch) break;
|
36 |
+
match = newMatch;
|
37 |
+
start = match.index;
|
38 |
+
cutOff = match.index + (match[0].length || 1);
|
39 |
+
if (cutOff == line.length) break;
|
40 |
+
}
|
41 |
+
var matchLen = (match && match[0].length) || 0;
|
42 |
+
if (!matchLen) {
|
43 |
+
if (start == 0 && line.length == 0) {match = undefined;}
|
44 |
+
else if (start != doc.getLine(pos.line).length) {
|
45 |
+
matchLen++;
|
46 |
+
}
|
47 |
+
}
|
48 |
+
} else {
|
49 |
+
query.lastIndex = pos.ch;
|
50 |
+
var line = doc.getLine(pos.line), match = query.exec(line);
|
51 |
+
var matchLen = (match && match[0].length) || 0;
|
52 |
+
var start = match && match.index;
|
53 |
+
if (start + matchLen != line.length && !matchLen) matchLen = 1;
|
54 |
+
}
|
55 |
+
if (match && matchLen)
|
56 |
+
return {from: Pos(pos.line, start),
|
57 |
+
to: Pos(pos.line, start + matchLen),
|
58 |
+
match: match};
|
59 |
+
};
|
60 |
+
} else { // String query
|
61 |
+
var origQuery = query;
|
62 |
+
if (caseFold) query = query.toLowerCase();
|
63 |
+
var fold = caseFold ? function(str){return str.toLowerCase();} : function(str){return str;};
|
64 |
+
var target = query.split("\n");
|
65 |
+
// Different methods for single-line and multi-line queries
|
66 |
+
if (target.length == 1) {
|
67 |
+
if (!query.length) {
|
68 |
+
// Empty string would match anything and never progress, so
|
69 |
+
// we define it to match nothing instead.
|
70 |
+
this.matches = function() {};
|
71 |
+
} else {
|
72 |
+
this.matches = function(reverse, pos) {
|
73 |
+
if (reverse) {
|
74 |
+
var orig = doc.getLine(pos.line).slice(0, pos.ch), line = fold(orig);
|
75 |
+
var match = line.lastIndexOf(query);
|
76 |
+
if (match > -1) {
|
77 |
+
match = adjustPos(orig, line, match);
|
78 |
+
return {from: Pos(pos.line, match), to: Pos(pos.line, match + origQuery.length)};
|
79 |
+
}
|
80 |
+
} else {
|
81 |
+
var orig = doc.getLine(pos.line).slice(pos.ch), line = fold(orig);
|
82 |
+
var match = line.indexOf(query);
|
83 |
+
if (match > -1) {
|
84 |
+
match = adjustPos(orig, line, match) + pos.ch;
|
85 |
+
return {from: Pos(pos.line, match), to: Pos(pos.line, match + origQuery.length)};
|
86 |
+
}
|
87 |
+
}
|
88 |
+
};
|
89 |
+
}
|
90 |
+
} else {
|
91 |
+
var origTarget = origQuery.split("\n");
|
92 |
+
this.matches = function(reverse, pos) {
|
93 |
+
var last = target.length - 1;
|
94 |
+
if (reverse) {
|
95 |
+
if (pos.line - (target.length - 1) < doc.firstLine()) return;
|
96 |
+
if (fold(doc.getLine(pos.line).slice(0, origTarget[last].length)) != target[target.length - 1]) return;
|
97 |
+
var to = Pos(pos.line, origTarget[last].length);
|
98 |
+
for (var ln = pos.line - 1, i = last - 1; i >= 1; --i, --ln)
|
99 |
+
if (target[i] != fold(doc.getLine(ln))) return;
|
100 |
+
var line = doc.getLine(ln), cut = line.length - origTarget[0].length;
|
101 |
+
if (fold(line.slice(cut)) != target[0]) return;
|
102 |
+
return {from: Pos(ln, cut), to: to};
|
103 |
+
} else {
|
104 |
+
if (pos.line + (target.length - 1) > doc.lastLine()) return;
|
105 |
+
var line = doc.getLine(pos.line), cut = line.length - origTarget[0].length;
|
106 |
+
if (fold(line.slice(cut)) != target[0]) return;
|
107 |
+
var from = Pos(pos.line, cut);
|
108 |
+
for (var ln = pos.line + 1, i = 1; i < last; ++i, ++ln)
|
109 |
+
if (target[i] != fold(doc.getLine(ln))) return;
|
110 |
+
if (fold(doc.getLine(ln).slice(0, origTarget[last].length)) != target[last]) return;
|
111 |
+
return {from: from, to: Pos(ln, origTarget[last].length)};
|
112 |
+
}
|
113 |
+
};
|
114 |
+
}
|
115 |
+
}
|
116 |
+
}
|
117 |
+
|
118 |
+
SearchCursor.prototype = {
|
119 |
+
findNext: function() {return this.find(false);},
|
120 |
+
findPrevious: function() {return this.find(true);},
|
121 |
+
|
122 |
+
find: function(reverse) {
|
123 |
+
var self = this, pos = this.doc.clipPos(reverse ? this.pos.from : this.pos.to);
|
124 |
+
function savePosAndFail(line) {
|
125 |
+
var pos = Pos(line, 0);
|
126 |
+
self.pos = {from: pos, to: pos};
|
127 |
+
self.atOccurrence = false;
|
128 |
+
return false;
|
129 |
+
}
|
130 |
+
|
131 |
+
for (;;) {
|
132 |
+
if (this.pos = this.matches(reverse, pos)) {
|
133 |
+
this.atOccurrence = true;
|
134 |
+
return this.pos.match || true;
|
135 |
+
}
|
136 |
+
if (reverse) {
|
137 |
+
if (!pos.line) return savePosAndFail(0);
|
138 |
+
pos = Pos(pos.line-1, this.doc.getLine(pos.line-1).length);
|
139 |
+
}
|
140 |
+
else {
|
141 |
+
var maxLine = this.doc.lineCount();
|
142 |
+
if (pos.line == maxLine - 1) return savePosAndFail(maxLine);
|
143 |
+
pos = Pos(pos.line + 1, 0);
|
144 |
+
}
|
145 |
+
}
|
146 |
+
},
|
147 |
+
|
148 |
+
from: function() {if (this.atOccurrence) return this.pos.from;},
|
149 |
+
to: function() {if (this.atOccurrence) return this.pos.to;},
|
150 |
+
|
151 |
+
replace: function(newText) {
|
152 |
+
if (!this.atOccurrence) return;
|
153 |
+
var lines = CodeMirror.splitLines(newText);
|
154 |
+
this.doc.replaceRange(lines, this.pos.from, this.pos.to);
|
155 |
+
this.pos.to = Pos(this.pos.from.line + lines.length - 1,
|
156 |
+
lines[lines.length - 1].length + (lines.length == 1 ? this.pos.from.ch : 0));
|
157 |
+
}
|
158 |
+
};
|
159 |
+
|
160 |
+
// Maps a position in a case-folded line back to a position in the original line
|
161 |
+
// (compensating for codepoints increasing in number during folding)
|
162 |
+
function adjustPos(orig, folded, pos) {
|
163 |
+
if (orig.length == folded.length) return pos;
|
164 |
+
for (var pos1 = Math.min(pos, orig.length);;) {
|
165 |
+
var len1 = orig.slice(0, pos1).toLowerCase().length;
|
166 |
+
if (len1 < pos) ++pos1;
|
167 |
+
else if (len1 > pos) --pos1;
|
168 |
+
else return pos1;
|
169 |
+
}
|
170 |
+
}
|
171 |
+
|
172 |
+
CodeMirror.defineExtension("getSearchCursor", function(query, pos, caseFold) {
|
173 |
+
return new SearchCursor(this.doc, query, pos, caseFold);
|
174 |
+
});
|
175 |
+
CodeMirror.defineDocExtension("getSearchCursor", function(query, pos, caseFold) {
|
176 |
+
return new SearchCursor(this, query, pos, caseFold);
|
177 |
+
});
|
178 |
+
|
179 |
+
CodeMirror.defineExtension("selectMatches", function(query, caseFold) {
|
180 |
+
var ranges = [], next;
|
181 |
+
var cur = this.getSearchCursor(query, this.getCursor("from"), caseFold);
|
182 |
+
while (next = cur.findNext()) {
|
183 |
+
if (CodeMirror.cmpPos(cur.to(), this.getCursor("to")) > 0) break;
|
184 |
+
ranges.push({anchor: cur.from(), head: cur.to()});
|
185 |
+
}
|
186 |
+
if (ranges.length)
|
187 |
+
this.setSelections(ranges, 0);
|
188 |
+
});
|
189 |
+
});
|
@@ -1,263 +1,309 @@
|
|
1 |
-
/* BASICS */
|
2 |
-
|
3 |
-
.CodeMirror {
|
4 |
-
/* Set height, width, borders, and global font properties here */
|
5 |
-
font-family: monospace;
|
6 |
-
height: 300px;
|
7 |
-
}
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
.CodeMirror
|
19 |
-
|
20 |
-
}
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
}
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
}
|
47 |
-
/* Shown when moving in bi-directional text */
|
48 |
-
.CodeMirror div.CodeMirror-secondarycursor {
|
49 |
-
border-left: 1px solid silver;
|
50 |
-
}
|
51 |
-
.CodeMirror.cm-
|
52 |
-
width: auto;
|
53 |
-
border: 0;
|
54 |
-
background: #7e7;
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
.cm-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
.
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
.
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
.
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
.
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
}
|
112 |
-
|
113 |
-
.
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
}
|
124 |
-
.
|
125 |
-
|
126 |
-
}
|
127 |
-
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
-
.CodeMirror
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
|
136 |
-
|
137 |
-
|
138 |
-
|
139 |
-
|
140 |
-
|
141 |
-
.CodeMirror
|
142 |
-
|
143 |
-
|
144 |
-
overflow
|
145 |
-
|
146 |
-
|
147 |
-
|
148 |
-
|
149 |
-
.CodeMirror-
|
150 |
-
|
151 |
-
|
152 |
-
|
153 |
-
|
154 |
-
|
155 |
-
|
156 |
-
|
157 |
-
|
158 |
-
|
159 |
-
|
160 |
-
|
161 |
-
|
162 |
-
|
163 |
-
|
164 |
-
|
165 |
-
|
166 |
-
|
167 |
-
|
168 |
-
|
169 |
-
|
170 |
-
.
|
171 |
-
|
172 |
-
|
173 |
-
z-index:
|
174 |
-
|
175 |
-
|
176 |
-
.CodeMirror-
|
177 |
-
|
178 |
-
|
179 |
-
|
180 |
-
|
181 |
-
|
182 |
-
|
183 |
-
|
184 |
-
|
185 |
-
|
186 |
-
|
187 |
-
|
188 |
-
|
189 |
-
|
190 |
-
|
191 |
-
|
192 |
-
|
193 |
-
|
194 |
-
|
195 |
-
|
196 |
-
|
197 |
-
|
198 |
-
|
199 |
-
|
200 |
-
|
201 |
-
|
202 |
-
|
203 |
-
|
204 |
-
|
205 |
-
|
206 |
-
|
207 |
-
|
208 |
-
|
209 |
-
|
210 |
-
|
211 |
-
|
212 |
-
|
213 |
-
|
214 |
-
|
215 |
-
|
216 |
-
|
217 |
-
|
218 |
-
|
219 |
-
|
220 |
-
|
221 |
-
|
222 |
-
|
223 |
-
|
224 |
-
|
225 |
-
|
226 |
-
|
227 |
-
|
228 |
-
|
229 |
-
|
230 |
-
|
231 |
-
|
232 |
-
|
233 |
-
|
234 |
-
|
235 |
-
|
236 |
-
|
237 |
-
|
238 |
-
|
239 |
-
|
240 |
-
|
241 |
-
|
242 |
-
|
243 |
-
|
244 |
-
|
245 |
-
|
246 |
-
|
247 |
-
|
248 |
-
|
249 |
-
|
250 |
-
|
251 |
-
|
252 |
-
|
253 |
-
|
254 |
-
|
255 |
-
|
256 |
-
|
257 |
-
|
258 |
-
|
259 |
-
|
260 |
-
|
261 |
-
|
262 |
-
|
263 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
/* BASICS */
|
2 |
+
|
3 |
+
.CodeMirror {
|
4 |
+
/* Set height, width, borders, and global font properties here */
|
5 |
+
font-family: monospace;
|
6 |
+
height: 300px;
|
7 |
+
}
|
8 |
+
|
9 |
+
/* PADDING */
|
10 |
+
|
11 |
+
.CodeMirror-lines {
|
12 |
+
padding: 4px 0; /* Vertical padding around content */
|
13 |
+
}
|
14 |
+
.CodeMirror pre {
|
15 |
+
padding: 0 4px; /* Horizontal padding of content */
|
16 |
+
}
|
17 |
+
|
18 |
+
.CodeMirror-scrollbar-filler, .CodeMirror-gutter-filler {
|
19 |
+
background-color: white; /* The little square between H and V scrollbars */
|
20 |
+
}
|
21 |
+
|
22 |
+
/* GUTTER */
|
23 |
+
|
24 |
+
.CodeMirror-gutters {
|
25 |
+
border-right: 1px solid #ddd;
|
26 |
+
background-color: #f7f7f7;
|
27 |
+
white-space: nowrap;
|
28 |
+
}
|
29 |
+
.CodeMirror-linenumbers {}
|
30 |
+
.CodeMirror-linenumber {
|
31 |
+
padding: 0 3px 0 5px;
|
32 |
+
min-width: 20px;
|
33 |
+
text-align: right;
|
34 |
+
color: #999;
|
35 |
+
-moz-box-sizing: content-box;
|
36 |
+
box-sizing: content-box;
|
37 |
+
}
|
38 |
+
|
39 |
+
.CodeMirror-guttermarker { color: black; }
|
40 |
+
.CodeMirror-guttermarker-subtle { color: #999; }
|
41 |
+
|
42 |
+
/* CURSOR */
|
43 |
+
|
44 |
+
.CodeMirror div.CodeMirror-cursor {
|
45 |
+
border-left: 1px solid black;
|
46 |
+
}
|
47 |
+
/* Shown when moving in bi-directional text */
|
48 |
+
.CodeMirror div.CodeMirror-secondarycursor {
|
49 |
+
border-left: 1px solid silver;
|
50 |
+
}
|
51 |
+
.CodeMirror.cm-fat-cursor div.CodeMirror-cursor {
|
52 |
+
width: auto;
|
53 |
+
border: 0;
|
54 |
+
background: #7e7;
|
55 |
+
}
|
56 |
+
.CodeMirror.cm-fat-cursor div.CodeMirror-cursors {
|
57 |
+
z-index: 1;
|
58 |
+
}
|
59 |
+
|
60 |
+
.cm-animate-fat-cursor {
|
61 |
+
width: auto;
|
62 |
+
border: 0;
|
63 |
+
-webkit-animation: blink 1.06s steps(1) infinite;
|
64 |
+
-moz-animation: blink 1.06s steps(1) infinite;
|
65 |
+
animation: blink 1.06s steps(1) infinite;
|
66 |
+
}
|
67 |
+
@-moz-keyframes blink {
|
68 |
+
0% { background: #7e7; }
|
69 |
+
50% { background: none; }
|
70 |
+
100% { background: #7e7; }
|
71 |
+
}
|
72 |
+
@-webkit-keyframes blink {
|
73 |
+
0% { background: #7e7; }
|
74 |
+
50% { background: none; }
|
75 |
+
100% { background: #7e7; }
|
76 |
+
}
|
77 |
+
@keyframes blink {
|
78 |
+
0% { background: #7e7; }
|
79 |
+
50% { background: none; }
|
80 |
+
100% { background: #7e7; }
|
81 |
+
}
|
82 |
+
|
83 |
+
/* Can style cursor different in overwrite (non-insert) mode */
|
84 |
+
div.CodeMirror-overwrite div.CodeMirror-cursor {}
|
85 |
+
|
86 |
+
.cm-tab { display: inline-block; text-decoration: inherit; }
|
87 |
+
|
88 |
+
.CodeMirror-ruler {
|
89 |
+
border-left: 1px solid #ccc;
|
90 |
+
position: absolute;
|
91 |
+
}
|
92 |
+
|
93 |
+
/* DEFAULT THEME */
|
94 |
+
|
95 |
+
.cm-s-default .cm-keyword {color: #708;}
|
96 |
+
.cm-s-default .cm-atom {color: #219;}
|
97 |
+
.cm-s-default .cm-number {color: #164;}
|
98 |
+
.cm-s-default .cm-def {color: #00f;}
|
99 |
+
.cm-s-default .cm-variable,
|
100 |
+
.cm-s-default .cm-punctuation,
|
101 |
+
.cm-s-default .cm-property,
|
102 |
+
.cm-s-default .cm-operator {}
|
103 |
+
.cm-s-default .cm-variable-2 {color: #05a;}
|
104 |
+
.cm-s-default .cm-variable-3 {color: #085;}
|
105 |
+
.cm-s-default .cm-comment {color: #a50;}
|
106 |
+
.cm-s-default .cm-string {color: #a11;}
|
107 |
+
.cm-s-default .cm-string-2 {color: #f50;}
|
108 |
+
.cm-s-default .cm-meta {color: #555;}
|
109 |
+
.cm-s-default .cm-qualifier {color: #555;}
|
110 |
+
.cm-s-default .cm-builtin {color: #30a;}
|
111 |
+
.cm-s-default .cm-bracket {color: #997;}
|
112 |
+
.cm-s-default .cm-tag {color: #170;}
|
113 |
+
.cm-s-default .cm-attribute {color: #00c;}
|
114 |
+
.cm-s-default .cm-header {color: blue;}
|
115 |
+
.cm-s-default .cm-quote {color: #090;}
|
116 |
+
.cm-s-default .cm-hr {color: #999;}
|
117 |
+
.cm-s-default .cm-link {color: #00c;}
|
118 |
+
|
119 |
+
.cm-negative {color: #d44;}
|
120 |
+
.cm-positive {color: #292;}
|
121 |
+
.cm-header, .cm-strong {font-weight: bold;}
|
122 |
+
.cm-em {font-style: italic;}
|
123 |
+
.cm-link {text-decoration: underline;}
|
124 |
+
.cm-strikethrough {text-decoration: line-through;}
|
125 |
+
|
126 |
+
.cm-s-default .cm-error {color: #f00;}
|
127 |
+
.cm-invalidchar {color: #f00;}
|
128 |
+
|
129 |
+
/* Default styles for common addons */
|
130 |
+
|
131 |
+
div.CodeMirror span.CodeMirror-matchingbracket {color: #0f0;}
|
132 |
+
div.CodeMirror span.CodeMirror-nonmatchingbracket {color: #f22;}
|
133 |
+
.CodeMirror-matchingtag { background: rgba(255, 150, 0, .3); }
|
134 |
+
.CodeMirror-activeline-background {background: #e8f2ff;}
|
135 |
+
|
136 |
+
/* STOP */
|
137 |
+
|
138 |
+
/* The rest of this file contains styles related to the mechanics of
|
139 |
+
the editor. You probably shouldn't touch them. */
|
140 |
+
|
141 |
+
.CodeMirror {
|
142 |
+
line-height: 1;
|
143 |
+
position: relative;
|
144 |
+
overflow: hidden;
|
145 |
+
background: white;
|
146 |
+
color: black;
|
147 |
+
}
|
148 |
+
|
149 |
+
.CodeMirror-scroll {
|
150 |
+
overflow: scroll !important; /* Things will break if this is overridden */
|
151 |
+
/* 30px is the magic margin used to hide the element's real scrollbars */
|
152 |
+
/* See overflow: hidden in .CodeMirror */
|
153 |
+
margin-bottom: -30px; margin-right: -30px;
|
154 |
+
padding-bottom: 30px;
|
155 |
+
height: 100%;
|
156 |
+
outline: none; /* Prevent dragging from highlighting the element */
|
157 |
+
position: relative;
|
158 |
+
-moz-box-sizing: content-box;
|
159 |
+
box-sizing: content-box;
|
160 |
+
}
|
161 |
+
.CodeMirror-sizer {
|
162 |
+
position: relative;
|
163 |
+
border-right: 30px solid transparent;
|
164 |
+
-moz-box-sizing: content-box;
|
165 |
+
box-sizing: content-box;
|
166 |
+
}
|
167 |
+
|
168 |
+
/* The fake, visible scrollbars. Used to force redraw during scrolling
|
169 |
+
before actuall scrolling happens, thus preventing shaking and
|
170 |
+
flickering artifacts. */
|
171 |
+
.CodeMirror-vscrollbar, .CodeMirror-hscrollbar, .CodeMirror-scrollbar-filler, .CodeMirror-gutter-filler {
|
172 |
+
position: absolute;
|
173 |
+
z-index: 6;
|
174 |
+
display: none;
|
175 |
+
}
|
176 |
+
.CodeMirror-vscrollbar {
|
177 |
+
right: 0; top: 0;
|
178 |
+
overflow-x: hidden;
|
179 |
+
overflow-y: scroll;
|
180 |
+
}
|
181 |
+
.CodeMirror-hscrollbar {
|
182 |
+
bottom: 0; left: 0;
|
183 |
+
overflow-y: hidden;
|
184 |
+
overflow-x: scroll;
|
185 |
+
}
|
186 |
+
.CodeMirror-scrollbar-filler {
|
187 |
+
right: 0; bottom: 0;
|
188 |
+
}
|
189 |
+
.CodeMirror-gutter-filler {
|
190 |
+
left: 0; bottom: 0;
|
191 |
+
}
|
192 |
+
|
193 |
+
.CodeMirror-gutters {
|
194 |
+
position: absolute; left: 0; top: 0;
|
195 |
+
z-index: 3;
|
196 |
+
}
|
197 |
+
.CodeMirror-gutter {
|
198 |
+
white-space: normal;
|
199 |
+
height: 100%;
|
200 |
+
-moz-box-sizing: content-box;
|
201 |
+
box-sizing: content-box;
|
202 |
+
display: inline-block;
|
203 |
+
margin-bottom: -30px;
|
204 |
+
/* Hack to make IE7 behave */
|
205 |
+
*zoom:1;
|
206 |
+
*display:inline;
|
207 |
+
}
|
208 |
+
.CodeMirror-gutter-wrapper {
|
209 |
+
position: absolute;
|
210 |
+
z-index: 4;
|
211 |
+
height: 100%;
|
212 |
+
}
|
213 |
+
.CodeMirror-gutter-elt {
|
214 |
+
position: absolute;
|
215 |
+
cursor: default;
|
216 |
+
z-index: 4;
|
217 |
+
}
|
218 |
+
|
219 |
+
.CodeMirror-lines {
|
220 |
+
cursor: text;
|
221 |
+
min-height: 1px; /* prevents collapsing before first draw */
|
222 |
+
}
|
223 |
+
.CodeMirror pre {
|
224 |
+
/* Reset some styles that the rest of the page might have set */
|
225 |
+
-moz-border-radius: 0; -webkit-border-radius: 0; border-radius: 0;
|
226 |
+
border-width: 0;
|
227 |
+
background: transparent;
|
228 |
+
font-family: inherit;
|
229 |
+
font-size: inherit;
|
230 |
+
margin: 0;
|
231 |
+
white-space: pre;
|
232 |
+
word-wrap: normal;
|
233 |
+
line-height: inherit;
|
234 |
+
color: inherit;
|
235 |
+
z-index: 2;
|
236 |
+
position: relative;
|
237 |
+
overflow: visible;
|
238 |
+
}
|
239 |
+
.CodeMirror-wrap pre {
|
240 |
+
word-wrap: break-word;
|
241 |
+
white-space: pre-wrap;
|
242 |
+
word-break: normal;
|
243 |
+
}
|
244 |
+
|
245 |
+
.CodeMirror-linebackground {
|
246 |
+
position: absolute;
|
247 |
+
left: 0; right: 0; top: 0; bottom: 0;
|
248 |
+
z-index: 0;
|
249 |
+
}
|
250 |
+
|
251 |
+
.CodeMirror-linewidget {
|
252 |
+
position: relative;
|
253 |
+
z-index: 2;
|
254 |
+
overflow: auto;
|
255 |
+
}
|
256 |
+
|
257 |
+
.CodeMirror-widget {}
|
258 |
+
|
259 |
+
.CodeMirror-measure {
|
260 |
+
position: absolute;
|
261 |
+
width: 100%;
|
262 |
+
height: 0;
|
263 |
+
overflow: hidden;
|
264 |
+
visibility: hidden;
|
265 |
+
}
|
266 |
+
.CodeMirror-measure pre { position: static; }
|
267 |
+
|
268 |
+
.CodeMirror div.CodeMirror-cursor {
|
269 |
+
position: absolute;
|
270 |
+
border-right: none;
|
271 |
+
width: 0;
|
272 |
+
}
|
273 |
+
|
274 |
+
div.CodeMirror-cursors {
|
275 |
+
visibility: hidden;
|
276 |
+
position: relative;
|
277 |
+
z-index: 3;
|
278 |
+
}
|
279 |
+
.CodeMirror-focused div.CodeMirror-cursors {
|
280 |
+
visibility: visible;
|
281 |
+
}
|
282 |
+
|
283 |
+
.CodeMirror-selected { background: #d9d9d9; }
|
284 |
+
.CodeMirror-focused .CodeMirror-selected { background: #d7d4f0; }
|
285 |
+
.CodeMirror-crosshair { cursor: crosshair; }
|
286 |
+
|
287 |
+
.cm-searching {
|
288 |
+
background: #ffa;
|
289 |
+
background: rgba(255, 255, 0, .4);
|
290 |
+
}
|
291 |
+
|
292 |
+
/* IE7 hack to prevent it from returning funny offsetTops on the spans */
|
293 |
+
.CodeMirror span { *vertical-align: text-bottom; }
|
294 |
+
|
295 |
+
/* Used to force a border model for a node */
|
296 |
+
.cm-force-border { padding-right: .1px; }
|
297 |
+
|
298 |
+
@media print {
|
299 |
+
/* Hide the cursor when printing */
|
300 |
+
.CodeMirror div.CodeMirror-cursors {
|
301 |
+
visibility: hidden;
|
302 |
+
}
|
303 |
+
}
|
304 |
+
|
305 |
+
/* See issue #2901 */
|
306 |
+
.cm-tab-wrap-hack:after { content: ''; }
|
307 |
+
|
308 |
+
/* Help users use markselection to safely style text background */
|
309 |
+
span.CodeMirror-selectedtext { background: none; }
|
@@ -1,5942 +1,8045 @@
|
|
1 |
-
// CodeMirror
|
2 |
-
|
3 |
-
|
4 |
-
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
var
|
26 |
-
|
27 |
-
var
|
28 |
-
|
29 |
-
var
|
30 |
-
var
|
31 |
-
var
|
32 |
-
|
33 |
-
var
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
var
|
38 |
-
var
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
}
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
d
|
130 |
-
|
131 |
-
|
132 |
-
//
|
133 |
-
d.
|
134 |
-
|
135 |
-
//
|
136 |
-
|
137 |
-
|
138 |
-
|
139 |
-
|
140 |
-
|
141 |
-
|
142 |
-
|
143 |
-
|
144 |
-
|
145 |
-
|
146 |
-
|
147 |
-
|
148 |
-
|
149 |
-
|
150 |
-
//
|
151 |
-
|
152 |
-
|
153 |
-
//
|
154 |
-
d.
|
155 |
-
|
156 |
-
|
157 |
-
|
158 |
-
//
|
159 |
-
d.
|
160 |
-
//
|
161 |
-
d.
|
162 |
-
//
|
163 |
-
|
164 |
-
|
165 |
-
//
|
166 |
-
|
167 |
-
//
|
168 |
-
d.
|
169 |
-
|
170 |
-
|
171 |
-
|
172 |
-
|
173 |
-
d.
|
174 |
-
|
175 |
-
|
176 |
-
|
177 |
-
//
|
178 |
-
d.
|
179 |
-
|
180 |
-
//
|
181 |
-
|
182 |
-
|
183 |
-
|
184 |
-
d.
|
185 |
-
|
186 |
-
|
187 |
-
|
188 |
-
|
189 |
-
|
190 |
-
|
191 |
-
|
192 |
-
|
193 |
-
|
194 |
-
|
195 |
-
|
196 |
-
|
197 |
-
|
198 |
-
|
199 |
-
|
200 |
-
|
201 |
-
|
202 |
-
|
203 |
-
|
204 |
-
|
205 |
-
|
206 |
-
|
207 |
-
|
208 |
-
|
209 |
-
|
210 |
-
|
211 |
-
|
212 |
-
|
213 |
-
|
214 |
-
|
215 |
-
|
216 |
-
|
217 |
-
|
218 |
-
|
219 |
-
|
220 |
-
|
221 |
-
|
222 |
-
|
223 |
-
|
224 |
-
|
225 |
-
|
226 |
-
|
227 |
-
|
228 |
-
|
229 |
-
|
230 |
-
|
231 |
-
|
232 |
-
|
233 |
-
|
234 |
-
|
235 |
-
|
236 |
-
|
237 |
-
|
238 |
-
|
239 |
-
|
240 |
-
|
241 |
-
|
242 |
-
|
243 |
-
|
244 |
-
|
245 |
-
|
246 |
-
|
247 |
-
|
248 |
-
|
249 |
-
|
250 |
-
|
251 |
-
|
252 |
-
|
253 |
-
|
254 |
-
|
255 |
-
|
256 |
-
function
|
257 |
-
|
258 |
-
|
259 |
-
|
260 |
-
|
261 |
-
|
262 |
-
|
263 |
-
|
264 |
-
|
265 |
-
|
266 |
-
|
267 |
-
|
268 |
-
|
269 |
-
|
270 |
-
|
271 |
-
|
272 |
-
|
273 |
-
|
274 |
-
|
275 |
-
|
276 |
-
|
277 |
-
|
278 |
-
|
279 |
-
|
280 |
-
|
281 |
-
|
282 |
-
|
283 |
-
|
284 |
-
|
285 |
-
|
286 |
-
|
287 |
-
|
288 |
-
|
289 |
-
|
290 |
-
|
291 |
-
|
292 |
-
|
293 |
-
|
294 |
-
|
295 |
-
|
296 |
-
|
297 |
-
|
298 |
-
|
299 |
-
|
300 |
-
|
301 |
-
if (
|
302 |
-
|
303 |
-
|
304 |
-
|
305 |
-
}
|
306 |
-
}
|
307 |
-
|
308 |
-
|
309 |
-
|
310 |
-
|
311 |
-
|
312 |
-
|
313 |
-
|
314 |
-
|
315 |
-
|
316 |
-
|
317 |
-
|
318 |
-
|
319 |
-
|
320 |
-
|
321 |
-
|
322 |
-
|
323 |
-
|
324 |
-
|
325 |
-
|
326 |
-
|
327 |
-
|
328 |
-
|
329 |
-
|
330 |
-
|
331 |
-
var
|
332 |
-
|
333 |
-
|
334 |
-
|
335 |
-
|
336 |
-
|
337 |
-
|
338 |
-
|
339 |
-
|
340 |
-
}
|
341 |
-
|
342 |
-
|
343 |
-
|
344 |
-
|
345 |
-
|
346 |
-
|
347 |
-
|
348 |
-
|
349 |
-
|
350 |
-
|
351 |
-
|
352 |
-
|
353 |
-
|
354 |
-
if (
|
355 |
-
|
356 |
-
|
357 |
-
|
358 |
-
|
359 |
-
|
360 |
-
|
361 |
-
|
362 |
-
|
363 |
-
|
364 |
-
|
365 |
-
|
366 |
-
|
367 |
-
|
368 |
-
|
369 |
-
|
370 |
-
|
371 |
-
|
372 |
-
|
373 |
-
|
374 |
-
|
375 |
-
|
376 |
-
|
377 |
-
|
378 |
-
|
379 |
-
|
380 |
-
|
381 |
-
|
382 |
-
|
383 |
-
|
384 |
-
|
385 |
-
|
386 |
-
|
387 |
-
|
388 |
-
|
389 |
-
|
390 |
-
if (
|
391 |
-
|
392 |
-
if (
|
393 |
-
|
394 |
-
|
395 |
-
|
396 |
-
|
397 |
-
|
398 |
-
|
399 |
-
|
400 |
-
|
401 |
-
|
402 |
-
|
403 |
-
|
404 |
-
|
405 |
-
|
406 |
-
|
407 |
-
|
408 |
-
|
409 |
-
|
410 |
-
|
411 |
-
|
412 |
-
|
413 |
-
|
414 |
-
|
415 |
-
|
416 |
-
|
417 |
-
|
418 |
-
|
419 |
-
|
420 |
-
|
421 |
-
|
422 |
-
|
423 |
-
|
424 |
-
|
425 |
-
if (
|
426 |
-
|
427 |
-
|
428 |
-
|
429 |
-
|
430 |
-
|
431 |
-
|
432 |
-
|
433 |
-
|
434 |
-
|
435 |
-
|
436 |
-
|
437 |
-
|
438 |
-
|
439 |
-
|
440 |
-
|
441 |
-
|
442 |
-
if (
|
443 |
-
|
444 |
-
|
445 |
-
|
446 |
-
|
447 |
-
|
448 |
-
|
449 |
-
|
450 |
-
|
451 |
-
|
452 |
-
|
453 |
-
|
454 |
-
|
455 |
-
|
456 |
-
|
457 |
-
|
458 |
-
|
459 |
-
|
460 |
-
|
461 |
-
|
462 |
-
|
463 |
-
|
464 |
-
|
465 |
-
|
466 |
-
|
467 |
-
|
468 |
-
|
469 |
-
|
470 |
-
|
471 |
-
|
472 |
-
|
473 |
-
|
474 |
-
|
475 |
-
|
476 |
-
|
477 |
-
|
478 |
-
|
479 |
-
|
480 |
-
|
481 |
-
|
482 |
-
|
483 |
-
|
484 |
-
|
485 |
-
|
486 |
-
|
487 |
-
|
488 |
-
|
489 |
-
|
490 |
-
|
491 |
-
|
492 |
-
|
493 |
-
|
494 |
-
|
495 |
-
|
496 |
-
|
497 |
-
|
498 |
-
|
499 |
-
|
500 |
-
|
501 |
-
|
502 |
-
|
503 |
-
|
504 |
-
|
505 |
-
|
506 |
-
|
507 |
-
|
508 |
-
|
509 |
-
|
510 |
-
|
511 |
-
|
512 |
-
|
513 |
-
|
514 |
-
|
515 |
-
|
516 |
-
|
517 |
-
|
518 |
-
|
519 |
-
|
520 |
-
|
521 |
-
|
522 |
-
|
523 |
-
|
524 |
-
|
525 |
-
display.
|
526 |
-
|
527 |
-
|
528 |
-
|
529 |
-
|
530 |
-
|
531 |
-
|
532 |
-
|
533 |
-
|
534 |
-
|
535 |
-
|
536 |
-
|
537 |
-
|
538 |
-
|
539 |
-
|
540 |
-
|
541 |
-
|
542 |
-
|
543 |
-
|
544 |
-
|
545 |
-
var
|
546 |
-
|
547 |
-
|
548 |
-
|
549 |
-
|
550 |
-
|
551 |
-
|
552 |
-
|
553 |
-
|
554 |
-
|
555 |
-
|
556 |
-
|
557 |
-
|
558 |
-
|
559 |
-
|
560 |
-
|
561 |
-
|
562 |
-
|
563 |
-
|
564 |
-
|
565 |
-
|
566 |
-
|
567 |
-
|
568 |
-
var
|
569 |
-
|
570 |
-
|
571 |
-
|
572 |
-
|
573 |
-
|
574 |
-
|
575 |
-
|
576 |
-
|
577 |
-
|
578 |
-
|
579 |
-
|
580 |
-
|
581 |
-
|
582 |
-
|
583 |
-
|
584 |
-
|
585 |
-
|
586 |
-
|
587 |
-
|
588 |
-
|
589 |
-
|
590 |
-
|
591 |
-
|
592 |
-
|
593 |
-
|
594 |
-
|
595 |
-
var
|
596 |
-
|
597 |
-
|
598 |
-
|
599 |
-
|
600 |
-
|
601 |
-
|
602 |
-
|
603 |
-
|
604 |
-
|
605 |
-
|
606 |
-
|
607 |
-
|
608 |
-
|
609 |
-
|
610 |
-
if (!
|
611 |
-
|
612 |
-
|
613 |
-
|
614 |
-
|
615 |
-
var
|
616 |
-
|
617 |
-
|
618 |
-
|
619 |
-
|
620 |
-
|
621 |
-
|
622 |
-
return
|
623 |
-
}
|
624 |
-
|
625 |
-
|
626 |
-
|
627 |
-
|
628 |
-
|
629 |
-
|
630 |
-
|
631 |
-
|
632 |
-
|
633 |
-
|
634 |
-
|
635 |
-
|
636 |
-
|
637 |
-
|
638 |
-
|
639 |
-
|
640 |
-
|
641 |
-
|
642 |
-
|
643 |
-
|
644 |
-
|
645 |
-
|
646 |
-
|
647 |
-
|
648 |
-
|
649 |
-
|
650 |
-
|
651 |
-
|
652 |
-
|
653 |
-
|
654 |
-
|
655 |
-
|
656 |
-
|
657 |
-
|
658 |
-
|
659 |
-
|
660 |
-
|
661 |
-
|
662 |
-
|
663 |
-
|
664 |
-
|
665 |
-
|
666 |
-
|
667 |
-
|
668 |
-
|
669 |
-
|
670 |
-
|
671 |
-
|
672 |
-
|
673 |
-
|
674 |
-
|
675 |
-
|
676 |
-
|
677 |
-
|
678 |
-
|
679 |
-
|
680 |
-
|
681 |
-
|
682 |
-
|
683 |
-
|
684 |
-
|
685 |
-
|
686 |
-
|
687 |
-
|
688 |
-
|
689 |
-
|
690 |
-
|
691 |
-
|
692 |
-
|
693 |
-
|
694 |
-
|
695 |
-
|
696 |
-
|
697 |
-
|
698 |
-
|
699 |
-
|
700 |
-
|
701 |
-
|
702 |
-
|
703 |
-
|
704 |
-
|
705 |
-
|
706 |
-
|
707 |
-
|
708 |
-
|
709 |
-
|
710 |
-
|
711 |
-
|
712 |
-
|
713 |
-
|
714 |
-
|
715 |
-
|
716 |
-
|
717 |
-
if (
|
718 |
-
|
719 |
-
|
720 |
-
|
721 |
-
|
722 |
-
|
723 |
-
|
724 |
-
|
725 |
-
|
726 |
-
|
727 |
-
|
728 |
-
|
729 |
-
|
730 |
-
|
731 |
-
|
732 |
-
|
733 |
-
|
734 |
-
|
735 |
-
|
736 |
-
|
737 |
-
|
738 |
-
|
739 |
-
|
740 |
-
|
741 |
-
|
742 |
-
|
743 |
-
if (
|
744 |
-
|
745 |
-
else
|
746 |
-
|
747 |
-
|
748 |
-
|
749 |
-
|
750 |
-
|
751 |
-
|
752 |
-
|
753 |
-
|
754 |
-
|
755 |
-
|
756 |
-
|
757 |
-
|
758 |
-
|
759 |
-
|
760 |
-
|
761 |
-
|
762 |
-
}
|
763 |
-
|
764 |
-
|
765 |
-
|
766 |
-
|
767 |
-
|
768 |
-
|
769 |
-
|
770 |
-
|
771 |
-
|
772 |
-
|
773 |
-
|
774 |
-
|
775 |
-
|
776 |
-
|
777 |
-
|
778 |
-
|
779 |
-
|
780 |
-
|
781 |
-
|
782 |
-
|
783 |
-
|
784 |
-
|
785 |
-
|
786 |
-
|
787 |
-
|
788 |
-
|
789 |
-
|
790 |
-
|
791 |
-
|
792 |
-
|
793 |
-
|
794 |
-
|
795 |
-
|
796 |
-
|
797 |
-
|
798 |
-
|
799 |
-
|
800 |
-
|
801 |
-
|
802 |
-
|
803 |
-
|
804 |
-
|
805 |
-
|
806 |
-
|
807 |
-
|
808 |
-
|
809 |
-
|
810 |
-
|
811 |
-
|
812 |
-
|
813 |
-
|
814 |
-
|
815 |
-
|
816 |
-
|
817 |
-
|
818 |
-
|
819 |
-
|
820 |
-
|
821 |
-
|
822 |
-
|
823 |
-
|
824 |
-
|
825 |
-
|
826 |
-
|
827 |
-
|
828 |
-
|
829 |
-
|
830 |
-
|
831 |
-
|
832 |
-
|
833 |
-
|
834 |
-
|
835 |
-
|
836 |
-
|
837 |
-
|
838 |
-
|
839 |
-
|
840 |
-
|
841 |
-
|
842 |
-
|
843 |
-
|
844 |
-
|
845 |
-
|
846 |
-
|
847 |
-
|
848 |
-
|
849 |
-
|
850 |
-
|
851 |
-
|
852 |
-
|
853 |
-
|
854 |
-
|
855 |
-
|
856 |
-
|
857 |
-
|
858 |
-
|
859 |
-
|
860 |
-
|
861 |
-
|
862 |
-
|
863 |
-
|
864 |
-
|
865 |
-
|
866 |
-
|
867 |
-
|
868 |
-
|
869 |
-
|
870 |
-
|
871 |
-
|
872 |
-
|
873 |
-
|
874 |
-
|
875 |
-
|
876 |
-
|
877 |
-
|
878 |
-
|
879 |
-
|
880 |
-
|
881 |
-
|
882 |
-
|
883 |
-
|
884 |
-
|
885 |
-
|
886 |
-
|
887 |
-
|
888 |
-
|
889 |
-
|
890 |
-
|
891 |
-
|
892 |
-
|
893 |
-
|
894 |
-
|
895 |
-
|
896 |
-
|
897 |
-
|
898 |
-
|
899 |
-
|
900 |
-
|
901 |
-
|
902 |
-
|
903 |
-
|
904 |
-
|
905 |
-
|
906 |
-
|
907 |
-
|
908 |
-
|
909 |
-
|
910 |
-
|
911 |
-
|
912 |
-
|
913 |
-
|
914 |
-
|
915 |
-
|
916 |
-
|
917 |
-
|
918 |
-
|
919 |
-
|
920 |
-
|
921 |
-
|
922 |
-
|
923 |
-
|
924 |
-
|
925 |
-
|
926 |
-
|
927 |
-
|
928 |
-
|
929 |
-
|
930 |
-
|
931 |
-
|
932 |
-
|
933 |
-
|
934 |
-
|
935 |
-
|
936 |
-
|
937 |
-
|
938 |
-
//
|
939 |
-
//
|
940 |
-
|
941 |
-
|
942 |
-
|
943 |
-
|
944 |
-
|
945 |
-
|
946 |
-
|
947 |
-
|
948 |
-
|
949 |
-
|
950 |
-
|
951 |
-
|
952 |
-
|
953 |
-
|
954 |
-
|
955 |
-
|
956 |
-
|
957 |
-
|
958 |
-
|
959 |
-
|
960 |
-
|
961 |
-
|
962 |
-
|
963 |
-
|
964 |
-
|
965 |
-
|
966 |
-
|
967 |
-
|
968 |
-
|
969 |
-
|
970 |
-
|
971 |
-
if (
|
972 |
-
|
973 |
-
|
974 |
-
|
975 |
-
|
976 |
-
|
977 |
-
|
978 |
-
|
979 |
-
|
980 |
-
|
981 |
-
|
982 |
-
|
983 |
-
|
984 |
-
|
985 |
-
|
986 |
-
|
987 |
-
|
988 |
-
|
989 |
-
|
990 |
-
|
991 |
-
|
992 |
-
|
993 |
-
|
994 |
-
|
995 |
-
|
996 |
-
|
997 |
-
|
998 |
-
|
999 |
-
|
1000 |
-
|
1001 |
-
|
1002 |
-
|
1003 |
-
|
1004 |
-
|
1005 |
-
|
1006 |
-
function
|
1007 |
-
var
|
1008 |
-
|
1009 |
-
|
1010 |
-
|
1011 |
-
|
1012 |
-
|
1013 |
-
|
1014 |
-
|
1015 |
-
|
1016 |
-
|
1017 |
-
|
1018 |
-
|
1019 |
-
|
1020 |
-
|
1021 |
-
|
1022 |
-
|
1023 |
-
|
1024 |
-
|
1025 |
-
|
1026 |
-
|
1027 |
-
|
1028 |
-
var
|
1029 |
-
var
|
1030 |
-
|
1031 |
-
|
1032 |
-
|
1033 |
-
|
1034 |
-
|
1035 |
-
|
1036 |
-
|
1037 |
-
|
1038 |
-
|
1039 |
-
|
1040 |
-
|
1041 |
-
|
1042 |
-
|
1043 |
-
|
1044 |
-
|
1045 |
-
|
1046 |
-
|
1047 |
-
|
1048 |
-
|
1049 |
-
|
1050 |
-
|
1051 |
-
|
1052 |
-
|
1053 |
-
|
1054 |
-
|
1055 |
-
|
1056 |
-
|
1057 |
-
|
1058 |
-
|
1059 |
-
|
1060 |
-
|
1061 |
-
|
1062 |
-
|
1063 |
-
|
1064 |
-
|
1065 |
-
|
1066 |
-
|
1067 |
-
|
1068 |
-
|
1069 |
-
|
1070 |
-
|
1071 |
-
|
1072 |
-
|
1073 |
-
|
1074 |
-
|
1075 |
-
|
1076 |
-
|
1077 |
-
|
1078 |
-
|
1079 |
-
|
1080 |
-
|
1081 |
-
|
1082 |
-
|
1083 |
-
|
1084 |
-
|
1085 |
-
|
1086 |
-
|
1087 |
-
|
1088 |
-
|
1089 |
-
|
1090 |
-
|
1091 |
-
|
1092 |
-
|
1093 |
-
|
1094 |
-
|
1095 |
-
|
1096 |
-
|
1097 |
-
|
1098 |
-
|
1099 |
-
|
1100 |
-
|
1101 |
-
|
1102 |
-
}
|
1103 |
-
|
1104 |
-
|
1105 |
-
|
1106 |
-
|
1107 |
-
|
1108 |
-
|
1109 |
-
|
1110 |
-
|
1111 |
-
|
1112 |
-
|
1113 |
-
|
1114 |
-
}
|
1115 |
-
|
1116 |
-
|
1117 |
-
|
1118 |
-
|
1119 |
-
|
1120 |
-
|
1121 |
-
|
1122 |
-
|
1123 |
-
|
1124 |
-
}
|
1125 |
-
return
|
1126 |
-
|
1127 |
-
|
1128 |
-
|
1129 |
-
|
1130 |
-
|
1131 |
-
|
1132 |
-
|
1133 |
-
|
1134 |
-
|
1135 |
-
|
1136 |
-
|
1137 |
-
|
1138 |
-
var
|
1139 |
-
|
1140 |
-
|
1141 |
-
|
1142 |
-
|
1143 |
-
|
1144 |
-
|
1145 |
-
|
1146 |
-
|
1147 |
-
|
1148 |
-
|
1149 |
-
|
1150 |
-
|
1151 |
-
|
1152 |
-
|
1153 |
-
|
1154 |
-
|
1155 |
-
|
1156 |
-
|
1157 |
-
|
1158 |
-
|
1159 |
-
|
1160 |
-
|
1161 |
-
|
1162 |
-
|
1163 |
-
|
1164 |
-
|
1165 |
-
if (
|
1166 |
-
|
1167 |
-
|
1168 |
-
|
1169 |
-
|
1170 |
-
|
1171 |
-
var
|
1172 |
-
|
1173 |
-
|
1174 |
-
|
1175 |
-
|
1176 |
-
|
1177 |
-
|
1178 |
-
|
1179 |
-
|
1180 |
-
|
1181 |
-
|
1182 |
-
|
1183 |
-
|
1184 |
-
//
|
1185 |
-
|
1186 |
-
|
1187 |
-
|
1188 |
-
|
1189 |
-
|
1190 |
-
|
1191 |
-
|
1192 |
-
|
1193 |
-
|
1194 |
-
|
1195 |
-
|
1196 |
-
|
1197 |
-
|
1198 |
-
|
1199 |
-
|
1200 |
-
|
1201 |
-
}
|
1202 |
-
|
1203 |
-
|
1204 |
-
|
1205 |
-
|
1206 |
-
}
|
1207 |
-
|
1208 |
-
|
1209 |
-
|
1210 |
-
|
1211 |
-
|
1212 |
-
|
1213 |
-
|
1214 |
-
|
1215 |
-
|
1216 |
-
|
1217 |
-
|
1218 |
-
|
1219 |
-
|
1220 |
-
|
1221 |
-
|
1222 |
-
|
1223 |
-
|
1224 |
-
|
1225 |
-
|
1226 |
-
|
1227 |
-
|
1228 |
-
|
1229 |
-
|
1230 |
-
|
1231 |
-
|
1232 |
-
var
|
1233 |
-
|
1234 |
-
|
1235 |
-
|
1236 |
-
|
1237 |
-
|
1238 |
-
|
1239 |
-
|
1240 |
-
|
1241 |
-
|
1242 |
-
|
1243 |
-
|
1244 |
-
|
1245 |
-
|
1246 |
-
|
1247 |
-
|
1248 |
-
|
1249 |
-
if (
|
1250 |
-
|
1251 |
-
|
1252 |
-
|
1253 |
-
|
1254 |
-
|
1255 |
-
|
1256 |
-
|
1257 |
-
|
1258 |
-
|
1259 |
-
|
1260 |
-
|
1261 |
-
|
1262 |
-
|
1263 |
-
|
1264 |
-
|
1265 |
-
|
1266 |
-
|
1267 |
-
|
1268 |
-
|
1269 |
-
|
1270 |
-
|
1271 |
-
|
1272 |
-
|
1273 |
-
|
1274 |
-
|
1275 |
-
|
1276 |
-
|
1277 |
-
|
1278 |
-
|
1279 |
-
|
1280 |
-
|
1281 |
-
|
1282 |
-
|
1283 |
-
|
1284 |
-
|
1285 |
-
|
1286 |
-
|
1287 |
-
|
1288 |
-
|
1289 |
-
|
1290 |
-
|
1291 |
-
|
1292 |
-
|
1293 |
-
|
1294 |
-
|
1295 |
-
|
1296 |
-
|
1297 |
-
|
1298 |
-
|
1299 |
-
|
1300 |
-
|
1301 |
-
|
1302 |
-
|
1303 |
-
|
1304 |
-
|
1305 |
-
}
|
1306 |
-
|
1307 |
-
|
1308 |
-
|
1309 |
-
|
1310 |
-
|
1311 |
-
|
1312 |
-
|
1313 |
-
|
1314 |
-
|
1315 |
-
|
1316 |
-
|
1317 |
-
|
1318 |
-
|
1319 |
-
|
1320 |
-
|
1321 |
-
|
1322 |
-
|
1323 |
-
|
1324 |
-
|
1325 |
-
|
1326 |
-
|
1327 |
-
|
1328 |
-
|
1329 |
-
|
1330 |
-
|
1331 |
-
|
1332 |
-
|
1333 |
-
|
1334 |
-
|
1335 |
-
|
1336 |
-
|
1337 |
-
|
1338 |
-
|
1339 |
-
|
1340 |
-
|
1341 |
-
|
1342 |
-
|
1343 |
-
|
1344 |
-
|
1345 |
-
|
1346 |
-
|
1347 |
-
|
1348 |
-
|
1349 |
-
|
1350 |
-
|
1351 |
-
|
1352 |
-
|
1353 |
-
|
1354 |
-
|
1355 |
-
|
1356 |
-
|
1357 |
-
|
1358 |
-
|
1359 |
-
|
1360 |
-
|
1361 |
-
|
1362 |
-
|
1363 |
-
|
1364 |
-
|
1365 |
-
var
|
1366 |
-
|
1367 |
-
|
1368 |
-
|
1369 |
-
|
1370 |
-
var
|
1371 |
-
|
1372 |
-
|
1373 |
-
|
1374 |
-
|
1375 |
-
|
1376 |
-
|
1377 |
-
|
1378 |
-
if (
|
1379 |
-
|
1380 |
-
|
1381 |
-
|
1382 |
-
|
1383 |
-
|
1384 |
-
|
1385 |
-
|
1386 |
-
|
1387 |
-
|
1388 |
-
|
1389 |
-
|
1390 |
-
|
1391 |
-
|
1392 |
-
|
1393 |
-
|
1394 |
-
|
1395 |
-
|
1396 |
-
|
1397 |
-
|
1398 |
-
|
1399 |
-
|
1400 |
-
|
1401 |
-
|
1402 |
-
|
1403 |
-
|
1404 |
-
|
1405 |
-
|
1406 |
-
|
1407 |
-
|
1408 |
-
|
1409 |
-
|
1410 |
-
|
1411 |
-
|
1412 |
-
|
1413 |
-
|
1414 |
-
|
1415 |
-
|
1416 |
-
|
1417 |
-
|
1418 |
-
|
1419 |
-
|
1420 |
-
|
1421 |
-
|
1422 |
-
|
1423 |
-
|
1424 |
-
|
1425 |
-
|
1426 |
-
|
1427 |
-
|
1428 |
-
|
1429 |
-
|
1430 |
-
|
1431 |
-
|
1432 |
-
|
1433 |
-
|
1434 |
-
|
1435 |
-
|
1436 |
-
|
1437 |
-
|
1438 |
-
|
1439 |
-
|
1440 |
-
|
1441 |
-
|
1442 |
-
|
1443 |
-
|
1444 |
-
|
1445 |
-
|
1446 |
-
|
1447 |
-
|
1448 |
-
|
1449 |
-
|
1450 |
-
|
1451 |
-
|
1452 |
-
|
1453 |
-
|
1454 |
-
|
1455 |
-
|
1456 |
-
|
1457 |
-
|
1458 |
-
|
1459 |
-
|
1460 |
-
|
1461 |
-
|
1462 |
-
|
1463 |
-
|
1464 |
-
|
1465 |
-
|
1466 |
-
|
1467 |
-
|
1468 |
-
|
1469 |
-
|
1470 |
-
|
1471 |
-
|
1472 |
-
|
1473 |
-
|
1474 |
-
|
1475 |
-
|
1476 |
-
|
1477 |
-
|
1478 |
-
|
1479 |
-
|
1480 |
-
|
1481 |
-
|
1482 |
-
|
1483 |
-
|
1484 |
-
|
1485 |
-
|
1486 |
-
|
1487 |
-
|
1488 |
-
|
1489 |
-
|
1490 |
-
|
1491 |
-
|
1492 |
-
|
1493 |
-
|
1494 |
-
|
1495 |
-
|
1496 |
-
|
1497 |
-
|
1498 |
-
|
1499 |
-
|
1500 |
-
|
1501 |
-
|
1502 |
-
|
1503 |
-
|
1504 |
-
|
1505 |
-
|
1506 |
-
|
1507 |
-
|
1508 |
-
|
1509 |
-
|
1510 |
-
|
1511 |
-
|
1512 |
-
|
1513 |
-
|
1514 |
-
|
1515 |
-
|
1516 |
-
|
1517 |
-
|
1518 |
-
|
1519 |
-
|
1520 |
-
|
1521 |
-
|
1522 |
-
|
1523 |
-
|
1524 |
-
|
1525 |
-
|
1526 |
-
|
1527 |
-
|
1528 |
-
cm.display.
|
1529 |
-
|
1530 |
-
|
1531 |
-
|
1532 |
-
|
1533 |
-
|
1534 |
-
|
1535 |
-
|
1536 |
-
|
1537 |
-
|
1538 |
-
|
1539 |
-
|
1540 |
-
|
1541 |
-
|
1542 |
-
|
1543 |
-
|
1544 |
-
|
1545 |
-
|
1546 |
-
|
1547 |
-
|
1548 |
-
|
1549 |
-
|
1550 |
-
|
1551 |
-
|
1552 |
-
|
1553 |
-
|
1554 |
-
|
1555 |
-
|
1556 |
-
|
1557 |
-
|
1558 |
-
|
1559 |
-
|
1560 |
-
|
1561 |
-
|
1562 |
-
|
1563 |
-
|
1564 |
-
|
1565 |
-
|
1566 |
-
|
1567 |
-
|
1568 |
-
|
1569 |
-
|
1570 |
-
|
1571 |
-
|
1572 |
-
|
1573 |
-
|
1574 |
-
|
1575 |
-
|
1576 |
-
|
1577 |
-
|
1578 |
-
|
1579 |
-
|
1580 |
-
|
1581 |
-
|
1582 |
-
|
1583 |
-
|
1584 |
-
|
1585 |
-
|
1586 |
-
|
1587 |
-
|
1588 |
-
|
1589 |
-
|
1590 |
-
|
1591 |
-
|
1592 |
-
|
1593 |
-
|
1594 |
-
|
1595 |
-
|
1596 |
-
|
1597 |
-
|
1598 |
-
|
1599 |
-
|
1600 |
-
|
1601 |
-
|
1602 |
-
|
1603 |
-
|
1604 |
-
|
1605 |
-
|
1606 |
-
|
1607 |
-
|
1608 |
-
|
1609 |
-
|
1610 |
-
|
1611 |
-
|
1612 |
-
|
1613 |
-
|
1614 |
-
|
1615 |
-
|
1616 |
-
|
1617 |
-
|
1618 |
-
|
1619 |
-
|
1620 |
-
|
1621 |
-
|
1622 |
-
|
1623 |
-
|
1624 |
-
|
1625 |
-
|
1626 |
-
|
1627 |
-
|
1628 |
-
|
1629 |
-
|
1630 |
-
|
1631 |
-
|
1632 |
-
|
1633 |
-
|
1634 |
-
|
1635 |
-
|
1636 |
-
|
1637 |
-
|
1638 |
-
|
1639 |
-
|
1640 |
-
|
1641 |
-
|
1642 |
-
|
1643 |
-
|
1644 |
-
|
1645 |
-
|
1646 |
-
|
1647 |
-
|
1648 |
-
|
1649 |
-
|
1650 |
-
|
1651 |
-
|
1652 |
-
|
1653 |
-
|
1654 |
-
|
1655 |
-
|
1656 |
-
|
1657 |
-
|
1658 |
-
|
1659 |
-
|
1660 |
-
|
1661 |
-
|
1662 |
-
|
1663 |
-
|
1664 |
-
|
1665 |
-
|
1666 |
-
|
1667 |
-
|
1668 |
-
|
1669 |
-
|
1670 |
-
|
1671 |
-
|
1672 |
-
|
1673 |
-
|
1674 |
-
|
1675 |
-
|
1676 |
-
|
1677 |
-
|
1678 |
-
|
1679 |
-
|
1680 |
-
|
1681 |
-
|
1682 |
-
|
1683 |
-
|
1684 |
-
|
1685 |
-
|
1686 |
-
|
1687 |
-
|
1688 |
-
|
1689 |
-
|
1690 |
-
|
1691 |
-
|
1692 |
-
|
1693 |
-
|
1694 |
-
|
1695 |
-
|
1696 |
-
|
1697 |
-
|
1698 |
-
|
1699 |
-
|
1700 |
-
|
1701 |
-
|
1702 |
-
|
1703 |
-
|
1704 |
-
|
1705 |
-
|
1706 |
-
|
1707 |
-
|
1708 |
-
}
|
1709 |
-
|
1710 |
-
|
1711 |
-
|
1712 |
-
|
1713 |
-
|
1714 |
-
|
1715 |
-
|
1716 |
-
|
1717 |
-
|
1718 |
-
|
1719 |
-
|
1720 |
-
|
1721 |
-
|
1722 |
-
|
1723 |
-
|
1724 |
-
|
1725 |
-
|
1726 |
-
|
1727 |
-
|
1728 |
-
|
1729 |
-
|
1730 |
-
|
1731 |
-
|
1732 |
-
|
1733 |
-
|
1734 |
-
|
1735 |
-
|
1736 |
-
|
1737 |
-
|
1738 |
-
|
1739 |
-
|
1740 |
-
|
1741 |
-
|
1742 |
-
|
1743 |
-
|
1744 |
-
|
1745 |
-
|
1746 |
-
|
1747 |
-
|
1748 |
-
if (
|
1749 |
-
|
1750 |
-
|
1751 |
-
|
1752 |
-
|
1753 |
-
|
1754 |
-
|
1755 |
-
|
1756 |
-
|
1757 |
-
|
1758 |
-
|
1759 |
-
|
1760 |
-
|
1761 |
-
|
1762 |
-
|
1763 |
-
|
1764 |
-
|
1765 |
-
|
1766 |
-
|
1767 |
-
|
1768 |
-
|
1769 |
-
|
1770 |
-
|
1771 |
-
|
1772 |
-
|
1773 |
-
|
1774 |
-
|
1775 |
-
|
1776 |
-
|
1777 |
-
|
1778 |
-
|
1779 |
-
|
1780 |
-
|
1781 |
-
|
1782 |
-
|
1783 |
-
if (
|
1784 |
-
|
1785 |
-
|
1786 |
-
|
1787 |
-
|
1788 |
-
|
1789 |
-
|
1790 |
-
|
1791 |
-
}
|
1792 |
-
|
1793 |
-
|
1794 |
-
|
1795 |
-
|
1796 |
-
|
1797 |
-
|
1798 |
-
|
1799 |
-
|
1800 |
-
|
1801 |
-
|
1802 |
-
|
1803 |
-
|
1804 |
-
if (
|
1805 |
-
|
1806 |
-
|
1807 |
-
|
1808 |
-
|
1809 |
-
|
1810 |
-
|
1811 |
-
|
1812 |
-
|
1813 |
-
|
1814 |
-
|
1815 |
-
|
1816 |
-
|
1817 |
-
|
1818 |
-
|
1819 |
-
|
1820 |
-
|
1821 |
-
|
1822 |
-
|
1823 |
-
|
1824 |
-
|
1825 |
-
|
1826 |
-
|
1827 |
-
|
1828 |
-
|
1829 |
-
|
1830 |
-
|
1831 |
-
|
1832 |
-
|
1833 |
-
|
1834 |
-
|
1835 |
-
|
1836 |
-
|
1837 |
-
|
1838 |
-
|
1839 |
-
|
1840 |
-
|
1841 |
-
|
1842 |
-
|
1843 |
-
|
1844 |
-
|
1845 |
-
|
1846 |
-
|
1847 |
-
|
1848 |
-
|
1849 |
-
|
1850 |
-
|
1851 |
-
|
1852 |
-
|
1853 |
-
|
1854 |
-
|
1855 |
-
|
1856 |
-
|
1857 |
-
|
1858 |
-
|
1859 |
-
|
1860 |
-
|
1861 |
-
|
1862 |
-
if (
|
1863 |
-
|
1864 |
-
|
1865 |
-
|
1866 |
-
|
1867 |
-
|
1868 |
-
|
1869 |
-
|
1870 |
-
|
1871 |
-
|
1872 |
-
|
1873 |
-
|
1874 |
-
|
1875 |
-
|
1876 |
-
|
1877 |
-
|
1878 |
-
|
1879 |
-
|
1880 |
-
|
1881 |
-
|
1882 |
-
|
1883 |
-
|
1884 |
-
|
1885 |
-
|
1886 |
-
|
1887 |
-
|
1888 |
-
|
1889 |
-
|
1890 |
-
|
1891 |
-
|
1892 |
-
|
1893 |
-
|
1894 |
-
|
1895 |
-
|
1896 |
-
|
1897 |
-
|
1898 |
-
|
1899 |
-
|
1900 |
-
|
1901 |
-
|
1902 |
-
|
1903 |
-
|
1904 |
-
|
1905 |
-
|
1906 |
-
|
1907 |
-
|
1908 |
-
|
1909 |
-
|
1910 |
-
|
1911 |
-
|
1912 |
-
|
1913 |
-
|
1914 |
-
|
1915 |
-
|
1916 |
-
|
1917 |
-
|
1918 |
-
|
1919 |
-
|
1920 |
-
|
1921 |
-
|
1922 |
-
|
1923 |
-
|
1924 |
-
|
1925 |
-
|
1926 |
-
|
1927 |
-
if (
|
1928 |
-
|
1929 |
-
|
1930 |
-
|
1931 |
-
|
1932 |
-
|
1933 |
-
|
1934 |
-
|
1935 |
-
|
1936 |
-
|
1937 |
-
|
1938 |
-
|
1939 |
-
|
1940 |
-
|
1941 |
-
|
1942 |
-
|
1943 |
-
|
1944 |
-
|
1945 |
-
|
1946 |
-
|
1947 |
-
|
1948 |
-
|
1949 |
-
|
1950 |
-
function
|
1951 |
-
|
1952 |
-
|
1953 |
-
|
1954 |
-
|
1955 |
-
|
1956 |
-
|
1957 |
-
|
1958 |
-
|
1959 |
-
|
1960 |
-
|
1961 |
-
|
1962 |
-
|
1963 |
-
|
1964 |
-
|
1965 |
-
|
1966 |
-
|
1967 |
-
|
1968 |
-
|
1969 |
-
|
1970 |
-
|
1971 |
-
|
1972 |
-
|
1973 |
-
|
1974 |
-
|
1975 |
-
|
1976 |
-
|
1977 |
-
|
1978 |
-
|
1979 |
-
|
1980 |
-
function
|
1981 |
-
var
|
1982 |
-
|
1983 |
-
|
1984 |
-
|
1985 |
-
|
1986 |
-
|
1987 |
-
|
1988 |
-
|
1989 |
-
|
1990 |
-
|
1991 |
-
|
1992 |
-
|
1993 |
-
|
1994 |
-
|
1995 |
-
|
1996 |
-
|
1997 |
-
|
1998 |
-
|
1999 |
-
|
2000 |
-
|
2001 |
-
|
2002 |
-
|
2003 |
-
|
2004 |
-
|
2005 |
-
|
2006 |
-
|
2007 |
-
|
2008 |
-
|
2009 |
-
|
2010 |
-
|
2011 |
-
|
2012 |
-
|
2013 |
-
|
2014 |
-
|
2015 |
-
|
2016 |
-
|
2017 |
-
}
|
2018 |
-
|
2019 |
-
|
2020 |
-
|
2021 |
-
|
2022 |
-
|
2023 |
-
|
2024 |
-
|
2025 |
-
|
2026 |
-
|
2027 |
-
|
2028 |
-
|
2029 |
-
|
2030 |
-
|
2031 |
-
|
2032 |
-
|
2033 |
-
|
2034 |
-
|
2035 |
-
|
2036 |
-
|
2037 |
-
|
2038 |
-
|
2039 |
-
|
2040 |
-
|
2041 |
-
|
2042 |
-
|
2043 |
-
|
2044 |
-
|
2045 |
-
|
2046 |
-
|
2047 |
-
|
2048 |
-
|
2049 |
-
|
2050 |
-
|
2051 |
-
|
2052 |
-
|
2053 |
-
|
2054 |
-
|
2055 |
-
|
2056 |
-
|
2057 |
-
|
2058 |
-
|
2059 |
-
|
2060 |
-
|
2061 |
-
|
2062 |
-
|
2063 |
-
|
2064 |
-
|
2065 |
-
|
2066 |
-
|
2067 |
-
|
2068 |
-
|
2069 |
-
|
2070 |
-
|
2071 |
-
|
2072 |
-
|
2073 |
-
|
2074 |
-
|
2075 |
-
|
2076 |
-
|
2077 |
-
|
2078 |
-
|
2079 |
-
|
2080 |
-
|
2081 |
-
|
2082 |
-
|
2083 |
-
|
2084 |
-
|
2085 |
-
|
2086 |
-
|
2087 |
-
|
2088 |
-
|
2089 |
-
|
2090 |
-
|
2091 |
-
|
2092 |
-
|
2093 |
-
|
2094 |
-
|
2095 |
-
|
2096 |
-
|
2097 |
-
|
2098 |
-
|
2099 |
-
|
2100 |
-
|
2101 |
-
|
2102 |
-
|
2103 |
-
|
2104 |
-
|
2105 |
-
|
2106 |
-
|
2107 |
-
|
2108 |
-
|
2109 |
-
|
2110 |
-
return
|
2111 |
-
|
2112 |
-
|
2113 |
-
|
2114 |
-
|
2115 |
-
|
2116 |
-
|
2117 |
-
|
2118 |
-
|
2119 |
-
|
2120 |
-
|
2121 |
-
|
2122 |
-
|
2123 |
-
|
2124 |
-
|
2125 |
-
|
2126 |
-
|
2127 |
-
|
2128 |
-
|
2129 |
-
|
2130 |
-
|
2131 |
-
|
2132 |
-
|
2133 |
-
|
2134 |
-
|
2135 |
-
|
2136 |
-
|
2137 |
-
|
2138 |
-
|
2139 |
-
|
2140 |
-
|
2141 |
-
|
2142 |
-
|
2143 |
-
|
2144 |
-
|
2145 |
-
|
2146 |
-
|
2147 |
-
|
2148 |
-
|
2149 |
-
|
2150 |
-
|
2151 |
-
|
2152 |
-
|
2153 |
-
|
2154 |
-
|
2155 |
-
|
2156 |
-
|
2157 |
-
|
2158 |
-
|
2159 |
-
|
2160 |
-
|
2161 |
-
|
2162 |
-
|
2163 |
-
|
2164 |
-
|
2165 |
-
|
2166 |
-
|
2167 |
-
|
2168 |
-
|
2169 |
-
|
2170 |
-
|
2171 |
-
|
2172 |
-
|
2173 |
-
}
|
2174 |
-
|
2175 |
-
|
2176 |
-
|
2177 |
-
|
2178 |
-
|
2179 |
-
|
2180 |
-
|
2181 |
-
|
2182 |
-
|
2183 |
-
|
2184 |
-
|
2185 |
-
|
2186 |
-
|
2187 |
-
|
2188 |
-
|
2189 |
-
|
2190 |
-
|
2191 |
-
|
2192 |
-
|
2193 |
-
|
2194 |
-
|
2195 |
-
|
2196 |
-
|
2197 |
-
|
2198 |
-
|
2199 |
-
var
|
2200 |
-
|
2201 |
-
|
2202 |
-
|
2203 |
-
|
2204 |
-
|
2205 |
-
|
2206 |
-
|
2207 |
-
|
2208 |
-
|
2209 |
-
|
2210 |
-
|
2211 |
-
|
2212 |
-
|
2213 |
-
|
2214 |
-
|
2215 |
-
|
2216 |
-
|
2217 |
-
|
2218 |
-
|
2219 |
-
|
2220 |
-
|
2221 |
-
|
2222 |
-
|
2223 |
-
if (
|
2224 |
-
|
2225 |
-
|
2226 |
-
|
2227 |
-
|
2228 |
-
|
2229 |
-
|
2230 |
-
|
2231 |
-
|
2232 |
-
|
2233 |
-
|
2234 |
-
|
2235 |
-
|
2236 |
-
|
2237 |
-
|
2238 |
-
|
2239 |
-
|
2240 |
-
|
2241 |
-
|
2242 |
-
|
2243 |
-
|
2244 |
-
|
2245 |
-
|
2246 |
-
}
|
2247 |
-
|
2248 |
-
|
2249 |
-
//
|
2250 |
-
|
2251 |
-
|
2252 |
-
|
2253 |
-
|
2254 |
-
|
2255 |
-
|
2256 |
-
|
2257 |
-
|
2258 |
-
|
2259 |
-
|
2260 |
-
|
2261 |
-
|
2262 |
-
|
2263 |
-
|
2264 |
-
return
|
2265 |
-
|
2266 |
-
|
2267 |
-
|
2268 |
-
|
2269 |
-
|
2270 |
-
|
2271 |
-
|
2272 |
-
|
2273 |
-
|
2274 |
-
|
2275 |
-
|
2276 |
-
|
2277 |
-
|
2278 |
-
|
2279 |
-
|
2280 |
-
|
2281 |
-
|
2282 |
-
|
2283 |
-
|
2284 |
-
|
2285 |
-
|
2286 |
-
|
2287 |
-
|
2288 |
-
|
2289 |
-
|
2290 |
-
|
2291 |
-
|
2292 |
-
|
2293 |
-
|
2294 |
-
|
2295 |
-
|
2296 |
-
|
2297 |
-
|
2298 |
-
|
2299 |
-
|
2300 |
-
|
2301 |
-
|
2302 |
-
|
2303 |
-
|
2304 |
-
|
2305 |
-
|
2306 |
-
|
2307 |
-
|
2308 |
-
|
2309 |
-
|
2310 |
-
|
2311 |
-
|
2312 |
-
|
2313 |
-
if (
|
2314 |
-
|
2315 |
-
|
2316 |
-
|
2317 |
-
|
2318 |
-
|
2319 |
-
|
2320 |
-
|
2321 |
-
|
2322 |
-
|
2323 |
-
|
2324 |
-
if (
|
2325 |
-
|
2326 |
-
|
2327 |
-
|
2328 |
-
|
2329 |
-
|
2330 |
-
|
2331 |
-
|
2332 |
-
|
2333 |
-
|
2334 |
-
|
2335 |
-
if (
|
2336 |
-
|
2337 |
-
|
2338 |
-
|
2339 |
-
|
2340 |
-
|
2341 |
-
|
2342 |
-
|
2343 |
-
|
2344 |
-
|
2345 |
-
|
2346 |
-
|
2347 |
-
|
2348 |
-
|
2349 |
-
|
2350 |
-
|
2351 |
-
|
2352 |
-
|
2353 |
-
|
2354 |
-
|
2355 |
-
|
2356 |
-
|
2357 |
-
|
2358 |
-
|
2359 |
-
|
2360 |
-
|
2361 |
-
|
2362 |
-
|
2363 |
-
|
2364 |
-
|
2365 |
-
var
|
2366 |
-
|
2367 |
-
|
2368 |
-
|
2369 |
-
|
2370 |
-
|
2371 |
-
|
2372 |
-
|
2373 |
-
|
2374 |
-
|
2375 |
-
|
2376 |
-
|
2377 |
-
|
2378 |
-
|
2379 |
-
|
2380 |
-
|
2381 |
-
|
2382 |
-
|
2383 |
-
|
2384 |
-
|
2385 |
-
|
2386 |
-
|
2387 |
-
|
2388 |
-
|
2389 |
-
|
2390 |
-
|
2391 |
-
|
2392 |
-
|
2393 |
-
|
2394 |
-
|
2395 |
-
|
2396 |
-
|
2397 |
-
|
2398 |
-
|
2399 |
-
|
2400 |
-
|
2401 |
-
|
2402 |
-
|
2403 |
-
|
2404 |
-
|
2405 |
-
|
2406 |
-
|
2407 |
-
|
2408 |
-
|
2409 |
-
|
2410 |
-
|
2411 |
-
if (doc.
|
2412 |
-
return
|
2413 |
-
|
2414 |
-
|
2415 |
-
|
2416 |
-
|
2417 |
-
|
2418 |
-
|
2419 |
-
|
2420 |
-
|
2421 |
-
|
2422 |
-
|
2423 |
-
|
2424 |
-
|
2425 |
-
|
2426 |
-
|
2427 |
-
|
2428 |
-
|
2429 |
-
|
2430 |
-
|
2431 |
-
|
2432 |
-
|
2433 |
-
|
2434 |
-
|
2435 |
-
|
2436 |
-
|
2437 |
-
|
2438 |
-
|
2439 |
-
|
2440 |
-
|
2441 |
-
|
2442 |
-
|
2443 |
-
|
2444 |
-
|
2445 |
-
|
2446 |
-
|
2447 |
-
|
2448 |
-
|
2449 |
-
|
2450 |
-
|
2451 |
-
|
2452 |
-
|
2453 |
-
|
2454 |
-
|
2455 |
-
|
2456 |
-
|
2457 |
-
|
2458 |
-
|
2459 |
-
|
2460 |
-
|
2461 |
-
|
2462 |
-
|
2463 |
-
|
2464 |
-
|
2465 |
-
|
2466 |
-
|
2467 |
-
|
2468 |
-
|
2469 |
-
|
2470 |
-
|
2471 |
-
|
2472 |
-
|
2473 |
-
|
2474 |
-
|
2475 |
-
|
2476 |
-
|
2477 |
-
|
2478 |
-
|
2479 |
-
|
2480 |
-
|
2481 |
-
|
2482 |
-
|
2483 |
-
|
2484 |
-
|
2485 |
-
if (cm.
|
2486 |
-
|
2487 |
-
|
2488 |
-
|
2489 |
-
|
2490 |
-
|
2491 |
-
|
2492 |
-
|
2493 |
-
|
2494 |
-
|
2495 |
-
|
2496 |
-
|
2497 |
-
|
2498 |
-
|
2499 |
-
//
|
2500 |
-
|
2501 |
-
|
2502 |
-
|
2503 |
-
|
2504 |
-
|
2505 |
-
|
2506 |
-
|
2507 |
-
|
2508 |
-
|
2509 |
-
|
2510 |
-
|
2511 |
-
|
2512 |
-
|
2513 |
-
|
2514 |
-
|
2515 |
-
|
2516 |
-
|
2517 |
-
if (
|
2518 |
-
|
2519 |
-
|
2520 |
-
|
2521 |
-
|
2522 |
-
|
2523 |
-
|
2524 |
-
|
2525 |
-
|
2526 |
-
|
2527 |
-
|
2528 |
-
|
2529 |
-
|
2530 |
-
|
2531 |
-
if (
|
2532 |
-
|
2533 |
-
|
2534 |
-
|
2535 |
-
|
2536 |
-
|
2537 |
-
|
2538 |
-
|
2539 |
-
|
2540 |
-
|
2541 |
-
|
2542 |
-
|
2543 |
-
|
2544 |
-
|
2545 |
-
}
|
2546 |
-
|
2547 |
-
|
2548 |
-
|
2549 |
-
|
2550 |
-
|
2551 |
-
|
2552 |
-
|
2553 |
-
|
2554 |
-
|
2555 |
-
|
2556 |
-
|
2557 |
-
|
2558 |
-
|
2559 |
-
|
2560 |
-
|
2561 |
-
|
2562 |
-
|
2563 |
-
|
2564 |
-
|
2565 |
-
|
2566 |
-
|
2567 |
-
|
2568 |
-
|
2569 |
-
|
2570 |
-
|
2571 |
-
|
2572 |
-
|
2573 |
-
|
2574 |
-
|
2575 |
-
|
2576 |
-
|
2577 |
-
|
2578 |
-
|
2579 |
-
|
2580 |
-
|
2581 |
-
|
2582 |
-
|
2583 |
-
|
2584 |
-
|
2585 |
-
|
2586 |
-
|
2587 |
-
|
2588 |
-
|
2589 |
-
|
2590 |
-
|
2591 |
-
|
2592 |
-
|
2593 |
-
|
2594 |
-
function
|
2595 |
-
|
2596 |
-
var
|
2597 |
-
|
2598 |
-
|
2599 |
-
var
|
2600 |
-
|
2601 |
-
|
2602 |
-
|
2603 |
-
|
2604 |
-
|
2605 |
-
|
2606 |
-
|
2607 |
-
|
2608 |
-
|
2609 |
-
|
2610 |
-
|
2611 |
-
|
2612 |
-
|
2613 |
-
|
2614 |
-
|
2615 |
-
|
2616 |
-
|
2617 |
-
|
2618 |
-
|
2619 |
-
|
2620 |
-
|
2621 |
-
|
2622 |
-
|
2623 |
-
|
2624 |
-
|
2625 |
-
|
2626 |
-
|
2627 |
-
|
2628 |
-
|
2629 |
-
|
2630 |
-
|
2631 |
-
|
2632 |
-
|
2633 |
-
|
2634 |
-
|
2635 |
-
|
2636 |
-
|
2637 |
-
|
2638 |
-
|
2639 |
-
|
2640 |
-
|
2641 |
-
|
2642 |
-
|
2643 |
-
|
2644 |
-
|
2645 |
-
|
2646 |
-
|
2647 |
-
|
2648 |
-
|
2649 |
-
|
2650 |
-
|
2651 |
-
|
2652 |
-
|
2653 |
-
|
2654 |
-
|
2655 |
-
|
2656 |
-
|
2657 |
-
|
2658 |
-
|
2659 |
-
|
2660 |
-
|
2661 |
-
}
|
2662 |
-
|
2663 |
-
|
2664 |
-
|
2665 |
-
|
2666 |
-
|
2667 |
-
|
2668 |
-
|
2669 |
-
|
2670 |
-
|
2671 |
-
|
2672 |
-
|
2673 |
-
|
2674 |
-
|
2675 |
-
|
2676 |
-
|
2677 |
-
|
2678 |
-
|
2679 |
-
|
2680 |
-
|
2681 |
-
|
2682 |
-
|
2683 |
-
|
2684 |
-
|
2685 |
-
|
2686 |
-
|
2687 |
-
|
2688 |
-
|
2689 |
-
|
2690 |
-
|
2691 |
-
|
2692 |
-
|
2693 |
-
|
2694 |
-
|
2695 |
-
|
2696 |
-
|
2697 |
-
|
2698 |
-
|
2699 |
-
|
2700 |
-
|
2701 |
-
|
2702 |
-
|
2703 |
-
|
2704 |
-
|
2705 |
-
|
2706 |
-
|
2707 |
-
|
2708 |
-
|
2709 |
-
|
2710 |
-
|
2711 |
-
|
2712 |
-
}
|
2713 |
-
|
2714 |
-
|
2715 |
-
|
2716 |
-
|
2717 |
-
|
2718 |
-
|
2719 |
-
|
2720 |
-
|
2721 |
-
|
2722 |
-
|
2723 |
-
|
2724 |
-
|
2725 |
-
|
2726 |
-
|
2727 |
-
|
2728 |
-
|
2729 |
-
|
2730 |
-
|
2731 |
-
|
2732 |
-
|
2733 |
-
|
2734 |
-
|
2735 |
-
|
2736 |
-
|
2737 |
-
|
2738 |
-
|
2739 |
-
|
2740 |
-
|
2741 |
-
|
2742 |
-
|
2743 |
-
|
2744 |
-
|
2745 |
-
|
2746 |
-
|
2747 |
-
|
2748 |
-
|
2749 |
-
}
|
2750 |
-
|
2751 |
-
|
2752 |
-
|
2753 |
-
|
2754 |
-
|
2755 |
-
|
2756 |
-
|
2757 |
-
|
2758 |
-
|
2759 |
-
|
2760 |
-
|
2761 |
-
|
2762 |
-
|
2763 |
-
|
2764 |
-
|
2765 |
-
|
2766 |
-
|
2767 |
-
|
2768 |
-
|
2769 |
-
|
2770 |
-
|
2771 |
-
|
2772 |
-
}
|
2773 |
-
|
2774 |
-
|
2775 |
-
|
2776 |
-
|
2777 |
-
|
2778 |
-
|
2779 |
-
|
2780 |
-
|
2781 |
-
return
|
2782 |
-
|
2783 |
-
|
2784 |
-
|
2785 |
-
|
2786 |
-
|
2787 |
-
var
|
2788 |
-
|
2789 |
-
var
|
2790 |
-
|
2791 |
-
|
2792 |
-
|
2793 |
-
|
2794 |
-
|
2795 |
-
|
2796 |
-
|
2797 |
-
|
2798 |
-
|
2799 |
-
|
2800 |
-
|
2801 |
-
|
2802 |
-
|
2803 |
-
|
2804 |
-
|
2805 |
-
if (
|
2806 |
-
|
2807 |
-
|
2808 |
-
|
2809 |
-
|
2810 |
-
|
2811 |
-
|
2812 |
-
|
2813 |
-
|
2814 |
-
|
2815 |
-
|
2816 |
-
|
2817 |
-
|
2818 |
-
|
2819 |
-
|
2820 |
-
|
2821 |
-
|
2822 |
-
|
2823 |
-
|
2824 |
-
|
2825 |
-
|
2826 |
-
|
2827 |
-
|
2828 |
-
|
2829 |
-
|
2830 |
-
|
2831 |
-
|
2832 |
-
|
2833 |
-
|
2834 |
-
}
|
2835 |
-
|
2836 |
-
|
2837 |
-
|
2838 |
-
|
2839 |
-
|
2840 |
-
|
2841 |
-
|
2842 |
-
|
2843 |
-
|
2844 |
-
|
2845 |
-
|
2846 |
-
|
2847 |
-
|
2848 |
-
|
2849 |
-
|
2850 |
-
|
2851 |
-
|
2852 |
-
|
2853 |
-
|
2854 |
-
|
2855 |
-
|
2856 |
-
|
2857 |
-
|
2858 |
-
|
2859 |
-
|
2860 |
-
|
2861 |
-
|
2862 |
-
|
2863 |
-
|
2864 |
-
|
2865 |
-
|
2866 |
-
|
2867 |
-
|
2868 |
-
|
2869 |
-
|
2870 |
-
|
2871 |
-
|
2872 |
-
|
2873 |
-
|
2874 |
-
|
2875 |
-
|
2876 |
-
|
2877 |
-
|
2878 |
-
|
2879 |
-
}
|
2880 |
-
|
2881 |
-
|
2882 |
-
|
2883 |
-
|
2884 |
-
|
2885 |
-
|
2886 |
-
|
2887 |
-
|
2888 |
-
|
2889 |
-
|
2890 |
-
|
2891 |
-
|
2892 |
-
|
2893 |
-
|
2894 |
-
|
2895 |
-
|
2896 |
-
|
2897 |
-
|
2898 |
-
|
2899 |
-
|
2900 |
-
|
2901 |
-
|
2902 |
-
|
2903 |
-
|
2904 |
-
|
2905 |
-
|
2906 |
-
|
2907 |
-
|
2908 |
-
|
2909 |
-
|
2910 |
-
|
2911 |
-
|
2912 |
-
|
2913 |
-
|
2914 |
-
|
2915 |
-
|
2916 |
-
|
2917 |
-
|
2918 |
-
|
2919 |
-
|
2920 |
-
|
2921 |
-
|
2922 |
-
}
|
2923 |
-
|
2924 |
-
|
2925 |
-
|
2926 |
-
|
2927 |
-
|
2928 |
-
|
2929 |
-
|
2930 |
-
|
2931 |
-
|
2932 |
-
|
2933 |
-
|
2934 |
-
|
2935 |
-
|
2936 |
-
|
2937 |
-
|
2938 |
-
|
2939 |
-
|
2940 |
-
|
2941 |
-
|
2942 |
-
|
2943 |
-
|
2944 |
-
|
2945 |
-
|
2946 |
-
|
2947 |
-
|
2948 |
-
|
2949 |
-
|
2950 |
-
|
2951 |
-
|
2952 |
-
|
2953 |
-
|
2954 |
-
|
2955 |
-
|
2956 |
-
|
2957 |
-
|
2958 |
-
|
2959 |
-
|
2960 |
-
|
2961 |
-
|
2962 |
-
|
2963 |
-
|
2964 |
-
|
2965 |
-
|
2966 |
-
|
2967 |
-
|
2968 |
-
|
2969 |
-
|
2970 |
-
|
2971 |
-
|
2972 |
-
|
2973 |
-
|
2974 |
-
|
2975 |
-
|
2976 |
-
|
2977 |
-
|
2978 |
-
|
2979 |
-
|
2980 |
-
|
2981 |
-
|
2982 |
-
|
2983 |
-
|
2984 |
-
|
2985 |
-
|
2986 |
-
|
2987 |
-
|
2988 |
-
|
2989 |
-
|
2990 |
-
|
2991 |
-
|
2992 |
-
|
2993 |
-
|
2994 |
-
|
2995 |
-
|
2996 |
-
|
2997 |
-
|
2998 |
-
|
2999 |
-
|
3000 |
-
|
3001 |
-
|
3002 |
-
|
3003 |
-
|
3004 |
-
|
3005 |
-
|
3006 |
-
|
3007 |
-
|
3008 |
-
|
3009 |
-
|
3010 |
-
|
3011 |
-
|
3012 |
-
|
3013 |
-
|
3014 |
-
|
3015 |
-
|
3016 |
-
|
3017 |
-
|
3018 |
-
|
3019 |
-
|
3020 |
-
|
3021 |
-
|
3022 |
-
|
3023 |
-
|
3024 |
-
|
3025 |
-
|
3026 |
-
|
3027 |
-
|
3028 |
-
|
3029 |
-
|
3030 |
-
|
3031 |
-
|
3032 |
-
|
3033 |
-
|
3034 |
-
|
3035 |
-
|
3036 |
-
|
3037 |
-
|
3038 |
-
|
3039 |
-
|
3040 |
-
|
3041 |
-
|
3042 |
-
|
3043 |
-
|
3044 |
-
|
3045 |
-
|
3046 |
-
|
3047 |
-
|
3048 |
-
|
3049 |
-
|
3050 |
-
|
3051 |
-
|
3052 |
-
|
3053 |
-
|
3054 |
-
|
3055 |
-
|
3056 |
-
|
3057 |
-
|
3058 |
-
|
3059 |
-
|
3060 |
-
|
3061 |
-
|
3062 |
-
|
3063 |
-
|
3064 |
-
|
3065 |
-
|
3066 |
-
|
3067 |
-
|
3068 |
-
|
3069 |
-
|
3070 |
-
|
3071 |
-
|
3072 |
-
|
3073 |
-
|
3074 |
-
|
3075 |
-
|
3076 |
-
var
|
3077 |
-
|
3078 |
-
|
3079 |
-
|
3080 |
-
|
3081 |
-
|
3082 |
-
|
3083 |
-
|
3084 |
-
|
3085 |
-
|
3086 |
-
|
3087 |
-
|
3088 |
-
|
3089 |
-
|
3090 |
-
|
3091 |
-
|
3092 |
-
|
3093 |
-
|
3094 |
-
|
3095 |
-
|
3096 |
-
|
3097 |
-
|
3098 |
-
|
3099 |
-
|
3100 |
-
|
3101 |
-
|
3102 |
-
|
3103 |
-
|
3104 |
-
|
3105 |
-
|
3106 |
-
|
3107 |
-
|
3108 |
-
|
3109 |
-
|
3110 |
-
|
3111 |
-
|
3112 |
-
|
3113 |
-
|
3114 |
-
|
3115 |
-
|
3116 |
-
|
3117 |
-
|
3118 |
-
|
3119 |
-
|
3120 |
-
|
3121 |
-
|
3122 |
-
|
3123 |
-
|
3124 |
-
|
3125 |
-
|
3126 |
-
|
3127 |
-
|
3128 |
-
|
3129 |
-
}
|
3130 |
-
|
3131 |
-
|
3132 |
-
|
3133 |
-
|
3134 |
-
|
3135 |
-
|
3136 |
-
|
3137 |
-
|
3138 |
-
|
3139 |
-
|
3140 |
-
|
3141 |
-
|
3142 |
-
|
3143 |
-
|
3144 |
-
|
3145 |
-
|
3146 |
-
|
3147 |
-
|
3148 |
-
|
3149 |
-
|
3150 |
-
|
3151 |
-
|
3152 |
-
|
3153 |
-
|
3154 |
-
|
3155 |
-
|
3156 |
-
|
3157 |
-
|
3158 |
-
|
3159 |
-
|
3160 |
-
|
3161 |
-
|
3162 |
-
|
3163 |
-
|
3164 |
-
|
3165 |
-
|
3166 |
-
|
3167 |
-
|
3168 |
-
|
3169 |
-
|
3170 |
-
|
3171 |
-
|
3172 |
-
|
3173 |
-
|
3174 |
-
|
3175 |
-
|
3176 |
-
|
3177 |
-
|
3178 |
-
|
3179 |
-
|
3180 |
-
|
3181 |
-
|
3182 |
-
|
3183 |
-
|
3184 |
-
|
3185 |
-
|
3186 |
-
|
3187 |
-
|
3188 |
-
|
3189 |
-
|
3190 |
-
|
3191 |
-
|
3192 |
-
|
3193 |
-
|
3194 |
-
|
3195 |
-
|
3196 |
-
|
3197 |
-
|
3198 |
-
|
3199 |
-
|
3200 |
-
|
3201 |
-
|
3202 |
-
|
3203 |
-
|
3204 |
-
|
3205 |
-
|
3206 |
-
|
3207 |
-
|
3208 |
-
|
3209 |
-
|
3210 |
-
|
3211 |
-
|
3212 |
-
|
3213 |
-
|
3214 |
-
|
3215 |
-
|
3216 |
-
|
3217 |
-
|
3218 |
-
|
3219 |
-
|
3220 |
-
|
3221 |
-
|
3222 |
-
|
3223 |
-
|
3224 |
-
|
3225 |
-
|
3226 |
-
|
3227 |
-
|
3228 |
-
|
3229 |
-
|
3230 |
-
|
3231 |
-
|
3232 |
-
|
3233 |
-
|
3234 |
-
|
3235 |
-
|
3236 |
-
|
3237 |
-
|
3238 |
-
|
3239 |
-
|
3240 |
-
|
3241 |
-
|
3242 |
-
|
3243 |
-
|
3244 |
-
|
3245 |
-
|
3246 |
-
|
3247 |
-
|
3248 |
-
|
3249 |
-
|
3250 |
-
|
3251 |
-
|
3252 |
-
|
3253 |
-
|
3254 |
-
|
3255 |
-
|
3256 |
-
|
3257 |
-
|
3258 |
-
|
3259 |
-
|
3260 |
-
|
3261 |
-
|
3262 |
-
|
3263 |
-
|
3264 |
-
|
3265 |
-
|
3266 |
-
|
3267 |
-
|
3268 |
-
|
3269 |
-
|
3270 |
-
|
3271 |
-
|
3272 |
-
|
3273 |
-
|
3274 |
-
|
3275 |
-
|
3276 |
-
|
3277 |
-
|
3278 |
-
|
3279 |
-
|
3280 |
-
|
3281 |
-
|
3282 |
-
|
3283 |
-
|
3284 |
-
|
3285 |
-
|
3286 |
-
|
3287 |
-
|
3288 |
-
|
3289 |
-
|
3290 |
-
|
3291 |
-
|
3292 |
-
|
3293 |
-
|
3294 |
-
|
3295 |
-
|
3296 |
-
|
3297 |
-
|
3298 |
-
|
3299 |
-
|
3300 |
-
|
3301 |
-
|
3302 |
-
|
3303 |
-
|
3304 |
-
|
3305 |
-
|
3306 |
-
|
3307 |
-
|
3308 |
-
|
3309 |
-
|
3310 |
-
|
3311 |
-
|
3312 |
-
|
3313 |
-
|
3314 |
-
|
3315 |
-
|
3316 |
-
|
3317 |
-
|
3318 |
-
|
3319 |
-
|
3320 |
-
|
3321 |
-
|
3322 |
-
|
3323 |
-
|
3324 |
-
|
3325 |
-
|
3326 |
-
|
3327 |
-
|
3328 |
-
|
3329 |
-
|
3330 |
-
|
3331 |
-
|
3332 |
-
|
3333 |
-
|
3334 |
-
|
3335 |
-
|
3336 |
-
|
3337 |
-
|
3338 |
-
|
3339 |
-
|
3340 |
-
|
3341 |
-
|
3342 |
-
|
3343 |
-
|
3344 |
-
|
3345 |
-
|
3346 |
-
|
3347 |
-
|
3348 |
-
|
3349 |
-
|
3350 |
-
|
3351 |
-
|
3352 |
-
|
3353 |
-
|
3354 |
-
|
3355 |
-
|
3356 |
-
|
3357 |
-
|
3358 |
-
|
3359 |
-
|
3360 |
-
|
3361 |
-
|
3362 |
-
if (
|
3363 |
-
|
3364 |
-
|
3365 |
-
|
3366 |
-
|
3367 |
-
|
3368 |
-
|
3369 |
-
|
3370 |
-
|
3371 |
-
|
3372 |
-
}
|
3373 |
-
|
3374 |
-
|
3375 |
-
|
3376 |
-
|
3377 |
-
|
3378 |
-
|
3379 |
-
|
3380 |
-
|
3381 |
-
|
3382 |
-
|
3383 |
-
|
3384 |
-
|
3385 |
-
|
3386 |
-
|
3387 |
-
|
3388 |
-
|
3389 |
-
|
3390 |
-
|
3391 |
-
|
3392 |
-
|
3393 |
-
|
3394 |
-
|
3395 |
-
|
3396 |
-
|
3397 |
-
|
3398 |
-
|
3399 |
-
|
3400 |
-
|
3401 |
-
|
3402 |
-
|
3403 |
-
|
3404 |
-
}
|
3405 |
-
|
3406 |
-
|
3407 |
-
|
3408 |
-
|
3409 |
-
|
3410 |
-
|
3411 |
-
|
3412 |
-
|
3413 |
-
|
3414 |
-
|
3415 |
-
|
3416 |
-
|
3417 |
-
|
3418 |
-
|
3419 |
-
|
3420 |
-
|
3421 |
-
|
3422 |
-
|
3423 |
-
|
3424 |
-
}
|
3425 |
-
|
3426 |
-
|
3427 |
-
|
3428 |
-
|
3429 |
-
|
3430 |
-
|
3431 |
-
|
3432 |
-
if (!
|
3433 |
-
|
3434 |
-
|
3435 |
-
|
3436 |
-
|
3437 |
-
|
3438 |
-
|
3439 |
-
|
3440 |
-
|
3441 |
-
|
3442 |
-
|
3443 |
-
|
3444 |
-
|
3445 |
-
|
3446 |
-
if (
|
3447 |
-
|
3448 |
-
|
3449 |
-
|
3450 |
-
|
3451 |
-
|
3452 |
-
|
3453 |
-
|
3454 |
-
|
3455 |
-
|
3456 |
-
|
3457 |
-
|
3458 |
-
|
3459 |
-
|
3460 |
-
|
3461 |
-
|
3462 |
-
|
3463 |
-
|
3464 |
-
|
3465 |
-
|
3466 |
-
|
3467 |
-
|
3468 |
-
|
3469 |
-
|
3470 |
-
|
3471 |
-
|
3472 |
-
|
3473 |
-
|
3474 |
-
|
3475 |
-
|
3476 |
-
|
3477 |
-
|
3478 |
-
|
3479 |
-
|
3480 |
-
|
3481 |
-
|
3482 |
-
|
3483 |
-
|
3484 |
-
|
3485 |
-
|
3486 |
-
|
3487 |
-
|
3488 |
-
|
3489 |
-
|
3490 |
-
|
3491 |
-
|
3492 |
-
|
3493 |
-
|
3494 |
-
|
3495 |
-
|
3496 |
-
|
3497 |
-
|
3498 |
-
|
3499 |
-
|
3500 |
-
|
3501 |
-
|
3502 |
-
|
3503 |
-
|
3504 |
-
|
3505 |
-
|
3506 |
-
|
3507 |
-
|
3508 |
-
|
3509 |
-
|
3510 |
-
|
3511 |
-
|
3512 |
-
|
3513 |
-
|
3514 |
-
|
3515 |
-
|
3516 |
-
|
3517 |
-
|
3518 |
-
|
3519 |
-
|
3520 |
-
|
3521 |
-
|
3522 |
-
|
3523 |
-
|
3524 |
-
|
3525 |
-
|
3526 |
-
|
3527 |
-
|
3528 |
-
|
3529 |
-
|
3530 |
-
|
3531 |
-
|
3532 |
-
|
3533 |
-
|
3534 |
-
|
3535 |
-
|
3536 |
-
|
3537 |
-
|
3538 |
-
|
3539 |
-
|
3540 |
-
|
3541 |
-
|
3542 |
-
|
3543 |
-
|
3544 |
-
|
3545 |
-
|
3546 |
-
|
3547 |
-
|
3548 |
-
|
3549 |
-
}
|
3550 |
-
|
3551 |
-
|
3552 |
-
|
3553 |
-
|
3554 |
-
|
3555 |
-
|
3556 |
-
|
3557 |
-
|
3558 |
-
|
3559 |
-
|
3560 |
-
|
3561 |
-
|
3562 |
-
|
3563 |
-
|
3564 |
-
|
3565 |
-
|
3566 |
-
|
3567 |
-
|
3568 |
-
|
3569 |
-
|
3570 |
-
|
3571 |
-
|
3572 |
-
|
3573 |
-
|
3574 |
-
|
3575 |
-
|
3576 |
-
|
3577 |
-
|
3578 |
-
|
3579 |
-
}
|
3580 |
-
|
3581 |
-
|
3582 |
-
|
3583 |
-
|
3584 |
-
|
3585 |
-
|
3586 |
-
|
3587 |
-
|
3588 |
-
|
3589 |
-
|
3590 |
-
|
3591 |
-
|
3592 |
-
|
3593 |
-
|
3594 |
-
|
3595 |
-
|
3596 |
-
|
3597 |
-
|
3598 |
-
|
3599 |
-
|
3600 |
-
if (
|
3601 |
-
|
3602 |
-
}
|
3603 |
-
|
3604 |
-
|
3605 |
-
|
3606 |
-
|
3607 |
-
|
3608 |
-
if (
|
3609 |
-
if (
|
3610 |
-
|
3611 |
-
|
3612 |
-
|
3613 |
-
|
3614 |
-
if (
|
3615 |
-
|
3616 |
-
|
3617 |
-
|
3618 |
-
|
3619 |
-
|
3620 |
-
|
3621 |
-
|
3622 |
-
|
3623 |
-
|
3624 |
-
|
3625 |
-
|
3626 |
-
|
3627 |
-
|
3628 |
-
function
|
3629 |
-
|
3630 |
-
|
3631 |
-
|
3632 |
-
|
3633 |
-
|
3634 |
-
var
|
3635 |
-
|
3636 |
-
|
3637 |
-
|
3638 |
-
|
3639 |
-
|
3640 |
-
|
3641 |
-
|
3642 |
-
|
3643 |
-
|
3644 |
-
|
3645 |
-
|
3646 |
-
|
3647 |
-
|
3648 |
-
|
3649 |
-
|
3650 |
-
|
3651 |
-
|
3652 |
-
|
3653 |
-
|
3654 |
-
|
3655 |
-
|
3656 |
-
|
3657 |
-
|
3658 |
-
|
3659 |
-
|
3660 |
-
|
3661 |
-
|
3662 |
-
|
3663 |
-
|
3664 |
-
|
3665 |
-
|
3666 |
-
|
3667 |
-
|
3668 |
-
|
3669 |
-
|
3670 |
-
|
3671 |
-
|
3672 |
-
|
3673 |
-
|
3674 |
-
|
3675 |
-
|
3676 |
-
|
3677 |
-
|
3678 |
-
|
3679 |
-
|
3680 |
-
|
3681 |
-
|
3682 |
-
|
3683 |
-
|
3684 |
-
|
3685 |
-
|
3686 |
-
|
3687 |
-
|
3688 |
-
|
3689 |
-
|
3690 |
-
|
3691 |
-
|
3692 |
-
|
3693 |
-
|
3694 |
-
|
3695 |
-
|
3696 |
-
}
|
3697 |
-
|
3698 |
-
|
3699 |
-
|
3700 |
-
|
3701 |
-
|
3702 |
-
|
3703 |
-
|
3704 |
-
|
3705 |
-
|
3706 |
-
|
3707 |
-
|
3708 |
-
|
3709 |
-
|
3710 |
-
|
3711 |
-
|
3712 |
-
|
3713 |
-
|
3714 |
-
|
3715 |
-
|
3716 |
-
|
3717 |
-
|
3718 |
-
|
3719 |
-
|
3720 |
-
|
3721 |
-
|
3722 |
-
|
3723 |
-
|
3724 |
-
|
3725 |
-
|
3726 |
-
|
3727 |
-
|
3728 |
-
|
3729 |
-
|
3730 |
-
|
3731 |
-
|
3732 |
-
|
3733 |
-
|
3734 |
-
|
3735 |
-
|
3736 |
-
|
3737 |
-
|
3738 |
-
|
3739 |
-
|
3740 |
-
var
|
3741 |
-
|
3742 |
-
|
3743 |
-
|
3744 |
-
|
3745 |
-
|
3746 |
-
|
3747 |
-
|
3748 |
-
|
3749 |
-
|
3750 |
-
|
3751 |
-
|
3752 |
-
|
3753 |
-
|
3754 |
-
|
3755 |
-
|
3756 |
-
|
3757 |
-
|
3758 |
-
|
3759 |
-
|
3760 |
-
|
3761 |
-
|
3762 |
-
|
3763 |
-
|
3764 |
-
|
3765 |
-
|
3766 |
-
|
3767 |
-
|
3768 |
-
|
3769 |
-
|
3770 |
-
|
3771 |
-
|
3772 |
-
|
3773 |
-
|
3774 |
-
|
3775 |
-
|
3776 |
-
|
3777 |
-
|
3778 |
-
|
3779 |
-
|
3780 |
-
|
3781 |
-
|
3782 |
-
|
3783 |
-
|
3784 |
-
|
3785 |
-
|
3786 |
-
|
3787 |
-
|
3788 |
-
|
3789 |
-
|
3790 |
-
|
3791 |
-
|
3792 |
-
|
3793 |
-
|
3794 |
-
|
3795 |
-
|
3796 |
-
|
3797 |
-
|
3798 |
-
|
3799 |
-
|
3800 |
-
|
3801 |
-
|
3802 |
-
|
3803 |
-
|
3804 |
-
|
3805 |
-
|
3806 |
-
|
3807 |
-
|
3808 |
-
|
3809 |
-
|
3810 |
-
|
3811 |
-
|
3812 |
-
|
3813 |
-
|
3814 |
-
if (
|
3815 |
-
|
3816 |
-
|
3817 |
-
|
3818 |
-
|
3819 |
-
|
3820 |
-
|
3821 |
-
|
3822 |
-
|
3823 |
-
|
3824 |
-
|
3825 |
-
|
3826 |
-
|
3827 |
-
|
3828 |
-
|
3829 |
-
|
3830 |
-
|
3831 |
-
|
3832 |
-
|
3833 |
-
|
3834 |
-
|
3835 |
-
|
3836 |
-
if (
|
3837 |
-
if (
|
3838 |
-
|
3839 |
-
|
3840 |
-
|
3841 |
-
|
3842 |
-
|
3843 |
-
|
3844 |
-
|
3845 |
-
|
3846 |
-
|
3847 |
-
|
3848 |
-
|
3849 |
-
|
3850 |
-
|
3851 |
-
|
3852 |
-
if (
|
3853 |
-
|
3854 |
-
|
3855 |
-
|
3856 |
-
|
3857 |
-
|
3858 |
-
|
3859 |
-
|
3860 |
-
|
3861 |
-
|
3862 |
-
|
3863 |
-
|
3864 |
-
|
3865 |
-
|
3866 |
-
|
3867 |
-
|
3868 |
-
|
3869 |
-
|
3870 |
-
|
3871 |
-
|
3872 |
-
|
3873 |
-
|
3874 |
-
|
3875 |
-
|
3876 |
-
|
3877 |
-
|
3878 |
-
|
3879 |
-
|
3880 |
-
|
3881 |
-
|
3882 |
-
|
3883 |
-
|
3884 |
-
|
3885 |
-
|
3886 |
-
|
3887 |
-
|
3888 |
-
|
3889 |
-
|
3890 |
-
|
3891 |
-
|
3892 |
-
|
3893 |
-
|
3894 |
-
|
3895 |
-
|
3896 |
-
|
3897 |
-
|
3898 |
-
|
3899 |
-
|
3900 |
-
|
3901 |
-
|
3902 |
-
|
3903 |
-
if (
|
3904 |
-
|
3905 |
-
|
3906 |
-
|
3907 |
-
|
3908 |
-
|
3909 |
-
|
3910 |
-
|
3911 |
-
|
3912 |
-
|
3913 |
-
|
3914 |
-
|
3915 |
-
|
3916 |
-
|
3917 |
-
|
3918 |
-
|
3919 |
-
|
3920 |
-
|
3921 |
-
|
3922 |
-
|
3923 |
-
|
3924 |
-
|
3925 |
-
|
3926 |
-
|
3927 |
-
|
3928 |
-
|
3929 |
-
|
3930 |
-
|
3931 |
-
|
3932 |
-
|
3933 |
-
|
3934 |
-
|
3935 |
-
|
3936 |
-
|
3937 |
-
|
3938 |
-
|
3939 |
-
|
3940 |
-
|
3941 |
-
|
3942 |
-
|
3943 |
-
|
3944 |
-
|
3945 |
-
|
3946 |
-
|
3947 |
-
|
3948 |
-
|
3949 |
-
|
3950 |
-
|
3951 |
-
|
3952 |
-
|
3953 |
-
|
3954 |
-
|
3955 |
-
|
3956 |
-
|
3957 |
-
|
3958 |
-
|
3959 |
-
|
3960 |
-
|
3961 |
-
|
3962 |
-
|
3963 |
-
|
3964 |
-
|
3965 |
-
|
3966 |
-
|
3967 |
-
|
3968 |
-
|
3969 |
-
|
3970 |
-
|
3971 |
-
if (
|
3972 |
-
|
3973 |
-
|
3974 |
-
|
3975 |
-
|
3976 |
-
|
3977 |
-
|
3978 |
-
if (
|
3979 |
-
|
3980 |
-
|
3981 |
-
|
3982 |
-
|
3983 |
-
|
3984 |
-
|
3985 |
-
|
3986 |
-
|
3987 |
-
|
3988 |
-
|
3989 |
-
|
3990 |
-
|
3991 |
-
|
3992 |
-
|
3993 |
-
|
3994 |
-
|
3995 |
-
|
3996 |
-
|
3997 |
-
}
|
3998 |
-
|
3999 |
-
|
4000 |
-
|
4001 |
-
|
4002 |
-
|
4003 |
-
|
4004 |
-
|
4005 |
-
var
|
4006 |
-
|
4007 |
-
|
4008 |
-
|
4009 |
-
|
4010 |
-
|
4011 |
-
|
4012 |
-
|
4013 |
-
|
4014 |
-
|
4015 |
-
|
4016 |
-
|
4017 |
-
|
4018 |
-
|
4019 |
-
|
4020 |
-
|
4021 |
-
var
|
4022 |
-
|
4023 |
-
|
4024 |
-
|
4025 |
-
|
4026 |
-
|
4027 |
-
|
4028 |
-
|
4029 |
-
|
4030 |
-
|
4031 |
-
|
4032 |
-
|
4033 |
-
|
4034 |
-
|
4035 |
-
|
4036 |
-
|
4037 |
-
|
4038 |
-
|
4039 |
-
|
4040 |
-
|
4041 |
-
|
4042 |
-
|
4043 |
-
|
4044 |
-
|
4045 |
-
|
4046 |
-
|
4047 |
-
|
4048 |
-
|
4049 |
-
|
4050 |
-
|
4051 |
-
|
4052 |
-
|
4053 |
-
|
4054 |
-
|
4055 |
-
|
4056 |
-
|
4057 |
-
|
4058 |
-
|
4059 |
-
|
4060 |
-
|
4061 |
-
|
4062 |
-
|
4063 |
-
|
4064 |
-
var
|
4065 |
-
|
4066 |
-
|
4067 |
-
|
4068 |
-
|
4069 |
-
|
4070 |
-
|
4071 |
-
|
4072 |
-
|
4073 |
-
|
4074 |
-
|
4075 |
-
|
4076 |
-
|
4077 |
-
|
4078 |
-
|
4079 |
-
|
4080 |
-
|
4081 |
-
|
4082 |
-
|
4083 |
-
|
4084 |
-
|
4085 |
-
|
4086 |
-
|
4087 |
-
|
4088 |
-
|
4089 |
-
|
4090 |
-
|
4091 |
-
|
4092 |
-
|
4093 |
-
|
4094 |
-
|
4095 |
-
|
4096 |
-
|
4097 |
-
|
4098 |
-
|
4099 |
-
|
4100 |
-
|
4101 |
-
|
4102 |
-
|
4103 |
-
|
4104 |
-
|
4105 |
-
|
4106 |
-
|
4107 |
-
|
4108 |
-
|
4109 |
-
|
4110 |
-
|
4111 |
-
|
4112 |
-
|
4113 |
-
|
4114 |
-
|
4115 |
-
|
4116 |
-
|
4117 |
-
|
4118 |
-
|
4119 |
-
|
4120 |
-
|
4121 |
-
|
4122 |
-
|
4123 |
-
|
4124 |
-
|
4125 |
-
|
4126 |
-
|
4127 |
-
|
4128 |
-
|
4129 |
-
|
4130 |
-
|
4131 |
-
|
4132 |
-
|
4133 |
-
|
4134 |
-
|
4135 |
-
|
4136 |
-
|
4137 |
-
|
4138 |
-
|
4139 |
-
|
4140 |
-
|
4141 |
-
|
4142 |
-
|
4143 |
-
|
4144 |
-
|
4145 |
-
|
4146 |
-
|
4147 |
-
|
4148 |
-
|
4149 |
-
|
4150 |
-
|
4151 |
-
|
4152 |
-
|
4153 |
-
|
4154 |
-
|
4155 |
-
|
4156 |
-
|
4157 |
-
|
4158 |
-
|
4159 |
-
|
4160 |
-
|
4161 |
-
|
4162 |
-
|
4163 |
-
|
4164 |
-
|
4165 |
-
|
4166 |
-
}
|
4167 |
-
|
4168 |
-
|
4169 |
-
|
4170 |
-
|
4171 |
-
|
4172 |
-
|
4173 |
-
|
4174 |
-
}
|
4175 |
-
|
4176 |
-
|
4177 |
-
|
4178 |
-
|
4179 |
-
|
4180 |
-
|
4181 |
-
|
4182 |
-
|
4183 |
-
|
4184 |
-
|
4185 |
-
|
4186 |
-
|
4187 |
-
|
4188 |
-
|
4189 |
-
|
4190 |
-
|
4191 |
-
|
4192 |
-
|
4193 |
-
|
4194 |
-
|
4195 |
-
|
4196 |
-
this
|
4197 |
-
|
4198 |
-
|
4199 |
-
|
4200 |
-
|
4201 |
-
|
4202 |
-
|
4203 |
-
|
4204 |
-
|
4205 |
-
|
4206 |
-
|
4207 |
-
|
4208 |
-
|
4209 |
-
|
4210 |
-
|
4211 |
-
|
4212 |
-
|
4213 |
-
|
4214 |
-
|
4215 |
-
|
4216 |
-
|
4217 |
-
|
4218 |
-
|
4219 |
-
|
4220 |
-
|
4221 |
-
|
4222 |
-
|
4223 |
-
|
4224 |
-
|
4225 |
-
|
4226 |
-
|
4227 |
-
|
4228 |
-
|
4229 |
-
|
4230 |
-
|
4231 |
-
|
4232 |
-
|
4233 |
-
|
4234 |
-
|
4235 |
-
|
4236 |
-
|
4237 |
-
|
4238 |
-
|
4239 |
-
|
4240 |
-
|
4241 |
-
|
4242 |
-
|
4243 |
-
|
4244 |
-
|
4245 |
-
|
4246 |
-
|
4247 |
-
|
4248 |
-
|
4249 |
-
|
4250 |
-
|
4251 |
-
|
4252 |
-
|
4253 |
-
|
4254 |
-
|
4255 |
-
|
4256 |
-
|
4257 |
-
|
4258 |
-
|
4259 |
-
|
4260 |
-
|
4261 |
-
|
4262 |
-
|
4263 |
-
|
4264 |
-
|
4265 |
-
|
4266 |
-
|
4267 |
-
|
4268 |
-
|
4269 |
-
|
4270 |
-
|
4271 |
-
|
4272 |
-
|
4273 |
-
|
4274 |
-
|
4275 |
-
|
4276 |
-
|
4277 |
-
|
4278 |
-
|
4279 |
-
|
4280 |
-
|
4281 |
-
|
4282 |
-
|
4283 |
-
|
4284 |
-
|
4285 |
-
|
4286 |
-
|
4287 |
-
|
4288 |
-
|
4289 |
-
|
4290 |
-
|
4291 |
-
|
4292 |
-
|
4293 |
-
|
4294 |
-
|
4295 |
-
|
4296 |
-
|
4297 |
-
|
4298 |
-
|
4299 |
-
|
4300 |
-
}
|
4301 |
-
|
4302 |
-
|
4303 |
-
|
4304 |
-
|
4305 |
-
|
4306 |
-
|
4307 |
-
|
4308 |
-
|
4309 |
-
|
4310 |
-
|
4311 |
-
|
4312 |
-
}
|
4313 |
-
|
4314 |
-
|
4315 |
-
|
4316 |
-
|
4317 |
-
|
4318 |
-
|
4319 |
-
|
4320 |
-
|
4321 |
-
|
4322 |
-
},
|
4323 |
-
|
4324 |
-
|
4325 |
-
|
4326 |
-
|
4327 |
-
|
4328 |
-
|
4329 |
-
|
4330 |
-
|
4331 |
-
|
4332 |
-
|
4333 |
-
|
4334 |
-
|
4335 |
-
|
4336 |
-
|
4337 |
-
|
4338 |
-
|
4339 |
-
|
4340 |
-
|
4341 |
-
|
4342 |
-
|
4343 |
-
|
4344 |
-
|
4345 |
-
|
4346 |
-
|
4347 |
-
|
4348 |
-
|
4349 |
-
|
4350 |
-
|
4351 |
-
|
4352 |
-
|
4353 |
-
|
4354 |
-
|
4355 |
-
|
4356 |
-
|
4357 |
-
|
4358 |
-
|
4359 |
-
|
4360 |
-
|
4361 |
-
|
4362 |
-
|
4363 |
-
|
4364 |
-
|
4365 |
-
|
4366 |
-
|
4367 |
-
|
4368 |
-
|
4369 |
-
|
4370 |
-
|
4371 |
-
|
4372 |
-
|
4373 |
-
|
4374 |
-
|
4375 |
-
|
4376 |
-
|
4377 |
-
|
4378 |
-
|
4379 |
-
|
4380 |
-
|
4381 |
-
|
4382 |
-
|
4383 |
-
|
4384 |
-
|
4385 |
-
|
4386 |
-
|
4387 |
-
|
4388 |
-
|
4389 |
-
|
4390 |
-
|
4391 |
-
|
4392 |
-
|
4393 |
-
|
4394 |
-
|
4395 |
-
|
4396 |
-
|
4397 |
-
|
4398 |
-
|
4399 |
-
|
4400 |
-
|
4401 |
-
|
4402 |
-
|
4403 |
-
|
4404 |
-
|
4405 |
-
var
|
4406 |
-
|
4407 |
-
|
4408 |
-
|
4409 |
-
|
4410 |
-
|
4411 |
-
|
4412 |
-
|
4413 |
-
|
4414 |
-
|
4415 |
-
|
4416 |
-
|
4417 |
-
|
4418 |
-
|
4419 |
-
|
4420 |
-
|
4421 |
-
|
4422 |
-
|
4423 |
-
var
|
4424 |
-
if (
|
4425 |
-
|
4426 |
-
|
4427 |
-
|
4428 |
-
|
4429 |
-
|
4430 |
-
|
4431 |
-
}
|
4432 |
-
|
4433 |
-
|
4434 |
-
|
4435 |
-
|
4436 |
-
|
4437 |
-
|
4438 |
-
|
4439 |
-
|
4440 |
-
|
4441 |
-
|
4442 |
-
|
4443 |
-
|
4444 |
-
|
4445 |
-
|
4446 |
-
|
4447 |
-
|
4448 |
-
|
4449 |
-
|
4450 |
-
|
4451 |
-
|
4452 |
-
|
4453 |
-
|
4454 |
-
|
4455 |
-
|
4456 |
-
|
4457 |
-
|
4458 |
-
|
4459 |
-
|
4460 |
-
|
4461 |
-
|
4462 |
-
|
4463 |
-
|
4464 |
-
|
4465 |
-
|
4466 |
-
|
4467 |
-
|
4468 |
-
|
4469 |
-
|
4470 |
-
|
4471 |
-
|
4472 |
-
|
4473 |
-
|
4474 |
-
|
4475 |
-
|
4476 |
-
|
4477 |
-
|
4478 |
-
|
4479 |
-
|
4480 |
-
|
4481 |
-
|
4482 |
-
|
4483 |
-
|
4484 |
-
|
4485 |
-
|
4486 |
-
|
4487 |
-
|
4488 |
-
|
4489 |
-
|
4490 |
-
|
4491 |
-
|
4492 |
-
|
4493 |
-
|
4494 |
-
|
4495 |
-
|
4496 |
-
|
4497 |
-
|
4498 |
-
|
4499 |
-
|
4500 |
-
|
4501 |
-
|
4502 |
-
|
4503 |
-
|
4504 |
-
|
4505 |
-
|
4506 |
-
|
4507 |
-
|
4508 |
-
|
4509 |
-
|
4510 |
-
|
4511 |
-
|
4512 |
-
|
4513 |
-
|
4514 |
-
|
4515 |
-
|
4516 |
-
|
4517 |
-
|
4518 |
-
|
4519 |
-
|
4520 |
-
|
4521 |
-
|
4522 |
-
|
4523 |
-
|
4524 |
-
|
4525 |
-
|
4526 |
-
|
4527 |
-
|
4528 |
-
|
4529 |
-
|
4530 |
-
|
4531 |
-
|
4532 |
-
|
4533 |
-
|
4534 |
-
|
4535 |
-
|
4536 |
-
|
4537 |
-
|
4538 |
-
|
4539 |
-
|
4540 |
-
|
4541 |
-
|
4542 |
-
|
4543 |
-
|
4544 |
-
|
4545 |
-
|
4546 |
-
|
4547 |
-
|
4548 |
-
|
4549 |
-
|
4550 |
-
|
4551 |
-
|
4552 |
-
|
4553 |
-
|
4554 |
-
|
4555 |
-
|
4556 |
-
|
4557 |
-
|
4558 |
-
|
4559 |
-
|
4560 |
-
|
4561 |
-
|
4562 |
-
|
4563 |
-
|
4564 |
-
|
4565 |
-
|
4566 |
-
|
4567 |
-
|
4568 |
-
|
4569 |
-
|
4570 |
-
|
4571 |
-
|
4572 |
-
|
4573 |
-
|
4574 |
-
|
4575 |
-
|
4576 |
-
|
4577 |
-
|
4578 |
-
|
4579 |
-
|
4580 |
-
|
4581 |
-
|
4582 |
-
|
4583 |
-
|
4584 |
-
|
4585 |
-
|
4586 |
-
|
4587 |
-
|
4588 |
-
|
4589 |
-
|
4590 |
-
|
4591 |
-
|
4592 |
-
|
4593 |
-
|
4594 |
-
|
4595 |
-
|
4596 |
-
|
4597 |
-
|
4598 |
-
|
4599 |
-
|
4600 |
-
|
4601 |
-
|
4602 |
-
|
4603 |
-
|
4604 |
-
|
4605 |
-
|
4606 |
-
|
4607 |
-
|
4608 |
-
|
4609 |
-
|
4610 |
-
|
4611 |
-
|
4612 |
-
|
4613 |
-
|
4614 |
-
|
4615 |
-
|
4616 |
-
|
4617 |
-
|
4618 |
-
|
4619 |
-
|
4620 |
-
|
4621 |
-
|
4622 |
-
|
4623 |
-
|
4624 |
-
|
4625 |
-
|
4626 |
-
|
4627 |
-
|
4628 |
-
|
4629 |
-
|
4630 |
-
|
4631 |
-
|
4632 |
-
|
4633 |
-
|
4634 |
-
|
4635 |
-
|
4636 |
-
|
4637 |
-
|
4638 |
-
|
4639 |
-
|
4640 |
-
|
4641 |
-
|
4642 |
-
|
4643 |
-
|
4644 |
-
|
4645 |
-
|
4646 |
-
|
4647 |
-
|
4648 |
-
|
4649 |
-
|
4650 |
-
|
4651 |
-
|
4652 |
-
|
4653 |
-
|
4654 |
-
|
4655 |
-
}
|
4656 |
-
|
4657 |
-
function
|
4658 |
-
|
4659 |
-
|
4660 |
-
|
4661 |
-
|
4662 |
-
|
4663 |
-
|
4664 |
-
|
4665 |
-
|
4666 |
-
|
4667 |
-
|
4668 |
-
|
4669 |
-
|
4670 |
-
|
4671 |
-
|
4672 |
-
|
4673 |
-
|
4674 |
-
|
4675 |
-
|
4676 |
-
|
4677 |
-
|
4678 |
-
|
4679 |
-
|
4680 |
-
|
4681 |
-
|
4682 |
-
|
4683 |
-
|
4684 |
-
|
4685 |
-
|
4686 |
-
|
4687 |
-
|
4688 |
-
|
4689 |
-
|
4690 |
-
};
|
4691 |
-
|
4692 |
-
function
|
4693 |
-
|
4694 |
-
|
4695 |
-
|
4696 |
-
|
4697 |
-
|
4698 |
-
|
4699 |
-
|
4700 |
-
|
4701 |
-
|
4702 |
-
|
4703 |
-
|
4704 |
-
|
4705 |
-
|
4706 |
-
|
4707 |
-
|
4708 |
-
|
4709 |
-
|
4710 |
-
|
4711 |
-
|
4712 |
-
|
4713 |
-
|
4714 |
-
|
4715 |
-
|
4716 |
-
|
4717 |
-
|
4718 |
-
|
4719 |
-
|
4720 |
-
|
4721 |
-
|
4722 |
-
|
4723 |
-
|
4724 |
-
|
4725 |
-
|
4726 |
-
}
|
4727 |
-
|
4728 |
-
|
4729 |
-
}
|
4730 |
-
|
4731 |
-
|
4732 |
-
|
4733 |
-
|
4734 |
-
|
4735 |
-
|
4736 |
-
|
4737 |
-
|
4738 |
-
|
4739 |
-
|
4740 |
-
|
4741 |
-
|
4742 |
-
|
4743 |
-
|
4744 |
-
|
4745 |
-
|
4746 |
-
|
4747 |
-
|
4748 |
-
|
4749 |
-
|
4750 |
-
|
4751 |
-
|
4752 |
-
|
4753 |
-
|
4754 |
-
|
4755 |
-
|
4756 |
-
|
4757 |
-
|
4758 |
-
|
4759 |
-
|
4760 |
-
|
4761 |
-
|
4762 |
-
|
4763 |
-
|
4764 |
-
|
4765 |
-
|
4766 |
-
|
4767 |
-
|
4768 |
-
|
4769 |
-
|
4770 |
-
|
4771 |
-
|
4772 |
-
|
4773 |
-
|
4774 |
-
|
4775 |
-
|
4776 |
-
|
4777 |
-
|
4778 |
-
|
4779 |
-
|
4780 |
-
|
4781 |
-
|
4782 |
-
|
4783 |
-
|
4784 |
-
|
4785 |
-
|
4786 |
-
|
4787 |
-
|
4788 |
-
|
4789 |
-
|
4790 |
-
|
4791 |
-
|
4792 |
-
|
4793 |
-
|
4794 |
-
|
4795 |
-
|
4796 |
-
|
4797 |
-
|
4798 |
-
|
4799 |
-
|
4800 |
-
|
4801 |
-
|
4802 |
-
|
4803 |
-
|
4804 |
-
|
4805 |
-
|
4806 |
-
|
4807 |
-
|
4808 |
-
|
4809 |
-
|
4810 |
-
|
4811 |
-
|
4812 |
-
|
4813 |
-
|
4814 |
-
|
4815 |
-
|
4816 |
-
|
4817 |
-
|
4818 |
-
|
4819 |
-
|
4820 |
-
|
4821 |
-
|
4822 |
-
|
4823 |
-
|
4824 |
-
|
4825 |
-
|
4826 |
-
|
4827 |
-
|
4828 |
-
|
4829 |
-
|
4830 |
-
|
4831 |
-
},
|
4832 |
-
|
4833 |
-
|
4834 |
-
|
4835 |
-
|
4836 |
-
|
4837 |
-
|
4838 |
-
|
4839 |
-
|
4840 |
-
|
4841 |
-
|
4842 |
-
|
4843 |
-
|
4844 |
-
|
4845 |
-
|
4846 |
-
|
4847 |
-
},
|
4848 |
-
|
4849 |
-
|
4850 |
-
|
4851 |
-
|
4852 |
-
|
4853 |
-
|
4854 |
-
|
4855 |
-
|
4856 |
-
|
4857 |
-
|
4858 |
-
|
4859 |
-
|
4860 |
-
|
4861 |
-
|
4862 |
-
|
4863 |
-
|
4864 |
-
|
4865 |
-
|
4866 |
-
|
4867 |
-
|
4868 |
-
|
4869 |
-
|
4870 |
-
|
4871 |
-
|
4872 |
-
|
4873 |
-
|
4874 |
-
},
|
4875 |
-
|
4876 |
-
|
4877 |
-
|
4878 |
-
|
4879 |
-
|
4880 |
-
|
4881 |
-
|
4882 |
-
|
4883 |
-
|
4884 |
-
|
4885 |
-
|
4886 |
-
|
4887 |
-
}
|
4888 |
-
|
4889 |
-
|
4890 |
-
|
4891 |
-
|
4892 |
-
|
4893 |
-
|
4894 |
-
|
4895 |
-
|
4896 |
-
|
4897 |
-
|
4898 |
-
|
4899 |
-
|
4900 |
-
|
4901 |
-
|
4902 |
-
|
4903 |
-
|
4904 |
-
|
4905 |
-
|
4906 |
-
|
4907 |
-
|
4908 |
-
|
4909 |
-
|
4910 |
-
|
4911 |
-
|
4912 |
-
|
4913 |
-
},
|
4914 |
-
|
4915 |
-
|
4916 |
-
|
4917 |
-
|
4918 |
-
},
|
4919 |
-
|
4920 |
-
|
4921 |
-
|
4922 |
-
|
4923 |
-
},
|
4924 |
-
|
4925 |
-
|
4926 |
-
|
4927 |
-
},
|
4928 |
-
|
4929 |
-
|
4930 |
-
|
4931 |
-
|
4932 |
-
|
4933 |
-
},
|
4934 |
-
|
4935 |
-
|
4936 |
-
var
|
4937 |
-
|
4938 |
-
var
|
4939 |
-
|
4940 |
-
|
4941 |
-
|
4942 |
-
|
4943 |
-
|
4944 |
-
|
4945 |
-
|
4946 |
-
|
4947 |
-
|
4948 |
-
|
4949 |
-
|
4950 |
-
|
4951 |
-
|
4952 |
-
|
4953 |
-
|
4954 |
-
|
4955 |
-
|
4956 |
-
|
4957 |
-
|
4958 |
-
|
4959 |
-
|
4960 |
-
|
4961 |
-
|
4962 |
-
|
4963 |
-
|
4964 |
-
|
4965 |
-
|
4966 |
-
|
4967 |
-
|
4968 |
-
|
4969 |
-
|
4970 |
-
|
4971 |
-
|
4972 |
-
|
4973 |
-
|
4974 |
-
|
4975 |
-
|
4976 |
-
|
4977 |
-
|
4978 |
-
|
4979 |
-
|
4980 |
-
|
4981 |
-
|
4982 |
-
|
4983 |
-
|
4984 |
-
|
4985 |
-
|
4986 |
-
|
4987 |
-
|
4988 |
-
|
4989 |
-
|
4990 |
-
|
4991 |
-
|
4992 |
-
|
4993 |
-
|
4994 |
-
|
4995 |
-
|
4996 |
-
|
4997 |
-
|
4998 |
-
|
4999 |
-
|
5000 |
-
|
5001 |
-
|
5002 |
-
|
5003 |
-
|
5004 |
-
|
5005 |
-
|
5006 |
-
|
5007 |
-
|
5008 |
-
|
5009 |
-
|
5010 |
-
|
5011 |
-
|
5012 |
-
|
5013 |
-
|
5014 |
-
|
5015 |
-
|
5016 |
-
|
5017 |
-
|
5018 |
-
|
5019 |
-
|
5020 |
-
|
5021 |
-
|
5022 |
-
|
5023 |
-
|
5024 |
-
|
5025 |
-
|
5026 |
-
|
5027 |
-
|
5028 |
-
|
5029 |
-
|
5030 |
-
|
5031 |
-
|
5032 |
-
|
5033 |
-
|
5034 |
-
|
5035 |
-
|
5036 |
-
|
5037 |
-
|
5038 |
-
|
5039 |
-
|
5040 |
-
|
5041 |
-
|
5042 |
-
|
5043 |
-
|
5044 |
-
|
5045 |
-
|
5046 |
-
|
5047 |
-
|
5048 |
-
|
5049 |
-
|
5050 |
-
|
5051 |
-
|
5052 |
-
|
5053 |
-
|
5054 |
-
|
5055 |
-
|
5056 |
-
|
5057 |
-
|
5058 |
-
|
5059 |
-
|
5060 |
-
|
5061 |
-
|
5062 |
-
|
5063 |
-
|
5064 |
-
|
5065 |
-
|
5066 |
-
|
5067 |
-
|
5068 |
-
|
5069 |
-
|
5070 |
-
|
5071 |
-
|
5072 |
-
|
5073 |
-
|
5074 |
-
|
5075 |
-
|
5076 |
-
|
5077 |
-
|
5078 |
-
|
5079 |
-
|
5080 |
-
|
5081 |
-
|
5082 |
-
|
5083 |
-
|
5084 |
-
|
5085 |
-
|
5086 |
-
return
|
5087 |
-
|
5088 |
-
|
5089 |
-
|
5090 |
-
|
5091 |
-
|
5092 |
-
|
5093 |
-
|
5094 |
-
|
5095 |
-
|
5096 |
-
|
5097 |
-
|
5098 |
-
|
5099 |
-
|
5100 |
-
|
5101 |
-
|
5102 |
-
|
5103 |
-
|
5104 |
-
|
5105 |
-
|
5106 |
-
function
|
5107 |
-
|
5108 |
-
|
5109 |
-
|
5110 |
-
|
5111 |
-
|
5112 |
-
|
5113 |
-
|
5114 |
-
|
5115 |
-
|
5116 |
-
|
5117 |
-
|
5118 |
-
|
5119 |
-
|
5120 |
-
|
5121 |
-
|
5122 |
-
|
5123 |
-
|
5124 |
-
|
5125 |
-
|
5126 |
-
|
5127 |
-
|
5128 |
-
|
5129 |
-
|
5130 |
-
|
5131 |
-
|
5132 |
-
|
5133 |
-
|
5134 |
-
|
5135 |
-
|
5136 |
-
|
5137 |
-
|
5138 |
-
|
5139 |
-
|
5140 |
-
|
5141 |
-
|
5142 |
-
|
5143 |
-
|
5144 |
-
|
5145 |
-
|
5146 |
-
|
5147 |
-
|
5148 |
-
|
5149 |
-
|
5150 |
-
|
5151 |
-
|
5152 |
-
|
5153 |
-
|
5154 |
-
|
5155 |
-
|
5156 |
-
|
5157 |
-
|
5158 |
-
|
5159 |
-
|
5160 |
-
|
5161 |
-
|
5162 |
-
|
5163 |
-
|
5164 |
-
|
5165 |
-
|
5166 |
-
|
5167 |
-
|
5168 |
-
|
5169 |
-
|
5170 |
-
|
5171 |
-
|
5172 |
-
|
5173 |
-
}
|
5174 |
-
|
5175 |
-
|
5176 |
-
|
5177 |
-
|
5178 |
-
|
5179 |
-
|
5180 |
-
|
5181 |
-
|
5182 |
-
|
5183 |
-
|
5184 |
-
|
5185 |
-
|
5186 |
-
|
5187 |
-
|
5188 |
-
|
5189 |
-
|
5190 |
-
|
5191 |
-
|
5192 |
-
|
5193 |
-
|
5194 |
-
|
5195 |
-
|
5196 |
-
|
5197 |
-
|
5198 |
-
|
5199 |
-
|
5200 |
-
|
5201 |
-
|
5202 |
-
|
5203 |
-
|
5204 |
-
|
5205 |
-
|
5206 |
-
|
5207 |
-
|
5208 |
-
|
5209 |
-
|
5210 |
-
|
5211 |
-
|
5212 |
-
|
5213 |
-
|
5214 |
-
|
5215 |
-
|
5216 |
-
|
5217 |
-
|
5218 |
-
|
5219 |
-
|
5220 |
-
|
5221 |
-
|
5222 |
-
|
5223 |
-
|
5224 |
-
|
5225 |
-
|
5226 |
-
|
5227 |
-
|
5228 |
-
|
5229 |
-
|
5230 |
-
|
5231 |
-
|
5232 |
-
|
5233 |
-
|
5234 |
-
|
5235 |
-
|
5236 |
-
|
5237 |
-
|
5238 |
-
|
5239 |
-
|
5240 |
-
|
5241 |
-
|
5242 |
-
|
5243 |
-
|
5244 |
-
|
5245 |
-
|
5246 |
-
|
5247 |
-
|
5248 |
-
|
5249 |
-
|
5250 |
-
|
5251 |
-
|
5252 |
-
|
5253 |
-
|
5254 |
-
|
5255 |
-
|
5256 |
-
|
5257 |
-
|
5258 |
-
//
|
5259 |
-
|
5260 |
-
|
5261 |
-
|
5262 |
-
|
5263 |
-
|
5264 |
-
|
5265 |
-
|
5266 |
-
|
5267 |
-
|
5268 |
-
|
5269 |
-
|
5270 |
-
|
5271 |
-
//
|
5272 |
-
|
5273 |
-
|
5274 |
-
|
5275 |
-
|
5276 |
-
|
5277 |
-
|
5278 |
-
|
5279 |
-
|
5280 |
-
|
5281 |
-
|
5282 |
-
|
5283 |
-
|
5284 |
-
|
5285 |
-
|
5286 |
-
|
5287 |
-
|
5288 |
-
|
5289 |
-
|
5290 |
-
if (!
|
5291 |
-
|
5292 |
-
|
5293 |
-
|
5294 |
-
|
5295 |
-
if (
|
5296 |
-
|
5297 |
-
|
5298 |
-
|
5299 |
-
|
5300 |
-
|
5301 |
-
|
5302 |
-
|
5303 |
-
|
5304 |
-
|
5305 |
-
|
5306 |
-
|
5307 |
-
|
5308 |
-
|
5309 |
-
|
5310 |
-
|
5311 |
-
|
5312 |
-
|
5313 |
-
|
5314 |
-
//
|
5315 |
-
|
5316 |
-
|
5317 |
-
|
5318 |
-
|
5319 |
-
|
5320 |
-
|
5321 |
-
|
5322 |
-
|
5323 |
-
|
5324 |
-
|
5325 |
-
|
5326 |
-
|
5327 |
-
|
5328 |
-
|
5329 |
-
|
5330 |
-
|
5331 |
-
|
5332 |
-
|
5333 |
-
|
5334 |
-
|
5335 |
-
|
5336 |
-
|
5337 |
-
|
5338 |
-
|
5339 |
-
|
5340 |
-
|
5341 |
-
|
5342 |
-
|
5343 |
-
|
5344 |
-
|
5345 |
-
|
5346 |
-
|
5347 |
-
|
5348 |
-
|
5349 |
-
|
5350 |
-
|
5351 |
-
|
5352 |
-
|
5353 |
-
|
5354 |
-
|
5355 |
-
|
5356 |
-
|
5357 |
-
|
5358 |
-
|
5359 |
-
|
5360 |
-
|
5361 |
-
|
5362 |
-
|
5363 |
-
|
5364 |
-
|
5365 |
-
|
5366 |
-
|
5367 |
-
|
5368 |
-
|
5369 |
-
|
5370 |
-
|
5371 |
-
|
5372 |
-
|
5373 |
-
|
5374 |
-
|
5375 |
-
|
5376 |
-
|
5377 |
-
|
5378 |
-
|
5379 |
-
|
5380 |
-
|
5381 |
-
|
5382 |
-
|
5383 |
-
|
5384 |
-
|
5385 |
-
|
5386 |
-
|
5387 |
-
|
5388 |
-
|
5389 |
-
|
5390 |
-
|
5391 |
-
|
5392 |
-
|
5393 |
-
|
5394 |
-
|
5395 |
-
|
5396 |
-
|
5397 |
-
|
5398 |
-
|
5399 |
-
|
5400 |
-
|
5401 |
-
|
5402 |
-
|
5403 |
-
|
5404 |
-
|
5405 |
-
|
5406 |
-
|
5407 |
-
|
5408 |
-
|
5409 |
-
|
5410 |
-
|
5411 |
-
|
5412 |
-
|
5413 |
-
|
5414 |
-
|
5415 |
-
|
5416 |
-
|
5417 |
-
|
5418 |
-
|
5419 |
-
|
5420 |
-
|
5421 |
-
|
5422 |
-
|
5423 |
-
|
5424 |
-
|
5425 |
-
|
5426 |
-
|
5427 |
-
|
5428 |
-
|
5429 |
-
|
5430 |
-
|
5431 |
-
|
5432 |
-
|
5433 |
-
|
5434 |
-
|
5435 |
-
|
5436 |
-
|
5437 |
-
|
5438 |
-
|
5439 |
-
|
5440 |
-
|
5441 |
-
if (
|
5442 |
-
|
5443 |
-
|
5444 |
-
|
5445 |
-
|
5446 |
-
|
5447 |
-
|
5448 |
-
|
5449 |
-
|
5450 |
-
|
5451 |
-
|
5452 |
-
|
5453 |
-
|
5454 |
-
|
5455 |
-
|
5456 |
-
|
5457 |
-
|
5458 |
-
|
5459 |
-
|
5460 |
-
|
5461 |
-
|
5462 |
-
|
5463 |
-
|
5464 |
-
|
5465 |
-
|
5466 |
-
|
5467 |
-
|
5468 |
-
|
5469 |
-
|
5470 |
-
|
5471 |
-
|
5472 |
-
return
|
5473 |
-
}
|
5474 |
-
|
5475 |
-
function
|
5476 |
-
|
5477 |
-
|
5478 |
-
var
|
5479 |
-
|
5480 |
-
|
5481 |
-
|
5482 |
-
|
5483 |
-
|
5484 |
-
|
5485 |
-
|
5486 |
-
|
5487 |
-
|
5488 |
-
|
5489 |
-
|
5490 |
-
|
5491 |
-
return
|
5492 |
-
|
5493 |
-
|
5494 |
-
|
5495 |
-
|
5496 |
-
|
5497 |
-
|
5498 |
-
|
5499 |
-
|
5500 |
-
|
5501 |
-
|
5502 |
-
|
5503 |
-
|
5504 |
-
|
5505 |
-
|
5506 |
-
|
5507 |
-
|
5508 |
-
|
5509 |
-
|
5510 |
-
|
5511 |
-
|
5512 |
-
|
5513 |
-
|
5514 |
-
|
5515 |
-
|
5516 |
-
|
5517 |
-
|
5518 |
-
|
5519 |
-
|
5520 |
-
|
5521 |
-
|
5522 |
-
|
5523 |
-
function
|
5524 |
-
|
5525 |
-
|
5526 |
-
|
5527 |
-
|
5528 |
-
|
5529 |
-
function
|
5530 |
-
|
5531 |
-
|
5532 |
-
|
5533 |
-
|
5534 |
-
|
5535 |
-
|
5536 |
-
|
5537 |
-
|
5538 |
-
|
5539 |
-
|
5540 |
-
|
5541 |
-
|
5542 |
-
|
5543 |
-
|
5544 |
-
|
5545 |
-
|
5546 |
-
|
5547 |
-
|
5548 |
-
|
5549 |
-
|
5550 |
-
|
5551 |
-
|
5552 |
-
|
5553 |
-
|
5554 |
-
|
5555 |
-
|
5556 |
-
|
5557 |
-
|
5558 |
-
|
5559 |
-
|
5560 |
-
|
5561 |
-
|
5562 |
-
|
5563 |
-
function
|
5564 |
-
|
5565 |
-
|
5566 |
-
|
5567 |
-
|
5568 |
-
|
5569 |
-
|
5570 |
-
|
5571 |
-
|
5572 |
-
|
5573 |
-
|
5574 |
-
|
5575 |
-
|
5576 |
-
|
5577 |
-
|
5578 |
-
|
5579 |
-
|
5580 |
-
|
5581 |
-
|
5582 |
-
|
5583 |
-
|
5584 |
-
|
5585 |
-
|
5586 |
-
|
5587 |
-
|
5588 |
-
|
5589 |
-
|
5590 |
-
|
5591 |
-
|
5592 |
-
|
5593 |
-
|
5594 |
-
|
5595 |
-
|
5596 |
-
|
5597 |
-
|
5598 |
-
|
5599 |
-
|
5600 |
-
|
5601 |
-
|
5602 |
-
|
5603 |
-
|
5604 |
-
|
5605 |
-
|
5606 |
-
|
5607 |
-
|
5608 |
-
|
5609 |
-
|
5610 |
-
|
5611 |
-
|
5612 |
-
|
5613 |
-
|
5614 |
-
|
5615 |
-
|
5616 |
-
|
5617 |
-
|
5618 |
-
|
5619 |
-
|
5620 |
-
|
5621 |
-
|
5622 |
-
|
5623 |
-
|
5624 |
-
|
5625 |
-
|
5626 |
-
|
5627 |
-
|
5628 |
-
|
5629 |
-
|
5630 |
-
|
5631 |
-
|
5632 |
-
|
5633 |
-
|
5634 |
-
|
5635 |
-
|
5636 |
-
|
5637 |
-
|
5638 |
-
|
5639 |
-
|
5640 |
-
|
5641 |
-
|
5642 |
-
|
5643 |
-
|
5644 |
-
|
5645 |
-
|
5646 |
-
|
5647 |
-
|
5648 |
-
|
5649 |
-
|
5650 |
-
|
5651 |
-
|
5652 |
-
|
5653 |
-
|
5654 |
-
|
5655 |
-
|
5656 |
-
(
|
5657 |
-
|
5658 |
-
|
5659 |
-
|
5660 |
-
|
5661 |
-
|
5662 |
-
|
5663 |
-
|
5664 |
-
|
5665 |
-
|
5666 |
-
|
5667 |
-
|
5668 |
-
|
5669 |
-
|
5670 |
-
|
5671 |
-
|
5672 |
-
|
5673 |
-
|
5674 |
-
|
5675 |
-
}
|
5676 |
-
}
|
5677 |
-
|
5678 |
-
}
|
5679 |
-
|
5680 |
-
|
5681 |
-
function
|
5682 |
-
|
5683 |
-
|
5684 |
-
|
5685 |
-
|
5686 |
-
|
5687 |
-
|
5688 |
-
|
5689 |
-
|
5690 |
-
|
5691 |
-
var
|
5692 |
-
var
|
5693 |
-
|
5694 |
-
|
5695 |
-
|
5696 |
-
|
5697 |
-
|
5698 |
-
|
5699 |
-
|
5700 |
-
|
5701 |
-
|
5702 |
-
|
5703 |
-
|
5704 |
-
|
5705 |
-
|
5706 |
-
|
5707 |
-
|
5708 |
-
|
5709 |
-
|
5710 |
-
|
5711 |
-
|
5712 |
-
|
5713 |
-
|
5714 |
-
|
5715 |
-
|
5716 |
-
|
5717 |
-
|
5718 |
-
|
5719 |
-
|
5720 |
-
|
5721 |
-
|
5722 |
-
|
5723 |
-
|
5724 |
-
|
5725 |
-
|
5726 |
-
|
5727 |
-
|
5728 |
-
|
5729 |
-
|
5730 |
-
|
5731 |
-
|
5732 |
-
|
5733 |
-
|
5734 |
-
|
5735 |
-
|
5736 |
-
|
5737 |
-
|
5738 |
-
|
5739 |
-
|
5740 |
-
|
5741 |
-
|
5742 |
-
|
5743 |
-
//
|
5744 |
-
//
|
5745 |
-
|
5746 |
-
|
5747 |
-
|
5748 |
-
|
5749 |
-
|
5750 |
-
|
5751 |
-
|
5752 |
-
|
5753 |
-
|
5754 |
-
|
5755 |
-
|
5756 |
-
|
5757 |
-
|
5758 |
-
|
5759 |
-
|
5760 |
-
|
5761 |
-
|
5762 |
-
|
5763 |
-
|
5764 |
-
|
5765 |
-
|
5766 |
-
|
5767 |
-
|
5768 |
-
|
5769 |
-
|
5770 |
-
|
5771 |
-
|
5772 |
-
|
5773 |
-
|
5774 |
-
|
5775 |
-
|
5776 |
-
|
5777 |
-
//
|
5778 |
-
//
|
5779 |
-
|
5780 |
-
//
|
5781 |
-
|
5782 |
-
|
5783 |
-
|
5784 |
-
|
5785 |
-
|
5786 |
-
|
5787 |
-
|
5788 |
-
//
|
5789 |
-
//
|
5790 |
-
|
5791 |
-
|
5792 |
-
|
5793 |
-
|
5794 |
-
|
5795 |
-
|
5796 |
-
|
5797 |
-
|
5798 |
-
|
5799 |
-
|
5800 |
-
|
5801 |
-
|
5802 |
-
|
5803 |
-
|
5804 |
-
|
5805 |
-
|
5806 |
-
|
5807 |
-
|
5808 |
-
|
5809 |
-
|
5810 |
-
|
5811 |
-
|
5812 |
-
|
5813 |
-
|
5814 |
-
|
5815 |
-
|
5816 |
-
|
5817 |
-
|
5818 |
-
|
5819 |
-
|
5820 |
-
|
5821 |
-
|
5822 |
-
|
5823 |
-
|
5824 |
-
|
5825 |
-
|
5826 |
-
|
5827 |
-
|
5828 |
-
|
5829 |
-
|
5830 |
-
|
5831 |
-
|
5832 |
-
|
5833 |
-
|
5834 |
-
|
5835 |
-
|
5836 |
-
|
5837 |
-
|
5838 |
-
|
5839 |
-
|
5840 |
-
|
5841 |
-
|
5842 |
-
|
5843 |
-
|
5844 |
-
|
5845 |
-
|
5846 |
-
|
5847 |
-
|
5848 |
-
|
5849 |
-
|
5850 |
-
|
5851 |
-
|
5852 |
-
|
5853 |
-
|
5854 |
-
|
5855 |
-
|
5856 |
-
|
5857 |
-
|
5858 |
-
|
5859 |
-
|
5860 |
-
|
5861 |
-
|
5862 |
-
|
5863 |
-
|
5864 |
-
|
5865 |
-
|
5866 |
-
|
5867 |
-
|
5868 |
-
|
5869 |
-
|
5870 |
-
|
5871 |
-
|
5872 |
-
|
5873 |
-
|
5874 |
-
|
5875 |
-
|
5876 |
-
|
5877 |
-
|
5878 |
-
|
5879 |
-
|
5880 |
-
|
5881 |
-
|
5882 |
-
|
5883 |
-
|
5884 |
-
|
5885 |
-
|
5886 |
-
|
5887 |
-
|
5888 |
-
|
5889 |
-
|
5890 |
-
|
5891 |
-
|
5892 |
-
|
5893 |
-
|
5894 |
-
|
5895 |
-
|
5896 |
-
|
5897 |
-
|
5898 |
-
|
5899 |
-
|
5900 |
-
|
5901 |
-
|
5902 |
-
|
5903 |
-
|
5904 |
-
|
5905 |
-
|
5906 |
-
|
5907 |
-
|
5908 |
-
|
5909 |
-
|
5910 |
-
|
5911 |
-
|
5912 |
-
|
5913 |
-
|
5914 |
-
|
5915 |
-
|
5916 |
-
|
5917 |
-
|
5918 |
-
|
5919 |
-
|
5920 |
-
|
5921 |
-
|
5922 |
-
|
5923 |
-
|
5924 |
-
|
5925 |
-
|
5926 |
-
|
5927 |
-
|
5928 |
-
|
5929 |
-
|
5930 |
-
|
5931 |
-
|
5932 |
-
|
5933 |
-
|
5934 |
-
|
5935 |
-
|
5936 |
-
|
5937 |
-
|
5938 |
-
|
5939 |
-
|
5940 |
-
|
5941 |
-
|
5942 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
// CodeMirror, copyright (c) by Marijn Haverbeke and others
|
2 |
+
// Distributed under an MIT license: http://codemirror.net/LICENSE
|
3 |
+
|
4 |
+
// This is CodeMirror (http://codemirror.net), a code editor
|
5 |
+
// implemented in JavaScript on top of the browser's DOM.
|
6 |
+
//
|
7 |
+
// You can find some technical background for some of the code below
|
8 |
+
// at http://marijnhaverbeke.nl/blog/#cm-internals .
|
9 |
+
|
10 |
+
(function(mod) {
|
11 |
+
if (typeof exports == "object" && typeof module == "object") // CommonJS
|
12 |
+
module.exports = mod();
|
13 |
+
else if (typeof define == "function" && define.amd) // AMD
|
14 |
+
return define([], mod);
|
15 |
+
else // Plain browser env
|
16 |
+
this.CodeMirror = mod();
|
17 |
+
})(function() {
|
18 |
+
"use strict";
|
19 |
+
|
20 |
+
// BROWSER SNIFFING
|
21 |
+
|
22 |
+
// Kludges for bugs and behavior differences that can't be feature
|
23 |
+
// detected are enabled based on userAgent etc sniffing.
|
24 |
+
|
25 |
+
var gecko = /gecko\/\d/i.test(navigator.userAgent);
|
26 |
+
// ie_uptoN means Internet Explorer version N or lower
|
27 |
+
var ie_upto10 = /MSIE \d/.test(navigator.userAgent);
|
28 |
+
var ie_11up = /Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent);
|
29 |
+
var ie = ie_upto10 || ie_11up;
|
30 |
+
var ie_version = ie && (ie_upto10 ? document.documentMode || 6 : ie_11up[1]);
|
31 |
+
var webkit = /WebKit\//.test(navigator.userAgent);
|
32 |
+
var qtwebkit = webkit && /Qt\/\d+\.\d+/.test(navigator.userAgent);
|
33 |
+
var chrome = /Chrome\//.test(navigator.userAgent);
|
34 |
+
var presto = /Opera\//.test(navigator.userAgent);
|
35 |
+
var safari = /Apple Computer/.test(navigator.vendor);
|
36 |
+
var khtml = /KHTML\//.test(navigator.userAgent);
|
37 |
+
var mac_geMountainLion = /Mac OS X 1\d\D([8-9]|\d\d)\D/.test(navigator.userAgent);
|
38 |
+
var phantom = /PhantomJS/.test(navigator.userAgent);
|
39 |
+
|
40 |
+
var ios = /AppleWebKit/.test(navigator.userAgent) && /Mobile\/\w+/.test(navigator.userAgent);
|
41 |
+
// This is woefully incomplete. Suggestions for alternative methods welcome.
|
42 |
+
var mobile = ios || /Android|webOS|BlackBerry|Opera Mini|Opera Mobi|IEMobile/i.test(navigator.userAgent);
|
43 |
+
var mac = ios || /Mac/.test(navigator.platform);
|
44 |
+
var windows = /win/i.test(navigator.platform);
|
45 |
+
|
46 |
+
var presto_version = presto && navigator.userAgent.match(/Version\/(\d*\.\d*)/);
|
47 |
+
if (presto_version) presto_version = Number(presto_version[1]);
|
48 |
+
if (presto_version && presto_version >= 15) { presto = false; webkit = true; }
|
49 |
+
// Some browsers use the wrong event properties to signal cmd/ctrl on OS X
|
50 |
+
var flipCtrlCmd = mac && (qtwebkit || presto && (presto_version == null || presto_version < 12.11));
|
51 |
+
var captureRightClick = gecko || (ie && ie_version >= 9);
|
52 |
+
|
53 |
+
// Optimize some code when these features are not used.
|
54 |
+
var sawReadOnlySpans = false, sawCollapsedSpans = false;
|
55 |
+
|
56 |
+
// EDITOR CONSTRUCTOR
|
57 |
+
|
58 |
+
// A CodeMirror instance represents an editor. This is the object
|
59 |
+
// that user code is usually dealing with.
|
60 |
+
|
61 |
+
function CodeMirror(place, options) {
|
62 |
+
if (!(this instanceof CodeMirror)) return new CodeMirror(place, options);
|
63 |
+
|
64 |
+
this.options = options = options ? copyObj(options) : {};
|
65 |
+
// Determine effective options based on given values and defaults.
|
66 |
+
copyObj(defaults, options, false);
|
67 |
+
setGuttersForLineNumbers(options);
|
68 |
+
|
69 |
+
var doc = options.value;
|
70 |
+
if (typeof doc == "string") doc = new Doc(doc, options.mode);
|
71 |
+
this.doc = doc;
|
72 |
+
|
73 |
+
var display = this.display = new Display(place, doc);
|
74 |
+
display.wrapper.CodeMirror = this;
|
75 |
+
updateGutters(this);
|
76 |
+
themeChanged(this);
|
77 |
+
if (options.lineWrapping)
|
78 |
+
this.display.wrapper.className += " CodeMirror-wrap";
|
79 |
+
if (options.autofocus && !mobile) focusInput(this);
|
80 |
+
initScrollbars(this);
|
81 |
+
|
82 |
+
this.state = {
|
83 |
+
keyMaps: [], // stores maps added by addKeyMap
|
84 |
+
overlays: [], // highlighting overlays, as added by addOverlay
|
85 |
+
modeGen: 0, // bumped when mode/overlay changes, used to invalidate highlighting info
|
86 |
+
overwrite: false, focused: false,
|
87 |
+
suppressEdits: false, // used to disable editing during key handlers when in readOnly mode
|
88 |
+
pasteIncoming: false, cutIncoming: false, // help recognize paste/cut edits in readInput
|
89 |
+
draggingText: false,
|
90 |
+
highlight: new Delayed(), // stores highlight worker timeout
|
91 |
+
keySeq: null // Unfinished key sequence
|
92 |
+
};
|
93 |
+
|
94 |
+
// Override magic textarea content restore that IE sometimes does
|
95 |
+
// on our hidden textarea on reload
|
96 |
+
if (ie && ie_version < 11) setTimeout(bind(resetInput, this, true), 20);
|
97 |
+
|
98 |
+
registerEventHandlers(this);
|
99 |
+
ensureGlobalHandlers();
|
100 |
+
|
101 |
+
startOperation(this);
|
102 |
+
this.curOp.forceUpdate = true;
|
103 |
+
attachDoc(this, doc);
|
104 |
+
|
105 |
+
if ((options.autofocus && !mobile) || activeElt() == display.input)
|
106 |
+
setTimeout(bind(onFocus, this), 20);
|
107 |
+
else
|
108 |
+
onBlur(this);
|
109 |
+
|
110 |
+
for (var opt in optionHandlers) if (optionHandlers.hasOwnProperty(opt))
|
111 |
+
optionHandlers[opt](this, options[opt], Init);
|
112 |
+
maybeUpdateLineNumberWidth(this);
|
113 |
+
for (var i = 0; i < initHooks.length; ++i) initHooks[i](this);
|
114 |
+
endOperation(this);
|
115 |
+
// Suppress optimizelegibility in Webkit, since it breaks text
|
116 |
+
// measuring on line wrapping boundaries.
|
117 |
+
if (webkit && options.lineWrapping &&
|
118 |
+
getComputedStyle(display.lineDiv).textRendering == "optimizelegibility")
|
119 |
+
display.lineDiv.style.textRendering = "auto";
|
120 |
+
}
|
121 |
+
|
122 |
+
// DISPLAY CONSTRUCTOR
|
123 |
+
|
124 |
+
// The display handles the DOM integration, both for input reading
|
125 |
+
// and content drawing. It holds references to DOM nodes and
|
126 |
+
// display-related state.
|
127 |
+
|
128 |
+
function Display(place, doc) {
|
129 |
+
var d = this;
|
130 |
+
|
131 |
+
// The semihidden textarea that is focused when the editor is
|
132 |
+
// focused, and receives input.
|
133 |
+
var input = d.input = elt("textarea", null, null, "position: absolute; padding: 0; width: 1px; height: 1em; outline: none");
|
134 |
+
// The textarea is kept positioned near the cursor to prevent the
|
135 |
+
// fact that it'll be scrolled into view on input from scrolling
|
136 |
+
// our fake cursor out of view. On webkit, when wrap=off, paste is
|
137 |
+
// very slow. So make the area wide instead.
|
138 |
+
if (webkit) input.style.width = "1000px";
|
139 |
+
else input.setAttribute("wrap", "off");
|
140 |
+
// If border: 0; -- iOS fails to open keyboard (issue #1287)
|
141 |
+
if (ios) input.style.border = "1px solid black";
|
142 |
+
input.setAttribute("autocorrect", "off"); input.setAttribute("autocapitalize", "off"); input.setAttribute("spellcheck", "false");
|
143 |
+
|
144 |
+
// Wraps and hides input textarea
|
145 |
+
d.inputDiv = elt("div", [input], null, "overflow: hidden; position: relative; width: 3px; height: 0px;");
|
146 |
+
// Covers bottom-right square when both scrollbars are present.
|
147 |
+
d.scrollbarFiller = elt("div", null, "CodeMirror-scrollbar-filler");
|
148 |
+
d.scrollbarFiller.setAttribute("not-content", "true");
|
149 |
+
// Covers bottom of gutter when coverGutterNextToScrollbar is on
|
150 |
+
// and h scrollbar is present.
|
151 |
+
d.gutterFiller = elt("div", null, "CodeMirror-gutter-filler");
|
152 |
+
d.gutterFiller.setAttribute("not-content", "true");
|
153 |
+
// Will contain the actual code, positioned to cover the viewport.
|
154 |
+
d.lineDiv = elt("div", null, "CodeMirror-code");
|
155 |
+
// Elements are added to these to represent selection and cursors.
|
156 |
+
d.selectionDiv = elt("div", null, null, "position: relative; z-index: 1");
|
157 |
+
d.cursorDiv = elt("div", null, "CodeMirror-cursors");
|
158 |
+
// A visibility: hidden element used to find the size of things.
|
159 |
+
d.measure = elt("div", null, "CodeMirror-measure");
|
160 |
+
// When lines outside of the viewport are measured, they are drawn in this.
|
161 |
+
d.lineMeasure = elt("div", null, "CodeMirror-measure");
|
162 |
+
// Wraps everything that needs to exist inside the vertically-padded coordinate system
|
163 |
+
d.lineSpace = elt("div", [d.measure, d.lineMeasure, d.selectionDiv, d.cursorDiv, d.lineDiv],
|
164 |
+
null, "position: relative; outline: none");
|
165 |
+
// Moved around its parent to cover visible view.
|
166 |
+
d.mover = elt("div", [elt("div", [d.lineSpace], "CodeMirror-lines")], null, "position: relative");
|
167 |
+
// Set to the height of the document, allowing scrolling.
|
168 |
+
d.sizer = elt("div", [d.mover], "CodeMirror-sizer");
|
169 |
+
d.sizerWidth = null;
|
170 |
+
// Behavior of elts with overflow: auto and padding is
|
171 |
+
// inconsistent across browsers. This is used to ensure the
|
172 |
+
// scrollable area is big enough.
|
173 |
+
d.heightForcer = elt("div", null, null, "position: absolute; height: " + scrollerGap + "px; width: 1px;");
|
174 |
+
// Will contain the gutters, if any.
|
175 |
+
d.gutters = elt("div", null, "CodeMirror-gutters");
|
176 |
+
d.lineGutter = null;
|
177 |
+
// Actual scrollable element.
|
178 |
+
d.scroller = elt("div", [d.sizer, d.heightForcer, d.gutters], "CodeMirror-scroll");
|
179 |
+
d.scroller.setAttribute("tabIndex", "-1");
|
180 |
+
// The element in which the editor lives.
|
181 |
+
d.wrapper = elt("div", [d.inputDiv, d.scrollbarFiller, d.gutterFiller, d.scroller], "CodeMirror");
|
182 |
+
|
183 |
+
// Work around IE7 z-index bug (not perfect, hence IE7 not really being supported)
|
184 |
+
if (ie && ie_version < 8) { d.gutters.style.zIndex = -1; d.scroller.style.paddingRight = 0; }
|
185 |
+
// Needed to hide big blue blinking cursor on Mobile Safari
|
186 |
+
if (ios) input.style.width = "0px";
|
187 |
+
if (!webkit) d.scroller.draggable = true;
|
188 |
+
// Needed to handle Tab key in KHTML
|
189 |
+
if (khtml) { d.inputDiv.style.height = "1px"; d.inputDiv.style.position = "absolute"; }
|
190 |
+
|
191 |
+
if (place) {
|
192 |
+
if (place.appendChild) place.appendChild(d.wrapper);
|
193 |
+
else place(d.wrapper);
|
194 |
+
}
|
195 |
+
|
196 |
+
// Current rendered range (may be bigger than the view window).
|
197 |
+
d.viewFrom = d.viewTo = doc.first;
|
198 |
+
d.reportedViewFrom = d.reportedViewTo = doc.first;
|
199 |
+
// Information about the rendered lines.
|
200 |
+
d.view = [];
|
201 |
+
d.renderedView = null;
|
202 |
+
// Holds info about a single rendered line when it was rendered
|
203 |
+
// for measurement, while not in view.
|
204 |
+
d.externalMeasured = null;
|
205 |
+
// Empty space (in pixels) above the view
|
206 |
+
d.viewOffset = 0;
|
207 |
+
d.lastWrapHeight = d.lastWrapWidth = 0;
|
208 |
+
d.updateLineNumbers = null;
|
209 |
+
|
210 |
+
d.nativeBarWidth = d.barHeight = d.barWidth = 0;
|
211 |
+
d.scrollbarsClipped = false;
|
212 |
+
|
213 |
+
// Used to only resize the line number gutter when necessary (when
|
214 |
+
// the amount of lines crosses a boundary that makes its width change)
|
215 |
+
d.lineNumWidth = d.lineNumInnerWidth = d.lineNumChars = null;
|
216 |
+
// See readInput and resetInput
|
217 |
+
d.prevInput = "";
|
218 |
+
// Set to true when a non-horizontal-scrolling line widget is
|
219 |
+
// added. As an optimization, line widget aligning is skipped when
|
220 |
+
// this is false.
|
221 |
+
d.alignWidgets = false;
|
222 |
+
// Flag that indicates whether we expect input to appear real soon
|
223 |
+
// now (after some event like 'keypress' or 'input') and are
|
224 |
+
// polling intensively.
|
225 |
+
d.pollingFast = false;
|
226 |
+
// Self-resetting timeout for the poller
|
227 |
+
d.poll = new Delayed();
|
228 |
+
|
229 |
+
d.cachedCharWidth = d.cachedTextHeight = d.cachedPaddingH = null;
|
230 |
+
|
231 |
+
// Tracks when resetInput has punted to just putting a short
|
232 |
+
// string into the textarea instead of the full selection.
|
233 |
+
d.inaccurateSelection = false;
|
234 |
+
|
235 |
+
// Tracks the maximum line length so that the horizontal scrollbar
|
236 |
+
// can be kept static when scrolling.
|
237 |
+
d.maxLine = null;
|
238 |
+
d.maxLineLength = 0;
|
239 |
+
d.maxLineChanged = false;
|
240 |
+
|
241 |
+
// Used for measuring wheel scrolling granularity
|
242 |
+
d.wheelDX = d.wheelDY = d.wheelStartX = d.wheelStartY = null;
|
243 |
+
|
244 |
+
// True when shift is held down.
|
245 |
+
d.shift = false;
|
246 |
+
|
247 |
+
// Used to track whether anything happened since the context menu
|
248 |
+
// was opened.
|
249 |
+
d.selForContextMenu = null;
|
250 |
+
}
|
251 |
+
|
252 |
+
// STATE UPDATES
|
253 |
+
|
254 |
+
// Used to get the editor into a consistent state again when options change.
|
255 |
+
|
256 |
+
function loadMode(cm) {
|
257 |
+
cm.doc.mode = CodeMirror.getMode(cm.options, cm.doc.modeOption);
|
258 |
+
resetModeState(cm);
|
259 |
+
}
|
260 |
+
|
261 |
+
function resetModeState(cm) {
|
262 |
+
cm.doc.iter(function(line) {
|
263 |
+
if (line.stateAfter) line.stateAfter = null;
|
264 |
+
if (line.styles) line.styles = null;
|
265 |
+
});
|
266 |
+
cm.doc.frontier = cm.doc.first;
|
267 |
+
startWorker(cm, 100);
|
268 |
+
cm.state.modeGen++;
|
269 |
+
if (cm.curOp) regChange(cm);
|
270 |
+
}
|
271 |
+
|
272 |
+
function wrappingChanged(cm) {
|
273 |
+
if (cm.options.lineWrapping) {
|
274 |
+
addClass(cm.display.wrapper, "CodeMirror-wrap");
|
275 |
+
cm.display.sizer.style.minWidth = "";
|
276 |
+
cm.display.sizerWidth = null;
|
277 |
+
} else {
|
278 |
+
rmClass(cm.display.wrapper, "CodeMirror-wrap");
|
279 |
+
findMaxLine(cm);
|
280 |
+
}
|
281 |
+
estimateLineHeights(cm);
|
282 |
+
regChange(cm);
|
283 |
+
clearCaches(cm);
|
284 |
+
setTimeout(function(){updateScrollbars(cm);}, 100);
|
285 |
+
}
|
286 |
+
|
287 |
+
// Returns a function that estimates the height of a line, to use as
|
288 |
+
// first approximation until the line becomes visible (and is thus
|
289 |
+
// properly measurable).
|
290 |
+
function estimateHeight(cm) {
|
291 |
+
var th = textHeight(cm.display), wrapping = cm.options.lineWrapping;
|
292 |
+
var perLine = wrapping && Math.max(5, cm.display.scroller.clientWidth / charWidth(cm.display) - 3);
|
293 |
+
return function(line) {
|
294 |
+
if (lineIsHidden(cm.doc, line)) return 0;
|
295 |
+
|
296 |
+
var widgetsHeight = 0;
|
297 |
+
if (line.widgets) for (var i = 0; i < line.widgets.length; i++) {
|
298 |
+
if (line.widgets[i].height) widgetsHeight += line.widgets[i].height;
|
299 |
+
}
|
300 |
+
|
301 |
+
if (wrapping)
|
302 |
+
return widgetsHeight + (Math.ceil(line.text.length / perLine) || 1) * th;
|
303 |
+
else
|
304 |
+
return widgetsHeight + th;
|
305 |
+
};
|
306 |
+
}
|
307 |
+
|
308 |
+
function estimateLineHeights(cm) {
|
309 |
+
var doc = cm.doc, est = estimateHeight(cm);
|
310 |
+
doc.iter(function(line) {
|
311 |
+
var estHeight = est(line);
|
312 |
+
if (estHeight != line.height) updateLineHeight(line, estHeight);
|
313 |
+
});
|
314 |
+
}
|
315 |
+
|
316 |
+
function themeChanged(cm) {
|
317 |
+
cm.display.wrapper.className = cm.display.wrapper.className.replace(/\s*cm-s-\S+/g, "") +
|
318 |
+
cm.options.theme.replace(/(^|\s)\s*/g, " cm-s-");
|
319 |
+
clearCaches(cm);
|
320 |
+
}
|
321 |
+
|
322 |
+
function guttersChanged(cm) {
|
323 |
+
updateGutters(cm);
|
324 |
+
regChange(cm);
|
325 |
+
setTimeout(function(){alignHorizontally(cm);}, 20);
|
326 |
+
}
|
327 |
+
|
328 |
+
// Rebuild the gutter elements, ensure the margin to the left of the
|
329 |
+
// code matches their width.
|
330 |
+
function updateGutters(cm) {
|
331 |
+
var gutters = cm.display.gutters, specs = cm.options.gutters;
|
332 |
+
removeChildren(gutters);
|
333 |
+
for (var i = 0; i < specs.length; ++i) {
|
334 |
+
var gutterClass = specs[i];
|
335 |
+
var gElt = gutters.appendChild(elt("div", null, "CodeMirror-gutter " + gutterClass));
|
336 |
+
if (gutterClass == "CodeMirror-linenumbers") {
|
337 |
+
cm.display.lineGutter = gElt;
|
338 |
+
gElt.style.width = (cm.display.lineNumWidth || 1) + "px";
|
339 |
+
}
|
340 |
+
}
|
341 |
+
gutters.style.display = i ? "" : "none";
|
342 |
+
updateGutterSpace(cm);
|
343 |
+
}
|
344 |
+
|
345 |
+
function updateGutterSpace(cm) {
|
346 |
+
var width = cm.display.gutters.offsetWidth;
|
347 |
+
cm.display.sizer.style.marginLeft = width + "px";
|
348 |
+
}
|
349 |
+
|
350 |
+
// Compute the character length of a line, taking into account
|
351 |
+
// collapsed ranges (see markText) that might hide parts, and join
|
352 |
+
// other lines onto it.
|
353 |
+
function lineLength(line) {
|
354 |
+
if (line.height == 0) return 0;
|
355 |
+
var len = line.text.length, merged, cur = line;
|
356 |
+
while (merged = collapsedSpanAtStart(cur)) {
|
357 |
+
var found = merged.find(0, true);
|
358 |
+
cur = found.from.line;
|
359 |
+
len += found.from.ch - found.to.ch;
|
360 |
+
}
|
361 |
+
cur = line;
|
362 |
+
while (merged = collapsedSpanAtEnd(cur)) {
|
363 |
+
var found = merged.find(0, true);
|
364 |
+
len -= cur.text.length - found.from.ch;
|
365 |
+
cur = found.to.line;
|
366 |
+
len += cur.text.length - found.to.ch;
|
367 |
+
}
|
368 |
+
return len;
|
369 |
+
}
|
370 |
+
|
371 |
+
// Find the longest line in the document.
|
372 |
+
function findMaxLine(cm) {
|
373 |
+
var d = cm.display, doc = cm.doc;
|
374 |
+
d.maxLine = getLine(doc, doc.first);
|
375 |
+
d.maxLineLength = lineLength(d.maxLine);
|
376 |
+
d.maxLineChanged = true;
|
377 |
+
doc.iter(function(line) {
|
378 |
+
var len = lineLength(line);
|
379 |
+
if (len > d.maxLineLength) {
|
380 |
+
d.maxLineLength = len;
|
381 |
+
d.maxLine = line;
|
382 |
+
}
|
383 |
+
});
|
384 |
+
}
|
385 |
+
|
386 |
+
// Make sure the gutters options contains the element
|
387 |
+
// "CodeMirror-linenumbers" when the lineNumbers option is true.
|
388 |
+
function setGuttersForLineNumbers(options) {
|
389 |
+
var found = indexOf(options.gutters, "CodeMirror-linenumbers");
|
390 |
+
if (found == -1 && options.lineNumbers) {
|
391 |
+
options.gutters = options.gutters.concat(["CodeMirror-linenumbers"]);
|
392 |
+
} else if (found > -1 && !options.lineNumbers) {
|
393 |
+
options.gutters = options.gutters.slice(0);
|
394 |
+
options.gutters.splice(found, 1);
|
395 |
+
}
|
396 |
+
}
|
397 |
+
|
398 |
+
// SCROLLBARS
|
399 |
+
|
400 |
+
// Prepare DOM reads needed to update the scrollbars. Done in one
|
401 |
+
// shot to minimize update/measure roundtrips.
|
402 |
+
function measureForScrollbars(cm) {
|
403 |
+
var d = cm.display, gutterW = d.gutters.offsetWidth;
|
404 |
+
var docH = Math.round(cm.doc.height + paddingVert(cm.display));
|
405 |
+
return {
|
406 |
+
clientHeight: d.scroller.clientHeight,
|
407 |
+
viewHeight: d.wrapper.clientHeight,
|
408 |
+
scrollWidth: d.scroller.scrollWidth, clientWidth: d.scroller.clientWidth,
|
409 |
+
viewWidth: d.wrapper.clientWidth,
|
410 |
+
barLeft: cm.options.fixedGutter ? gutterW : 0,
|
411 |
+
docHeight: docH,
|
412 |
+
scrollHeight: docH + scrollGap(cm) + d.barHeight,
|
413 |
+
nativeBarWidth: d.nativeBarWidth,
|
414 |
+
gutterWidth: gutterW
|
415 |
+
};
|
416 |
+
}
|
417 |
+
|
418 |
+
function NativeScrollbars(place, scroll, cm) {
|
419 |
+
this.cm = cm;
|
420 |
+
var vert = this.vert = elt("div", [elt("div", null, null, "min-width: 1px")], "CodeMirror-vscrollbar");
|
421 |
+
var horiz = this.horiz = elt("div", [elt("div", null, null, "height: 100%; min-height: 1px")], "CodeMirror-hscrollbar");
|
422 |
+
place(vert); place(horiz);
|
423 |
+
|
424 |
+
on(vert, "scroll", function() {
|
425 |
+
if (vert.clientHeight) scroll(vert.scrollTop, "vertical");
|
426 |
+
});
|
427 |
+
on(horiz, "scroll", function() {
|
428 |
+
if (horiz.clientWidth) scroll(horiz.scrollLeft, "horizontal");
|
429 |
+
});
|
430 |
+
|
431 |
+
this.checkedOverlay = false;
|
432 |
+
// Need to set a minimum width to see the scrollbar on IE7 (but must not set it on IE8).
|
433 |
+
if (ie && ie_version < 8) this.horiz.style.minHeight = this.vert.style.minWidth = "18px";
|
434 |
+
}
|
435 |
+
|
436 |
+
NativeScrollbars.prototype = copyObj({
|
437 |
+
update: function(measure) {
|
438 |
+
var needsH = measure.scrollWidth > measure.clientWidth + 1;
|
439 |
+
var needsV = measure.scrollHeight > measure.clientHeight + 1;
|
440 |
+
var sWidth = measure.nativeBarWidth;
|
441 |
+
|
442 |
+
if (needsV) {
|
443 |
+
this.vert.style.display = "block";
|
444 |
+
this.vert.style.bottom = needsH ? sWidth + "px" : "0";
|
445 |
+
var totalHeight = measure.viewHeight - (needsH ? sWidth : 0);
|
446 |
+
// A bug in IE8 can cause this value to be negative, so guard it.
|
447 |
+
this.vert.firstChild.style.height =
|
448 |
+
Math.max(0, measure.scrollHeight - measure.clientHeight + totalHeight) + "px";
|
449 |
+
} else {
|
450 |
+
this.vert.style.display = "";
|
451 |
+
this.vert.firstChild.style.height = "0";
|
452 |
+
}
|
453 |
+
|
454 |
+
if (needsH) {
|
455 |
+
this.horiz.style.display = "block";
|
456 |
+
this.horiz.style.right = needsV ? sWidth + "px" : "0";
|
457 |
+
this.horiz.style.left = measure.barLeft + "px";
|
458 |
+
var totalWidth = measure.viewWidth - measure.barLeft - (needsV ? sWidth : 0);
|
459 |
+
this.horiz.firstChild.style.width =
|
460 |
+
(measure.scrollWidth - measure.clientWidth + totalWidth) + "px";
|
461 |
+
} else {
|
462 |
+
this.horiz.style.display = "";
|
463 |
+
this.horiz.firstChild.style.width = "0";
|
464 |
+
}
|
465 |
+
|
466 |
+
if (!this.checkedOverlay && measure.clientHeight > 0) {
|
467 |
+
if (sWidth == 0) this.overlayHack();
|
468 |
+
this.checkedOverlay = true;
|
469 |
+
}
|
470 |
+
|
471 |
+
return {right: needsV ? sWidth : 0, bottom: needsH ? sWidth : 0};
|
472 |
+
},
|
473 |
+
setScrollLeft: function(pos) {
|
474 |
+
if (this.horiz.scrollLeft != pos) this.horiz.scrollLeft = pos;
|
475 |
+
},
|
476 |
+
setScrollTop: function(pos) {
|
477 |
+
if (this.vert.scrollTop != pos) this.vert.scrollTop = pos;
|
478 |
+
},
|
479 |
+
overlayHack: function() {
|
480 |
+
var w = mac && !mac_geMountainLion ? "12px" : "18px";
|
481 |
+
this.horiz.style.minHeight = this.vert.style.minWidth = w;
|
482 |
+
var self = this;
|
483 |
+
var barMouseDown = function(e) {
|
484 |
+
if (e_target(e) != self.vert && e_target(e) != self.horiz)
|
485 |
+
operation(self.cm, onMouseDown)(e);
|
486 |
+
};
|
487 |
+
on(this.vert, "mousedown", barMouseDown);
|
488 |
+
on(this.horiz, "mousedown", barMouseDown);
|
489 |
+
},
|
490 |
+
clear: function() {
|
491 |
+
var parent = this.horiz.parentNode;
|
492 |
+
parent.removeChild(this.horiz);
|
493 |
+
parent.removeChild(this.vert);
|
494 |
+
}
|
495 |
+
}, NativeScrollbars.prototype);
|
496 |
+
|
497 |
+
function NullScrollbars() {}
|
498 |
+
|
499 |
+
NullScrollbars.prototype = copyObj({
|
500 |
+
update: function() { return {bottom: 0, right: 0}; },
|
501 |
+
setScrollLeft: function() {},
|
502 |
+
setScrollTop: function() {},
|
503 |
+
clear: function() {}
|
504 |
+
}, NullScrollbars.prototype);
|
505 |
+
|
506 |
+
CodeMirror.scrollbarModel = {"native": NativeScrollbars, "null": NullScrollbars};
|
507 |
+
|
508 |
+
function initScrollbars(cm) {
|
509 |
+
if (cm.display.scrollbars) {
|
510 |
+
cm.display.scrollbars.clear();
|
511 |
+
if (cm.display.scrollbars.addClass)
|
512 |
+
rmClass(cm.display.wrapper, cm.display.scrollbars.addClass);
|
513 |
+
}
|
514 |
+
|
515 |
+
cm.display.scrollbars = new CodeMirror.scrollbarModel[cm.options.scrollbarStyle](function(node) {
|
516 |
+
cm.display.wrapper.insertBefore(node, cm.display.scrollbarFiller);
|
517 |
+
on(node, "mousedown", function() {
|
518 |
+
if (cm.state.focused) setTimeout(bind(focusInput, cm), 0);
|
519 |
+
});
|
520 |
+
node.setAttribute("not-content", "true");
|
521 |
+
}, function(pos, axis) {
|
522 |
+
if (axis == "horizontal") setScrollLeft(cm, pos);
|
523 |
+
else setScrollTop(cm, pos);
|
524 |
+
}, cm);
|
525 |
+
if (cm.display.scrollbars.addClass)
|
526 |
+
addClass(cm.display.wrapper, cm.display.scrollbars.addClass);
|
527 |
+
}
|
528 |
+
|
529 |
+
function updateScrollbars(cm, measure) {
|
530 |
+
if (!measure) measure = measureForScrollbars(cm);
|
531 |
+
var startWidth = cm.display.barWidth, startHeight = cm.display.barHeight;
|
532 |
+
updateScrollbarsInner(cm, measure);
|
533 |
+
for (var i = 0; i < 4 && startWidth != cm.display.barWidth || startHeight != cm.display.barHeight; i++) {
|
534 |
+
if (startWidth != cm.display.barWidth && cm.options.lineWrapping)
|
535 |
+
updateHeightsInViewport(cm);
|
536 |
+
updateScrollbarsInner(cm, measureForScrollbars(cm));
|
537 |
+
startWidth = cm.display.barWidth; startHeight = cm.display.barHeight;
|
538 |
+
}
|
539 |
+
}
|
540 |
+
|
541 |
+
// Re-synchronize the fake scrollbars with the actual size of the
|
542 |
+
// content.
|
543 |
+
function updateScrollbarsInner(cm, measure) {
|
544 |
+
var d = cm.display;
|
545 |
+
var sizes = d.scrollbars.update(measure);
|
546 |
+
|
547 |
+
d.sizer.style.paddingRight = (d.barWidth = sizes.right) + "px";
|
548 |
+
d.sizer.style.paddingBottom = (d.barHeight = sizes.bottom) + "px";
|
549 |
+
|
550 |
+
if (sizes.right && sizes.bottom) {
|
551 |
+
d.scrollbarFiller.style.display = "block";
|
552 |
+
d.scrollbarFiller.style.height = sizes.bottom + "px";
|
553 |
+
d.scrollbarFiller.style.width = sizes.right + "px";
|
554 |
+
} else d.scrollbarFiller.style.display = "";
|
555 |
+
if (sizes.bottom && cm.options.coverGutterNextToScrollbar && cm.options.fixedGutter) {
|
556 |
+
d.gutterFiller.style.display = "block";
|
557 |
+
d.gutterFiller.style.height = sizes.bottom + "px";
|
558 |
+
d.gutterFiller.style.width = measure.gutterWidth + "px";
|
559 |
+
} else d.gutterFiller.style.display = "";
|
560 |
+
}
|
561 |
+
|
562 |
+
// Compute the lines that are visible in a given viewport (defaults
|
563 |
+
// the the current scroll position). viewport may contain top,
|
564 |
+
// height, and ensure (see op.scrollToPos) properties.
|
565 |
+
function visibleLines(display, doc, viewport) {
|
566 |
+
var top = viewport && viewport.top != null ? Math.max(0, viewport.top) : display.scroller.scrollTop;
|
567 |
+
top = Math.floor(top - paddingTop(display));
|
568 |
+
var bottom = viewport && viewport.bottom != null ? viewport.bottom : top + display.wrapper.clientHeight;
|
569 |
+
|
570 |
+
var from = lineAtHeight(doc, top), to = lineAtHeight(doc, bottom);
|
571 |
+
// Ensure is a {from: {line, ch}, to: {line, ch}} object, and
|
572 |
+
// forces those lines into the viewport (if possible).
|
573 |
+
if (viewport && viewport.ensure) {
|
574 |
+
var ensureFrom = viewport.ensure.from.line, ensureTo = viewport.ensure.to.line;
|
575 |
+
if (ensureFrom < from) {
|
576 |
+
from = ensureFrom;
|
577 |
+
to = lineAtHeight(doc, heightAtLine(getLine(doc, ensureFrom)) + display.wrapper.clientHeight);
|
578 |
+
} else if (Math.min(ensureTo, doc.lastLine()) >= to) {
|
579 |
+
from = lineAtHeight(doc, heightAtLine(getLine(doc, ensureTo)) - display.wrapper.clientHeight);
|
580 |
+
to = ensureTo;
|
581 |
+
}
|
582 |
+
}
|
583 |
+
return {from: from, to: Math.max(to, from + 1)};
|
584 |
+
}
|
585 |
+
|
586 |
+
// LINE NUMBERS
|
587 |
+
|
588 |
+
// Re-align line numbers and gutter marks to compensate for
|
589 |
+
// horizontal scrolling.
|
590 |
+
function alignHorizontally(cm) {
|
591 |
+
var display = cm.display, view = display.view;
|
592 |
+
if (!display.alignWidgets && (!display.gutters.firstChild || !cm.options.fixedGutter)) return;
|
593 |
+
var comp = compensateForHScroll(display) - display.scroller.scrollLeft + cm.doc.scrollLeft;
|
594 |
+
var gutterW = display.gutters.offsetWidth, left = comp + "px";
|
595 |
+
for (var i = 0; i < view.length; i++) if (!view[i].hidden) {
|
596 |
+
if (cm.options.fixedGutter && view[i].gutter)
|
597 |
+
view[i].gutter.style.left = left;
|
598 |
+
var align = view[i].alignable;
|
599 |
+
if (align) for (var j = 0; j < align.length; j++)
|
600 |
+
align[j].style.left = left;
|
601 |
+
}
|
602 |
+
if (cm.options.fixedGutter)
|
603 |
+
display.gutters.style.left = (comp + gutterW) + "px";
|
604 |
+
}
|
605 |
+
|
606 |
+
// Used to ensure that the line number gutter is still the right
|
607 |
+
// size for the current document size. Returns true when an update
|
608 |
+
// is needed.
|
609 |
+
function maybeUpdateLineNumberWidth(cm) {
|
610 |
+
if (!cm.options.lineNumbers) return false;
|
611 |
+
var doc = cm.doc, last = lineNumberFor(cm.options, doc.first + doc.size - 1), display = cm.display;
|
612 |
+
if (last.length != display.lineNumChars) {
|
613 |
+
var test = display.measure.appendChild(elt("div", [elt("div", last)],
|
614 |
+
"CodeMirror-linenumber CodeMirror-gutter-elt"));
|
615 |
+
var innerW = test.firstChild.offsetWidth, padding = test.offsetWidth - innerW;
|
616 |
+
display.lineGutter.style.width = "";
|
617 |
+
display.lineNumInnerWidth = Math.max(innerW, display.lineGutter.offsetWidth - padding);
|
618 |
+
display.lineNumWidth = display.lineNumInnerWidth + padding;
|
619 |
+
display.lineNumChars = display.lineNumInnerWidth ? last.length : -1;
|
620 |
+
display.lineGutter.style.width = display.lineNumWidth + "px";
|
621 |
+
updateGutterSpace(cm);
|
622 |
+
return true;
|
623 |
+
}
|
624 |
+
return false;
|
625 |
+
}
|
626 |
+
|
627 |
+
function lineNumberFor(options, i) {
|
628 |
+
return String(options.lineNumberFormatter(i + options.firstLineNumber));
|
629 |
+
}
|
630 |
+
|
631 |
+
// Computes display.scroller.scrollLeft + display.gutters.offsetWidth,
|
632 |
+
// but using getBoundingClientRect to get a sub-pixel-accurate
|
633 |
+
// result.
|
634 |
+
function compensateForHScroll(display) {
|
635 |
+
return display.scroller.getBoundingClientRect().left - display.sizer.getBoundingClientRect().left;
|
636 |
+
}
|
637 |
+
|
638 |
+
// DISPLAY DRAWING
|
639 |
+
|
640 |
+
function DisplayUpdate(cm, viewport, force) {
|
641 |
+
var display = cm.display;
|
642 |
+
|
643 |
+
this.viewport = viewport;
|
644 |
+
// Store some values that we'll need later (but don't want to force a relayout for)
|
645 |
+
this.visible = visibleLines(display, cm.doc, viewport);
|
646 |
+
this.editorIsHidden = !display.wrapper.offsetWidth;
|
647 |
+
this.wrapperHeight = display.wrapper.clientHeight;
|
648 |
+
this.wrapperWidth = display.wrapper.clientWidth;
|
649 |
+
this.oldDisplayWidth = displayWidth(cm);
|
650 |
+
this.force = force;
|
651 |
+
this.dims = getDimensions(cm);
|
652 |
+
}
|
653 |
+
|
654 |
+
function maybeClipScrollbars(cm) {
|
655 |
+
var display = cm.display;
|
656 |
+
if (!display.scrollbarsClipped && display.scroller.offsetWidth) {
|
657 |
+
display.nativeBarWidth = display.scroller.offsetWidth - display.scroller.clientWidth;
|
658 |
+
display.heightForcer.style.height = scrollGap(cm) + "px";
|
659 |
+
display.sizer.style.marginBottom = -display.nativeBarWidth + "px";
|
660 |
+
display.sizer.style.borderRightWidth = scrollGap(cm) + "px";
|
661 |
+
display.scrollbarsClipped = true;
|
662 |
+
}
|
663 |
+
}
|
664 |
+
|
665 |
+
// Does the actual updating of the line display. Bails out
|
666 |
+
// (returning false) when there is nothing to be done and forced is
|
667 |
+
// false.
|
668 |
+
function updateDisplayIfNeeded(cm, update) {
|
669 |
+
var display = cm.display, doc = cm.doc;
|
670 |
+
|
671 |
+
if (update.editorIsHidden) {
|
672 |
+
resetView(cm);
|
673 |
+
return false;
|
674 |
+
}
|
675 |
+
|
676 |
+
// Bail out if the visible area is already rendered and nothing changed.
|
677 |
+
if (!update.force &&
|
678 |
+
update.visible.from >= display.viewFrom && update.visible.to <= display.viewTo &&
|
679 |
+
(display.updateLineNumbers == null || display.updateLineNumbers >= display.viewTo) &&
|
680 |
+
display.renderedView == display.view && countDirtyView(cm) == 0)
|
681 |
+
return false;
|
682 |
+
|
683 |
+
if (maybeUpdateLineNumberWidth(cm)) {
|
684 |
+
resetView(cm);
|
685 |
+
update.dims = getDimensions(cm);
|
686 |
+
}
|
687 |
+
|
688 |
+
// Compute a suitable new viewport (from & to)
|
689 |
+
var end = doc.first + doc.size;
|
690 |
+
var from = Math.max(update.visible.from - cm.options.viewportMargin, doc.first);
|
691 |
+
var to = Math.min(end, update.visible.to + cm.options.viewportMargin);
|
692 |
+
if (display.viewFrom < from && from - display.viewFrom < 20) from = Math.max(doc.first, display.viewFrom);
|
693 |
+
if (display.viewTo > to && display.viewTo - to < 20) to = Math.min(end, display.viewTo);
|
694 |
+
if (sawCollapsedSpans) {
|
695 |
+
from = visualLineNo(cm.doc, from);
|
696 |
+
to = visualLineEndNo(cm.doc, to);
|
697 |
+
}
|
698 |
+
|
699 |
+
var different = from != display.viewFrom || to != display.viewTo ||
|
700 |
+
display.lastWrapHeight != update.wrapperHeight || display.lastWrapWidth != update.wrapperWidth;
|
701 |
+
adjustView(cm, from, to);
|
702 |
+
|
703 |
+
display.viewOffset = heightAtLine(getLine(cm.doc, display.viewFrom));
|
704 |
+
// Position the mover div to align with the current scroll position
|
705 |
+
cm.display.mover.style.top = display.viewOffset + "px";
|
706 |
+
|
707 |
+
var toUpdate = countDirtyView(cm);
|
708 |
+
if (!different && toUpdate == 0 && !update.force && display.renderedView == display.view &&
|
709 |
+
(display.updateLineNumbers == null || display.updateLineNumbers >= display.viewTo))
|
710 |
+
return false;
|
711 |
+
|
712 |
+
// For big changes, we hide the enclosing element during the
|
713 |
+
// update, since that speeds up the operations on most browsers.
|
714 |
+
var focused = activeElt();
|
715 |
+
if (toUpdate > 4) display.lineDiv.style.display = "none";
|
716 |
+
patchDisplay(cm, display.updateLineNumbers, update.dims);
|
717 |
+
if (toUpdate > 4) display.lineDiv.style.display = "";
|
718 |
+
display.renderedView = display.view;
|
719 |
+
// There might have been a widget with a focused element that got
|
720 |
+
// hidden or updated, if so re-focus it.
|
721 |
+
if (focused && activeElt() != focused && focused.offsetHeight) focused.focus();
|
722 |
+
|
723 |
+
// Prevent selection and cursors from interfering with the scroll
|
724 |
+
// width and height.
|
725 |
+
removeChildren(display.cursorDiv);
|
726 |
+
removeChildren(display.selectionDiv);
|
727 |
+
display.gutters.style.height = 0;
|
728 |
+
|
729 |
+
if (different) {
|
730 |
+
display.lastWrapHeight = update.wrapperHeight;
|
731 |
+
display.lastWrapWidth = update.wrapperWidth;
|
732 |
+
startWorker(cm, 400);
|
733 |
+
}
|
734 |
+
|
735 |
+
display.updateLineNumbers = null;
|
736 |
+
|
737 |
+
return true;
|
738 |
+
}
|
739 |
+
|
740 |
+
function postUpdateDisplay(cm, update) {
|
741 |
+
var force = update.force, viewport = update.viewport;
|
742 |
+
for (var first = true;; first = false) {
|
743 |
+
if (first && cm.options.lineWrapping && update.oldDisplayWidth != displayWidth(cm)) {
|
744 |
+
force = true;
|
745 |
+
} else {
|
746 |
+
force = false;
|
747 |
+
// Clip forced viewport to actual scrollable area.
|
748 |
+
if (viewport && viewport.top != null)
|
749 |
+
viewport = {top: Math.min(cm.doc.height + paddingVert(cm.display) - displayHeight(cm), viewport.top)};
|
750 |
+
// Updated line heights might result in the drawn area not
|
751 |
+
// actually covering the viewport. Keep looping until it does.
|
752 |
+
update.visible = visibleLines(cm.display, cm.doc, viewport);
|
753 |
+
if (update.visible.from >= cm.display.viewFrom && update.visible.to <= cm.display.viewTo)
|
754 |
+
break;
|
755 |
+
}
|
756 |
+
if (!updateDisplayIfNeeded(cm, update)) break;
|
757 |
+
updateHeightsInViewport(cm);
|
758 |
+
var barMeasure = measureForScrollbars(cm);
|
759 |
+
updateSelection(cm);
|
760 |
+
setDocumentHeight(cm, barMeasure);
|
761 |
+
updateScrollbars(cm, barMeasure);
|
762 |
+
}
|
763 |
+
|
764 |
+
signalLater(cm, "update", cm);
|
765 |
+
if (cm.display.viewFrom != cm.display.reportedViewFrom || cm.display.viewTo != cm.display.reportedViewTo) {
|
766 |
+
signalLater(cm, "viewportChange", cm, cm.display.viewFrom, cm.display.viewTo);
|
767 |
+
cm.display.reportedViewFrom = cm.display.viewFrom; cm.display.reportedViewTo = cm.display.viewTo;
|
768 |
+
}
|
769 |
+
}
|
770 |
+
|
771 |
+
function updateDisplaySimple(cm, viewport) {
|
772 |
+
var update = new DisplayUpdate(cm, viewport);
|
773 |
+
if (updateDisplayIfNeeded(cm, update)) {
|
774 |
+
updateHeightsInViewport(cm);
|
775 |
+
postUpdateDisplay(cm, update);
|
776 |
+
var barMeasure = measureForScrollbars(cm);
|
777 |
+
updateSelection(cm);
|
778 |
+
setDocumentHeight(cm, barMeasure);
|
779 |
+
updateScrollbars(cm, barMeasure);
|
780 |
+
}
|
781 |
+
}
|
782 |
+
|
783 |
+
function setDocumentHeight(cm, measure) {
|
784 |
+
cm.display.sizer.style.minHeight = measure.docHeight + "px";
|
785 |
+
var total = measure.docHeight + cm.display.barHeight;
|
786 |
+
cm.display.heightForcer.style.top = total + "px";
|
787 |
+
cm.display.gutters.style.height = Math.max(total + scrollGap(cm), measure.clientHeight) + "px";
|
788 |
+
}
|
789 |
+
|
790 |
+
// Read the actual heights of the rendered lines, and update their
|
791 |
+
// stored heights to match.
|
792 |
+
function updateHeightsInViewport(cm) {
|
793 |
+
var display = cm.display;
|
794 |
+
var prevBottom = display.lineDiv.offsetTop;
|
795 |
+
for (var i = 0; i < display.view.length; i++) {
|
796 |
+
var cur = display.view[i], height;
|
797 |
+
if (cur.hidden) continue;
|
798 |
+
if (ie && ie_version < 8) {
|
799 |
+
var bot = cur.node.offsetTop + cur.node.offsetHeight;
|
800 |
+
height = bot - prevBottom;
|
801 |
+
prevBottom = bot;
|
802 |
+
} else {
|
803 |
+
var box = cur.node.getBoundingClientRect();
|
804 |
+
height = box.bottom - box.top;
|
805 |
+
}
|
806 |
+
var diff = cur.line.height - height;
|
807 |
+
if (height < 2) height = textHeight(display);
|
808 |
+
if (diff > .001 || diff < -.001) {
|
809 |
+
updateLineHeight(cur.line, height);
|
810 |
+
updateWidgetHeight(cur.line);
|
811 |
+
if (cur.rest) for (var j = 0; j < cur.rest.length; j++)
|
812 |
+
updateWidgetHeight(cur.rest[j]);
|
813 |
+
}
|
814 |
+
}
|
815 |
+
}
|
816 |
+
|
817 |
+
// Read and store the height of line widgets associated with the
|
818 |
+
// given line.
|
819 |
+
function updateWidgetHeight(line) {
|
820 |
+
if (line.widgets) for (var i = 0; i < line.widgets.length; ++i)
|
821 |
+
line.widgets[i].height = line.widgets[i].node.offsetHeight;
|
822 |
+
}
|
823 |
+
|
824 |
+
// Do a bulk-read of the DOM positions and sizes needed to draw the
|
825 |
+
// view, so that we don't interleave reading and writing to the DOM.
|
826 |
+
function getDimensions(cm) {
|
827 |
+
var d = cm.display, left = {}, width = {};
|
828 |
+
var gutterLeft = d.gutters.clientLeft;
|
829 |
+
for (var n = d.gutters.firstChild, i = 0; n; n = n.nextSibling, ++i) {
|
830 |
+
left[cm.options.gutters[i]] = n.offsetLeft + n.clientLeft + gutterLeft;
|
831 |
+
width[cm.options.gutters[i]] = n.clientWidth;
|
832 |
+
}
|
833 |
+
return {fixedPos: compensateForHScroll(d),
|
834 |
+
gutterTotalWidth: d.gutters.offsetWidth,
|
835 |
+
gutterLeft: left,
|
836 |
+
gutterWidth: width,
|
837 |
+
wrapperWidth: d.wrapper.clientWidth};
|
838 |
+
}
|
839 |
+
|
840 |
+
// Sync the actual display DOM structure with display.view, removing
|
841 |
+
// nodes for lines that are no longer in view, and creating the ones
|
842 |
+
// that are not there yet, and updating the ones that are out of
|
843 |
+
// date.
|
844 |
+
function patchDisplay(cm, updateNumbersFrom, dims) {
|
845 |
+
var display = cm.display, lineNumbers = cm.options.lineNumbers;
|
846 |
+
var container = display.lineDiv, cur = container.firstChild;
|
847 |
+
|
848 |
+
function rm(node) {
|
849 |
+
var next = node.nextSibling;
|
850 |
+
// Works around a throw-scroll bug in OS X Webkit
|
851 |
+
if (webkit && mac && cm.display.currentWheelTarget == node)
|
852 |
+
node.style.display = "none";
|
853 |
+
else
|
854 |
+
node.parentNode.removeChild(node);
|
855 |
+
return next;
|
856 |
+
}
|
857 |
+
|
858 |
+
var view = display.view, lineN = display.viewFrom;
|
859 |
+
// Loop over the elements in the view, syncing cur (the DOM nodes
|
860 |
+
// in display.lineDiv) with the view as we go.
|
861 |
+
for (var i = 0; i < view.length; i++) {
|
862 |
+
var lineView = view[i];
|
863 |
+
if (lineView.hidden) {
|
864 |
+
} else if (!lineView.node) { // Not drawn yet
|
865 |
+
var node = buildLineElement(cm, lineView, lineN, dims);
|
866 |
+
container.insertBefore(node, cur);
|
867 |
+
} else { // Already drawn
|
868 |
+
while (cur != lineView.node) cur = rm(cur);
|
869 |
+
var updateNumber = lineNumbers && updateNumbersFrom != null &&
|
870 |
+
updateNumbersFrom <= lineN && lineView.lineNumber;
|
871 |
+
if (lineView.changes) {
|
872 |
+
if (indexOf(lineView.changes, "gutter") > -1) updateNumber = false;
|
873 |
+
updateLineForChanges(cm, lineView, lineN, dims);
|
874 |
+
}
|
875 |
+
if (updateNumber) {
|
876 |
+
removeChildren(lineView.lineNumber);
|
877 |
+
lineView.lineNumber.appendChild(document.createTextNode(lineNumberFor(cm.options, lineN)));
|
878 |
+
}
|
879 |
+
cur = lineView.node.nextSibling;
|
880 |
+
}
|
881 |
+
lineN += lineView.size;
|
882 |
+
}
|
883 |
+
while (cur) cur = rm(cur);
|
884 |
+
}
|
885 |
+
|
886 |
+
// When an aspect of a line changes, a string is added to
|
887 |
+
// lineView.changes. This updates the relevant part of the line's
|
888 |
+
// DOM structure.
|
889 |
+
function updateLineForChanges(cm, lineView, lineN, dims) {
|
890 |
+
for (var j = 0; j < lineView.changes.length; j++) {
|
891 |
+
var type = lineView.changes[j];
|
892 |
+
if (type == "text") updateLineText(cm, lineView);
|
893 |
+
else if (type == "gutter") updateLineGutter(cm, lineView, lineN, dims);
|
894 |
+
else if (type == "class") updateLineClasses(lineView);
|
895 |
+
else if (type == "widget") updateLineWidgets(lineView, dims);
|
896 |
+
}
|
897 |
+
lineView.changes = null;
|
898 |
+
}
|
899 |
+
|
900 |
+
// Lines with gutter elements, widgets or a background class need to
|
901 |
+
// be wrapped, and have the extra elements added to the wrapper div
|
902 |
+
function ensureLineWrapped(lineView) {
|
903 |
+
if (lineView.node == lineView.text) {
|
904 |
+
lineView.node = elt("div", null, null, "position: relative");
|
905 |
+
if (lineView.text.parentNode)
|
906 |
+
lineView.text.parentNode.replaceChild(lineView.node, lineView.text);
|
907 |
+
lineView.node.appendChild(lineView.text);
|
908 |
+
if (ie && ie_version < 8) lineView.node.style.zIndex = 2;
|
909 |
+
}
|
910 |
+
return lineView.node;
|
911 |
+
}
|
912 |
+
|
913 |
+
function updateLineBackground(lineView) {
|
914 |
+
var cls = lineView.bgClass ? lineView.bgClass + " " + (lineView.line.bgClass || "") : lineView.line.bgClass;
|
915 |
+
if (cls) cls += " CodeMirror-linebackground";
|
916 |
+
if (lineView.background) {
|
917 |
+
if (cls) lineView.background.className = cls;
|
918 |
+
else { lineView.background.parentNode.removeChild(lineView.background); lineView.background = null; }
|
919 |
+
} else if (cls) {
|
920 |
+
var wrap = ensureLineWrapped(lineView);
|
921 |
+
lineView.background = wrap.insertBefore(elt("div", null, cls), wrap.firstChild);
|
922 |
+
}
|
923 |
+
}
|
924 |
+
|
925 |
+
// Wrapper around buildLineContent which will reuse the structure
|
926 |
+
// in display.externalMeasured when possible.
|
927 |
+
function getLineContent(cm, lineView) {
|
928 |
+
var ext = cm.display.externalMeasured;
|
929 |
+
if (ext && ext.line == lineView.line) {
|
930 |
+
cm.display.externalMeasured = null;
|
931 |
+
lineView.measure = ext.measure;
|
932 |
+
return ext.built;
|
933 |
+
}
|
934 |
+
return buildLineContent(cm, lineView);
|
935 |
+
}
|
936 |
+
|
937 |
+
// Redraw the line's text. Interacts with the background and text
|
938 |
+
// classes because the mode may output tokens that influence these
|
939 |
+
// classes.
|
940 |
+
function updateLineText(cm, lineView) {
|
941 |
+
var cls = lineView.text.className;
|
942 |
+
var built = getLineContent(cm, lineView);
|
943 |
+
if (lineView.text == lineView.node) lineView.node = built.pre;
|
944 |
+
lineView.text.parentNode.replaceChild(built.pre, lineView.text);
|
945 |
+
lineView.text = built.pre;
|
946 |
+
if (built.bgClass != lineView.bgClass || built.textClass != lineView.textClass) {
|
947 |
+
lineView.bgClass = built.bgClass;
|
948 |
+
lineView.textClass = built.textClass;
|
949 |
+
updateLineClasses(lineView);
|
950 |
+
} else if (cls) {
|
951 |
+
lineView.text.className = cls;
|
952 |
+
}
|
953 |
+
}
|
954 |
+
|
955 |
+
function updateLineClasses(lineView) {
|
956 |
+
updateLineBackground(lineView);
|
957 |
+
if (lineView.line.wrapClass)
|
958 |
+
ensureLineWrapped(lineView).className = lineView.line.wrapClass;
|
959 |
+
else if (lineView.node != lineView.text)
|
960 |
+
lineView.node.className = "";
|
961 |
+
var textClass = lineView.textClass ? lineView.textClass + " " + (lineView.line.textClass || "") : lineView.line.textClass;
|
962 |
+
lineView.text.className = textClass || "";
|
963 |
+
}
|
964 |
+
|
965 |
+
function updateLineGutter(cm, lineView, lineN, dims) {
|
966 |
+
if (lineView.gutter) {
|
967 |
+
lineView.node.removeChild(lineView.gutter);
|
968 |
+
lineView.gutter = null;
|
969 |
+
}
|
970 |
+
var markers = lineView.line.gutterMarkers;
|
971 |
+
if (cm.options.lineNumbers || markers) {
|
972 |
+
var wrap = ensureLineWrapped(lineView);
|
973 |
+
var gutterWrap = lineView.gutter =
|
974 |
+
wrap.insertBefore(elt("div", null, "CodeMirror-gutter-wrapper", "left: " +
|
975 |
+
(cm.options.fixedGutter ? dims.fixedPos : -dims.gutterTotalWidth) +
|
976 |
+
"px; width: " + dims.gutterTotalWidth + "px"),
|
977 |
+
lineView.text);
|
978 |
+
if (lineView.line.gutterClass)
|
979 |
+
gutterWrap.className += " " + lineView.line.gutterClass;
|
980 |
+
if (cm.options.lineNumbers && (!markers || !markers["CodeMirror-linenumbers"]))
|
981 |
+
lineView.lineNumber = gutterWrap.appendChild(
|
982 |
+
elt("div", lineNumberFor(cm.options, lineN),
|
983 |
+
"CodeMirror-linenumber CodeMirror-gutter-elt",
|
984 |
+
"left: " + dims.gutterLeft["CodeMirror-linenumbers"] + "px; width: "
|
985 |
+
+ cm.display.lineNumInnerWidth + "px"));
|
986 |
+
if (markers) for (var k = 0; k < cm.options.gutters.length; ++k) {
|
987 |
+
var id = cm.options.gutters[k], found = markers.hasOwnProperty(id) && markers[id];
|
988 |
+
if (found)
|
989 |
+
gutterWrap.appendChild(elt("div", [found], "CodeMirror-gutter-elt", "left: " +
|
990 |
+
dims.gutterLeft[id] + "px; width: " + dims.gutterWidth[id] + "px"));
|
991 |
+
}
|
992 |
+
}
|
993 |
+
}
|
994 |
+
|
995 |
+
function updateLineWidgets(lineView, dims) {
|
996 |
+
if (lineView.alignable) lineView.alignable = null;
|
997 |
+
for (var node = lineView.node.firstChild, next; node; node = next) {
|
998 |
+
var next = node.nextSibling;
|
999 |
+
if (node.className == "CodeMirror-linewidget")
|
1000 |
+
lineView.node.removeChild(node);
|
1001 |
+
}
|
1002 |
+
insertLineWidgets(lineView, dims);
|
1003 |
+
}
|
1004 |
+
|
1005 |
+
// Build a line's DOM representation from scratch
|
1006 |
+
function buildLineElement(cm, lineView, lineN, dims) {
|
1007 |
+
var built = getLineContent(cm, lineView);
|
1008 |
+
lineView.text = lineView.node = built.pre;
|
1009 |
+
if (built.bgClass) lineView.bgClass = built.bgClass;
|
1010 |
+
if (built.textClass) lineView.textClass = built.textClass;
|
1011 |
+
|
1012 |
+
updateLineClasses(lineView);
|
1013 |
+
updateLineGutter(cm, lineView, lineN, dims);
|
1014 |
+
insertLineWidgets(lineView, dims);
|
1015 |
+
return lineView.node;
|
1016 |
+
}
|
1017 |
+
|
1018 |
+
// A lineView may contain multiple logical lines (when merged by
|
1019 |
+
// collapsed spans). The widgets for all of them need to be drawn.
|
1020 |
+
function insertLineWidgets(lineView, dims) {
|
1021 |
+
insertLineWidgetsFor(lineView.line, lineView, dims, true);
|
1022 |
+
if (lineView.rest) for (var i = 0; i < lineView.rest.length; i++)
|
1023 |
+
insertLineWidgetsFor(lineView.rest[i], lineView, dims, false);
|
1024 |
+
}
|
1025 |
+
|
1026 |
+
function insertLineWidgetsFor(line, lineView, dims, allowAbove) {
|
1027 |
+
if (!line.widgets) return;
|
1028 |
+
var wrap = ensureLineWrapped(lineView);
|
1029 |
+
for (var i = 0, ws = line.widgets; i < ws.length; ++i) {
|
1030 |
+
var widget = ws[i], node = elt("div", [widget.node], "CodeMirror-linewidget");
|
1031 |
+
if (!widget.handleMouseEvents) node.setAttribute("cm-ignore-events", "true");
|
1032 |
+
positionLineWidget(widget, node, lineView, dims);
|
1033 |
+
if (allowAbove && widget.above)
|
1034 |
+
wrap.insertBefore(node, lineView.gutter || lineView.text);
|
1035 |
+
else
|
1036 |
+
wrap.appendChild(node);
|
1037 |
+
signalLater(widget, "redraw");
|
1038 |
+
}
|
1039 |
+
}
|
1040 |
+
|
1041 |
+
function positionLineWidget(widget, node, lineView, dims) {
|
1042 |
+
if (widget.noHScroll) {
|
1043 |
+
(lineView.alignable || (lineView.alignable = [])).push(node);
|
1044 |
+
var width = dims.wrapperWidth;
|
1045 |
+
node.style.left = dims.fixedPos + "px";
|
1046 |
+
if (!widget.coverGutter) {
|
1047 |
+
width -= dims.gutterTotalWidth;
|
1048 |
+
node.style.paddingLeft = dims.gutterTotalWidth + "px";
|
1049 |
+
}
|
1050 |
+
node.style.width = width + "px";
|
1051 |
+
}
|
1052 |
+
if (widget.coverGutter) {
|
1053 |
+
node.style.zIndex = 5;
|
1054 |
+
node.style.position = "relative";
|
1055 |
+
if (!widget.noHScroll) node.style.marginLeft = -dims.gutterTotalWidth + "px";
|
1056 |
+
}
|
1057 |
+
}
|
1058 |
+
|
1059 |
+
// POSITION OBJECT
|
1060 |
+
|
1061 |
+
// A Pos instance represents a position within the text.
|
1062 |
+
var Pos = CodeMirror.Pos = function(line, ch) {
|
1063 |
+
if (!(this instanceof Pos)) return new Pos(line, ch);
|
1064 |
+
this.line = line; this.ch = ch;
|
1065 |
+
};
|
1066 |
+
|
1067 |
+
// Compare two positions, return 0 if they are the same, a negative
|
1068 |
+
// number when a is less, and a positive number otherwise.
|
1069 |
+
var cmp = CodeMirror.cmpPos = function(a, b) { return a.line - b.line || a.ch - b.ch; };
|
1070 |
+
|
1071 |
+
function copyPos(x) {return Pos(x.line, x.ch);}
|
1072 |
+
function maxPos(a, b) { return cmp(a, b) < 0 ? b : a; }
|
1073 |
+
function minPos(a, b) { return cmp(a, b) < 0 ? a : b; }
|
1074 |
+
|
1075 |
+
// SELECTION / CURSOR
|
1076 |
+
|
1077 |
+
// Selection objects are immutable. A new one is created every time
|
1078 |
+
// the selection changes. A selection is one or more non-overlapping
|
1079 |
+
// (and non-touching) ranges, sorted, and an integer that indicates
|
1080 |
+
// which one is the primary selection (the one that's scrolled into
|
1081 |
+
// view, that getCursor returns, etc).
|
1082 |
+
function Selection(ranges, primIndex) {
|
1083 |
+
this.ranges = ranges;
|
1084 |
+
this.primIndex = primIndex;
|
1085 |
+
}
|
1086 |
+
|
1087 |
+
Selection.prototype = {
|
1088 |
+
primary: function() { return this.ranges[this.primIndex]; },
|
1089 |
+
equals: function(other) {
|
1090 |
+
if (other == this) return true;
|
1091 |
+
if (other.primIndex != this.primIndex || other.ranges.length != this.ranges.length) return false;
|
1092 |
+
for (var i = 0; i < this.ranges.length; i++) {
|
1093 |
+
var here = this.ranges[i], there = other.ranges[i];
|
1094 |
+
if (cmp(here.anchor, there.anchor) != 0 || cmp(here.head, there.head) != 0) return false;
|
1095 |
+
}
|
1096 |
+
return true;
|
1097 |
+
},
|
1098 |
+
deepCopy: function() {
|
1099 |
+
for (var out = [], i = 0; i < this.ranges.length; i++)
|
1100 |
+
out[i] = new Range(copyPos(this.ranges[i].anchor), copyPos(this.ranges[i].head));
|
1101 |
+
return new Selection(out, this.primIndex);
|
1102 |
+
},
|
1103 |
+
somethingSelected: function() {
|
1104 |
+
for (var i = 0; i < this.ranges.length; i++)
|
1105 |
+
if (!this.ranges[i].empty()) return true;
|
1106 |
+
return false;
|
1107 |
+
},
|
1108 |
+
contains: function(pos, end) {
|
1109 |
+
if (!end) end = pos;
|
1110 |
+
for (var i = 0; i < this.ranges.length; i++) {
|
1111 |
+
var range = this.ranges[i];
|
1112 |
+
if (cmp(end, range.from()) >= 0 && cmp(pos, range.to()) <= 0)
|
1113 |
+
return i;
|
1114 |
+
}
|
1115 |
+
return -1;
|
1116 |
+
}
|
1117 |
+
};
|
1118 |
+
|
1119 |
+
function Range(anchor, head) {
|
1120 |
+
this.anchor = anchor; this.head = head;
|
1121 |
+
}
|
1122 |
+
|
1123 |
+
Range.prototype = {
|
1124 |
+
from: function() { return minPos(this.anchor, this.head); },
|
1125 |
+
to: function() { return maxPos(this.anchor, this.head); },
|
1126 |
+
empty: function() {
|
1127 |
+
return this.head.line == this.anchor.line && this.head.ch == this.anchor.ch;
|
1128 |
+
}
|
1129 |
+
};
|
1130 |
+
|
1131 |
+
// Take an unsorted, potentially overlapping set of ranges, and
|
1132 |
+
// build a selection out of it. 'Consumes' ranges array (modifying
|
1133 |
+
// it).
|
1134 |
+
function normalizeSelection(ranges, primIndex) {
|
1135 |
+
var prim = ranges[primIndex];
|
1136 |
+
ranges.sort(function(a, b) { return cmp(a.from(), b.from()); });
|
1137 |
+
primIndex = indexOf(ranges, prim);
|
1138 |
+
for (var i = 1; i < ranges.length; i++) {
|
1139 |
+
var cur = ranges[i], prev = ranges[i - 1];
|
1140 |
+
if (cmp(prev.to(), cur.from()) >= 0) {
|
1141 |
+
var from = minPos(prev.from(), cur.from()), to = maxPos(prev.to(), cur.to());
|
1142 |
+
var inv = prev.empty() ? cur.from() == cur.head : prev.from() == prev.head;
|
1143 |
+
if (i <= primIndex) --primIndex;
|
1144 |
+
ranges.splice(--i, 2, new Range(inv ? to : from, inv ? from : to));
|
1145 |
+
}
|
1146 |
+
}
|
1147 |
+
return new Selection(ranges, primIndex);
|
1148 |
+
}
|
1149 |
+
|
1150 |
+
function simpleSelection(anchor, head) {
|
1151 |
+
return new Selection([new Range(anchor, head || anchor)], 0);
|
1152 |
+
}
|
1153 |
+
|
1154 |
+
// Most of the external API clips given positions to make sure they
|
1155 |
+
// actually exist within the document.
|
1156 |
+
function clipLine(doc, n) {return Math.max(doc.first, Math.min(n, doc.first + doc.size - 1));}
|
1157 |
+
function clipPos(doc, pos) {
|
1158 |
+
if (pos.line < doc.first) return Pos(doc.first, 0);
|
1159 |
+
var last = doc.first + doc.size - 1;
|
1160 |
+
if (pos.line > last) return Pos(last, getLine(doc, last).text.length);
|
1161 |
+
return clipToLen(pos, getLine(doc, pos.line).text.length);
|
1162 |
+
}
|
1163 |
+
function clipToLen(pos, linelen) {
|
1164 |
+
var ch = pos.ch;
|
1165 |
+
if (ch == null || ch > linelen) return Pos(pos.line, linelen);
|
1166 |
+
else if (ch < 0) return Pos(pos.line, 0);
|
1167 |
+
else return pos;
|
1168 |
+
}
|
1169 |
+
function isLine(doc, l) {return l >= doc.first && l < doc.first + doc.size;}
|
1170 |
+
function clipPosArray(doc, array) {
|
1171 |
+
for (var out = [], i = 0; i < array.length; i++) out[i] = clipPos(doc, array[i]);
|
1172 |
+
return out;
|
1173 |
+
}
|
1174 |
+
|
1175 |
+
// SELECTION UPDATES
|
1176 |
+
|
1177 |
+
// The 'scroll' parameter given to many of these indicated whether
|
1178 |
+
// the new cursor position should be scrolled into view after
|
1179 |
+
// modifying the selection.
|
1180 |
+
|
1181 |
+
// If shift is held or the extend flag is set, extends a range to
|
1182 |
+
// include a given position (and optionally a second position).
|
1183 |
+
// Otherwise, simply returns the range between the given positions.
|
1184 |
+
// Used for cursor motion and such.
|
1185 |
+
function extendRange(doc, range, head, other) {
|
1186 |
+
if (doc.cm && doc.cm.display.shift || doc.extend) {
|
1187 |
+
var anchor = range.anchor;
|
1188 |
+
if (other) {
|
1189 |
+
var posBefore = cmp(head, anchor) < 0;
|
1190 |
+
if (posBefore != (cmp(other, anchor) < 0)) {
|
1191 |
+
anchor = head;
|
1192 |
+
head = other;
|
1193 |
+
} else if (posBefore != (cmp(head, other) < 0)) {
|
1194 |
+
head = other;
|
1195 |
+
}
|
1196 |
+
}
|
1197 |
+
return new Range(anchor, head);
|
1198 |
+
} else {
|
1199 |
+
return new Range(other || head, head);
|
1200 |
+
}
|
1201 |
+
}
|
1202 |
+
|
1203 |
+
// Extend the primary selection range, discard the rest.
|
1204 |
+
function extendSelection(doc, head, other, options) {
|
1205 |
+
setSelection(doc, new Selection([extendRange(doc, doc.sel.primary(), head, other)], 0), options);
|
1206 |
+
}
|
1207 |
+
|
1208 |
+
// Extend all selections (pos is an array of selections with length
|
1209 |
+
// equal the number of selections)
|
1210 |
+
function extendSelections(doc, heads, options) {
|
1211 |
+
for (var out = [], i = 0; i < doc.sel.ranges.length; i++)
|
1212 |
+
out[i] = extendRange(doc, doc.sel.ranges[i], heads[i], null);
|
1213 |
+
var newSel = normalizeSelection(out, doc.sel.primIndex);
|
1214 |
+
setSelection(doc, newSel, options);
|
1215 |
+
}
|
1216 |
+
|
1217 |
+
// Updates a single range in the selection.
|
1218 |
+
function replaceOneSelection(doc, i, range, options) {
|
1219 |
+
var ranges = doc.sel.ranges.slice(0);
|
1220 |
+
ranges[i] = range;
|
1221 |
+
setSelection(doc, normalizeSelection(ranges, doc.sel.primIndex), options);
|
1222 |
+
}
|
1223 |
+
|
1224 |
+
// Reset the selection to a single range.
|
1225 |
+
function setSimpleSelection(doc, anchor, head, options) {
|
1226 |
+
setSelection(doc, simpleSelection(anchor, head), options);
|
1227 |
+
}
|
1228 |
+
|
1229 |
+
// Give beforeSelectionChange handlers a change to influence a
|
1230 |
+
// selection update.
|
1231 |
+
function filterSelectionChange(doc, sel) {
|
1232 |
+
var obj = {
|
1233 |
+
ranges: sel.ranges,
|
1234 |
+
update: function(ranges) {
|
1235 |
+
this.ranges = [];
|
1236 |
+
for (var i = 0; i < ranges.length; i++)
|
1237 |
+
this.ranges[i] = new Range(clipPos(doc, ranges[i].anchor),
|
1238 |
+
clipPos(doc, ranges[i].head));
|
1239 |
+
}
|
1240 |
+
};
|
1241 |
+
signal(doc, "beforeSelectionChange", doc, obj);
|
1242 |
+
if (doc.cm) signal(doc.cm, "beforeSelectionChange", doc.cm, obj);
|
1243 |
+
if (obj.ranges != sel.ranges) return normalizeSelection(obj.ranges, obj.ranges.length - 1);
|
1244 |
+
else return sel;
|
1245 |
+
}
|
1246 |
+
|
1247 |
+
function setSelectionReplaceHistory(doc, sel, options) {
|
1248 |
+
var done = doc.history.done, last = lst(done);
|
1249 |
+
if (last && last.ranges) {
|
1250 |
+
done[done.length - 1] = sel;
|
1251 |
+
setSelectionNoUndo(doc, sel, options);
|
1252 |
+
} else {
|
1253 |
+
setSelection(doc, sel, options);
|
1254 |
+
}
|
1255 |
+
}
|
1256 |
+
|
1257 |
+
// Set a new selection.
|
1258 |
+
function setSelection(doc, sel, options) {
|
1259 |
+
setSelectionNoUndo(doc, sel, options);
|
1260 |
+
addSelectionToHistory(doc, doc.sel, doc.cm ? doc.cm.curOp.id : NaN, options);
|
1261 |
+
}
|
1262 |
+
|
1263 |
+
function setSelectionNoUndo(doc, sel, options) {
|
1264 |
+
if (hasHandler(doc, "beforeSelectionChange") || doc.cm && hasHandler(doc.cm, "beforeSelectionChange"))
|
1265 |
+
sel = filterSelectionChange(doc, sel);
|
1266 |
+
|
1267 |
+
var bias = options && options.bias ||
|
1268 |
+
(cmp(sel.primary().head, doc.sel.primary().head) < 0 ? -1 : 1);
|
1269 |
+
setSelectionInner(doc, skipAtomicInSelection(doc, sel, bias, true));
|
1270 |
+
|
1271 |
+
if (!(options && options.scroll === false) && doc.cm)
|
1272 |
+
ensureCursorVisible(doc.cm);
|
1273 |
+
}
|
1274 |
+
|
1275 |
+
function setSelectionInner(doc, sel) {
|
1276 |
+
if (sel.equals(doc.sel)) return;
|
1277 |
+
|
1278 |
+
doc.sel = sel;
|
1279 |
+
|
1280 |
+
if (doc.cm) {
|
1281 |
+
doc.cm.curOp.updateInput = doc.cm.curOp.selectionChanged = true;
|
1282 |
+
signalCursorActivity(doc.cm);
|
1283 |
+
}
|
1284 |
+
signalLater(doc, "cursorActivity", doc);
|
1285 |
+
}
|
1286 |
+
|
1287 |
+
// Verify that the selection does not partially select any atomic
|
1288 |
+
// marked ranges.
|
1289 |
+
function reCheckSelection(doc) {
|
1290 |
+
setSelectionInner(doc, skipAtomicInSelection(doc, doc.sel, null, false), sel_dontScroll);
|
1291 |
+
}
|
1292 |
+
|
1293 |
+
// Return a selection that does not partially select any atomic
|
1294 |
+
// ranges.
|
1295 |
+
function skipAtomicInSelection(doc, sel, bias, mayClear) {
|
1296 |
+
var out;
|
1297 |
+
for (var i = 0; i < sel.ranges.length; i++) {
|
1298 |
+
var range = sel.ranges[i];
|
1299 |
+
var newAnchor = skipAtomic(doc, range.anchor, bias, mayClear);
|
1300 |
+
var newHead = skipAtomic(doc, range.head, bias, mayClear);
|
1301 |
+
if (out || newAnchor != range.anchor || newHead != range.head) {
|
1302 |
+
if (!out) out = sel.ranges.slice(0, i);
|
1303 |
+
out[i] = new Range(newAnchor, newHead);
|
1304 |
+
}
|
1305 |
+
}
|
1306 |
+
return out ? normalizeSelection(out, sel.primIndex) : sel;
|
1307 |
+
}
|
1308 |
+
|
1309 |
+
// Ensure a given position is not inside an atomic range.
|
1310 |
+
function skipAtomic(doc, pos, bias, mayClear) {
|
1311 |
+
var flipped = false, curPos = pos;
|
1312 |
+
var dir = bias || 1;
|
1313 |
+
doc.cantEdit = false;
|
1314 |
+
search: for (;;) {
|
1315 |
+
var line = getLine(doc, curPos.line);
|
1316 |
+
if (line.markedSpans) {
|
1317 |
+
for (var i = 0; i < line.markedSpans.length; ++i) {
|
1318 |
+
var sp = line.markedSpans[i], m = sp.marker;
|
1319 |
+
if ((sp.from == null || (m.inclusiveLeft ? sp.from <= curPos.ch : sp.from < curPos.ch)) &&
|
1320 |
+
(sp.to == null || (m.inclusiveRight ? sp.to >= curPos.ch : sp.to > curPos.ch))) {
|
1321 |
+
if (mayClear) {
|
1322 |
+
signal(m, "beforeCursorEnter");
|
1323 |
+
if (m.explicitlyCleared) {
|
1324 |
+
if (!line.markedSpans) break;
|
1325 |
+
else {--i; continue;}
|
1326 |
+
}
|
1327 |
+
}
|
1328 |
+
if (!m.atomic) continue;
|
1329 |
+
var newPos = m.find(dir < 0 ? -1 : 1);
|
1330 |
+
if (cmp(newPos, curPos) == 0) {
|
1331 |
+
newPos.ch += dir;
|
1332 |
+
if (newPos.ch < 0) {
|
1333 |
+
if (newPos.line > doc.first) newPos = clipPos(doc, Pos(newPos.line - 1));
|
1334 |
+
else newPos = null;
|
1335 |
+
} else if (newPos.ch > line.text.length) {
|
1336 |
+
if (newPos.line < doc.first + doc.size - 1) newPos = Pos(newPos.line + 1, 0);
|
1337 |
+
else newPos = null;
|
1338 |
+
}
|
1339 |
+
if (!newPos) {
|
1340 |
+
if (flipped) {
|
1341 |
+
// Driven in a corner -- no valid cursor position found at all
|
1342 |
+
// -- try again *with* clearing, if we didn't already
|
1343 |
+
if (!mayClear) return skipAtomic(doc, pos, bias, true);
|
1344 |
+
// Otherwise, turn off editing until further notice, and return the start of the doc
|
1345 |
+
doc.cantEdit = true;
|
1346 |
+
return Pos(doc.first, 0);
|
1347 |
+
}
|
1348 |
+
flipped = true; newPos = pos; dir = -dir;
|
1349 |
+
}
|
1350 |
+
}
|
1351 |
+
curPos = newPos;
|
1352 |
+
continue search;
|
1353 |
+
}
|
1354 |
+
}
|
1355 |
+
}
|
1356 |
+
return curPos;
|
1357 |
+
}
|
1358 |
+
}
|
1359 |
+
|
1360 |
+
// SELECTION DRAWING
|
1361 |
+
|
1362 |
+
// Redraw the selection and/or cursor
|
1363 |
+
function drawSelection(cm) {
|
1364 |
+
var display = cm.display, doc = cm.doc, result = {};
|
1365 |
+
var curFragment = result.cursors = document.createDocumentFragment();
|
1366 |
+
var selFragment = result.selection = document.createDocumentFragment();
|
1367 |
+
|
1368 |
+
for (var i = 0; i < doc.sel.ranges.length; i++) {
|
1369 |
+
var range = doc.sel.ranges[i];
|
1370 |
+
var collapsed = range.empty();
|
1371 |
+
if (collapsed || cm.options.showCursorWhenSelecting)
|
1372 |
+
drawSelectionCursor(cm, range, curFragment);
|
1373 |
+
if (!collapsed)
|
1374 |
+
drawSelectionRange(cm, range, selFragment);
|
1375 |
+
}
|
1376 |
+
|
1377 |
+
// Move the hidden textarea near the cursor to prevent scrolling artifacts
|
1378 |
+
if (cm.options.moveInputWithCursor) {
|
1379 |
+
var headPos = cursorCoords(cm, doc.sel.primary().head, "div");
|
1380 |
+
var wrapOff = display.wrapper.getBoundingClientRect(), lineOff = display.lineDiv.getBoundingClientRect();
|
1381 |
+
result.teTop = Math.max(0, Math.min(display.wrapper.clientHeight - 10,
|
1382 |
+
headPos.top + lineOff.top - wrapOff.top));
|
1383 |
+
result.teLeft = Math.max(0, Math.min(display.wrapper.clientWidth - 10,
|
1384 |
+
headPos.left + lineOff.left - wrapOff.left));
|
1385 |
+
}
|
1386 |
+
|
1387 |
+
return result;
|
1388 |
+
}
|
1389 |
+
|
1390 |
+
function showSelection(cm, drawn) {
|
1391 |
+
removeChildrenAndAdd(cm.display.cursorDiv, drawn.cursors);
|
1392 |
+
removeChildrenAndAdd(cm.display.selectionDiv, drawn.selection);
|
1393 |
+
if (drawn.teTop != null) {
|
1394 |
+
cm.display.inputDiv.style.top = drawn.teTop + "px";
|
1395 |
+
cm.display.inputDiv.style.left = drawn.teLeft + "px";
|
1396 |
+
}
|
1397 |
+
}
|
1398 |
+
|
1399 |
+
function updateSelection(cm) {
|
1400 |
+
showSelection(cm, drawSelection(cm));
|
1401 |
+
}
|
1402 |
+
|
1403 |
+
// Draws a cursor for the given range
|
1404 |
+
function drawSelectionCursor(cm, range, output) {
|
1405 |
+
var pos = cursorCoords(cm, range.head, "div", null, null, !cm.options.singleCursorHeightPerLine);
|
1406 |
+
|
1407 |
+
var cursor = output.appendChild(elt("div", "\u00a0", "CodeMirror-cursor"));
|
1408 |
+
cursor.style.left = pos.left + "px";
|
1409 |
+
cursor.style.top = pos.top + "px";
|
1410 |
+
cursor.style.height = Math.max(0, pos.bottom - pos.top) * cm.options.cursorHeight + "px";
|
1411 |
+
|
1412 |
+
if (pos.other) {
|
1413 |
+
// Secondary cursor, shown when on a 'jump' in bi-directional text
|
1414 |
+
var otherCursor = output.appendChild(elt("div", "\u00a0", "CodeMirror-cursor CodeMirror-secondarycursor"));
|
1415 |
+
otherCursor.style.display = "";
|
1416 |
+
otherCursor.style.left = pos.other.left + "px";
|
1417 |
+
otherCursor.style.top = pos.other.top + "px";
|
1418 |
+
otherCursor.style.height = (pos.other.bottom - pos.other.top) * .85 + "px";
|
1419 |
+
}
|
1420 |
+
}
|
1421 |
+
|
1422 |
+
// Draws the given range as a highlighted selection
|
1423 |
+
function drawSelectionRange(cm, range, output) {
|
1424 |
+
var display = cm.display, doc = cm.doc;
|
1425 |
+
var fragment = document.createDocumentFragment();
|
1426 |
+
var padding = paddingH(cm.display), leftSide = padding.left;
|
1427 |
+
var rightSide = Math.max(display.sizerWidth, displayWidth(cm) - display.sizer.offsetLeft) - padding.right;
|
1428 |
+
|
1429 |
+
function add(left, top, width, bottom) {
|
1430 |
+
if (top < 0) top = 0;
|
1431 |
+
top = Math.round(top);
|
1432 |
+
bottom = Math.round(bottom);
|
1433 |
+
fragment.appendChild(elt("div", null, "CodeMirror-selected", "position: absolute; left: " + left +
|
1434 |
+
"px; top: " + top + "px; width: " + (width == null ? rightSide - left : width) +
|
1435 |
+
"px; height: " + (bottom - top) + "px"));
|
1436 |
+
}
|
1437 |
+
|
1438 |
+
function drawForLine(line, fromArg, toArg) {
|
1439 |
+
var lineObj = getLine(doc, line);
|
1440 |
+
var lineLen = lineObj.text.length;
|
1441 |
+
var start, end;
|
1442 |
+
function coords(ch, bias) {
|
1443 |
+
return charCoords(cm, Pos(line, ch), "div", lineObj, bias);
|
1444 |
+
}
|
1445 |
+
|
1446 |
+
iterateBidiSections(getOrder(lineObj), fromArg || 0, toArg == null ? lineLen : toArg, function(from, to, dir) {
|
1447 |
+
var leftPos = coords(from, "left"), rightPos, left, right;
|
1448 |
+
if (from == to) {
|
1449 |
+
rightPos = leftPos;
|
1450 |
+
left = right = leftPos.left;
|
1451 |
+
} else {
|
1452 |
+
rightPos = coords(to - 1, "right");
|
1453 |
+
if (dir == "rtl") { var tmp = leftPos; leftPos = rightPos; rightPos = tmp; }
|
1454 |
+
left = leftPos.left;
|
1455 |
+
right = rightPos.right;
|
1456 |
+
}
|
1457 |
+
if (fromArg == null && from == 0) left = leftSide;
|
1458 |
+
if (rightPos.top - leftPos.top > 3) { // Different lines, draw top part
|
1459 |
+
add(left, leftPos.top, null, leftPos.bottom);
|
1460 |
+
left = leftSide;
|
1461 |
+
if (leftPos.bottom < rightPos.top) add(left, leftPos.bottom, null, rightPos.top);
|
1462 |
+
}
|
1463 |
+
if (toArg == null && to == lineLen) right = rightSide;
|
1464 |
+
if (!start || leftPos.top < start.top || leftPos.top == start.top && leftPos.left < start.left)
|
1465 |
+
start = leftPos;
|
1466 |
+
if (!end || rightPos.bottom > end.bottom || rightPos.bottom == end.bottom && rightPos.right > end.right)
|
1467 |
+
end = rightPos;
|
1468 |
+
if (left < leftSide + 1) left = leftSide;
|
1469 |
+
add(left, rightPos.top, right - left, rightPos.bottom);
|
1470 |
+
});
|
1471 |
+
return {start: start, end: end};
|
1472 |
+
}
|
1473 |
+
|
1474 |
+
var sFrom = range.from(), sTo = range.to();
|
1475 |
+
if (sFrom.line == sTo.line) {
|
1476 |
+
drawForLine(sFrom.line, sFrom.ch, sTo.ch);
|
1477 |
+
} else {
|
1478 |
+
var fromLine = getLine(doc, sFrom.line), toLine = getLine(doc, sTo.line);
|
1479 |
+
var singleVLine = visualLine(fromLine) == visualLine(toLine);
|
1480 |
+
var leftEnd = drawForLine(sFrom.line, sFrom.ch, singleVLine ? fromLine.text.length + 1 : null).end;
|
1481 |
+
var rightStart = drawForLine(sTo.line, singleVLine ? 0 : null, sTo.ch).start;
|
1482 |
+
if (singleVLine) {
|
1483 |
+
if (leftEnd.top < rightStart.top - 2) {
|
1484 |
+
add(leftEnd.right, leftEnd.top, null, leftEnd.bottom);
|
1485 |
+
add(leftSide, rightStart.top, rightStart.left, rightStart.bottom);
|
1486 |
+
} else {
|
1487 |
+
add(leftEnd.right, leftEnd.top, rightStart.left - leftEnd.right, leftEnd.bottom);
|
1488 |
+
}
|
1489 |
+
}
|
1490 |
+
if (leftEnd.bottom < rightStart.top)
|
1491 |
+
add(leftSide, leftEnd.bottom, null, rightStart.top);
|
1492 |
+
}
|
1493 |
+
|
1494 |
+
output.appendChild(fragment);
|
1495 |
+
}
|
1496 |
+
|
1497 |
+
// Cursor-blinking
|
1498 |
+
function restartBlink(cm) {
|
1499 |
+
if (!cm.state.focused) return;
|
1500 |
+
var display = cm.display;
|
1501 |
+
clearInterval(display.blinker);
|
1502 |
+
var on = true;
|
1503 |
+
display.cursorDiv.style.visibility = "";
|
1504 |
+
if (cm.options.cursorBlinkRate > 0)
|
1505 |
+
display.blinker = setInterval(function() {
|
1506 |
+
display.cursorDiv.style.visibility = (on = !on) ? "" : "hidden";
|
1507 |
+
}, cm.options.cursorBlinkRate);
|
1508 |
+
else if (cm.options.cursorBlinkRate < 0)
|
1509 |
+
display.cursorDiv.style.visibility = "hidden";
|
1510 |
+
}
|
1511 |
+
|
1512 |
+
// HIGHLIGHT WORKER
|
1513 |
+
|
1514 |
+
function startWorker(cm, time) {
|
1515 |
+
if (cm.doc.mode.startState && cm.doc.frontier < cm.display.viewTo)
|
1516 |
+
cm.state.highlight.set(time, bind(highlightWorker, cm));
|
1517 |
+
}
|
1518 |
+
|
1519 |
+
function highlightWorker(cm) {
|
1520 |
+
var doc = cm.doc;
|
1521 |
+
if (doc.frontier < doc.first) doc.frontier = doc.first;
|
1522 |
+
if (doc.frontier >= cm.display.viewTo) return;
|
1523 |
+
var end = +new Date + cm.options.workTime;
|
1524 |
+
var state = copyState(doc.mode, getStateBefore(cm, doc.frontier));
|
1525 |
+
var changedLines = [];
|
1526 |
+
|
1527 |
+
doc.iter(doc.frontier, Math.min(doc.first + doc.size, cm.display.viewTo + 500), function(line) {
|
1528 |
+
if (doc.frontier >= cm.display.viewFrom) { // Visible
|
1529 |
+
var oldStyles = line.styles;
|
1530 |
+
var highlighted = highlightLine(cm, line, state, true);
|
1531 |
+
line.styles = highlighted.styles;
|
1532 |
+
var oldCls = line.styleClasses, newCls = highlighted.classes;
|
1533 |
+
if (newCls) line.styleClasses = newCls;
|
1534 |
+
else if (oldCls) line.styleClasses = null;
|
1535 |
+
var ischange = !oldStyles || oldStyles.length != line.styles.length ||
|
1536 |
+
oldCls != newCls && (!oldCls || !newCls || oldCls.bgClass != newCls.bgClass || oldCls.textClass != newCls.textClass);
|
1537 |
+
for (var i = 0; !ischange && i < oldStyles.length; ++i) ischange = oldStyles[i] != line.styles[i];
|
1538 |
+
if (ischange) changedLines.push(doc.frontier);
|
1539 |
+
line.stateAfter = copyState(doc.mode, state);
|
1540 |
+
} else {
|
1541 |
+
processLine(cm, line.text, state);
|
1542 |
+
line.stateAfter = doc.frontier % 5 == 0 ? copyState(doc.mode, state) : null;
|
1543 |
+
}
|
1544 |
+
++doc.frontier;
|
1545 |
+
if (+new Date > end) {
|
1546 |
+
startWorker(cm, cm.options.workDelay);
|
1547 |
+
return true;
|
1548 |
+
}
|
1549 |
+
});
|
1550 |
+
if (changedLines.length) runInOp(cm, function() {
|
1551 |
+
for (var i = 0; i < changedLines.length; i++)
|
1552 |
+
regLineChange(cm, changedLines[i], "text");
|
1553 |
+
});
|
1554 |
+
}
|
1555 |
+
|
1556 |
+
// Finds the line to start with when starting a parse. Tries to
|
1557 |
+
// find a line with a stateAfter, so that it can start with a
|
1558 |
+
// valid state. If that fails, it returns the line with the
|
1559 |
+
// smallest indentation, which tends to need the least context to
|
1560 |
+
// parse correctly.
|
1561 |
+
function findStartLine(cm, n, precise) {
|
1562 |
+
var minindent, minline, doc = cm.doc;
|
1563 |
+
var lim = precise ? -1 : n - (cm.doc.mode.innerMode ? 1000 : 100);
|
1564 |
+
for (var search = n; search > lim; --search) {
|
1565 |
+
if (search <= doc.first) return doc.first;
|
1566 |
+
var line = getLine(doc, search - 1);
|
1567 |
+
if (line.stateAfter && (!precise || search <= doc.frontier)) return search;
|
1568 |
+
var indented = countColumn(line.text, null, cm.options.tabSize);
|
1569 |
+
if (minline == null || minindent > indented) {
|
1570 |
+
minline = search - 1;
|
1571 |
+
minindent = indented;
|
1572 |
+
}
|
1573 |
+
}
|
1574 |
+
return minline;
|
1575 |
+
}
|
1576 |
+
|
1577 |
+
function getStateBefore(cm, n, precise) {
|
1578 |
+
var doc = cm.doc, display = cm.display;
|
1579 |
+
if (!doc.mode.startState) return true;
|
1580 |
+
var pos = findStartLine(cm, n, precise), state = pos > doc.first && getLine(doc, pos-1).stateAfter;
|
1581 |
+
if (!state) state = startState(doc.mode);
|
1582 |
+
else state = copyState(doc.mode, state);
|
1583 |
+
doc.iter(pos, n, function(line) {
|
1584 |
+
processLine(cm, line.text, state);
|
1585 |
+
var save = pos == n - 1 || pos % 5 == 0 || pos >= display.viewFrom && pos < display.viewTo;
|
1586 |
+
line.stateAfter = save ? copyState(doc.mode, state) : null;
|
1587 |
+
++pos;
|
1588 |
+
});
|
1589 |
+
if (precise) doc.frontier = pos;
|
1590 |
+
return state;
|
1591 |
+
}
|
1592 |
+
|
1593 |
+
// POSITION MEASUREMENT
|
1594 |
+
|
1595 |
+
function paddingTop(display) {return display.lineSpace.offsetTop;}
|
1596 |
+
function paddingVert(display) {return display.mover.offsetHeight - display.lineSpace.offsetHeight;}
|
1597 |
+
function paddingH(display) {
|
1598 |
+
if (display.cachedPaddingH) return display.cachedPaddingH;
|
1599 |
+
var e = removeChildrenAndAdd(display.measure, elt("pre", "x"));
|
1600 |
+
var style = window.getComputedStyle ? window.getComputedStyle(e) : e.currentStyle;
|
1601 |
+
var data = {left: parseInt(style.paddingLeft), right: parseInt(style.paddingRight)};
|
1602 |
+
if (!isNaN(data.left) && !isNaN(data.right)) display.cachedPaddingH = data;
|
1603 |
+
return data;
|
1604 |
+
}
|
1605 |
+
|
1606 |
+
function scrollGap(cm) { return scrollerGap - cm.display.nativeBarWidth; }
|
1607 |
+
function displayWidth(cm) {
|
1608 |
+
return cm.display.scroller.clientWidth - scrollGap(cm) - cm.display.barWidth;
|
1609 |
+
}
|
1610 |
+
function displayHeight(cm) {
|
1611 |
+
return cm.display.scroller.clientHeight - scrollGap(cm) - cm.display.barHeight;
|
1612 |
+
}
|
1613 |
+
|
1614 |
+
// Ensure the lineView.wrapping.heights array is populated. This is
|
1615 |
+
// an array of bottom offsets for the lines that make up a drawn
|
1616 |
+
// line. When lineWrapping is on, there might be more than one
|
1617 |
+
// height.
|
1618 |
+
function ensureLineHeights(cm, lineView, rect) {
|
1619 |
+
var wrapping = cm.options.lineWrapping;
|
1620 |
+
var curWidth = wrapping && displayWidth(cm);
|
1621 |
+
if (!lineView.measure.heights || wrapping && lineView.measure.width != curWidth) {
|
1622 |
+
var heights = lineView.measure.heights = [];
|
1623 |
+
if (wrapping) {
|
1624 |
+
lineView.measure.width = curWidth;
|
1625 |
+
var rects = lineView.text.firstChild.getClientRects();
|
1626 |
+
for (var i = 0; i < rects.length - 1; i++) {
|
1627 |
+
var cur = rects[i], next = rects[i + 1];
|
1628 |
+
if (Math.abs(cur.bottom - next.bottom) > 2)
|
1629 |
+
heights.push((cur.bottom + next.top) / 2 - rect.top);
|
1630 |
+
}
|
1631 |
+
}
|
1632 |
+
heights.push(rect.bottom - rect.top);
|
1633 |
+
}
|
1634 |
+
}
|
1635 |
+
|
1636 |
+
// Find a line map (mapping character offsets to text nodes) and a
|
1637 |
+
// measurement cache for the given line number. (A line view might
|
1638 |
+
// contain multiple lines when collapsed ranges are present.)
|
1639 |
+
function mapFromLineView(lineView, line, lineN) {
|
1640 |
+
if (lineView.line == line)
|
1641 |
+
return {map: lineView.measure.map, cache: lineView.measure.cache};
|
1642 |
+
for (var i = 0; i < lineView.rest.length; i++)
|
1643 |
+
if (lineView.rest[i] == line)
|
1644 |
+
return {map: lineView.measure.maps[i], cache: lineView.measure.caches[i]};
|
1645 |
+
for (var i = 0; i < lineView.rest.length; i++)
|
1646 |
+
if (lineNo(lineView.rest[i]) > lineN)
|
1647 |
+
return {map: lineView.measure.maps[i], cache: lineView.measure.caches[i], before: true};
|
1648 |
+
}
|
1649 |
+
|
1650 |
+
// Render a line into the hidden node display.externalMeasured. Used
|
1651 |
+
// when measurement is needed for a line that's not in the viewport.
|
1652 |
+
function updateExternalMeasurement(cm, line) {
|
1653 |
+
line = visualLine(line);
|
1654 |
+
var lineN = lineNo(line);
|
1655 |
+
var view = cm.display.externalMeasured = new LineView(cm.doc, line, lineN);
|
1656 |
+
view.lineN = lineN;
|
1657 |
+
var built = view.built = buildLineContent(cm, view);
|
1658 |
+
view.text = built.pre;
|
1659 |
+
removeChildrenAndAdd(cm.display.lineMeasure, built.pre);
|
1660 |
+
return view;
|
1661 |
+
}
|
1662 |
+
|
1663 |
+
// Get a {top, bottom, left, right} box (in line-local coordinates)
|
1664 |
+
// for a given character.
|
1665 |
+
function measureChar(cm, line, ch, bias) {
|
1666 |
+
return measureCharPrepared(cm, prepareMeasureForLine(cm, line), ch, bias);
|
1667 |
+
}
|
1668 |
+
|
1669 |
+
// Find a line view that corresponds to the given line number.
|
1670 |
+
function findViewForLine(cm, lineN) {
|
1671 |
+
if (lineN >= cm.display.viewFrom && lineN < cm.display.viewTo)
|
1672 |
+
return cm.display.view[findViewIndex(cm, lineN)];
|
1673 |
+
var ext = cm.display.externalMeasured;
|
1674 |
+
if (ext && lineN >= ext.lineN && lineN < ext.lineN + ext.size)
|
1675 |
+
return ext;
|
1676 |
+
}
|
1677 |
+
|
1678 |
+
// Measurement can be split in two steps, the set-up work that
|
1679 |
+
// applies to the whole line, and the measurement of the actual
|
1680 |
+
// character. Functions like coordsChar, that need to do a lot of
|
1681 |
+
// measurements in a row, can thus ensure that the set-up work is
|
1682 |
+
// only done once.
|
1683 |
+
function prepareMeasureForLine(cm, line) {
|
1684 |
+
var lineN = lineNo(line);
|
1685 |
+
var view = findViewForLine(cm, lineN);
|
1686 |
+
if (view && !view.text)
|
1687 |
+
view = null;
|
1688 |
+
else if (view && view.changes)
|
1689 |
+
updateLineForChanges(cm, view, lineN, getDimensions(cm));
|
1690 |
+
if (!view)
|
1691 |
+
view = updateExternalMeasurement(cm, line);
|
1692 |
+
|
1693 |
+
var info = mapFromLineView(view, line, lineN);
|
1694 |
+
return {
|
1695 |
+
line: line, view: view, rect: null,
|
1696 |
+
map: info.map, cache: info.cache, before: info.before,
|
1697 |
+
hasHeights: false
|
1698 |
+
};
|
1699 |
+
}
|
1700 |
+
|
1701 |
+
// Given a prepared measurement object, measures the position of an
|
1702 |
+
// actual character (or fetches it from the cache).
|
1703 |
+
function measureCharPrepared(cm, prepared, ch, bias, varHeight) {
|
1704 |
+
if (prepared.before) ch = -1;
|
1705 |
+
var key = ch + (bias || ""), found;
|
1706 |
+
if (prepared.cache.hasOwnProperty(key)) {
|
1707 |
+
found = prepared.cache[key];
|
1708 |
+
} else {
|
1709 |
+
if (!prepared.rect)
|
1710 |
+
prepared.rect = prepared.view.text.getBoundingClientRect();
|
1711 |
+
if (!prepared.hasHeights) {
|
1712 |
+
ensureLineHeights(cm, prepared.view, prepared.rect);
|
1713 |
+
prepared.hasHeights = true;
|
1714 |
+
}
|
1715 |
+
found = measureCharInner(cm, prepared, ch, bias);
|
1716 |
+
if (!found.bogus) prepared.cache[key] = found;
|
1717 |
+
}
|
1718 |
+
return {left: found.left, right: found.right,
|
1719 |
+
top: varHeight ? found.rtop : found.top,
|
1720 |
+
bottom: varHeight ? found.rbottom : found.bottom};
|
1721 |
+
}
|
1722 |
+
|
1723 |
+
var nullRect = {left: 0, right: 0, top: 0, bottom: 0};
|
1724 |
+
|
1725 |
+
function measureCharInner(cm, prepared, ch, bias) {
|
1726 |
+
var map = prepared.map;
|
1727 |
+
|
1728 |
+
var node, start, end, collapse;
|
1729 |
+
// First, search the line map for the text node corresponding to,
|
1730 |
+
// or closest to, the target character.
|
1731 |
+
for (var i = 0; i < map.length; i += 3) {
|
1732 |
+
var mStart = map[i], mEnd = map[i + 1];
|
1733 |
+
if (ch < mStart) {
|
1734 |
+
start = 0; end = 1;
|
1735 |
+
collapse = "left";
|
1736 |
+
} else if (ch < mEnd) {
|
1737 |
+
start = ch - mStart;
|
1738 |
+
end = start + 1;
|
1739 |
+
} else if (i == map.length - 3 || ch == mEnd && map[i + 3] > ch) {
|
1740 |
+
end = mEnd - mStart;
|
1741 |
+
start = end - 1;
|
1742 |
+
if (ch >= mEnd) collapse = "right";
|
1743 |
+
}
|
1744 |
+
if (start != null) {
|
1745 |
+
node = map[i + 2];
|
1746 |
+
if (mStart == mEnd && bias == (node.insertLeft ? "left" : "right"))
|
1747 |
+
collapse = bias;
|
1748 |
+
if (bias == "left" && start == 0)
|
1749 |
+
while (i && map[i - 2] == map[i - 3] && map[i - 1].insertLeft) {
|
1750 |
+
node = map[(i -= 3) + 2];
|
1751 |
+
collapse = "left";
|
1752 |
+
}
|
1753 |
+
if (bias == "right" && start == mEnd - mStart)
|
1754 |
+
while (i < map.length - 3 && map[i + 3] == map[i + 4] && !map[i + 5].insertLeft) {
|
1755 |
+
node = map[(i += 3) + 2];
|
1756 |
+
collapse = "right";
|
1757 |
+
}
|
1758 |
+
break;
|
1759 |
+
}
|
1760 |
+
}
|
1761 |
+
|
1762 |
+
var rect;
|
1763 |
+
if (node.nodeType == 3) { // If it is a text node, use a range to retrieve the coordinates.
|
1764 |
+
for (var i = 0; i < 4; i++) { // Retry a maximum of 4 times when nonsense rectangles are returned
|
1765 |
+
while (start && isExtendingChar(prepared.line.text.charAt(mStart + start))) --start;
|
1766 |
+
while (mStart + end < mEnd && isExtendingChar(prepared.line.text.charAt(mStart + end))) ++end;
|
1767 |
+
if (ie && ie_version < 9 && start == 0 && end == mEnd - mStart) {
|
1768 |
+
rect = node.parentNode.getBoundingClientRect();
|
1769 |
+
} else if (ie && cm.options.lineWrapping) {
|
1770 |
+
var rects = range(node, start, end).getClientRects();
|
1771 |
+
if (rects.length)
|
1772 |
+
rect = rects[bias == "right" ? rects.length - 1 : 0];
|
1773 |
+
else
|
1774 |
+
rect = nullRect;
|
1775 |
+
} else {
|
1776 |
+
rect = range(node, start, end).getBoundingClientRect() || nullRect;
|
1777 |
+
}
|
1778 |
+
if (rect.left || rect.right || start == 0) break;
|
1779 |
+
end = start;
|
1780 |
+
start = start - 1;
|
1781 |
+
collapse = "right";
|
1782 |
+
}
|
1783 |
+
if (ie && ie_version < 11) rect = maybeUpdateRectForZooming(cm.display.measure, rect);
|
1784 |
+
} else { // If it is a widget, simply get the box for the whole widget.
|
1785 |
+
if (start > 0) collapse = bias = "right";
|
1786 |
+
var rects;
|
1787 |
+
if (cm.options.lineWrapping && (rects = node.getClientRects()).length > 1)
|
1788 |
+
rect = rects[bias == "right" ? rects.length - 1 : 0];
|
1789 |
+
else
|
1790 |
+
rect = node.getBoundingClientRect();
|
1791 |
+
}
|
1792 |
+
if (ie && ie_version < 9 && !start && (!rect || !rect.left && !rect.right)) {
|
1793 |
+
var rSpan = node.parentNode.getClientRects()[0];
|
1794 |
+
if (rSpan)
|
1795 |
+
rect = {left: rSpan.left, right: rSpan.left + charWidth(cm.display), top: rSpan.top, bottom: rSpan.bottom};
|
1796 |
+
else
|
1797 |
+
rect = nullRect;
|
1798 |
+
}
|
1799 |
+
|
1800 |
+
var rtop = rect.top - prepared.rect.top, rbot = rect.bottom - prepared.rect.top;
|
1801 |
+
var mid = (rtop + rbot) / 2;
|
1802 |
+
var heights = prepared.view.measure.heights;
|
1803 |
+
for (var i = 0; i < heights.length - 1; i++)
|
1804 |
+
if (mid < heights[i]) break;
|
1805 |
+
var top = i ? heights[i - 1] : 0, bot = heights[i];
|
1806 |
+
var result = {left: (collapse == "right" ? rect.right : rect.left) - prepared.rect.left,
|
1807 |
+
right: (collapse == "left" ? rect.left : rect.right) - prepared.rect.left,
|
1808 |
+
top: top, bottom: bot};
|
1809 |
+
if (!rect.left && !rect.right) result.bogus = true;
|
1810 |
+
if (!cm.options.singleCursorHeightPerLine) { result.rtop = rtop; result.rbottom = rbot; }
|
1811 |
+
|
1812 |
+
return result;
|
1813 |
+
}
|
1814 |
+
|
1815 |
+
// Work around problem with bounding client rects on ranges being
|
1816 |
+
// returned incorrectly when zoomed on IE10 and below.
|
1817 |
+
function maybeUpdateRectForZooming(measure, rect) {
|
1818 |
+
if (!window.screen || screen.logicalXDPI == null ||
|
1819 |
+
screen.logicalXDPI == screen.deviceXDPI || !hasBadZoomedRects(measure))
|
1820 |
+
return rect;
|
1821 |
+
var scaleX = screen.logicalXDPI / screen.deviceXDPI;
|
1822 |
+
var scaleY = screen.logicalYDPI / screen.deviceYDPI;
|
1823 |
+
return {left: rect.left * scaleX, right: rect.right * scaleX,
|
1824 |
+
top: rect.top * scaleY, bottom: rect.bottom * scaleY};
|
1825 |
+
}
|
1826 |
+
|
1827 |
+
function clearLineMeasurementCacheFor(lineView) {
|
1828 |
+
if (lineView.measure) {
|
1829 |
+
lineView.measure.cache = {};
|
1830 |
+
lineView.measure.heights = null;
|
1831 |
+
if (lineView.rest) for (var i = 0; i < lineView.rest.length; i++)
|
1832 |
+
lineView.measure.caches[i] = {};
|
1833 |
+
}
|
1834 |
+
}
|
1835 |
+
|
1836 |
+
function clearLineMeasurementCache(cm) {
|
1837 |
+
cm.display.externalMeasure = null;
|
1838 |
+
removeChildren(cm.display.lineMeasure);
|
1839 |
+
for (var i = 0; i < cm.display.view.length; i++)
|
1840 |
+
clearLineMeasurementCacheFor(cm.display.view[i]);
|
1841 |
+
}
|
1842 |
+
|
1843 |
+
function clearCaches(cm) {
|
1844 |
+
clearLineMeasurementCache(cm);
|
1845 |
+
cm.display.cachedCharWidth = cm.display.cachedTextHeight = cm.display.cachedPaddingH = null;
|
1846 |
+
if (!cm.options.lineWrapping) cm.display.maxLineChanged = true;
|
1847 |
+
cm.display.lineNumChars = null;
|
1848 |
+
}
|
1849 |
+
|
1850 |
+
function pageScrollX() { return window.pageXOffset || (document.documentElement || document.body).scrollLeft; }
|
1851 |
+
function pageScrollY() { return window.pageYOffset || (document.documentElement || document.body).scrollTop; }
|
1852 |
+
|
1853 |
+
// Converts a {top, bottom, left, right} box from line-local
|
1854 |
+
// coordinates into another coordinate system. Context may be one of
|
1855 |
+
// "line", "div" (display.lineDiv), "local"/null (editor), "window",
|
1856 |
+
// or "page".
|
1857 |
+
function intoCoordSystem(cm, lineObj, rect, context) {
|
1858 |
+
if (lineObj.widgets) for (var i = 0; i < lineObj.widgets.length; ++i) if (lineObj.widgets[i].above) {
|
1859 |
+
var size = widgetHeight(lineObj.widgets[i]);
|
1860 |
+
rect.top += size; rect.bottom += size;
|
1861 |
+
}
|
1862 |
+
if (context == "line") return rect;
|
1863 |
+
if (!context) context = "local";
|
1864 |
+
var yOff = heightAtLine(lineObj);
|
1865 |
+
if (context == "local") yOff += paddingTop(cm.display);
|
1866 |
+
else yOff -= cm.display.viewOffset;
|
1867 |
+
if (context == "page" || context == "window") {
|
1868 |
+
var lOff = cm.display.lineSpace.getBoundingClientRect();
|
1869 |
+
yOff += lOff.top + (context == "window" ? 0 : pageScrollY());
|
1870 |
+
var xOff = lOff.left + (context == "window" ? 0 : pageScrollX());
|
1871 |
+
rect.left += xOff; rect.right += xOff;
|
1872 |
+
}
|
1873 |
+
rect.top += yOff; rect.bottom += yOff;
|
1874 |
+
return rect;
|
1875 |
+
}
|
1876 |
+
|
1877 |
+
// Coverts a box from "div" coords to another coordinate system.
|
1878 |
+
// Context may be "window", "page", "div", or "local"/null.
|
1879 |
+
function fromCoordSystem(cm, coords, context) {
|
1880 |
+
if (context == "div") return coords;
|
1881 |
+
var left = coords.left, top = coords.top;
|
1882 |
+
// First move into "page" coordinate system
|
1883 |
+
if (context == "page") {
|
1884 |
+
left -= pageScrollX();
|
1885 |
+
top -= pageScrollY();
|
1886 |
+
} else if (context == "local" || !context) {
|
1887 |
+
var localBox = cm.display.sizer.getBoundingClientRect();
|
1888 |
+
left += localBox.left;
|
1889 |
+
top += localBox.top;
|
1890 |
+
}
|
1891 |
+
|
1892 |
+
var lineSpaceBox = cm.display.lineSpace.getBoundingClientRect();
|
1893 |
+
return {left: left - lineSpaceBox.left, top: top - lineSpaceBox.top};
|
1894 |
+
}
|
1895 |
+
|
1896 |
+
function charCoords(cm, pos, context, lineObj, bias) {
|
1897 |
+
if (!lineObj) lineObj = getLine(cm.doc, pos.line);
|
1898 |
+
return intoCoordSystem(cm, lineObj, measureChar(cm, lineObj, pos.ch, bias), context);
|
1899 |
+
}
|
1900 |
+
|
1901 |
+
// Returns a box for a given cursor position, which may have an
|
1902 |
+
// 'other' property containing the position of the secondary cursor
|
1903 |
+
// on a bidi boundary.
|
1904 |
+
function cursorCoords(cm, pos, context, lineObj, preparedMeasure, varHeight) {
|
1905 |
+
lineObj = lineObj || getLine(cm.doc, pos.line);
|
1906 |
+
if (!preparedMeasure) preparedMeasure = prepareMeasureForLine(cm, lineObj);
|
1907 |
+
function get(ch, right) {
|
1908 |
+
var m = measureCharPrepared(cm, preparedMeasure, ch, right ? "right" : "left", varHeight);
|
1909 |
+
if (right) m.left = m.right; else m.right = m.left;
|
1910 |
+
return intoCoordSystem(cm, lineObj, m, context);
|
1911 |
+
}
|
1912 |
+
function getBidi(ch, partPos) {
|
1913 |
+
var part = order[partPos], right = part.level % 2;
|
1914 |
+
if (ch == bidiLeft(part) && partPos && part.level < order[partPos - 1].level) {
|
1915 |
+
part = order[--partPos];
|
1916 |
+
ch = bidiRight(part) - (part.level % 2 ? 0 : 1);
|
1917 |
+
right = true;
|
1918 |
+
} else if (ch == bidiRight(part) && partPos < order.length - 1 && part.level < order[partPos + 1].level) {
|
1919 |
+
part = order[++partPos];
|
1920 |
+
ch = bidiLeft(part) - part.level % 2;
|
1921 |
+
right = false;
|
1922 |
+
}
|
1923 |
+
if (right && ch == part.to && ch > part.from) return get(ch - 1);
|
1924 |
+
return get(ch, right);
|
1925 |
+
}
|
1926 |
+
var order = getOrder(lineObj), ch = pos.ch;
|
1927 |
+
if (!order) return get(ch);
|
1928 |
+
var partPos = getBidiPartAt(order, ch);
|
1929 |
+
var val = getBidi(ch, partPos);
|
1930 |
+
if (bidiOther != null) val.other = getBidi(ch, bidiOther);
|
1931 |
+
return val;
|
1932 |
+
}
|
1933 |
+
|
1934 |
+
// Used to cheaply estimate the coordinates for a position. Used for
|
1935 |
+
// intermediate scroll updates.
|
1936 |
+
function estimateCoords(cm, pos) {
|
1937 |
+
var left = 0, pos = clipPos(cm.doc, pos);
|
1938 |
+
if (!cm.options.lineWrapping) left = charWidth(cm.display) * pos.ch;
|
1939 |
+
var lineObj = getLine(cm.doc, pos.line);
|
1940 |
+
var top = heightAtLine(lineObj) + paddingTop(cm.display);
|
1941 |
+
return {left: left, right: left, top: top, bottom: top + lineObj.height};
|
1942 |
+
}
|
1943 |
+
|
1944 |
+
// Positions returned by coordsChar contain some extra information.
|
1945 |
+
// xRel is the relative x position of the input coordinates compared
|
1946 |
+
// to the found position (so xRel > 0 means the coordinates are to
|
1947 |
+
// the right of the character position, for example). When outside
|
1948 |
+
// is true, that means the coordinates lie outside the line's
|
1949 |
+
// vertical range.
|
1950 |
+
function PosWithInfo(line, ch, outside, xRel) {
|
1951 |
+
var pos = Pos(line, ch);
|
1952 |
+
pos.xRel = xRel;
|
1953 |
+
if (outside) pos.outside = true;
|
1954 |
+
return pos;
|
1955 |
+
}
|
1956 |
+
|
1957 |
+
// Compute the character position closest to the given coordinates.
|
1958 |
+
// Input must be lineSpace-local ("div" coordinate system).
|
1959 |
+
function coordsChar(cm, x, y) {
|
1960 |
+
var doc = cm.doc;
|
1961 |
+
y += cm.display.viewOffset;
|
1962 |
+
if (y < 0) return PosWithInfo(doc.first, 0, true, -1);
|
1963 |
+
var lineN = lineAtHeight(doc, y), last = doc.first + doc.size - 1;
|
1964 |
+
if (lineN > last)
|
1965 |
+
return PosWithInfo(doc.first + doc.size - 1, getLine(doc, last).text.length, true, 1);
|
1966 |
+
if (x < 0) x = 0;
|
1967 |
+
|
1968 |
+
var lineObj = getLine(doc, lineN);
|
1969 |
+
for (;;) {
|
1970 |
+
var found = coordsCharInner(cm, lineObj, lineN, x, y);
|
1971 |
+
var merged = collapsedSpanAtEnd(lineObj);
|
1972 |
+
var mergedPos = merged && merged.find(0, true);
|
1973 |
+
if (merged && (found.ch > mergedPos.from.ch || found.ch == mergedPos.from.ch && found.xRel > 0))
|
1974 |
+
lineN = lineNo(lineObj = mergedPos.to.line);
|
1975 |
+
else
|
1976 |
+
return found;
|
1977 |
+
}
|
1978 |
+
}
|
1979 |
+
|
1980 |
+
function coordsCharInner(cm, lineObj, lineNo, x, y) {
|
1981 |
+
var innerOff = y - heightAtLine(lineObj);
|
1982 |
+
var wrongLine = false, adjust = 2 * cm.display.wrapper.clientWidth;
|
1983 |
+
var preparedMeasure = prepareMeasureForLine(cm, lineObj);
|
1984 |
+
|
1985 |
+
function getX(ch) {
|
1986 |
+
var sp = cursorCoords(cm, Pos(lineNo, ch), "line", lineObj, preparedMeasure);
|
1987 |
+
wrongLine = true;
|
1988 |
+
if (innerOff > sp.bottom) return sp.left - adjust;
|
1989 |
+
else if (innerOff < sp.top) return sp.left + adjust;
|
1990 |
+
else wrongLine = false;
|
1991 |
+
return sp.left;
|
1992 |
+
}
|
1993 |
+
|
1994 |
+
var bidi = getOrder(lineObj), dist = lineObj.text.length;
|
1995 |
+
var from = lineLeft(lineObj), to = lineRight(lineObj);
|
1996 |
+
var fromX = getX(from), fromOutside = wrongLine, toX = getX(to), toOutside = wrongLine;
|
1997 |
+
|
1998 |
+
if (x > toX) return PosWithInfo(lineNo, to, toOutside, 1);
|
1999 |
+
// Do a binary search between these bounds.
|
2000 |
+
for (;;) {
|
2001 |
+
if (bidi ? to == from || to == moveVisually(lineObj, from, 1) : to - from <= 1) {
|
2002 |
+
var ch = x < fromX || x - fromX <= toX - x ? from : to;
|
2003 |
+
var xDiff = x - (ch == from ? fromX : toX);
|
2004 |
+
while (isExtendingChar(lineObj.text.charAt(ch))) ++ch;
|
2005 |
+
var pos = PosWithInfo(lineNo, ch, ch == from ? fromOutside : toOutside,
|
2006 |
+
xDiff < -1 ? -1 : xDiff > 1 ? 1 : 0);
|
2007 |
+
return pos;
|
2008 |
+
}
|
2009 |
+
var step = Math.ceil(dist / 2), middle = from + step;
|
2010 |
+
if (bidi) {
|
2011 |
+
middle = from;
|
2012 |
+
for (var i = 0; i < step; ++i) middle = moveVisually(lineObj, middle, 1);
|
2013 |
+
}
|
2014 |
+
var middleX = getX(middle);
|
2015 |
+
if (middleX > x) {to = middle; toX = middleX; if (toOutside = wrongLine) toX += 1000; dist = step;}
|
2016 |
+
else {from = middle; fromX = middleX; fromOutside = wrongLine; dist -= step;}
|
2017 |
+
}
|
2018 |
+
}
|
2019 |
+
|
2020 |
+
var measureText;
|
2021 |
+
// Compute the default text height.
|
2022 |
+
function textHeight(display) {
|
2023 |
+
if (display.cachedTextHeight != null) return display.cachedTextHeight;
|
2024 |
+
if (measureText == null) {
|
2025 |
+
measureText = elt("pre");
|
2026 |
+
// Measure a bunch of lines, for browsers that compute
|
2027 |
+
// fractional heights.
|
2028 |
+
for (var i = 0; i < 49; ++i) {
|
2029 |
+
measureText.appendChild(document.createTextNode("x"));
|
2030 |
+
measureText.appendChild(elt("br"));
|
2031 |
+
}
|
2032 |
+
measureText.appendChild(document.createTextNode("x"));
|
2033 |
+
}
|
2034 |
+
removeChildrenAndAdd(display.measure, measureText);
|
2035 |
+
var height = measureText.offsetHeight / 50;
|
2036 |
+
if (height > 3) display.cachedTextHeight = height;
|
2037 |
+
removeChildren(display.measure);
|
2038 |
+
return height || 1;
|
2039 |
+
}
|
2040 |
+
|
2041 |
+
// Compute the default character width.
|
2042 |
+
function charWidth(display) {
|
2043 |
+
if (display.cachedCharWidth != null) return display.cachedCharWidth;
|
2044 |
+
var anchor = elt("span", "xxxxxxxxxx");
|
2045 |
+
var pre = elt("pre", [anchor]);
|
2046 |
+
removeChildrenAndAdd(display.measure, pre);
|
2047 |
+
var rect = anchor.getBoundingClientRect(), width = (rect.right - rect.left) / 10;
|
2048 |
+
if (width > 2) display.cachedCharWidth = width;
|
2049 |
+
return width || 10;
|
2050 |
+
}
|
2051 |
+
|
2052 |
+
// OPERATIONS
|
2053 |
+
|
2054 |
+
// Operations are used to wrap a series of changes to the editor
|
2055 |
+
// state in such a way that each change won't have to update the
|
2056 |
+
// cursor and display (which would be awkward, slow, and
|
2057 |
+
// error-prone). Instead, display updates are batched and then all
|
2058 |
+
// combined and executed at once.
|
2059 |
+
|
2060 |
+
var operationGroup = null;
|
2061 |
+
|
2062 |
+
var nextOpId = 0;
|
2063 |
+
// Start a new operation.
|
2064 |
+
function startOperation(cm) {
|
2065 |
+
cm.curOp = {
|
2066 |
+
cm: cm,
|
2067 |
+
viewChanged: false, // Flag that indicates that lines might need to be redrawn
|
2068 |
+
startHeight: cm.doc.height, // Used to detect need to update scrollbar
|
2069 |
+
forceUpdate: false, // Used to force a redraw
|
2070 |
+
updateInput: null, // Whether to reset the input textarea
|
2071 |
+
typing: false, // Whether this reset should be careful to leave existing text (for compositing)
|
2072 |
+
changeObjs: null, // Accumulated changes, for firing change events
|
2073 |
+
cursorActivityHandlers: null, // Set of handlers to fire cursorActivity on
|
2074 |
+
cursorActivityCalled: 0, // Tracks which cursorActivity handlers have been called already
|
2075 |
+
selectionChanged: false, // Whether the selection needs to be redrawn
|
2076 |
+
updateMaxLine: false, // Set when the widest line needs to be determined anew
|
2077 |
+
scrollLeft: null, scrollTop: null, // Intermediate scroll position, not pushed to DOM yet
|
2078 |
+
scrollToPos: null, // Used to scroll to a specific position
|
2079 |
+
id: ++nextOpId // Unique ID
|
2080 |
+
};
|
2081 |
+
if (operationGroup) {
|
2082 |
+
operationGroup.ops.push(cm.curOp);
|
2083 |
+
} else {
|
2084 |
+
cm.curOp.ownsGroup = operationGroup = {
|
2085 |
+
ops: [cm.curOp],
|
2086 |
+
delayedCallbacks: []
|
2087 |
+
};
|
2088 |
+
}
|
2089 |
+
}
|
2090 |
+
|
2091 |
+
function fireCallbacksForOps(group) {
|
2092 |
+
// Calls delayed callbacks and cursorActivity handlers until no
|
2093 |
+
// new ones appear
|
2094 |
+
var callbacks = group.delayedCallbacks, i = 0;
|
2095 |
+
do {
|
2096 |
+
for (; i < callbacks.length; i++)
|
2097 |
+
callbacks[i]();
|
2098 |
+
for (var j = 0; j < group.ops.length; j++) {
|
2099 |
+
var op = group.ops[j];
|
2100 |
+
if (op.cursorActivityHandlers)
|
2101 |
+
while (op.cursorActivityCalled < op.cursorActivityHandlers.length)
|
2102 |
+
op.cursorActivityHandlers[op.cursorActivityCalled++](op.cm);
|
2103 |
+
}
|
2104 |
+
} while (i < callbacks.length);
|
2105 |
+
}
|
2106 |
+
|
2107 |
+
// Finish an operation, updating the display and signalling delayed events
|
2108 |
+
function endOperation(cm) {
|
2109 |
+
var op = cm.curOp, group = op.ownsGroup;
|
2110 |
+
if (!group) return;
|
2111 |
+
|
2112 |
+
try { fireCallbacksForOps(group); }
|
2113 |
+
finally {
|
2114 |
+
operationGroup = null;
|
2115 |
+
for (var i = 0; i < group.ops.length; i++)
|
2116 |
+
group.ops[i].cm.curOp = null;
|
2117 |
+
endOperations(group);
|
2118 |
+
}
|
2119 |
+
}
|
2120 |
+
|
2121 |
+
// The DOM updates done when an operation finishes are batched so
|
2122 |
+
// that the minimum number of relayouts are required.
|
2123 |
+
function endOperations(group) {
|
2124 |
+
var ops = group.ops;
|
2125 |
+
for (var i = 0; i < ops.length; i++) // Read DOM
|
2126 |
+
endOperation_R1(ops[i]);
|
2127 |
+
for (var i = 0; i < ops.length; i++) // Write DOM (maybe)
|
2128 |
+
endOperation_W1(ops[i]);
|
2129 |
+
for (var i = 0; i < ops.length; i++) // Read DOM
|
2130 |
+
endOperation_R2(ops[i]);
|
2131 |
+
for (var i = 0; i < ops.length; i++) // Write DOM (maybe)
|
2132 |
+
endOperation_W2(ops[i]);
|
2133 |
+
for (var i = 0; i < ops.length; i++) // Read DOM
|
2134 |
+
endOperation_finish(ops[i]);
|
2135 |
+
}
|
2136 |
+
|
2137 |
+
function endOperation_R1(op) {
|
2138 |
+
var cm = op.cm, display = cm.display;
|
2139 |
+
maybeClipScrollbars(cm);
|
2140 |
+
if (op.updateMaxLine) findMaxLine(cm);
|
2141 |
+
|
2142 |
+
op.mustUpdate = op.viewChanged || op.forceUpdate || op.scrollTop != null ||
|
2143 |
+
op.scrollToPos && (op.scrollToPos.from.line < display.viewFrom ||
|
2144 |
+
op.scrollToPos.to.line >= display.viewTo) ||
|
2145 |
+
display.maxLineChanged && cm.options.lineWrapping;
|
2146 |
+
op.update = op.mustUpdate &&
|
2147 |
+
new DisplayUpdate(cm, op.mustUpdate && {top: op.scrollTop, ensure: op.scrollToPos}, op.forceUpdate);
|
2148 |
+
}
|
2149 |
+
|
2150 |
+
function endOperation_W1(op) {
|
2151 |
+
op.updatedDisplay = op.mustUpdate && updateDisplayIfNeeded(op.cm, op.update);
|
2152 |
+
}
|
2153 |
+
|
2154 |
+
function endOperation_R2(op) {
|
2155 |
+
var cm = op.cm, display = cm.display;
|
2156 |
+
if (op.updatedDisplay) updateHeightsInViewport(cm);
|
2157 |
+
|
2158 |
+
op.barMeasure = measureForScrollbars(cm);
|
2159 |
+
|
2160 |
+
// If the max line changed since it was last measured, measure it,
|
2161 |
+
// and ensure the document's width matches it.
|
2162 |
+
// updateDisplay_W2 will use these properties to do the actual resizing
|
2163 |
+
if (display.maxLineChanged && !cm.options.lineWrapping) {
|
2164 |
+
op.adjustWidthTo = measureChar(cm, display.maxLine, display.maxLine.text.length).left + 3;
|
2165 |
+
cm.display.sizerWidth = op.adjustWidthTo;
|
2166 |
+
op.barMeasure.scrollWidth =
|
2167 |
+
Math.max(display.scroller.clientWidth, display.sizer.offsetLeft + op.adjustWidthTo + scrollGap(cm) + cm.display.barWidth);
|
2168 |
+
op.maxScrollLeft = Math.max(0, display.sizer.offsetLeft + op.adjustWidthTo - displayWidth(cm));
|
2169 |
+
}
|
2170 |
+
|
2171 |
+
if (op.updatedDisplay || op.selectionChanged)
|
2172 |
+
op.newSelectionNodes = drawSelection(cm);
|
2173 |
+
}
|
2174 |
+
|
2175 |
+
function endOperation_W2(op) {
|
2176 |
+
var cm = op.cm;
|
2177 |
+
|
2178 |
+
if (op.adjustWidthTo != null) {
|
2179 |
+
cm.display.sizer.style.minWidth = op.adjustWidthTo + "px";
|
2180 |
+
if (op.maxScrollLeft < cm.doc.scrollLeft)
|
2181 |
+
setScrollLeft(cm, Math.min(cm.display.scroller.scrollLeft, op.maxScrollLeft), true);
|
2182 |
+
cm.display.maxLineChanged = false;
|
2183 |
+
}
|
2184 |
+
|
2185 |
+
if (op.newSelectionNodes)
|
2186 |
+
showSelection(cm, op.newSelectionNodes);
|
2187 |
+
if (op.updatedDisplay)
|
2188 |
+
setDocumentHeight(cm, op.barMeasure);
|
2189 |
+
if (op.updatedDisplay || op.startHeight != cm.doc.height)
|
2190 |
+
updateScrollbars(cm, op.barMeasure);
|
2191 |
+
|
2192 |
+
if (op.selectionChanged) restartBlink(cm);
|
2193 |
+
|
2194 |
+
if (cm.state.focused && op.updateInput)
|
2195 |
+
resetInput(cm, op.typing);
|
2196 |
+
}
|
2197 |
+
|
2198 |
+
function endOperation_finish(op) {
|
2199 |
+
var cm = op.cm, display = cm.display, doc = cm.doc;
|
2200 |
+
|
2201 |
+
if (op.updatedDisplay) postUpdateDisplay(cm, op.update);
|
2202 |
+
|
2203 |
+
// Abort mouse wheel delta measurement, when scrolling explicitly
|
2204 |
+
if (display.wheelStartX != null && (op.scrollTop != null || op.scrollLeft != null || op.scrollToPos))
|
2205 |
+
display.wheelStartX = display.wheelStartY = null;
|
2206 |
+
|
2207 |
+
// Propagate the scroll position to the actual DOM scroller
|
2208 |
+
if (op.scrollTop != null && (display.scroller.scrollTop != op.scrollTop || op.forceScroll)) {
|
2209 |
+
doc.scrollTop = Math.max(0, Math.min(display.scroller.scrollHeight - display.scroller.clientHeight, op.scrollTop));
|
2210 |
+
display.scrollbars.setScrollTop(doc.scrollTop);
|
2211 |
+
display.scroller.scrollTop = doc.scrollTop;
|
2212 |
+
}
|
2213 |
+
if (op.scrollLeft != null && (display.scroller.scrollLeft != op.scrollLeft || op.forceScroll)) {
|
2214 |
+
doc.scrollLeft = Math.max(0, Math.min(display.scroller.scrollWidth - displayWidth(cm), op.scrollLeft));
|
2215 |
+
display.scrollbars.setScrollLeft(doc.scrollLeft);
|
2216 |
+
display.scroller.scrollLeft = doc.scrollLeft;
|
2217 |
+
alignHorizontally(cm);
|
2218 |
+
}
|
2219 |
+
// If we need to scroll a specific position into view, do so.
|
2220 |
+
if (op.scrollToPos) {
|
2221 |
+
var coords = scrollPosIntoView(cm, clipPos(doc, op.scrollToPos.from),
|
2222 |
+
clipPos(doc, op.scrollToPos.to), op.scrollToPos.margin);
|
2223 |
+
if (op.scrollToPos.isCursor && cm.state.focused) maybeScrollWindow(cm, coords);
|
2224 |
+
}
|
2225 |
+
|
2226 |
+
// Fire events for markers that are hidden/unidden by editing or
|
2227 |
+
// undoing
|
2228 |
+
var hidden = op.maybeHiddenMarkers, unhidden = op.maybeUnhiddenMarkers;
|
2229 |
+
if (hidden) for (var i = 0; i < hidden.length; ++i)
|
2230 |
+
if (!hidden[i].lines.length) signal(hidden[i], "hide");
|
2231 |
+
if (unhidden) for (var i = 0; i < unhidden.length; ++i)
|
2232 |
+
if (unhidden[i].lines.length) signal(unhidden[i], "unhide");
|
2233 |
+
|
2234 |
+
if (display.wrapper.offsetHeight)
|
2235 |
+
doc.scrollTop = cm.display.scroller.scrollTop;
|
2236 |
+
|
2237 |
+
// Fire change events, and delayed event handlers
|
2238 |
+
if (op.changeObjs)
|
2239 |
+
signal(cm, "changes", cm, op.changeObjs);
|
2240 |
+
}
|
2241 |
+
|
2242 |
+
// Run the given function in an operation
|
2243 |
+
function runInOp(cm, f) {
|
2244 |
+
if (cm.curOp) return f();
|
2245 |
+
startOperation(cm);
|
2246 |
+
try { return f(); }
|
2247 |
+
finally { endOperation(cm); }
|
2248 |
+
}
|
2249 |
+
// Wraps a function in an operation. Returns the wrapped function.
|
2250 |
+
function operation(cm, f) {
|
2251 |
+
return function() {
|
2252 |
+
if (cm.curOp) return f.apply(cm, arguments);
|
2253 |
+
startOperation(cm);
|
2254 |
+
try { return f.apply(cm, arguments); }
|
2255 |
+
finally { endOperation(cm); }
|
2256 |
+
};
|
2257 |
+
}
|
2258 |
+
// Used to add methods to editor and doc instances, wrapping them in
|
2259 |
+
// operations.
|
2260 |
+
function methodOp(f) {
|
2261 |
+
return function() {
|
2262 |
+
if (this.curOp) return f.apply(this, arguments);
|
2263 |
+
startOperation(this);
|
2264 |
+
try { return f.apply(this, arguments); }
|
2265 |
+
finally { endOperation(this); }
|
2266 |
+
};
|
2267 |
+
}
|
2268 |
+
function docMethodOp(f) {
|
2269 |
+
return function() {
|
2270 |
+
var cm = this.cm;
|
2271 |
+
if (!cm || cm.curOp) return f.apply(this, arguments);
|
2272 |
+
startOperation(cm);
|
2273 |
+
try { return f.apply(this, arguments); }
|
2274 |
+
finally { endOperation(cm); }
|
2275 |
+
};
|
2276 |
+
}
|
2277 |
+
|
2278 |
+
// VIEW TRACKING
|
2279 |
+
|
2280 |
+
// These objects are used to represent the visible (currently drawn)
|
2281 |
+
// part of the document. A LineView may correspond to multiple
|
2282 |
+
// logical lines, if those are connected by collapsed ranges.
|
2283 |
+
function LineView(doc, line, lineN) {
|
2284 |
+
// The starting line
|
2285 |
+
this.line = line;
|
2286 |
+
// Continuing lines, if any
|
2287 |
+
this.rest = visualLineContinued(line);
|
2288 |
+
// Number of logical lines in this visual line
|
2289 |
+
this.size = this.rest ? lineNo(lst(this.rest)) - lineN + 1 : 1;
|
2290 |
+
this.node = this.text = null;
|
2291 |
+
this.hidden = lineIsHidden(doc, line);
|
2292 |
+
}
|
2293 |
+
|
2294 |
+
// Create a range of LineView objects for the given lines.
|
2295 |
+
function buildViewArray(cm, from, to) {
|
2296 |
+
var array = [], nextPos;
|
2297 |
+
for (var pos = from; pos < to; pos = nextPos) {
|
2298 |
+
var view = new LineView(cm.doc, getLine(cm.doc, pos), pos);
|
2299 |
+
nextPos = pos + view.size;
|
2300 |
+
array.push(view);
|
2301 |
+
}
|
2302 |
+
return array;
|
2303 |
+
}
|
2304 |
+
|
2305 |
+
// Updates the display.view data structure for a given change to the
|
2306 |
+
// document. From and to are in pre-change coordinates. Lendiff is
|
2307 |
+
// the amount of lines added or subtracted by the change. This is
|
2308 |
+
// used for changes that span multiple lines, or change the way
|
2309 |
+
// lines are divided into visual lines. regLineChange (below)
|
2310 |
+
// registers single-line changes.
|
2311 |
+
function regChange(cm, from, to, lendiff) {
|
2312 |
+
if (from == null) from = cm.doc.first;
|
2313 |
+
if (to == null) to = cm.doc.first + cm.doc.size;
|
2314 |
+
if (!lendiff) lendiff = 0;
|
2315 |
+
|
2316 |
+
var display = cm.display;
|
2317 |
+
if (lendiff && to < display.viewTo &&
|
2318 |
+
(display.updateLineNumbers == null || display.updateLineNumbers > from))
|
2319 |
+
display.updateLineNumbers = from;
|
2320 |
+
|
2321 |
+
cm.curOp.viewChanged = true;
|
2322 |
+
|
2323 |
+
if (from >= display.viewTo) { // Change after
|
2324 |
+
if (sawCollapsedSpans && visualLineNo(cm.doc, from) < display.viewTo)
|
2325 |
+
resetView(cm);
|
2326 |
+
} else if (to <= display.viewFrom) { // Change before
|
2327 |
+
if (sawCollapsedSpans && visualLineEndNo(cm.doc, to + lendiff) > display.viewFrom) {
|
2328 |
+
resetView(cm);
|
2329 |
+
} else {
|
2330 |
+
display.viewFrom += lendiff;
|
2331 |
+
display.viewTo += lendiff;
|
2332 |
+
}
|
2333 |
+
} else if (from <= display.viewFrom && to >= display.viewTo) { // Full overlap
|
2334 |
+
resetView(cm);
|
2335 |
+
} else if (from <= display.viewFrom) { // Top overlap
|
2336 |
+
var cut = viewCuttingPoint(cm, to, to + lendiff, 1);
|
2337 |
+
if (cut) {
|
2338 |
+
display.view = display.view.slice(cut.index);
|
2339 |
+
display.viewFrom = cut.lineN;
|
2340 |
+
display.viewTo += lendiff;
|
2341 |
+
} else {
|
2342 |
+
resetView(cm);
|
2343 |
+
}
|
2344 |
+
} else if (to >= display.viewTo) { // Bottom overlap
|
2345 |
+
var cut = viewCuttingPoint(cm, from, from, -1);
|
2346 |
+
if (cut) {
|
2347 |
+
display.view = display.view.slice(0, cut.index);
|
2348 |
+
display.viewTo = cut.lineN;
|
2349 |
+
} else {
|
2350 |
+
resetView(cm);
|
2351 |
+
}
|
2352 |
+
} else { // Gap in the middle
|
2353 |
+
var cutTop = viewCuttingPoint(cm, from, from, -1);
|
2354 |
+
var cutBot = viewCuttingPoint(cm, to, to + lendiff, 1);
|
2355 |
+
if (cutTop && cutBot) {
|
2356 |
+
display.view = display.view.slice(0, cutTop.index)
|
2357 |
+
.concat(buildViewArray(cm, cutTop.lineN, cutBot.lineN))
|
2358 |
+
.concat(display.view.slice(cutBot.index));
|
2359 |
+
display.viewTo += lendiff;
|
2360 |
+
} else {
|
2361 |
+
resetView(cm);
|
2362 |
+
}
|
2363 |
+
}
|
2364 |
+
|
2365 |
+
var ext = display.externalMeasured;
|
2366 |
+
if (ext) {
|
2367 |
+
if (to < ext.lineN)
|
2368 |
+
ext.lineN += lendiff;
|
2369 |
+
else if (from < ext.lineN + ext.size)
|
2370 |
+
display.externalMeasured = null;
|
2371 |
+
}
|
2372 |
+
}
|
2373 |
+
|
2374 |
+
// Register a change to a single line. Type must be one of "text",
|
2375 |
+
// "gutter", "class", "widget"
|
2376 |
+
function regLineChange(cm, line, type) {
|
2377 |
+
cm.curOp.viewChanged = true;
|
2378 |
+
var display = cm.display, ext = cm.display.externalMeasured;
|
2379 |
+
if (ext && line >= ext.lineN && line < ext.lineN + ext.size)
|
2380 |
+
display.externalMeasured = null;
|
2381 |
+
|
2382 |
+
if (line < display.viewFrom || line >= display.viewTo) return;
|
2383 |
+
var lineView = display.view[findViewIndex(cm, line)];
|
2384 |
+
if (lineView.node == null) return;
|
2385 |
+
var arr = lineView.changes || (lineView.changes = []);
|
2386 |
+
if (indexOf(arr, type) == -1) arr.push(type);
|
2387 |
+
}
|
2388 |
+
|
2389 |
+
// Clear the view.
|
2390 |
+
function resetView(cm) {
|
2391 |
+
cm.display.viewFrom = cm.display.viewTo = cm.doc.first;
|
2392 |
+
cm.display.view = [];
|
2393 |
+
cm.display.viewOffset = 0;
|
2394 |
+
}
|
2395 |
+
|
2396 |
+
// Find the view element corresponding to a given line. Return null
|
2397 |
+
// when the line isn't visible.
|
2398 |
+
function findViewIndex(cm, n) {
|
2399 |
+
if (n >= cm.display.viewTo) return null;
|
2400 |
+
n -= cm.display.viewFrom;
|
2401 |
+
if (n < 0) return null;
|
2402 |
+
var view = cm.display.view;
|
2403 |
+
for (var i = 0; i < view.length; i++) {
|
2404 |
+
n -= view[i].size;
|
2405 |
+
if (n < 0) return i;
|
2406 |
+
}
|
2407 |
+
}
|
2408 |
+
|
2409 |
+
function viewCuttingPoint(cm, oldN, newN, dir) {
|
2410 |
+
var index = findViewIndex(cm, oldN), diff, view = cm.display.view;
|
2411 |
+
if (!sawCollapsedSpans || newN == cm.doc.first + cm.doc.size)
|
2412 |
+
return {index: index, lineN: newN};
|
2413 |
+
for (var i = 0, n = cm.display.viewFrom; i < index; i++)
|
2414 |
+
n += view[i].size;
|
2415 |
+
if (n != oldN) {
|
2416 |
+
if (dir > 0) {
|
2417 |
+
if (index == view.length - 1) return null;
|
2418 |
+
diff = (n + view[index].size) - oldN;
|
2419 |
+
index++;
|
2420 |
+
} else {
|
2421 |
+
diff = n - oldN;
|
2422 |
+
}
|
2423 |
+
oldN += diff; newN += diff;
|
2424 |
+
}
|
2425 |
+
while (visualLineNo(cm.doc, newN) != newN) {
|
2426 |
+
if (index == (dir < 0 ? 0 : view.length - 1)) return null;
|
2427 |
+
newN += dir * view[index - (dir < 0 ? 1 : 0)].size;
|
2428 |
+
index += dir;
|
2429 |
+
}
|
2430 |
+
return {index: index, lineN: newN};
|
2431 |
+
}
|
2432 |
+
|
2433 |
+
// Force the view to cover a given range, adding empty view element
|
2434 |
+
// or clipping off existing ones as needed.
|
2435 |
+
function adjustView(cm, from, to) {
|
2436 |
+
var display = cm.display, view = display.view;
|
2437 |
+
if (view.length == 0 || from >= display.viewTo || to <= display.viewFrom) {
|
2438 |
+
display.view = buildViewArray(cm, from, to);
|
2439 |
+
display.viewFrom = from;
|
2440 |
+
} else {
|
2441 |
+
if (display.viewFrom > from)
|
2442 |
+
display.view = buildViewArray(cm, from, display.viewFrom).concat(display.view);
|
2443 |
+
else if (display.viewFrom < from)
|
2444 |
+
display.view = display.view.slice(findViewIndex(cm, from));
|
2445 |
+
display.viewFrom = from;
|
2446 |
+
if (display.viewTo < to)
|
2447 |
+
display.view = display.view.concat(buildViewArray(cm, display.viewTo, to));
|
2448 |
+
else if (display.viewTo > to)
|
2449 |
+
display.view = display.view.slice(0, findViewIndex(cm, to));
|
2450 |
+
}
|
2451 |
+
display.viewTo = to;
|
2452 |
+
}
|
2453 |
+
|
2454 |
+
// Count the number of lines in the view whose DOM representation is
|
2455 |
+
// out of date (or nonexistent).
|
2456 |
+
function countDirtyView(cm) {
|
2457 |
+
var view = cm.display.view, dirty = 0;
|
2458 |
+
for (var i = 0; i < view.length; i++) {
|
2459 |
+
var lineView = view[i];
|
2460 |
+
if (!lineView.hidden && (!lineView.node || lineView.changes)) ++dirty;
|
2461 |
+
}
|
2462 |
+
return dirty;
|
2463 |
+
}
|
2464 |
+
|
2465 |
+
// INPUT HANDLING
|
2466 |
+
|
2467 |
+
// Poll for input changes, using the normal rate of polling. This
|
2468 |
+
// runs as long as the editor is focused.
|
2469 |
+
function slowPoll(cm) {
|
2470 |
+
if (cm.display.pollingFast) return;
|
2471 |
+
cm.display.poll.set(cm.options.pollInterval, function() {
|
2472 |
+
readInput(cm);
|
2473 |
+
if (cm.state.focused) slowPoll(cm);
|
2474 |
+
});
|
2475 |
+
}
|
2476 |
+
|
2477 |
+
// When an event has just come in that is likely to add or change
|
2478 |
+
// something in the input textarea, we poll faster, to ensure that
|
2479 |
+
// the change appears on the screen quickly.
|
2480 |
+
function fastPoll(cm) {
|
2481 |
+
var missed = false;
|
2482 |
+
cm.display.pollingFast = true;
|
2483 |
+
function p() {
|
2484 |
+
var changed = readInput(cm);
|
2485 |
+
if (!changed && !missed) {missed = true; cm.display.poll.set(60, p);}
|
2486 |
+
else {cm.display.pollingFast = false; slowPoll(cm);}
|
2487 |
+
}
|
2488 |
+
cm.display.poll.set(20, p);
|
2489 |
+
}
|
2490 |
+
|
2491 |
+
// This will be set to an array of strings when copying, so that,
|
2492 |
+
// when pasting, we know what kind of selections the copied text
|
2493 |
+
// was made out of.
|
2494 |
+
var lastCopied = null;
|
2495 |
+
|
2496 |
+
// Read input from the textarea, and update the document to match.
|
2497 |
+
// When something is selected, it is present in the textarea, and
|
2498 |
+
// selected (unless it is huge, in which case a placeholder is
|
2499 |
+
// used). When nothing is selected, the cursor sits after previously
|
2500 |
+
// seen text (can be empty), which is stored in prevInput (we must
|
2501 |
+
// not reset the textarea when typing, because that breaks IME).
|
2502 |
+
function readInput(cm) {
|
2503 |
+
var input = cm.display.input, prevInput = cm.display.prevInput, doc = cm.doc;
|
2504 |
+
// Since this is called a *lot*, try to bail out as cheaply as
|
2505 |
+
// possible when it is clear that nothing happened. hasSelection
|
2506 |
+
// will be the case when there is a lot of text in the textarea,
|
2507 |
+
// in which case reading its value would be expensive.
|
2508 |
+
if (!cm.state.focused || (hasSelection(input) && !prevInput) || isReadOnly(cm) || cm.options.disableInput || cm.state.keySeq)
|
2509 |
+
return false;
|
2510 |
+
// See paste handler for more on the fakedLastChar kludge
|
2511 |
+
if (cm.state.pasteIncoming && cm.state.fakedLastChar) {
|
2512 |
+
input.value = input.value.substring(0, input.value.length - 1);
|
2513 |
+
cm.state.fakedLastChar = false;
|
2514 |
+
}
|
2515 |
+
var text = input.value;
|
2516 |
+
// If nothing changed, bail.
|
2517 |
+
if (text == prevInput && !cm.somethingSelected()) return false;
|
2518 |
+
// Work around nonsensical selection resetting in IE9/10, and
|
2519 |
+
// inexplicable appearance of private area unicode characters on
|
2520 |
+
// some key combos in Mac (#2689).
|
2521 |
+
if (ie && ie_version >= 9 && cm.display.inputHasSelection === text ||
|
2522 |
+
mac && /[\uf700-\uf7ff]/.test(text)) {
|
2523 |
+
resetInput(cm);
|
2524 |
+
return false;
|
2525 |
+
}
|
2526 |
+
|
2527 |
+
var withOp = !cm.curOp;
|
2528 |
+
if (withOp) startOperation(cm);
|
2529 |
+
cm.display.shift = false;
|
2530 |
+
|
2531 |
+
if (text.charCodeAt(0) == 0x200b && doc.sel == cm.display.selForContextMenu && !prevInput)
|
2532 |
+
prevInput = "\u200b";
|
2533 |
+
// Find the part of the input that is actually new
|
2534 |
+
var same = 0, l = Math.min(prevInput.length, text.length);
|
2535 |
+
while (same < l && prevInput.charCodeAt(same) == text.charCodeAt(same)) ++same;
|
2536 |
+
var inserted = text.slice(same), textLines = splitLines(inserted);
|
2537 |
+
|
2538 |
+
// When pasing N lines into N selections, insert one line per selection
|
2539 |
+
var multiPaste = null;
|
2540 |
+
if (cm.state.pasteIncoming && doc.sel.ranges.length > 1) {
|
2541 |
+
if (lastCopied && lastCopied.join("\n") == inserted)
|
2542 |
+
multiPaste = doc.sel.ranges.length % lastCopied.length == 0 && map(lastCopied, splitLines);
|
2543 |
+
else if (textLines.length == doc.sel.ranges.length)
|
2544 |
+
multiPaste = map(textLines, function(l) { return [l]; });
|
2545 |
+
}
|
2546 |
+
|
2547 |
+
// Normal behavior is to insert the new text into every selection
|
2548 |
+
for (var i = doc.sel.ranges.length - 1; i >= 0; i--) {
|
2549 |
+
var range = doc.sel.ranges[i];
|
2550 |
+
var from = range.from(), to = range.to();
|
2551 |
+
// Handle deletion
|
2552 |
+
if (same < prevInput.length)
|
2553 |
+
from = Pos(from.line, from.ch - (prevInput.length - same));
|
2554 |
+
// Handle overwrite
|
2555 |
+
else if (cm.state.overwrite && range.empty() && !cm.state.pasteIncoming)
|
2556 |
+
to = Pos(to.line, Math.min(getLine(doc, to.line).text.length, to.ch + lst(textLines).length));
|
2557 |
+
var updateInput = cm.curOp.updateInput;
|
2558 |
+
var changeEvent = {from: from, to: to, text: multiPaste ? multiPaste[i % multiPaste.length] : textLines,
|
2559 |
+
origin: cm.state.pasteIncoming ? "paste" : cm.state.cutIncoming ? "cut" : "+input"};
|
2560 |
+
makeChange(cm.doc, changeEvent);
|
2561 |
+
signalLater(cm, "inputRead", cm, changeEvent);
|
2562 |
+
// When an 'electric' character is inserted, immediately trigger a reindent
|
2563 |
+
if (inserted && !cm.state.pasteIncoming && cm.options.electricChars &&
|
2564 |
+
cm.options.smartIndent && range.head.ch < 100 &&
|
2565 |
+
(!i || doc.sel.ranges[i - 1].head.line != range.head.line)) {
|
2566 |
+
var mode = cm.getModeAt(range.head);
|
2567 |
+
var end = changeEnd(changeEvent);
|
2568 |
+
if (mode.electricChars) {
|
2569 |
+
for (var j = 0; j < mode.electricChars.length; j++)
|
2570 |
+
if (inserted.indexOf(mode.electricChars.charAt(j)) > -1) {
|
2571 |
+
indentLine(cm, end.line, "smart");
|
2572 |
+
break;
|
2573 |
+
}
|
2574 |
+
} else if (mode.electricInput) {
|
2575 |
+
if (mode.electricInput.test(getLine(doc, end.line).text.slice(0, end.ch)))
|
2576 |
+
indentLine(cm, end.line, "smart");
|
2577 |
+
}
|
2578 |
+
}
|
2579 |
+
}
|
2580 |
+
ensureCursorVisible(cm);
|
2581 |
+
cm.curOp.updateInput = updateInput;
|
2582 |
+
cm.curOp.typing = true;
|
2583 |
+
|
2584 |
+
// Don't leave long text in the textarea, since it makes further polling slow
|
2585 |
+
if (text.length > 1000 || text.indexOf("\n") > -1) input.value = cm.display.prevInput = "";
|
2586 |
+
else cm.display.prevInput = text;
|
2587 |
+
if (withOp) endOperation(cm);
|
2588 |
+
cm.state.pasteIncoming = cm.state.cutIncoming = false;
|
2589 |
+
return true;
|
2590 |
+
}
|
2591 |
+
|
2592 |
+
// Reset the input to correspond to the selection (or to be empty,
|
2593 |
+
// when not typing and nothing is selected)
|
2594 |
+
function resetInput(cm, typing) {
|
2595 |
+
if (cm.display.contextMenuPending) return;
|
2596 |
+
var minimal, selected, doc = cm.doc;
|
2597 |
+
if (cm.somethingSelected()) {
|
2598 |
+
cm.display.prevInput = "";
|
2599 |
+
var range = doc.sel.primary();
|
2600 |
+
minimal = hasCopyEvent &&
|
2601 |
+
(range.to().line - range.from().line > 100 || (selected = cm.getSelection()).length > 1000);
|
2602 |
+
var content = minimal ? "-" : selected || cm.getSelection();
|
2603 |
+
cm.display.input.value = content;
|
2604 |
+
if (cm.state.focused) selectInput(cm.display.input);
|
2605 |
+
if (ie && ie_version >= 9) cm.display.inputHasSelection = content;
|
2606 |
+
} else if (!typing) {
|
2607 |
+
cm.display.prevInput = cm.display.input.value = "";
|
2608 |
+
if (ie && ie_version >= 9) cm.display.inputHasSelection = null;
|
2609 |
+
}
|
2610 |
+
cm.display.inaccurateSelection = minimal;
|
2611 |
+
}
|
2612 |
+
|
2613 |
+
function focusInput(cm) {
|
2614 |
+
if (cm.options.readOnly != "nocursor" && (!mobile || activeElt() != cm.display.input))
|
2615 |
+
cm.display.input.focus();
|
2616 |
+
}
|
2617 |
+
|
2618 |
+
function ensureFocus(cm) {
|
2619 |
+
if (!cm.state.focused) { focusInput(cm); onFocus(cm); }
|
2620 |
+
}
|
2621 |
+
|
2622 |
+
function isReadOnly(cm) {
|
2623 |
+
return cm.options.readOnly || cm.doc.cantEdit;
|
2624 |
+
}
|
2625 |
+
|
2626 |
+
// EVENT HANDLERS
|
2627 |
+
|
2628 |
+
// Attach the necessary event handlers when initializing the editor
|
2629 |
+
function registerEventHandlers(cm) {
|
2630 |
+
var d = cm.display;
|
2631 |
+
on(d.scroller, "mousedown", operation(cm, onMouseDown));
|
2632 |
+
// Older IE's will not fire a second mousedown for a double click
|
2633 |
+
if (ie && ie_version < 11)
|
2634 |
+
on(d.scroller, "dblclick", operation(cm, function(e) {
|
2635 |
+
if (signalDOMEvent(cm, e)) return;
|
2636 |
+
var pos = posFromMouse(cm, e);
|
2637 |
+
if (!pos || clickInGutter(cm, e) || eventInWidget(cm.display, e)) return;
|
2638 |
+
e_preventDefault(e);
|
2639 |
+
var word = cm.findWordAt(pos);
|
2640 |
+
extendSelection(cm.doc, word.anchor, word.head);
|
2641 |
+
}));
|
2642 |
+
else
|
2643 |
+
on(d.scroller, "dblclick", function(e) { signalDOMEvent(cm, e) || e_preventDefault(e); });
|
2644 |
+
// Prevent normal selection in the editor (we handle our own)
|
2645 |
+
on(d.lineSpace, "selectstart", function(e) {
|
2646 |
+
if (!eventInWidget(d, e)) e_preventDefault(e);
|
2647 |
+
});
|
2648 |
+
// Some browsers fire contextmenu *after* opening the menu, at
|
2649 |
+
// which point we can't mess with it anymore. Context menu is
|
2650 |
+
// handled in onMouseDown for these browsers.
|
2651 |
+
if (!captureRightClick) on(d.scroller, "contextmenu", function(e) {onContextMenu(cm, e);});
|
2652 |
+
|
2653 |
+
// Sync scrolling between fake scrollbars and real scrollable
|
2654 |
+
// area, ensure viewport is updated when scrolling.
|
2655 |
+
on(d.scroller, "scroll", function() {
|
2656 |
+
if (d.scroller.clientHeight) {
|
2657 |
+
setScrollTop(cm, d.scroller.scrollTop);
|
2658 |
+
setScrollLeft(cm, d.scroller.scrollLeft, true);
|
2659 |
+
signal(cm, "scroll", cm);
|
2660 |
+
}
|
2661 |
+
});
|
2662 |
+
|
2663 |
+
// Listen to wheel events in order to try and update the viewport on time.
|
2664 |
+
on(d.scroller, "mousewheel", function(e){onScrollWheel(cm, e);});
|
2665 |
+
on(d.scroller, "DOMMouseScroll", function(e){onScrollWheel(cm, e);});
|
2666 |
+
|
2667 |
+
// Prevent wrapper from ever scrolling
|
2668 |
+
on(d.wrapper, "scroll", function() { d.wrapper.scrollTop = d.wrapper.scrollLeft = 0; });
|
2669 |
+
|
2670 |
+
on(d.input, "keyup", function(e) { onKeyUp.call(cm, e); });
|
2671 |
+
on(d.input, "input", function() {
|
2672 |
+
if (ie && ie_version >= 9 && cm.display.inputHasSelection) cm.display.inputHasSelection = null;
|
2673 |
+
readInput(cm);
|
2674 |
+
});
|
2675 |
+
on(d.input, "keydown", operation(cm, onKeyDown));
|
2676 |
+
on(d.input, "keypress", operation(cm, onKeyPress));
|
2677 |
+
on(d.input, "focus", bind(onFocus, cm));
|
2678 |
+
on(d.input, "blur", bind(onBlur, cm));
|
2679 |
+
|
2680 |
+
function drag_(e) {
|
2681 |
+
if (!signalDOMEvent(cm, e)) e_stop(e);
|
2682 |
+
}
|
2683 |
+
if (cm.options.dragDrop) {
|
2684 |
+
on(d.scroller, "dragstart", function(e){onDragStart(cm, e);});
|
2685 |
+
on(d.scroller, "dragenter", drag_);
|
2686 |
+
on(d.scroller, "dragover", drag_);
|
2687 |
+
on(d.scroller, "drop", operation(cm, onDrop));
|
2688 |
+
}
|
2689 |
+
on(d.scroller, "paste", function(e) {
|
2690 |
+
if (eventInWidget(d, e)) return;
|
2691 |
+
cm.state.pasteIncoming = true;
|
2692 |
+
focusInput(cm);
|
2693 |
+
fastPoll(cm);
|
2694 |
+
});
|
2695 |
+
on(d.input, "paste", function() {
|
2696 |
+
// Workaround for webkit bug https://bugs.webkit.org/show_bug.cgi?id=90206
|
2697 |
+
// Add a char to the end of textarea before paste occur so that
|
2698 |
+
// selection doesn't span to the end of textarea.
|
2699 |
+
if (webkit && !cm.state.fakedLastChar && !(new Date - cm.state.lastMiddleDown < 200)) {
|
2700 |
+
var start = d.input.selectionStart, end = d.input.selectionEnd;
|
2701 |
+
d.input.value += "$";
|
2702 |
+
// The selection end needs to be set before the start, otherwise there
|
2703 |
+
// can be an intermediate non-empty selection between the two, which
|
2704 |
+
// can override the middle-click paste buffer on linux and cause the
|
2705 |
+
// wrong thing to get pasted.
|
2706 |
+
d.input.selectionEnd = end;
|
2707 |
+
d.input.selectionStart = start;
|
2708 |
+
cm.state.fakedLastChar = true;
|
2709 |
+
}
|
2710 |
+
cm.state.pasteIncoming = true;
|
2711 |
+
fastPoll(cm);
|
2712 |
+
});
|
2713 |
+
|
2714 |
+
function prepareCopyCut(e) {
|
2715 |
+
if (cm.somethingSelected()) {
|
2716 |
+
lastCopied = cm.getSelections();
|
2717 |
+
if (d.inaccurateSelection) {
|
2718 |
+
d.prevInput = "";
|
2719 |
+
d.inaccurateSelection = false;
|
2720 |
+
d.input.value = lastCopied.join("\n");
|
2721 |
+
selectInput(d.input);
|
2722 |
+
}
|
2723 |
+
} else {
|
2724 |
+
var text = [], ranges = [];
|
2725 |
+
for (var i = 0; i < cm.doc.sel.ranges.length; i++) {
|
2726 |
+
var line = cm.doc.sel.ranges[i].head.line;
|
2727 |
+
var lineRange = {anchor: Pos(line, 0), head: Pos(line + 1, 0)};
|
2728 |
+
ranges.push(lineRange);
|
2729 |
+
text.push(cm.getRange(lineRange.anchor, lineRange.head));
|
2730 |
+
}
|
2731 |
+
if (e.type == "cut") {
|
2732 |
+
cm.setSelections(ranges, null, sel_dontScroll);
|
2733 |
+
} else {
|
2734 |
+
d.prevInput = "";
|
2735 |
+
d.input.value = text.join("\n");
|
2736 |
+
selectInput(d.input);
|
2737 |
+
}
|
2738 |
+
lastCopied = text;
|
2739 |
+
}
|
2740 |
+
if (e.type == "cut") cm.state.cutIncoming = true;
|
2741 |
+
}
|
2742 |
+
on(d.input, "cut", prepareCopyCut);
|
2743 |
+
on(d.input, "copy", prepareCopyCut);
|
2744 |
+
|
2745 |
+
// Needed to handle Tab key in KHTML
|
2746 |
+
if (khtml) on(d.sizer, "mouseup", function() {
|
2747 |
+
if (activeElt() == d.input) d.input.blur();
|
2748 |
+
focusInput(cm);
|
2749 |
+
});
|
2750 |
+
}
|
2751 |
+
|
2752 |
+
// Called when the window resizes
|
2753 |
+
function onResize(cm) {
|
2754 |
+
var d = cm.display;
|
2755 |
+
if (d.lastWrapHeight == d.wrapper.clientHeight && d.lastWrapWidth == d.wrapper.clientWidth)
|
2756 |
+
return;
|
2757 |
+
// Might be a text scaling operation, clear size caches.
|
2758 |
+
d.cachedCharWidth = d.cachedTextHeight = d.cachedPaddingH = null;
|
2759 |
+
d.scrollbarsClipped = false;
|
2760 |
+
cm.setSize();
|
2761 |
+
}
|
2762 |
+
|
2763 |
+
// MOUSE EVENTS
|
2764 |
+
|
2765 |
+
// Return true when the given mouse event happened in a widget
|
2766 |
+
function eventInWidget(display, e) {
|
2767 |
+
for (var n = e_target(e); n != display.wrapper; n = n.parentNode) {
|
2768 |
+
if (!n || (n.nodeType == 1 && n.getAttribute("cm-ignore-events") == "true") ||
|
2769 |
+
(n.parentNode == display.sizer && n != display.mover))
|
2770 |
+
return true;
|
2771 |
+
}
|
2772 |
+
}
|
2773 |
+
|
2774 |
+
// Given a mouse event, find the corresponding position. If liberal
|
2775 |
+
// is false, it checks whether a gutter or scrollbar was clicked,
|
2776 |
+
// and returns null if it was. forRect is used by rectangular
|
2777 |
+
// selections, and tries to estimate a character position even for
|
2778 |
+
// coordinates beyond the right of the text.
|
2779 |
+
function posFromMouse(cm, e, liberal, forRect) {
|
2780 |
+
var display = cm.display;
|
2781 |
+
if (!liberal && e_target(e).getAttribute("not-content") == "true") return null;
|
2782 |
+
|
2783 |
+
var x, y, space = display.lineSpace.getBoundingClientRect();
|
2784 |
+
// Fails unpredictably on IE[67] when mouse is dragged around quickly.
|
2785 |
+
try { x = e.clientX - space.left; y = e.clientY - space.top; }
|
2786 |
+
catch (e) { return null; }
|
2787 |
+
var coords = coordsChar(cm, x, y), line;
|
2788 |
+
if (forRect && coords.xRel == 1 && (line = getLine(cm.doc, coords.line).text).length == coords.ch) {
|
2789 |
+
var colDiff = countColumn(line, line.length, cm.options.tabSize) - line.length;
|
2790 |
+
coords = Pos(coords.line, Math.max(0, Math.round((x - paddingH(cm.display).left) / charWidth(cm.display)) - colDiff));
|
2791 |
+
}
|
2792 |
+
return coords;
|
2793 |
+
}
|
2794 |
+
|
2795 |
+
// A mouse down can be a single click, double click, triple click,
|
2796 |
+
// start of selection drag, start of text drag, new cursor
|
2797 |
+
// (ctrl-click), rectangle drag (alt-drag), or xwin
|
2798 |
+
// middle-click-paste. Or it might be a click on something we should
|
2799 |
+
// not interfere with, such as a scrollbar or widget.
|
2800 |
+
function onMouseDown(e) {
|
2801 |
+
if (signalDOMEvent(this, e)) return;
|
2802 |
+
var cm = this, display = cm.display;
|
2803 |
+
display.shift = e.shiftKey;
|
2804 |
+
|
2805 |
+
if (eventInWidget(display, e)) {
|
2806 |
+
if (!webkit) {
|
2807 |
+
// Briefly turn off draggability, to allow widgets to do
|
2808 |
+
// normal dragging things.
|
2809 |
+
display.scroller.draggable = false;
|
2810 |
+
setTimeout(function(){display.scroller.draggable = true;}, 100);
|
2811 |
+
}
|
2812 |
+
return;
|
2813 |
+
}
|
2814 |
+
if (clickInGutter(cm, e)) return;
|
2815 |
+
var start = posFromMouse(cm, e);
|
2816 |
+
window.focus();
|
2817 |
+
|
2818 |
+
switch (e_button(e)) {
|
2819 |
+
case 1:
|
2820 |
+
if (start)
|
2821 |
+
leftButtonDown(cm, e, start);
|
2822 |
+
else if (e_target(e) == display.scroller)
|
2823 |
+
e_preventDefault(e);
|
2824 |
+
break;
|
2825 |
+
case 2:
|
2826 |
+
if (webkit) cm.state.lastMiddleDown = +new Date;
|
2827 |
+
if (start) extendSelection(cm.doc, start);
|
2828 |
+
setTimeout(bind(focusInput, cm), 20);
|
2829 |
+
e_preventDefault(e);
|
2830 |
+
break;
|
2831 |
+
case 3:
|
2832 |
+
if (captureRightClick) onContextMenu(cm, e);
|
2833 |
+
break;
|
2834 |
+
}
|
2835 |
+
}
|
2836 |
+
|
2837 |
+
var lastClick, lastDoubleClick;
|
2838 |
+
function leftButtonDown(cm, e, start) {
|
2839 |
+
setTimeout(bind(ensureFocus, cm), 0);
|
2840 |
+
|
2841 |
+
var now = +new Date, type;
|
2842 |
+
if (lastDoubleClick && lastDoubleClick.time > now - 400 && cmp(lastDoubleClick.pos, start) == 0) {
|
2843 |
+
type = "triple";
|
2844 |
+
} else if (lastClick && lastClick.time > now - 400 && cmp(lastClick.pos, start) == 0) {
|
2845 |
+
type = "double";
|
2846 |
+
lastDoubleClick = {time: now, pos: start};
|
2847 |
+
} else {
|
2848 |
+
type = "single";
|
2849 |
+
lastClick = {time: now, pos: start};
|
2850 |
+
}
|
2851 |
+
|
2852 |
+
var sel = cm.doc.sel, modifier = mac ? e.metaKey : e.ctrlKey, contained;
|
2853 |
+
if (cm.options.dragDrop && dragAndDrop && !isReadOnly(cm) &&
|
2854 |
+
type == "single" && (contained = sel.contains(start)) > -1 &&
|
2855 |
+
!sel.ranges[contained].empty())
|
2856 |
+
leftButtonStartDrag(cm, e, start, modifier);
|
2857 |
+
else
|
2858 |
+
leftButtonSelect(cm, e, start, type, modifier);
|
2859 |
+
}
|
2860 |
+
|
2861 |
+
// Start a text drag. When it ends, see if any dragging actually
|
2862 |
+
// happen, and treat as a click if it didn't.
|
2863 |
+
function leftButtonStartDrag(cm, e, start, modifier) {
|
2864 |
+
var display = cm.display;
|
2865 |
+
var dragEnd = operation(cm, function(e2) {
|
2866 |
+
if (webkit) display.scroller.draggable = false;
|
2867 |
+
cm.state.draggingText = false;
|
2868 |
+
off(document, "mouseup", dragEnd);
|
2869 |
+
off(display.scroller, "drop", dragEnd);
|
2870 |
+
if (Math.abs(e.clientX - e2.clientX) + Math.abs(e.clientY - e2.clientY) < 10) {
|
2871 |
+
e_preventDefault(e2);
|
2872 |
+
if (!modifier)
|
2873 |
+
extendSelection(cm.doc, start);
|
2874 |
+
focusInput(cm);
|
2875 |
+
// Work around unexplainable focus problem in IE9 (#2127)
|
2876 |
+
if (ie && ie_version == 9)
|
2877 |
+
setTimeout(function() {document.body.focus(); focusInput(cm);}, 20);
|
2878 |
+
}
|
2879 |
+
});
|
2880 |
+
// Let the drag handler handle this.
|
2881 |
+
if (webkit) display.scroller.draggable = true;
|
2882 |
+
cm.state.draggingText = dragEnd;
|
2883 |
+
// IE's approach to draggable
|
2884 |
+
if (display.scroller.dragDrop) display.scroller.dragDrop();
|
2885 |
+
on(document, "mouseup", dragEnd);
|
2886 |
+
on(display.scroller, "drop", dragEnd);
|
2887 |
+
}
|
2888 |
+
|
2889 |
+
// Normal selection, as opposed to text dragging.
|
2890 |
+
function leftButtonSelect(cm, e, start, type, addNew) {
|
2891 |
+
var display = cm.display, doc = cm.doc;
|
2892 |
+
e_preventDefault(e);
|
2893 |
+
|
2894 |
+
var ourRange, ourIndex, startSel = doc.sel, ranges = startSel.ranges;
|
2895 |
+
if (addNew && !e.shiftKey) {
|
2896 |
+
ourIndex = doc.sel.contains(start);
|
2897 |
+
if (ourIndex > -1)
|
2898 |
+
ourRange = ranges[ourIndex];
|
2899 |
+
else
|
2900 |
+
ourRange = new Range(start, start);
|
2901 |
+
} else {
|
2902 |
+
ourRange = doc.sel.primary();
|
2903 |
+
}
|
2904 |
+
|
2905 |
+
if (e.altKey) {
|
2906 |
+
type = "rect";
|
2907 |
+
if (!addNew) ourRange = new Range(start, start);
|
2908 |
+
start = posFromMouse(cm, e, true, true);
|
2909 |
+
ourIndex = -1;
|
2910 |
+
} else if (type == "double") {
|
2911 |
+
var word = cm.findWordAt(start);
|
2912 |
+
if (cm.display.shift || doc.extend)
|
2913 |
+
ourRange = extendRange(doc, ourRange, word.anchor, word.head);
|
2914 |
+
else
|
2915 |
+
ourRange = word;
|
2916 |
+
} else if (type == "triple") {
|
2917 |
+
var line = new Range(Pos(start.line, 0), clipPos(doc, Pos(start.line + 1, 0)));
|
2918 |
+
if (cm.display.shift || doc.extend)
|
2919 |
+
ourRange = extendRange(doc, ourRange, line.anchor, line.head);
|
2920 |
+
else
|
2921 |
+
ourRange = line;
|
2922 |
+
} else {
|
2923 |
+
ourRange = extendRange(doc, ourRange, start);
|
2924 |
+
}
|
2925 |
+
|
2926 |
+
if (!addNew) {
|
2927 |
+
ourIndex = 0;
|
2928 |
+
setSelection(doc, new Selection([ourRange], 0), sel_mouse);
|
2929 |
+
startSel = doc.sel;
|
2930 |
+
} else if (ourIndex == -1) {
|
2931 |
+
ourIndex = ranges.length;
|
2932 |
+
setSelection(doc, normalizeSelection(ranges.concat([ourRange]), ourIndex),
|
2933 |
+
{scroll: false, origin: "*mouse"});
|
2934 |
+
} else if (ranges.length > 1 && ranges[ourIndex].empty() && type == "single") {
|
2935 |
+
setSelection(doc, normalizeSelection(ranges.slice(0, ourIndex).concat(ranges.slice(ourIndex + 1)), 0));
|
2936 |
+
startSel = doc.sel;
|
2937 |
+
} else {
|
2938 |
+
replaceOneSelection(doc, ourIndex, ourRange, sel_mouse);
|
2939 |
+
}
|
2940 |
+
|
2941 |
+
var lastPos = start;
|
2942 |
+
function extendTo(pos) {
|
2943 |
+
if (cmp(lastPos, pos) == 0) return;
|
2944 |
+
lastPos = pos;
|
2945 |
+
|
2946 |
+
if (type == "rect") {
|
2947 |
+
var ranges = [], tabSize = cm.options.tabSize;
|
2948 |
+
var startCol = countColumn(getLine(doc, start.line).text, start.ch, tabSize);
|
2949 |
+
var posCol = countColumn(getLine(doc, pos.line).text, pos.ch, tabSize);
|
2950 |
+
var left = Math.min(startCol, posCol), right = Math.max(startCol, posCol);
|
2951 |
+
for (var line = Math.min(start.line, pos.line), end = Math.min(cm.lastLine(), Math.max(start.line, pos.line));
|
2952 |
+
line <= end; line++) {
|
2953 |
+
var text = getLine(doc, line).text, leftPos = findColumn(text, left, tabSize);
|
2954 |
+
if (left == right)
|
2955 |
+
ranges.push(new Range(Pos(line, leftPos), Pos(line, leftPos)));
|
2956 |
+
else if (text.length > leftPos)
|
2957 |
+
ranges.push(new Range(Pos(line, leftPos), Pos(line, findColumn(text, right, tabSize))));
|
2958 |
+
}
|
2959 |
+
if (!ranges.length) ranges.push(new Range(start, start));
|
2960 |
+
setSelection(doc, normalizeSelection(startSel.ranges.slice(0, ourIndex).concat(ranges), ourIndex),
|
2961 |
+
{origin: "*mouse", scroll: false});
|
2962 |
+
cm.scrollIntoView(pos);
|
2963 |
+
} else {
|
2964 |
+
var oldRange = ourRange;
|
2965 |
+
var anchor = oldRange.anchor, head = pos;
|
2966 |
+
if (type != "single") {
|
2967 |
+
if (type == "double")
|
2968 |
+
var range = cm.findWordAt(pos);
|
2969 |
+
else
|
2970 |
+
var range = new Range(Pos(pos.line, 0), clipPos(doc, Pos(pos.line + 1, 0)));
|
2971 |
+
if (cmp(range.anchor, anchor) > 0) {
|
2972 |
+
head = range.head;
|
2973 |
+
anchor = minPos(oldRange.from(), range.anchor);
|
2974 |
+
} else {
|
2975 |
+
head = range.anchor;
|
2976 |
+
anchor = maxPos(oldRange.to(), range.head);
|
2977 |
+
}
|
2978 |
+
}
|
2979 |
+
var ranges = startSel.ranges.slice(0);
|
2980 |
+
ranges[ourIndex] = new Range(clipPos(doc, anchor), head);
|
2981 |
+
setSelection(doc, normalizeSelection(ranges, ourIndex), sel_mouse);
|
2982 |
+
}
|
2983 |
+
}
|
2984 |
+
|
2985 |
+
var editorSize = display.wrapper.getBoundingClientRect();
|
2986 |
+
// Used to ensure timeout re-tries don't fire when another extend
|
2987 |
+
// happened in the meantime (clearTimeout isn't reliable -- at
|
2988 |
+
// least on Chrome, the timeouts still happen even when cleared,
|
2989 |
+
// if the clear happens after their scheduled firing time).
|
2990 |
+
var counter = 0;
|
2991 |
+
|
2992 |
+
function extend(e) {
|
2993 |
+
var curCount = ++counter;
|
2994 |
+
var cur = posFromMouse(cm, e, true, type == "rect");
|
2995 |
+
if (!cur) return;
|
2996 |
+
if (cmp(cur, lastPos) != 0) {
|
2997 |
+
ensureFocus(cm);
|
2998 |
+
extendTo(cur);
|
2999 |
+
var visible = visibleLines(display, doc);
|
3000 |
+
if (cur.line >= visible.to || cur.line < visible.from)
|
3001 |
+
setTimeout(operation(cm, function(){if (counter == curCount) extend(e);}), 150);
|
3002 |
+
} else {
|
3003 |
+
var outside = e.clientY < editorSize.top ? -20 : e.clientY > editorSize.bottom ? 20 : 0;
|
3004 |
+
if (outside) setTimeout(operation(cm, function() {
|
3005 |
+
if (counter != curCount) return;
|
3006 |
+
display.scroller.scrollTop += outside;
|
3007 |
+
extend(e);
|
3008 |
+
}), 50);
|
3009 |
+
}
|
3010 |
+
}
|
3011 |
+
|
3012 |
+
function done(e) {
|
3013 |
+
counter = Infinity;
|
3014 |
+
e_preventDefault(e);
|
3015 |
+
focusInput(cm);
|
3016 |
+
off(document, "mousemove", move);
|
3017 |
+
off(document, "mouseup", up);
|
3018 |
+
doc.history.lastSelOrigin = null;
|
3019 |
+
}
|
3020 |
+
|
3021 |
+
var move = operation(cm, function(e) {
|
3022 |
+
if (!e_button(e)) done(e);
|
3023 |
+
else extend(e);
|
3024 |
+
});
|
3025 |
+
var up = operation(cm, done);
|
3026 |
+
on(document, "mousemove", move);
|
3027 |
+
on(document, "mouseup", up);
|
3028 |
+
}
|
3029 |
+
|
3030 |
+
// Determines whether an event happened in the gutter, and fires the
|
3031 |
+
// handlers for the corresponding event.
|
3032 |
+
function gutterEvent(cm, e, type, prevent, signalfn) {
|
3033 |
+
try { var mX = e.clientX, mY = e.clientY; }
|
3034 |
+
catch(e) { return false; }
|
3035 |
+
if (mX >= Math.floor(cm.display.gutters.getBoundingClientRect().right)) return false;
|
3036 |
+
if (prevent) e_preventDefault(e);
|
3037 |
+
|
3038 |
+
var display = cm.display;
|
3039 |
+
var lineBox = display.lineDiv.getBoundingClientRect();
|
3040 |
+
|
3041 |
+
if (mY > lineBox.bottom || !hasHandler(cm, type)) return e_defaultPrevented(e);
|
3042 |
+
mY -= lineBox.top - display.viewOffset;
|
3043 |
+
|
3044 |
+
for (var i = 0; i < cm.options.gutters.length; ++i) {
|
3045 |
+
var g = display.gutters.childNodes[i];
|
3046 |
+
if (g && g.getBoundingClientRect().right >= mX) {
|
3047 |
+
var line = lineAtHeight(cm.doc, mY);
|
3048 |
+
var gutter = cm.options.gutters[i];
|
3049 |
+
signalfn(cm, type, cm, line, gutter, e);
|
3050 |
+
return e_defaultPrevented(e);
|
3051 |
+
}
|
3052 |
+
}
|
3053 |
+
}
|
3054 |
+
|
3055 |
+
function clickInGutter(cm, e) {
|
3056 |
+
return gutterEvent(cm, e, "gutterClick", true, signalLater);
|
3057 |
+
}
|
3058 |
+
|
3059 |
+
// Kludge to work around strange IE behavior where it'll sometimes
|
3060 |
+
// re-fire a series of drag-related events right after the drop (#1551)
|
3061 |
+
var lastDrop = 0;
|
3062 |
+
|
3063 |
+
function onDrop(e) {
|
3064 |
+
var cm = this;
|
3065 |
+
if (signalDOMEvent(cm, e) || eventInWidget(cm.display, e))
|
3066 |
+
return;
|
3067 |
+
e_preventDefault(e);
|
3068 |
+
if (ie) lastDrop = +new Date;
|
3069 |
+
var pos = posFromMouse(cm, e, true), files = e.dataTransfer.files;
|
3070 |
+
if (!pos || isReadOnly(cm)) return;
|
3071 |
+
// Might be a file drop, in which case we simply extract the text
|
3072 |
+
// and insert it.
|
3073 |
+
if (files && files.length && window.FileReader && window.File) {
|
3074 |
+
var n = files.length, text = Array(n), read = 0;
|
3075 |
+
var loadFile = function(file, i) {
|
3076 |
+
var reader = new FileReader;
|
3077 |
+
reader.onload = operation(cm, function() {
|
3078 |
+
text[i] = reader.result;
|
3079 |
+
if (++read == n) {
|
3080 |
+
pos = clipPos(cm.doc, pos);
|
3081 |
+
var change = {from: pos, to: pos, text: splitLines(text.join("\n")), origin: "paste"};
|
3082 |
+
makeChange(cm.doc, change);
|
3083 |
+
setSelectionReplaceHistory(cm.doc, simpleSelection(pos, changeEnd(change)));
|
3084 |
+
}
|
3085 |
+
});
|
3086 |
+
reader.readAsText(file);
|
3087 |
+
};
|
3088 |
+
for (var i = 0; i < n; ++i) loadFile(files[i], i);
|
3089 |
+
} else { // Normal drop
|
3090 |
+
// Don't do a replace if the drop happened inside of the selected text.
|
3091 |
+
if (cm.state.draggingText && cm.doc.sel.contains(pos) > -1) {
|
3092 |
+
cm.state.draggingText(e);
|
3093 |
+
// Ensure the editor is re-focused
|
3094 |
+
setTimeout(bind(focusInput, cm), 20);
|
3095 |
+
return;
|
3096 |
+
}
|
3097 |
+
try {
|
3098 |
+
var text = e.dataTransfer.getData("Text");
|
3099 |
+
if (text) {
|
3100 |
+
if (cm.state.draggingText && !(mac ? e.metaKey : e.ctrlKey))
|
3101 |
+
var selected = cm.listSelections();
|
3102 |
+
setSelectionNoUndo(cm.doc, simpleSelection(pos, pos));
|
3103 |
+
if (selected) for (var i = 0; i < selected.length; ++i)
|
3104 |
+
replaceRange(cm.doc, "", selected[i].anchor, selected[i].head, "drag");
|
3105 |
+
cm.replaceSelection(text, "around", "paste");
|
3106 |
+
focusInput(cm);
|
3107 |
+
}
|
3108 |
+
}
|
3109 |
+
catch(e){}
|
3110 |
+
}
|
3111 |
+
}
|
3112 |
+
|
3113 |
+
function onDragStart(cm, e) {
|
3114 |
+
if (ie && (!cm.state.draggingText || +new Date - lastDrop < 100)) { e_stop(e); return; }
|
3115 |
+
if (signalDOMEvent(cm, e) || eventInWidget(cm.display, e)) return;
|
3116 |
+
|
3117 |
+
e.dataTransfer.setData("Text", cm.getSelection());
|
3118 |
+
|
3119 |
+
// Use dummy image instead of default browsers image.
|
3120 |
+
// Recent Safari (~6.0.2) have a tendency to segfault when this happens, so we don't do it there.
|
3121 |
+
if (e.dataTransfer.setDragImage && !safari) {
|
3122 |
+
var img = elt("img", null, null, "position: fixed; left: 0; top: 0;");
|
3123 |
+
img.src = "data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==";
|
3124 |
+
if (presto) {
|
3125 |
+
img.width = img.height = 1;
|
3126 |
+
cm.display.wrapper.appendChild(img);
|
3127 |
+
// Force a relayout, or Opera won't use our image for some obscure reason
|
3128 |
+
img._top = img.offsetTop;
|
3129 |
+
}
|
3130 |
+
e.dataTransfer.setDragImage(img, 0, 0);
|
3131 |
+
if (presto) img.parentNode.removeChild(img);
|
3132 |
+
}
|
3133 |
+
}
|
3134 |
+
|
3135 |
+
// SCROLL EVENTS
|
3136 |
+
|
3137 |
+
// Sync the scrollable area and scrollbars, ensure the viewport
|
3138 |
+
// covers the visible area.
|
3139 |
+
function setScrollTop(cm, val) {
|
3140 |
+
if (Math.abs(cm.doc.scrollTop - val) < 2) return;
|
3141 |
+
cm.doc.scrollTop = val;
|
3142 |
+
if (!gecko) updateDisplaySimple(cm, {top: val});
|
3143 |
+
if (cm.display.scroller.scrollTop != val) cm.display.scroller.scrollTop = val;
|
3144 |
+
cm.display.scrollbars.setScrollTop(val);
|
3145 |
+
if (gecko) updateDisplaySimple(cm);
|
3146 |
+
startWorker(cm, 100);
|
3147 |
+
}
|
3148 |
+
// Sync scroller and scrollbar, ensure the gutter elements are
|
3149 |
+
// aligned.
|
3150 |
+
function setScrollLeft(cm, val, isScroller) {
|
3151 |
+
if (isScroller ? val == cm.doc.scrollLeft : Math.abs(cm.doc.scrollLeft - val) < 2) return;
|
3152 |
+
val = Math.min(val, cm.display.scroller.scrollWidth - cm.display.scroller.clientWidth);
|
3153 |
+
cm.doc.scrollLeft = val;
|
3154 |
+
alignHorizontally(cm);
|
3155 |
+
if (cm.display.scroller.scrollLeft != val) cm.display.scroller.scrollLeft = val;
|
3156 |
+
cm.display.scrollbars.setScrollLeft(val);
|
3157 |
+
}
|
3158 |
+
|
3159 |
+
// Since the delta values reported on mouse wheel events are
|
3160 |
+
// unstandardized between browsers and even browser versions, and
|
3161 |
+
// generally horribly unpredictable, this code starts by measuring
|
3162 |
+
// the scroll effect that the first few mouse wheel events have,
|
3163 |
+
// and, from that, detects the way it can convert deltas to pixel
|
3164 |
+
// offsets afterwards.
|
3165 |
+
//
|
3166 |
+
// The reason we want to know the amount a wheel event will scroll
|
3167 |
+
// is that it gives us a chance to update the display before the
|
3168 |
+
// actual scrolling happens, reducing flickering.
|
3169 |
+
|
3170 |
+
var wheelSamples = 0, wheelPixelsPerUnit = null;
|
3171 |
+
// Fill in a browser-detected starting value on browsers where we
|
3172 |
+
// know one. These don't have to be accurate -- the result of them
|
3173 |
+
// being wrong would just be a slight flicker on the first wheel
|
3174 |
+
// scroll (if it is large enough).
|
3175 |
+
if (ie) wheelPixelsPerUnit = -.53;
|
3176 |
+
else if (gecko) wheelPixelsPerUnit = 15;
|
3177 |
+
else if (chrome) wheelPixelsPerUnit = -.7;
|
3178 |
+
else if (safari) wheelPixelsPerUnit = -1/3;
|
3179 |
+
|
3180 |
+
var wheelEventDelta = function(e) {
|
3181 |
+
var dx = e.wheelDeltaX, dy = e.wheelDeltaY;
|
3182 |
+
if (dx == null && e.detail && e.axis == e.HORIZONTAL_AXIS) dx = e.detail;
|
3183 |
+
if (dy == null && e.detail && e.axis == e.VERTICAL_AXIS) dy = e.detail;
|
3184 |
+
else if (dy == null) dy = e.wheelDelta;
|
3185 |
+
return {x: dx, y: dy};
|
3186 |
+
};
|
3187 |
+
CodeMirror.wheelEventPixels = function(e) {
|
3188 |
+
var delta = wheelEventDelta(e);
|
3189 |
+
delta.x *= wheelPixelsPerUnit;
|
3190 |
+
delta.y *= wheelPixelsPerUnit;
|
3191 |
+
return delta;
|
3192 |
+
};
|
3193 |
+
|
3194 |
+
function onScrollWheel(cm, e) {
|
3195 |
+
var delta = wheelEventDelta(e), dx = delta.x, dy = delta.y;
|
3196 |
+
|
3197 |
+
var display = cm.display, scroll = display.scroller;
|
3198 |
+
// Quit if there's nothing to scroll here
|
3199 |
+
if (!(dx && scroll.scrollWidth > scroll.clientWidth ||
|
3200 |
+
dy && scroll.scrollHeight > scroll.clientHeight)) return;
|
3201 |
+
|
3202 |
+
// Webkit browsers on OS X abort momentum scrolls when the target
|
3203 |
+
// of the scroll event is removed from the scrollable element.
|
3204 |
+
// This hack (see related code in patchDisplay) makes sure the
|
3205 |
+
// element is kept around.
|
3206 |
+
if (dy && mac && webkit) {
|
3207 |
+
outer: for (var cur = e.target, view = display.view; cur != scroll; cur = cur.parentNode) {
|
3208 |
+
for (var i = 0; i < view.length; i++) {
|
3209 |
+
if (view[i].node == cur) {
|
3210 |
+
cm.display.currentWheelTarget = cur;
|
3211 |
+
break outer;
|
3212 |
+
}
|
3213 |
+
}
|
3214 |
+
}
|
3215 |
+
}
|
3216 |
+
|
3217 |
+
// On some browsers, horizontal scrolling will cause redraws to
|
3218 |
+
// happen before the gutter has been realigned, causing it to
|
3219 |
+
// wriggle around in a most unseemly way. When we have an
|
3220 |
+
// estimated pixels/delta value, we just handle horizontal
|
3221 |
+
// scrolling entirely here. It'll be slightly off from native, but
|
3222 |
+
// better than glitching out.
|
3223 |
+
if (dx && !gecko && !presto && wheelPixelsPerUnit != null) {
|
3224 |
+
if (dy)
|
3225 |
+
setScrollTop(cm, Math.max(0, Math.min(scroll.scrollTop + dy * wheelPixelsPerUnit, scroll.scrollHeight - scroll.clientHeight)));
|
3226 |
+
setScrollLeft(cm, Math.max(0, Math.min(scroll.scrollLeft + dx * wheelPixelsPerUnit, scroll.scrollWidth - scroll.clientWidth)));
|
3227 |
+
e_preventDefault(e);
|
3228 |
+
display.wheelStartX = null; // Abort measurement, if in progress
|
3229 |
+
return;
|
3230 |
+
}
|
3231 |
+
|
3232 |
+
// 'Project' the visible viewport to cover the area that is being
|
3233 |
+
// scrolled into view (if we know enough to estimate it).
|
3234 |
+
if (dy && wheelPixelsPerUnit != null) {
|
3235 |
+
var pixels = dy * wheelPixelsPerUnit;
|
3236 |
+
var top = cm.doc.scrollTop, bot = top + display.wrapper.clientHeight;
|
3237 |
+
if (pixels < 0) top = Math.max(0, top + pixels - 50);
|
3238 |
+
else bot = Math.min(cm.doc.height, bot + pixels + 50);
|
3239 |
+
updateDisplaySimple(cm, {top: top, bottom: bot});
|
3240 |
+
}
|
3241 |
+
|
3242 |
+
if (wheelSamples < 20) {
|
3243 |
+
if (display.wheelStartX == null) {
|
3244 |
+
display.wheelStartX = scroll.scrollLeft; display.wheelStartY = scroll.scrollTop;
|
3245 |
+
display.wheelDX = dx; display.wheelDY = dy;
|
3246 |
+
setTimeout(function() {
|
3247 |
+
if (display.wheelStartX == null) return;
|
3248 |
+
var movedX = scroll.scrollLeft - display.wheelStartX;
|
3249 |
+
var movedY = scroll.scrollTop - display.wheelStartY;
|
3250 |
+
var sample = (movedY && display.wheelDY && movedY / display.wheelDY) ||
|
3251 |
+
(movedX && display.wheelDX && movedX / display.wheelDX);
|
3252 |
+
display.wheelStartX = display.wheelStartY = null;
|
3253 |
+
if (!sample) return;
|
3254 |
+
wheelPixelsPerUnit = (wheelPixelsPerUnit * wheelSamples + sample) / (wheelSamples + 1);
|
3255 |
+
++wheelSamples;
|
3256 |
+
}, 200);
|
3257 |
+
} else {
|
3258 |
+
display.wheelDX += dx; display.wheelDY += dy;
|
3259 |
+
}
|
3260 |
+
}
|
3261 |
+
}
|
3262 |
+
|
3263 |
+
// KEY EVENTS
|
3264 |
+
|
3265 |
+
// Run a handler that was bound to a key.
|
3266 |
+
function doHandleBinding(cm, bound, dropShift) {
|
3267 |
+
if (typeof bound == "string") {
|
3268 |
+
bound = commands[bound];
|
3269 |
+
if (!bound) return false;
|
3270 |
+
}
|
3271 |
+
// Ensure previous input has been read, so that the handler sees a
|
3272 |
+
// consistent view of the document
|
3273 |
+
if (cm.display.pollingFast && readInput(cm)) cm.display.pollingFast = false;
|
3274 |
+
var prevShift = cm.display.shift, done = false;
|
3275 |
+
try {
|
3276 |
+
if (isReadOnly(cm)) cm.state.suppressEdits = true;
|
3277 |
+
if (dropShift) cm.display.shift = false;
|
3278 |
+
done = bound(cm) != Pass;
|
3279 |
+
} finally {
|
3280 |
+
cm.display.shift = prevShift;
|
3281 |
+
cm.state.suppressEdits = false;
|
3282 |
+
}
|
3283 |
+
return done;
|
3284 |
+
}
|
3285 |
+
|
3286 |
+
function lookupKeyForEditor(cm, name, handle) {
|
3287 |
+
for (var i = 0; i < cm.state.keyMaps.length; i++) {
|
3288 |
+
var result = lookupKey(name, cm.state.keyMaps[i], handle, cm);
|
3289 |
+
if (result) return result;
|
3290 |
+
}
|
3291 |
+
return (cm.options.extraKeys && lookupKey(name, cm.options.extraKeys, handle, cm))
|
3292 |
+
|| lookupKey(name, cm.options.keyMap, handle, cm);
|
3293 |
+
}
|
3294 |
+
|
3295 |
+
var stopSeq = new Delayed;
|
3296 |
+
function dispatchKey(cm, name, e, handle) {
|
3297 |
+
var seq = cm.state.keySeq;
|
3298 |
+
if (seq) {
|
3299 |
+
if (isModifierKey(name)) return "handled";
|
3300 |
+
stopSeq.set(50, function() {
|
3301 |
+
if (cm.state.keySeq == seq) {
|
3302 |
+
cm.state.keySeq = null;
|
3303 |
+
resetInput(cm);
|
3304 |
+
}
|
3305 |
+
});
|
3306 |
+
name = seq + " " + name;
|
3307 |
+
}
|
3308 |
+
var result = lookupKeyForEditor(cm, name, handle);
|
3309 |
+
|
3310 |
+
if (result == "multi")
|
3311 |
+
cm.state.keySeq = name;
|
3312 |
+
if (result == "handled")
|
3313 |
+
signalLater(cm, "keyHandled", cm, name, e);
|
3314 |
+
|
3315 |
+
if (result == "handled" || result == "multi") {
|
3316 |
+
e_preventDefault(e);
|
3317 |
+
restartBlink(cm);
|
3318 |
+
}
|
3319 |
+
|
3320 |
+
if (seq && !result && /\'$/.test(name)) {
|
3321 |
+
e_preventDefault(e);
|
3322 |
+
return true;
|
3323 |
+
}
|
3324 |
+
return !!result;
|
3325 |
+
}
|
3326 |
+
|
3327 |
+
// Handle a key from the keydown event.
|
3328 |
+
function handleKeyBinding(cm, e) {
|
3329 |
+
var name = keyName(e, true);
|
3330 |
+
if (!name) return false;
|
3331 |
+
|
3332 |
+
if (e.shiftKey && !cm.state.keySeq) {
|
3333 |
+
// First try to resolve full name (including 'Shift-'). Failing
|
3334 |
+
// that, see if there is a cursor-motion command (starting with
|
3335 |
+
// 'go') bound to the keyname without 'Shift-'.
|
3336 |
+
return dispatchKey(cm, "Shift-" + name, e, function(b) {return doHandleBinding(cm, b, true);})
|
3337 |
+
|| dispatchKey(cm, name, e, function(b) {
|
3338 |
+
if (typeof b == "string" ? /^go[A-Z]/.test(b) : b.motion)
|
3339 |
+
return doHandleBinding(cm, b);
|
3340 |
+
});
|
3341 |
+
} else {
|
3342 |
+
return dispatchKey(cm, name, e, function(b) { return doHandleBinding(cm, b); });
|
3343 |
+
}
|
3344 |
+
}
|
3345 |
+
|
3346 |
+
// Handle a key from the keypress event
|
3347 |
+
function handleCharBinding(cm, e, ch) {
|
3348 |
+
return dispatchKey(cm, "'" + ch + "'", e,
|
3349 |
+
function(b) { return doHandleBinding(cm, b, true); });
|
3350 |
+
}
|
3351 |
+
|
3352 |
+
var lastStoppedKey = null;
|
3353 |
+
function onKeyDown(e) {
|
3354 |
+
var cm = this;
|
3355 |
+
ensureFocus(cm);
|
3356 |
+
if (signalDOMEvent(cm, e)) return;
|
3357 |
+
// IE does strange things with escape.
|
3358 |
+
if (ie && ie_version < 11 && e.keyCode == 27) e.returnValue = false;
|
3359 |
+
var code = e.keyCode;
|
3360 |
+
cm.display.shift = code == 16 || e.shiftKey;
|
3361 |
+
var handled = handleKeyBinding(cm, e);
|
3362 |
+
if (presto) {
|
3363 |
+
lastStoppedKey = handled ? code : null;
|
3364 |
+
// Opera has no cut event... we try to at least catch the key combo
|
3365 |
+
if (!handled && code == 88 && !hasCopyEvent && (mac ? e.metaKey : e.ctrlKey))
|
3366 |
+
cm.replaceSelection("", null, "cut");
|
3367 |
+
}
|
3368 |
+
|
3369 |
+
// Turn mouse into crosshair when Alt is held on Mac.
|
3370 |
+
if (code == 18 && !/\bCodeMirror-crosshair\b/.test(cm.display.lineDiv.className))
|
3371 |
+
showCrossHair(cm);
|
3372 |
+
}
|
3373 |
+
|
3374 |
+
function showCrossHair(cm) {
|
3375 |
+
var lineDiv = cm.display.lineDiv;
|
3376 |
+
addClass(lineDiv, "CodeMirror-crosshair");
|
3377 |
+
|
3378 |
+
function up(e) {
|
3379 |
+
if (e.keyCode == 18 || !e.altKey) {
|
3380 |
+
rmClass(lineDiv, "CodeMirror-crosshair");
|
3381 |
+
off(document, "keyup", up);
|
3382 |
+
off(document, "mouseover", up);
|
3383 |
+
}
|
3384 |
+
}
|
3385 |
+
on(document, "keyup", up);
|
3386 |
+
on(document, "mouseover", up);
|
3387 |
+
}
|
3388 |
+
|
3389 |
+
function onKeyUp(e) {
|
3390 |
+
if (e.keyCode == 16) this.doc.sel.shift = false;
|
3391 |
+
signalDOMEvent(this, e);
|
3392 |
+
}
|
3393 |
+
|
3394 |
+
function onKeyPress(e) {
|
3395 |
+
var cm = this;
|
3396 |
+
if (signalDOMEvent(cm, e) || e.ctrlKey && !e.altKey || mac && e.metaKey) return;
|
3397 |
+
var keyCode = e.keyCode, charCode = e.charCode;
|
3398 |
+
if (presto && keyCode == lastStoppedKey) {lastStoppedKey = null; e_preventDefault(e); return;}
|
3399 |
+
if (((presto && (!e.which || e.which < 10)) || khtml) && handleKeyBinding(cm, e)) return;
|
3400 |
+
var ch = String.fromCharCode(charCode == null ? keyCode : charCode);
|
3401 |
+
if (handleCharBinding(cm, e, ch)) return;
|
3402 |
+
if (ie && ie_version >= 9) cm.display.inputHasSelection = null;
|
3403 |
+
fastPoll(cm);
|
3404 |
+
}
|
3405 |
+
|
3406 |
+
// FOCUS/BLUR EVENTS
|
3407 |
+
|
3408 |
+
function onFocus(cm) {
|
3409 |
+
if (cm.options.readOnly == "nocursor") return;
|
3410 |
+
if (!cm.state.focused) {
|
3411 |
+
signal(cm, "focus", cm);
|
3412 |
+
cm.state.focused = true;
|
3413 |
+
addClass(cm.display.wrapper, "CodeMirror-focused");
|
3414 |
+
// The prevInput test prevents this from firing when a context
|
3415 |
+
// menu is closed (since the resetInput would kill the
|
3416 |
+
// select-all detection hack)
|
3417 |
+
if (!cm.curOp && cm.display.selForContextMenu != cm.doc.sel) {
|
3418 |
+
resetInput(cm);
|
3419 |
+
if (webkit) setTimeout(bind(resetInput, cm, true), 0); // Issue #1730
|
3420 |
+
}
|
3421 |
+
}
|
3422 |
+
slowPoll(cm);
|
3423 |
+
restartBlink(cm);
|
3424 |
+
}
|
3425 |
+
function onBlur(cm) {
|
3426 |
+
if (cm.state.focused) {
|
3427 |
+
signal(cm, "blur", cm);
|
3428 |
+
cm.state.focused = false;
|
3429 |
+
rmClass(cm.display.wrapper, "CodeMirror-focused");
|
3430 |
+
}
|
3431 |
+
clearInterval(cm.display.blinker);
|
3432 |
+
setTimeout(function() {if (!cm.state.focused) cm.display.shift = false;}, 150);
|
3433 |
+
}
|
3434 |
+
|
3435 |
+
// CONTEXT MENU HANDLING
|
3436 |
+
|
3437 |
+
// To make the context menu work, we need to briefly unhide the
|
3438 |
+
// textarea (making it as unobtrusive as possible) to let the
|
3439 |
+
// right-click take effect on it.
|
3440 |
+
function onContextMenu(cm, e) {
|
3441 |
+
if (signalDOMEvent(cm, e, "contextmenu")) return;
|
3442 |
+
var display = cm.display;
|
3443 |
+
if (eventInWidget(display, e) || contextMenuInGutter(cm, e)) return;
|
3444 |
+
|
3445 |
+
var pos = posFromMouse(cm, e), scrollPos = display.scroller.scrollTop;
|
3446 |
+
if (!pos || presto) return; // Opera is difficult.
|
3447 |
+
|
3448 |
+
// Reset the current text selection only if the click is done outside of the selection
|
3449 |
+
// and 'resetSelectionOnContextMenu' option is true.
|
3450 |
+
var reset = cm.options.resetSelectionOnContextMenu;
|
3451 |
+
if (reset && cm.doc.sel.contains(pos) == -1)
|
3452 |
+
operation(cm, setSelection)(cm.doc, simpleSelection(pos), sel_dontScroll);
|
3453 |
+
|
3454 |
+
var oldCSS = display.input.style.cssText;
|
3455 |
+
display.inputDiv.style.position = "absolute";
|
3456 |
+
display.input.style.cssText = "position: fixed; width: 30px; height: 30px; top: " + (e.clientY - 5) +
|
3457 |
+
"px; left: " + (e.clientX - 5) + "px; z-index: 1000; background: " +
|
3458 |
+
(ie ? "rgba(255, 255, 255, .05)" : "transparent") +
|
3459 |
+
"; outline: none; border-width: 0; outline: none; overflow: hidden; opacity: .05; filter: alpha(opacity=5);";
|
3460 |
+
if (webkit) var oldScrollY = window.scrollY; // Work around Chrome issue (#2712)
|
3461 |
+
focusInput(cm);
|
3462 |
+
if (webkit) window.scrollTo(null, oldScrollY);
|
3463 |
+
resetInput(cm);
|
3464 |
+
// Adds "Select all" to context menu in FF
|
3465 |
+
if (!cm.somethingSelected()) display.input.value = display.prevInput = " ";
|
3466 |
+
display.contextMenuPending = true;
|
3467 |
+
display.selForContextMenu = cm.doc.sel;
|
3468 |
+
clearTimeout(display.detectingSelectAll);
|
3469 |
+
|
3470 |
+
// Select-all will be greyed out if there's nothing to select, so
|
3471 |
+
// this adds a zero-width space so that we can later check whether
|
3472 |
+
// it got selected.
|
3473 |
+
function prepareSelectAllHack() {
|
3474 |
+
if (display.input.selectionStart != null) {
|
3475 |
+
var selected = cm.somethingSelected();
|
3476 |
+
var extval = display.input.value = "\u200b" + (selected ? display.input.value : "");
|
3477 |
+
display.prevInput = selected ? "" : "\u200b";
|
3478 |
+
display.input.selectionStart = 1; display.input.selectionEnd = extval.length;
|
3479 |
+
// Re-set this, in case some other handler touched the
|
3480 |
+
// selection in the meantime.
|
3481 |
+
display.selForContextMenu = cm.doc.sel;
|
3482 |
+
}
|
3483 |
+
}
|
3484 |
+
function rehide() {
|
3485 |
+
display.contextMenuPending = false;
|
3486 |
+
display.inputDiv.style.position = "relative";
|
3487 |
+
display.input.style.cssText = oldCSS;
|
3488 |
+
if (ie && ie_version < 9) display.scrollbars.setScrollTop(display.scroller.scrollTop = scrollPos);
|
3489 |
+
slowPoll(cm);
|
3490 |
+
|
3491 |
+
// Try to detect the user choosing select-all
|
3492 |
+
if (display.input.selectionStart != null) {
|
3493 |
+
if (!ie || (ie && ie_version < 9)) prepareSelectAllHack();
|
3494 |
+
var i = 0, poll = function() {
|
3495 |
+
if (display.selForContextMenu == cm.doc.sel && display.input.selectionStart == 0)
|
3496 |
+
operation(cm, commands.selectAll)(cm);
|
3497 |
+
else if (i++ < 10) display.detectingSelectAll = setTimeout(poll, 500);
|
3498 |
+
else resetInput(cm);
|
3499 |
+
};
|
3500 |
+
display.detectingSelectAll = setTimeout(poll, 200);
|
3501 |
+
}
|
3502 |
+
}
|
3503 |
+
|
3504 |
+
if (ie && ie_version >= 9) prepareSelectAllHack();
|
3505 |
+
if (captureRightClick) {
|
3506 |
+
e_stop(e);
|
3507 |
+
var mouseup = function() {
|
3508 |
+
off(window, "mouseup", mouseup);
|
3509 |
+
setTimeout(rehide, 20);
|
3510 |
+
};
|
3511 |
+
on(window, "mouseup", mouseup);
|
3512 |
+
} else {
|
3513 |
+
setTimeout(rehide, 50);
|
3514 |
+
}
|
3515 |
+
}
|
3516 |
+
|
3517 |
+
function contextMenuInGutter(cm, e) {
|
3518 |
+
if (!hasHandler(cm, "gutterContextMenu")) return false;
|
3519 |
+
return gutterEvent(cm, e, "gutterContextMenu", false, signal);
|
3520 |
+
}
|
3521 |
+
|
3522 |
+
// UPDATING
|
3523 |
+
|
3524 |
+
// Compute the position of the end of a change (its 'to' property
|
3525 |
+
// refers to the pre-change end).
|
3526 |
+
var changeEnd = CodeMirror.changeEnd = function(change) {
|
3527 |
+
if (!change.text) return change.to;
|
3528 |
+
return Pos(change.from.line + change.text.length - 1,
|
3529 |
+
lst(change.text).length + (change.text.length == 1 ? change.from.ch : 0));
|
3530 |
+
};
|
3531 |
+
|
3532 |
+
// Adjust a position to refer to the post-change position of the
|
3533 |
+
// same text, or the end of the change if the change covers it.
|
3534 |
+
function adjustForChange(pos, change) {
|
3535 |
+
if (cmp(pos, change.from) < 0) return pos;
|
3536 |
+
if (cmp(pos, change.to) <= 0) return changeEnd(change);
|
3537 |
+
|
3538 |
+
var line = pos.line + change.text.length - (change.to.line - change.from.line) - 1, ch = pos.ch;
|
3539 |
+
if (pos.line == change.to.line) ch += changeEnd(change).ch - change.to.ch;
|
3540 |
+
return Pos(line, ch);
|
3541 |
+
}
|
3542 |
+
|
3543 |
+
function computeSelAfterChange(doc, change) {
|
3544 |
+
var out = [];
|
3545 |
+
for (var i = 0; i < doc.sel.ranges.length; i++) {
|
3546 |
+
var range = doc.sel.ranges[i];
|
3547 |
+
out.push(new Range(adjustForChange(range.anchor, change),
|
3548 |
+
adjustForChange(range.head, change)));
|
3549 |
+
}
|
3550 |
+
return normalizeSelection(out, doc.sel.primIndex);
|
3551 |
+
}
|
3552 |
+
|
3553 |
+
function offsetPos(pos, old, nw) {
|
3554 |
+
if (pos.line == old.line)
|
3555 |
+
return Pos(nw.line, pos.ch - old.ch + nw.ch);
|
3556 |
+
else
|
3557 |
+
return Pos(nw.line + (pos.line - old.line), pos.ch);
|
3558 |
+
}
|
3559 |
+
|
3560 |
+
// Used by replaceSelections to allow moving the selection to the
|
3561 |
+
// start or around the replaced test. Hint may be "start" or "around".
|
3562 |
+
function computeReplacedSel(doc, changes, hint) {
|
3563 |
+
var out = [];
|
3564 |
+
var oldPrev = Pos(doc.first, 0), newPrev = oldPrev;
|
3565 |
+
for (var i = 0; i < changes.length; i++) {
|
3566 |
+
var change = changes[i];
|
3567 |
+
var from = offsetPos(change.from, oldPrev, newPrev);
|
3568 |
+
var to = offsetPos(changeEnd(change), oldPrev, newPrev);
|
3569 |
+
oldPrev = change.to;
|
3570 |
+
newPrev = to;
|
3571 |
+
if (hint == "around") {
|
3572 |
+
var range = doc.sel.ranges[i], inv = cmp(range.head, range.anchor) < 0;
|
3573 |
+
out[i] = new Range(inv ? to : from, inv ? from : to);
|
3574 |
+
} else {
|
3575 |
+
out[i] = new Range(from, from);
|
3576 |
+
}
|
3577 |
+
}
|
3578 |
+
return new Selection(out, doc.sel.primIndex);
|
3579 |
+
}
|
3580 |
+
|
3581 |
+
// Allow "beforeChange" event handlers to influence a change
|
3582 |
+
function filterChange(doc, change, update) {
|
3583 |
+
var obj = {
|
3584 |
+
canceled: false,
|
3585 |
+
from: change.from,
|
3586 |
+
to: change.to,
|
3587 |
+
text: change.text,
|
3588 |
+
origin: change.origin,
|
3589 |
+
cancel: function() { this.canceled = true; }
|
3590 |
+
};
|
3591 |
+
if (update) obj.update = function(from, to, text, origin) {
|
3592 |
+
if (from) this.from = clipPos(doc, from);
|
3593 |
+
if (to) this.to = clipPos(doc, to);
|
3594 |
+
if (text) this.text = text;
|
3595 |
+
if (origin !== undefined) this.origin = origin;
|
3596 |
+
};
|
3597 |
+
signal(doc, "beforeChange", doc, obj);
|
3598 |
+
if (doc.cm) signal(doc.cm, "beforeChange", doc.cm, obj);
|
3599 |
+
|
3600 |
+
if (obj.canceled) return null;
|
3601 |
+
return {from: obj.from, to: obj.to, text: obj.text, origin: obj.origin};
|
3602 |
+
}
|
3603 |
+
|
3604 |
+
// Apply a change to a document, and add it to the document's
|
3605 |
+
// history, and propagating it to all linked documents.
|
3606 |
+
function makeChange(doc, change, ignoreReadOnly) {
|
3607 |
+
if (doc.cm) {
|
3608 |
+
if (!doc.cm.curOp) return operation(doc.cm, makeChange)(doc, change, ignoreReadOnly);
|
3609 |
+
if (doc.cm.state.suppressEdits) return;
|
3610 |
+
}
|
3611 |
+
|
3612 |
+
if (hasHandler(doc, "beforeChange") || doc.cm && hasHandler(doc.cm, "beforeChange")) {
|
3613 |
+
change = filterChange(doc, change, true);
|
3614 |
+
if (!change) return;
|
3615 |
+
}
|
3616 |
+
|
3617 |
+
// Possibly split or suppress the update based on the presence
|
3618 |
+
// of read-only spans in its range.
|
3619 |
+
var split = sawReadOnlySpans && !ignoreReadOnly && removeReadOnlyRanges(doc, change.from, change.to);
|
3620 |
+
if (split) {
|
3621 |
+
for (var i = split.length - 1; i >= 0; --i)
|
3622 |
+
makeChangeInner(doc, {from: split[i].from, to: split[i].to, text: i ? [""] : change.text});
|
3623 |
+
} else {
|
3624 |
+
makeChangeInner(doc, change);
|
3625 |
+
}
|
3626 |
+
}
|
3627 |
+
|
3628 |
+
function makeChangeInner(doc, change) {
|
3629 |
+
if (change.text.length == 1 && change.text[0] == "" && cmp(change.from, change.to) == 0) return;
|
3630 |
+
var selAfter = computeSelAfterChange(doc, change);
|
3631 |
+
addChangeToHistory(doc, change, selAfter, doc.cm ? doc.cm.curOp.id : NaN);
|
3632 |
+
|
3633 |
+
makeChangeSingleDoc(doc, change, selAfter, stretchSpansOverChange(doc, change));
|
3634 |
+
var rebased = [];
|
3635 |
+
|
3636 |
+
linkedDocs(doc, function(doc, sharedHist) {
|
3637 |
+
if (!sharedHist && indexOf(rebased, doc.history) == -1) {
|
3638 |
+
rebaseHist(doc.history, change);
|
3639 |
+
rebased.push(doc.history);
|
3640 |
+
}
|
3641 |
+
makeChangeSingleDoc(doc, change, null, stretchSpansOverChange(doc, change));
|
3642 |
+
});
|
3643 |
+
}
|
3644 |
+
|
3645 |
+
// Revert a change stored in a document's history.
|
3646 |
+
function makeChangeFromHistory(doc, type, allowSelectionOnly) {
|
3647 |
+
if (doc.cm && doc.cm.state.suppressEdits) return;
|
3648 |
+
|
3649 |
+
var hist = doc.history, event, selAfter = doc.sel;
|
3650 |
+
var source = type == "undo" ? hist.done : hist.undone, dest = type == "undo" ? hist.undone : hist.done;
|
3651 |
+
|
3652 |
+
// Verify that there is a useable event (so that ctrl-z won't
|
3653 |
+
// needlessly clear selection events)
|
3654 |
+
for (var i = 0; i < source.length; i++) {
|
3655 |
+
event = source[i];
|
3656 |
+
if (allowSelectionOnly ? event.ranges && !event.equals(doc.sel) : !event.ranges)
|
3657 |
+
break;
|
3658 |
+
}
|
3659 |
+
if (i == source.length) return;
|
3660 |
+
hist.lastOrigin = hist.lastSelOrigin = null;
|
3661 |
+
|
3662 |
+
for (;;) {
|
3663 |
+
event = source.pop();
|
3664 |
+
if (event.ranges) {
|
3665 |
+
pushSelectionToHistory(event, dest);
|
3666 |
+
if (allowSelectionOnly && !event.equals(doc.sel)) {
|
3667 |
+
setSelection(doc, event, {clearRedo: false});
|
3668 |
+
return;
|
3669 |
+
}
|
3670 |
+
selAfter = event;
|
3671 |
+
}
|
3672 |
+
else break;
|
3673 |
+
}
|
3674 |
+
|
3675 |
+
// Build up a reverse change object to add to the opposite history
|
3676 |
+
// stack (redo when undoing, and vice versa).
|
3677 |
+
var antiChanges = [];
|
3678 |
+
pushSelectionToHistory(selAfter, dest);
|
3679 |
+
dest.push({changes: antiChanges, generation: hist.generation});
|
3680 |
+
hist.generation = event.generation || ++hist.maxGeneration;
|
3681 |
+
|
3682 |
+
var filter = hasHandler(doc, "beforeChange") || doc.cm && hasHandler(doc.cm, "beforeChange");
|
3683 |
+
|
3684 |
+
for (var i = event.changes.length - 1; i >= 0; --i) {
|
3685 |
+
var change = event.changes[i];
|
3686 |
+
change.origin = type;
|
3687 |
+
if (filter && !filterChange(doc, change, false)) {
|
3688 |
+
source.length = 0;
|
3689 |
+
return;
|
3690 |
+
}
|
3691 |
+
|
3692 |
+
antiChanges.push(historyChangeFromChange(doc, change));
|
3693 |
+
|
3694 |
+
var after = i ? computeSelAfterChange(doc, change) : lst(source);
|
3695 |
+
makeChangeSingleDoc(doc, change, after, mergeOldSpans(doc, change));
|
3696 |
+
if (!i && doc.cm) doc.cm.scrollIntoView({from: change.from, to: changeEnd(change)});
|
3697 |
+
var rebased = [];
|
3698 |
+
|
3699 |
+
// Propagate to the linked documents
|
3700 |
+
linkedDocs(doc, function(doc, sharedHist) {
|
3701 |
+
if (!sharedHist && indexOf(rebased, doc.history) == -1) {
|
3702 |
+
rebaseHist(doc.history, change);
|
3703 |
+
rebased.push(doc.history);
|
3704 |
+
}
|
3705 |
+
makeChangeSingleDoc(doc, change, null, mergeOldSpans(doc, change));
|
3706 |
+
});
|
3707 |
+
}
|
3708 |
+
}
|
3709 |
+
|
3710 |
+
// Sub-views need their line numbers shifted when text is added
|
3711 |
+
// above or below them in the parent document.
|
3712 |
+
function shiftDoc(doc, distance) {
|
3713 |
+
if (distance == 0) return;
|
3714 |
+
doc.first += distance;
|
3715 |
+
doc.sel = new Selection(map(doc.sel.ranges, function(range) {
|
3716 |
+
return new Range(Pos(range.anchor.line + distance, range.anchor.ch),
|
3717 |
+
Pos(range.head.line + distance, range.head.ch));
|
3718 |
+
}), doc.sel.primIndex);
|
3719 |
+
if (doc.cm) {
|
3720 |
+
regChange(doc.cm, doc.first, doc.first - distance, distance);
|
3721 |
+
for (var d = doc.cm.display, l = d.viewFrom; l < d.viewTo; l++)
|
3722 |
+
regLineChange(doc.cm, l, "gutter");
|
3723 |
+
}
|
3724 |
+
}
|
3725 |
+
|
3726 |
+
// More lower-level change function, handling only a single document
|
3727 |
+
// (not linked ones).
|
3728 |
+
function makeChangeSingleDoc(doc, change, selAfter, spans) {
|
3729 |
+
if (doc.cm && !doc.cm.curOp)
|
3730 |
+
return operation(doc.cm, makeChangeSingleDoc)(doc, change, selAfter, spans);
|
3731 |
+
|
3732 |
+
if (change.to.line < doc.first) {
|
3733 |
+
shiftDoc(doc, change.text.length - 1 - (change.to.line - change.from.line));
|
3734 |
+
return;
|
3735 |
+
}
|
3736 |
+
if (change.from.line > doc.lastLine()) return;
|
3737 |
+
|
3738 |
+
// Clip the change to the size of this doc
|
3739 |
+
if (change.from.line < doc.first) {
|
3740 |
+
var shift = change.text.length - 1 - (doc.first - change.from.line);
|
3741 |
+
shiftDoc(doc, shift);
|
3742 |
+
change = {from: Pos(doc.first, 0), to: Pos(change.to.line + shift, change.to.ch),
|
3743 |
+
text: [lst(change.text)], origin: change.origin};
|
3744 |
+
}
|
3745 |
+
var last = doc.lastLine();
|
3746 |
+
if (change.to.line > last) {
|
3747 |
+
change = {from: change.from, to: Pos(last, getLine(doc, last).text.length),
|
3748 |
+
text: [change.text[0]], origin: change.origin};
|
3749 |
+
}
|
3750 |
+
|
3751 |
+
change.removed = getBetween(doc, change.from, change.to);
|
3752 |
+
|
3753 |
+
if (!selAfter) selAfter = computeSelAfterChange(doc, change);
|
3754 |
+
if (doc.cm) makeChangeSingleDocInEditor(doc.cm, change, spans);
|
3755 |
+
else updateDoc(doc, change, spans);
|
3756 |
+
setSelectionNoUndo(doc, selAfter, sel_dontScroll);
|
3757 |
+
}
|
3758 |
+
|
3759 |
+
// Handle the interaction of a change to a document with the editor
|
3760 |
+
// that this document is part of.
|
3761 |
+
function makeChangeSingleDocInEditor(cm, change, spans) {
|
3762 |
+
var doc = cm.doc, display = cm.display, from = change.from, to = change.to;
|
3763 |
+
|
3764 |
+
var recomputeMaxLength = false, checkWidthStart = from.line;
|
3765 |
+
if (!cm.options.lineWrapping) {
|
3766 |
+
checkWidthStart = lineNo(visualLine(getLine(doc, from.line)));
|
3767 |
+
doc.iter(checkWidthStart, to.line + 1, function(line) {
|
3768 |
+
if (line == display.maxLine) {
|
3769 |
+
recomputeMaxLength = true;
|
3770 |
+
return true;
|
3771 |
+
}
|
3772 |
+
});
|
3773 |
+
}
|
3774 |
+
|
3775 |
+
if (doc.sel.contains(change.from, change.to) > -1)
|
3776 |
+
signalCursorActivity(cm);
|
3777 |
+
|
3778 |
+
updateDoc(doc, change, spans, estimateHeight(cm));
|
3779 |
+
|
3780 |
+
if (!cm.options.lineWrapping) {
|
3781 |
+
doc.iter(checkWidthStart, from.line + change.text.length, function(line) {
|
3782 |
+
var len = lineLength(line);
|
3783 |
+
if (len > display.maxLineLength) {
|
3784 |
+
display.maxLine = line;
|
3785 |
+
display.maxLineLength = len;
|
3786 |
+
display.maxLineChanged = true;
|
3787 |
+
recomputeMaxLength = false;
|
3788 |
+
}
|
3789 |
+
});
|
3790 |
+
if (recomputeMaxLength) cm.curOp.updateMaxLine = true;
|
3791 |
+
}
|
3792 |
+
|
3793 |
+
// Adjust frontier, schedule worker
|
3794 |
+
doc.frontier = Math.min(doc.frontier, from.line);
|
3795 |
+
startWorker(cm, 400);
|
3796 |
+
|
3797 |
+
var lendiff = change.text.length - (to.line - from.line) - 1;
|
3798 |
+
// Remember that these lines changed, for updating the display
|
3799 |
+
if (change.full)
|
3800 |
+
regChange(cm);
|
3801 |
+
else if (from.line == to.line && change.text.length == 1 && !isWholeLineUpdate(cm.doc, change))
|
3802 |
+
regLineChange(cm, from.line, "text");
|
3803 |
+
else
|
3804 |
+
regChange(cm, from.line, to.line + 1, lendiff);
|
3805 |
+
|
3806 |
+
var changesHandler = hasHandler(cm, "changes"), changeHandler = hasHandler(cm, "change");
|
3807 |
+
if (changeHandler || changesHandler) {
|
3808 |
+
var obj = {
|
3809 |
+
from: from, to: to,
|
3810 |
+
text: change.text,
|
3811 |
+
removed: change.removed,
|
3812 |
+
origin: change.origin
|
3813 |
+
};
|
3814 |
+
if (changeHandler) signalLater(cm, "change", cm, obj);
|
3815 |
+
if (changesHandler) (cm.curOp.changeObjs || (cm.curOp.changeObjs = [])).push(obj);
|
3816 |
+
}
|
3817 |
+
cm.display.selForContextMenu = null;
|
3818 |
+
}
|
3819 |
+
|
3820 |
+
function replaceRange(doc, code, from, to, origin) {
|
3821 |
+
if (!to) to = from;
|
3822 |
+
if (cmp(to, from) < 0) { var tmp = to; to = from; from = tmp; }
|
3823 |
+
if (typeof code == "string") code = splitLines(code);
|
3824 |
+
makeChange(doc, {from: from, to: to, text: code, origin: origin});
|
3825 |
+
}
|
3826 |
+
|
3827 |
+
// SCROLLING THINGS INTO VIEW
|
3828 |
+
|
3829 |
+
// If an editor sits on the top or bottom of the window, partially
|
3830 |
+
// scrolled out of view, this ensures that the cursor is visible.
|
3831 |
+
function maybeScrollWindow(cm, coords) {
|
3832 |
+
if (signalDOMEvent(cm, "scrollCursorIntoView")) return;
|
3833 |
+
|
3834 |
+
var display = cm.display, box = display.sizer.getBoundingClientRect(), doScroll = null;
|
3835 |
+
if (coords.top + box.top < 0) doScroll = true;
|
3836 |
+
else if (coords.bottom + box.top > (window.innerHeight || document.documentElement.clientHeight)) doScroll = false;
|
3837 |
+
if (doScroll != null && !phantom) {
|
3838 |
+
var scrollNode = elt("div", "\u200b", null, "position: absolute; top: " +
|
3839 |
+
(coords.top - display.viewOffset - paddingTop(cm.display)) + "px; height: " +
|
3840 |
+
(coords.bottom - coords.top + scrollGap(cm) + display.barHeight) + "px; left: " +
|
3841 |
+
coords.left + "px; width: 2px;");
|
3842 |
+
cm.display.lineSpace.appendChild(scrollNode);
|
3843 |
+
scrollNode.scrollIntoView(doScroll);
|
3844 |
+
cm.display.lineSpace.removeChild(scrollNode);
|
3845 |
+
}
|
3846 |
+
}
|
3847 |
+
|
3848 |
+
// Scroll a given position into view (immediately), verifying that
|
3849 |
+
// it actually became visible (as line heights are accurately
|
3850 |
+
// measured, the position of something may 'drift' during drawing).
|
3851 |
+
function scrollPosIntoView(cm, pos, end, margin) {
|
3852 |
+
if (margin == null) margin = 0;
|
3853 |
+
for (var limit = 0; limit < 5; limit++) {
|
3854 |
+
var changed = false, coords = cursorCoords(cm, pos);
|
3855 |
+
var endCoords = !end || end == pos ? coords : cursorCoords(cm, end);
|
3856 |
+
var scrollPos = calculateScrollPos(cm, Math.min(coords.left, endCoords.left),
|
3857 |
+
Math.min(coords.top, endCoords.top) - margin,
|
3858 |
+
Math.max(coords.left, endCoords.left),
|
3859 |
+
Math.max(coords.bottom, endCoords.bottom) + margin);
|
3860 |
+
var startTop = cm.doc.scrollTop, startLeft = cm.doc.scrollLeft;
|
3861 |
+
if (scrollPos.scrollTop != null) {
|
3862 |
+
setScrollTop(cm, scrollPos.scrollTop);
|
3863 |
+
if (Math.abs(cm.doc.scrollTop - startTop) > 1) changed = true;
|
3864 |
+
}
|
3865 |
+
if (scrollPos.scrollLeft != null) {
|
3866 |
+
setScrollLeft(cm, scrollPos.scrollLeft);
|
3867 |
+
if (Math.abs(cm.doc.scrollLeft - startLeft) > 1) changed = true;
|
3868 |
+
}
|
3869 |
+
if (!changed) break;
|
3870 |
+
}
|
3871 |
+
return coords;
|
3872 |
+
}
|
3873 |
+
|
3874 |
+
// Scroll a given set of coordinates into view (immediately).
|
3875 |
+
function scrollIntoView(cm, x1, y1, x2, y2) {
|
3876 |
+
var scrollPos = calculateScrollPos(cm, x1, y1, x2, y2);
|
3877 |
+
if (scrollPos.scrollTop != null) setScrollTop(cm, scrollPos.scrollTop);
|
3878 |
+
if (scrollPos.scrollLeft != null) setScrollLeft(cm, scrollPos.scrollLeft);
|
3879 |
+
}
|
3880 |
+
|
3881 |
+
// Calculate a new scroll position needed to scroll the given
|
3882 |
+
// rectangle into view. Returns an object with scrollTop and
|
3883 |
+
// scrollLeft properties. When these are undefined, the
|
3884 |
+
// vertical/horizontal position does not need to be adjusted.
|
3885 |
+
function calculateScrollPos(cm, x1, y1, x2, y2) {
|
3886 |
+
var display = cm.display, snapMargin = textHeight(cm.display);
|
3887 |
+
if (y1 < 0) y1 = 0;
|
3888 |
+
var screentop = cm.curOp && cm.curOp.scrollTop != null ? cm.curOp.scrollTop : display.scroller.scrollTop;
|
3889 |
+
var screen = displayHeight(cm), result = {};
|
3890 |
+
if (y2 - y1 > screen) y2 = y1 + screen;
|
3891 |
+
var docBottom = cm.doc.height + paddingVert(display);
|
3892 |
+
var atTop = y1 < snapMargin, atBottom = y2 > docBottom - snapMargin;
|
3893 |
+
if (y1 < screentop) {
|
3894 |
+
result.scrollTop = atTop ? 0 : y1;
|
3895 |
+
} else if (y2 > screentop + screen) {
|
3896 |
+
var newTop = Math.min(y1, (atBottom ? docBottom : y2) - screen);
|
3897 |
+
if (newTop != screentop) result.scrollTop = newTop;
|
3898 |
+
}
|
3899 |
+
|
3900 |
+
var screenleft = cm.curOp && cm.curOp.scrollLeft != null ? cm.curOp.scrollLeft : display.scroller.scrollLeft;
|
3901 |
+
var screenw = displayWidth(cm) - (cm.options.fixedGutter ? display.gutters.offsetWidth : 0);
|
3902 |
+
var tooWide = x2 - x1 > screenw;
|
3903 |
+
if (tooWide) x2 = x1 + screenw;
|
3904 |
+
if (x1 < 10)
|
3905 |
+
result.scrollLeft = 0;
|
3906 |
+
else if (x1 < screenleft)
|
3907 |
+
result.scrollLeft = Math.max(0, x1 - (tooWide ? 0 : 10));
|
3908 |
+
else if (x2 > screenw + screenleft - 3)
|
3909 |
+
result.scrollLeft = x2 + (tooWide ? 0 : 10) - screenw;
|
3910 |
+
return result;
|
3911 |
+
}
|
3912 |
+
|
3913 |
+
// Store a relative adjustment to the scroll position in the current
|
3914 |
+
// operation (to be applied when the operation finishes).
|
3915 |
+
function addToScrollPos(cm, left, top) {
|
3916 |
+
if (left != null || top != null) resolveScrollToPos(cm);
|
3917 |
+
if (left != null)
|
3918 |
+
cm.curOp.scrollLeft = (cm.curOp.scrollLeft == null ? cm.doc.scrollLeft : cm.curOp.scrollLeft) + left;
|
3919 |
+
if (top != null)
|
3920 |
+
cm.curOp.scrollTop = (cm.curOp.scrollTop == null ? cm.doc.scrollTop : cm.curOp.scrollTop) + top;
|
3921 |
+
}
|
3922 |
+
|
3923 |
+
// Make sure that at the end of the operation the current cursor is
|
3924 |
+
// shown.
|
3925 |
+
function ensureCursorVisible(cm) {
|
3926 |
+
resolveScrollToPos(cm);
|
3927 |
+
var cur = cm.getCursor(), from = cur, to = cur;
|
3928 |
+
if (!cm.options.lineWrapping) {
|
3929 |
+
from = cur.ch ? Pos(cur.line, cur.ch - 1) : cur;
|
3930 |
+
to = Pos(cur.line, cur.ch + 1);
|
3931 |
+
}
|
3932 |
+
cm.curOp.scrollToPos = {from: from, to: to, margin: cm.options.cursorScrollMargin, isCursor: true};
|
3933 |
+
}
|
3934 |
+
|
3935 |
+
// When an operation has its scrollToPos property set, and another
|
3936 |
+
// scroll action is applied before the end of the operation, this
|
3937 |
+
// 'simulates' scrolling that position into view in a cheap way, so
|
3938 |
+
// that the effect of intermediate scroll commands is not ignored.
|
3939 |
+
function resolveScrollToPos(cm) {
|
3940 |
+
var range = cm.curOp.scrollToPos;
|
3941 |
+
if (range) {
|
3942 |
+
cm.curOp.scrollToPos = null;
|
3943 |
+
var from = estimateCoords(cm, range.from), to = estimateCoords(cm, range.to);
|
3944 |
+
var sPos = calculateScrollPos(cm, Math.min(from.left, to.left),
|
3945 |
+
Math.min(from.top, to.top) - range.margin,
|
3946 |
+
Math.max(from.right, to.right),
|
3947 |
+
Math.max(from.bottom, to.bottom) + range.margin);
|
3948 |
+
cm.scrollTo(sPos.scrollLeft, sPos.scrollTop);
|
3949 |
+
}
|
3950 |
+
}
|
3951 |
+
|
3952 |
+
// API UTILITIES
|
3953 |
+
|
3954 |
+
// Indent the given line. The how parameter can be "smart",
|
3955 |
+
// "add"/null, "subtract", or "prev". When aggressive is false
|
3956 |
+
// (typically set to true for forced single-line indents), empty
|
3957 |
+
// lines are not indented, and places where the mode returns Pass
|
3958 |
+
// are left alone.
|
3959 |
+
function indentLine(cm, n, how, aggressive) {
|
3960 |
+
var doc = cm.doc, state;
|
3961 |
+
if (how == null) how = "add";
|
3962 |
+
if (how == "smart") {
|
3963 |
+
// Fall back to "prev" when the mode doesn't have an indentation
|
3964 |
+
// method.
|
3965 |
+
if (!doc.mode.indent) how = "prev";
|
3966 |
+
else state = getStateBefore(cm, n);
|
3967 |
+
}
|
3968 |
+
|
3969 |
+
var tabSize = cm.options.tabSize;
|
3970 |
+
var line = getLine(doc, n), curSpace = countColumn(line.text, null, tabSize);
|
3971 |
+
if (line.stateAfter) line.stateAfter = null;
|
3972 |
+
var curSpaceString = line.text.match(/^\s*/)[0], indentation;
|
3973 |
+
if (!aggressive && !/\S/.test(line.text)) {
|
3974 |
+
indentation = 0;
|
3975 |
+
how = "not";
|
3976 |
+
} else if (how == "smart") {
|
3977 |
+
indentation = doc.mode.indent(state, line.text.slice(curSpaceString.length), line.text);
|
3978 |
+
if (indentation == Pass || indentation > 150) {
|
3979 |
+
if (!aggressive) return;
|
3980 |
+
how = "prev";
|
3981 |
+
}
|
3982 |
+
}
|
3983 |
+
if (how == "prev") {
|
3984 |
+
if (n > doc.first) indentation = countColumn(getLine(doc, n-1).text, null, tabSize);
|
3985 |
+
else indentation = 0;
|
3986 |
+
} else if (how == "add") {
|
3987 |
+
indentation = curSpace + cm.options.indentUnit;
|
3988 |
+
} else if (how == "subtract") {
|
3989 |
+
indentation = curSpace - cm.options.indentUnit;
|
3990 |
+
} else if (typeof how == "number") {
|
3991 |
+
indentation = curSpace + how;
|
3992 |
+
}
|
3993 |
+
indentation = Math.max(0, indentation);
|
3994 |
+
|
3995 |
+
var indentString = "", pos = 0;
|
3996 |
+
if (cm.options.indentWithTabs)
|
3997 |
+
for (var i = Math.floor(indentation / tabSize); i; --i) {pos += tabSize; indentString += "\t";}
|
3998 |
+
if (pos < indentation) indentString += spaceStr(indentation - pos);
|
3999 |
+
|
4000 |
+
if (indentString != curSpaceString) {
|
4001 |
+
replaceRange(doc, indentString, Pos(n, 0), Pos(n, curSpaceString.length), "+input");
|
4002 |
+
} else {
|
4003 |
+
// Ensure that, if the cursor was in the whitespace at the start
|
4004 |
+
// of the line, it is moved to the end of that space.
|
4005 |
+
for (var i = 0; i < doc.sel.ranges.length; i++) {
|
4006 |
+
var range = doc.sel.ranges[i];
|
4007 |
+
if (range.head.line == n && range.head.ch < curSpaceString.length) {
|
4008 |
+
var pos = Pos(n, curSpaceString.length);
|
4009 |
+
replaceOneSelection(doc, i, new Range(pos, pos));
|
4010 |
+
break;
|
4011 |
+
}
|
4012 |
+
}
|
4013 |
+
}
|
4014 |
+
line.stateAfter = null;
|
4015 |
+
}
|
4016 |
+
|
4017 |
+
// Utility for applying a change to a line by handle or number,
|
4018 |
+
// returning the number and optionally registering the line as
|
4019 |
+
// changed.
|
4020 |
+
function changeLine(doc, handle, changeType, op) {
|
4021 |
+
var no = handle, line = handle;
|
4022 |
+
if (typeof handle == "number") line = getLine(doc, clipLine(doc, handle));
|
4023 |
+
else no = lineNo(handle);
|
4024 |
+
if (no == null) return null;
|
4025 |
+
if (op(line, no) && doc.cm) regLineChange(doc.cm, no, changeType);
|
4026 |
+
return line;
|
4027 |
+
}
|
4028 |
+
|
4029 |
+
// Helper for deleting text near the selection(s), used to implement
|
4030 |
+
// backspace, delete, and similar functionality.
|
4031 |
+
function deleteNearSelection(cm, compute) {
|
4032 |
+
var ranges = cm.doc.sel.ranges, kill = [];
|
4033 |
+
// Build up a set of ranges to kill first, merging overlapping
|
4034 |
+
// ranges.
|
4035 |
+
for (var i = 0; i < ranges.length; i++) {
|
4036 |
+
var toKill = compute(ranges[i]);
|
4037 |
+
while (kill.length && cmp(toKill.from, lst(kill).to) <= 0) {
|
4038 |
+
var replaced = kill.pop();
|
4039 |
+
if (cmp(replaced.from, toKill.from) < 0) {
|
4040 |
+
toKill.from = replaced.from;
|
4041 |
+
break;
|
4042 |
+
}
|
4043 |
+
}
|
4044 |
+
kill.push(toKill);
|
4045 |
+
}
|
4046 |
+
// Next, remove those actual ranges.
|
4047 |
+
runInOp(cm, function() {
|
4048 |
+
for (var i = kill.length - 1; i >= 0; i--)
|
4049 |
+
replaceRange(cm.doc, "", kill[i].from, kill[i].to, "+delete");
|
4050 |
+
ensureCursorVisible(cm);
|
4051 |
+
});
|
4052 |
+
}
|
4053 |
+
|
4054 |
+
// Used for horizontal relative motion. Dir is -1 or 1 (left or
|
4055 |
+
// right), unit can be "char", "column" (like char, but doesn't
|
4056 |
+
// cross line boundaries), "word" (across next word), or "group" (to
|
4057 |
+
// the start of next group of word or non-word-non-whitespace
|
4058 |
+
// chars). The visually param controls whether, in right-to-left
|
4059 |
+
// text, direction 1 means to move towards the next index in the
|
4060 |
+
// string, or towards the character to the right of the current
|
4061 |
+
// position. The resulting position will have a hitSide=true
|
4062 |
+
// property if it reached the end of the document.
|
4063 |
+
function findPosH(doc, pos, dir, unit, visually) {
|
4064 |
+
var line = pos.line, ch = pos.ch, origDir = dir;
|
4065 |
+
var lineObj = getLine(doc, line);
|
4066 |
+
var possible = true;
|
4067 |
+
function findNextLine() {
|
4068 |
+
var l = line + dir;
|
4069 |
+
if (l < doc.first || l >= doc.first + doc.size) return (possible = false);
|
4070 |
+
line = l;
|
4071 |
+
return lineObj = getLine(doc, l);
|
4072 |
+
}
|
4073 |
+
function moveOnce(boundToLine) {
|
4074 |
+
var next = (visually ? moveVisually : moveLogically)(lineObj, ch, dir, true);
|
4075 |
+
if (next == null) {
|
4076 |
+
if (!boundToLine && findNextLine()) {
|
4077 |
+
if (visually) ch = (dir < 0 ? lineRight : lineLeft)(lineObj);
|
4078 |
+
else ch = dir < 0 ? lineObj.text.length : 0;
|
4079 |
+
} else return (possible = false);
|
4080 |
+
} else ch = next;
|
4081 |
+
return true;
|
4082 |
+
}
|
4083 |
+
|
4084 |
+
if (unit == "char") moveOnce();
|
4085 |
+
else if (unit == "column") moveOnce(true);
|
4086 |
+
else if (unit == "word" || unit == "group") {
|
4087 |
+
var sawType = null, group = unit == "group";
|
4088 |
+
var helper = doc.cm && doc.cm.getHelper(pos, "wordChars");
|
4089 |
+
for (var first = true;; first = false) {
|
4090 |
+
if (dir < 0 && !moveOnce(!first)) break;
|
4091 |
+
var cur = lineObj.text.charAt(ch) || "\n";
|
4092 |
+
var type = isWordChar(cur, helper) ? "w"
|
4093 |
+
: group && cur == "\n" ? "n"
|
4094 |
+
: !group || /\s/.test(cur) ? null
|
4095 |
+
: "p";
|
4096 |
+
if (group && !first && !type) type = "s";
|
4097 |
+
if (sawType && sawType != type) {
|
4098 |
+
if (dir < 0) {dir = 1; moveOnce();}
|
4099 |
+
break;
|
4100 |
+
}
|
4101 |
+
|
4102 |
+
if (type) sawType = type;
|
4103 |
+
if (dir > 0 && !moveOnce(!first)) break;
|
4104 |
+
}
|
4105 |
+
}
|
4106 |
+
var result = skipAtomic(doc, Pos(line, ch), origDir, true);
|
4107 |
+
if (!possible) result.hitSide = true;
|
4108 |
+
return result;
|
4109 |
+
}
|
4110 |
+
|
4111 |
+
// For relative vertical movement. Dir may be -1 or 1. Unit can be
|
4112 |
+
// "page" or "line". The resulting position will have a hitSide=true
|
4113 |
+
// property if it reached the end of the document.
|
4114 |
+
function findPosV(cm, pos, dir, unit) {
|
4115 |
+
var doc = cm.doc, x = pos.left, y;
|
4116 |
+
if (unit == "page") {
|
4117 |
+
var pageSize = Math.min(cm.display.wrapper.clientHeight, window.innerHeight || document.documentElement.clientHeight);
|
4118 |
+
y = pos.top + dir * (pageSize - (dir < 0 ? 1.5 : .5) * textHeight(cm.display));
|
4119 |
+
} else if (unit == "line") {
|
4120 |
+
y = dir > 0 ? pos.bottom + 3 : pos.top - 3;
|
4121 |
+
}
|
4122 |
+
for (;;) {
|
4123 |
+
var target = coordsChar(cm, x, y);
|
4124 |
+
if (!target.outside) break;
|
4125 |
+
if (dir < 0 ? y <= 0 : y >= doc.height) { target.hitSide = true; break; }
|
4126 |
+
y += dir * 5;
|
4127 |
+
}
|
4128 |
+
return target;
|
4129 |
+
}
|
4130 |
+
|
4131 |
+
// EDITOR METHODS
|
4132 |
+
|
4133 |
+
// The publicly visible API. Note that methodOp(f) means
|
4134 |
+
// 'wrap f in an operation, performed on its `this` parameter'.
|
4135 |
+
|
4136 |
+
// This is not the complete set of editor methods. Most of the
|
4137 |
+
// methods defined on the Doc type are also injected into
|
4138 |
+
// CodeMirror.prototype, for backwards compatibility and
|
4139 |
+
// convenience.
|
4140 |
+
|
4141 |
+
CodeMirror.prototype = {
|
4142 |
+
constructor: CodeMirror,
|
4143 |
+
focus: function(){window.focus(); focusInput(this); fastPoll(this);},
|
4144 |
+
|
4145 |
+
setOption: function(option, value) {
|
4146 |
+
var options = this.options, old = options[option];
|
4147 |
+
if (options[option] == value && option != "mode") return;
|
4148 |
+
options[option] = value;
|
4149 |
+
if (optionHandlers.hasOwnProperty(option))
|
4150 |
+
operation(this, optionHandlers[option])(this, value, old);
|
4151 |
+
},
|
4152 |
+
|
4153 |
+
getOption: function(option) {return this.options[option];},
|
4154 |
+
getDoc: function() {return this.doc;},
|
4155 |
+
|
4156 |
+
addKeyMap: function(map, bottom) {
|
4157 |
+
this.state.keyMaps[bottom ? "push" : "unshift"](getKeyMap(map));
|
4158 |
+
},
|
4159 |
+
removeKeyMap: function(map) {
|
4160 |
+
var maps = this.state.keyMaps;
|
4161 |
+
for (var i = 0; i < maps.length; ++i)
|
4162 |
+
if (maps[i] == map || maps[i].name == map) {
|
4163 |
+
maps.splice(i, 1);
|
4164 |
+
return true;
|
4165 |
+
}
|
4166 |
+
},
|
4167 |
+
|
4168 |
+
addOverlay: methodOp(function(spec, options) {
|
4169 |
+
var mode = spec.token ? spec : CodeMirror.getMode(this.options, spec);
|
4170 |
+
if (mode.startState) throw new Error("Overlays may not be stateful.");
|
4171 |
+
this.state.overlays.push({mode: mode, modeSpec: spec, opaque: options && options.opaque});
|
4172 |
+
this.state.modeGen++;
|
4173 |
+
regChange(this);
|
4174 |
+
}),
|
4175 |
+
removeOverlay: methodOp(function(spec) {
|
4176 |
+
var overlays = this.state.overlays;
|
4177 |
+
for (var i = 0; i < overlays.length; ++i) {
|
4178 |
+
var cur = overlays[i].modeSpec;
|
4179 |
+
if (cur == spec || typeof spec == "string" && cur.name == spec) {
|
4180 |
+
overlays.splice(i, 1);
|
4181 |
+
this.state.modeGen++;
|
4182 |
+
regChange(this);
|
4183 |
+
return;
|
4184 |
+
}
|
4185 |
+
}
|
4186 |
+
}),
|
4187 |
+
|
4188 |
+
indentLine: methodOp(function(n, dir, aggressive) {
|
4189 |
+
if (typeof dir != "string" && typeof dir != "number") {
|
4190 |
+
if (dir == null) dir = this.options.smartIndent ? "smart" : "prev";
|
4191 |
+
else dir = dir ? "add" : "subtract";
|
4192 |
+
}
|
4193 |
+
if (isLine(this.doc, n)) indentLine(this, n, dir, aggressive);
|
4194 |
+
}),
|
4195 |
+
indentSelection: methodOp(function(how) {
|
4196 |
+
var ranges = this.doc.sel.ranges, end = -1;
|
4197 |
+
for (var i = 0; i < ranges.length; i++) {
|
4198 |
+
var range = ranges[i];
|
4199 |
+
if (!range.empty()) {
|
4200 |
+
var from = range.from(), to = range.to();
|
4201 |
+
var start = Math.max(end, from.line);
|
4202 |
+
end = Math.min(this.lastLine(), to.line - (to.ch ? 0 : 1)) + 1;
|
4203 |
+
for (var j = start; j < end; ++j)
|
4204 |
+
indentLine(this, j, how);
|
4205 |
+
var newRanges = this.doc.sel.ranges;
|
4206 |
+
if (from.ch == 0 && ranges.length == newRanges.length && newRanges[i].from().ch > 0)
|
4207 |
+
replaceOneSelection(this.doc, i, new Range(from, newRanges[i].to()), sel_dontScroll);
|
4208 |
+
} else if (range.head.line > end) {
|
4209 |
+
indentLine(this, range.head.line, how, true);
|
4210 |
+
end = range.head.line;
|
4211 |
+
if (i == this.doc.sel.primIndex) ensureCursorVisible(this);
|
4212 |
+
}
|
4213 |
+
}
|
4214 |
+
}),
|
4215 |
+
|
4216 |
+
// Fetch the parser token for a given character. Useful for hacks
|
4217 |
+
// that want to inspect the mode state (say, for completion).
|
4218 |
+
getTokenAt: function(pos, precise) {
|
4219 |
+
return takeToken(this, pos, precise);
|
4220 |
+
},
|
4221 |
+
|
4222 |
+
getLineTokens: function(line, precise) {
|
4223 |
+
return takeToken(this, Pos(line), precise, true);
|
4224 |
+
},
|
4225 |
+
|
4226 |
+
getTokenTypeAt: function(pos) {
|
4227 |
+
pos = clipPos(this.doc, pos);
|
4228 |
+
var styles = getLineStyles(this, getLine(this.doc, pos.line));
|
4229 |
+
var before = 0, after = (styles.length - 1) / 2, ch = pos.ch;
|
4230 |
+
var type;
|
4231 |
+
if (ch == 0) type = styles[2];
|
4232 |
+
else for (;;) {
|
4233 |
+
var mid = (before + after) >> 1;
|
4234 |
+
if ((mid ? styles[mid * 2 - 1] : 0) >= ch) after = mid;
|
4235 |
+
else if (styles[mid * 2 + 1] < ch) before = mid + 1;
|
4236 |
+
else { type = styles[mid * 2 + 2]; break; }
|
4237 |
+
}
|
4238 |
+
var cut = type ? type.indexOf("cm-overlay ") : -1;
|
4239 |
+
return cut < 0 ? type : cut == 0 ? null : type.slice(0, cut - 1);
|
4240 |
+
},
|
4241 |
+
|
4242 |
+
getModeAt: function(pos) {
|
4243 |
+
var mode = this.doc.mode;
|
4244 |
+
if (!mode.innerMode) return mode;
|
4245 |
+
return CodeMirror.innerMode(mode, this.getTokenAt(pos).state).mode;
|
4246 |
+
},
|
4247 |
+
|
4248 |
+
getHelper: function(pos, type) {
|
4249 |
+
return this.getHelpers(pos, type)[0];
|
4250 |
+
},
|
4251 |
+
|
4252 |
+
getHelpers: function(pos, type) {
|
4253 |
+
var found = [];
|
4254 |
+
if (!helpers.hasOwnProperty(type)) return helpers;
|
4255 |
+
var help = helpers[type], mode = this.getModeAt(pos);
|
4256 |
+
if (typeof mode[type] == "string") {
|
4257 |
+
if (help[mode[type]]) found.push(help[mode[type]]);
|
4258 |
+
} else if (mode[type]) {
|
4259 |
+
for (var i = 0; i < mode[type].length; i++) {
|
4260 |
+
var val = help[mode[type][i]];
|
4261 |
+
if (val) found.push(val);
|
4262 |
+
}
|
4263 |
+
} else if (mode.helperType && help[mode.helperType]) {
|
4264 |
+
found.push(help[mode.helperType]);
|
4265 |
+
} else if (help[mode.name]) {
|
4266 |
+
found.push(help[mode.name]);
|
4267 |
+
}
|
4268 |
+
for (var i = 0; i < help._global.length; i++) {
|
4269 |
+
var cur = help._global[i];
|
4270 |
+
if (cur.pred(mode, this) && indexOf(found, cur.val) == -1)
|
4271 |
+
found.push(cur.val);
|
4272 |
+
}
|
4273 |
+
return found;
|
4274 |
+
},
|
4275 |
+
|
4276 |
+
getStateAfter: function(line, precise) {
|
4277 |
+
var doc = this.doc;
|
4278 |
+
line = clipLine(doc, line == null ? doc.first + doc.size - 1: line);
|
4279 |
+
return getStateBefore(this, line + 1, precise);
|
4280 |
+
},
|
4281 |
+
|
4282 |
+
cursorCoords: function(start, mode) {
|
4283 |
+
var pos, range = this.doc.sel.primary();
|
4284 |
+
if (start == null) pos = range.head;
|
4285 |
+
else if (typeof start == "object") pos = clipPos(this.doc, start);
|
4286 |
+
else pos = start ? range.from() : range.to();
|
4287 |
+
return cursorCoords(this, pos, mode || "page");
|
4288 |
+
},
|
4289 |
+
|
4290 |
+
charCoords: function(pos, mode) {
|
4291 |
+
return charCoords(this, clipPos(this.doc, pos), mode || "page");
|
4292 |
+
},
|
4293 |
+
|
4294 |
+
coordsChar: function(coords, mode) {
|
4295 |
+
coords = fromCoordSystem(this, coords, mode || "page");
|
4296 |
+
return coordsChar(this, coords.left, coords.top);
|
4297 |
+
},
|
4298 |
+
|
4299 |
+
lineAtHeight: function(height, mode) {
|
4300 |
+
height = fromCoordSystem(this, {top: height, left: 0}, mode || "page").top;
|
4301 |
+
return lineAtHeight(this.doc, height + this.display.viewOffset);
|
4302 |
+
},
|
4303 |
+
heightAtLine: function(line, mode) {
|
4304 |
+
var end = false, last = this.doc.first + this.doc.size - 1;
|
4305 |
+
if (line < this.doc.first) line = this.doc.first;
|
4306 |
+
else if (line > last) { line = last; end = true; }
|
4307 |
+
var lineObj = getLine(this.doc, line);
|
4308 |
+
return intoCoordSystem(this, lineObj, {top: 0, left: 0}, mode || "page").top +
|
4309 |
+
(end ? this.doc.height - heightAtLine(lineObj) : 0);
|
4310 |
+
},
|
4311 |
+
|
4312 |
+
defaultTextHeight: function() { return textHeight(this.display); },
|
4313 |
+
defaultCharWidth: function() { return charWidth(this.display); },
|
4314 |
+
|
4315 |
+
setGutterMarker: methodOp(function(line, gutterID, value) {
|
4316 |
+
return changeLine(this.doc, line, "gutter", function(line) {
|
4317 |
+
var markers = line.gutterMarkers || (line.gutterMarkers = {});
|
4318 |
+
markers[gutterID] = value;
|
4319 |
+
if (!value && isEmpty(markers)) line.gutterMarkers = null;
|
4320 |
+
return true;
|
4321 |
+
});
|
4322 |
+
}),
|
4323 |
+
|
4324 |
+
clearGutter: methodOp(function(gutterID) {
|
4325 |
+
var cm = this, doc = cm.doc, i = doc.first;
|
4326 |
+
doc.iter(function(line) {
|
4327 |
+
if (line.gutterMarkers && line.gutterMarkers[gutterID]) {
|
4328 |
+
line.gutterMarkers[gutterID] = null;
|
4329 |
+
regLineChange(cm, i, "gutter");
|
4330 |
+
if (isEmpty(line.gutterMarkers)) line.gutterMarkers = null;
|
4331 |
+
}
|
4332 |
+
++i;
|
4333 |
+
});
|
4334 |
+
}),
|
4335 |
+
|
4336 |
+
addLineWidget: methodOp(function(handle, node, options) {
|
4337 |
+
return addLineWidget(this, handle, node, options);
|
4338 |
+
}),
|
4339 |
+
|
4340 |
+
removeLineWidget: function(widget) { widget.clear(); },
|
4341 |
+
|
4342 |
+
lineInfo: function(line) {
|
4343 |
+
if (typeof line == "number") {
|
4344 |
+
if (!isLine(this.doc, line)) return null;
|
4345 |
+
var n = line;
|
4346 |
+
line = getLine(this.doc, line);
|
4347 |
+
if (!line) return null;
|
4348 |
+
} else {
|
4349 |
+
var n = lineNo(line);
|
4350 |
+
if (n == null) return null;
|
4351 |
+
}
|
4352 |
+
return {line: n, handle: line, text: line.text, gutterMarkers: line.gutterMarkers,
|
4353 |
+
textClass: line.textClass, bgClass: line.bgClass, wrapClass: line.wrapClass,
|
4354 |
+
widgets: line.widgets};
|
4355 |
+
},
|
4356 |
+
|
4357 |
+
getViewport: function() { return {from: this.display.viewFrom, to: this.display.viewTo};},
|
4358 |
+
|
4359 |
+
addWidget: function(pos, node, scroll, vert, horiz) {
|
4360 |
+
var display = this.display;
|
4361 |
+
pos = cursorCoords(this, clipPos(this.doc, pos));
|
4362 |
+
var top = pos.bottom, left = pos.left;
|
4363 |
+
node.style.position = "absolute";
|
4364 |
+
node.setAttribute("cm-ignore-events", "true");
|
4365 |
+
display.sizer.appendChild(node);
|
4366 |
+
if (vert == "over") {
|
4367 |
+
top = pos.top;
|
4368 |
+
} else if (vert == "above" || vert == "near") {
|
4369 |
+
var vspace = Math.max(display.wrapper.clientHeight, this.doc.height),
|
4370 |
+
hspace = Math.max(display.sizer.clientWidth, display.lineSpace.clientWidth);
|
4371 |
+
// Default to positioning above (if specified and possible); otherwise default to positioning below
|
4372 |
+
if ((vert == 'above' || pos.bottom + node.offsetHeight > vspace) && pos.top > node.offsetHeight)
|
4373 |
+
top = pos.top - node.offsetHeight;
|
4374 |
+
else if (pos.bottom + node.offsetHeight <= vspace)
|
4375 |
+
top = pos.bottom;
|
4376 |
+
if (left + node.offsetWidth > hspace)
|
4377 |
+
left = hspace - node.offsetWidth;
|
4378 |
+
}
|
4379 |
+
node.style.top = top + "px";
|
4380 |
+
node.style.left = node.style.right = "";
|
4381 |
+
if (horiz == "right") {
|
4382 |
+
left = display.sizer.clientWidth - node.offsetWidth;
|
4383 |
+
node.style.right = "0px";
|
4384 |
+
} else {
|
4385 |
+
if (horiz == "left") left = 0;
|
4386 |
+
else if (horiz == "middle") left = (display.sizer.clientWidth - node.offsetWidth) / 2;
|
4387 |
+
node.style.left = left + "px";
|
4388 |
+
}
|
4389 |
+
if (scroll)
|
4390 |
+
scrollIntoView(this, left, top, left + node.offsetWidth, top + node.offsetHeight);
|
4391 |
+
},
|
4392 |
+
|
4393 |
+
triggerOnKeyDown: methodOp(onKeyDown),
|
4394 |
+
triggerOnKeyPress: methodOp(onKeyPress),
|
4395 |
+
triggerOnKeyUp: onKeyUp,
|
4396 |
+
|
4397 |
+
execCommand: function(cmd) {
|
4398 |
+
if (commands.hasOwnProperty(cmd))
|
4399 |
+
return commands[cmd](this);
|
4400 |
+
},
|
4401 |
+
|
4402 |
+
findPosH: function(from, amount, unit, visually) {
|
4403 |
+
var dir = 1;
|
4404 |
+
if (amount < 0) { dir = -1; amount = -amount; }
|
4405 |
+
for (var i = 0, cur = clipPos(this.doc, from); i < amount; ++i) {
|
4406 |
+
cur = findPosH(this.doc, cur, dir, unit, visually);
|
4407 |
+
if (cur.hitSide) break;
|
4408 |
+
}
|
4409 |
+
return cur;
|
4410 |
+
},
|
4411 |
+
|
4412 |
+
moveH: methodOp(function(dir, unit) {
|
4413 |
+
var cm = this;
|
4414 |
+
cm.extendSelectionsBy(function(range) {
|
4415 |
+
if (cm.display.shift || cm.doc.extend || range.empty())
|
4416 |
+
return findPosH(cm.doc, range.head, dir, unit, cm.options.rtlMoveVisually);
|
4417 |
+
else
|
4418 |
+
return dir < 0 ? range.from() : range.to();
|
4419 |
+
}, sel_move);
|
4420 |
+
}),
|
4421 |
+
|
4422 |
+
deleteH: methodOp(function(dir, unit) {
|
4423 |
+
var sel = this.doc.sel, doc = this.doc;
|
4424 |
+
if (sel.somethingSelected())
|
4425 |
+
doc.replaceSelection("", null, "+delete");
|
4426 |
+
else
|
4427 |
+
deleteNearSelection(this, function(range) {
|
4428 |
+
var other = findPosH(doc, range.head, dir, unit, false);
|
4429 |
+
return dir < 0 ? {from: other, to: range.head} : {from: range.head, to: other};
|
4430 |
+
});
|
4431 |
+
}),
|
4432 |
+
|
4433 |
+
findPosV: function(from, amount, unit, goalColumn) {
|
4434 |
+
var dir = 1, x = goalColumn;
|
4435 |
+
if (amount < 0) { dir = -1; amount = -amount; }
|
4436 |
+
for (var i = 0, cur = clipPos(this.doc, from); i < amount; ++i) {
|
4437 |
+
var coords = cursorCoords(this, cur, "div");
|
4438 |
+
if (x == null) x = coords.left;
|
4439 |
+
else coords.left = x;
|
4440 |
+
cur = findPosV(this, coords, dir, unit);
|
4441 |
+
if (cur.hitSide) break;
|
4442 |
+
}
|
4443 |
+
return cur;
|
4444 |
+
},
|
4445 |
+
|
4446 |
+
moveV: methodOp(function(dir, unit) {
|
4447 |
+
var cm = this, doc = this.doc, goals = [];
|
4448 |
+
var collapse = !cm.display.shift && !doc.extend && doc.sel.somethingSelected();
|
4449 |
+
doc.extendSelectionsBy(function(range) {
|
4450 |
+
if (collapse)
|
4451 |
+
return dir < 0 ? range.from() : range.to();
|
4452 |
+
var headPos = cursorCoords(cm, range.head, "div");
|
4453 |
+
if (range.goalColumn != null) headPos.left = range.goalColumn;
|
4454 |
+
goals.push(headPos.left);
|
4455 |
+
var pos = findPosV(cm, headPos, dir, unit);
|
4456 |
+
if (unit == "page" && range == doc.sel.primary())
|
4457 |
+
addToScrollPos(cm, null, charCoords(cm, pos, "div").top - headPos.top);
|
4458 |
+
return pos;
|
4459 |
+
}, sel_move);
|
4460 |
+
if (goals.length) for (var i = 0; i < doc.sel.ranges.length; i++)
|
4461 |
+
doc.sel.ranges[i].goalColumn = goals[i];
|
4462 |
+
}),
|
4463 |
+
|
4464 |
+
// Find the word at the given position (as returned by coordsChar).
|
4465 |
+
findWordAt: function(pos) {
|
4466 |
+
var doc = this.doc, line = getLine(doc, pos.line).text;
|
4467 |
+
var start = pos.ch, end = pos.ch;
|
4468 |
+
if (line) {
|
4469 |
+
var helper = this.getHelper(pos, "wordChars");
|
4470 |
+
if ((pos.xRel < 0 || end == line.length) && start) --start; else ++end;
|
4471 |
+
var startChar = line.charAt(start);
|
4472 |
+
var check = isWordChar(startChar, helper)
|
4473 |
+
? function(ch) { return isWordChar(ch, helper); }
|
4474 |
+
: /\s/.test(startChar) ? function(ch) {return /\s/.test(ch);}
|
4475 |
+
: function(ch) {return !/\s/.test(ch) && !isWordChar(ch);};
|
4476 |
+
while (start > 0 && check(line.charAt(start - 1))) --start;
|
4477 |
+
while (end < line.length && check(line.charAt(end))) ++end;
|
4478 |
+
}
|
4479 |
+
return new Range(Pos(pos.line, start), Pos(pos.line, end));
|
4480 |
+
},
|
4481 |
+
|
4482 |
+
toggleOverwrite: function(value) {
|
4483 |
+
if (value != null && value == this.state.overwrite) return;
|
4484 |
+
if (this.state.overwrite = !this.state.overwrite)
|
4485 |
+
addClass(this.display.cursorDiv, "CodeMirror-overwrite");
|
4486 |
+
else
|
4487 |
+
rmClass(this.display.cursorDiv, "CodeMirror-overwrite");
|
4488 |
+
|
4489 |
+
signal(this, "overwriteToggle", this, this.state.overwrite);
|
4490 |
+
},
|
4491 |
+
hasFocus: function() { return activeElt() == this.display.input; },
|
4492 |
+
|
4493 |
+
scrollTo: methodOp(function(x, y) {
|
4494 |
+
if (x != null || y != null) resolveScrollToPos(this);
|
4495 |
+
if (x != null) this.curOp.scrollLeft = x;
|
4496 |
+
if (y != null) this.curOp.scrollTop = y;
|
4497 |
+
}),
|
4498 |
+
getScrollInfo: function() {
|
4499 |
+
var scroller = this.display.scroller;
|
4500 |
+
return {left: scroller.scrollLeft, top: scroller.scrollTop,
|
4501 |
+
height: scroller.scrollHeight - scrollGap(this) - this.display.barHeight,
|
4502 |
+
width: scroller.scrollWidth - scrollGap(this) - this.display.barWidth,
|
4503 |
+
clientHeight: displayHeight(this), clientWidth: displayWidth(this)};
|
4504 |
+
},
|
4505 |
+
|
4506 |
+
scrollIntoView: methodOp(function(range, margin) {
|
4507 |
+
if (range == null) {
|
4508 |
+
range = {from: this.doc.sel.primary().head, to: null};
|
4509 |
+
if (margin == null) margin = this.options.cursorScrollMargin;
|
4510 |
+
} else if (typeof range == "number") {
|
4511 |
+
range = {from: Pos(range, 0), to: null};
|
4512 |
+
} else if (range.from == null) {
|
4513 |
+
range = {from: range, to: null};
|
4514 |
+
}
|
4515 |
+
if (!range.to) range.to = range.from;
|
4516 |
+
range.margin = margin || 0;
|
4517 |
+
|
4518 |
+
if (range.from.line != null) {
|
4519 |
+
resolveScrollToPos(this);
|
4520 |
+
this.curOp.scrollToPos = range;
|
4521 |
+
} else {
|
4522 |
+
var sPos = calculateScrollPos(this, Math.min(range.from.left, range.to.left),
|
4523 |
+
Math.min(range.from.top, range.to.top) - range.margin,
|
4524 |
+
Math.max(range.from.right, range.to.right),
|
4525 |
+
Math.max(range.from.bottom, range.to.bottom) + range.margin);
|
4526 |
+
this.scrollTo(sPos.scrollLeft, sPos.scrollTop);
|
4527 |
+
}
|
4528 |
+
}),
|
4529 |
+
|
4530 |
+
setSize: methodOp(function(width, height) {
|
4531 |
+
var cm = this;
|
4532 |
+
function interpret(val) {
|
4533 |
+
return typeof val == "number" || /^\d+$/.test(String(val)) ? val + "px" : val;
|
4534 |
+
}
|
4535 |
+
if (width != null) cm.display.wrapper.style.width = interpret(width);
|
4536 |
+
if (height != null) cm.display.wrapper.style.height = interpret(height);
|
4537 |
+
if (cm.options.lineWrapping) clearLineMeasurementCache(this);
|
4538 |
+
var lineNo = cm.display.viewFrom;
|
4539 |
+
cm.doc.iter(lineNo, cm.display.viewTo, function(line) {
|
4540 |
+
if (line.widgets) for (var i = 0; i < line.widgets.length; i++)
|
4541 |
+
if (line.widgets[i].noHScroll) { regLineChange(cm, lineNo, "widget"); break; }
|
4542 |
+
++lineNo;
|
4543 |
+
});
|
4544 |
+
cm.curOp.forceUpdate = true;
|
4545 |
+
signal(cm, "refresh", this);
|
4546 |
+
}),
|
4547 |
+
|
4548 |
+
operation: function(f){return runInOp(this, f);},
|
4549 |
+
|
4550 |
+
refresh: methodOp(function() {
|
4551 |
+
var oldHeight = this.display.cachedTextHeight;
|
4552 |
+
regChange(this);
|
4553 |
+
this.curOp.forceUpdate = true;
|
4554 |
+
clearCaches(this);
|
4555 |
+
this.scrollTo(this.doc.scrollLeft, this.doc.scrollTop);
|
4556 |
+
updateGutterSpace(this);
|
4557 |
+
if (oldHeight == null || Math.abs(oldHeight - textHeight(this.display)) > .5)
|
4558 |
+
estimateLineHeights(this);
|
4559 |
+
signal(this, "refresh", this);
|
4560 |
+
}),
|
4561 |
+
|
4562 |
+
swapDoc: methodOp(function(doc) {
|
4563 |
+
var old = this.doc;
|
4564 |
+
old.cm = null;
|
4565 |
+
attachDoc(this, doc);
|
4566 |
+
clearCaches(this);
|
4567 |
+
resetInput(this);
|
4568 |
+
this.scrollTo(doc.scrollLeft, doc.scrollTop);
|
4569 |
+
this.curOp.forceScroll = true;
|
4570 |
+
signalLater(this, "swapDoc", this, old);
|
4571 |
+
return old;
|
4572 |
+
}),
|
4573 |
+
|
4574 |
+
getInputField: function(){return this.display.input;},
|
4575 |
+
getWrapperElement: function(){return this.display.wrapper;},
|
4576 |
+
getScrollerElement: function(){return this.display.scroller;},
|
4577 |
+
getGutterElement: function(){return this.display.gutters;}
|
4578 |
+
};
|
4579 |
+
eventMixin(CodeMirror);
|
4580 |
+
|
4581 |
+
// OPTION DEFAULTS
|
4582 |
+
|
4583 |
+
// The default configuration options.
|
4584 |
+
var defaults = CodeMirror.defaults = {};
|
4585 |
+
// Functions to run when options are changed.
|
4586 |
+
var optionHandlers = CodeMirror.optionHandlers = {};
|
4587 |
+
|
4588 |
+
function option(name, deflt, handle, notOnInit) {
|
4589 |
+
CodeMirror.defaults[name] = deflt;
|
4590 |
+
if (handle) optionHandlers[name] =
|
4591 |
+
notOnInit ? function(cm, val, old) {if (old != Init) handle(cm, val, old);} : handle;
|
4592 |
+
}
|
4593 |
+
|
4594 |
+
// Passed to option handlers when there is no old value.
|
4595 |
+
var Init = CodeMirror.Init = {toString: function(){return "CodeMirror.Init";}};
|
4596 |
+
|
4597 |
+
// These two are, on init, called from the constructor because they
|
4598 |
+
// have to be initialized before the editor can start at all.
|
4599 |
+
option("value", "", function(cm, val) {
|
4600 |
+
cm.setValue(val);
|
4601 |
+
}, true);
|
4602 |
+
option("mode", null, function(cm, val) {
|
4603 |
+
cm.doc.modeOption = val;
|
4604 |
+
loadMode(cm);
|
4605 |
+
}, true);
|
4606 |
+
|
4607 |
+
option("indentUnit", 2, loadMode, true);
|
4608 |
+
option("indentWithTabs", false);
|
4609 |
+
option("smartIndent", true);
|
4610 |
+
option("tabSize", 4, function(cm) {
|
4611 |
+
resetModeState(cm);
|
4612 |
+
clearCaches(cm);
|
4613 |
+
regChange(cm);
|
4614 |
+
}, true);
|
4615 |
+
option("specialChars", /[\t\u0000-\u0019\u00ad\u200b-\u200f\u2028\u2029\ufeff]/g, function(cm, val) {
|
4616 |
+
cm.options.specialChars = new RegExp(val.source + (val.test("\t") ? "" : "|\t"), "g");
|
4617 |
+
cm.refresh();
|
4618 |
+
}, true);
|
4619 |
+
option("specialCharPlaceholder", defaultSpecialCharPlaceholder, function(cm) {cm.refresh();}, true);
|
4620 |
+
option("electricChars", true);
|
4621 |
+
option("rtlMoveVisually", !windows);
|
4622 |
+
option("wholeLineUpdateBefore", true);
|
4623 |
+
|
4624 |
+
option("theme", "default", function(cm) {
|
4625 |
+
themeChanged(cm);
|
4626 |
+
guttersChanged(cm);
|
4627 |
+
}, true);
|
4628 |
+
option("keyMap", "default", function(cm, val, old) {
|
4629 |
+
var next = getKeyMap(val);
|
4630 |
+
var prev = old != CodeMirror.Init && getKeyMap(old);
|
4631 |
+
if (prev && prev.detach) prev.detach(cm, next);
|
4632 |
+
if (next.attach) next.attach(cm, prev || null);
|
4633 |
+
});
|
4634 |
+
option("extraKeys", null);
|
4635 |
+
|
4636 |
+
option("lineWrapping", false, wrappingChanged, true);
|
4637 |
+
option("gutters", [], function(cm) {
|
4638 |
+
setGuttersForLineNumbers(cm.options);
|
4639 |
+
guttersChanged(cm);
|
4640 |
+
}, true);
|
4641 |
+
option("fixedGutter", true, function(cm, val) {
|
4642 |
+
cm.display.gutters.style.left = val ? compensateForHScroll(cm.display) + "px" : "0";
|
4643 |
+
cm.refresh();
|
4644 |
+
}, true);
|
4645 |
+
option("coverGutterNextToScrollbar", false, function(cm) {updateScrollbars(cm);}, true);
|
4646 |
+
option("scrollbarStyle", "native", function(cm) {
|
4647 |
+
initScrollbars(cm);
|
4648 |
+
updateScrollbars(cm);
|
4649 |
+
cm.display.scrollbars.setScrollTop(cm.doc.scrollTop);
|
4650 |
+
cm.display.scrollbars.setScrollLeft(cm.doc.scrollLeft);
|
4651 |
+
}, true);
|
4652 |
+
option("lineNumbers", false, function(cm) {
|
4653 |
+
setGuttersForLineNumbers(cm.options);
|
4654 |
+
guttersChanged(cm);
|
4655 |
+
}, true);
|
4656 |
+
option("firstLineNumber", 1, guttersChanged, true);
|
4657 |
+
option("lineNumberFormatter", function(integer) {return integer;}, guttersChanged, true);
|
4658 |
+
option("showCursorWhenSelecting", false, updateSelection, true);
|
4659 |
+
|
4660 |
+
option("resetSelectionOnContextMenu", true);
|
4661 |
+
|
4662 |
+
option("readOnly", false, function(cm, val) {
|
4663 |
+
if (val == "nocursor") {
|
4664 |
+
onBlur(cm);
|
4665 |
+
cm.display.input.blur();
|
4666 |
+
cm.display.disabled = true;
|
4667 |
+
} else {
|
4668 |
+
cm.display.disabled = false;
|
4669 |
+
if (!val) resetInput(cm);
|
4670 |
+
}
|
4671 |
+
});
|
4672 |
+
option("disableInput", false, function(cm, val) {if (!val) resetInput(cm);}, true);
|
4673 |
+
option("dragDrop", true);
|
4674 |
+
|
4675 |
+
option("cursorBlinkRate", 530);
|
4676 |
+
option("cursorScrollMargin", 0);
|
4677 |
+
option("cursorHeight", 1, updateSelection, true);
|
4678 |
+
option("singleCursorHeightPerLine", true, updateSelection, true);
|
4679 |
+
option("workTime", 100);
|
4680 |
+
option("workDelay", 100);
|
4681 |
+
option("flattenSpans", true, resetModeState, true);
|
4682 |
+
option("addModeClass", false, resetModeState, true);
|
4683 |
+
option("pollInterval", 100);
|
4684 |
+
option("undoDepth", 200, function(cm, val){cm.doc.history.undoDepth = val;});
|
4685 |
+
option("historyEventDelay", 1250);
|
4686 |
+
option("viewportMargin", 10, function(cm){cm.refresh();}, true);
|
4687 |
+
option("maxHighlightLength", 10000, resetModeState, true);
|
4688 |
+
option("moveInputWithCursor", true, function(cm, val) {
|
4689 |
+
if (!val) cm.display.inputDiv.style.top = cm.display.inputDiv.style.left = 0;
|
4690 |
+
});
|
4691 |
+
|
4692 |
+
option("tabindex", null, function(cm, val) {
|
4693 |
+
cm.display.input.tabIndex = val || "";
|
4694 |
+
});
|
4695 |
+
option("autofocus", null);
|
4696 |
+
|
4697 |
+
// MODE DEFINITION AND QUERYING
|
4698 |
+
|
4699 |
+
// Known modes, by name and by MIME
|
4700 |
+
var modes = CodeMirror.modes = {}, mimeModes = CodeMirror.mimeModes = {};
|
4701 |
+
|
4702 |
+
// Extra arguments are stored as the mode's dependencies, which is
|
4703 |
+
// used by (legacy) mechanisms like loadmode.js to automatically
|
4704 |
+
// load a mode. (Preferred mechanism is the require/define calls.)
|
4705 |
+
CodeMirror.defineMode = function(name, mode) {
|
4706 |
+
if (!CodeMirror.defaults.mode && name != "null") CodeMirror.defaults.mode = name;
|
4707 |
+
if (arguments.length > 2)
|
4708 |
+
mode.dependencies = Array.prototype.slice.call(arguments, 2);
|
4709 |
+
modes[name] = mode;
|
4710 |
+
};
|
4711 |
+
|
4712 |
+
CodeMirror.defineMIME = function(mime, spec) {
|
4713 |
+
mimeModes[mime] = spec;
|
4714 |
+
};
|
4715 |
+
|
4716 |
+
// Given a MIME type, a {name, ...options} config object, or a name
|
4717 |
+
// string, return a mode config object.
|
4718 |
+
CodeMirror.resolveMode = function(spec) {
|
4719 |
+
if (typeof spec == "string" && mimeModes.hasOwnProperty(spec)) {
|
4720 |
+
spec = mimeModes[spec];
|
4721 |
+
} else if (spec && typeof spec.name == "string" && mimeModes.hasOwnProperty(spec.name)) {
|
4722 |
+
var found = mimeModes[spec.name];
|
4723 |
+
if (typeof found == "string") found = {name: found};
|
4724 |
+
spec = createObj(found, spec);
|
4725 |
+
spec.name = found.name;
|
4726 |
+
} else if (typeof spec == "string" && /^[\w\-]+\/[\w\-]+\+xml$/.test(spec)) {
|
4727 |
+
return CodeMirror.resolveMode("application/xml");
|
4728 |
+
}
|
4729 |
+
if (typeof spec == "string") return {name: spec};
|
4730 |
+
else return spec || {name: "null"};
|
4731 |
+
};
|
4732 |
+
|
4733 |
+
// Given a mode spec (anything that resolveMode accepts), find and
|
4734 |
+
// initialize an actual mode object.
|
4735 |
+
CodeMirror.getMode = function(options, spec) {
|
4736 |
+
var spec = CodeMirror.resolveMode(spec);
|
4737 |
+
var mfactory = modes[spec.name];
|
4738 |
+
if (!mfactory) return CodeMirror.getMode(options, "text/plain");
|
4739 |
+
var modeObj = mfactory(options, spec);
|
4740 |
+
if (modeExtensions.hasOwnProperty(spec.name)) {
|
4741 |
+
var exts = modeExtensions[spec.name];
|
4742 |
+
for (var prop in exts) {
|
4743 |
+
if (!exts.hasOwnProperty(prop)) continue;
|
4744 |
+
if (modeObj.hasOwnProperty(prop)) modeObj["_" + prop] = modeObj[prop];
|
4745 |
+
modeObj[prop] = exts[prop];
|
4746 |
+
}
|
4747 |
+
}
|
4748 |
+
modeObj.name = spec.name;
|
4749 |
+
if (spec.helperType) modeObj.helperType = spec.helperType;
|
4750 |
+
if (spec.modeProps) for (var prop in spec.modeProps)
|
4751 |
+
modeObj[prop] = spec.modeProps[prop];
|
4752 |
+
|
4753 |
+
return modeObj;
|
4754 |
+
};
|
4755 |
+
|
4756 |
+
// Minimal default mode.
|
4757 |
+
CodeMirror.defineMode("null", function() {
|
4758 |
+
return {token: function(stream) {stream.skipToEnd();}};
|
4759 |
+
});
|
4760 |
+
CodeMirror.defineMIME("text/plain", "null");
|
4761 |
+
|
4762 |
+
// This can be used to attach properties to mode objects from
|
4763 |
+
// outside the actual mode definition.
|
4764 |
+
var modeExtensions = CodeMirror.modeExtensions = {};
|
4765 |
+
CodeMirror.extendMode = function(mode, properties) {
|
4766 |
+
var exts = modeExtensions.hasOwnProperty(mode) ? modeExtensions[mode] : (modeExtensions[mode] = {});
|
4767 |
+
copyObj(properties, exts);
|
4768 |
+
};
|
4769 |
+
|
4770 |
+
// EXTENSIONS
|
4771 |
+
|
4772 |
+
CodeMirror.defineExtension = function(name, func) {
|
4773 |
+
CodeMirror.prototype[name] = func;
|
4774 |
+
};
|
4775 |
+
CodeMirror.defineDocExtension = function(name, func) {
|
4776 |
+
Doc.prototype[name] = func;
|
4777 |
+
};
|
4778 |
+
CodeMirror.defineOption = option;
|
4779 |
+
|
4780 |
+
var initHooks = [];
|
4781 |
+
CodeMirror.defineInitHook = function(f) {initHooks.push(f);};
|
4782 |
+
|
4783 |
+
var helpers = CodeMirror.helpers = {};
|
4784 |
+
CodeMirror.registerHelper = function(type, name, value) {
|
4785 |
+
if (!helpers.hasOwnProperty(type)) helpers[type] = CodeMirror[type] = {_global: []};
|
4786 |
+
helpers[type][name] = value;
|
4787 |
+
};
|
4788 |
+
CodeMirror.registerGlobalHelper = function(type, name, predicate, value) {
|
4789 |
+
CodeMirror.registerHelper(type, name, value);
|
4790 |
+
helpers[type]._global.push({pred: predicate, val: value});
|
4791 |
+
};
|
4792 |
+
|
4793 |
+
// MODE STATE HANDLING
|
4794 |
+
|
4795 |
+
// Utility functions for working with state. Exported because nested
|
4796 |
+
// modes need to do this for their inner modes.
|
4797 |
+
|
4798 |
+
var copyState = CodeMirror.copyState = function(mode, state) {
|
4799 |
+
if (state === true) return state;
|
4800 |
+
if (mode.copyState) return mode.copyState(state);
|
4801 |
+
var nstate = {};
|
4802 |
+
for (var n in state) {
|
4803 |
+
var val = state[n];
|
4804 |
+
if (val instanceof Array) val = val.concat([]);
|
4805 |
+
nstate[n] = val;
|
4806 |
+
}
|
4807 |
+
return nstate;
|
4808 |
+
};
|
4809 |
+
|
4810 |
+
var startState = CodeMirror.startState = function(mode, a1, a2) {
|
4811 |
+
return mode.startState ? mode.startState(a1, a2) : true;
|
4812 |
+
};
|
4813 |
+
|
4814 |
+
// Given a mode and a state (for that mode), find the inner mode and
|
4815 |
+
// state at the position that the state refers to.
|
4816 |
+
CodeMirror.innerMode = function(mode, state) {
|
4817 |
+
while (mode.innerMode) {
|
4818 |
+
var info = mode.innerMode(state);
|
4819 |
+
if (!info || info.mode == mode) break;
|
4820 |
+
state = info.state;
|
4821 |
+
mode = info.mode;
|
4822 |
+
}
|
4823 |
+
return info || {mode: mode, state: state};
|
4824 |
+
};
|
4825 |
+
|
4826 |
+
// STANDARD COMMANDS
|
4827 |
+
|
4828 |
+
// Commands are parameter-less actions that can be performed on an
|
4829 |
+
// editor, mostly used for keybindings.
|
4830 |
+
var commands = CodeMirror.commands = {
|
4831 |
+
selectAll: function(cm) {cm.setSelection(Pos(cm.firstLine(), 0), Pos(cm.lastLine()), sel_dontScroll);},
|
4832 |
+
singleSelection: function(cm) {
|
4833 |
+
cm.setSelection(cm.getCursor("anchor"), cm.getCursor("head"), sel_dontScroll);
|
4834 |
+
},
|
4835 |
+
killLine: function(cm) {
|
4836 |
+
deleteNearSelection(cm, function(range) {
|
4837 |
+
if (range.empty()) {
|
4838 |
+
var len = getLine(cm.doc, range.head.line).text.length;
|
4839 |
+
if (range.head.ch == len && range.head.line < cm.lastLine())
|
4840 |
+
return {from: range.head, to: Pos(range.head.line + 1, 0)};
|
4841 |
+
else
|
4842 |
+
return {from: range.head, to: Pos(range.head.line, len)};
|
4843 |
+
} else {
|
4844 |
+
return {from: range.from(), to: range.to()};
|
4845 |
+
}
|
4846 |
+
});
|
4847 |
+
},
|
4848 |
+
deleteLine: function(cm) {
|
4849 |
+
deleteNearSelection(cm, function(range) {
|
4850 |
+
return {from: Pos(range.from().line, 0),
|
4851 |
+
to: clipPos(cm.doc, Pos(range.to().line + 1, 0))};
|
4852 |
+
});
|
4853 |
+
},
|
4854 |
+
delLineLeft: function(cm) {
|
4855 |
+
deleteNearSelection(cm, function(range) {
|
4856 |
+
return {from: Pos(range.from().line, 0), to: range.from()};
|
4857 |
+
});
|
4858 |
+
},
|
4859 |
+
delWrappedLineLeft: function(cm) {
|
4860 |
+
deleteNearSelection(cm, function(range) {
|
4861 |
+
var top = cm.charCoords(range.head, "div").top + 5;
|
4862 |
+
var leftPos = cm.coordsChar({left: 0, top: top}, "div");
|
4863 |
+
return {from: leftPos, to: range.from()};
|
4864 |
+
});
|
4865 |
+
},
|
4866 |
+
delWrappedLineRight: function(cm) {
|
4867 |
+
deleteNearSelection(cm, function(range) {
|
4868 |
+
var top = cm.charCoords(range.head, "div").top + 5;
|
4869 |
+
var rightPos = cm.coordsChar({left: cm.display.lineDiv.offsetWidth + 100, top: top}, "div");
|
4870 |
+
return {from: range.from(), to: rightPos };
|
4871 |
+
});
|
4872 |
+
},
|
4873 |
+
undo: function(cm) {cm.undo();},
|
4874 |
+
redo: function(cm) {cm.redo();},
|
4875 |
+
undoSelection: function(cm) {cm.undoSelection();},
|
4876 |
+
redoSelection: function(cm) {cm.redoSelection();},
|
4877 |
+
goDocStart: function(cm) {cm.extendSelection(Pos(cm.firstLine(), 0));},
|
4878 |
+
goDocEnd: function(cm) {cm.extendSelection(Pos(cm.lastLine()));},
|
4879 |
+
goLineStart: function(cm) {
|
4880 |
+
cm.extendSelectionsBy(function(range) { return lineStart(cm, range.head.line); },
|
4881 |
+
{origin: "+move", bias: 1});
|
4882 |
+
},
|
4883 |
+
goLineStartSmart: function(cm) {
|
4884 |
+
cm.extendSelectionsBy(function(range) {
|
4885 |
+
return lineStartSmart(cm, range.head);
|
4886 |
+
}, {origin: "+move", bias: 1});
|
4887 |
+
},
|
4888 |
+
goLineEnd: function(cm) {
|
4889 |
+
cm.extendSelectionsBy(function(range) { return lineEnd(cm, range.head.line); },
|
4890 |
+
{origin: "+move", bias: -1});
|
4891 |
+
},
|
4892 |
+
goLineRight: function(cm) {
|
4893 |
+
cm.extendSelectionsBy(function(range) {
|
4894 |
+
var top = cm.charCoords(range.head, "div").top + 5;
|
4895 |
+
return cm.coordsChar({left: cm.display.lineDiv.offsetWidth + 100, top: top}, "div");
|
4896 |
+
}, sel_move);
|
4897 |
+
},
|
4898 |
+
goLineLeft: function(cm) {
|
4899 |
+
cm.extendSelectionsBy(function(range) {
|
4900 |
+
var top = cm.charCoords(range.head, "div").top + 5;
|
4901 |
+
return cm.coordsChar({left: 0, top: top}, "div");
|
4902 |
+
}, sel_move);
|
4903 |
+
},
|
4904 |
+
goLineLeftSmart: function(cm) {
|
4905 |
+
cm.extendSelectionsBy(function(range) {
|
4906 |
+
var top = cm.charCoords(range.head, "div").top + 5;
|
4907 |
+
var pos = cm.coordsChar({left: 0, top: top}, "div");
|
4908 |
+
if (pos.ch < cm.getLine(pos.line).search(/\S/)) return lineStartSmart(cm, range.head);
|
4909 |
+
return pos;
|
4910 |
+
}, sel_move);
|
4911 |
+
},
|
4912 |
+
goLineUp: function(cm) {cm.moveV(-1, "line");},
|
4913 |
+
goLineDown: function(cm) {cm.moveV(1, "line");},
|
4914 |
+
goPageUp: function(cm) {cm.moveV(-1, "page");},
|
4915 |
+
goPageDown: function(cm) {cm.moveV(1, "page");},
|
4916 |
+
goCharLeft: function(cm) {cm.moveH(-1, "char");},
|
4917 |
+
goCharRight: function(cm) {cm.moveH(1, "char");},
|
4918 |
+
goColumnLeft: function(cm) {cm.moveH(-1, "column");},
|
4919 |
+
goColumnRight: function(cm) {cm.moveH(1, "column");},
|
4920 |
+
goWordLeft: function(cm) {cm.moveH(-1, "word");},
|
4921 |
+
goGroupRight: function(cm) {cm.moveH(1, "group");},
|
4922 |
+
goGroupLeft: function(cm) {cm.moveH(-1, "group");},
|
4923 |
+
goWordRight: function(cm) {cm.moveH(1, "word");},
|
4924 |
+
delCharBefore: function(cm) {cm.deleteH(-1, "char");},
|
4925 |
+
delCharAfter: function(cm) {cm.deleteH(1, "char");},
|
4926 |
+
delWordBefore: function(cm) {cm.deleteH(-1, "word");},
|
4927 |
+
delWordAfter: function(cm) {cm.deleteH(1, "word");},
|
4928 |
+
delGroupBefore: function(cm) {cm.deleteH(-1, "group");},
|
4929 |
+
delGroupAfter: function(cm) {cm.deleteH(1, "group");},
|
4930 |
+
indentAuto: function(cm) {cm.indentSelection("smart");},
|
4931 |
+
indentMore: function(cm) {cm.indentSelection("add");},
|
4932 |
+
indentLess: function(cm) {cm.indentSelection("subtract");},
|
4933 |
+
insertTab: function(cm) {cm.replaceSelection("\t");},
|
4934 |
+
insertSoftTab: function(cm) {
|
4935 |
+
var spaces = [], ranges = cm.listSelections(), tabSize = cm.options.tabSize;
|
4936 |
+
for (var i = 0; i < ranges.length; i++) {
|
4937 |
+
var pos = ranges[i].from();
|
4938 |
+
var col = countColumn(cm.getLine(pos.line), pos.ch, tabSize);
|
4939 |
+
spaces.push(new Array(tabSize - col % tabSize + 1).join(" "));
|
4940 |
+
}
|
4941 |
+
cm.replaceSelections(spaces);
|
4942 |
+
},
|
4943 |
+
defaultTab: function(cm) {
|
4944 |
+
if (cm.somethingSelected()) cm.indentSelection("add");
|
4945 |
+
else cm.execCommand("insertTab");
|
4946 |
+
},
|
4947 |
+
transposeChars: function(cm) {
|
4948 |
+
runInOp(cm, function() {
|
4949 |
+
var ranges = cm.listSelections(), newSel = [];
|
4950 |
+
for (var i = 0; i < ranges.length; i++) {
|
4951 |
+
var cur = ranges[i].head, line = getLine(cm.doc, cur.line).text;
|
4952 |
+
if (line) {
|
4953 |
+
if (cur.ch == line.length) cur = new Pos(cur.line, cur.ch - 1);
|
4954 |
+
if (cur.ch > 0) {
|
4955 |
+
cur = new Pos(cur.line, cur.ch + 1);
|
4956 |
+
cm.replaceRange(line.charAt(cur.ch - 1) + line.charAt(cur.ch - 2),
|
4957 |
+
Pos(cur.line, cur.ch - 2), cur, "+transpose");
|
4958 |
+
} else if (cur.line > cm.doc.first) {
|
4959 |
+
var prev = getLine(cm.doc, cur.line - 1).text;
|
4960 |
+
if (prev)
|
4961 |
+
cm.replaceRange(line.charAt(0) + "\n" + prev.charAt(prev.length - 1),
|
4962 |
+
Pos(cur.line - 1, prev.length - 1), Pos(cur.line, 1), "+transpose");
|
4963 |
+
}
|
4964 |
+
}
|
4965 |
+
newSel.push(new Range(cur, cur));
|
4966 |
+
}
|
4967 |
+
cm.setSelections(newSel);
|
4968 |
+
});
|
4969 |
+
},
|
4970 |
+
newlineAndIndent: function(cm) {
|
4971 |
+
runInOp(cm, function() {
|
4972 |
+
var len = cm.listSelections().length;
|
4973 |
+
for (var i = 0; i < len; i++) {
|
4974 |
+
var range = cm.listSelections()[i];
|
4975 |
+
cm.replaceRange("\n", range.anchor, range.head, "+input");
|
4976 |
+
cm.indentLine(range.from().line + 1, null, true);
|
4977 |
+
ensureCursorVisible(cm);
|
4978 |
+
}
|
4979 |
+
});
|
4980 |
+
},
|
4981 |
+
toggleOverwrite: function(cm) {cm.toggleOverwrite();}
|
4982 |
+
};
|
4983 |
+
|
4984 |
+
|
4985 |
+
// STANDARD KEYMAPS
|
4986 |
+
|
4987 |
+
var keyMap = CodeMirror.keyMap = {};
|
4988 |
+
|
4989 |
+
keyMap.basic = {
|
4990 |
+
"Left": "goCharLeft", "Right": "goCharRight", "Up": "goLineUp", "Down": "goLineDown",
|
4991 |
+
"End": "goLineEnd", "Home": "goLineStartSmart", "PageUp": "goPageUp", "PageDown": "goPageDown",
|
4992 |
+
"Delete": "delCharAfter", "Backspace": "delCharBefore", "Shift-Backspace": "delCharBefore",
|
4993 |
+
"Tab": "defaultTab", "Shift-Tab": "indentAuto",
|
4994 |
+
"Enter": "newlineAndIndent", "Insert": "toggleOverwrite",
|
4995 |
+
"Esc": "singleSelection"
|
4996 |
+
};
|
4997 |
+
// Note that the save and find-related commands aren't defined by
|
4998 |
+
// default. User code or addons can define them. Unknown commands
|
4999 |
+
// are simply ignored.
|
5000 |
+
keyMap.pcDefault = {
|
5001 |
+
"Ctrl-A": "selectAll", "Ctrl-D": "deleteLine", "Ctrl-Z": "undo", "Shift-Ctrl-Z": "redo", "Ctrl-Y": "redo",
|
5002 |
+
"Ctrl-Home": "goDocStart", "Ctrl-End": "goDocEnd", "Ctrl-Up": "goLineUp", "Ctrl-Down": "goLineDown",
|
5003 |
+
"Ctrl-Left": "goGroupLeft", "Ctrl-Right": "goGroupRight", "Alt-Left": "goLineStart", "Alt-Right": "goLineEnd",
|
5004 |
+
"Ctrl-Backspace": "delGroupBefore", "Ctrl-Delete": "delGroupAfter", "Ctrl-S": "save", "Ctrl-F": "find",
|
5005 |
+
"Ctrl-G": "findNext", "Shift-Ctrl-G": "findPrev", "Shift-Ctrl-F": "replace", "Shift-Ctrl-R": "replaceAll",
|
5006 |
+
"Ctrl-[": "indentLess", "Ctrl-]": "indentMore",
|
5007 |
+
"Ctrl-U": "undoSelection", "Shift-Ctrl-U": "redoSelection", "Alt-U": "redoSelection",
|
5008 |
+
fallthrough: "basic"
|
5009 |
+
};
|
5010 |
+
// Very basic readline/emacs-style bindings, which are standard on Mac.
|
5011 |
+
keyMap.emacsy = {
|
5012 |
+
"Ctrl-F": "goCharRight", "Ctrl-B": "goCharLeft", "Ctrl-P": "goLineUp", "Ctrl-N": "goLineDown",
|
5013 |
+
"Alt-F": "goWordRight", "Alt-B": "goWordLeft", "Ctrl-A": "goLineStart", "Ctrl-E": "goLineEnd",
|
5014 |
+
"Ctrl-V": "goPageDown", "Shift-Ctrl-V": "goPageUp", "Ctrl-D": "delCharAfter", "Ctrl-H": "delCharBefore",
|
5015 |
+
"Alt-D": "delWordAfter", "Alt-Backspace": "delWordBefore", "Ctrl-K": "killLine", "Ctrl-T": "transposeChars"
|
5016 |
+
};
|
5017 |
+
keyMap.macDefault = {
|
5018 |
+
"Cmd-A": "selectAll", "Cmd-D": "deleteLine", "Cmd-Z": "undo", "Shift-Cmd-Z": "redo", "Cmd-Y": "redo",
|
5019 |
+
"Cmd-Home": "goDocStart", "Cmd-Up": "goDocStart", "Cmd-End": "goDocEnd", "Cmd-Down": "goDocEnd", "Alt-Left": "goGroupLeft",
|
5020 |
+
"Alt-Right": "goGroupRight", "Cmd-Left": "goLineLeft", "Cmd-Right": "goLineRight", "Alt-Backspace": "delGroupBefore",
|
5021 |
+
"Ctrl-Alt-Backspace": "delGroupAfter", "Alt-Delete": "delGroupAfter", "Cmd-S": "save", "Cmd-F": "find",
|
5022 |
+
"Cmd-G": "findNext", "Shift-Cmd-G": "findPrev", "Cmd-Alt-F": "replace", "Shift-Cmd-Alt-F": "replaceAll",
|
5023 |
+
"Cmd-[": "indentLess", "Cmd-]": "indentMore", "Cmd-Backspace": "delWrappedLineLeft", "Cmd-Delete": "delWrappedLineRight",
|
5024 |
+
"Cmd-U": "undoSelection", "Shift-Cmd-U": "redoSelection", "Ctrl-Up": "goDocStart", "Ctrl-Down": "goDocEnd",
|
5025 |
+
fallthrough: ["basic", "emacsy"]
|
5026 |
+
};
|
5027 |
+
keyMap["default"] = mac ? keyMap.macDefault : keyMap.pcDefault;
|
5028 |
+
|
5029 |
+
// KEYMAP DISPATCH
|
5030 |
+
|
5031 |
+
function normalizeKeyName(name) {
|
5032 |
+
var parts = name.split(/-(?!$)/), name = parts[parts.length - 1];
|
5033 |
+
var alt, ctrl, shift, cmd;
|
5034 |
+
for (var i = 0; i < parts.length - 1; i++) {
|
5035 |
+
var mod = parts[i];
|
5036 |
+
if (/^(cmd|meta|m)$/i.test(mod)) cmd = true;
|
5037 |
+
else if (/^a(lt)?$/i.test(mod)) alt = true;
|
5038 |
+
else if (/^(c|ctrl|control)$/i.test(mod)) ctrl = true;
|
5039 |
+
else if (/^s(hift)$/i.test(mod)) shift = true;
|
5040 |
+
else throw new Error("Unrecognized modifier name: " + mod);
|
5041 |
+
}
|
5042 |
+
if (alt) name = "Alt-" + name;
|
5043 |
+
if (ctrl) name = "Ctrl-" + name;
|
5044 |
+
if (cmd) name = "Cmd-" + name;
|
5045 |
+
if (shift) name = "Shift-" + name;
|
5046 |
+
return name;
|
5047 |
+
}
|
5048 |
+
|
5049 |
+
// This is a kludge to keep keymaps mostly working as raw objects
|
5050 |
+
// (backwards compatibility) while at the same time support features
|
5051 |
+
// like normalization and multi-stroke key bindings. It compiles a
|
5052 |
+
// new normalized keymap, and then updates the old object to reflect
|
5053 |
+
// this.
|
5054 |
+
CodeMirror.normalizeKeyMap = function(keymap) {
|
5055 |
+
var copy = {};
|
5056 |
+
for (var keyname in keymap) if (keymap.hasOwnProperty(keyname)) {
|
5057 |
+
var value = keymap[keyname];
|
5058 |
+
if (/^(name|fallthrough|(de|at)tach)$/.test(keyname)) continue;
|
5059 |
+
if (value == "...") { delete keymap[keyname]; continue; }
|
5060 |
+
|
5061 |
+
var keys = map(keyname.split(" "), normalizeKeyName);
|
5062 |
+
for (var i = 0; i < keys.length; i++) {
|
5063 |
+
var val, name;
|
5064 |
+
if (i == keys.length - 1) {
|
5065 |
+
name = keyname;
|
5066 |
+
val = value;
|
5067 |
+
} else {
|
5068 |
+
name = keys.slice(0, i + 1).join(" ");
|
5069 |
+
val = "...";
|
5070 |
+
}
|
5071 |
+
var prev = copy[name];
|
5072 |
+
if (!prev) copy[name] = val;
|
5073 |
+
else if (prev != val) throw new Error("Inconsistent bindings for " + name);
|
5074 |
+
}
|
5075 |
+
delete keymap[keyname];
|
5076 |
+
}
|
5077 |
+
for (var prop in copy) keymap[prop] = copy[prop];
|
5078 |
+
return keymap;
|
5079 |
+
};
|
5080 |
+
|
5081 |
+
var lookupKey = CodeMirror.lookupKey = function(key, map, handle, context) {
|
5082 |
+
map = getKeyMap(map);
|
5083 |
+
var found = map.call ? map.call(key, context) : map[key];
|
5084 |
+
if (found === false) return "nothing";
|
5085 |
+
if (found === "...") return "multi";
|
5086 |
+
if (found != null && handle(found)) return "handled";
|
5087 |
+
|
5088 |
+
if (map.fallthrough) {
|
5089 |
+
if (Object.prototype.toString.call(map.fallthrough) != "[object Array]")
|
5090 |
+
return lookupKey(key, map.fallthrough, handle, context);
|
5091 |
+
for (var i = 0; i < map.fallthrough.length; i++) {
|
5092 |
+
var result = lookupKey(key, map.fallthrough[i], handle, context);
|
5093 |
+
if (result) return result;
|
5094 |
+
}
|
5095 |
+
}
|
5096 |
+
};
|
5097 |
+
|
5098 |
+
// Modifier key presses don't count as 'real' key presses for the
|
5099 |
+
// purpose of keymap fallthrough.
|
5100 |
+
var isModifierKey = CodeMirror.isModifierKey = function(value) {
|
5101 |
+
var name = typeof value == "string" ? value : keyNames[value.keyCode];
|
5102 |
+
return name == "Ctrl" || name == "Alt" || name == "Shift" || name == "Mod";
|
5103 |
+
};
|
5104 |
+
|
5105 |
+
// Look up the name of a key as indicated by an event object.
|
5106 |
+
var keyName = CodeMirror.keyName = function(event, noShift) {
|
5107 |
+
if (presto && event.keyCode == 34 && event["char"]) return false;
|
5108 |
+
var base = keyNames[event.keyCode], name = base;
|
5109 |
+
if (name == null || event.altGraphKey) return false;
|
5110 |
+
if (event.altKey && base != "Alt") name = "Alt-" + name;
|
5111 |
+
if ((flipCtrlCmd ? event.metaKey : event.ctrlKey) && base != "Ctrl") name = "Ctrl-" + name;
|
5112 |
+
if ((flipCtrlCmd ? event.ctrlKey : event.metaKey) && base != "Cmd") name = "Cmd-" + name;
|
5113 |
+
if (!noShift && event.shiftKey && base != "Shift") name = "Shift-" + name;
|
5114 |
+
return name;
|
5115 |
+
};
|
5116 |
+
|
5117 |
+
function getKeyMap(val) {
|
5118 |
+
return typeof val == "string" ? keyMap[val] : val;
|
5119 |
+
}
|
5120 |
+
|
5121 |
+
// FROMTEXTAREA
|
5122 |
+
|
5123 |
+
CodeMirror.fromTextArea = function(textarea, options) {
|
5124 |
+
if (!options) options = {};
|
5125 |
+
options.value = textarea.value;
|
5126 |
+
if (!options.tabindex && textarea.tabindex)
|
5127 |
+
options.tabindex = textarea.tabindex;
|
5128 |
+
if (!options.placeholder && textarea.placeholder)
|
5129 |
+
options.placeholder = textarea.placeholder;
|
5130 |
+
// Set autofocus to true if this textarea is focused, or if it has
|
5131 |
+
// autofocus and no other element is focused.
|
5132 |
+
if (options.autofocus == null) {
|
5133 |
+
var hasFocus = activeElt();
|
5134 |
+
options.autofocus = hasFocus == textarea ||
|
5135 |
+
textarea.getAttribute("autofocus") != null && hasFocus == document.body;
|
5136 |
+
}
|
5137 |
+
|
5138 |
+
function save() {textarea.value = cm.getValue();}
|
5139 |
+
if (textarea.form) {
|
5140 |
+
on(textarea.form, "submit", save);
|
5141 |
+
// Deplorable hack to make the submit method do the right thing.
|
5142 |
+
if (!options.leaveSubmitMethodAlone) {
|
5143 |
+
var form = textarea.form, realSubmit = form.submit;
|
5144 |
+
try {
|
5145 |
+
var wrappedSubmit = form.submit = function() {
|
5146 |
+
save();
|
5147 |
+
form.submit = realSubmit;
|
5148 |
+
form.submit();
|
5149 |
+
form.submit = wrappedSubmit;
|
5150 |
+
};
|
5151 |
+
} catch(e) {}
|
5152 |
+
}
|
5153 |
+
}
|
5154 |
+
|
5155 |
+
textarea.style.display = "none";
|
5156 |
+
var cm = CodeMirror(function(node) {
|
5157 |
+
textarea.parentNode.insertBefore(node, textarea.nextSibling);
|
5158 |
+
}, options);
|
5159 |
+
cm.save = save;
|
5160 |
+
cm.getTextArea = function() { return textarea; };
|
5161 |
+
cm.toTextArea = function() {
|
5162 |
+
cm.toTextArea = isNaN; // Prevent this from being ran twice
|
5163 |
+
save();
|
5164 |
+
textarea.parentNode.removeChild(cm.getWrapperElement());
|
5165 |
+
textarea.style.display = "";
|
5166 |
+
if (textarea.form) {
|
5167 |
+
off(textarea.form, "submit", save);
|
5168 |
+
if (typeof textarea.form.submit == "function")
|
5169 |
+
textarea.form.submit = realSubmit;
|
5170 |
+
}
|
5171 |
+
};
|
5172 |
+
return cm;
|
5173 |
+
};
|
5174 |
+
|
5175 |
+
// STRING STREAM
|
5176 |
+
|
5177 |
+
// Fed to the mode parsers, provides helper functions to make
|
5178 |
+
// parsers more succinct.
|
5179 |
+
|
5180 |
+
var StringStream = CodeMirror.StringStream = function(string, tabSize) {
|
5181 |
+
this.pos = this.start = 0;
|
5182 |
+
this.string = string;
|
5183 |
+
this.tabSize = tabSize || 8;
|
5184 |
+
this.lastColumnPos = this.lastColumnValue = 0;
|
5185 |
+
this.lineStart = 0;
|
5186 |
+
};
|
5187 |
+
|
5188 |
+
StringStream.prototype = {
|
5189 |
+
eol: function() {return this.pos >= this.string.length;},
|
5190 |
+
sol: function() {return this.pos == this.lineStart;},
|
5191 |
+
peek: function() {return this.string.charAt(this.pos) || undefined;},
|
5192 |
+
next: function() {
|
5193 |
+
if (this.pos < this.string.length)
|
5194 |
+
return this.string.charAt(this.pos++);
|
5195 |
+
},
|
5196 |
+
eat: function(match) {
|
5197 |
+
var ch = this.string.charAt(this.pos);
|
5198 |
+
if (typeof match == "string") var ok = ch == match;
|
5199 |
+
else var ok = ch && (match.test ? match.test(ch) : match(ch));
|
5200 |
+
if (ok) {++this.pos; return ch;}
|
5201 |
+
},
|
5202 |
+
eatWhile: function(match) {
|
5203 |
+
var start = this.pos;
|
5204 |
+
while (this.eat(match)){}
|
5205 |
+
return this.pos > start;
|
5206 |
+
},
|
5207 |
+
eatSpace: function() {
|
5208 |
+
var start = this.pos;
|
5209 |
+
while (/[\s\u00a0]/.test(this.string.charAt(this.pos))) ++this.pos;
|
5210 |
+
return this.pos > start;
|
5211 |
+
},
|
5212 |
+
skipToEnd: function() {this.pos = this.string.length;},
|
5213 |
+
skipTo: function(ch) {
|
5214 |
+
var found = this.string.indexOf(ch, this.pos);
|
5215 |
+
if (found > -1) {this.pos = found; return true;}
|
5216 |
+
},
|
5217 |
+
backUp: function(n) {this.pos -= n;},
|
5218 |
+
column: function() {
|
5219 |
+
if (this.lastColumnPos < this.start) {
|
5220 |
+
this.lastColumnValue = countColumn(this.string, this.start, this.tabSize, this.lastColumnPos, this.lastColumnValue);
|
5221 |
+
this.lastColumnPos = this.start;
|
5222 |
+
}
|
5223 |
+
return this.lastColumnValue - (this.lineStart ? countColumn(this.string, this.lineStart, this.tabSize) : 0);
|
5224 |
+
},
|
5225 |
+
indentation: function() {
|
5226 |
+
return countColumn(this.string, null, this.tabSize) -
|
5227 |
+
(this.lineStart ? countColumn(this.string, this.lineStart, this.tabSize) : 0);
|
5228 |
+
},
|
5229 |
+
match: function(pattern, consume, caseInsensitive) {
|
5230 |
+
if (typeof pattern == "string") {
|
5231 |
+
var cased = function(str) {return caseInsensitive ? str.toLowerCase() : str;};
|
5232 |
+
var substr = this.string.substr(this.pos, pattern.length);
|
5233 |
+
if (cased(substr) == cased(pattern)) {
|
5234 |
+
if (consume !== false) this.pos += pattern.length;
|
5235 |
+
return true;
|
5236 |
+
}
|
5237 |
+
} else {
|
5238 |
+
var match = this.string.slice(this.pos).match(pattern);
|
5239 |
+
if (match && match.index > 0) return null;
|
5240 |
+
if (match && consume !== false) this.pos += match[0].length;
|
5241 |
+
return match;
|
5242 |
+
}
|
5243 |
+
},
|
5244 |
+
current: function(){return this.string.slice(this.start, this.pos);},
|
5245 |
+
hideFirstChars: function(n, inner) {
|
5246 |
+
this.lineStart += n;
|
5247 |
+
try { return inner(); }
|
5248 |
+
finally { this.lineStart -= n; }
|
5249 |
+
}
|
5250 |
+
};
|
5251 |
+
|
5252 |
+
// TEXTMARKERS
|
5253 |
+
|
5254 |
+
// Created with markText and setBookmark methods. A TextMarker is a
|
5255 |
+
// handle that can be used to clear or find a marked position in the
|
5256 |
+
// document. Line objects hold arrays (markedSpans) containing
|
5257 |
+
// {from, to, marker} object pointing to such marker objects, and
|
5258 |
+
// indicating that such a marker is present on that line. Multiple
|
5259 |
+
// lines may point to the same marker when it spans across lines.
|
5260 |
+
// The spans will have null for their from/to properties when the
|
5261 |
+
// marker continues beyond the start/end of the line. Markers have
|
5262 |
+
// links back to the lines they currently touch.
|
5263 |
+
|
5264 |
+
var TextMarker = CodeMirror.TextMarker = function(doc, type) {
|
5265 |
+
this.lines = [];
|
5266 |
+
this.type = type;
|
5267 |
+
this.doc = doc;
|
5268 |
+
};
|
5269 |
+
eventMixin(TextMarker);
|
5270 |
+
|
5271 |
+
// Clear the marker.
|
5272 |
+
TextMarker.prototype.clear = function() {
|
5273 |
+
if (this.explicitlyCleared) return;
|
5274 |
+
var cm = this.doc.cm, withOp = cm && !cm.curOp;
|
5275 |
+
if (withOp) startOperation(cm);
|
5276 |
+
if (hasHandler(this, "clear")) {
|
5277 |
+
var found = this.find();
|
5278 |
+
if (found) signalLater(this, "clear", found.from, found.to);
|
5279 |
+
}
|
5280 |
+
var min = null, max = null;
|
5281 |
+
for (var i = 0; i < this.lines.length; ++i) {
|
5282 |
+
var line = this.lines[i];
|
5283 |
+
var span = getMarkedSpanFor(line.markedSpans, this);
|
5284 |
+
if (cm && !this.collapsed) regLineChange(cm, lineNo(line), "text");
|
5285 |
+
else if (cm) {
|
5286 |
+
if (span.to != null) max = lineNo(line);
|
5287 |
+
if (span.from != null) min = lineNo(line);
|
5288 |
+
}
|
5289 |
+
line.markedSpans = removeMarkedSpan(line.markedSpans, span);
|
5290 |
+
if (span.from == null && this.collapsed && !lineIsHidden(this.doc, line) && cm)
|
5291 |
+
updateLineHeight(line, textHeight(cm.display));
|
5292 |
+
}
|
5293 |
+
if (cm && this.collapsed && !cm.options.lineWrapping) for (var i = 0; i < this.lines.length; ++i) {
|
5294 |
+
var visual = visualLine(this.lines[i]), len = lineLength(visual);
|
5295 |
+
if (len > cm.display.maxLineLength) {
|
5296 |
+
cm.display.maxLine = visual;
|
5297 |
+
cm.display.maxLineLength = len;
|
5298 |
+
cm.display.maxLineChanged = true;
|
5299 |
+
}
|
5300 |
+
}
|
5301 |
+
|
5302 |
+
if (min != null && cm && this.collapsed) regChange(cm, min, max + 1);
|
5303 |
+
this.lines.length = 0;
|
5304 |
+
this.explicitlyCleared = true;
|
5305 |
+
if (this.atomic && this.doc.cantEdit) {
|
5306 |
+
this.doc.cantEdit = false;
|
5307 |
+
if (cm) reCheckSelection(cm.doc);
|
5308 |
+
}
|
5309 |
+
if (cm) signalLater(cm, "markerCleared", cm, this);
|
5310 |
+
if (withOp) endOperation(cm);
|
5311 |
+
if (this.parent) this.parent.clear();
|
5312 |
+
};
|
5313 |
+
|
5314 |
+
// Find the position of the marker in the document. Returns a {from,
|
5315 |
+
// to} object by default. Side can be passed to get a specific side
|
5316 |
+
// -- 0 (both), -1 (left), or 1 (right). When lineObj is true, the
|
5317 |
+
// Pos objects returned contain a line object, rather than a line
|
5318 |
+
// number (used to prevent looking up the same line twice).
|
5319 |
+
TextMarker.prototype.find = function(side, lineObj) {
|
5320 |
+
if (side == null && this.type == "bookmark") side = 1;
|
5321 |
+
var from, to;
|
5322 |
+
for (var i = 0; i < this.lines.length; ++i) {
|
5323 |
+
var line = this.lines[i];
|
5324 |
+
var span = getMarkedSpanFor(line.markedSpans, this);
|
5325 |
+
if (span.from != null) {
|
5326 |
+
from = Pos(lineObj ? line : lineNo(line), span.from);
|
5327 |
+
if (side == -1) return from;
|
5328 |
+
}
|
5329 |
+
if (span.to != null) {
|
5330 |
+
to = Pos(lineObj ? line : lineNo(line), span.to);
|
5331 |
+
if (side == 1) return to;
|
5332 |
+
}
|
5333 |
+
}
|
5334 |
+
return from && {from: from, to: to};
|
5335 |
+
};
|
5336 |
+
|
5337 |
+
// Signals that the marker's widget changed, and surrounding layout
|
5338 |
+
// should be recomputed.
|
5339 |
+
TextMarker.prototype.changed = function() {
|
5340 |
+
var pos = this.find(-1, true), widget = this, cm = this.doc.cm;
|
5341 |
+
if (!pos || !cm) return;
|
5342 |
+
runInOp(cm, function() {
|
5343 |
+
var line = pos.line, lineN = lineNo(pos.line);
|
5344 |
+
var view = findViewForLine(cm, lineN);
|
5345 |
+
if (view) {
|
5346 |
+
clearLineMeasurementCacheFor(view);
|
5347 |
+
cm.curOp.selectionChanged = cm.curOp.forceUpdate = true;
|
5348 |
+
}
|
5349 |
+
cm.curOp.updateMaxLine = true;
|
5350 |
+
if (!lineIsHidden(widget.doc, line) && widget.height != null) {
|
5351 |
+
var oldHeight = widget.height;
|
5352 |
+
widget.height = null;
|
5353 |
+
var dHeight = widgetHeight(widget) - oldHeight;
|
5354 |
+
if (dHeight)
|
5355 |
+
updateLineHeight(line, line.height + dHeight);
|
5356 |
+
}
|
5357 |
+
});
|
5358 |
+
};
|
5359 |
+
|
5360 |
+
TextMarker.prototype.attachLine = function(line) {
|
5361 |
+
if (!this.lines.length && this.doc.cm) {
|
5362 |
+
var op = this.doc.cm.curOp;
|
5363 |
+
if (!op.maybeHiddenMarkers || indexOf(op.maybeHiddenMarkers, this) == -1)
|
5364 |
+
(op.maybeUnhiddenMarkers || (op.maybeUnhiddenMarkers = [])).push(this);
|
5365 |
+
}
|
5366 |
+
this.lines.push(line);
|
5367 |
+
};
|
5368 |
+
TextMarker.prototype.detachLine = function(line) {
|
5369 |
+
this.lines.splice(indexOf(this.lines, line), 1);
|
5370 |
+
if (!this.lines.length && this.doc.cm) {
|
5371 |
+
var op = this.doc.cm.curOp;
|
5372 |
+
(op.maybeHiddenMarkers || (op.maybeHiddenMarkers = [])).push(this);
|
5373 |
+
}
|
5374 |
+
};
|
5375 |
+
|
5376 |
+
// Collapsed markers have unique ids, in order to be able to order
|
5377 |
+
// them, which is needed for uniquely determining an outer marker
|
5378 |
+
// when they overlap (they may nest, but not partially overlap).
|
5379 |
+
var nextMarkerId = 0;
|
5380 |
+
|
5381 |
+
// Create a marker, wire it up to the right lines, and
|
5382 |
+
function markText(doc, from, to, options, type) {
|
5383 |
+
// Shared markers (across linked documents) are handled separately
|
5384 |
+
// (markTextShared will call out to this again, once per
|
5385 |
+
// document).
|
5386 |
+
if (options && options.shared) return markTextShared(doc, from, to, options, type);
|
5387 |
+
// Ensure we are in an operation.
|
5388 |
+
if (doc.cm && !doc.cm.curOp) return operation(doc.cm, markText)(doc, from, to, options, type);
|
5389 |
+
|
5390 |
+
var marker = new TextMarker(doc, type), diff = cmp(from, to);
|
5391 |
+
if (options) copyObj(options, marker, false);
|
5392 |
+
// Don't connect empty markers unless clearWhenEmpty is false
|
5393 |
+
if (diff > 0 || diff == 0 && marker.clearWhenEmpty !== false)
|
5394 |
+
return marker;
|
5395 |
+
if (marker.replacedWith) {
|
5396 |
+
// Showing up as a widget implies collapsed (widget replaces text)
|
5397 |
+
marker.collapsed = true;
|
5398 |
+
marker.widgetNode = elt("span", [marker.replacedWith], "CodeMirror-widget");
|
5399 |
+
if (!options.handleMouseEvents) marker.widgetNode.setAttribute("cm-ignore-events", "true");
|
5400 |
+
if (options.insertLeft) marker.widgetNode.insertLeft = true;
|
5401 |
+
}
|
5402 |
+
if (marker.collapsed) {
|
5403 |
+
if (conflictingCollapsedRange(doc, from.line, from, to, marker) ||
|
5404 |
+
from.line != to.line && conflictingCollapsedRange(doc, to.line, from, to, marker))
|
5405 |
+
throw new Error("Inserting collapsed marker partially overlapping an existing one");
|
5406 |
+
sawCollapsedSpans = true;
|
5407 |
+
}
|
5408 |
+
|
5409 |
+
if (marker.addToHistory)
|
5410 |
+
addChangeToHistory(doc, {from: from, to: to, origin: "markText"}, doc.sel, NaN);
|
5411 |
+
|
5412 |
+
var curLine = from.line, cm = doc.cm, updateMaxLine;
|
5413 |
+
doc.iter(curLine, to.line + 1, function(line) {
|
5414 |
+
if (cm && marker.collapsed && !cm.options.lineWrapping && visualLine(line) == cm.display.maxLine)
|
5415 |
+
updateMaxLine = true;
|
5416 |
+
if (marker.collapsed && curLine != from.line) updateLineHeight(line, 0);
|
5417 |
+
addMarkedSpan(line, new MarkedSpan(marker,
|
5418 |
+
curLine == from.line ? from.ch : null,
|
5419 |
+
curLine == to.line ? to.ch : null));
|
5420 |
+
++curLine;
|
5421 |
+
});
|
5422 |
+
// lineIsHidden depends on the presence of the spans, so needs a second pass
|
5423 |
+
if (marker.collapsed) doc.iter(from.line, to.line + 1, function(line) {
|
5424 |
+
if (lineIsHidden(doc, line)) updateLineHeight(line, 0);
|
5425 |
+
});
|
5426 |
+
|
5427 |
+
if (marker.clearOnEnter) on(marker, "beforeCursorEnter", function() { marker.clear(); });
|
5428 |
+
|
5429 |
+
if (marker.readOnly) {
|
5430 |
+
sawReadOnlySpans = true;
|
5431 |
+
if (doc.history.done.length || doc.history.undone.length)
|
5432 |
+
doc.clearHistory();
|
5433 |
+
}
|
5434 |
+
if (marker.collapsed) {
|
5435 |
+
marker.id = ++nextMarkerId;
|
5436 |
+
marker.atomic = true;
|
5437 |
+
}
|
5438 |
+
if (cm) {
|
5439 |
+
// Sync editor state
|
5440 |
+
if (updateMaxLine) cm.curOp.updateMaxLine = true;
|
5441 |
+
if (marker.collapsed)
|
5442 |
+
regChange(cm, from.line, to.line + 1);
|
5443 |
+
else if (marker.className || marker.title || marker.startStyle || marker.endStyle || marker.css)
|
5444 |
+
for (var i = from.line; i <= to.line; i++) regLineChange(cm, i, "text");
|
5445 |
+
if (marker.atomic) reCheckSelection(cm.doc);
|
5446 |
+
signalLater(cm, "markerAdded", cm, marker);
|
5447 |
+
}
|
5448 |
+
return marker;
|
5449 |
+
}
|
5450 |
+
|
5451 |
+
// SHARED TEXTMARKERS
|
5452 |
+
|
5453 |
+
// A shared marker spans multiple linked documents. It is
|
5454 |
+
// implemented as a meta-marker-object controlling multiple normal
|
5455 |
+
// markers.
|
5456 |
+
var SharedTextMarker = CodeMirror.SharedTextMarker = function(markers, primary) {
|
5457 |
+
this.markers = markers;
|
5458 |
+
this.primary = primary;
|
5459 |
+
for (var i = 0; i < markers.length; ++i)
|
5460 |
+
markers[i].parent = this;
|
5461 |
+
};
|
5462 |
+
eventMixin(SharedTextMarker);
|
5463 |
+
|
5464 |
+
SharedTextMarker.prototype.clear = function() {
|
5465 |
+
if (this.explicitlyCleared) return;
|
5466 |
+
this.explicitlyCleared = true;
|
5467 |
+
for (var i = 0; i < this.markers.length; ++i)
|
5468 |
+
this.markers[i].clear();
|
5469 |
+
signalLater(this, "clear");
|
5470 |
+
};
|
5471 |
+
SharedTextMarker.prototype.find = function(side, lineObj) {
|
5472 |
+
return this.primary.find(side, lineObj);
|
5473 |
+
};
|
5474 |
+
|
5475 |
+
function markTextShared(doc, from, to, options, type) {
|
5476 |
+
options = copyObj(options);
|
5477 |
+
options.shared = false;
|
5478 |
+
var markers = [markText(doc, from, to, options, type)], primary = markers[0];
|
5479 |
+
var widget = options.widgetNode;
|
5480 |
+
linkedDocs(doc, function(doc) {
|
5481 |
+
if (widget) options.widgetNode = widget.cloneNode(true);
|
5482 |
+
markers.push(markText(doc, clipPos(doc, from), clipPos(doc, to), options, type));
|
5483 |
+
for (var i = 0; i < doc.linked.length; ++i)
|
5484 |
+
if (doc.linked[i].isParent) return;
|
5485 |
+
primary = lst(markers);
|
5486 |
+
});
|
5487 |
+
return new SharedTextMarker(markers, primary);
|
5488 |
+
}
|
5489 |
+
|
5490 |
+
function findSharedMarkers(doc) {
|
5491 |
+
return doc.findMarks(Pos(doc.first, 0), doc.clipPos(Pos(doc.lastLine())),
|
5492 |
+
function(m) { return m.parent; });
|
5493 |
+
}
|
5494 |
+
|
5495 |
+
function copySharedMarkers(doc, markers) {
|
5496 |
+
for (var i = 0; i < markers.length; i++) {
|
5497 |
+
var marker = markers[i], pos = marker.find();
|
5498 |
+
var mFrom = doc.clipPos(pos.from), mTo = doc.clipPos(pos.to);
|
5499 |
+
if (cmp(mFrom, mTo)) {
|
5500 |
+
var subMark = markText(doc, mFrom, mTo, marker.primary, marker.primary.type);
|
5501 |
+
marker.markers.push(subMark);
|
5502 |
+
subMark.parent = marker;
|
5503 |
+
}
|
5504 |
+
}
|
5505 |
+
}
|
5506 |
+
|
5507 |
+
function detachSharedMarkers(markers) {
|
5508 |
+
for (var i = 0; i < markers.length; i++) {
|
5509 |
+
var marker = markers[i], linked = [marker.primary.doc];;
|
5510 |
+
linkedDocs(marker.primary.doc, function(d) { linked.push(d); });
|
5511 |
+
for (var j = 0; j < marker.markers.length; j++) {
|
5512 |
+
var subMarker = marker.markers[j];
|
5513 |
+
if (indexOf(linked, subMarker.doc) == -1) {
|
5514 |
+
subMarker.parent = null;
|
5515 |
+
marker.markers.splice(j--, 1);
|
5516 |
+
}
|
5517 |
+
}
|
5518 |
+
}
|
5519 |
+
}
|
5520 |
+
|
5521 |
+
// TEXTMARKER SPANS
|
5522 |
+
|
5523 |
+
function MarkedSpan(marker, from, to) {
|
5524 |
+
this.marker = marker;
|
5525 |
+
this.from = from; this.to = to;
|
5526 |
+
}
|
5527 |
+
|
5528 |
+
// Search an array of spans for a span matching the given marker.
|
5529 |
+
function getMarkedSpanFor(spans, marker) {
|
5530 |
+
if (spans) for (var i = 0; i < spans.length; ++i) {
|
5531 |
+
var span = spans[i];
|
5532 |
+
if (span.marker == marker) return span;
|
5533 |
+
}
|
5534 |
+
}
|
5535 |
+
// Remove a span from an array, returning undefined if no spans are
|
5536 |
+
// left (we don't store arrays for lines without spans).
|
5537 |
+
function removeMarkedSpan(spans, span) {
|
5538 |
+
for (var r, i = 0; i < spans.length; ++i)
|
5539 |
+
if (spans[i] != span) (r || (r = [])).push(spans[i]);
|
5540 |
+
return r;
|
5541 |
+
}
|
5542 |
+
// Add a span to a line.
|
5543 |
+
function addMarkedSpan(line, span) {
|
5544 |
+
line.markedSpans = line.markedSpans ? line.markedSpans.concat([span]) : [span];
|
5545 |
+
span.marker.attachLine(line);
|
5546 |
+
}
|
5547 |
+
|
5548 |
+
// Used for the algorithm that adjusts markers for a change in the
|
5549 |
+
// document. These functions cut an array of spans at a given
|
5550 |
+
// character position, returning an array of remaining chunks (or
|
5551 |
+
// undefined if nothing remains).
|
5552 |
+
function markedSpansBefore(old, startCh, isInsert) {
|
5553 |
+
if (old) for (var i = 0, nw; i < old.length; ++i) {
|
5554 |
+
var span = old[i], marker = span.marker;
|
5555 |
+
var startsBefore = span.from == null || (marker.inclusiveLeft ? span.from <= startCh : span.from < startCh);
|
5556 |
+
if (startsBefore || span.from == startCh && marker.type == "bookmark" && (!isInsert || !span.marker.insertLeft)) {
|
5557 |
+
var endsAfter = span.to == null || (marker.inclusiveRight ? span.to >= startCh : span.to > startCh);
|
5558 |
+
(nw || (nw = [])).push(new MarkedSpan(marker, span.from, endsAfter ? null : span.to));
|
5559 |
+
}
|
5560 |
+
}
|
5561 |
+
return nw;
|
5562 |
+
}
|
5563 |
+
function markedSpansAfter(old, endCh, isInsert) {
|
5564 |
+
if (old) for (var i = 0, nw; i < old.length; ++i) {
|
5565 |
+
var span = old[i], marker = span.marker;
|
5566 |
+
var endsAfter = span.to == null || (marker.inclusiveRight ? span.to >= endCh : span.to > endCh);
|
5567 |
+
if (endsAfter || span.from == endCh && marker.type == "bookmark" && (!isInsert || span.marker.insertLeft)) {
|
5568 |
+
var startsBefore = span.from == null || (marker.inclusiveLeft ? span.from <= endCh : span.from < endCh);
|
5569 |
+
(nw || (nw = [])).push(new MarkedSpan(marker, startsBefore ? null : span.from - endCh,
|
5570 |
+
span.to == null ? null : span.to - endCh));
|
5571 |
+
}
|
5572 |
+
}
|
5573 |
+
return nw;
|
5574 |
+
}
|
5575 |
+
|
5576 |
+
// Given a change object, compute the new set of marker spans that
|
5577 |
+
// cover the line in which the change took place. Removes spans
|
5578 |
+
// entirely within the change, reconnects spans belonging to the
|
5579 |
+
// same marker that appear on both sides of the change, and cuts off
|
5580 |
+
// spans partially within the change. Returns an array of span
|
5581 |
+
// arrays with one element for each line in (after) the change.
|
5582 |
+
function stretchSpansOverChange(doc, change) {
|
5583 |
+
if (change.full) return null;
|
5584 |
+
var oldFirst = isLine(doc, change.from.line) && getLine(doc, change.from.line).markedSpans;
|
5585 |
+
var oldLast = isLine(doc, change.to.line) && getLine(doc, change.to.line).markedSpans;
|
5586 |
+
if (!oldFirst && !oldLast) return null;
|
5587 |
+
|
5588 |
+
var startCh = change.from.ch, endCh = change.to.ch, isInsert = cmp(change.from, change.to) == 0;
|
5589 |
+
// Get the spans that 'stick out' on both sides
|
5590 |
+
var first = markedSpansBefore(oldFirst, startCh, isInsert);
|
5591 |
+
var last = markedSpansAfter(oldLast, endCh, isInsert);
|
5592 |
+
|
5593 |
+
// Next, merge those two ends
|
5594 |
+
var sameLine = change.text.length == 1, offset = lst(change.text).length + (sameLine ? startCh : 0);
|
5595 |
+
if (first) {
|
5596 |
+
// Fix up .to properties of first
|
5597 |
+
for (var i = 0; i < first.length; ++i) {
|
5598 |
+
var span = first[i];
|
5599 |
+
if (span.to == null) {
|
5600 |
+
var found = getMarkedSpanFor(last, span.marker);
|
5601 |
+
if (!found) span.to = startCh;
|
5602 |
+
else if (sameLine) span.to = found.to == null ? null : found.to + offset;
|
5603 |
+
}
|
5604 |
+
}
|
5605 |
+
}
|
5606 |
+
if (last) {
|
5607 |
+
// Fix up .from in last (or move them into first in case of sameLine)
|
5608 |
+
for (var i = 0; i < last.length; ++i) {
|
5609 |
+
var span = last[i];
|
5610 |
+
if (span.to != null) span.to += offset;
|
5611 |
+
if (span.from == null) {
|
5612 |
+
var found = getMarkedSpanFor(first, span.marker);
|
5613 |
+
if (!found) {
|
5614 |
+
span.from = offset;
|
5615 |
+
if (sameLine) (first || (first = [])).push(span);
|
5616 |
+
}
|
5617 |
+
} else {
|
5618 |
+
span.from += offset;
|
5619 |
+
if (sameLine) (first || (first = [])).push(span);
|
5620 |
+
}
|
5621 |
+
}
|
5622 |
+
}
|
5623 |
+
// Make sure we didn't create any zero-length spans
|
5624 |
+
if (first) first = clearEmptySpans(first);
|
5625 |
+
if (last && last != first) last = clearEmptySpans(last);
|
5626 |
+
|
5627 |
+
var newMarkers = [first];
|
5628 |
+
if (!sameLine) {
|
5629 |
+
// Fill gap with whole-line-spans
|
5630 |
+
var gap = change.text.length - 2, gapMarkers;
|
5631 |
+
if (gap > 0 && first)
|
5632 |
+
for (var i = 0; i < first.length; ++i)
|
5633 |
+
if (first[i].to == null)
|
5634 |
+
(gapMarkers || (gapMarkers = [])).push(new MarkedSpan(first[i].marker, null, null));
|
5635 |
+
for (var i = 0; i < gap; ++i)
|
5636 |
+
newMarkers.push(gapMarkers);
|
5637 |
+
newMarkers.push(last);
|
5638 |
+
}
|
5639 |
+
return newMarkers;
|
5640 |
+
}
|
5641 |
+
|
5642 |
+
// Remove spans that are empty and don't have a clearWhenEmpty
|
5643 |
+
// option of false.
|
5644 |
+
function clearEmptySpans(spans) {
|
5645 |
+
for (var i = 0; i < spans.length; ++i) {
|
5646 |
+
var span = spans[i];
|
5647 |
+
if (span.from != null && span.from == span.to && span.marker.clearWhenEmpty !== false)
|
5648 |
+
spans.splice(i--, 1);
|
5649 |
+
}
|
5650 |
+
if (!spans.length) return null;
|
5651 |
+
return spans;
|
5652 |
+
}
|
5653 |
+
|
5654 |
+
// Used for un/re-doing changes from the history. Combines the
|
5655 |
+
// result of computing the existing spans with the set of spans that
|
5656 |
+
// existed in the history (so that deleting around a span and then
|
5657 |
+
// undoing brings back the span).
|
5658 |
+
function mergeOldSpans(doc, change) {
|
5659 |
+
var old = getOldSpans(doc, change);
|
5660 |
+
var stretched = stretchSpansOverChange(doc, change);
|
5661 |
+
if (!old) return stretched;
|
5662 |
+
if (!stretched) return old;
|
5663 |
+
|
5664 |
+
for (var i = 0; i < old.length; ++i) {
|
5665 |
+
var oldCur = old[i], stretchCur = stretched[i];
|
5666 |
+
if (oldCur && stretchCur) {
|
5667 |
+
spans: for (var j = 0; j < stretchCur.length; ++j) {
|
5668 |
+
var span = stretchCur[j];
|
5669 |
+
for (var k = 0; k < oldCur.length; ++k)
|
5670 |
+
if (oldCur[k].marker == span.marker) continue spans;
|
5671 |
+
oldCur.push(span);
|
5672 |
+
}
|
5673 |
+
} else if (stretchCur) {
|
5674 |
+
old[i] = stretchCur;
|
5675 |
+
}
|
5676 |
+
}
|
5677 |
+
return old;
|
5678 |
+
}
|
5679 |
+
|
5680 |
+
// Used to 'clip' out readOnly ranges when making a change.
|
5681 |
+
function removeReadOnlyRanges(doc, from, to) {
|
5682 |
+
var markers = null;
|
5683 |
+
doc.iter(from.line, to.line + 1, function(line) {
|
5684 |
+
if (line.markedSpans) for (var i = 0; i < line.markedSpans.length; ++i) {
|
5685 |
+
var mark = line.markedSpans[i].marker;
|
5686 |
+
if (mark.readOnly && (!markers || indexOf(markers, mark) == -1))
|
5687 |
+
(markers || (markers = [])).push(mark);
|
5688 |
+
}
|
5689 |
+
});
|
5690 |
+
if (!markers) return null;
|
5691 |
+
var parts = [{from: from, to: to}];
|
5692 |
+
for (var i = 0; i < markers.length; ++i) {
|
5693 |
+
var mk = markers[i], m = mk.find(0);
|
5694 |
+
for (var j = 0; j < parts.length; ++j) {
|
5695 |
+
var p = parts[j];
|
5696 |
+
if (cmp(p.to, m.from) < 0 || cmp(p.from, m.to) > 0) continue;
|
5697 |
+
var newParts = [j, 1], dfrom = cmp(p.from, m.from), dto = cmp(p.to, m.to);
|
5698 |
+
if (dfrom < 0 || !mk.inclusiveLeft && !dfrom)
|
5699 |
+
newParts.push({from: p.from, to: m.from});
|
5700 |
+
if (dto > 0 || !mk.inclusiveRight && !dto)
|
5701 |
+
newParts.push({from: m.to, to: p.to});
|
5702 |
+
parts.splice.apply(parts, newParts);
|
5703 |
+
j += newParts.length - 1;
|
5704 |
+
}
|
5705 |
+
}
|
5706 |
+
return parts;
|
5707 |
+
}
|
5708 |
+
|
5709 |
+
// Connect or disconnect spans from a line.
|
5710 |
+
function detachMarkedSpans(line) {
|
5711 |
+
var spans = line.markedSpans;
|
5712 |
+
if (!spans) return;
|
5713 |
+
for (var i = 0; i < spans.length; ++i)
|
5714 |
+
spans[i].marker.detachLine(line);
|
5715 |
+
line.markedSpans = null;
|
5716 |
+
}
|
5717 |
+
function attachMarkedSpans(line, spans) {
|
5718 |
+
if (!spans) return;
|
5719 |
+
for (var i = 0; i < spans.length; ++i)
|
5720 |
+
spans[i].marker.attachLine(line);
|
5721 |
+
line.markedSpans = spans;
|
5722 |
+
}
|
5723 |
+
|
5724 |
+
// Helpers used when computing which overlapping collapsed span
|
5725 |
+
// counts as the larger one.
|
5726 |
+
function extraLeft(marker) { return marker.inclusiveLeft ? -1 : 0; }
|
5727 |
+
function extraRight(marker) { return marker.inclusiveRight ? 1 : 0; }
|
5728 |
+
|
5729 |
+
// Returns a number indicating which of two overlapping collapsed
|
5730 |
+
// spans is larger (and thus includes the other). Falls back to
|
5731 |
+
// comparing ids when the spans cover exactly the same range.
|
5732 |
+
function compareCollapsedMarkers(a, b) {
|
5733 |
+
var lenDiff = a.lines.length - b.lines.length;
|
5734 |
+
if (lenDiff != 0) return lenDiff;
|
5735 |
+
var aPos = a.find(), bPos = b.find();
|
5736 |
+
var fromCmp = cmp(aPos.from, bPos.from) || extraLeft(a) - extraLeft(b);
|
5737 |
+
if (fromCmp) return -fromCmp;
|
5738 |
+
var toCmp = cmp(aPos.to, bPos.to) || extraRight(a) - extraRight(b);
|
5739 |
+
if (toCmp) return toCmp;
|
5740 |
+
return b.id - a.id;
|
5741 |
+
}
|
5742 |
+
|
5743 |
+
// Find out whether a line ends or starts in a collapsed span. If
|
5744 |
+
// so, return the marker for that span.
|
5745 |
+
function collapsedSpanAtSide(line, start) {
|
5746 |
+
var sps = sawCollapsedSpans && line.markedSpans, found;
|
5747 |
+
if (sps) for (var sp, i = 0; i < sps.length; ++i) {
|
5748 |
+
sp = sps[i];
|
5749 |
+
if (sp.marker.collapsed && (start ? sp.from : sp.to) == null &&
|
5750 |
+
(!found || compareCollapsedMarkers(found, sp.marker) < 0))
|
5751 |
+
found = sp.marker;
|
5752 |
+
}
|
5753 |
+
return found;
|
5754 |
+
}
|
5755 |
+
function collapsedSpanAtStart(line) { return collapsedSpanAtSide(line, true); }
|
5756 |
+
function collapsedSpanAtEnd(line) { return collapsedSpanAtSide(line, false); }
|
5757 |
+
|
5758 |
+
// Test whether there exists a collapsed span that partially
|
5759 |
+
// overlaps (covers the start or end, but not both) of a new span.
|
5760 |
+
// Such overlap is not allowed.
|
5761 |
+
function conflictingCollapsedRange(doc, lineNo, from, to, marker) {
|
5762 |
+
var line = getLine(doc, lineNo);
|
5763 |
+
var sps = sawCollapsedSpans && line.markedSpans;
|
5764 |
+
if (sps) for (var i = 0; i < sps.length; ++i) {
|
5765 |
+
var sp = sps[i];
|
5766 |
+
if (!sp.marker.collapsed) continue;
|
5767 |
+
var found = sp.marker.find(0);
|
5768 |
+
var fromCmp = cmp(found.from, from) || extraLeft(sp.marker) - extraLeft(marker);
|
5769 |
+
var toCmp = cmp(found.to, to) || extraRight(sp.marker) - extraRight(marker);
|
5770 |
+
if (fromCmp >= 0 && toCmp <= 0 || fromCmp <= 0 && toCmp >= 0) continue;
|
5771 |
+
if (fromCmp <= 0 && (cmp(found.to, from) > 0 || (sp.marker.inclusiveRight && marker.inclusiveLeft)) ||
|
5772 |
+
fromCmp >= 0 && (cmp(found.from, to) < 0 || (sp.marker.inclusiveLeft && marker.inclusiveRight)))
|
5773 |
+
return true;
|
5774 |
+
}
|
5775 |
+
}
|
5776 |
+
|
5777 |
+
// A visual line is a line as drawn on the screen. Folding, for
|
5778 |
+
// example, can cause multiple logical lines to appear on the same
|
5779 |
+
// visual line. This finds the start of the visual line that the
|
5780 |
+
// given line is part of (usually that is the line itself).
|
5781 |
+
function visualLine(line) {
|
5782 |
+
var merged;
|
5783 |
+
while (merged = collapsedSpanAtStart(line))
|
5784 |
+
line = merged.find(-1, true).line;
|
5785 |
+
return line;
|
5786 |
+
}
|
5787 |
+
|
5788 |
+
// Returns an array of logical lines that continue the visual line
|
5789 |
+
// started by the argument, or undefined if there are no such lines.
|
5790 |
+
function visualLineContinued(line) {
|
5791 |
+
var merged, lines;
|
5792 |
+
while (merged = collapsedSpanAtEnd(line)) {
|
5793 |
+
line = merged.find(1, true).line;
|
5794 |
+
(lines || (lines = [])).push(line);
|
5795 |
+
}
|
5796 |
+
return lines;
|
5797 |
+
}
|
5798 |
+
|
5799 |
+
// Get the line number of the start of the visual line that the
|
5800 |
+
// given line number is part of.
|
5801 |
+
function visualLineNo(doc, lineN) {
|
5802 |
+
var line = getLine(doc, lineN), vis = visualLine(line);
|
5803 |
+
if (line == vis) return lineN;
|
5804 |
+
return lineNo(vis);
|
5805 |
+
}
|
5806 |
+
// Get the line number of the start of the next visual line after
|
5807 |
+
// the given line.
|
5808 |
+
function visualLineEndNo(doc, lineN) {
|
5809 |
+
if (lineN > doc.lastLine()) return lineN;
|
5810 |
+
var line = getLine(doc, lineN), merged;
|
5811 |
+
if (!lineIsHidden(doc, line)) return lineN;
|
5812 |
+
while (merged = collapsedSpanAtEnd(line))
|
5813 |
+
line = merged.find(1, true).line;
|
5814 |
+
return lineNo(line) + 1;
|
5815 |
+
}
|
5816 |
+
|
5817 |
+
// Compute whether a line is hidden. Lines count as hidden when they
|
5818 |
+
// are part of a visual line that starts with another line, or when
|
5819 |
+
// they are entirely covered by collapsed, non-widget span.
|
5820 |
+
function lineIsHidden(doc, line) {
|
5821 |
+
var sps = sawCollapsedSpans && line.markedSpans;
|
5822 |
+
if (sps) for (var sp, i = 0; i < sps.length; ++i) {
|
5823 |
+
sp = sps[i];
|
5824 |
+
if (!sp.marker.collapsed) continue;
|
5825 |
+
if (sp.from == null) return true;
|
5826 |
+
if (sp.marker.widgetNode) continue;
|
5827 |
+
if (sp.from == 0 && sp.marker.inclusiveLeft && lineIsHiddenInner(doc, line, sp))
|
5828 |
+
return true;
|
5829 |
+
}
|
5830 |
+
}
|
5831 |
+
function lineIsHiddenInner(doc, line, span) {
|
5832 |
+
if (span.to == null) {
|
5833 |
+
var end = span.marker.find(1, true);
|
5834 |
+
return lineIsHiddenInner(doc, end.line, getMarkedSpanFor(end.line.markedSpans, span.marker));
|
5835 |
+
}
|
5836 |
+
if (span.marker.inclusiveRight && span.to == line.text.length)
|
5837 |
+
return true;
|
5838 |
+
for (var sp, i = 0; i < line.markedSpans.length; ++i) {
|
5839 |
+
sp = line.markedSpans[i];
|
5840 |
+
if (sp.marker.collapsed && !sp.marker.widgetNode && sp.from == span.to &&
|
5841 |
+
(sp.to == null || sp.to != span.from) &&
|
5842 |
+
(sp.marker.inclusiveLeft || span.marker.inclusiveRight) &&
|
5843 |
+
lineIsHiddenInner(doc, line, sp)) return true;
|
5844 |
+
}
|
5845 |
+
}
|
5846 |
+
|
5847 |
+
// LINE WIDGETS
|
5848 |
+
|
5849 |
+
// Line widgets are block elements displayed above or below a line.
|
5850 |
+
|
5851 |
+
var LineWidget = CodeMirror.LineWidget = function(cm, node, options) {
|
5852 |
+
if (options) for (var opt in options) if (options.hasOwnProperty(opt))
|
5853 |
+
this[opt] = options[opt];
|
5854 |
+
this.cm = cm;
|
5855 |
+
this.node = node;
|
5856 |
+
};
|
5857 |
+
eventMixin(LineWidget);
|
5858 |
+
|
5859 |
+
function adjustScrollWhenAboveVisible(cm, line, diff) {
|
5860 |
+
if (heightAtLine(line) < ((cm.curOp && cm.curOp.scrollTop) || cm.doc.scrollTop))
|
5861 |
+
addToScrollPos(cm, null, diff);
|
5862 |
+
}
|
5863 |
+
|
5864 |
+
LineWidget.prototype.clear = function() {
|
5865 |
+
var cm = this.cm, ws = this.line.widgets, line = this.line, no = lineNo(line);
|
5866 |
+
if (no == null || !ws) return;
|
5867 |
+
for (var i = 0; i < ws.length; ++i) if (ws[i] == this) ws.splice(i--, 1);
|
5868 |
+
if (!ws.length) line.widgets = null;
|
5869 |
+
var height = widgetHeight(this);
|
5870 |
+
runInOp(cm, function() {
|
5871 |
+
adjustScrollWhenAboveVisible(cm, line, -height);
|
5872 |
+
regLineChange(cm, no, "widget");
|
5873 |
+
updateLineHeight(line, Math.max(0, line.height - height));
|
5874 |
+
});
|
5875 |
+
};
|
5876 |
+
LineWidget.prototype.changed = function() {
|
5877 |
+
var oldH = this.height, cm = this.cm, line = this.line;
|
5878 |
+
this.height = null;
|
5879 |
+
var diff = widgetHeight(this) - oldH;
|
5880 |
+
if (!diff) return;
|
5881 |
+
runInOp(cm, function() {
|
5882 |
+
cm.curOp.forceUpdate = true;
|
5883 |
+
adjustScrollWhenAboveVisible(cm, line, diff);
|
5884 |
+
updateLineHeight(line, line.height + diff);
|
5885 |
+
});
|
5886 |
+
};
|
5887 |
+
|
5888 |
+
function widgetHeight(widget) {
|
5889 |
+
if (widget.height != null) return widget.height;
|
5890 |
+
if (!contains(document.body, widget.node)) {
|
5891 |
+
var parentStyle = "position: relative;";
|
5892 |
+
if (widget.coverGutter)
|
5893 |
+
parentStyle += "margin-left: -" + widget.cm.display.gutters.offsetWidth + "px;";
|
5894 |
+
if (widget.noHScroll)
|
5895 |
+
parentStyle += "width: " + widget.cm.display.wrapper.clientWidth + "px;";
|
5896 |
+
removeChildrenAndAdd(widget.cm.display.measure, elt("div", [widget.node], null, parentStyle));
|
5897 |
+
}
|
5898 |
+
return widget.height = widget.node.offsetHeight;
|
5899 |
+
}
|
5900 |
+
|
5901 |
+
function addLineWidget(cm, handle, node, options) {
|
5902 |
+
var widget = new LineWidget(cm, node, options);
|
5903 |
+
if (widget.noHScroll) cm.display.alignWidgets = true;
|
5904 |
+
changeLine(cm.doc, handle, "widget", function(line) {
|
5905 |
+
var widgets = line.widgets || (line.widgets = []);
|
5906 |
+
if (widget.insertAt == null) widgets.push(widget);
|
5907 |
+
else widgets.splice(Math.min(widgets.length - 1, Math.max(0, widget.insertAt)), 0, widget);
|
5908 |
+
widget.line = line;
|
5909 |
+
if (!lineIsHidden(cm.doc, line)) {
|
5910 |
+
var aboveVisible = heightAtLine(line) < cm.doc.scrollTop;
|
5911 |
+
updateLineHeight(line, line.height + widgetHeight(widget));
|
5912 |
+
if (aboveVisible) addToScrollPos(cm, null, widget.height);
|
5913 |
+
cm.curOp.forceUpdate = true;
|
5914 |
+
}
|
5915 |
+
return true;
|
5916 |
+
});
|
5917 |
+
return widget;
|
5918 |
+
}
|
5919 |
+
|
5920 |
+
// LINE DATA STRUCTURE
|
5921 |
+
|
5922 |
+
// Line objects. These hold state related to a line, including
|
5923 |
+
// highlighting info (the styles array).
|
5924 |
+
var Line = CodeMirror.Line = function(text, markedSpans, estimateHeight) {
|
5925 |
+
this.text = text;
|
5926 |
+
attachMarkedSpans(this, markedSpans);
|
5927 |
+
this.height = estimateHeight ? estimateHeight(this) : 1;
|
5928 |
+
};
|
5929 |
+
eventMixin(Line);
|
5930 |
+
Line.prototype.lineNo = function() { return lineNo(this); };
|
5931 |
+
|
5932 |
+
// Change the content (text, markers) of a line. Automatically
|
5933 |
+
// invalidates cached information and tries to re-estimate the
|
5934 |
+
// line's height.
|
5935 |
+
function updateLine(line, text, markedSpans, estimateHeight) {
|
5936 |
+
line.text = text;
|
5937 |
+
if (line.stateAfter) line.stateAfter = null;
|
5938 |
+
if (line.styles) line.styles = null;
|
5939 |
+
if (line.order != null) line.order = null;
|
5940 |
+
detachMarkedSpans(line);
|
5941 |
+
attachMarkedSpans(line, markedSpans);
|
5942 |
+
var estHeight = estimateHeight ? estimateHeight(line) : 1;
|
5943 |
+
if (estHeight != line.height) updateLineHeight(line, estHeight);
|
5944 |
+
}
|
5945 |
+
|
5946 |
+
// Detach a line from the document tree and its markers.
|
5947 |
+
function cleanUpLine(line) {
|
5948 |
+
line.parent = null;
|
5949 |
+
detachMarkedSpans(line);
|
5950 |
+
}
|
5951 |
+
|
5952 |
+
function extractLineClasses(type, output) {
|
5953 |
+
if (type) for (;;) {
|
5954 |
+
var lineClass = type.match(/(?:^|\s+)line-(background-)?(\S+)/);
|
5955 |
+
if (!lineClass) break;
|
5956 |
+
type = type.slice(0, lineClass.index) + type.slice(lineClass.index + lineClass[0].length);
|
5957 |
+
var prop = lineClass[1] ? "bgClass" : "textClass";
|
5958 |
+
if (output[prop] == null)
|
5959 |
+
output[prop] = lineClass[2];
|
5960 |
+
else if (!(new RegExp("(?:^|\s)" + lineClass[2] + "(?:$|\s)")).test(output[prop]))
|
5961 |
+
output[prop] += " " + lineClass[2];
|
5962 |
+
}
|
5963 |
+
return type;
|
5964 |
+
}
|
5965 |
+
|
5966 |
+
function callBlankLine(mode, state) {
|
5967 |
+
if (mode.blankLine) return mode.blankLine(state);
|
5968 |
+
if (!mode.innerMode) return;
|
5969 |
+
var inner = CodeMirror.innerMode(mode, state);
|
5970 |
+
if (inner.mode.blankLine) return inner.mode.blankLine(inner.state);
|
5971 |
+
}
|
5972 |
+
|
5973 |
+
function readToken(mode, stream, state, inner) {
|
5974 |
+
for (var i = 0; i < 10; i++) {
|
5975 |
+
if (inner) inner[0] = CodeMirror.innerMode(mode, state).mode;
|
5976 |
+
var style = mode.token(stream, state);
|
5977 |
+
if (stream.pos > stream.start) return style;
|
5978 |
+
}
|
5979 |
+
throw new Error("Mode " + mode.name + " failed to advance stream.");
|
5980 |
+
}
|
5981 |
+
|
5982 |
+
// Utility for getTokenAt and getLineTokens
|
5983 |
+
function takeToken(cm, pos, precise, asArray) {
|
5984 |
+
function getObj(copy) {
|
5985 |
+
return {start: stream.start, end: stream.pos,
|
5986 |
+
string: stream.current(),
|
5987 |
+
type: style || null,
|
5988 |
+
state: copy ? copyState(doc.mode, state) : state};
|
5989 |
+
}
|
5990 |
+
|
5991 |
+
var doc = cm.doc, mode = doc.mode, style;
|
5992 |
+
pos = clipPos(doc, pos);
|
5993 |
+
var line = getLine(doc, pos.line), state = getStateBefore(cm, pos.line, precise);
|
5994 |
+
var stream = new StringStream(line.text, cm.options.tabSize), tokens;
|
5995 |
+
if (asArray) tokens = [];
|
5996 |
+
while ((asArray || stream.pos < pos.ch) && !stream.eol()) {
|
5997 |
+
stream.start = stream.pos;
|
5998 |
+
style = readToken(mode, stream, state);
|
5999 |
+
if (asArray) tokens.push(getObj(true));
|
6000 |
+
}
|
6001 |
+
return asArray ? tokens : getObj();
|
6002 |
+
}
|
6003 |
+
|
6004 |
+
// Run the given mode's parser over a line, calling f for each token.
|
6005 |
+
function runMode(cm, text, mode, state, f, lineClasses, forceToEnd) {
|
6006 |
+
var flattenSpans = mode.flattenSpans;
|
6007 |
+
if (flattenSpans == null) flattenSpans = cm.options.flattenSpans;
|
6008 |
+
var curStart = 0, curStyle = null;
|
6009 |
+
var stream = new StringStream(text, cm.options.tabSize), style;
|
6010 |
+
var inner = cm.options.addModeClass && [null];
|
6011 |
+
if (text == "") extractLineClasses(callBlankLine(mode, state), lineClasses);
|
6012 |
+
while (!stream.eol()) {
|
6013 |
+
if (stream.pos > cm.options.maxHighlightLength) {
|
6014 |
+
flattenSpans = false;
|
6015 |
+
if (forceToEnd) processLine(cm, text, state, stream.pos);
|
6016 |
+
stream.pos = text.length;
|
6017 |
+
style = null;
|
6018 |
+
} else {
|
6019 |
+
style = extractLineClasses(readToken(mode, stream, state, inner), lineClasses);
|
6020 |
+
}
|
6021 |
+
if (inner) {
|
6022 |
+
var mName = inner[0].name;
|
6023 |
+
if (mName) style = "m-" + (style ? mName + " " + style : mName);
|
6024 |
+
}
|
6025 |
+
if (!flattenSpans || curStyle != style) {
|
6026 |
+
while (curStart < stream.start) {
|
6027 |
+
curStart = Math.min(stream.start, curStart + 50000);
|
6028 |
+
f(curStart, curStyle);
|
6029 |
+
}
|
6030 |
+
curStyle = style;
|
6031 |
+
}
|
6032 |
+
stream.start = stream.pos;
|
6033 |
+
}
|
6034 |
+
while (curStart < stream.pos) {
|
6035 |
+
// Webkit seems to refuse to render text nodes longer than 57444 characters
|
6036 |
+
var pos = Math.min(stream.pos, curStart + 50000);
|
6037 |
+
f(pos, curStyle);
|
6038 |
+
curStart = pos;
|
6039 |
+
}
|
6040 |
+
}
|
6041 |
+
|
6042 |
+
// Compute a style array (an array starting with a mode generation
|
6043 |
+
// -- for invalidation -- followed by pairs of end positions and
|
6044 |
+
// style strings), which is used to highlight the tokens on the
|
6045 |
+
// line.
|
6046 |
+
function highlightLine(cm, line, state, forceToEnd) {
|
6047 |
+
// A styles array always starts with a number identifying the
|
6048 |
+
// mode/overlays that it is based on (for easy invalidation).
|
6049 |
+
var st = [cm.state.modeGen], lineClasses = {};
|
6050 |
+
// Compute the base array of styles
|
6051 |
+
runMode(cm, line.text, cm.doc.mode, state, function(end, style) {
|
6052 |
+
st.push(end, style);
|
6053 |
+
}, lineClasses, forceToEnd);
|
6054 |
+
|
6055 |
+
// Run overlays, adjust style array.
|
6056 |
+
for (var o = 0; o < cm.state.overlays.length; ++o) {
|
6057 |
+
var overlay = cm.state.overlays[o], i = 1, at = 0;
|
6058 |
+
runMode(cm, line.text, overlay.mode, true, function(end, style) {
|
6059 |
+
var start = i;
|
6060 |
+
// Ensure there's a token end at the current position, and that i points at it
|
6061 |
+
while (at < end) {
|
6062 |
+
var i_end = st[i];
|
6063 |
+
if (i_end > end)
|
6064 |
+
st.splice(i, 1, end, st[i+1], i_end);
|
6065 |
+
i += 2;
|
6066 |
+
at = Math.min(end, i_end);
|
6067 |
+
}
|
6068 |
+
if (!style) return;
|
6069 |
+
if (overlay.opaque) {
|
6070 |
+
st.splice(start, i - start, end, "cm-overlay " + style);
|
6071 |
+
i = start + 2;
|
6072 |
+
} else {
|
6073 |
+
for (; start < i; start += 2) {
|
6074 |
+
var cur = st[start+1];
|
6075 |
+
st[start+1] = (cur ? cur + " " : "") + "cm-overlay " + style;
|
6076 |
+
}
|
6077 |
+
}
|
6078 |
+
}, lineClasses);
|
6079 |
+
}
|
6080 |
+
|
6081 |
+
return {styles: st, classes: lineClasses.bgClass || lineClasses.textClass ? lineClasses : null};
|
6082 |
+
}
|
6083 |
+
|
6084 |
+
function getLineStyles(cm, line, updateFrontier) {
|
6085 |
+
if (!line.styles || line.styles[0] != cm.state.modeGen) {
|
6086 |
+
var result = highlightLine(cm, line, line.stateAfter = getStateBefore(cm, lineNo(line)));
|
6087 |
+
line.styles = result.styles;
|
6088 |
+
if (result.classes) line.styleClasses = result.classes;
|
6089 |
+
else if (line.styleClasses) line.styleClasses = null;
|
6090 |
+
if (updateFrontier === cm.doc.frontier) cm.doc.frontier++;
|
6091 |
+
}
|
6092 |
+
return line.styles;
|
6093 |
+
}
|
6094 |
+
|
6095 |
+
// Lightweight form of highlight -- proceed over this line and
|
6096 |
+
// update state, but don't save a style array. Used for lines that
|
6097 |
+
// aren't currently visible.
|
6098 |
+
function processLine(cm, text, state, startAt) {
|
6099 |
+
var mode = cm.doc.mode;
|
6100 |
+
var stream = new StringStream(text, cm.options.tabSize);
|
6101 |
+
stream.start = stream.pos = startAt || 0;
|
6102 |
+
if (text == "") callBlankLine(mode, state);
|
6103 |
+
while (!stream.eol() && stream.pos <= cm.options.maxHighlightLength) {
|
6104 |
+
readToken(mode, stream, state);
|
6105 |
+
stream.start = stream.pos;
|
6106 |
+
}
|
6107 |
+
}
|
6108 |
+
|
6109 |
+
// Convert a style as returned by a mode (either null, or a string
|
6110 |
+
// containing one or more styles) to a CSS style. This is cached,
|
6111 |
+
// and also looks for line-wide styles.
|
6112 |
+
var styleToClassCache = {}, styleToClassCacheWithMode = {};
|
6113 |
+
function interpretTokenStyle(style, options) {
|
6114 |
+
if (!style || /^\s*$/.test(style)) return null;
|
6115 |
+
var cache = options.addModeClass ? styleToClassCacheWithMode : styleToClassCache;
|
6116 |
+
return cache[style] ||
|
6117 |
+
(cache[style] = style.replace(/\S+/g, "cm-$&"));
|
6118 |
+
}
|
6119 |
+
|
6120 |
+
// Render the DOM representation of the text of a line. Also builds
|
6121 |
+
// up a 'line map', which points at the DOM nodes that represent
|
6122 |
+
// specific stretches of text, and is used by the measuring code.
|
6123 |
+
// The returned object contains the DOM node, this map, and
|
6124 |
+
// information about line-wide styles that were set by the mode.
|
6125 |
+
function buildLineContent(cm, lineView) {
|
6126 |
+
// The padding-right forces the element to have a 'border', which
|
6127 |
+
// is needed on Webkit to be able to get line-level bounding
|
6128 |
+
// rectangles for it (in measureChar).
|
6129 |
+
var content = elt("span", null, null, webkit ? "padding-right: .1px" : null);
|
6130 |
+
var builder = {pre: elt("pre", [content]), content: content, col: 0, pos: 0, cm: cm};
|
6131 |
+
lineView.measure = {};
|
6132 |
+
|
6133 |
+
// Iterate over the logical lines that make up this visual line.
|
6134 |
+
for (var i = 0; i <= (lineView.rest ? lineView.rest.length : 0); i++) {
|
6135 |
+
var line = i ? lineView.rest[i - 1] : lineView.line, order;
|
6136 |
+
builder.pos = 0;
|
6137 |
+
builder.addToken = buildToken;
|
6138 |
+
// Optionally wire in some hacks into the token-rendering
|
6139 |
+
// algorithm, to deal with browser quirks.
|
6140 |
+
if ((ie || webkit) && cm.getOption("lineWrapping"))
|
6141 |
+
builder.addToken = buildTokenSplitSpaces(builder.addToken);
|
6142 |
+
if (hasBadBidiRects(cm.display.measure) && (order = getOrder(line)))
|
6143 |
+
builder.addToken = buildTokenBadBidi(builder.addToken, order);
|
6144 |
+
builder.map = [];
|
6145 |
+
var allowFrontierUpdate = lineView != cm.display.externalMeasured && lineNo(line);
|
6146 |
+
insertLineContent(line, builder, getLineStyles(cm, line, allowFrontierUpdate));
|
6147 |
+
if (line.styleClasses) {
|
6148 |
+
if (line.styleClasses.bgClass)
|
6149 |
+
builder.bgClass = joinClasses(line.styleClasses.bgClass, builder.bgClass || "");
|
6150 |
+
if (line.styleClasses.textClass)
|
6151 |
+
builder.textClass = joinClasses(line.styleClasses.textClass, builder.textClass || "");
|
6152 |
+
}
|
6153 |
+
|
6154 |
+
// Ensure at least a single node is present, for measuring.
|
6155 |
+
if (builder.map.length == 0)
|
6156 |
+
builder.map.push(0, 0, builder.content.appendChild(zeroWidthElement(cm.display.measure)));
|
6157 |
+
|
6158 |
+
// Store the map and a cache object for the current logical line
|
6159 |
+
if (i == 0) {
|
6160 |
+
lineView.measure.map = builder.map;
|
6161 |
+
lineView.measure.cache = {};
|
6162 |
+
} else {
|
6163 |
+
(lineView.measure.maps || (lineView.measure.maps = [])).push(builder.map);
|
6164 |
+
(lineView.measure.caches || (lineView.measure.caches = [])).push({});
|
6165 |
+
}
|
6166 |
+
}
|
6167 |
+
|
6168 |
+
// See issue #2901
|
6169 |
+
if (webkit && /\bcm-tab\b/.test(builder.content.lastChild.className))
|
6170 |
+
builder.content.className = "cm-tab-wrap-hack";
|
6171 |
+
|
6172 |
+
signal(cm, "renderLine", cm, lineView.line, builder.pre);
|
6173 |
+
if (builder.pre.className)
|
6174 |
+
builder.textClass = joinClasses(builder.pre.className, builder.textClass || "");
|
6175 |
+
|
6176 |
+
return builder;
|
6177 |
+
}
|
6178 |
+
|
6179 |
+
function defaultSpecialCharPlaceholder(ch) {
|
6180 |
+
var token = elt("span", "\u2022", "cm-invalidchar");
|
6181 |
+
token.title = "\\u" + ch.charCodeAt(0).toString(16);
|
6182 |
+
return token;
|
6183 |
+
}
|
6184 |
+
|
6185 |
+
// Build up the DOM representation for a single token, and add it to
|
6186 |
+
// the line map. Takes care to render special characters separately.
|
6187 |
+
function buildToken(builder, text, style, startStyle, endStyle, title, css) {
|
6188 |
+
if (!text) return;
|
6189 |
+
var special = builder.cm.options.specialChars, mustWrap = false;
|
6190 |
+
if (!special.test(text)) {
|
6191 |
+
builder.col += text.length;
|
6192 |
+
var content = document.createTextNode(text);
|
6193 |
+
builder.map.push(builder.pos, builder.pos + text.length, content);
|
6194 |
+
if (ie && ie_version < 9) mustWrap = true;
|
6195 |
+
builder.pos += text.length;
|
6196 |
+
} else {
|
6197 |
+
var content = document.createDocumentFragment(), pos = 0;
|
6198 |
+
while (true) {
|
6199 |
+
special.lastIndex = pos;
|
6200 |
+
var m = special.exec(text);
|
6201 |
+
var skipped = m ? m.index - pos : text.length - pos;
|
6202 |
+
if (skipped) {
|
6203 |
+
var txt = document.createTextNode(text.slice(pos, pos + skipped));
|
6204 |
+
if (ie && ie_version < 9) content.appendChild(elt("span", [txt]));
|
6205 |
+
else content.appendChild(txt);
|
6206 |
+
builder.map.push(builder.pos, builder.pos + skipped, txt);
|
6207 |
+
builder.col += skipped;
|
6208 |
+
builder.pos += skipped;
|
6209 |
+
}
|
6210 |
+
if (!m) break;
|
6211 |
+
pos += skipped + 1;
|
6212 |
+
if (m[0] == "\t") {
|
6213 |
+
var tabSize = builder.cm.options.tabSize, tabWidth = tabSize - builder.col % tabSize;
|
6214 |
+
var txt = content.appendChild(elt("span", spaceStr(tabWidth), "cm-tab"));
|
6215 |
+
builder.col += tabWidth;
|
6216 |
+
} else {
|
6217 |
+
var txt = builder.cm.options.specialCharPlaceholder(m[0]);
|
6218 |
+
if (ie && ie_version < 9) content.appendChild(elt("span", [txt]));
|
6219 |
+
else content.appendChild(txt);
|
6220 |
+
builder.col += 1;
|
6221 |
+
}
|
6222 |
+
builder.map.push(builder.pos, builder.pos + 1, txt);
|
6223 |
+
builder.pos++;
|
6224 |
+
}
|
6225 |
+
}
|
6226 |
+
if (style || startStyle || endStyle || mustWrap || css) {
|
6227 |
+
var fullStyle = style || "";
|
6228 |
+
if (startStyle) fullStyle += startStyle;
|
6229 |
+
if (endStyle) fullStyle += endStyle;
|
6230 |
+
var token = elt("span", [content], fullStyle, css);
|
6231 |
+
if (title) token.title = title;
|
6232 |
+
return builder.content.appendChild(token);
|
6233 |
+
}
|
6234 |
+
builder.content.appendChild(content);
|
6235 |
+
}
|
6236 |
+
|
6237 |
+
function buildTokenSplitSpaces(inner) {
|
6238 |
+
function split(old) {
|
6239 |
+
var out = " ";
|
6240 |
+
for (var i = 0; i < old.length - 2; ++i) out += i % 2 ? " " : "\u00a0";
|
6241 |
+
out += " ";
|
6242 |
+
return out;
|
6243 |
+
}
|
6244 |
+
return function(builder, text, style, startStyle, endStyle, title) {
|
6245 |
+
inner(builder, text.replace(/ {3,}/g, split), style, startStyle, endStyle, title);
|
6246 |
+
};
|
6247 |
+
}
|
6248 |
+
|
6249 |
+
// Work around nonsense dimensions being reported for stretches of
|
6250 |
+
// right-to-left text.
|
6251 |
+
function buildTokenBadBidi(inner, order) {
|
6252 |
+
return function(builder, text, style, startStyle, endStyle, title) {
|
6253 |
+
style = style ? style + " cm-force-border" : "cm-force-border";
|
6254 |
+
var start = builder.pos, end = start + text.length;
|
6255 |
+
for (;;) {
|
6256 |
+
// Find the part that overlaps with the start of this text
|
6257 |
+
for (var i = 0; i < order.length; i++) {
|
6258 |
+
var part = order[i];
|
6259 |
+
if (part.to > start && part.from <= start) break;
|
6260 |
+
}
|
6261 |
+
if (part.to >= end) return inner(builder, text, style, startStyle, endStyle, title);
|
6262 |
+
inner(builder, text.slice(0, part.to - start), style, startStyle, null, title);
|
6263 |
+
startStyle = null;
|
6264 |
+
text = text.slice(part.to - start);
|
6265 |
+
start = part.to;
|
6266 |
+
}
|
6267 |
+
};
|
6268 |
+
}
|
6269 |
+
|
6270 |
+
function buildCollapsedSpan(builder, size, marker, ignoreWidget) {
|
6271 |
+
var widget = !ignoreWidget && marker.widgetNode;
|
6272 |
+
if (widget) {
|
6273 |
+
builder.map.push(builder.pos, builder.pos + size, widget);
|
6274 |
+
builder.content.appendChild(widget);
|
6275 |
+
}
|
6276 |
+
builder.pos += size;
|
6277 |
+
}
|
6278 |
+
|
6279 |
+
// Outputs a number of spans to make up a line, taking highlighting
|
6280 |
+
// and marked text into account.
|
6281 |
+
function insertLineContent(line, builder, styles) {
|
6282 |
+
var spans = line.markedSpans, allText = line.text, at = 0;
|
6283 |
+
if (!spans) {
|
6284 |
+
for (var i = 1; i < styles.length; i+=2)
|
6285 |
+
builder.addToken(builder, allText.slice(at, at = styles[i]), interpretTokenStyle(styles[i+1], builder.cm.options));
|
6286 |
+
return;
|
6287 |
+
}
|
6288 |
+
|
6289 |
+
var len = allText.length, pos = 0, i = 1, text = "", style, css;
|
6290 |
+
var nextChange = 0, spanStyle, spanEndStyle, spanStartStyle, title, collapsed;
|
6291 |
+
for (;;) {
|
6292 |
+
if (nextChange == pos) { // Update current marker set
|
6293 |
+
spanStyle = spanEndStyle = spanStartStyle = title = css = "";
|
6294 |
+
collapsed = null; nextChange = Infinity;
|
6295 |
+
var foundBookmarks = [];
|
6296 |
+
for (var j = 0; j < spans.length; ++j) {
|
6297 |
+
var sp = spans[j], m = sp.marker;
|
6298 |
+
if (sp.from <= pos && (sp.to == null || sp.to > pos)) {
|
6299 |
+
if (sp.to != null && nextChange > sp.to) { nextChange = sp.to; spanEndStyle = ""; }
|
6300 |
+
if (m.className) spanStyle += " " + m.className;
|
6301 |
+
if (m.css) css = m.css;
|
6302 |
+
if (m.startStyle && sp.from == pos) spanStartStyle += " " + m.startStyle;
|
6303 |
+
if (m.endStyle && sp.to == nextChange) spanEndStyle += " " + m.endStyle;
|
6304 |
+
if (m.title && !title) title = m.title;
|
6305 |
+
if (m.collapsed && (!collapsed || compareCollapsedMarkers(collapsed.marker, m) < 0))
|
6306 |
+
collapsed = sp;
|
6307 |
+
} else if (sp.from > pos && nextChange > sp.from) {
|
6308 |
+
nextChange = sp.from;
|
6309 |
+
}
|
6310 |
+
if (m.type == "bookmark" && sp.from == pos && m.widgetNode) foundBookmarks.push(m);
|
6311 |
+
}
|
6312 |
+
if (collapsed && (collapsed.from || 0) == pos) {
|
6313 |
+
buildCollapsedSpan(builder, (collapsed.to == null ? len + 1 : collapsed.to) - pos,
|
6314 |
+
collapsed.marker, collapsed.from == null);
|
6315 |
+
if (collapsed.to == null) return;
|
6316 |
+
}
|
6317 |
+
if (!collapsed && foundBookmarks.length) for (var j = 0; j < foundBookmarks.length; ++j)
|
6318 |
+
buildCollapsedSpan(builder, 0, foundBookmarks[j]);
|
6319 |
+
}
|
6320 |
+
if (pos >= len) break;
|
6321 |
+
|
6322 |
+
var upto = Math.min(len, nextChange);
|
6323 |
+
while (true) {
|
6324 |
+
if (text) {
|
6325 |
+
var end = pos + text.length;
|
6326 |
+
if (!collapsed) {
|
6327 |
+
var tokenText = end > upto ? text.slice(0, upto - pos) : text;
|
6328 |
+
builder.addToken(builder, tokenText, style ? style + spanStyle : spanStyle,
|
6329 |
+
spanStartStyle, pos + tokenText.length == nextChange ? spanEndStyle : "", title, css);
|
6330 |
+
}
|
6331 |
+
if (end >= upto) {text = text.slice(upto - pos); pos = upto; break;}
|
6332 |
+
pos = end;
|
6333 |
+
spanStartStyle = "";
|
6334 |
+
}
|
6335 |
+
text = allText.slice(at, at = styles[i++]);
|
6336 |
+
style = interpretTokenStyle(styles[i++], builder.cm.options);
|
6337 |
+
}
|
6338 |
+
}
|
6339 |
+
}
|
6340 |
+
|
6341 |
+
// DOCUMENT DATA STRUCTURE
|
6342 |
+
|
6343 |
+
// By default, updates that start and end at the beginning of a line
|
6344 |
+
// are treated specially, in order to make the association of line
|
6345 |
+
// widgets and marker elements with the text behave more intuitive.
|
6346 |
+
function isWholeLineUpdate(doc, change) {
|
6347 |
+
return change.from.ch == 0 && change.to.ch == 0 && lst(change.text) == "" &&
|
6348 |
+
(!doc.cm || doc.cm.options.wholeLineUpdateBefore);
|
6349 |
+
}
|
6350 |
+
|
6351 |
+
// Perform a change on the document data structure.
|
6352 |
+
function updateDoc(doc, change, markedSpans, estimateHeight) {
|
6353 |
+
function spansFor(n) {return markedSpans ? markedSpans[n] : null;}
|
6354 |
+
function update(line, text, spans) {
|
6355 |
+
updateLine(line, text, spans, estimateHeight);
|
6356 |
+
signalLater(line, "change", line, change);
|
6357 |
+
}
|
6358 |
+
function linesFor(start, end) {
|
6359 |
+
for (var i = start, result = []; i < end; ++i)
|
6360 |
+
result.push(new Line(text[i], spansFor(i), estimateHeight));
|
6361 |
+
return result;
|
6362 |
+
}
|
6363 |
+
|
6364 |
+
var from = change.from, to = change.to, text = change.text;
|
6365 |
+
var firstLine = getLine(doc, from.line), lastLine = getLine(doc, to.line);
|
6366 |
+
var lastText = lst(text), lastSpans = spansFor(text.length - 1), nlines = to.line - from.line;
|
6367 |
+
|
6368 |
+
// Adjust the line structure
|
6369 |
+
if (change.full) {
|
6370 |
+
doc.insert(0, linesFor(0, text.length));
|
6371 |
+
doc.remove(text.length, doc.size - text.length);
|
6372 |
+
} else if (isWholeLineUpdate(doc, change)) {
|
6373 |
+
// This is a whole-line replace. Treated specially to make
|
6374 |
+
// sure line objects move the way they are supposed to.
|
6375 |
+
var added = linesFor(0, text.length - 1);
|
6376 |
+
update(lastLine, lastLine.text, lastSpans);
|
6377 |
+
if (nlines) doc.remove(from.line, nlines);
|
6378 |
+
if (added.length) doc.insert(from.line, added);
|
6379 |
+
} else if (firstLine == lastLine) {
|
6380 |
+
if (text.length == 1) {
|
6381 |
+
update(firstLine, firstLine.text.slice(0, from.ch) + lastText + firstLine.text.slice(to.ch), lastSpans);
|
6382 |
+
} else {
|
6383 |
+
var added = linesFor(1, text.length - 1);
|
6384 |
+
added.push(new Line(lastText + firstLine.text.slice(to.ch), lastSpans, estimateHeight));
|
6385 |
+
update(firstLine, firstLine.text.slice(0, from.ch) + text[0], spansFor(0));
|
6386 |
+
doc.insert(from.line + 1, added);
|
6387 |
+
}
|
6388 |
+
} else if (text.length == 1) {
|
6389 |
+
update(firstLine, firstLine.text.slice(0, from.ch) + text[0] + lastLine.text.slice(to.ch), spansFor(0));
|
6390 |
+
doc.remove(from.line + 1, nlines);
|
6391 |
+
} else {
|
6392 |
+
update(firstLine, firstLine.text.slice(0, from.ch) + text[0], spansFor(0));
|
6393 |
+
update(lastLine, lastText + lastLine.text.slice(to.ch), lastSpans);
|
6394 |
+
var added = linesFor(1, text.length - 1);
|
6395 |
+
if (nlines > 1) doc.remove(from.line + 1, nlines - 1);
|
6396 |
+
doc.insert(from.line + 1, added);
|
6397 |
+
}
|
6398 |
+
|
6399 |
+
signalLater(doc, "change", doc, change);
|
6400 |
+
}
|
6401 |
+
|
6402 |
+
// The document is represented as a BTree consisting of leaves, with
|
6403 |
+
// chunk of lines in them, and branches, with up to ten leaves or
|
6404 |
+
// other branch nodes below them. The top node is always a branch
|
6405 |
+
// node, and is the document object itself (meaning it has
|
6406 |
+
// additional methods and properties).
|
6407 |
+
//
|
6408 |
+
// All nodes have parent links. The tree is used both to go from
|
6409 |
+
// line numbers to line objects, and to go from objects to numbers.
|
6410 |
+
// It also indexes by height, and is used to convert between height
|
6411 |
+
// and line object, and to find the total height of the document.
|
6412 |
+
//
|
6413 |
+
// See also http://marijnhaverbeke.nl/blog/codemirror-line-tree.html
|
6414 |
+
|
6415 |
+
function LeafChunk(lines) {
|
6416 |
+
this.lines = lines;
|
6417 |
+
this.parent = null;
|
6418 |
+
for (var i = 0, height = 0; i < lines.length; ++i) {
|
6419 |
+
lines[i].parent = this;
|
6420 |
+
height += lines[i].height;
|
6421 |
+
}
|
6422 |
+
this.height = height;
|
6423 |
+
}
|
6424 |
+
|
6425 |
+
LeafChunk.prototype = {
|
6426 |
+
chunkSize: function() { return this.lines.length; },
|
6427 |
+
// Remove the n lines at offset 'at'.
|
6428 |
+
removeInner: function(at, n) {
|
6429 |
+
for (var i = at, e = at + n; i < e; ++i) {
|
6430 |
+
var line = this.lines[i];
|
6431 |
+
this.height -= line.height;
|
6432 |
+
cleanUpLine(line);
|
6433 |
+
signalLater(line, "delete");
|
6434 |
+
}
|
6435 |
+
this.lines.splice(at, n);
|
6436 |
+
},
|
6437 |
+
// Helper used to collapse a small branch into a single leaf.
|
6438 |
+
collapse: function(lines) {
|
6439 |
+
lines.push.apply(lines, this.lines);
|
6440 |
+
},
|
6441 |
+
// Insert the given array of lines at offset 'at', count them as
|
6442 |
+
// having the given height.
|
6443 |
+
insertInner: function(at, lines, height) {
|
6444 |
+
this.height += height;
|
6445 |
+
this.lines = this.lines.slice(0, at).concat(lines).concat(this.lines.slice(at));
|
6446 |
+
for (var i = 0; i < lines.length; ++i) lines[i].parent = this;
|
6447 |
+
},
|
6448 |
+
// Used to iterate over a part of the tree.
|
6449 |
+
iterN: function(at, n, op) {
|
6450 |
+
for (var e = at + n; at < e; ++at)
|
6451 |
+
if (op(this.lines[at])) return true;
|
6452 |
+
}
|
6453 |
+
};
|
6454 |
+
|
6455 |
+
function BranchChunk(children) {
|
6456 |
+
this.children = children;
|
6457 |
+
var size = 0, height = 0;
|
6458 |
+
for (var i = 0; i < children.length; ++i) {
|
6459 |
+
var ch = children[i];
|
6460 |
+
size += ch.chunkSize(); height += ch.height;
|
6461 |
+
ch.parent = this;
|
6462 |
+
}
|
6463 |
+
this.size = size;
|
6464 |
+
this.height = height;
|
6465 |
+
this.parent = null;
|
6466 |
+
}
|
6467 |
+
|
6468 |
+
BranchChunk.prototype = {
|
6469 |
+
chunkSize: function() { return this.size; },
|
6470 |
+
removeInner: function(at, n) {
|
6471 |
+
this.size -= n;
|
6472 |
+
for (var i = 0; i < this.children.length; ++i) {
|
6473 |
+
var child = this.children[i], sz = child.chunkSize();
|
6474 |
+
if (at < sz) {
|
6475 |
+
var rm = Math.min(n, sz - at), oldHeight = child.height;
|
6476 |
+
child.removeInner(at, rm);
|
6477 |
+
this.height -= oldHeight - child.height;
|
6478 |
+
if (sz == rm) { this.children.splice(i--, 1); child.parent = null; }
|
6479 |
+
if ((n -= rm) == 0) break;
|
6480 |
+
at = 0;
|
6481 |
+
} else at -= sz;
|
6482 |
+
}
|
6483 |
+
// If the result is smaller than 25 lines, ensure that it is a
|
6484 |
+
// single leaf node.
|
6485 |
+
if (this.size - n < 25 &&
|
6486 |
+
(this.children.length > 1 || !(this.children[0] instanceof LeafChunk))) {
|
6487 |
+
var lines = [];
|
6488 |
+
this.collapse(lines);
|
6489 |
+
this.children = [new LeafChunk(lines)];
|
6490 |
+
this.children[0].parent = this;
|
6491 |
+
}
|
6492 |
+
},
|
6493 |
+
collapse: function(lines) {
|
6494 |
+
for (var i = 0; i < this.children.length; ++i) this.children[i].collapse(lines);
|
6495 |
+
},
|
6496 |
+
insertInner: function(at, lines, height) {
|
6497 |
+
this.size += lines.length;
|
6498 |
+
this.height += height;
|
6499 |
+
for (var i = 0; i < this.children.length; ++i) {
|
6500 |
+
var child = this.children[i], sz = child.chunkSize();
|
6501 |
+
if (at <= sz) {
|
6502 |
+
child.insertInner(at, lines, height);
|
6503 |
+
if (child.lines && child.lines.length > 50) {
|
6504 |
+
while (child.lines.length > 50) {
|
6505 |
+
var spilled = child.lines.splice(child.lines.length - 25, 25);
|
6506 |
+
var newleaf = new LeafChunk(spilled);
|
6507 |
+
child.height -= newleaf.height;
|
6508 |
+
this.children.splice(i + 1, 0, newleaf);
|
6509 |
+
newleaf.parent = this;
|
6510 |
+
}
|
6511 |
+
this.maybeSpill();
|
6512 |
+
}
|
6513 |
+
break;
|
6514 |
+
}
|
6515 |
+
at -= sz;
|
6516 |
+
}
|
6517 |
+
},
|
6518 |
+
// When a node has grown, check whether it should be split.
|
6519 |
+
maybeSpill: function() {
|
6520 |
+
if (this.children.length <= 10) return;
|
6521 |
+
var me = this;
|
6522 |
+
do {
|
6523 |
+
var spilled = me.children.splice(me.children.length - 5, 5);
|
6524 |
+
var sibling = new BranchChunk(spilled);
|
6525 |
+
if (!me.parent) { // Become the parent node
|
6526 |
+
var copy = new BranchChunk(me.children);
|
6527 |
+
copy.parent = me;
|
6528 |
+
me.children = [copy, sibling];
|
6529 |
+
me = copy;
|
6530 |
+
} else {
|
6531 |
+
me.size -= sibling.size;
|
6532 |
+
me.height -= sibling.height;
|
6533 |
+
var myIndex = indexOf(me.parent.children, me);
|
6534 |
+
me.parent.children.splice(myIndex + 1, 0, sibling);
|
6535 |
+
}
|
6536 |
+
sibling.parent = me.parent;
|
6537 |
+
} while (me.children.length > 10);
|
6538 |
+
me.parent.maybeSpill();
|
6539 |
+
},
|
6540 |
+
iterN: function(at, n, op) {
|
6541 |
+
for (var i = 0; i < this.children.length; ++i) {
|
6542 |
+
var child = this.children[i], sz = child.chunkSize();
|
6543 |
+
if (at < sz) {
|
6544 |
+
var used = Math.min(n, sz - at);
|
6545 |
+
if (child.iterN(at, used, op)) return true;
|
6546 |
+
if ((n -= used) == 0) break;
|
6547 |
+
at = 0;
|
6548 |
+
} else at -= sz;
|
6549 |
+
}
|
6550 |
+
}
|
6551 |
+
};
|
6552 |
+
|
6553 |
+
var nextDocId = 0;
|
6554 |
+
var Doc = CodeMirror.Doc = function(text, mode, firstLine) {
|
6555 |
+
if (!(this instanceof Doc)) return new Doc(text, mode, firstLine);
|
6556 |
+
if (firstLine == null) firstLine = 0;
|
6557 |
+
|
6558 |
+
BranchChunk.call(this, [new LeafChunk([new Line("", null)])]);
|
6559 |
+
this.first = firstLine;
|
6560 |
+
this.scrollTop = this.scrollLeft = 0;
|
6561 |
+
this.cantEdit = false;
|
6562 |
+
this.cleanGeneration = 1;
|
6563 |
+
this.frontier = firstLine;
|
6564 |
+
var start = Pos(firstLine, 0);
|
6565 |
+
this.sel = simpleSelection(start);
|
6566 |
+
this.history = new History(null);
|
6567 |
+
this.id = ++nextDocId;
|
6568 |
+
this.modeOption = mode;
|
6569 |
+
|
6570 |
+
if (typeof text == "string") text = splitLines(text);
|
6571 |
+
updateDoc(this, {from: start, to: start, text: text});
|
6572 |
+
setSelection(this, simpleSelection(start), sel_dontScroll);
|
6573 |
+
};
|
6574 |
+
|
6575 |
+
Doc.prototype = createObj(BranchChunk.prototype, {
|
6576 |
+
constructor: Doc,
|
6577 |
+
// Iterate over the document. Supports two forms -- with only one
|
6578 |
+
// argument, it calls that for each line in the document. With
|
6579 |
+
// three, it iterates over the range given by the first two (with
|
6580 |
+
// the second being non-inclusive).
|
6581 |
+
iter: function(from, to, op) {
|
6582 |
+
if (op) this.iterN(from - this.first, to - from, op);
|
6583 |
+
else this.iterN(this.first, this.first + this.size, from);
|
6584 |
+
},
|
6585 |
+
|
6586 |
+
// Non-public interface for adding and removing lines.
|
6587 |
+
insert: function(at, lines) {
|
6588 |
+
var height = 0;
|
6589 |
+
for (var i = 0; i < lines.length; ++i) height += lines[i].height;
|
6590 |
+
this.insertInner(at - this.first, lines, height);
|
6591 |
+
},
|
6592 |
+
remove: function(at, n) { this.removeInner(at - this.first, n); },
|
6593 |
+
|
6594 |
+
// From here, the methods are part of the public interface. Most
|
6595 |
+
// are also available from CodeMirror (editor) instances.
|
6596 |
+
|
6597 |
+
getValue: function(lineSep) {
|
6598 |
+
var lines = getLines(this, this.first, this.first + this.size);
|
6599 |
+
if (lineSep === false) return lines;
|
6600 |
+
return lines.join(lineSep || "\n");
|
6601 |
+
},
|
6602 |
+
setValue: docMethodOp(function(code) {
|
6603 |
+
var top = Pos(this.first, 0), last = this.first + this.size - 1;
|
6604 |
+
makeChange(this, {from: top, to: Pos(last, getLine(this, last).text.length),
|
6605 |
+
text: splitLines(code), origin: "setValue", full: true}, true);
|
6606 |
+
setSelection(this, simpleSelection(top));
|
6607 |
+
}),
|
6608 |
+
replaceRange: function(code, from, to, origin) {
|
6609 |
+
from = clipPos(this, from);
|
6610 |
+
to = to ? clipPos(this, to) : from;
|
6611 |
+
replaceRange(this, code, from, to, origin);
|
6612 |
+
},
|
6613 |
+
getRange: function(from, to, lineSep) {
|
6614 |
+
var lines = getBetween(this, clipPos(this, from), clipPos(this, to));
|
6615 |
+
if (lineSep === false) return lines;
|
6616 |
+
return lines.join(lineSep || "\n");
|
6617 |
+
},
|
6618 |
+
|
6619 |
+
getLine: function(line) {var l = this.getLineHandle(line); return l && l.text;},
|
6620 |
+
|
6621 |
+
getLineHandle: function(line) {if (isLine(this, line)) return getLine(this, line);},
|
6622 |
+
getLineNumber: function(line) {return lineNo(line);},
|
6623 |
+
|
6624 |
+
getLineHandleVisualStart: function(line) {
|
6625 |
+
if (typeof line == "number") line = getLine(this, line);
|
6626 |
+
return visualLine(line);
|
6627 |
+
},
|
6628 |
+
|
6629 |
+
lineCount: function() {return this.size;},
|
6630 |
+
firstLine: function() {return this.first;},
|
6631 |
+
lastLine: function() {return this.first + this.size - 1;},
|
6632 |
+
|
6633 |
+
clipPos: function(pos) {return clipPos(this, pos);},
|
6634 |
+
|
6635 |
+
getCursor: function(start) {
|
6636 |
+
var range = this.sel.primary(), pos;
|
6637 |
+
if (start == null || start == "head") pos = range.head;
|
6638 |
+
else if (start == "anchor") pos = range.anchor;
|
6639 |
+
else if (start == "end" || start == "to" || start === false) pos = range.to();
|
6640 |
+
else pos = range.from();
|
6641 |
+
return pos;
|
6642 |
+
},
|
6643 |
+
listSelections: function() { return this.sel.ranges; },
|
6644 |
+
somethingSelected: function() {return this.sel.somethingSelected();},
|
6645 |
+
|
6646 |
+
setCursor: docMethodOp(function(line, ch, options) {
|
6647 |
+
setSimpleSelection(this, clipPos(this, typeof line == "number" ? Pos(line, ch || 0) : line), null, options);
|
6648 |
+
}),
|
6649 |
+
setSelection: docMethodOp(function(anchor, head, options) {
|
6650 |
+
setSimpleSelection(this, clipPos(this, anchor), clipPos(this, head || anchor), options);
|
6651 |
+
}),
|
6652 |
+
extendSelection: docMethodOp(function(head, other, options) {
|
6653 |
+
extendSelection(this, clipPos(this, head), other && clipPos(this, other), options);
|
6654 |
+
}),
|
6655 |
+
extendSelections: docMethodOp(function(heads, options) {
|
6656 |
+
extendSelections(this, clipPosArray(this, heads, options));
|
6657 |
+
}),
|
6658 |
+
extendSelectionsBy: docMethodOp(function(f, options) {
|
6659 |
+
extendSelections(this, map(this.sel.ranges, f), options);
|
6660 |
+
}),
|
6661 |
+
setSelections: docMethodOp(function(ranges, primary, options) {
|
6662 |
+
if (!ranges.length) return;
|
6663 |
+
for (var i = 0, out = []; i < ranges.length; i++)
|
6664 |
+
out[i] = new Range(clipPos(this, ranges[i].anchor),
|
6665 |
+
clipPos(this, ranges[i].head));
|
6666 |
+
if (primary == null) primary = Math.min(ranges.length - 1, this.sel.primIndex);
|
6667 |
+
setSelection(this, normalizeSelection(out, primary), options);
|
6668 |
+
}),
|
6669 |
+
addSelection: docMethodOp(function(anchor, head, options) {
|
6670 |
+
var ranges = this.sel.ranges.slice(0);
|
6671 |
+
ranges.push(new Range(clipPos(this, anchor), clipPos(this, head || anchor)));
|
6672 |
+
setSelection(this, normalizeSelection(ranges, ranges.length - 1), options);
|
6673 |
+
}),
|
6674 |
+
|
6675 |
+
getSelection: function(lineSep) {
|
6676 |
+
var ranges = this.sel.ranges, lines;
|
6677 |
+
for (var i = 0; i < ranges.length; i++) {
|
6678 |
+
var sel = getBetween(this, ranges[i].from(), ranges[i].to());
|
6679 |
+
lines = lines ? lines.concat(sel) : sel;
|
6680 |
+
}
|
6681 |
+
if (lineSep === false) return lines;
|
6682 |
+
else return lines.join(lineSep || "\n");
|
6683 |
+
},
|
6684 |
+
getSelections: function(lineSep) {
|
6685 |
+
var parts = [], ranges = this.sel.ranges;
|
6686 |
+
for (var i = 0; i < ranges.length; i++) {
|
6687 |
+
var sel = getBetween(this, ranges[i].from(), ranges[i].to());
|
6688 |
+
if (lineSep !== false) sel = sel.join(lineSep || "\n");
|
6689 |
+
parts[i] = sel;
|
6690 |
+
}
|
6691 |
+
return parts;
|
6692 |
+
},
|
6693 |
+
replaceSelection: function(code, collapse, origin) {
|
6694 |
+
var dup = [];
|
6695 |
+
for (var i = 0; i < this.sel.ranges.length; i++)
|
6696 |
+
dup[i] = code;
|
6697 |
+
this.replaceSelections(dup, collapse, origin || "+input");
|
6698 |
+
},
|
6699 |
+
replaceSelections: docMethodOp(function(code, collapse, origin) {
|
6700 |
+
var changes = [], sel = this.sel;
|
6701 |
+
for (var i = 0; i < sel.ranges.length; i++) {
|
6702 |
+
var range = sel.ranges[i];
|
6703 |
+
changes[i] = {from: range.from(), to: range.to(), text: splitLines(code[i]), origin: origin};
|
6704 |
+
}
|
6705 |
+
var newSel = collapse && collapse != "end" && computeReplacedSel(this, changes, collapse);
|
6706 |
+
for (var i = changes.length - 1; i >= 0; i--)
|
6707 |
+
makeChange(this, changes[i]);
|
6708 |
+
if (newSel) setSelectionReplaceHistory(this, newSel);
|
6709 |
+
else if (this.cm) ensureCursorVisible(this.cm);
|
6710 |
+
}),
|
6711 |
+
undo: docMethodOp(function() {makeChangeFromHistory(this, "undo");}),
|
6712 |
+
redo: docMethodOp(function() {makeChangeFromHistory(this, "redo");}),
|
6713 |
+
undoSelection: docMethodOp(function() {makeChangeFromHistory(this, "undo", true);}),
|
6714 |
+
redoSelection: docMethodOp(function() {makeChangeFromHistory(this, "redo", true);}),
|
6715 |
+
|
6716 |
+
setExtending: function(val) {this.extend = val;},
|
6717 |
+
getExtending: function() {return this.extend;},
|
6718 |
+
|
6719 |
+
historySize: function() {
|
6720 |
+
var hist = this.history, done = 0, undone = 0;
|
6721 |
+
for (var i = 0; i < hist.done.length; i++) if (!hist.done[i].ranges) ++done;
|
6722 |
+
for (var i = 0; i < hist.undone.length; i++) if (!hist.undone[i].ranges) ++undone;
|
6723 |
+
return {undo: done, redo: undone};
|
6724 |
+
},
|
6725 |
+
clearHistory: function() {this.history = new History(this.history.maxGeneration);},
|
6726 |
+
|
6727 |
+
markClean: function() {
|
6728 |
+
this.cleanGeneration = this.changeGeneration(true);
|
6729 |
+
},
|
6730 |
+
changeGeneration: function(forceSplit) {
|
6731 |
+
if (forceSplit)
|
6732 |
+
this.history.lastOp = this.history.lastSelOp = this.history.lastOrigin = null;
|
6733 |
+
return this.history.generation;
|
6734 |
+
},
|
6735 |
+
isClean: function (gen) {
|
6736 |
+
return this.history.generation == (gen || this.cleanGeneration);
|
6737 |
+
},
|
6738 |
+
|
6739 |
+
getHistory: function() {
|
6740 |
+
return {done: copyHistoryArray(this.history.done),
|
6741 |
+
undone: copyHistoryArray(this.history.undone)};
|
6742 |
+
},
|
6743 |
+
setHistory: function(histData) {
|
6744 |
+
var hist = this.history = new History(this.history.maxGeneration);
|
6745 |
+
hist.done = copyHistoryArray(histData.done.slice(0), null, true);
|
6746 |
+
hist.undone = copyHistoryArray(histData.undone.slice(0), null, true);
|
6747 |
+
},
|
6748 |
+
|
6749 |
+
addLineClass: docMethodOp(function(handle, where, cls) {
|
6750 |
+
return changeLine(this, handle, where == "gutter" ? "gutter" : "class", function(line) {
|
6751 |
+
var prop = where == "text" ? "textClass"
|
6752 |
+
: where == "background" ? "bgClass"
|
6753 |
+
: where == "gutter" ? "gutterClass" : "wrapClass";
|
6754 |
+
if (!line[prop]) line[prop] = cls;
|
6755 |
+
else if (classTest(cls).test(line[prop])) return false;
|
6756 |
+
else line[prop] += " " + cls;
|
6757 |
+
return true;
|
6758 |
+
});
|
6759 |
+
}),
|
6760 |
+
removeLineClass: docMethodOp(function(handle, where, cls) {
|
6761 |
+
return changeLine(this, handle, where == "gutter" ? "gutter" : "class", function(line) {
|
6762 |
+
var prop = where == "text" ? "textClass"
|
6763 |
+
: where == "background" ? "bgClass"
|
6764 |
+
: where == "gutter" ? "gutterClass" : "wrapClass";
|
6765 |
+
var cur = line[prop];
|
6766 |
+
if (!cur) return false;
|
6767 |
+
else if (cls == null) line[prop] = null;
|
6768 |
+
else {
|
6769 |
+
var found = cur.match(classTest(cls));
|
6770 |
+
if (!found) return false;
|
6771 |
+
var end = found.index + found[0].length;
|
6772 |
+
line[prop] = cur.slice(0, found.index) + (!found.index || end == cur.length ? "" : " ") + cur.slice(end) || null;
|
6773 |
+
}
|
6774 |
+
return true;
|
6775 |
+
});
|
6776 |
+
}),
|
6777 |
+
|
6778 |
+
markText: function(from, to, options) {
|
6779 |
+
return markText(this, clipPos(this, from), clipPos(this, to), options, "range");
|
6780 |
+
},
|
6781 |
+
setBookmark: function(pos, options) {
|
6782 |
+
var realOpts = {replacedWith: options && (options.nodeType == null ? options.widget : options),
|
6783 |
+
insertLeft: options && options.insertLeft,
|
6784 |
+
clearWhenEmpty: false, shared: options && options.shared};
|
6785 |
+
pos = clipPos(this, pos);
|
6786 |
+
return markText(this, pos, pos, realOpts, "bookmark");
|
6787 |
+
},
|
6788 |
+
findMarksAt: function(pos) {
|
6789 |
+
pos = clipPos(this, pos);
|
6790 |
+
var markers = [], spans = getLine(this, pos.line).markedSpans;
|
6791 |
+
if (spans) for (var i = 0; i < spans.length; ++i) {
|
6792 |
+
var span = spans[i];
|
6793 |
+
if ((span.from == null || span.from <= pos.ch) &&
|
6794 |
+
(span.to == null || span.to >= pos.ch))
|
6795 |
+
markers.push(span.marker.parent || span.marker);
|
6796 |
+
}
|
6797 |
+
return markers;
|
6798 |
+
},
|
6799 |
+
findMarks: function(from, to, filter) {
|
6800 |
+
from = clipPos(this, from); to = clipPos(this, to);
|
6801 |
+
var found = [], lineNo = from.line;
|
6802 |
+
this.iter(from.line, to.line + 1, function(line) {
|
6803 |
+
var spans = line.markedSpans;
|
6804 |
+
if (spans) for (var i = 0; i < spans.length; i++) {
|
6805 |
+
var span = spans[i];
|
6806 |
+
if (!(lineNo == from.line && from.ch > span.to ||
|
6807 |
+
span.from == null && lineNo != from.line||
|
6808 |
+
lineNo == to.line && span.from > to.ch) &&
|
6809 |
+
(!filter || filter(span.marker)))
|
6810 |
+
found.push(span.marker.parent || span.marker);
|
6811 |
+
}
|
6812 |
+
++lineNo;
|
6813 |
+
});
|
6814 |
+
return found;
|
6815 |
+
},
|
6816 |
+
getAllMarks: function() {
|
6817 |
+
var markers = [];
|
6818 |
+
this.iter(function(line) {
|
6819 |
+
var sps = line.markedSpans;
|
6820 |
+
if (sps) for (var i = 0; i < sps.length; ++i)
|
6821 |
+
if (sps[i].from != null) markers.push(sps[i].marker);
|
6822 |
+
});
|
6823 |
+
return markers;
|
6824 |
+
},
|
6825 |
+
|
6826 |
+
posFromIndex: function(off) {
|
6827 |
+
var ch, lineNo = this.first;
|
6828 |
+
this.iter(function(line) {
|
6829 |
+
var sz = line.text.length + 1;
|
6830 |
+
if (sz > off) { ch = off; return true; }
|
6831 |
+
off -= sz;
|
6832 |
+
++lineNo;
|
6833 |
+
});
|
6834 |
+
return clipPos(this, Pos(lineNo, ch));
|
6835 |
+
},
|
6836 |
+
indexFromPos: function (coords) {
|
6837 |
+
coords = clipPos(this, coords);
|
6838 |
+
var index = coords.ch;
|
6839 |
+
if (coords.line < this.first || coords.ch < 0) return 0;
|
6840 |
+
this.iter(this.first, coords.line, function (line) {
|
6841 |
+
index += line.text.length + 1;
|
6842 |
+
});
|
6843 |
+
return index;
|
6844 |
+
},
|
6845 |
+
|
6846 |
+
copy: function(copyHistory) {
|
6847 |
+
var doc = new Doc(getLines(this, this.first, this.first + this.size), this.modeOption, this.first);
|
6848 |
+
doc.scrollTop = this.scrollTop; doc.scrollLeft = this.scrollLeft;
|
6849 |
+
doc.sel = this.sel;
|
6850 |
+
doc.extend = false;
|
6851 |
+
if (copyHistory) {
|
6852 |
+
doc.history.undoDepth = this.history.undoDepth;
|
6853 |
+
doc.setHistory(this.getHistory());
|
6854 |
+
}
|
6855 |
+
return doc;
|
6856 |
+
},
|
6857 |
+
|
6858 |
+
linkedDoc: function(options) {
|
6859 |
+
if (!options) options = {};
|
6860 |
+
var from = this.first, to = this.first + this.size;
|
6861 |
+
if (options.from != null && options.from > from) from = options.from;
|
6862 |
+
if (options.to != null && options.to < to) to = options.to;
|
6863 |
+
var copy = new Doc(getLines(this, from, to), options.mode || this.modeOption, from);
|
6864 |
+
if (options.sharedHist) copy.history = this.history;
|
6865 |
+
(this.linked || (this.linked = [])).push({doc: copy, sharedHist: options.sharedHist});
|
6866 |
+
copy.linked = [{doc: this, isParent: true, sharedHist: options.sharedHist}];
|
6867 |
+
copySharedMarkers(copy, findSharedMarkers(this));
|
6868 |
+
return copy;
|
6869 |
+
},
|
6870 |
+
unlinkDoc: function(other) {
|
6871 |
+
if (other instanceof CodeMirror) other = other.doc;
|
6872 |
+
if (this.linked) for (var i = 0; i < this.linked.length; ++i) {
|
6873 |
+
var link = this.linked[i];
|
6874 |
+
if (link.doc != other) continue;
|
6875 |
+
this.linked.splice(i, 1);
|
6876 |
+
other.unlinkDoc(this);
|
6877 |
+
detachSharedMarkers(findSharedMarkers(this));
|
6878 |
+
break;
|
6879 |
+
}
|
6880 |
+
// If the histories were shared, split them again
|
6881 |
+
if (other.history == this.history) {
|
6882 |
+
var splitIds = [other.id];
|
6883 |
+
linkedDocs(other, function(doc) {splitIds.push(doc.id);}, true);
|
6884 |
+
other.history = new History(null);
|
6885 |
+
other.history.done = copyHistoryArray(this.history.done, splitIds);
|
6886 |
+
other.history.undone = copyHistoryArray(this.history.undone, splitIds);
|
6887 |
+
}
|
6888 |
+
},
|
6889 |
+
iterLinkedDocs: function(f) {linkedDocs(this, f);},
|
6890 |
+
|
6891 |
+
getMode: function() {return this.mode;},
|
6892 |
+
getEditor: function() {return this.cm;}
|
6893 |
+
});
|
6894 |
+
|
6895 |
+
// Public alias.
|
6896 |
+
Doc.prototype.eachLine = Doc.prototype.iter;
|
6897 |
+
|
6898 |
+
// Set up methods on CodeMirror's prototype to redirect to the editor's document.
|
6899 |
+
var dontDelegate = "iter insert remove copy getEditor".split(" ");
|
6900 |
+
for (var prop in Doc.prototype) if (Doc.prototype.hasOwnProperty(prop) && indexOf(dontDelegate, prop) < 0)
|
6901 |
+
CodeMirror.prototype[prop] = (function(method) {
|
6902 |
+
return function() {return method.apply(this.doc, arguments);};
|
6903 |
+
})(Doc.prototype[prop]);
|
6904 |
+
|
6905 |
+
eventMixin(Doc);
|
6906 |
+
|
6907 |
+
// Call f for all linked documents.
|
6908 |
+
function linkedDocs(doc, f, sharedHistOnly) {
|
6909 |
+
function propagate(doc, skip, sharedHist) {
|
6910 |
+
if (doc.linked) for (var i = 0; i < doc.linked.length; ++i) {
|
6911 |
+
var rel = doc.linked[i];
|
6912 |
+
if (rel.doc == skip) continue;
|
6913 |
+
var shared = sharedHist && rel.sharedHist;
|
6914 |
+
if (sharedHistOnly && !shared) continue;
|
6915 |
+
f(rel.doc, shared);
|
6916 |
+
propagate(rel.doc, doc, shared);
|
6917 |
+
}
|
6918 |
+
}
|
6919 |
+
propagate(doc, null, true);
|
6920 |
+
}
|
6921 |
+
|
6922 |
+
// Attach a document to an editor.
|
6923 |
+
function attachDoc(cm, doc) {
|
6924 |
+
if (doc.cm) throw new Error("This document is already in use.");
|
6925 |
+
cm.doc = doc;
|
6926 |
+
doc.cm = cm;
|
6927 |
+
estimateLineHeights(cm);
|
6928 |
+
loadMode(cm);
|
6929 |
+
if (!cm.options.lineWrapping) findMaxLine(cm);
|
6930 |
+
cm.options.mode = doc.modeOption;
|
6931 |
+
regChange(cm);
|
6932 |
+
}
|
6933 |
+
|
6934 |
+
// LINE UTILITIES
|
6935 |
+
|
6936 |
+
// Find the line object corresponding to the given line number.
|
6937 |
+
function getLine(doc, n) {
|
6938 |
+
n -= doc.first;
|
6939 |
+
if (n < 0 || n >= doc.size) throw new Error("There is no line " + (n + doc.first) + " in the document.");
|
6940 |
+
for (var chunk = doc; !chunk.lines;) {
|
6941 |
+
for (var i = 0;; ++i) {
|
6942 |
+
var child = chunk.children[i], sz = child.chunkSize();
|
6943 |
+
if (n < sz) { chunk = child; break; }
|
6944 |
+
n -= sz;
|
6945 |
+
}
|
6946 |
+
}
|
6947 |
+
return chunk.lines[n];
|
6948 |
+
}
|
6949 |
+
|
6950 |
+
// Get the part of a document between two positions, as an array of
|
6951 |
+
// strings.
|
6952 |
+
function getBetween(doc, start, end) {
|
6953 |
+
var out = [], n = start.line;
|
6954 |
+
doc.iter(start.line, end.line + 1, function(line) {
|
6955 |
+
var text = line.text;
|
6956 |
+
if (n == end.line) text = text.slice(0, end.ch);
|
6957 |
+
if (n == start.line) text = text.slice(start.ch);
|
6958 |
+
out.push(text);
|
6959 |
+
++n;
|
6960 |
+
});
|
6961 |
+
return out;
|
6962 |
+
}
|
6963 |
+
// Get the lines between from and to, as array of strings.
|
6964 |
+
function getLines(doc, from, to) {
|
6965 |
+
var out = [];
|
6966 |
+
doc.iter(from, to, function(line) { out.push(line.text); });
|
6967 |
+
return out;
|
6968 |
+
}
|
6969 |
+
|
6970 |
+
// Update the height of a line, propagating the height change
|
6971 |
+
// upwards to parent nodes.
|
6972 |
+
function updateLineHeight(line, height) {
|
6973 |
+
var diff = height - line.height;
|
6974 |
+
if (diff) for (var n = line; n; n = n.parent) n.height += diff;
|
6975 |
+
}
|
6976 |
+
|
6977 |
+
// Given a line object, find its line number by walking up through
|
6978 |
+
// its parent links.
|
6979 |
+
function lineNo(line) {
|
6980 |
+
if (line.parent == null) return null;
|
6981 |
+
var cur = line.parent, no = indexOf(cur.lines, line);
|
6982 |
+
for (var chunk = cur.parent; chunk; cur = chunk, chunk = chunk.parent) {
|
6983 |
+
for (var i = 0;; ++i) {
|
6984 |
+
if (chunk.children[i] == cur) break;
|
6985 |
+
no += chunk.children[i].chunkSize();
|
6986 |
+
}
|
6987 |
+
}
|
6988 |
+
return no + cur.first;
|
6989 |
+
}
|
6990 |
+
|
6991 |
+
// Find the line at the given vertical position, using the height
|
6992 |
+
// information in the document tree.
|
6993 |
+
function lineAtHeight(chunk, h) {
|
6994 |
+
var n = chunk.first;
|
6995 |
+
outer: do {
|
6996 |
+
for (var i = 0; i < chunk.children.length; ++i) {
|
6997 |
+
var child = chunk.children[i], ch = child.height;
|
6998 |
+
if (h < ch) { chunk = child; continue outer; }
|
6999 |
+
h -= ch;
|
7000 |
+
n += child.chunkSize();
|
7001 |
+
}
|
7002 |
+
return n;
|
7003 |
+
} while (!chunk.lines);
|
7004 |
+
for (var i = 0; i < chunk.lines.length; ++i) {
|
7005 |
+
var line = chunk.lines[i], lh = line.height;
|
7006 |
+
if (h < lh) break;
|
7007 |
+
h -= lh;
|
7008 |
+
}
|
7009 |
+
return n + i;
|
7010 |
+
}
|
7011 |
+
|
7012 |
+
|
7013 |
+
// Find the height above the given line.
|
7014 |
+
function heightAtLine(lineObj) {
|
7015 |
+
lineObj = visualLine(lineObj);
|
7016 |
+
|
7017 |
+
var h = 0, chunk = lineObj.parent;
|
7018 |
+
for (var i = 0; i < chunk.lines.length; ++i) {
|
7019 |
+
var line = chunk.lines[i];
|
7020 |
+
if (line == lineObj) break;
|
7021 |
+
else h += line.height;
|
7022 |
+
}
|
7023 |
+
for (var p = chunk.parent; p; chunk = p, p = chunk.parent) {
|
7024 |
+
for (var i = 0; i < p.children.length; ++i) {
|
7025 |
+
var cur = p.children[i];
|
7026 |
+
if (cur == chunk) break;
|
7027 |
+
else h += cur.height;
|
7028 |
+
}
|
7029 |
+
}
|
7030 |
+
return h;
|
7031 |
+
}
|
7032 |
+
|
7033 |
+
// Get the bidi ordering for the given line (and cache it). Returns
|
7034 |
+
// false for lines that are fully left-to-right, and an array of
|
7035 |
+
// BidiSpan objects otherwise.
|
7036 |
+
function getOrder(line) {
|
7037 |
+
var order = line.order;
|
7038 |
+
if (order == null) order = line.order = bidiOrdering(line.text);
|
7039 |
+
return order;
|
7040 |
+
}
|
7041 |
+
|
7042 |
+
// HISTORY
|
7043 |
+
|
7044 |
+
function History(startGen) {
|
7045 |
+
// Arrays of change events and selections. Doing something adds an
|
7046 |
+
// event to done and clears undo. Undoing moves events from done
|
7047 |
+
// to undone, redoing moves them in the other direction.
|
7048 |
+
this.done = []; this.undone = [];
|
7049 |
+
this.undoDepth = Infinity;
|
7050 |
+
// Used to track when changes can be merged into a single undo
|
7051 |
+
// event
|
7052 |
+
this.lastModTime = this.lastSelTime = 0;
|
7053 |
+
this.lastOp = this.lastSelOp = null;
|
7054 |
+
this.lastOrigin = this.lastSelOrigin = null;
|
7055 |
+
// Used by the isClean() method
|
7056 |
+
this.generation = this.maxGeneration = startGen || 1;
|
7057 |
+
}
|
7058 |
+
|
7059 |
+
// Create a history change event from an updateDoc-style change
|
7060 |
+
// object.
|
7061 |
+
function historyChangeFromChange(doc, change) {
|
7062 |
+
var histChange = {from: copyPos(change.from), to: changeEnd(change), text: getBetween(doc, change.from, change.to)};
|
7063 |
+
attachLocalSpans(doc, histChange, change.from.line, change.to.line + 1);
|
7064 |
+
linkedDocs(doc, function(doc) {attachLocalSpans(doc, histChange, change.from.line, change.to.line + 1);}, true);
|
7065 |
+
return histChange;
|
7066 |
+
}
|
7067 |
+
|
7068 |
+
// Pop all selection events off the end of a history array. Stop at
|
7069 |
+
// a change event.
|
7070 |
+
function clearSelectionEvents(array) {
|
7071 |
+
while (array.length) {
|
7072 |
+
var last = lst(array);
|
7073 |
+
if (last.ranges) array.pop();
|
7074 |
+
else break;
|
7075 |
+
}
|
7076 |
+
}
|
7077 |
+
|
7078 |
+
// Find the top change event in the history. Pop off selection
|
7079 |
+
// events that are in the way.
|
7080 |
+
function lastChangeEvent(hist, force) {
|
7081 |
+
if (force) {
|
7082 |
+
clearSelectionEvents(hist.done);
|
7083 |
+
return lst(hist.done);
|
7084 |
+
} else if (hist.done.length && !lst(hist.done).ranges) {
|
7085 |
+
return lst(hist.done);
|
7086 |
+
} else if (hist.done.length > 1 && !hist.done[hist.done.length - 2].ranges) {
|
7087 |
+
hist.done.pop();
|
7088 |
+
return lst(hist.done);
|
7089 |
+
}
|
7090 |
+
}
|
7091 |
+
|
7092 |
+
// Register a change in the history. Merges changes that are within
|
7093 |
+
// a single operation, ore are close together with an origin that
|
7094 |
+
// allows merging (starting with "+") into a single event.
|
7095 |
+
function addChangeToHistory(doc, change, selAfter, opId) {
|
7096 |
+
var hist = doc.history;
|
7097 |
+
hist.undone.length = 0;
|
7098 |
+
var time = +new Date, cur;
|
7099 |
+
|
7100 |
+
if ((hist.lastOp == opId ||
|
7101 |
+
hist.lastOrigin == change.origin && change.origin &&
|
7102 |
+
((change.origin.charAt(0) == "+" && doc.cm && hist.lastModTime > time - doc.cm.options.historyEventDelay) ||
|
7103 |
+
change.origin.charAt(0) == "*")) &&
|
7104 |
+
(cur = lastChangeEvent(hist, hist.lastOp == opId))) {
|
7105 |
+
// Merge this change into the last event
|
7106 |
+
var last = lst(cur.changes);
|
7107 |
+
if (cmp(change.from, change.to) == 0 && cmp(change.from, last.to) == 0) {
|
7108 |
+
// Optimized case for simple insertion -- don't want to add
|
7109 |
+
// new changesets for every character typed
|
7110 |
+
last.to = changeEnd(change);
|
7111 |
+
} else {
|
7112 |
+
// Add new sub-event
|
7113 |
+
cur.changes.push(historyChangeFromChange(doc, change));
|
7114 |
+
}
|
7115 |
+
} else {
|
7116 |
+
// Can not be merged, start a new event.
|
7117 |
+
var before = lst(hist.done);
|
7118 |
+
if (!before || !before.ranges)
|
7119 |
+
pushSelectionToHistory(doc.sel, hist.done);
|
7120 |
+
cur = {changes: [historyChangeFromChange(doc, change)],
|
7121 |
+
generation: hist.generation};
|
7122 |
+
hist.done.push(cur);
|
7123 |
+
while (hist.done.length > hist.undoDepth) {
|
7124 |
+
hist.done.shift();
|
7125 |
+
if (!hist.done[0].ranges) hist.done.shift();
|
7126 |
+
}
|
7127 |
+
}
|
7128 |
+
hist.done.push(selAfter);
|
7129 |
+
hist.generation = ++hist.maxGeneration;
|
7130 |
+
hist.lastModTime = hist.lastSelTime = time;
|
7131 |
+
hist.lastOp = hist.lastSelOp = opId;
|
7132 |
+
hist.lastOrigin = hist.lastSelOrigin = change.origin;
|
7133 |
+
|
7134 |
+
if (!last) signal(doc, "historyAdded");
|
7135 |
+
}
|
7136 |
+
|
7137 |
+
function selectionEventCanBeMerged(doc, origin, prev, sel) {
|
7138 |
+
var ch = origin.charAt(0);
|
7139 |
+
return ch == "*" ||
|
7140 |
+
ch == "+" &&
|
7141 |
+
prev.ranges.length == sel.ranges.length &&
|
7142 |
+
prev.somethingSelected() == sel.somethingSelected() &&
|
7143 |
+
new Date - doc.history.lastSelTime <= (doc.cm ? doc.cm.options.historyEventDelay : 500);
|
7144 |
+
}
|
7145 |
+
|
7146 |
+
// Called whenever the selection changes, sets the new selection as
|
7147 |
+
// the pending selection in the history, and pushes the old pending
|
7148 |
+
// selection into the 'done' array when it was significantly
|
7149 |
+
// different (in number of selected ranges, emptiness, or time).
|
7150 |
+
function addSelectionToHistory(doc, sel, opId, options) {
|
7151 |
+
var hist = doc.history, origin = options && options.origin;
|
7152 |
+
|
7153 |
+
// A new event is started when the previous origin does not match
|
7154 |
+
// the current, or the origins don't allow matching. Origins
|
7155 |
+
// starting with * are always merged, those starting with + are
|
7156 |
+
// merged when similar and close together in time.
|
7157 |
+
if (opId == hist.lastSelOp ||
|
7158 |
+
(origin && hist.lastSelOrigin == origin &&
|
7159 |
+
(hist.lastModTime == hist.lastSelTime && hist.lastOrigin == origin ||
|
7160 |
+
selectionEventCanBeMerged(doc, origin, lst(hist.done), sel))))
|
7161 |
+
hist.done[hist.done.length - 1] = sel;
|
7162 |
+
else
|
7163 |
+
pushSelectionToHistory(sel, hist.done);
|
7164 |
+
|
7165 |
+
hist.lastSelTime = +new Date;
|
7166 |
+
hist.lastSelOrigin = origin;
|
7167 |
+
hist.lastSelOp = opId;
|
7168 |
+
if (options && options.clearRedo !== false)
|
7169 |
+
clearSelectionEvents(hist.undone);
|
7170 |
+
}
|
7171 |
+
|
7172 |
+
function pushSelectionToHistory(sel, dest) {
|
7173 |
+
var top = lst(dest);
|
7174 |
+
if (!(top && top.ranges && top.equals(sel)))
|
7175 |
+
dest.push(sel);
|
7176 |
+
}
|
7177 |
+
|
7178 |
+
// Used to store marked span information in the history.
|
7179 |
+
function attachLocalSpans(doc, change, from, to) {
|
7180 |
+
var existing = change["spans_" + doc.id], n = 0;
|
7181 |
+
doc.iter(Math.max(doc.first, from), Math.min(doc.first + doc.size, to), function(line) {
|
7182 |
+
if (line.markedSpans)
|
7183 |
+
(existing || (existing = change["spans_" + doc.id] = {}))[n] = line.markedSpans;
|
7184 |
+
++n;
|
7185 |
+
});
|
7186 |
+
}
|
7187 |
+
|
7188 |
+
// When un/re-doing restores text containing marked spans, those
|
7189 |
+
// that have been explicitly cleared should not be restored.
|
7190 |
+
function removeClearedSpans(spans) {
|
7191 |
+
if (!spans) return null;
|
7192 |
+
for (var i = 0, out; i < spans.length; ++i) {
|
7193 |
+
if (spans[i].marker.explicitlyCleared) { if (!out) out = spans.slice(0, i); }
|
7194 |
+
else if (out) out.push(spans[i]);
|
7195 |
+
}
|
7196 |
+
return !out ? spans : out.length ? out : null;
|
7197 |
+
}
|
7198 |
+
|
7199 |
+
// Retrieve and filter the old marked spans stored in a change event.
|
7200 |
+
function getOldSpans(doc, change) {
|
7201 |
+
var found = change["spans_" + doc.id];
|
7202 |
+
if (!found) return null;
|
7203 |
+
for (var i = 0, nw = []; i < change.text.length; ++i)
|
7204 |
+
nw.push(removeClearedSpans(found[i]));
|
7205 |
+
return nw;
|
7206 |
+
}
|
7207 |
+
|
7208 |
+
// Used both to provide a JSON-safe object in .getHistory, and, when
|
7209 |
+
// detaching a document, to split the history in two
|
7210 |
+
function copyHistoryArray(events, newGroup, instantiateSel) {
|
7211 |
+
for (var i = 0, copy = []; i < events.length; ++i) {
|
7212 |
+
var event = events[i];
|
7213 |
+
if (event.ranges) {
|
7214 |
+
copy.push(instantiateSel ? Selection.prototype.deepCopy.call(event) : event);
|
7215 |
+
continue;
|
7216 |
+
}
|
7217 |
+
var changes = event.changes, newChanges = [];
|
7218 |
+
copy.push({changes: newChanges});
|
7219 |
+
for (var j = 0; j < changes.length; ++j) {
|
7220 |
+
var change = changes[j], m;
|
7221 |
+
newChanges.push({from: change.from, to: change.to, text: change.text});
|
7222 |
+
if (newGroup) for (var prop in change) if (m = prop.match(/^spans_(\d+)$/)) {
|
7223 |
+
if (indexOf(newGroup, Number(m[1])) > -1) {
|
7224 |
+
lst(newChanges)[prop] = change[prop];
|
7225 |
+
delete change[prop];
|
7226 |
+
}
|
7227 |
+
}
|
7228 |
+
}
|
7229 |
+
}
|
7230 |
+
return copy;
|
7231 |
+
}
|
7232 |
+
|
7233 |
+
// Rebasing/resetting history to deal with externally-sourced changes
|
7234 |
+
|
7235 |
+
function rebaseHistSelSingle(pos, from, to, diff) {
|
7236 |
+
if (to < pos.line) {
|
7237 |
+
pos.line += diff;
|
7238 |
+
} else if (from < pos.line) {
|
7239 |
+
pos.line = from;
|
7240 |
+
pos.ch = 0;
|
7241 |
+
}
|
7242 |
+
}
|
7243 |
+
|
7244 |
+
// Tries to rebase an array of history events given a change in the
|
7245 |
+
// document. If the change touches the same lines as the event, the
|
7246 |
+
// event, and everything 'behind' it, is discarded. If the change is
|
7247 |
+
// before the event, the event's positions are updated. Uses a
|
7248 |
+
// copy-on-write scheme for the positions, to avoid having to
|
7249 |
+
// reallocate them all on every rebase, but also avoid problems with
|
7250 |
+
// shared position objects being unsafely updated.
|
7251 |
+
function rebaseHistArray(array, from, to, diff) {
|
7252 |
+
for (var i = 0; i < array.length; ++i) {
|
7253 |
+
var sub = array[i], ok = true;
|
7254 |
+
if (sub.ranges) {
|
7255 |
+
if (!sub.copied) { sub = array[i] = sub.deepCopy(); sub.copied = true; }
|
7256 |
+
for (var j = 0; j < sub.ranges.length; j++) {
|
7257 |
+
rebaseHistSelSingle(sub.ranges[j].anchor, from, to, diff);
|
7258 |
+
rebaseHistSelSingle(sub.ranges[j].head, from, to, diff);
|
7259 |
+
}
|
7260 |
+
continue;
|
7261 |
+
}
|
7262 |
+
for (var j = 0; j < sub.changes.length; ++j) {
|
7263 |
+
var cur = sub.changes[j];
|
7264 |
+
if (to < cur.from.line) {
|
7265 |
+
cur.from = Pos(cur.from.line + diff, cur.from.ch);
|
7266 |
+
cur.to = Pos(cur.to.line + diff, cur.to.ch);
|
7267 |
+
} else if (from <= cur.to.line) {
|
7268 |
+
ok = false;
|
7269 |
+
break;
|
7270 |
+
}
|
7271 |
+
}
|
7272 |
+
if (!ok) {
|
7273 |
+
array.splice(0, i + 1);
|
7274 |
+
i = 0;
|
7275 |
+
}
|
7276 |
+
}
|
7277 |
+
}
|
7278 |
+
|
7279 |
+
function rebaseHist(hist, change) {
|
7280 |
+
var from = change.from.line, to = change.to.line, diff = change.text.length - (to - from) - 1;
|
7281 |
+
rebaseHistArray(hist.done, from, to, diff);
|
7282 |
+
rebaseHistArray(hist.undone, from, to, diff);
|
7283 |
+
}
|
7284 |
+
|
7285 |
+
// EVENT UTILITIES
|
7286 |
+
|
7287 |
+
// Due to the fact that we still support jurassic IE versions, some
|
7288 |
+
// compatibility wrappers are needed.
|
7289 |
+
|
7290 |
+
var e_preventDefault = CodeMirror.e_preventDefault = function(e) {
|
7291 |
+
if (e.preventDefault) e.preventDefault();
|
7292 |
+
else e.returnValue = false;
|
7293 |
+
};
|
7294 |
+
var e_stopPropagation = CodeMirror.e_stopPropagation = function(e) {
|
7295 |
+
if (e.stopPropagation) e.stopPropagation();
|
7296 |
+
else e.cancelBubble = true;
|
7297 |
+
};
|
7298 |
+
function e_defaultPrevented(e) {
|
7299 |
+
return e.defaultPrevented != null ? e.defaultPrevented : e.returnValue == false;
|
7300 |
+
}
|
7301 |
+
var e_stop = CodeMirror.e_stop = function(e) {e_preventDefault(e); e_stopPropagation(e);};
|
7302 |
+
|
7303 |
+
function e_target(e) {return e.target || e.srcElement;}
|
7304 |
+
function e_button(e) {
|
7305 |
+
var b = e.which;
|
7306 |
+
if (b == null) {
|
7307 |
+
if (e.button & 1) b = 1;
|
7308 |
+
else if (e.button & 2) b = 3;
|
7309 |
+
else if (e.button & 4) b = 2;
|
7310 |
+
}
|
7311 |
+
if (mac && e.ctrlKey && b == 1) b = 3;
|
7312 |
+
return b;
|
7313 |
+
}
|
7314 |
+
|
7315 |
+
// EVENT HANDLING
|
7316 |
+
|
7317 |
+
// Lightweight event framework. on/off also work on DOM nodes,
|
7318 |
+
// registering native DOM handlers.
|
7319 |
+
|
7320 |
+
var on = CodeMirror.on = function(emitter, type, f) {
|
7321 |
+
if (emitter.addEventListener)
|
7322 |
+
emitter.addEventListener(type, f, false);
|
7323 |
+
else if (emitter.attachEvent)
|
7324 |
+
emitter.attachEvent("on" + type, f);
|
7325 |
+
else {
|
7326 |
+
var map = emitter._handlers || (emitter._handlers = {});
|
7327 |
+
var arr = map[type] || (map[type] = []);
|
7328 |
+
arr.push(f);
|
7329 |
+
}
|
7330 |
+
};
|
7331 |
+
|
7332 |
+
var off = CodeMirror.off = function(emitter, type, f) {
|
7333 |
+
if (emitter.removeEventListener)
|
7334 |
+
emitter.removeEventListener(type, f, false);
|
7335 |
+
else if (emitter.detachEvent)
|
7336 |
+
emitter.detachEvent("on" + type, f);
|
7337 |
+
else {
|
7338 |
+
var arr = emitter._handlers && emitter._handlers[type];
|
7339 |
+
if (!arr) return;
|
7340 |
+
for (var i = 0; i < arr.length; ++i)
|
7341 |
+
if (arr[i] == f) { arr.splice(i, 1); break; }
|
7342 |
+
}
|
7343 |
+
};
|
7344 |
+
|
7345 |
+
var signal = CodeMirror.signal = function(emitter, type /*, values...*/) {
|
7346 |
+
var arr = emitter._handlers && emitter._handlers[type];
|
7347 |
+
if (!arr) return;
|
7348 |
+
var args = Array.prototype.slice.call(arguments, 2);
|
7349 |
+
for (var i = 0; i < arr.length; ++i) arr[i].apply(null, args);
|
7350 |
+
};
|
7351 |
+
|
7352 |
+
var orphanDelayedCallbacks = null;
|
7353 |
+
|
7354 |
+
// Often, we want to signal events at a point where we are in the
|
7355 |
+
// middle of some work, but don't want the handler to start calling
|
7356 |
+
// other methods on the editor, which might be in an inconsistent
|
7357 |
+
// state or simply not expect any other events to happen.
|
7358 |
+
// signalLater looks whether there are any handlers, and schedules
|
7359 |
+
// them to be executed when the last operation ends, or, if no
|
7360 |
+
// operation is active, when a timeout fires.
|
7361 |
+
function signalLater(emitter, type /*, values...*/) {
|
7362 |
+
var arr = emitter._handlers && emitter._handlers[type];
|
7363 |
+
if (!arr) return;
|
7364 |
+
var args = Array.prototype.slice.call(arguments, 2), list;
|
7365 |
+
if (operationGroup) {
|
7366 |
+
list = operationGroup.delayedCallbacks;
|
7367 |
+
} else if (orphanDelayedCallbacks) {
|
7368 |
+
list = orphanDelayedCallbacks;
|
7369 |
+
} else {
|
7370 |
+
list = orphanDelayedCallbacks = [];
|
7371 |
+
setTimeout(fireOrphanDelayed, 0);
|
7372 |
+
}
|
7373 |
+
function bnd(f) {return function(){f.apply(null, args);};};
|
7374 |
+
for (var i = 0; i < arr.length; ++i)
|
7375 |
+
list.push(bnd(arr[i]));
|
7376 |
+
}
|
7377 |
+
|
7378 |
+
function fireOrphanDelayed() {
|
7379 |
+
var delayed = orphanDelayedCallbacks;
|
7380 |
+
orphanDelayedCallbacks = null;
|
7381 |
+
for (var i = 0; i < delayed.length; ++i) delayed[i]();
|
7382 |
+
}
|
7383 |
+
|
7384 |
+
// The DOM events that CodeMirror handles can be overridden by
|
7385 |
+
// registering a (non-DOM) handler on the editor for the event name,
|
7386 |
+
// and preventDefault-ing the event in that handler.
|
7387 |
+
function signalDOMEvent(cm, e, override) {
|
7388 |
+
if (typeof e == "string")
|
7389 |
+
e = {type: e, preventDefault: function() { this.defaultPrevented = true; }};
|
7390 |
+
signal(cm, override || e.type, cm, e);
|
7391 |
+
return e_defaultPrevented(e) || e.codemirrorIgnore;
|
7392 |
+
}
|
7393 |
+
|
7394 |
+
function signalCursorActivity(cm) {
|
7395 |
+
var arr = cm._handlers && cm._handlers.cursorActivity;
|
7396 |
+
if (!arr) return;
|
7397 |
+
var set = cm.curOp.cursorActivityHandlers || (cm.curOp.cursorActivityHandlers = []);
|
7398 |
+
for (var i = 0; i < arr.length; ++i) if (indexOf(set, arr[i]) == -1)
|
7399 |
+
set.push(arr[i]);
|
7400 |
+
}
|
7401 |
+
|
7402 |
+
function hasHandler(emitter, type) {
|
7403 |
+
var arr = emitter._handlers && emitter._handlers[type];
|
7404 |
+
return arr && arr.length > 0;
|
7405 |
+
}
|
7406 |
+
|
7407 |
+
// Add on and off methods to a constructor's prototype, to make
|
7408 |
+
// registering events on such objects more convenient.
|
7409 |
+
function eventMixin(ctor) {
|
7410 |
+
ctor.prototype.on = function(type, f) {on(this, type, f);};
|
7411 |
+
ctor.prototype.off = function(type, f) {off(this, type, f);};
|
7412 |
+
}
|
7413 |
+
|
7414 |
+
// MISC UTILITIES
|
7415 |
+
|
7416 |
+
// Number of pixels added to scroller and sizer to hide scrollbar
|
7417 |
+
var scrollerGap = 30;
|
7418 |
+
|
7419 |
+
// Returned or thrown by various protocols to signal 'I'm not
|
7420 |
+
// handling this'.
|
7421 |
+
var Pass = CodeMirror.Pass = {toString: function(){return "CodeMirror.Pass";}};
|
7422 |
+
|
7423 |
+
// Reused option objects for setSelection & friends
|
7424 |
+
var sel_dontScroll = {scroll: false}, sel_mouse = {origin: "*mouse"}, sel_move = {origin: "+move"};
|
7425 |
+
|
7426 |
+
function Delayed() {this.id = null;}
|
7427 |
+
Delayed.prototype.set = function(ms, f) {
|
7428 |
+
clearTimeout(this.id);
|
7429 |
+
this.id = setTimeout(f, ms);
|
7430 |
+
};
|
7431 |
+
|
7432 |
+
// Counts the column offset in a string, taking tabs into account.
|
7433 |
+
// Used mostly to find indentation.
|
7434 |
+
var countColumn = CodeMirror.countColumn = function(string, end, tabSize, startIndex, startValue) {
|
7435 |
+
if (end == null) {
|
7436 |
+
end = string.search(/[^\s\u00a0]/);
|
7437 |
+
if (end == -1) end = string.length;
|
7438 |
+
}
|
7439 |
+
for (var i = startIndex || 0, n = startValue || 0;;) {
|
7440 |
+
var nextTab = string.indexOf("\t", i);
|
7441 |
+
if (nextTab < 0 || nextTab >= end)
|
7442 |
+
return n + (end - i);
|
7443 |
+
n += nextTab - i;
|
7444 |
+
n += tabSize - (n % tabSize);
|
7445 |
+
i = nextTab + 1;
|
7446 |
+
}
|
7447 |
+
};
|
7448 |
+
|
7449 |
+
// The inverse of countColumn -- find the offset that corresponds to
|
7450 |
+
// a particular column.
|
7451 |
+
function findColumn(string, goal, tabSize) {
|
7452 |
+
for (var pos = 0, col = 0;;) {
|
7453 |
+
var nextTab = string.indexOf("\t", pos);
|
7454 |
+
if (nextTab == -1) nextTab = string.length;
|
7455 |
+
var skipped = nextTab - pos;
|
7456 |
+
if (nextTab == string.length || col + skipped >= goal)
|
7457 |
+
return pos + Math.min(skipped, goal - col);
|
7458 |
+
col += nextTab - pos;
|
7459 |
+
col += tabSize - (col % tabSize);
|
7460 |
+
pos = nextTab + 1;
|
7461 |
+
if (col >= goal) return pos;
|
7462 |
+
}
|
7463 |
+
}
|
7464 |
+
|
7465 |
+
var spaceStrs = [""];
|
7466 |
+
function spaceStr(n) {
|
7467 |
+
while (spaceStrs.length <= n)
|
7468 |
+
spaceStrs.push(lst(spaceStrs) + " ");
|
7469 |
+
return spaceStrs[n];
|
7470 |
+
}
|
7471 |
+
|
7472 |
+
function lst(arr) { return arr[arr.length-1]; }
|
7473 |
+
|
7474 |
+
var selectInput = function(node) { node.select(); };
|
7475 |
+
if (ios) // Mobile Safari apparently has a bug where select() is broken.
|
7476 |
+
selectInput = function(node) { node.selectionStart = 0; node.selectionEnd = node.value.length; };
|
7477 |
+
else if (ie) // Suppress mysterious IE10 errors
|
7478 |
+
selectInput = function(node) { try { node.select(); } catch(_e) {} };
|
7479 |
+
|
7480 |
+
function indexOf(array, elt) {
|
7481 |
+
for (var i = 0; i < array.length; ++i)
|
7482 |
+
if (array[i] == elt) return i;
|
7483 |
+
return -1;
|
7484 |
+
}
|
7485 |
+
function map(array, f) {
|
7486 |
+
var out = [];
|
7487 |
+
for (var i = 0; i < array.length; i++) out[i] = f(array[i], i);
|
7488 |
+
return out;
|
7489 |
+
}
|
7490 |
+
|
7491 |
+
function createObj(base, props) {
|
7492 |
+
var inst;
|
7493 |
+
if (Object.create) {
|
7494 |
+
inst = Object.create(base);
|
7495 |
+
} else {
|
7496 |
+
var ctor = function() {};
|
7497 |
+
ctor.prototype = base;
|
7498 |
+
inst = new ctor();
|
7499 |
+
}
|
7500 |
+
if (props) copyObj(props, inst);
|
7501 |
+
return inst;
|
7502 |
+
};
|
7503 |
+
|
7504 |
+
function copyObj(obj, target, overwrite) {
|
7505 |
+
if (!target) target = {};
|
7506 |
+
for (var prop in obj)
|
7507 |
+
if (obj.hasOwnProperty(prop) && (overwrite !== false || !target.hasOwnProperty(prop)))
|
7508 |
+
target[prop] = obj[prop];
|
7509 |
+
return target;
|
7510 |
+
}
|
7511 |
+
|
7512 |
+
function bind(f) {
|
7513 |
+
var args = Array.prototype.slice.call(arguments, 1);
|
7514 |
+
return function(){return f.apply(null, args);};
|
7515 |
+
}
|
7516 |
+
|
7517 |
+
var nonASCIISingleCaseWordChar = /[\u00df\u0590-\u05f4\u0600-\u06ff\u3040-\u309f\u30a0-\u30ff\u3400-\u4db5\u4e00-\u9fcc\uac00-\ud7af]/;
|
7518 |
+
var isWordCharBasic = CodeMirror.isWordChar = function(ch) {
|
7519 |
+
return /\w/.test(ch) || ch > "\x80" &&
|
7520 |
+
(ch.toUpperCase() != ch.toLowerCase() || nonASCIISingleCaseWordChar.test(ch));
|
7521 |
+
};
|
7522 |
+
function isWordChar(ch, helper) {
|
7523 |
+
if (!helper) return isWordCharBasic(ch);
|
7524 |
+
if (helper.source.indexOf("\\w") > -1 && isWordCharBasic(ch)) return true;
|
7525 |
+
return helper.test(ch);
|
7526 |
+
}
|
7527 |
+
|
7528 |
+
function isEmpty(obj) {
|
7529 |
+
for (var n in obj) if (obj.hasOwnProperty(n) && obj[n]) return false;
|
7530 |
+
return true;
|
7531 |
+
}
|
7532 |
+
|
7533 |
+
// Extending unicode characters. A series of a non-extending char +
|
7534 |
+
// any number of extending chars is treated as a single unit as far
|
7535 |
+
// as editing and measuring is concerned. This is not fully correct,
|
7536 |
+
// since some scripts/fonts/browsers also treat other configurations
|
7537 |
+
// of code points as a group.
|
7538 |
+
var extendingChars = /[\u0300-\u036f\u0483-\u0489\u0591-\u05bd\u05bf\u05c1\u05c2\u05c4\u05c5\u05c7\u0610-\u061a\u064b-\u065e\u0670\u06d6-\u06dc\u06de-\u06e4\u06e7\u06e8\u06ea-\u06ed\u0711\u0730-\u074a\u07a6-\u07b0\u07eb-\u07f3\u0816-\u0819\u081b-\u0823\u0825-\u0827\u0829-\u082d\u0900-\u0902\u093c\u0941-\u0948\u094d\u0951-\u0955\u0962\u0963\u0981\u09bc\u09be\u09c1-\u09c4\u09cd\u09d7\u09e2\u09e3\u0a01\u0a02\u0a3c\u0a41\u0a42\u0a47\u0a48\u0a4b-\u0a4d\u0a51\u0a70\u0a71\u0a75\u0a81\u0a82\u0abc\u0ac1-\u0ac5\u0ac7\u0ac8\u0acd\u0ae2\u0ae3\u0b01\u0b3c\u0b3e\u0b3f\u0b41-\u0b44\u0b4d\u0b56\u0b57\u0b62\u0b63\u0b82\u0bbe\u0bc0\u0bcd\u0bd7\u0c3e-\u0c40\u0c46-\u0c48\u0c4a-\u0c4d\u0c55\u0c56\u0c62\u0c63\u0cbc\u0cbf\u0cc2\u0cc6\u0ccc\u0ccd\u0cd5\u0cd6\u0ce2\u0ce3\u0d3e\u0d41-\u0d44\u0d4d\u0d57\u0d62\u0d63\u0dca\u0dcf\u0dd2-\u0dd4\u0dd6\u0ddf\u0e31\u0e34-\u0e3a\u0e47-\u0e4e\u0eb1\u0eb4-\u0eb9\u0ebb\u0ebc\u0ec8-\u0ecd\u0f18\u0f19\u0f35\u0f37\u0f39\u0f71-\u0f7e\u0f80-\u0f84\u0f86\u0f87\u0f90-\u0f97\u0f99-\u0fbc\u0fc6\u102d-\u1030\u1032-\u1037\u1039\u103a\u103d\u103e\u1058\u1059\u105e-\u1060\u1071-\u1074\u1082\u1085\u1086\u108d\u109d\u135f\u1712-\u1714\u1732-\u1734\u1752\u1753\u1772\u1773\u17b7-\u17bd\u17c6\u17c9-\u17d3\u17dd\u180b-\u180d\u18a9\u1920-\u1922\u1927\u1928\u1932\u1939-\u193b\u1a17\u1a18\u1a56\u1a58-\u1a5e\u1a60\u1a62\u1a65-\u1a6c\u1a73-\u1a7c\u1a7f\u1b00-\u1b03\u1b34\u1b36-\u1b3a\u1b3c\u1b42\u1b6b-\u1b73\u1b80\u1b81\u1ba2-\u1ba5\u1ba8\u1ba9\u1c2c-\u1c33\u1c36\u1c37\u1cd0-\u1cd2\u1cd4-\u1ce0\u1ce2-\u1ce8\u1ced\u1dc0-\u1de6\u1dfd-\u1dff\u200c\u200d\u20d0-\u20f0\u2cef-\u2cf1\u2de0-\u2dff\u302a-\u302f\u3099\u309a\ua66f-\ua672\ua67c\ua67d\ua6f0\ua6f1\ua802\ua806\ua80b\ua825\ua826\ua8c4\ua8e0-\ua8f1\ua926-\ua92d\ua947-\ua951\ua980-\ua982\ua9b3\ua9b6-\ua9b9\ua9bc\uaa29-\uaa2e\uaa31\uaa32\uaa35\uaa36\uaa43\uaa4c\uaab0\uaab2-\uaab4\uaab7\uaab8\uaabe\uaabf\uaac1\uabe5\uabe8\uabed\udc00-\udfff\ufb1e\ufe00-\ufe0f\ufe20-\ufe26\uff9e\uff9f]/;
|
7539 |
+
function isExtendingChar(ch) { return ch.charCodeAt(0) >= 768 && extendingChars.test(ch); }
|
7540 |
+
|
7541 |
+
// DOM UTILITIES
|
7542 |
+
|
7543 |
+
function elt(tag, content, className, style) {
|
7544 |
+
var e = document.createElement(tag);
|
7545 |
+
if (className) e.className = className;
|
7546 |
+
if (style) e.style.cssText = style;
|
7547 |
+
if (typeof content == "string") e.appendChild(document.createTextNode(content));
|
7548 |
+
else if (content) for (var i = 0; i < content.length; ++i) e.appendChild(content[i]);
|
7549 |
+
return e;
|
7550 |
+
}
|
7551 |
+
|
7552 |
+
var range;
|
7553 |
+
if (document.createRange) range = function(node, start, end) {
|
7554 |
+
var r = document.createRange();
|
7555 |
+
r.setEnd(node, end);
|
7556 |
+
r.setStart(node, start);
|
7557 |
+
return r;
|
7558 |
+
};
|
7559 |
+
else range = function(node, start, end) {
|
7560 |
+
var r = document.body.createTextRange();
|
7561 |
+
try { r.moveToElementText(node.parentNode); }
|
7562 |
+
catch(e) { return r; }
|
7563 |
+
r.collapse(true);
|
7564 |
+
r.moveEnd("character", end);
|
7565 |
+
r.moveStart("character", start);
|
7566 |
+
return r;
|
7567 |
+
};
|
7568 |
+
|
7569 |
+
function removeChildren(e) {
|
7570 |
+
for (var count = e.childNodes.length; count > 0; --count)
|
7571 |
+
e.removeChild(e.firstChild);
|
7572 |
+
return e;
|
7573 |
+
}
|
7574 |
+
|
7575 |
+
function removeChildrenAndAdd(parent, e) {
|
7576 |
+
return removeChildren(parent).appendChild(e);
|
7577 |
+
}
|
7578 |
+
|
7579 |
+
function contains(parent, child) {
|
7580 |
+
if (parent.contains)
|
7581 |
+
return parent.contains(child);
|
7582 |
+
while (child = child.parentNode)
|
7583 |
+
if (child == parent) return true;
|
7584 |
+
}
|
7585 |
+
|
7586 |
+
function activeElt() { return document.activeElement; }
|
7587 |
+
// Older versions of IE throws unspecified error when touching
|
7588 |
+
// document.activeElement in some cases (during loading, in iframe)
|
7589 |
+
if (ie && ie_version < 11) activeElt = function() {
|
7590 |
+
try { return document.activeElement; }
|
7591 |
+
catch(e) { return document.body; }
|
7592 |
+
};
|
7593 |
+
|
7594 |
+
function classTest(cls) { return new RegExp("(^|\\s)" + cls + "(?:$|\\s)\\s*"); }
|
7595 |
+
var rmClass = CodeMirror.rmClass = function(node, cls) {
|
7596 |
+
var current = node.className;
|
7597 |
+
var match = classTest(cls).exec(current);
|
7598 |
+
if (match) {
|
7599 |
+
var after = current.slice(match.index + match[0].length);
|
7600 |
+
node.className = current.slice(0, match.index) + (after ? match[1] + after : "");
|
7601 |
+
}
|
7602 |
+
};
|
7603 |
+
var addClass = CodeMirror.addClass = function(node, cls) {
|
7604 |
+
var current = node.className;
|
7605 |
+
if (!classTest(cls).test(current)) node.className += (current ? " " : "") + cls;
|
7606 |
+
};
|
7607 |
+
function joinClasses(a, b) {
|
7608 |
+
var as = a.split(" ");
|
7609 |
+
for (var i = 0; i < as.length; i++)
|
7610 |
+
if (as[i] && !classTest(as[i]).test(b)) b += " " + as[i];
|
7611 |
+
return b;
|
7612 |
+
}
|
7613 |
+
|
7614 |
+
// WINDOW-WIDE EVENTS
|
7615 |
+
|
7616 |
+
// These must be handled carefully, because naively registering a
|
7617 |
+
// handler for each editor will cause the editors to never be
|
7618 |
+
// garbage collected.
|
7619 |
+
|
7620 |
+
function forEachCodeMirror(f) {
|
7621 |
+
if (!document.body.getElementsByClassName) return;
|
7622 |
+
var byClass = document.body.getElementsByClassName("CodeMirror");
|
7623 |
+
for (var i = 0; i < byClass.length; i++) {
|
7624 |
+
var cm = byClass[i].CodeMirror;
|
7625 |
+
if (cm) f(cm);
|
7626 |
+
}
|
7627 |
+
}
|
7628 |
+
|
7629 |
+
var globalsRegistered = false;
|
7630 |
+
function ensureGlobalHandlers() {
|
7631 |
+
if (globalsRegistered) return;
|
7632 |
+
registerGlobalHandlers();
|
7633 |
+
globalsRegistered = true;
|
7634 |
+
}
|
7635 |
+
function registerGlobalHandlers() {
|
7636 |
+
// When the window resizes, we need to refresh active editors.
|
7637 |
+
var resizeTimer;
|
7638 |
+
on(window, "resize", function() {
|
7639 |
+
if (resizeTimer == null) resizeTimer = setTimeout(function() {
|
7640 |
+
resizeTimer = null;
|
7641 |
+
forEachCodeMirror(onResize);
|
7642 |
+
}, 100);
|
7643 |
+
});
|
7644 |
+
// When the window loses focus, we want to show the editor as blurred
|
7645 |
+
on(window, "blur", function() {
|
7646 |
+
forEachCodeMirror(onBlur);
|
7647 |
+
});
|
7648 |
+
}
|
7649 |
+
|
7650 |
+
// FEATURE DETECTION
|
7651 |
+
|
7652 |
+
// Detect drag-and-drop
|
7653 |
+
var dragAndDrop = function() {
|
7654 |
+
// There is *some* kind of drag-and-drop support in IE6-8, but I
|
7655 |
+
// couldn't get it to work yet.
|
7656 |
+
if (ie && ie_version < 9) return false;
|
7657 |
+
var div = elt('div');
|
7658 |
+
return "draggable" in div || "dragDrop" in div;
|
7659 |
+
}();
|
7660 |
+
|
7661 |
+
var zwspSupported;
|
7662 |
+
function zeroWidthElement(measure) {
|
7663 |
+
if (zwspSupported == null) {
|
7664 |
+
var test = elt("span", "\u200b");
|
7665 |
+
removeChildrenAndAdd(measure, elt("span", [test, document.createTextNode("x")]));
|
7666 |
+
if (measure.firstChild.offsetHeight != 0)
|
7667 |
+
zwspSupported = test.offsetWidth <= 1 && test.offsetHeight > 2 && !(ie && ie_version < 8);
|
7668 |
+
}
|
7669 |
+
if (zwspSupported) return elt("span", "\u200b");
|
7670 |
+
else return elt("span", "\u00a0", null, "display: inline-block; width: 1px; margin-right: -1px");
|
7671 |
+
}
|
7672 |
+
|
7673 |
+
// Feature-detect IE's crummy client rect reporting for bidi text
|
7674 |
+
var badBidiRects;
|
7675 |
+
function hasBadBidiRects(measure) {
|
7676 |
+
if (badBidiRects != null) return badBidiRects;
|
7677 |
+
var txt = removeChildrenAndAdd(measure, document.createTextNode("A\u062eA"));
|
7678 |
+
var r0 = range(txt, 0, 1).getBoundingClientRect();
|
7679 |
+
if (!r0 || r0.left == r0.right) return false; // Safari returns null in some cases (#2780)
|
7680 |
+
var r1 = range(txt, 1, 2).getBoundingClientRect();
|
7681 |
+
return badBidiRects = (r1.right - r0.right < 3);
|
7682 |
+
}
|
7683 |
+
|
7684 |
+
// See if "".split is the broken IE version, if so, provide an
|
7685 |
+
// alternative way to split lines.
|
7686 |
+
var splitLines = CodeMirror.splitLines = "\n\nb".split(/\n/).length != 3 ? function(string) {
|
7687 |
+
var pos = 0, result = [], l = string.length;
|
7688 |
+
while (pos <= l) {
|
7689 |
+
var nl = string.indexOf("\n", pos);
|
7690 |
+
if (nl == -1) nl = string.length;
|
7691 |
+
var line = string.slice(pos, string.charAt(nl - 1) == "\r" ? nl - 1 : nl);
|
7692 |
+
var rt = line.indexOf("\r");
|
7693 |
+
if (rt != -1) {
|
7694 |
+
result.push(line.slice(0, rt));
|
7695 |
+
pos += rt + 1;
|
7696 |
+
} else {
|
7697 |
+
result.push(line);
|
7698 |
+
pos = nl + 1;
|
7699 |
+
}
|
7700 |
+
}
|
7701 |
+
return result;
|
7702 |
+
} : function(string){return string.split(/\r\n?|\n/);};
|
7703 |
+
|
7704 |
+
var hasSelection = window.getSelection ? function(te) {
|
7705 |
+
try { return te.selectionStart != te.selectionEnd; }
|
7706 |
+
catch(e) { return false; }
|
7707 |
+
} : function(te) {
|
7708 |
+
try {var range = te.ownerDocument.selection.createRange();}
|
7709 |
+
catch(e) {}
|
7710 |
+
if (!range || range.parentElement() != te) return false;
|
7711 |
+
return range.compareEndPoints("StartToEnd", range) != 0;
|
7712 |
+
};
|
7713 |
+
|
7714 |
+
var hasCopyEvent = (function() {
|
7715 |
+
var e = elt("div");
|
7716 |
+
if ("oncopy" in e) return true;
|
7717 |
+
e.setAttribute("oncopy", "return;");
|
7718 |
+
return typeof e.oncopy == "function";
|
7719 |
+
})();
|
7720 |
+
|
7721 |
+
var badZoomedRects = null;
|
7722 |
+
function hasBadZoomedRects(measure) {
|
7723 |
+
if (badZoomedRects != null) return badZoomedRects;
|
7724 |
+
var node = removeChildrenAndAdd(measure, elt("span", "x"));
|
7725 |
+
var normal = node.getBoundingClientRect();
|
7726 |
+
var fromRange = range(node, 0, 1).getBoundingClientRect();
|
7727 |
+
return badZoomedRects = Math.abs(normal.left - fromRange.left) > 1;
|
7728 |
+
}
|
7729 |
+
|
7730 |
+
// KEY NAMES
|
7731 |
+
|
7732 |
+
var keyNames = {3: "Enter", 8: "Backspace", 9: "Tab", 13: "Enter", 16: "Shift", 17: "Ctrl", 18: "Alt",
|
7733 |
+
19: "Pause", 20: "CapsLock", 27: "Esc", 32: "Space", 33: "PageUp", 34: "PageDown", 35: "End",
|
7734 |
+
36: "Home", 37: "Left", 38: "Up", 39: "Right", 40: "Down", 44: "PrintScrn", 45: "Insert",
|
7735 |
+
46: "Delete", 59: ";", 61: "=", 91: "Mod", 92: "Mod", 93: "Mod", 107: "=", 109: "-", 127: "Delete",
|
7736 |
+
173: "-", 186: ";", 187: "=", 188: ",", 189: "-", 190: ".", 191: "/", 192: "`", 219: "[", 220: "\\",
|
7737 |
+
221: "]", 222: "'", 63232: "Up", 63233: "Down", 63234: "Left", 63235: "Right", 63272: "Delete",
|
7738 |
+
63273: "Home", 63275: "End", 63276: "PageUp", 63277: "PageDown", 63302: "Insert"};
|
7739 |
+
CodeMirror.keyNames = keyNames;
|
7740 |
+
(function() {
|
7741 |
+
// Number keys
|
7742 |
+
for (var i = 0; i < 10; i++) keyNames[i + 48] = keyNames[i + 96] = String(i);
|
7743 |
+
// Alphabetic keys
|
7744 |
+
for (var i = 65; i <= 90; i++) keyNames[i] = String.fromCharCode(i);
|
7745 |
+
// Function keys
|
7746 |
+
for (var i = 1; i <= 12; i++) keyNames[i + 111] = keyNames[i + 63235] = "F" + i;
|
7747 |
+
})();
|
7748 |
+
|
7749 |
+
// BIDI HELPERS
|
7750 |
+
|
7751 |
+
function iterateBidiSections(order, from, to, f) {
|
7752 |
+
if (!order) return f(from, to, "ltr");
|
7753 |
+
var found = false;
|
7754 |
+
for (var i = 0; i < order.length; ++i) {
|
7755 |
+
var part = order[i];
|
7756 |
+
if (part.from < to && part.to > from || from == to && part.to == from) {
|
7757 |
+
f(Math.max(part.from, from), Math.min(part.to, to), part.level == 1 ? "rtl" : "ltr");
|
7758 |
+
found = true;
|
7759 |
+
}
|
7760 |
+
}
|
7761 |
+
if (!found) f(from, to, "ltr");
|
7762 |
+
}
|
7763 |
+
|
7764 |
+
function bidiLeft(part) { return part.level % 2 ? part.to : part.from; }
|
7765 |
+
function bidiRight(part) { return part.level % 2 ? part.from : part.to; }
|
7766 |
+
|
7767 |
+
function lineLeft(line) { var order = getOrder(line); return order ? bidiLeft(order[0]) : 0; }
|
7768 |
+
function lineRight(line) {
|
7769 |
+
var order = getOrder(line);
|
7770 |
+
if (!order) return line.text.length;
|
7771 |
+
return bidiRight(lst(order));
|
7772 |
+
}
|
7773 |
+
|
7774 |
+
function lineStart(cm, lineN) {
|
7775 |
+
var line = getLine(cm.doc, lineN);
|
7776 |
+
var visual = visualLine(line);
|
7777 |
+
if (visual != line) lineN = lineNo(visual);
|
7778 |
+
var order = getOrder(visual);
|
7779 |
+
var ch = !order ? 0 : order[0].level % 2 ? lineRight(visual) : lineLeft(visual);
|
7780 |
+
return Pos(lineN, ch);
|
7781 |
+
}
|
7782 |
+
function lineEnd(cm, lineN) {
|
7783 |
+
var merged, line = getLine(cm.doc, lineN);
|
7784 |
+
while (merged = collapsedSpanAtEnd(line)) {
|
7785 |
+
line = merged.find(1, true).line;
|
7786 |
+
lineN = null;
|
7787 |
+
}
|
7788 |
+
var order = getOrder(line);
|
7789 |
+
var ch = !order ? line.text.length : order[0].level % 2 ? lineLeft(line) : lineRight(line);
|
7790 |
+
return Pos(lineN == null ? lineNo(line) : lineN, ch);
|
7791 |
+
}
|
7792 |
+
function lineStartSmart(cm, pos) {
|
7793 |
+
var start = lineStart(cm, pos.line);
|
7794 |
+
var line = getLine(cm.doc, start.line);
|
7795 |
+
var order = getOrder(line);
|
7796 |
+
if (!order || order[0].level == 0) {
|
7797 |
+
var firstNonWS = Math.max(0, line.text.search(/\S/));
|
7798 |
+
var inWS = pos.line == start.line && pos.ch <= firstNonWS && pos.ch;
|
7799 |
+
return Pos(start.line, inWS ? 0 : firstNonWS);
|
7800 |
+
}
|
7801 |
+
return start;
|
7802 |
+
}
|
7803 |
+
|
7804 |
+
function compareBidiLevel(order, a, b) {
|
7805 |
+
var linedir = order[0].level;
|
7806 |
+
if (a == linedir) return true;
|
7807 |
+
if (b == linedir) return false;
|
7808 |
+
return a < b;
|
7809 |
+
}
|
7810 |
+
var bidiOther;
|
7811 |
+
function getBidiPartAt(order, pos) {
|
7812 |
+
bidiOther = null;
|
7813 |
+
for (var i = 0, found; i < order.length; ++i) {
|
7814 |
+
var cur = order[i];
|
7815 |
+
if (cur.from < pos && cur.to > pos) return i;
|
7816 |
+
if ((cur.from == pos || cur.to == pos)) {
|
7817 |
+
if (found == null) {
|
7818 |
+
found = i;
|
7819 |
+
} else if (compareBidiLevel(order, cur.level, order[found].level)) {
|
7820 |
+
if (cur.from != cur.to) bidiOther = found;
|
7821 |
+
return i;
|
7822 |
+
} else {
|
7823 |
+
if (cur.from != cur.to) bidiOther = i;
|
7824 |
+
return found;
|
7825 |
+
}
|
7826 |
+
}
|
7827 |
+
}
|
7828 |
+
return found;
|
7829 |
+
}
|
7830 |
+
|
7831 |
+
function moveInLine(line, pos, dir, byUnit) {
|
7832 |
+
if (!byUnit) return pos + dir;
|
7833 |
+
do pos += dir;
|
7834 |
+
while (pos > 0 && isExtendingChar(line.text.charAt(pos)));
|
7835 |
+
return pos;
|
7836 |
+
}
|
7837 |
+
|
7838 |
+
// This is needed in order to move 'visually' through bi-directional
|
7839 |
+
// text -- i.e., pressing left should make the cursor go left, even
|
7840 |
+
// when in RTL text. The tricky part is the 'jumps', where RTL and
|
7841 |
+
// LTR text touch each other. This often requires the cursor offset
|
7842 |
+
// to move more than one unit, in order to visually move one unit.
|
7843 |
+
function moveVisually(line, start, dir, byUnit) {
|
7844 |
+
var bidi = getOrder(line);
|
7845 |
+
if (!bidi) return moveLogically(line, start, dir, byUnit);
|
7846 |
+
var pos = getBidiPartAt(bidi, start), part = bidi[pos];
|
7847 |
+
var target = moveInLine(line, start, part.level % 2 ? -dir : dir, byUnit);
|
7848 |
+
|
7849 |
+
for (;;) {
|
7850 |
+
if (target > part.from && target < part.to) return target;
|
7851 |
+
if (target == part.from || target == part.to) {
|
7852 |
+
if (getBidiPartAt(bidi, target) == pos) return target;
|
7853 |
+
part = bidi[pos += dir];
|
7854 |
+
return (dir > 0) == part.level % 2 ? part.to : part.from;
|
7855 |
+
} else {
|
7856 |
+
part = bidi[pos += dir];
|
7857 |
+
if (!part) return null;
|
7858 |
+
if ((dir > 0) == part.level % 2)
|
7859 |
+
target = moveInLine(line, part.to, -1, byUnit);
|
7860 |
+
else
|
7861 |
+
target = moveInLine(line, part.from, 1, byUnit);
|
7862 |
+
}
|
7863 |
+
}
|
7864 |
+
}
|
7865 |
+
|
7866 |
+
function moveLogically(line, start, dir, byUnit) {
|
7867 |
+
var target = start + dir;
|
7868 |
+
if (byUnit) while (target > 0 && isExtendingChar(line.text.charAt(target))) target += dir;
|
7869 |
+
return target < 0 || target > line.text.length ? null : target;
|
7870 |
+
}
|
7871 |
+
|
7872 |
+
// Bidirectional ordering algorithm
|
7873 |
+
// See http://unicode.org/reports/tr9/tr9-13.html for the algorithm
|
7874 |
+
// that this (partially) implements.
|
7875 |
+
|
7876 |
+
// One-char codes used for character types:
|
7877 |
+
// L (L): Left-to-Right
|
7878 |
+
// R (R): Right-to-Left
|
7879 |
+
// r (AL): Right-to-Left Arabic
|
7880 |
+
// 1 (EN): European Number
|
7881 |
+
// + (ES): European Number Separator
|
7882 |
+
// % (ET): European Number Terminator
|
7883 |
+
// n (AN): Arabic Number
|
7884 |
+
// , (CS): Common Number Separator
|
7885 |
+
// m (NSM): Non-Spacing Mark
|
7886 |
+
// b (BN): Boundary Neutral
|
7887 |
+
// s (B): Paragraph Separator
|
7888 |
+
// t (S): Segment Separator
|
7889 |
+
// w (WS): Whitespace
|
7890 |
+
// N (ON): Other Neutrals
|
7891 |
+
|
7892 |
+
// Returns null if characters are ordered as they appear
|
7893 |
+
// (left-to-right), or an array of sections ({from, to, level}
|
7894 |
+
// objects) in the order in which they occur visually.
|
7895 |
+
var bidiOrdering = (function() {
|
7896 |
+
// Character types for codepoints 0 to 0xff
|
7897 |
+
var lowTypes = "bbbbbbbbbtstwsbbbbbbbbbbbbbbssstwNN%%%NNNNNN,N,N1111111111NNNNNNNLLLLLLLLLLLLLLLLLLLLLLLLLLNNNNNNLLLLLLLLLLLLLLLLLLLLLLLLLLNNNNbbbbbbsbbbbbbbbbbbbbbbbbbbbbbbbbb,N%%%%NNNNLNNNNN%%11NLNNN1LNNNNNLLLLLLLLLLLLLLLLLLLLLLLNLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLN";
|
7898 |
+
// Character types for codepoints 0x600 to 0x6ff
|
7899 |
+
var arabicTypes = "rrrrrrrrrrrr,rNNmmmmmmrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrmmmmmmmmmmmmmmrrrrrrrnnnnnnnnnn%nnrrrmrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrmmmmmmmmmmmmmmmmmmmNmmmm";
|
7900 |
+
function charType(code) {
|
7901 |
+
if (code <= 0xf7) return lowTypes.charAt(code);
|
7902 |
+
else if (0x590 <= code && code <= 0x5f4) return "R";
|
7903 |
+
else if (0x600 <= code && code <= 0x6ed) return arabicTypes.charAt(code - 0x600);
|
7904 |
+
else if (0x6ee <= code && code <= 0x8ac) return "r";
|
7905 |
+
else if (0x2000 <= code && code <= 0x200b) return "w";
|
7906 |
+
else if (code == 0x200c) return "b";
|
7907 |
+
else return "L";
|
7908 |
+
}
|
7909 |
+
|
7910 |
+
var bidiRE = /[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac]/;
|
7911 |
+
var isNeutral = /[stwN]/, isStrong = /[LRr]/, countsAsLeft = /[Lb1n]/, countsAsNum = /[1n]/;
|
7912 |
+
// Browsers seem to always treat the boundaries of block elements as being L.
|
7913 |
+
var outerType = "L";
|
7914 |
+
|
7915 |
+
function BidiSpan(level, from, to) {
|
7916 |
+
this.level = level;
|
7917 |
+
this.from = from; this.to = to;
|
7918 |
+
}
|
7919 |
+
|
7920 |
+
return function(str) {
|
7921 |
+
if (!bidiRE.test(str)) return false;
|
7922 |
+
var len = str.length, types = [];
|
7923 |
+
for (var i = 0, type; i < len; ++i)
|
7924 |
+
types.push(type = charType(str.charCodeAt(i)));
|
7925 |
+
|
7926 |
+
// W1. Examine each non-spacing mark (NSM) in the level run, and
|
7927 |
+
// change the type of the NSM to the type of the previous
|
7928 |
+
// character. If the NSM is at the start of the level run, it will
|
7929 |
+
// get the type of sor.
|
7930 |
+
for (var i = 0, prev = outerType; i < len; ++i) {
|
7931 |
+
var type = types[i];
|
7932 |
+
if (type == "m") types[i] = prev;
|
7933 |
+
else prev = type;
|
7934 |
+
}
|
7935 |
+
|
7936 |
+
// W2. Search backwards from each instance of a European number
|
7937 |
+
// until the first strong type (R, L, AL, or sor) is found. If an
|
7938 |
+
// AL is found, change the type of the European number to Arabic
|
7939 |
+
// number.
|
7940 |
+
// W3. Change all ALs to R.
|
7941 |
+
for (var i = 0, cur = outerType; i < len; ++i) {
|
7942 |
+
var type = types[i];
|
7943 |
+
if (type == "1" && cur == "r") types[i] = "n";
|
7944 |
+
else if (isStrong.test(type)) { cur = type; if (type == "r") types[i] = "R"; }
|
7945 |
+
}
|
7946 |
+
|
7947 |
+
// W4. A single European separator between two European numbers
|
7948 |
+
// changes to a European number. A single common separator between
|
7949 |
+
// two numbers of the same type changes to that type.
|
7950 |
+
for (var i = 1, prev = types[0]; i < len - 1; ++i) {
|
7951 |
+
var type = types[i];
|
7952 |
+
if (type == "+" && prev == "1" && types[i+1] == "1") types[i] = "1";
|
7953 |
+
else if (type == "," && prev == types[i+1] &&
|
7954 |
+
(prev == "1" || prev == "n")) types[i] = prev;
|
7955 |
+
prev = type;
|
7956 |
+
}
|
7957 |
+
|
7958 |
+
// W5. A sequence of European terminators adjacent to European
|
7959 |
+
// numbers changes to all European numbers.
|
7960 |
+
// W6. Otherwise, separators and terminators change to Other
|
7961 |
+
// Neutral.
|
7962 |
+
for (var i = 0; i < len; ++i) {
|
7963 |
+
var type = types[i];
|
7964 |
+
if (type == ",") types[i] = "N";
|
7965 |
+
else if (type == "%") {
|
7966 |
+
for (var end = i + 1; end < len && types[end] == "%"; ++end) {}
|
7967 |
+
var replace = (i && types[i-1] == "!") || (end < len && types[end] == "1") ? "1" : "N";
|
7968 |
+
for (var j = i; j < end; ++j) types[j] = replace;
|
7969 |
+
i = end - 1;
|
7970 |
+
}
|
7971 |
+
}
|
7972 |
+
|
7973 |
+
// W7. Search backwards from each instance of a European number
|
7974 |
+
// until the first strong type (R, L, or sor) is found. If an L is
|
7975 |
+
// found, then change the type of the European number to L.
|
7976 |
+
for (var i = 0, cur = outerType; i < len; ++i) {
|
7977 |
+
var type = types[i];
|
7978 |
+
if (cur == "L" && type == "1") types[i] = "L";
|
7979 |
+
else if (isStrong.test(type)) cur = type;
|
7980 |
+
}
|
7981 |
+
|
7982 |
+
// N1. A sequence of neutrals takes the direction of the
|
7983 |
+
// surrounding strong text if the text on both sides has the same
|
7984 |
+
// direction. European and Arabic numbers act as if they were R in
|
7985 |
+
// terms of their influence on neutrals. Start-of-level-run (sor)
|
7986 |
+
// and end-of-level-run (eor) are used at level run boundaries.
|
7987 |
+
// N2. Any remaining neutrals take the embedding direction.
|
7988 |
+
for (var i = 0; i < len; ++i) {
|
7989 |
+
if (isNeutral.test(types[i])) {
|
7990 |
+
for (var end = i + 1; end < len && isNeutral.test(types[end]); ++end) {}
|
7991 |
+
var before = (i ? types[i-1] : outerType) == "L";
|
7992 |
+
var after = (end < len ? types[end] : outerType) == "L";
|
7993 |
+
var replace = before || after ? "L" : "R";
|
7994 |
+
for (var j = i; j < end; ++j) types[j] = replace;
|
7995 |
+
i = end - 1;
|
7996 |
+
}
|
7997 |
+
}
|
7998 |
+
|
7999 |
+
// Here we depart from the documented algorithm, in order to avoid
|
8000 |
+
// building up an actual levels array. Since there are only three
|
8001 |
+
// levels (0, 1, 2) in an implementation that doesn't take
|
8002 |
+
// explicit embedding into account, we can build up the order on
|
8003 |
+
// the fly, without following the level-based algorithm.
|
8004 |
+
var order = [], m;
|
8005 |
+
for (var i = 0; i < len;) {
|
8006 |
+
if (countsAsLeft.test(types[i])) {
|
8007 |
+
var start = i;
|
8008 |
+
for (++i; i < len && countsAsLeft.test(types[i]); ++i) {}
|
8009 |
+
order.push(new BidiSpan(0, start, i));
|
8010 |
+
} else {
|
8011 |
+
var pos = i, at = order.length;
|
8012 |
+
for (++i; i < len && types[i] != "L"; ++i) {}
|
8013 |
+
for (var j = pos; j < i;) {
|
8014 |
+
if (countsAsNum.test(types[j])) {
|
8015 |
+
if (pos < j) order.splice(at, 0, new BidiSpan(1, pos, j));
|
8016 |
+
var nstart = j;
|
8017 |
+
for (++j; j < i && countsAsNum.test(types[j]); ++j) {}
|
8018 |
+
order.splice(at, 0, new BidiSpan(2, nstart, j));
|
8019 |
+
pos = j;
|
8020 |
+
} else ++j;
|
8021 |
+
}
|
8022 |
+
if (pos < i) order.splice(at, 0, new BidiSpan(1, pos, i));
|
8023 |
+
}
|
8024 |
+
}
|
8025 |
+
if (order[0].level == 1 && (m = str.match(/^\s+/))) {
|
8026 |
+
order[0].from = m[0].length;
|
8027 |
+
order.unshift(new BidiSpan(0, 0, m[0].length));
|
8028 |
+
}
|
8029 |
+
if (lst(order).level == 1 && (m = str.match(/\s+$/))) {
|
8030 |
+
lst(order).to -= m[0].length;
|
8031 |
+
order.push(new BidiSpan(0, len - m[0].length, len));
|
8032 |
+
}
|
8033 |
+
if (order[0].level != lst(order).level)
|
8034 |
+
order.push(new BidiSpan(order[0].level, len, len));
|
8035 |
+
|
8036 |
+
return order;
|
8037 |
+
};
|
8038 |
+
})();
|
8039 |
+
|
8040 |
+
// THE END
|
8041 |
+
|
8042 |
+
CodeMirror.version = "4.12.0";
|
8043 |
+
|
8044 |
+
return CodeMirror;
|
8045 |
+
});
|
@@ -1,362 +1,489 @@
|
|
1 |
-
CodeMirror
|
2 |
-
|
3 |
-
|
4 |
-
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
}
|
43 |
-
if (
|
44 |
-
stream.eatWhile(
|
45 |
-
return "
|
46 |
-
}
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
}
|
57 |
-
if (
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
if (
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
break;
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
return
|
98 |
-
}
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
|
136 |
-
|
137 |
-
|
138 |
-
|
139 |
-
|
140 |
-
|
141 |
-
|
142 |
-
|
143 |
-
|
144 |
-
|
145 |
-
|
146 |
-
|
147 |
-
|
148 |
-
if (
|
149 |
-
|
150 |
-
|
151 |
-
|
152 |
-
|
153 |
-
|
154 |
-
else if (ctx.type
|
155 |
-
else
|
156 |
-
|
157 |
-
|
158 |
-
|
159 |
-
|
160 |
-
|
161 |
-
|
162 |
-
|
163 |
-
|
164 |
-
|
165 |
-
|
166 |
-
(
|
167 |
-
|
168 |
-
|
169 |
-
|
170 |
-
|
171 |
-
|
172 |
-
|
173 |
-
|
174 |
-
|
175 |
-
|
176 |
-
|
177 |
-
|
178 |
-
|
179 |
-
|
180 |
-
|
181 |
-
|
182 |
-
|
183 |
-
|
184 |
-
|
185 |
-
|
186 |
-
|
187 |
-
|
188 |
-
|
189 |
-
|
190 |
-
|
191 |
-
|
192 |
-
|
193 |
-
|
194 |
-
|
195 |
-
|
196 |
-
|
197 |
-
|
198 |
-
|
199 |
-
|
200 |
-
|
201 |
-
|
202 |
-
|
203 |
-
|
204 |
-
|
205 |
-
|
206 |
-
|
207 |
-
|
208 |
-
|
209 |
-
|
210 |
-
|
211 |
-
|
212 |
-
|
213 |
-
|
214 |
-
|
215 |
-
|
216 |
-
|
217 |
-
|
218 |
-
|
219 |
-
|
220 |
-
|
221 |
-
|
222 |
-
|
223 |
-
|
224 |
-
|
225 |
-
|
226 |
-
|
227 |
-
|
228 |
-
|
229 |
-
|
230 |
-
|
231 |
-
|
232 |
-
|
233 |
-
|
234 |
-
|
235 |
-
|
236 |
-
|
237 |
-
"
|
238 |
-
|
239 |
-
|
240 |
-
}
|
241 |
-
}
|
242 |
-
|
243 |
-
|
244 |
-
|
245 |
-
|
246 |
-
|
247 |
-
|
248 |
-
|
249 |
-
|
250 |
-
|
251 |
-
|
252 |
-
|
253 |
-
|
254 |
-
|
255 |
-
|
256 |
-
|
257 |
-
|
258 |
-
|
259 |
-
|
260 |
-
|
261 |
-
|
262 |
-
|
263 |
-
|
264 |
-
|
265 |
-
|
266 |
-
|
267 |
-
|
268 |
-
|
269 |
-
|
270 |
-
|
271 |
-
|
272 |
-
|
273 |
-
|
274 |
-
|
275 |
-
|
276 |
-
|
277 |
-
|
278 |
-
|
279 |
-
|
280 |
-
|
281 |
-
|
282 |
-
|
283 |
-
|
284 |
-
|
285 |
-
|
286 |
-
|
287 |
-
|
288 |
-
|
289 |
-
|
290 |
-
|
291 |
-
|
292 |
-
|
293 |
-
|
294 |
-
|
295 |
-
|
296 |
-
|
297 |
-
|
298 |
-
|
299 |
-
|
300 |
-
"
|
301 |
-
|
302 |
-
|
303 |
-
|
304 |
-
|
305 |
-
|
306 |
-
|
307 |
-
|
308 |
-
|
309 |
-
"
|
310 |
-
"
|
311 |
-
"
|
312 |
-
|
313 |
-
|
314 |
-
|
315 |
-
|
316 |
-
|
317 |
-
|
318 |
-
|
319 |
-
|
320 |
-
|
321 |
-
|
322 |
-
|
323 |
-
|
324 |
-
|
325 |
-
|
326 |
-
"
|
327 |
-
"
|
328 |
-
"
|
329 |
-
"
|
330 |
-
"
|
331 |
-
"
|
332 |
-
|
333 |
-
|
334 |
-
|
335 |
-
|
336 |
-
|
337 |
-
|
338 |
-
|
339 |
-
|
340 |
-
|
341 |
-
|
342 |
-
|
343 |
-
|
344 |
-
|
345 |
-
|
346 |
-
|
347 |
-
|
348 |
-
|
349 |
-
|
350 |
-
|
351 |
-
|
352 |
-
|
353 |
-
|
354 |
-
|
355 |
-
|
356 |
-
|
357 |
-
|
358 |
-
|
359 |
-
|
360 |
-
|
361 |
-
|
362 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
// CodeMirror, copyright (c) by Marijn Haverbeke and others
|
2 |
+
// Distributed under an MIT license: http://codemirror.net/LICENSE
|
3 |
+
|
4 |
+
(function(mod) {
|
5 |
+
if (typeof exports == "object" && typeof module == "object") // CommonJS
|
6 |
+
mod(require("../../lib/codemirror"));
|
7 |
+
else if (typeof define == "function" && define.amd) // AMD
|
8 |
+
define(["../../lib/codemirror"], mod);
|
9 |
+
else // Plain browser env
|
10 |
+
mod(CodeMirror);
|
11 |
+
})(function(CodeMirror) {
|
12 |
+
"use strict";
|
13 |
+
|
14 |
+
CodeMirror.defineMode("clike", function(config, parserConfig) {
|
15 |
+
var indentUnit = config.indentUnit,
|
16 |
+
statementIndentUnit = parserConfig.statementIndentUnit || indentUnit,
|
17 |
+
dontAlignCalls = parserConfig.dontAlignCalls,
|
18 |
+
keywords = parserConfig.keywords || {},
|
19 |
+
builtin = parserConfig.builtin || {},
|
20 |
+
blockKeywords = parserConfig.blockKeywords || {},
|
21 |
+
atoms = parserConfig.atoms || {},
|
22 |
+
hooks = parserConfig.hooks || {},
|
23 |
+
multiLineStrings = parserConfig.multiLineStrings,
|
24 |
+
indentStatements = parserConfig.indentStatements !== false;
|
25 |
+
var isOperatorChar = /[+\-*&%=<>!?|\/]/;
|
26 |
+
|
27 |
+
var curPunc;
|
28 |
+
|
29 |
+
function tokenBase(stream, state) {
|
30 |
+
var ch = stream.next();
|
31 |
+
if (hooks[ch]) {
|
32 |
+
var result = hooks[ch](stream, state);
|
33 |
+
if (result !== false) return result;
|
34 |
+
}
|
35 |
+
if (ch == '"' || ch == "'") {
|
36 |
+
state.tokenize = tokenString(ch);
|
37 |
+
return state.tokenize(stream, state);
|
38 |
+
}
|
39 |
+
if (/[\[\]{}\(\),;\:\.]/.test(ch)) {
|
40 |
+
curPunc = ch;
|
41 |
+
return null;
|
42 |
+
}
|
43 |
+
if (/\d/.test(ch)) {
|
44 |
+
stream.eatWhile(/[\w\.]/);
|
45 |
+
return "number";
|
46 |
+
}
|
47 |
+
if (ch == "/") {
|
48 |
+
if (stream.eat("*")) {
|
49 |
+
state.tokenize = tokenComment;
|
50 |
+
return tokenComment(stream, state);
|
51 |
+
}
|
52 |
+
if (stream.eat("/")) {
|
53 |
+
stream.skipToEnd();
|
54 |
+
return "comment";
|
55 |
+
}
|
56 |
+
}
|
57 |
+
if (isOperatorChar.test(ch)) {
|
58 |
+
stream.eatWhile(isOperatorChar);
|
59 |
+
return "operator";
|
60 |
+
}
|
61 |
+
stream.eatWhile(/[\w\$_\xa1-\uffff]/);
|
62 |
+
var cur = stream.current();
|
63 |
+
if (keywords.propertyIsEnumerable(cur)) {
|
64 |
+
if (blockKeywords.propertyIsEnumerable(cur)) curPunc = "newstatement";
|
65 |
+
return "keyword";
|
66 |
+
}
|
67 |
+
if (builtin.propertyIsEnumerable(cur)) {
|
68 |
+
if (blockKeywords.propertyIsEnumerable(cur)) curPunc = "newstatement";
|
69 |
+
return "builtin";
|
70 |
+
}
|
71 |
+
if (atoms.propertyIsEnumerable(cur)) return "atom";
|
72 |
+
return "variable";
|
73 |
+
}
|
74 |
+
|
75 |
+
function tokenString(quote) {
|
76 |
+
return function(stream, state) {
|
77 |
+
var escaped = false, next, end = false;
|
78 |
+
while ((next = stream.next()) != null) {
|
79 |
+
if (next == quote && !escaped) {end = true; break;}
|
80 |
+
escaped = !escaped && next == "\\";
|
81 |
+
}
|
82 |
+
if (end || !(escaped || multiLineStrings))
|
83 |
+
state.tokenize = null;
|
84 |
+
return "string";
|
85 |
+
};
|
86 |
+
}
|
87 |
+
|
88 |
+
function tokenComment(stream, state) {
|
89 |
+
var maybeEnd = false, ch;
|
90 |
+
while (ch = stream.next()) {
|
91 |
+
if (ch == "/" && maybeEnd) {
|
92 |
+
state.tokenize = null;
|
93 |
+
break;
|
94 |
+
}
|
95 |
+
maybeEnd = (ch == "*");
|
96 |
+
}
|
97 |
+
return "comment";
|
98 |
+
}
|
99 |
+
|
100 |
+
function Context(indented, column, type, align, prev) {
|
101 |
+
this.indented = indented;
|
102 |
+
this.column = column;
|
103 |
+
this.type = type;
|
104 |
+
this.align = align;
|
105 |
+
this.prev = prev;
|
106 |
+
}
|
107 |
+
function pushContext(state, col, type) {
|
108 |
+
var indent = state.indented;
|
109 |
+
if (state.context && state.context.type == "statement")
|
110 |
+
indent = state.context.indented;
|
111 |
+
return state.context = new Context(indent, col, type, null, state.context);
|
112 |
+
}
|
113 |
+
function popContext(state) {
|
114 |
+
var t = state.context.type;
|
115 |
+
if (t == ")" || t == "]" || t == "}")
|
116 |
+
state.indented = state.context.indented;
|
117 |
+
return state.context = state.context.prev;
|
118 |
+
}
|
119 |
+
|
120 |
+
// Interface
|
121 |
+
|
122 |
+
return {
|
123 |
+
startState: function(basecolumn) {
|
124 |
+
return {
|
125 |
+
tokenize: null,
|
126 |
+
context: new Context((basecolumn || 0) - indentUnit, 0, "top", false),
|
127 |
+
indented: 0,
|
128 |
+
startOfLine: true
|
129 |
+
};
|
130 |
+
},
|
131 |
+
|
132 |
+
token: function(stream, state) {
|
133 |
+
var ctx = state.context;
|
134 |
+
if (stream.sol()) {
|
135 |
+
if (ctx.align == null) ctx.align = false;
|
136 |
+
state.indented = stream.indentation();
|
137 |
+
state.startOfLine = true;
|
138 |
+
}
|
139 |
+
if (stream.eatSpace()) return null;
|
140 |
+
curPunc = null;
|
141 |
+
var style = (state.tokenize || tokenBase)(stream, state);
|
142 |
+
if (style == "comment" || style == "meta") return style;
|
143 |
+
if (ctx.align == null) ctx.align = true;
|
144 |
+
|
145 |
+
if ((curPunc == ";" || curPunc == ":" || curPunc == ",") && ctx.type == "statement") popContext(state);
|
146 |
+
else if (curPunc == "{") pushContext(state, stream.column(), "}");
|
147 |
+
else if (curPunc == "[") pushContext(state, stream.column(), "]");
|
148 |
+
else if (curPunc == "(") pushContext(state, stream.column(), ")");
|
149 |
+
else if (curPunc == "}") {
|
150 |
+
while (ctx.type == "statement") ctx = popContext(state);
|
151 |
+
if (ctx.type == "}") ctx = popContext(state);
|
152 |
+
while (ctx.type == "statement") ctx = popContext(state);
|
153 |
+
}
|
154 |
+
else if (curPunc == ctx.type) popContext(state);
|
155 |
+
else if (indentStatements &&
|
156 |
+
(((ctx.type == "}" || ctx.type == "top") && curPunc != ';') ||
|
157 |
+
(ctx.type == "statement" && curPunc == "newstatement")))
|
158 |
+
pushContext(state, stream.column(), "statement");
|
159 |
+
state.startOfLine = false;
|
160 |
+
return style;
|
161 |
+
},
|
162 |
+
|
163 |
+
indent: function(state, textAfter) {
|
164 |
+
if (state.tokenize != tokenBase && state.tokenize != null) return CodeMirror.Pass;
|
165 |
+
var ctx = state.context, firstChar = textAfter && textAfter.charAt(0);
|
166 |
+
if (ctx.type == "statement" && firstChar == "}") ctx = ctx.prev;
|
167 |
+
var closing = firstChar == ctx.type;
|
168 |
+
if (ctx.type == "statement") return ctx.indented + (firstChar == "{" ? 0 : statementIndentUnit);
|
169 |
+
else if (ctx.align && (!dontAlignCalls || ctx.type != ")")) return ctx.column + (closing ? 0 : 1);
|
170 |
+
else if (ctx.type == ")" && !closing) return ctx.indented + statementIndentUnit;
|
171 |
+
else return ctx.indented + (closing ? 0 : indentUnit);
|
172 |
+
},
|
173 |
+
|
174 |
+
electricChars: "{}",
|
175 |
+
blockCommentStart: "/*",
|
176 |
+
blockCommentEnd: "*/",
|
177 |
+
lineComment: "//",
|
178 |
+
fold: "brace"
|
179 |
+
};
|
180 |
+
});
|
181 |
+
|
182 |
+
function words(str) {
|
183 |
+
var obj = {}, words = str.split(" ");
|
184 |
+
for (var i = 0; i < words.length; ++i) obj[words[i]] = true;
|
185 |
+
return obj;
|
186 |
+
}
|
187 |
+
var cKeywords = "auto if break int case long char register continue return default short do sizeof " +
|
188 |
+
"double static else struct entry switch extern typedef float union for unsigned " +
|
189 |
+
"goto while enum void const signed volatile";
|
190 |
+
|
191 |
+
function cppHook(stream, state) {
|
192 |
+
if (!state.startOfLine) return false;
|
193 |
+
for (;;) {
|
194 |
+
if (stream.skipTo("\\")) {
|
195 |
+
stream.next();
|
196 |
+
if (stream.eol()) {
|
197 |
+
state.tokenize = cppHook;
|
198 |
+
break;
|
199 |
+
}
|
200 |
+
} else {
|
201 |
+
stream.skipToEnd();
|
202 |
+
state.tokenize = null;
|
203 |
+
break;
|
204 |
+
}
|
205 |
+
}
|
206 |
+
return "meta";
|
207 |
+
}
|
208 |
+
|
209 |
+
function cpp11StringHook(stream, state) {
|
210 |
+
stream.backUp(1);
|
211 |
+
// Raw strings.
|
212 |
+
if (stream.match(/(R|u8R|uR|UR|LR)/)) {
|
213 |
+
var match = stream.match(/"([^\s\\()]{0,16})\(/);
|
214 |
+
if (!match) {
|
215 |
+
return false;
|
216 |
+
}
|
217 |
+
state.cpp11RawStringDelim = match[1];
|
218 |
+
state.tokenize = tokenRawString;
|
219 |
+
return tokenRawString(stream, state);
|
220 |
+
}
|
221 |
+
// Unicode strings/chars.
|
222 |
+
if (stream.match(/(u8|u|U|L)/)) {
|
223 |
+
if (stream.match(/["']/, /* eat */ false)) {
|
224 |
+
return "string";
|
225 |
+
}
|
226 |
+
return false;
|
227 |
+
}
|
228 |
+
// Ignore this hook.
|
229 |
+
stream.next();
|
230 |
+
return false;
|
231 |
+
}
|
232 |
+
|
233 |
+
// C#-style strings where "" escapes a quote.
|
234 |
+
function tokenAtString(stream, state) {
|
235 |
+
var next;
|
236 |
+
while ((next = stream.next()) != null) {
|
237 |
+
if (next == '"' && !stream.eat('"')) {
|
238 |
+
state.tokenize = null;
|
239 |
+
break;
|
240 |
+
}
|
241 |
+
}
|
242 |
+
return "string";
|
243 |
+
}
|
244 |
+
|
245 |
+
// C++11 raw string literal is <prefix>"<delim>( anything )<delim>", where
|
246 |
+
// <delim> can be a string up to 16 characters long.
|
247 |
+
function tokenRawString(stream, state) {
|
248 |
+
// Escape characters that have special regex meanings.
|
249 |
+
var delim = state.cpp11RawStringDelim.replace(/[^\w\s]/g, '\\$&');
|
250 |
+
var match = stream.match(new RegExp(".*?\\)" + delim + '"'));
|
251 |
+
if (match)
|
252 |
+
state.tokenize = null;
|
253 |
+
else
|
254 |
+
stream.skipToEnd();
|
255 |
+
return "string";
|
256 |
+
}
|
257 |
+
|
258 |
+
function def(mimes, mode) {
|
259 |
+
if (typeof mimes == "string") mimes = [mimes];
|
260 |
+
var words = [];
|
261 |
+
function add(obj) {
|
262 |
+
if (obj) for (var prop in obj) if (obj.hasOwnProperty(prop))
|
263 |
+
words.push(prop);
|
264 |
+
}
|
265 |
+
add(mode.keywords);
|
266 |
+
add(mode.builtin);
|
267 |
+
add(mode.atoms);
|
268 |
+
if (words.length) {
|
269 |
+
mode.helperType = mimes[0];
|
270 |
+
CodeMirror.registerHelper("hintWords", mimes[0], words);
|
271 |
+
}
|
272 |
+
|
273 |
+
for (var i = 0; i < mimes.length; ++i)
|
274 |
+
CodeMirror.defineMIME(mimes[i], mode);
|
275 |
+
}
|
276 |
+
|
277 |
+
def(["text/x-csrc", "text/x-c", "text/x-chdr"], {
|
278 |
+
name: "clike",
|
279 |
+
keywords: words(cKeywords),
|
280 |
+
blockKeywords: words("case do else for if switch while struct"),
|
281 |
+
atoms: words("null"),
|
282 |
+
hooks: {"#": cppHook},
|
283 |
+
modeProps: {fold: ["brace", "include"]}
|
284 |
+
});
|
285 |
+
|
286 |
+
def(["text/x-c++src", "text/x-c++hdr"], {
|
287 |
+
name: "clike",
|
288 |
+
keywords: words(cKeywords + " asm dynamic_cast namespace reinterpret_cast try bool explicit new " +
|
289 |
+
"static_cast typeid catch operator template typename class friend private " +
|
290 |
+
"this using const_cast inline public throw virtual delete mutable protected " +
|
291 |
+
"wchar_t alignas alignof constexpr decltype nullptr noexcept thread_local final " +
|
292 |
+
"static_assert override"),
|
293 |
+
blockKeywords: words("catch class do else finally for if struct switch try while"),
|
294 |
+
atoms: words("true false null"),
|
295 |
+
hooks: {
|
296 |
+
"#": cppHook,
|
297 |
+
"u": cpp11StringHook,
|
298 |
+
"U": cpp11StringHook,
|
299 |
+
"L": cpp11StringHook,
|
300 |
+
"R": cpp11StringHook
|
301 |
+
},
|
302 |
+
modeProps: {fold: ["brace", "include"]}
|
303 |
+
});
|
304 |
+
|
305 |
+
def("text/x-java", {
|
306 |
+
name: "clike",
|
307 |
+
keywords: words("abstract assert boolean break byte case catch char class const continue default " +
|
308 |
+
"do double else enum extends final finally float for goto if implements import " +
|
309 |
+
"instanceof int interface long native new package private protected public " +
|
310 |
+
"return short static strictfp super switch synchronized this throw throws transient " +
|
311 |
+
"try void volatile while"),
|
312 |
+
blockKeywords: words("catch class do else finally for if switch try while"),
|
313 |
+
atoms: words("true false null"),
|
314 |
+
hooks: {
|
315 |
+
"@": function(stream) {
|
316 |
+
stream.eatWhile(/[\w\$_]/);
|
317 |
+
return "meta";
|
318 |
+
}
|
319 |
+
},
|
320 |
+
modeProps: {fold: ["brace", "import"]}
|
321 |
+
});
|
322 |
+
|
323 |
+
def("text/x-csharp", {
|
324 |
+
name: "clike",
|
325 |
+
keywords: words("abstract as base break case catch checked class const continue" +
|
326 |
+
" default delegate do else enum event explicit extern finally fixed for" +
|
327 |
+
" foreach goto if implicit in interface internal is lock namespace new" +
|
328 |
+
" operator out override params private protected public readonly ref return sealed" +
|
329 |
+
" sizeof stackalloc static struct switch this throw try typeof unchecked" +
|
330 |
+
" unsafe using virtual void volatile while add alias ascending descending dynamic from get" +
|
331 |
+
" global group into join let orderby partial remove select set value var yield"),
|
332 |
+
blockKeywords: words("catch class do else finally for foreach if struct switch try while"),
|
333 |
+
builtin: words("Boolean Byte Char DateTime DateTimeOffset Decimal Double" +
|
334 |
+
" Guid Int16 Int32 Int64 Object SByte Single String TimeSpan UInt16 UInt32" +
|
335 |
+
" UInt64 bool byte char decimal double short int long object" +
|
336 |
+
" sbyte float string ushort uint ulong"),
|
337 |
+
atoms: words("true false null"),
|
338 |
+
hooks: {
|
339 |
+
"@": function(stream, state) {
|
340 |
+
if (stream.eat('"')) {
|
341 |
+
state.tokenize = tokenAtString;
|
342 |
+
return tokenAtString(stream, state);
|
343 |
+
}
|
344 |
+
stream.eatWhile(/[\w\$_]/);
|
345 |
+
return "meta";
|
346 |
+
}
|
347 |
+
}
|
348 |
+
});
|
349 |
+
|
350 |
+
function tokenTripleString(stream, state) {
|
351 |
+
var escaped = false;
|
352 |
+
while (!stream.eol()) {
|
353 |
+
if (!escaped && stream.match('"""')) {
|
354 |
+
state.tokenize = null;
|
355 |
+
break;
|
356 |
+
}
|
357 |
+
escaped = stream.next() != "\\" && !escaped;
|
358 |
+
}
|
359 |
+
return "string";
|
360 |
+
}
|
361 |
+
|
362 |
+
def("text/x-scala", {
|
363 |
+
name: "clike",
|
364 |
+
keywords: words(
|
365 |
+
|
366 |
+
/* scala */
|
367 |
+
"abstract case catch class def do else extends false final finally for forSome if " +
|
368 |
+
"implicit import lazy match new null object override package private protected return " +
|
369 |
+
"sealed super this throw trait try trye type val var while with yield _ : = => <- <: " +
|
370 |
+
"<% >: # @ " +
|
371 |
+
|
372 |
+
/* package scala */
|
373 |
+
"assert assume require print println printf readLine readBoolean readByte readShort " +
|
374 |
+
"readChar readInt readLong readFloat readDouble " +
|
375 |
+
|
376 |
+
"AnyVal App Application Array BufferedIterator BigDecimal BigInt Char Console Either " +
|
377 |
+
"Enumeration Equiv Error Exception Fractional Function IndexedSeq Integral Iterable " +
|
378 |
+
"Iterator List Map Numeric Nil NotNull Option Ordered Ordering PartialFunction PartialOrdering " +
|
379 |
+
"Product Proxy Range Responder Seq Serializable Set Specializable Stream StringBuilder " +
|
380 |
+
"StringContext Symbol Throwable Traversable TraversableOnce Tuple Unit Vector :: #:: " +
|
381 |
+
|
382 |
+
/* package java.lang */
|
383 |
+
"Boolean Byte Character CharSequence Class ClassLoader Cloneable Comparable " +
|
384 |
+
"Compiler Double Exception Float Integer Long Math Number Object Package Pair Process " +
|
385 |
+
"Runtime Runnable SecurityManager Short StackTraceElement StrictMath String " +
|
386 |
+
"StringBuffer System Thread ThreadGroup ThreadLocal Throwable Triple Void"
|
387 |
+
),
|
388 |
+
multiLineStrings: true,
|
389 |
+
blockKeywords: words("catch class do else finally for forSome if match switch try while"),
|
390 |
+
atoms: words("true false null"),
|
391 |
+
indentStatements: false,
|
392 |
+
hooks: {
|
393 |
+
"@": function(stream) {
|
394 |
+
stream.eatWhile(/[\w\$_]/);
|
395 |
+
return "meta";
|
396 |
+
},
|
397 |
+
'"': function(stream, state) {
|
398 |
+
if (!stream.match('""')) return false;
|
399 |
+
state.tokenize = tokenTripleString;
|
400 |
+
return state.tokenize(stream, state);
|
401 |
+
}
|
402 |
+
}
|
403 |
+
});
|
404 |
+
|
405 |
+
def(["x-shader/x-vertex", "x-shader/x-fragment"], {
|
406 |
+
name: "clike",
|
407 |
+
keywords: words("float int bool void " +
|
408 |
+
"vec2 vec3 vec4 ivec2 ivec3 ivec4 bvec2 bvec3 bvec4 " +
|
409 |
+
"mat2 mat3 mat4 " +
|
410 |
+
"sampler1D sampler2D sampler3D samplerCube " +
|
411 |
+
"sampler1DShadow sampler2DShadow " +
|
412 |
+
"const attribute uniform varying " +
|
413 |
+
"break continue discard return " +
|
414 |
+
"for while do if else struct " +
|
415 |
+
"in out inout"),
|
416 |
+
blockKeywords: words("for while do if else struct"),
|
417 |
+
builtin: words("radians degrees sin cos tan asin acos atan " +
|
418 |
+
"pow exp log exp2 sqrt inversesqrt " +
|
419 |
+
"abs sign floor ceil fract mod min max clamp mix step smoothstep " +
|
420 |
+
"length distance dot cross normalize ftransform faceforward " +
|
421 |
+
"reflect refract matrixCompMult " +
|
422 |
+
"lessThan lessThanEqual greaterThan greaterThanEqual " +
|
423 |
+
"equal notEqual any all not " +
|
424 |
+
"texture1D texture1DProj texture1DLod texture1DProjLod " +
|
425 |
+
"texture2D texture2DProj texture2DLod texture2DProjLod " +
|
426 |
+
"texture3D texture3DProj texture3DLod texture3DProjLod " +
|
427 |
+
"textureCube textureCubeLod " +
|
428 |
+
"shadow1D shadow2D shadow1DProj shadow2DProj " +
|
429 |
+
"shadow1DLod shadow2DLod shadow1DProjLod shadow2DProjLod " +
|
430 |
+
"dFdx dFdy fwidth " +
|
431 |
+
"noise1 noise2 noise3 noise4"),
|
432 |
+
atoms: words("true false " +
|
433 |
+
"gl_FragColor gl_SecondaryColor gl_Normal gl_Vertex " +
|
434 |
+
"gl_MultiTexCoord0 gl_MultiTexCoord1 gl_MultiTexCoord2 gl_MultiTexCoord3 " +
|
435 |
+
"gl_MultiTexCoord4 gl_MultiTexCoord5 gl_MultiTexCoord6 gl_MultiTexCoord7 " +
|
436 |
+
"gl_FogCoord gl_PointCoord " +
|
437 |
+
"gl_Position gl_PointSize gl_ClipVertex " +
|
438 |
+
"gl_FrontColor gl_BackColor gl_FrontSecondaryColor gl_BackSecondaryColor " +
|
439 |
+
"gl_TexCoord gl_FogFragCoord " +
|
440 |
+
"gl_FragCoord gl_FrontFacing " +
|
441 |
+
"gl_FragData gl_FragDepth " +
|
442 |
+
"gl_ModelViewMatrix gl_ProjectionMatrix gl_ModelViewProjectionMatrix " +
|
443 |
+
"gl_TextureMatrix gl_NormalMatrix gl_ModelViewMatrixInverse " +
|
444 |
+
"gl_ProjectionMatrixInverse gl_ModelViewProjectionMatrixInverse " +
|
445 |
+
"gl_TexureMatrixTranspose gl_ModelViewMatrixInverseTranspose " +
|
446 |
+
"gl_ProjectionMatrixInverseTranspose " +
|
447 |
+
"gl_ModelViewProjectionMatrixInverseTranspose " +
|
448 |
+
"gl_TextureMatrixInverseTranspose " +
|
449 |
+
"gl_NormalScale gl_DepthRange gl_ClipPlane " +
|
450 |
+
"gl_Point gl_FrontMaterial gl_BackMaterial gl_LightSource gl_LightModel " +
|
451 |
+
"gl_FrontLightModelProduct gl_BackLightModelProduct " +
|
452 |
+
"gl_TextureColor gl_EyePlaneS gl_EyePlaneT gl_EyePlaneR gl_EyePlaneQ " +
|
453 |
+
"gl_FogParameters " +
|
454 |
+
"gl_MaxLights gl_MaxClipPlanes gl_MaxTextureUnits gl_MaxTextureCoords " +
|
455 |
+
"gl_MaxVertexAttribs gl_MaxVertexUniformComponents gl_MaxVaryingFloats " +
|
456 |
+
"gl_MaxVertexTextureImageUnits gl_MaxTextureImageUnits " +
|
457 |
+
"gl_MaxFragmentUniformComponents gl_MaxCombineTextureImageUnits " +
|
458 |
+
"gl_MaxDrawBuffers"),
|
459 |
+
hooks: {"#": cppHook},
|
460 |
+
modeProps: {fold: ["brace", "include"]}
|
461 |
+
});
|
462 |
+
|
463 |
+
def("text/x-nesc", {
|
464 |
+
name: "clike",
|
465 |
+
keywords: words(cKeywords + "as atomic async call command component components configuration event generic " +
|
466 |
+
"implementation includes interface module new norace nx_struct nx_union post provides " +
|
467 |
+
"signal task uses abstract extends"),
|
468 |
+
blockKeywords: words("case do else for if switch while struct"),
|
469 |
+
atoms: words("null"),
|
470 |
+
hooks: {"#": cppHook},
|
471 |
+
modeProps: {fold: ["brace", "include"]}
|
472 |
+
});
|
473 |
+
|
474 |
+
def("text/x-objectivec", {
|
475 |
+
name: "clike",
|
476 |
+
keywords: words(cKeywords + "inline restrict _Bool _Complex _Imaginery BOOL Class bycopy byref id IMP in " +
|
477 |
+
"inout nil oneway out Protocol SEL self super atomic nonatomic retain copy readwrite readonly"),
|
478 |
+
atoms: words("YES NO NULL NILL ON OFF"),
|
479 |
+
hooks: {
|
480 |
+
"@": function(stream) {
|
481 |
+
stream.eatWhile(/[\w\$]/);
|
482 |
+
return "keyword";
|
483 |
+
},
|
484 |
+
"#": cppHook
|
485 |
+
},
|
486 |
+
modeProps: {fold: "brace"}
|
487 |
+
});
|
488 |
+
|
489 |
+
});
|
@@ -1,132 +1,226 @@
|
|
1 |
-
(
|
2 |
-
|
3 |
-
|
4 |
-
|
5 |
-
|
6 |
-
|
7 |
-
function
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
|
130 |
-
CodeMirror.defineMIME("application/x-httpd-php-open", {name: "php", startOpen: true});
|
131 |
-
CodeMirror.defineMIME("text/x-php", phpConfig);
|
132 |
-
})();
|
1 |
+
// CodeMirror, copyright (c) by Marijn Haverbeke and others
|
2 |
+
// Distributed under an MIT license: http://codemirror.net/LICENSE
|
3 |
+
|
4 |
+
(function(mod) {
|
5 |
+
if (typeof exports == "object" && typeof module == "object") // CommonJS
|
6 |
+
mod(require("../../lib/codemirror"), require("../htmlmixed/htmlmixed"), require("../clike/clike"));
|
7 |
+
else if (typeof define == "function" && define.amd) // AMD
|
8 |
+
define(["../../lib/codemirror", "../htmlmixed/htmlmixed", "../clike/clike"], mod);
|
9 |
+
else // Plain browser env
|
10 |
+
mod(CodeMirror);
|
11 |
+
})(function(CodeMirror) {
|
12 |
+
"use strict";
|
13 |
+
|
14 |
+
function keywords(str) {
|
15 |
+
var obj = {}, words = str.split(" ");
|
16 |
+
for (var i = 0; i < words.length; ++i) obj[words[i]] = true;
|
17 |
+
return obj;
|
18 |
+
}
|
19 |
+
|
20 |
+
// Helper for stringWithEscapes
|
21 |
+
function matchSequence(list, end) {
|
22 |
+
if (list.length == 0) return stringWithEscapes(end);
|
23 |
+
return function (stream, state) {
|
24 |
+
var patterns = list[0];
|
25 |
+
for (var i = 0; i < patterns.length; i++) if (stream.match(patterns[i][0])) {
|
26 |
+
state.tokenize = matchSequence(list.slice(1), end);
|
27 |
+
return patterns[i][1];
|
28 |
+
}
|
29 |
+
state.tokenize = stringWithEscapes(end);
|
30 |
+
return "string";
|
31 |
+
};
|
32 |
+
}
|
33 |
+
function stringWithEscapes(closing) {
|
34 |
+
return function(stream, state) { return stringWithEscapes_(stream, state, closing); };
|
35 |
+
}
|
36 |
+
function stringWithEscapes_(stream, state, closing) {
|
37 |
+
// "Complex" syntax
|
38 |
+
if (stream.match("${", false) || stream.match("{$", false)) {
|
39 |
+
state.tokenize = null;
|
40 |
+
return "string";
|
41 |
+
}
|
42 |
+
|
43 |
+
// Simple syntax
|
44 |
+
if (stream.match(/^\$[a-zA-Z_][a-zA-Z0-9_]*/)) {
|
45 |
+
// After the variable name there may appear array or object operator.
|
46 |
+
if (stream.match("[", false)) {
|
47 |
+
// Match array operator
|
48 |
+
state.tokenize = matchSequence([
|
49 |
+
[["[", null]],
|
50 |
+
[[/\d[\w\.]*/, "number"],
|
51 |
+
[/\$[a-zA-Z_][a-zA-Z0-9_]*/, "variable-2"],
|
52 |
+
[/[\w\$]+/, "variable"]],
|
53 |
+
[["]", null]]
|
54 |
+
], closing);
|
55 |
+
}
|
56 |
+
if (stream.match(/\-\>\w/, false)) {
|
57 |
+
// Match object operator
|
58 |
+
state.tokenize = matchSequence([
|
59 |
+
[["->", null]],
|
60 |
+
[[/[\w]+/, "variable"]]
|
61 |
+
], closing);
|
62 |
+
}
|
63 |
+
return "variable-2";
|
64 |
+
}
|
65 |
+
|
66 |
+
var escaped = false;
|
67 |
+
// Normal string
|
68 |
+
while (!stream.eol() &&
|
69 |
+
(escaped || (!stream.match("{$", false) &&
|
70 |
+
!stream.match(/^(\$[a-zA-Z_][a-zA-Z0-9_]*|\$\{)/, false)))) {
|
71 |
+
if (!escaped && stream.match(closing)) {
|
72 |
+
state.tokenize = null;
|
73 |
+
state.tokStack.pop(); state.tokStack.pop();
|
74 |
+
break;
|
75 |
+
}
|
76 |
+
escaped = stream.next() == "\\" && !escaped;
|
77 |
+
}
|
78 |
+
return "string";
|
79 |
+
}
|
80 |
+
|
81 |
+
var phpKeywords = "abstract and array as break case catch class clone const continue declare default " +
|
82 |
+
"do else elseif enddeclare endfor endforeach endif endswitch endwhile extends final " +
|
83 |
+
"for foreach function global goto if implements interface instanceof namespace " +
|
84 |
+
"new or private protected public static switch throw trait try use var while xor " +
|
85 |
+
"die echo empty exit eval include include_once isset list require require_once return " +
|
86 |
+
"print unset __halt_compiler self static parent yield insteadof finally";
|
87 |
+
var phpAtoms = "true false null TRUE FALSE NULL __CLASS__ __DIR__ __FILE__ __LINE__ __METHOD__ __FUNCTION__ __NAMESPACE__ __TRAIT__";
|
88 |
+
var phpBuiltin = "func_num_args func_get_arg func_get_args strlen strcmp strncmp strcasecmp strncasecmp each error_reporting define defined trigger_error user_error set_error_handler restore_error_handler get_declared_classes get_loaded_extensions extension_loaded get_extension_funcs debug_backtrace constant bin2hex hex2bin sleep usleep time mktime gmmktime strftime gmstrftime strtotime date gmdate getdate localtime checkdate flush wordwrap htmlspecialchars htmlentities html_entity_decode md5 md5_file crc32 getimagesize image_type_to_mime_type phpinfo phpversion phpcredits strnatcmp strnatcasecmp substr_count strspn strcspn strtok strtoupper strtolower strpos strrpos strrev hebrev hebrevc nl2br basename dirname pathinfo stripslashes stripcslashes strstr stristr strrchr str_shuffle str_word_count strcoll substr substr_replace quotemeta ucfirst ucwords strtr addslashes addcslashes rtrim str_replace str_repeat count_chars chunk_split trim ltrim strip_tags similar_text explode implode setlocale localeconv parse_str str_pad chop strchr sprintf printf vprintf vsprintf sscanf fscanf parse_url urlencode urldecode rawurlencode rawurldecode readlink linkinfo link unlink exec system escapeshellcmd escapeshellarg passthru shell_exec proc_open proc_close rand srand getrandmax mt_rand mt_srand mt_getrandmax base64_decode base64_encode abs ceil floor round is_finite is_nan is_infinite bindec hexdec octdec decbin decoct dechex base_convert number_format fmod ip2long long2ip getenv putenv getopt microtime gettimeofday getrusage uniqid quoted_printable_decode set_time_limit get_cfg_var magic_quotes_runtime set_magic_quotes_runtime get_magic_quotes_gpc get_magic_quotes_runtime import_request_variables error_log serialize unserialize memory_get_usage var_dump var_export debug_zval_dump print_r highlight_file show_source highlight_string ini_get ini_get_all ini_set ini_alter ini_restore get_include_path set_include_path restore_include_path setcookie header headers_sent connection_aborted connection_status ignore_user_abort parse_ini_file is_uploaded_file move_uploaded_file intval floatval doubleval strval gettype settype is_null is_resource is_bool is_long is_float is_int is_integer is_double is_real is_numeric is_string is_array is_object is_scalar ereg ereg_replace eregi eregi_replace split spliti join sql_regcase dl pclose popen readfile rewind rmdir umask fclose feof fgetc fgets fgetss fread fopen fpassthru ftruncate fstat fseek ftell fflush fwrite fputs mkdir rename copy tempnam tmpfile file file_get_contents stream_select stream_context_create stream_context_set_params stream_context_set_option stream_context_get_options stream_filter_prepend stream_filter_append fgetcsv flock get_meta_tags stream_set_write_buffer set_file_buffer set_socket_blocking stream_set_blocking socket_set_blocking stream_get_meta_data stream_register_wrapper stream_wrapper_register stream_set_timeout socket_set_timeout socket_get_status realpath fnmatch fsockopen pfsockopen pack unpack get_browser crypt opendir closedir chdir getcwd rewinddir readdir dir glob fileatime filectime filegroup fileinode filemtime fileowner fileperms filesize filetype file_exists is_writable is_writeable is_readable is_executable is_file is_dir is_link stat lstat chown touch clearstatcache mail ob_start ob_flush ob_clean ob_end_flush ob_end_clean ob_get_flush ob_get_clean ob_get_length ob_get_level ob_get_status ob_get_contents ob_implicit_flush ob_list_handlers ksort krsort natsort natcasesort asort arsort sort rsort usort uasort uksort shuffle array_walk count end prev next reset current key min max in_array array_search extract compact array_fill range array_multisort array_push array_pop array_shift array_unshift array_splice array_slice array_merge array_merge_recursive array_keys array_values array_count_values array_reverse array_reduce array_pad array_flip array_change_key_case array_rand array_unique array_intersect array_intersect_assoc array_diff array_diff_assoc array_sum array_filter array_map array_chunk array_key_exists pos sizeof key_exists assert assert_options version_compare ftok str_rot13 aggregate session_name session_module_name session_save_path session_id session_regenerate_id session_decode session_register session_unregister session_is_registered session_encode session_start session_destroy session_unset session_set_save_handler session_cache_limiter session_cache_expire session_set_cookie_params session_get_cookie_params session_write_close preg_match preg_match_all preg_replace preg_replace_callback preg_split preg_quote preg_grep overload ctype_alnum ctype_alpha ctype_cntrl ctype_digit ctype_lower ctype_graph ctype_print ctype_punct ctype_space ctype_upper ctype_xdigit virtual apache_request_headers apache_note apache_lookup_uri apache_child_terminate apache_setenv apache_response_headers apache_get_version getallheaders mysql_connect mysql_pconnect mysql_close mysql_select_db mysql_create_db mysql_drop_db mysql_query mysql_unbuffered_query mysql_db_query mysql_list_dbs mysql_list_tables mysql_list_fields mysql_list_processes mysql_error mysql_errno mysql_affected_rows mysql_insert_id mysql_result mysql_num_rows mysql_num_fields mysql_fetch_row mysql_fetch_array mysql_fetch_assoc mysql_fetch_object mysql_data_seek mysql_fetch_lengths mysql_fetch_field mysql_field_seek mysql_free_result mysql_field_name mysql_field_table mysql_field_len mysql_field_type mysql_field_flags mysql_escape_string mysql_real_escape_string mysql_stat mysql_thread_id mysql_client_encoding mysql_get_client_info mysql_get_host_info mysql_get_proto_info mysql_get_server_info mysql_info mysql mysql_fieldname mysql_fieldtable mysql_fieldlen mysql_fieldtype mysql_fieldflags mysql_selectdb mysql_createdb mysql_dropdb mysql_freeresult mysql_numfields mysql_numrows mysql_listdbs mysql_listtables mysql_listfields mysql_db_name mysql_dbname mysql_tablename mysql_table_name pg_connect pg_pconnect pg_close pg_connection_status pg_connection_busy pg_connection_reset pg_host pg_dbname pg_port pg_tty pg_options pg_ping pg_query pg_send_query pg_cancel_query pg_fetch_result pg_fetch_row pg_fetch_assoc pg_fetch_array pg_fetch_object pg_fetch_all pg_affected_rows pg_get_result pg_result_seek pg_result_status pg_free_result pg_last_oid pg_num_rows pg_num_fields pg_field_name pg_field_num pg_field_size pg_field_type pg_field_prtlen pg_field_is_null pg_get_notify pg_get_pid pg_result_error pg_last_error pg_last_notice pg_put_line pg_end_copy pg_copy_to pg_copy_from pg_trace pg_untrace pg_lo_create pg_lo_unlink pg_lo_open pg_lo_close pg_lo_read pg_lo_write pg_lo_read_all pg_lo_import pg_lo_export pg_lo_seek pg_lo_tell pg_escape_string pg_escape_bytea pg_unescape_bytea pg_client_encoding pg_set_client_encoding pg_meta_data pg_convert pg_insert pg_update pg_delete pg_select pg_exec pg_getlastoid pg_cmdtuples pg_errormessage pg_numrows pg_numfields pg_fieldname pg_fieldsize pg_fieldtype pg_fieldnum pg_fieldprtlen pg_fieldisnull pg_freeresult pg_result pg_loreadall pg_locreate pg_lounlink pg_loopen pg_loclose pg_loread pg_lowrite pg_loimport pg_loexport http_response_code get_declared_traits getimagesizefromstring socket_import_stream stream_set_chunk_size trait_exists header_register_callback class_uses session_status session_register_shutdown echo print global static exit array empty eval isset unset die include require include_once require_once json_decode json_encode json_last_error json_last_error_msg curl_close curl_copy_handle curl_errno curl_error curl_escape curl_exec curl_file_create curl_getinfo curl_init curl_multi_add_handle curl_multi_close curl_multi_exec curl_multi_getcontent curl_multi_info_read curl_multi_init curl_multi_remove_handle curl_multi_select curl_multi_setopt curl_multi_strerror curl_pause curl_reset curl_setopt_array curl_setopt curl_share_close curl_share_init curl_share_setopt curl_strerror curl_unescape curl_version mysqli_affected_rows mysqli_autocommit mysqli_change_user mysqli_character_set_name mysqli_close mysqli_commit mysqli_connect_errno mysqli_connect_error mysqli_connect mysqli_data_seek mysqli_debug mysqli_dump_debug_info mysqli_errno mysqli_error_list mysqli_error mysqli_fetch_all mysqli_fetch_array mysqli_fetch_assoc mysqli_fetch_field_direct mysqli_fetch_field mysqli_fetch_fields mysqli_fetch_lengths mysqli_fetch_object mysqli_fetch_row mysqli_field_count mysqli_field_seek mysqli_field_tell mysqli_free_result mysqli_get_charset mysqli_get_client_info mysqli_get_client_stats mysqli_get_client_version mysqli_get_connection_stats mysqli_get_host_info mysqli_get_proto_info mysqli_get_server_info mysqli_get_server_version mysqli_info mysqli_init mysqli_insert_id mysqli_kill mysqli_more_results mysqli_multi_query mysqli_next_result mysqli_num_fields mysqli_num_rows mysqli_options mysqli_ping mysqli_prepare mysqli_query mysqli_real_connect mysqli_real_escape_string mysqli_real_query mysqli_reap_async_query mysqli_refresh mysqli_rollback mysqli_select_db mysqli_set_charset mysqli_set_local_infile_default mysqli_set_local_infile_handler mysqli_sqlstate mysqli_ssl_set mysqli_stat mysqli_stmt_init mysqli_store_result mysqli_thread_id mysqli_thread_safe mysqli_use_result mysqli_warning_count";
|
89 |
+
CodeMirror.registerHelper("hintWords", "php", [phpKeywords, phpAtoms, phpBuiltin].join(" ").split(" "));
|
90 |
+
CodeMirror.registerHelper("wordChars", "php", /[\w$]/);
|
91 |
+
|
92 |
+
var phpConfig = {
|
93 |
+
name: "clike",
|
94 |
+
helperType: "php",
|
95 |
+
keywords: keywords(phpKeywords),
|
96 |
+
blockKeywords: keywords("catch do else elseif for foreach if switch try while finally"),
|
97 |
+
atoms: keywords(phpAtoms),
|
98 |
+
builtin: keywords(phpBuiltin),
|
99 |
+
multiLineStrings: true,
|
100 |
+
hooks: {
|
101 |
+
"$": function(stream) {
|
102 |
+
stream.eatWhile(/[\w\$_]/);
|
103 |
+
return "variable-2";
|
104 |
+
},
|
105 |
+
"<": function(stream, state) {
|
106 |
+
if (stream.match(/<</)) {
|
107 |
+
stream.eatWhile(/[\w\.]/);
|
108 |
+
var delim = stream.current().slice(3);
|
109 |
+
if (delim) {
|
110 |
+
(state.tokStack || (state.tokStack = [])).push(delim, 0);
|
111 |
+
state.tokenize = stringWithEscapes(delim);
|
112 |
+
return "string";
|
113 |
+
}
|
114 |
+
}
|
115 |
+
return false;
|
116 |
+
},
|
117 |
+
"#": function(stream) {
|
118 |
+
while (!stream.eol() && !stream.match("?>", false)) stream.next();
|
119 |
+
return "comment";
|
120 |
+
},
|
121 |
+
"/": function(stream) {
|
122 |
+
if (stream.eat("/")) {
|
123 |
+
while (!stream.eol() && !stream.match("?>", false)) stream.next();
|
124 |
+
return "comment";
|
125 |
+
}
|
126 |
+
return false;
|
127 |
+
},
|
128 |
+
'"': function(_stream, state) {
|
129 |
+
(state.tokStack || (state.tokStack = [])).push('"'
|
|
|
|
|
|