PluginProbe ʕ •ᴥ•ʔ
Pods – Custom Content Types and Fields / 3.2.8.2
Pods – Custom Content Types and Fields v3.2.8.2
trunk 1.14.8 2.7.31.3 2.8.23.3 2.9.19.3 3.0.10.3 3.1.4.1 3.2.0 3.2.1 3.2.1.1 3.2.2 3.2.4 3.2.5 3.2.6 3.2.7 3.2.7.1 3.2.8 3.2.8.1 3.2.8.2 3.3.0 3.3.1 3.3.2 3.3.3 3.3.4 3.3.5 3.3.6 3.3.7 3.3.8 3.3.9
pods / ui / fields / codemirror.php
pods / ui / fields Last commit date
_comment.php 2 years ago _db.php 2 years ago _hidden.php 2 years ago _label.php 2 years ago _row.php 2 years ago attachment.php 1 year ago checkbox.php 1 year ago cleditor.php 2 years ago codemirror.php 2 years ago color.php 2 years ago currency.php 2 years ago date.php 2 years ago datetime.php 2 years ago email.php 2 years ago link.php 1 year ago number.php 2 years ago oembed.php 1 year ago password.php 2 years ago phone.php 2 years ago radio.php 2 years ago select.php 2 years ago slider.php 1 year ago slug.php 2 years ago text.php 2 years ago textarea.php 2 years ago time.php 2 years ago tinymce.php 2 years ago website.php 2 years ago
codemirror.php
52 lines
1 <?php
2 // Don't load directly.
3 if ( ! defined( 'ABSPATH' ) ) {
4 die( '-1' );
5 }
6
7 pods_form_enqueue_script( 'pods-codemirror' );
8 pods_form_enqueue_style( 'pods-codemirror' );
9 pods_form_enqueue_style( 'pods-styles' );
10 pods_form_enqueue_script( 'pods-codemirror-loadmode' );
11
12 $type = 'textarea';
13 $attributes = array();
14 $attributes['tabindex'] = 2;
15 $attributes = PodsForm::merge_attributes( $attributes, $name, $form_field_type, $options, 'pods-ui-field-codemirror' );
16 ?>
17 <div class="pods-codemirror pods-compat-container pods-form-ui-field">
18 <div class="code-toolbar"><!-- Placeholder --></div>
19 <textarea<?php PodsForm::attributes( $attributes, $name, $form_field_type, $options ); ?>><?php echo esc_textarea( $value ); ?></textarea>
20 <div class="code-footer"><!-- Placeholder --></div>
21
22 <script>
23 var $textarea_<?php echo esc_js( pods_js_name( $attributes['id'] ) ); ?>,
24 codemirror_<?php echo esc_js( pods_js_name( $attributes['id'] ) ); ?>;
25
26 jQuery( function ( $ ) {
27 $textarea_<?php echo esc_js( pods_js_name( $attributes['id'] ) ); ?> = jQuery( 'textarea#<?php echo esc_js( $attributes['id'] ); ?>' );
28
29 CodeMirror.modeURL = "<?php echo esc_js( PODS_URL ); ?>ui/js/codemirror/mode/%N/%N.js";
30 if ( 'undefined' == typeof codemirror_<?php echo esc_js( pods_js_name( $attributes['id'] ) ); ?> ) {
31
32 codemirror_<?php echo esc_js( pods_js_name( $attributes['id'] ) ); ?> = CodeMirror.fromTextArea( document.getElementById( "<?php echo esc_js( $attributes['id'] ); ?>" ), {
33 lineNumbers : true,
34 matchBrackets : true,
35 mode : "application/x-httpd-php",
36 indentUnit : 4,
37 indentWithTabs : false,
38 lineWrapping : true,
39 enterMode : "keep",
40 tabMode : "shift"
41 } );
42 codemirror_<?php echo esc_js( pods_js_name( $attributes['id'] ) ); ?>.on( 'blur', function () {
43 var value = codemirror_<?php echo esc_js( pods_js_name( $attributes['id'] ) ); ?>.getValue();
44 $textarea_<?php echo esc_js( pods_js_name( $attributes['id'] ) ); ?>.val( value );
45 } );
46
47 CodeMirror.autoLoadMode( codemirror_<?php echo esc_js( pods_js_name( $attributes['id'] ) ); ?>, 'php' );
48 }
49 } );
50 </script>
51 </div>
52