Contact Form 7 Style - Version 3.1.9

Version Description

Release Date: October 21th, 2020

  • [Security Fix] Added suggested santiziation on possible critical field
  • [Minor Fix] Google Fonts List updated
  • [Major Fix] Predefined templates loading issue
Download this release

Release Info

Developer mlehelsz
Plugin Icon 128x128 Contact Form 7 Style
Version 3.1.9
Comparing to
See all releases

Code changes from version 3.1.8 to 3.1.9

admin/images/paypal.svg CHANGED
@@ -1,55 +1,55 @@
1
- <?xml version="1.0" encoding="utf-8"?>
2
- <!-- Generator: Adobe Illustrator 16.0.4, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
3
- <!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
4
- <svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
5
- width="124px" height="33px" viewBox="0 0 124 33" enable-background="new 0 0 124 33" xml:space="preserve">
6
- <path fill="#253B80" d="M46.211,6.749h-6.839c-0.468,0-0.866,0.34-0.939,0.802l-2.766,17.537c-0.055,0.346,0.213,0.658,0.564,0.658
7
- h3.265c0.468,0,0.866-0.34,0.939-0.803l0.746-4.73c0.072-0.463,0.471-0.803,0.938-0.803h2.165c4.505,0,7.105-2.18,7.784-6.5
8
- c0.306-1.89,0.013-3.375-0.872-4.415C50.224,7.353,48.5,6.749,46.211,6.749z M47,13.154c-0.374,2.454-2.249,2.454-4.062,2.454
9
- h-1.032l0.724-4.583c0.043-0.277,0.283-0.481,0.563-0.481h0.473c1.235,0,2.4,0,3.002,0.704C47.027,11.668,47.137,12.292,47,13.154z"
10
- />
11
- <path fill="#253B80" d="M66.654,13.075h-3.275c-0.279,0-0.52,0.204-0.563,0.481l-0.145,0.916l-0.229-0.332
12
- c-0.709-1.029-2.29-1.373-3.868-1.373c-3.619,0-6.71,2.741-7.312,6.586c-0.313,1.918,0.132,3.752,1.22,5.031
13
- c0.998,1.176,2.426,1.666,4.125,1.666c2.916,0,4.533-1.875,4.533-1.875l-0.146,0.91c-0.055,0.348,0.213,0.66,0.562,0.66h2.95
14
- c0.469,0,0.865-0.34,0.939-0.803l1.77-11.209C67.271,13.388,67.004,13.075,66.654,13.075z M62.089,19.449
15
- c-0.316,1.871-1.801,3.127-3.695,3.127c-0.951,0-1.711-0.305-2.199-0.883c-0.484-0.574-0.668-1.391-0.514-2.301
16
- c0.295-1.855,1.805-3.152,3.67-3.152c0.93,0,1.686,0.309,2.184,0.892C62.034,17.721,62.232,18.543,62.089,19.449z"/>
17
- <path fill="#253B80" d="M84.096,13.075h-3.291c-0.314,0-0.609,0.156-0.787,0.417l-4.539,6.686l-1.924-6.425
18
- c-0.121-0.402-0.492-0.678-0.912-0.678h-3.234c-0.393,0-0.666,0.384-0.541,0.754l3.625,10.638l-3.408,4.811
19
- c-0.268,0.379,0.002,0.9,0.465,0.9h3.287c0.312,0,0.604-0.152,0.781-0.408L84.564,13.97C84.826,13.592,84.557,13.075,84.096,13.075z
20
- "/>
21
- <path fill="#179BD7" d="M94.992,6.749h-6.84c-0.467,0-0.865,0.34-0.938,0.802l-2.766,17.537c-0.055,0.346,0.213,0.658,0.562,0.658
22
- h3.51c0.326,0,0.605-0.238,0.656-0.562l0.785-4.971c0.072-0.463,0.471-0.803,0.938-0.803h2.164c4.506,0,7.105-2.18,7.785-6.5
23
- c0.307-1.89,0.012-3.375-0.873-4.415C99.004,7.353,97.281,6.749,94.992,6.749z M95.781,13.154c-0.373,2.454-2.248,2.454-4.062,2.454
24
- h-1.031l0.725-4.583c0.043-0.277,0.281-0.481,0.562-0.481h0.473c1.234,0,2.4,0,3.002,0.704
25
- C95.809,11.668,95.918,12.292,95.781,13.154z"/>
26
- <path fill="#179BD7" d="M115.434,13.075h-3.273c-0.281,0-0.52,0.204-0.562,0.481l-0.145,0.916l-0.23-0.332
27
- c-0.709-1.029-2.289-1.373-3.867-1.373c-3.619,0-6.709,2.741-7.311,6.586c-0.312,1.918,0.131,3.752,1.219,5.031
28
- c1,1.176,2.426,1.666,4.125,1.666c2.916,0,4.533-1.875,4.533-1.875l-0.146,0.91c-0.055,0.348,0.213,0.66,0.564,0.66h2.949
29
- c0.467,0,0.865-0.34,0.938-0.803l1.771-11.209C116.053,13.388,115.785,13.075,115.434,13.075z M110.869,19.449
30
- c-0.314,1.871-1.801,3.127-3.695,3.127c-0.949,0-1.711-0.305-2.199-0.883c-0.484-0.574-0.666-1.391-0.514-2.301
31
- c0.297-1.855,1.805-3.152,3.67-3.152c0.93,0,1.686,0.309,2.184,0.892C110.816,17.721,111.014,18.543,110.869,19.449z"/>
32
- <path fill="#179BD7" d="M119.295,7.23l-2.807,17.858c-0.055,0.346,0.213,0.658,0.562,0.658h2.822c0.469,0,0.867-0.34,0.939-0.803
33
- l2.768-17.536c0.055-0.346-0.213-0.659-0.562-0.659h-3.16C119.578,6.749,119.338,6.953,119.295,7.23z"/>
34
- <path fill="#253B80" d="M7.266,29.154l0.523-3.322l-1.165-0.027H1.061L4.927,1.292C4.939,1.218,4.978,1.149,5.035,1.1
35
- c0.057-0.049,0.13-0.076,0.206-0.076h9.38c3.114,0,5.263,0.648,6.385,1.927c0.526,0.6,0.861,1.227,1.023,1.917
36
- c0.17,0.724,0.173,1.589,0.007,2.644l-0.012,0.077v0.676l0.526,0.298c0.443,0.235,0.795,0.504,1.065,0.812
37
- c0.45,0.513,0.741,1.165,0.864,1.938c0.127,0.795,0.085,1.741-0.123,2.812c-0.24,1.232-0.628,2.305-1.152,3.183
38
- c-0.482,0.809-1.096,1.48-1.825,2c-0.696,0.494-1.523,0.869-2.458,1.109c-0.906,0.236-1.939,0.355-3.072,0.355h-0.73
39
- c-0.522,0-1.029,0.188-1.427,0.525c-0.399,0.344-0.663,0.814-0.744,1.328l-0.055,0.299l-0.924,5.855l-0.042,0.215
40
- c-0.011,0.068-0.03,0.102-0.058,0.125c-0.025,0.021-0.061,0.035-0.096,0.035H7.266z"/>
41
- <path fill="#179BD7" d="M23.048,7.667L23.048,7.667L23.048,7.667c-0.028,0.179-0.06,0.362-0.096,0.55
42
- c-1.237,6.351-5.469,8.545-10.874,8.545H9.326c-0.661,0-1.218,0.48-1.321,1.132l0,0l0,0L6.596,26.83l-0.399,2.533
43
- c-0.067,0.428,0.263,0.814,0.695,0.814h4.881c0.578,0,1.069-0.42,1.16-0.99l0.048-0.248l0.919-5.832l0.059-0.32
44
- c0.09-0.572,0.582-0.992,1.16-0.992h0.73c4.729,0,8.431-1.92,9.513-7.476c0.452-2.321,0.218-4.259-0.978-5.622
45
- C24.022,8.286,23.573,7.945,23.048,7.667z"/>
46
- <path fill="#222D65" d="M21.754,7.151c-0.189-0.055-0.384-0.105-0.584-0.15c-0.201-0.044-0.407-0.083-0.619-0.117
47
- c-0.742-0.12-1.555-0.177-2.426-0.177h-7.352c-0.181,0-0.353,0.041-0.507,0.115C9.927,6.985,9.675,7.306,9.614,7.699L8.05,17.605
48
- l-0.045,0.289c0.103-0.652,0.66-1.132,1.321-1.132h2.752c5.405,0,9.637-2.195,10.874-8.545c0.037-0.188,0.068-0.371,0.096-0.55
49
- c-0.313-0.166-0.652-0.308-1.017-0.429C21.941,7.208,21.848,7.179,21.754,7.151z"/>
50
- <path fill="#253B80" d="M9.614,7.699c0.061-0.393,0.313-0.714,0.652-0.876c0.155-0.074,0.326-0.115,0.507-0.115h7.352
51
- c0.871,0,1.684,0.057,2.426,0.177c0.212,0.034,0.418,0.073,0.619,0.117c0.2,0.045,0.395,0.095,0.584,0.15
52
- c0.094,0.028,0.187,0.057,0.278,0.086c0.365,0.121,0.704,0.264,1.017,0.429c0.368-2.347-0.003-3.945-1.272-5.392
53
- C20.378,0.682,17.853,0,14.622,0h-9.38c-0.66,0-1.223,0.48-1.325,1.133L0.01,25.898c-0.077,0.49,0.301,0.932,0.795,0.932h5.791
54
- l1.454-9.225L9.614,7.699z"/>
55
- </svg>
1
+ <?xml version="1.0" encoding="utf-8"?>
2
+ <!-- Generator: Adobe Illustrator 16.0.4, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
3
+ <!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
4
+ <svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
5
+ width="124px" height="33px" viewBox="0 0 124 33" enable-background="new 0 0 124 33" xml:space="preserve">
6
+ <path fill="#253B80" d="M46.211,6.749h-6.839c-0.468,0-0.866,0.34-0.939,0.802l-2.766,17.537c-0.055,0.346,0.213,0.658,0.564,0.658
7
+ h3.265c0.468,0,0.866-0.34,0.939-0.803l0.746-4.73c0.072-0.463,0.471-0.803,0.938-0.803h2.165c4.505,0,7.105-2.18,7.784-6.5
8
+ c0.306-1.89,0.013-3.375-0.872-4.415C50.224,7.353,48.5,6.749,46.211,6.749z M47,13.154c-0.374,2.454-2.249,2.454-4.062,2.454
9
+ h-1.032l0.724-4.583c0.043-0.277,0.283-0.481,0.563-0.481h0.473c1.235,0,2.4,0,3.002,0.704C47.027,11.668,47.137,12.292,47,13.154z"
10
+ />
11
+ <path fill="#253B80" d="M66.654,13.075h-3.275c-0.279,0-0.52,0.204-0.563,0.481l-0.145,0.916l-0.229-0.332
12
+ c-0.709-1.029-2.29-1.373-3.868-1.373c-3.619,0-6.71,2.741-7.312,6.586c-0.313,1.918,0.132,3.752,1.22,5.031
13
+ c0.998,1.176,2.426,1.666,4.125,1.666c2.916,0,4.533-1.875,4.533-1.875l-0.146,0.91c-0.055,0.348,0.213,0.66,0.562,0.66h2.95
14
+ c0.469,0,0.865-0.34,0.939-0.803l1.77-11.209C67.271,13.388,67.004,13.075,66.654,13.075z M62.089,19.449
15
+ c-0.316,1.871-1.801,3.127-3.695,3.127c-0.951,0-1.711-0.305-2.199-0.883c-0.484-0.574-0.668-1.391-0.514-2.301
16
+ c0.295-1.855,1.805-3.152,3.67-3.152c0.93,0,1.686,0.309,2.184,0.892C62.034,17.721,62.232,18.543,62.089,19.449z"/>
17
+ <path fill="#253B80" d="M84.096,13.075h-3.291c-0.314,0-0.609,0.156-0.787,0.417l-4.539,6.686l-1.924-6.425
18
+ c-0.121-0.402-0.492-0.678-0.912-0.678h-3.234c-0.393,0-0.666,0.384-0.541,0.754l3.625,10.638l-3.408,4.811
19
+ c-0.268,0.379,0.002,0.9,0.465,0.9h3.287c0.312,0,0.604-0.152,0.781-0.408L84.564,13.97C84.826,13.592,84.557,13.075,84.096,13.075z
20
+ "/>
21
+ <path fill="#179BD7" d="M94.992,6.749h-6.84c-0.467,0-0.865,0.34-0.938,0.802l-2.766,17.537c-0.055,0.346,0.213,0.658,0.562,0.658
22
+ h3.51c0.326,0,0.605-0.238,0.656-0.562l0.785-4.971c0.072-0.463,0.471-0.803,0.938-0.803h2.164c4.506,0,7.105-2.18,7.785-6.5
23
+ c0.307-1.89,0.012-3.375-0.873-4.415C99.004,7.353,97.281,6.749,94.992,6.749z M95.781,13.154c-0.373,2.454-2.248,2.454-4.062,2.454
24
+ h-1.031l0.725-4.583c0.043-0.277,0.281-0.481,0.562-0.481h0.473c1.234,0,2.4,0,3.002,0.704
25
+ C95.809,11.668,95.918,12.292,95.781,13.154z"/>
26
+ <path fill="#179BD7" d="M115.434,13.075h-3.273c-0.281,0-0.52,0.204-0.562,0.481l-0.145,0.916l-0.23-0.332
27
+ c-0.709-1.029-2.289-1.373-3.867-1.373c-3.619,0-6.709,2.741-7.311,6.586c-0.312,1.918,0.131,3.752,1.219,5.031
28
+ c1,1.176,2.426,1.666,4.125,1.666c2.916,0,4.533-1.875,4.533-1.875l-0.146,0.91c-0.055,0.348,0.213,0.66,0.564,0.66h2.949
29
+ c0.467,0,0.865-0.34,0.938-0.803l1.771-11.209C116.053,13.388,115.785,13.075,115.434,13.075z M110.869,19.449
30
+ c-0.314,1.871-1.801,3.127-3.695,3.127c-0.949,0-1.711-0.305-2.199-0.883c-0.484-0.574-0.666-1.391-0.514-2.301
31
+ c0.297-1.855,1.805-3.152,3.67-3.152c0.93,0,1.686,0.309,2.184,0.892C110.816,17.721,111.014,18.543,110.869,19.449z"/>
32
+ <path fill="#179BD7" d="M119.295,7.23l-2.807,17.858c-0.055,0.346,0.213,0.658,0.562,0.658h2.822c0.469,0,0.867-0.34,0.939-0.803
33
+ l2.768-17.536c0.055-0.346-0.213-0.659-0.562-0.659h-3.16C119.578,6.749,119.338,6.953,119.295,7.23z"/>
34
+ <path fill="#253B80" d="M7.266,29.154l0.523-3.322l-1.165-0.027H1.061L4.927,1.292C4.939,1.218,4.978,1.149,5.035,1.1
35
+ c0.057-0.049,0.13-0.076,0.206-0.076h9.38c3.114,0,5.263,0.648,6.385,1.927c0.526,0.6,0.861,1.227,1.023,1.917
36
+ c0.17,0.724,0.173,1.589,0.007,2.644l-0.012,0.077v0.676l0.526,0.298c0.443,0.235,0.795,0.504,1.065,0.812
37
+ c0.45,0.513,0.741,1.165,0.864,1.938c0.127,0.795,0.085,1.741-0.123,2.812c-0.24,1.232-0.628,2.305-1.152,3.183
38
+ c-0.482,0.809-1.096,1.48-1.825,2c-0.696,0.494-1.523,0.869-2.458,1.109c-0.906,0.236-1.939,0.355-3.072,0.355h-0.73
39
+ c-0.522,0-1.029,0.188-1.427,0.525c-0.399,0.344-0.663,0.814-0.744,1.328l-0.055,0.299l-0.924,5.855l-0.042,0.215
40
+ c-0.011,0.068-0.03,0.102-0.058,0.125c-0.025,0.021-0.061,0.035-0.096,0.035H7.266z"/>
41
+ <path fill="#179BD7" d="M23.048,7.667L23.048,7.667L23.048,7.667c-0.028,0.179-0.06,0.362-0.096,0.55
42
+ c-1.237,6.351-5.469,8.545-10.874,8.545H9.326c-0.661,0-1.218,0.48-1.321,1.132l0,0l0,0L6.596,26.83l-0.399,2.533
43
+ c-0.067,0.428,0.263,0.814,0.695,0.814h4.881c0.578,0,1.069-0.42,1.16-0.99l0.048-0.248l0.919-5.832l0.059-0.32
44
+ c0.09-0.572,0.582-0.992,1.16-0.992h0.73c4.729,0,8.431-1.92,9.513-7.476c0.452-2.321,0.218-4.259-0.978-5.622
45
+ C24.022,8.286,23.573,7.945,23.048,7.667z"/>
46
+ <path fill="#222D65" d="M21.754,7.151c-0.189-0.055-0.384-0.105-0.584-0.15c-0.201-0.044-0.407-0.083-0.619-0.117
47
+ c-0.742-0.12-1.555-0.177-2.426-0.177h-7.352c-0.181,0-0.353,0.041-0.507,0.115C9.927,6.985,9.675,7.306,9.614,7.699L8.05,17.605
48
+ l-0.045,0.289c0.103-0.652,0.66-1.132,1.321-1.132h2.752c5.405,0,9.637-2.195,10.874-8.545c0.037-0.188,0.068-0.371,0.096-0.55
49
+ c-0.313-0.166-0.652-0.308-1.017-0.429C21.941,7.208,21.848,7.179,21.754,7.151z"/>
50
+ <path fill="#253B80" d="M9.614,7.699c0.061-0.393,0.313-0.714,0.652-0.876c0.155-0.074,0.326-0.115,0.507-0.115h7.352
51
+ c0.871,0,1.684,0.057,2.426,0.177c0.212,0.034,0.418,0.073,0.619,0.117c0.2,0.045,0.395,0.095,0.584,0.15
52
+ c0.094,0.028,0.187,0.057,0.278,0.086c0.365,0.121,0.704,0.264,1.017,0.429c0.368-2.347-0.003-3.945-1.272-5.392
53
+ C20.378,0.682,17.853,0,14.622,0h-9.38c-0.66,0-1.223,0.48-1.325,1.133L0.01,25.898c-0.077,0.49,0.301,0.932,0.795,0.932h5.791
54
+ l1.454-9.225L9.614,7.699z"/>
55
+ </svg>
admin/js/admin.js CHANGED
@@ -1,697 +1,697 @@
1
- /*
2
- jQuery functions for the Admin area
3
- */
4
- jQuery(document).ready(function($) {
5
-
6
- /* System Status */
7
-
8
- /* Email address validation */
9
-
10
- function isValidEmailAddress(emailAddress) {
11
- var pattern = /^([a-z\d!#$%&'*+\-\/=?^_`{|}~\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]+(\.[a-z\d!#$%&'*+\-\/=?^_`{|}~\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]+)*|"((([ \t]*\r\n)?[ \t]+)?([\x01-\x08\x0b\x0c\x0e-\x1f\x7f\x21\x23-\x5b\x5d-\x7e\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]|\\[\x01-\x09\x0b\x0c\x0d-\x7f\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]))*(([ \t]*\r\n)?[ \t]+)?")@(([a-z\d\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]|[a-z\d\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF][a-z\d\-._~\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]*[a-z\d\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])\.)+([a-z\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]|[a-z\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF][a-z\d\-._~\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]*[a-z\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])\.?$/i;
12
- return pattern.test(emailAddress);
13
- }
14
-
15
- function hideShowBtns(previewForm) {
16
- if (previewForm.find('label').length < 1) {
17
- $('.button[data-property="label"]').hide();
18
- } else {
19
- $('.button[data-property="label"]').show();
20
- }
21
- if (previewForm.find('p').length < 1) {
22
- $('.button[data-property="p"]').hide();
23
- } else {
24
- $('.button[data-property="p"]').show();
25
- }
26
- if (previewForm.find('fieldset').length < 1) {
27
- $('.button[data-property="fieldset"]').hide();
28
- } else {
29
- $('.button[data-property="fieldset"]').show();
30
- }
31
- if (previewForm.find('select').length < 1) {
32
- $('.button[data-property="select"]').hide();
33
- } else {
34
- $('.button[data-property="select"]').show();
35
- }
36
- if (previewForm.find('input[type="checkbox"]').length < 1) {
37
- $('.button[data-property="checkbox"]').hide();
38
- } else {
39
- $('.button[data-property="checkbox"]').show();
40
- }
41
- if (previewForm.find('input[type="radio"]').length < 1) {
42
- $('.button[data-property="radio"]').hide();
43
- } else {
44
- $('.button[data-property="radio"]').show();
45
- }
46
- }
47
-
48
- /* Validation border color */
49
-
50
- function validateInput(elem, result) {
51
-
52
- if (result == 'valid') {
53
- elem.css('border-color', '#ddd');
54
- } else {
55
- elem.css('border-color', 'red');
56
- }
57
- }
58
-
59
- /* Send Report */
60
-
61
- var cf7s_status_name = $('.cf7style-name'),
62
- cf7s_status_email = $('.cf7style-email'),
63
- cf7s_status_message = $('.cf7style-message'),
64
- cf7s_status_submit = $('.cf7style-status-submit');
65
-
66
- cf7s_status_submit.on('click', function(e) {
67
- e.preventDefault();
68
-
69
- $('.cf7style-input').each(function(index, value) {
70
- if ($(this).val() == '') {
71
- validateInput($(this), 'error');
72
- } else {
73
- validateInput($(this), 'valid');
74
- }
75
- });
76
-
77
- if (cf7s_status_name.val() !== '' && cf7s_status_email.val() !== '') {
78
- if (!isValidEmailAddress(cf7s_status_email.val())) {
79
- validateInput(cf7s_status_email, 'error');
80
- } else {
81
- validateInput(cf7s_status_email, 'valid');
82
-
83
- var status = $('<div />');
84
-
85
- $('.cf7style-status-table').each(function(index, value) {
86
- var table = $("<table />");
87
- table.html($(this).html());
88
- status.append(table);
89
- });
90
-
91
- $.ajax({
92
- 'url': ajaxurl,
93
- 'method': 'POST',
94
- 'data': {
95
- 'action': 'cf7_style_send_status_report',
96
- 'name': cf7s_status_name.val(),
97
- 'email': cf7s_status_email.val(),
98
- 'message': cf7s_status_message.val(),
99
- 'report': status.html()
100
- },
101
- 'beforeSend': function() {
102
- cf7s_status_submit.text('Sending...');
103
- },
104
- 'success': function(data) {
105
- if ($.trim(data) == 'success') {
106
- cf7s_status_submit.text('Report sent').removeClass('cf7style-status-submit').attr('disabled', 'disabled');
107
- } else {
108
- cf7s_status_submit.text('Something went wrong!').removeClass('cf7style-status-submit').attr('disabled', 'disabled');
109
- }
110
- }
111
- });
112
- }
113
-
114
- } else {
115
- console.log('error 1');
116
- }
117
- });
118
-
119
- /* Show info */
120
-
121
- $('.cf7style-status-info').on('click', function(e) {
122
- e.preventDefault();
123
- $('.cf7style-status-table').toggle();
124
-
125
- });
126
-
127
- String.prototype.filename = function(extension) {
128
- var s = this.replace(/\\/g, '/');
129
- s = s.substring(s.lastIndexOf('/') + 1);
130
- return extension ? s.replace(/[?#].+$/, '') : s.split('.')[0];
131
- }
132
-
133
- function changeFont(value) {
134
- $(".google-fontos").remove();
135
- if ("none" != value && "undefined" != typeof value) {
136
- $("head").append('<link class="google-fontos" rel="stylesheet" href="https://fonts.googleapis.com/css?family=' + value + ':100,200,300,400,500,600,700,800,900&subset=latin,latin-ext,cyrillic,cyrillic-ext,greek-ext,greek,vietnamese" />');
137
- $(".cf7-style.preview-zone p").css("font-family", "'" + value + "', sans-serif");
138
- $('.preview-form-container .wpcf7').css("font-family", "'" + value + "', sans-serif");
139
- }
140
- }
141
-
142
- function scrolling(element) {
143
- $(window).scroll(function() {
144
- if ($(window).width() > 1600) {
145
- var offset = element.find('.panel-header').offset(),
146
- cf7styleOffset = $('#cf7_style_meta_box_style_customizer').offset(),
147
- diff = $(window).scrollTop() - cf7styleOffset.top;
148
- if (diff > 0) {
149
- element.find('.panel-header').css('top', diff);
150
- }
151
- if (diff <= 0) {
152
- element.find('.panel-header').css('top', 0);
153
- }
154
- }
155
- if ($(window).scrollTop() > 700) {
156
- $('.fixed-save-style').show();
157
- } else {
158
- $('.fixed-save-style').hide();
159
- }
160
-
161
- }).trigger('scroll');
162
- }
163
-
164
- function autoCompleteOtherValues() {
165
- $("input[type='number']").on("change", function() {
166
- var _t = $(this),
167
- value = _t.val(),
168
- indexor = _t.parent().index(),
169
- allInput = _t.parent().parent().find("input[type=number]");
170
- switch (indexor) {
171
- case 1:
172
- allInput.each(function() {
173
- if (parseFloat($(this).attr('step')) == parseFloat(_t.attr('step'))) {
174
- $(this).val(value);
175
- }
176
- });
177
- break;
178
- case 2:
179
- if (parseFloat(allInput.eq(3).attr('step')) == parseFloat(_t.attr('step'))) {
180
- allInput.eq(3).val(value);
181
- }
182
- break;
183
- }
184
- });
185
- }
186
-
187
- function initialPreview(previewType) {
188
- var hiddenInputData = $('input[name="cf7styleallvalues"]');
189
- if (hiddenInputData.length > 0) {
190
- var loadedData = $('input[name="cf7styleallvalues"]').val(),
191
- loadedArray = $.parseJSON(loadedData.replace(/'/g, '"'));
192
- $('.place-style').remove();
193
- $.each(loadedArray, function(index, value) {
194
- if (index.indexOf('unit') < 0 && ((previewType == "hover" && index.indexOf('hover') > 0) || (previewType != "hover" && index.indexOf('hover') < 0))) {
195
- var splitArray = index.split("_"),
196
- newElem = splitArray[0],
197
- unit = (previewType == "hover" && index.indexOf('hover') > 0) ? loadedArray[index.replace('hover', '') + "unit_hover"] : loadedArray[index + "_unit"];
198
- if (splitArray[0] == "placeholder" && value != '') {
199
- unit = (typeof unit == 'undefined' || value == "") ? "" : unit;
200
- var newValue = value + unit;
201
- var $style = $('<style>').attr('class', 'place-style');
202
- $style.text(
203
- '.preview-form-container ::-webkit-input-placeholder { ' +
204
- splitArray[1] + ': ' + newValue + ';' +
205
- '}' +
206
- '.preview-form-container ::-moz-placeholder { ' +
207
- splitArray[1] + ': ' + newValue + ';' +
208
- '}' +
209
- '.preview-form-container :-ms-input-placeholder { ' +
210
- splitArray[1] + ': ' + newValue + ';' +
211
- '}' +
212
- '.preview-form-container :-moz-placeholder { ' +
213
- splitArray[1] + ': ' + newValue + ';' +
214
- '}');
215
- $style.appendTo('head');
216
- return;
217
- }
218
-
219
- if (splitArray[0] == "submit") {
220
- newElem = "input[type='submit']";
221
- }
222
- if (splitArray[0] == "form") {
223
- newElem = ".wpcf7";
224
- }
225
- if (splitArray[0] == 'wpcf7-not-valid-tip' || splitArray[0] == 'wpcf7-validation-errors' || splitArray[0] == 'wpcf7-mail-sent-ok') {
226
- newElem = "." + splitArray[0];
227
- }
228
- unit = (typeof unit == 'undefined' || value == "") ? "" : unit;
229
- var newValue = value + unit;
230
- if (splitArray[1] == "background-image") {
231
- newValue = 'url(' + value + ')';
232
- }
233
- newElem = (newElem == 'radio') ? 'input[type="radio"]' : (newElem == 'checkbox') ? 'input[type="checkbox"]' : newElem;
234
- $('.preview-form-container ' + newElem).css(splitArray[1], newValue);
235
- }
236
- });
237
- }
238
- }
239
-
240
- function selectAllForms(element) {
241
- element.on("click", function() {
242
- $(".cf7style_body_select_all input").prop('checked', ($(this).is(":checked")) ? true : false);
243
- });
244
- }
245
-
246
- function cf7_slider(elem, slideWidth, animationSpeed, showArrows) {
247
-
248
- var active = elem.find('.active'),
249
- index = active.index() + 1,
250
- slide = elem.find('li'),
251
- sliderViewport = elem.find('ul'),
252
- arrow = elem.find('.narrow'),
253
- arrowLeft = elem.find('.narrow.left'),
254
- arrowRight = elem.find('.narrow.right'),
255
- totalSlides = elem.find('li').length;
256
-
257
- arrowRight.addClass('visible');
258
- sliderViewport.css('width', totalSlides * slideWidth);
259
-
260
- if (showArrows == false) {
261
- elem.mouseenter(function() {
262
- elem.find('.visible').stop().show();
263
- }).mouseleave(function() {
264
- elem.find('.visible').stop().hide();
265
- });
266
- }
267
-
268
- arrow.on('click', function(e) {
269
- e.stopPropagation();
270
- e.preventDefault();
271
- var direction = $(this).attr('data-direction');
272
-
273
- if (direction == "left" && index !== 1) {
274
- sliderViewport.stop(true, true).animate({
275
- marginLeft: "+=" + (slideWidth) + "px"
276
- }, animationSpeed);
277
-
278
- index--;
279
- }
280
-
281
- if (direction == "right" && index !== totalSlides) {
282
- sliderViewport.stop(true, true).animate({
283
- marginLeft: -(slideWidth * index) + "px"
284
- }, animationSpeed);
285
-
286
- index++;
287
- }
288
-
289
- if (index == 1) {
290
- arrowLeft.hide().removeClass('visible');
291
- arrowRight.show().addClass('visible');
292
- }
293
-
294
- if (index == totalSlides) {
295
- arrowRight.hide().removeClass('visible');
296
- }
297
-
298
- if (index < totalSlides) {
299
- arrowRight.show().addClass('visible');
300
- }
301
-
302
- if (index > 1) {
303
- arrowLeft.show().addClass('visible');
304
- }
305
-
306
- slide.removeClass('active').eq(index - 1).addClass('active');
307
- });
308
- sliderViewport.css({
309
- 'margin-left': '-' + (index - 1) * slideWidth + 'px'
310
- });
311
- }
312
-
313
- function sliderInit(element) {
314
- cf7_slider(element, 202, 500, true);
315
- element.find('li').on('click', function() {
316
- if (!$(this).hasClass('current-saved')) {
317
- element.find('li').removeClass('current-saved');
318
- $(this).addClass('current-saved');
319
- element.find('.overlay em').html('Not Active');
320
- $(this).find('.overlay em').html('Active');
321
- $('.cf7style_template').removeAttr('checked');
322
- $(this).find('.cf7style_template').attr("checked", "checked");
323
- }
324
- });
325
- }
326
-
327
- $.fn.serializeObject = function() {
328
- var o = {};
329
- var a = this.serializeArray();
330
- $.each(a, function() {
331
- if (o[this.name] !== undefined) {
332
- if (!o[this.name].push) {
333
- o[this.name] = [o[this.name]];
334
- }
335
- o[this.name].push(this.value || '');
336
- } else {
337
- o[this.name] = this.value || '';
338
- }
339
- });
340
- return o;
341
- }
342
-
343
- function updateHiddenInput(current) {
344
- var loadedString = "",
345
- loadedArray = $.parseJSON($('input[name="cf7styleallvalues"]').val().replace(/'/g, '"'));
346
- $.each(current.serializeObject(), function(index, value) {
347
- if (loadedArray.length == 0) {
348
- loadedArray = {};
349
- }
350
- loadedArray[index.replace(/cf7stylecustom\[/g, '').replace(/]/g, '')] = value;
351
- });
352
- loadedString = JSON.stringify(loadedArray);
353
- loadedString = loadedString.replace(/cf7stylecustom\[/g, '').replace(/]/g, '').replace(/"/g, "'");
354
- $('input[name="cf7styleallvalues"]').val(loadedString);
355
- $('input[name="cf7styleallvalues"]').attr('value', loadedString);
356
- }
357
-
358
- function showTheOption() {
359
- initialPreview();
360
- $('#form-tag a.button').on('click', function(e) {
361
- e.preventDefault();
362
- var _t = $(this),
363
- currentElement = $('.' + _t.attr('data-property') + '-panel'),
364
- onlyOnce = 0;
365
- if ($('.modified-style-here').length == 0) {
366
- if (!_t.hasClass('button-primary')) {
367
- $('.panel').stop(true, true).animate({
368
- 'opacity': 0
369
- }, 300, function() {
370
- if (onlyOnce === 0) {
371
- onlyOnce++;
372
-
373
- $('.panel').addClass('hidden');
374
- $('.panel').html('');
375
- currentElement.css('opacity', '0');
376
- currentElement.removeClass('hidden');
377
-
378
- $.ajax({
379
- 'url': ajaxurl,
380
- 'method': 'POST',
381
- 'data': {
382
- 'action': 'cf7_style_load_property',
383
- 'property': _t.attr('data-property')
384
- },
385
- 'beforeSend': function() {
386
- _t.parent().find('a').prop('disabled', 'true');
387
- $('.panel-options .loading').removeClass('hidden');
388
- },
389
- 'success': function(data) {
390
- _t.parent().find('a').prop('disabled', 'false');
391
- onlyOnce = 0;
392
- currentElement.html(data);
393
- $('.panel-options .loading').addClass('hidden');
394
- var loadedData = $('input[name="cf7styleallvalues"]').val(),
395
- loadedArray = $.parseJSON(loadedData.replace(/'/g, '"'));
396
- currentElement.find('[name^="cf7stylecustom"]').each(function() {
397
- if (($(this).attr('id') in loadedArray) && loadedArray[$(this).attr('id')] != "") {
398
- $(this).val(loadedArray[$(this).attr('id')]);
399
- }
400
- });
401
- currentElement.find('.cf7-style-color-field').wpColorPicker(options);
402
- autoCompleteOtherValues();
403
- addBgImage();
404
- currentElement.stop(true, true).animate({
405
- 'opacity': 1
406
- }, 300);
407
- injectCheckbox();
408
- changeInputStep();
409
- }
410
- });
411
-
412
- }
413
- });
414
-
415
- $(".element-selector input:eq(0)").prop("checked", true);
416
- }
417
- $('#form-tag a.button').removeClass('button-primary');
418
- _t.addClass('button-primary');
419
- $('input[name="cf7styleactivepane"]').val(_t.attr('data-property'));
420
- } else {
421
- $('.panel-options .decision').removeClass('hidden');
422
- }
423
- });
424
-
425
- $('.panel-options .cancel-btn').on('click', function(e) {
426
- e.preventDefault();
427
- $('.panel-options .decision').addClass('hidden');
428
- });
429
-
430
- $('.element-selector input').on('change', function() {
431
- $('.element-selector input').prop('checked', false);
432
- $(this).prop('checked', true);
433
- if ($(this).val() == "hover") {
434
- $('.panel:visible li').addClass('hidden');
435
- $('.panel:visible li.hover-element').removeClass('hidden');
436
- initialPreview("hover");
437
- } else {
438
- $('.panel:visible li.hover-element').addClass('hidden');
439
- $('.panel:visible li').not('.hover-element').removeClass('hidden');
440
- initialPreview();
441
- }
442
- });
443
- $('#form-preview').on('change', function() {
444
- $('.preview-form-container').addClass('hidden');
445
- $('.preview-form-container').eq($(this).val()).removeClass('hidden');
446
- hideShowBtns( $('.preview-form-container').eq($(this).val()) );
447
- });
448
- var once = 0;
449
- $(document).on("change", '[name^="cf7stylecustom"]', function() {
450
- if (once == 0) {
451
- once++;
452
- $(this).parents('.panel').addClass('modified-style-here');
453
- }
454
- updateHiddenInput($(this).parents('.panel').find('[name^="cf7stylecustom"]'));
455
- if ($('input[name="element-type"]:checked').val() == "hover") {
456
- initialPreview('hover');
457
- } else {
458
- initialPreview();
459
- }
460
- });
461
- $(document).on("keyup", '[name^="cf7stylecustom"]', function() {
462
- updateHiddenInput($(this).parents('.panel').find('[name^="cf7stylecustom"]'));
463
- if ($('input[name="element-type"]:checked').val() == "hover") {
464
- initialPreview('hover');
465
- } else {
466
- initialPreview();
467
- }
468
- });
469
- }
470
-
471
- function removePreviewfields(element) {
472
- element.remove();
473
- }
474
-
475
- function disableSubmit(element) {
476
- element.on('click', function(e) {
477
- e.preventDefault();
478
- });
479
- }
480
-
481
- function addDummyElements() {
482
- $('.wpcf7 input[aria-required="true"]').each(function() {
483
- $('<span role="alert" class="wpcf7-not-valid-tip">Required field message example.</span>').insertAfter($(this));
484
- });
485
- $('.wpcf7').each(function() {
486
- $('<div class="wpcf7-response-output wpcf7-display-none wpcf7-validation-errors" style="display: block;" role="alert">Error message example.</div>').appendTo($(this));
487
- $('<div class="wpcf7-response-output wpcf7-display-none wpcf7-mail-sent-ok" style="display: block;" role="alert">Thank you message example.</div>').appendTo($(this));
488
- });
489
- }
490
-
491
- function addBgImage() {
492
- var bgFormInput = $('.cf7-style-upload-field');
493
- bgFormInput.addClass('hidden');
494
- bgFormInput.each(function() {
495
- var _t = $(this);
496
- $('<span class="image-info-box"></span>').insertAfter(_t);
497
- if (_t.val() != "") {
498
- _t.parent().find('.image-info-box').text(_t.val().filename('yes'));
499
- }
500
- });
501
- if ($('.upload-btn').length <= 0) {
502
- $("<a href='javascript: void(0);' class='remove-btn button'>Remove</a>").insertAfter(bgFormInput);
503
- $("<a href='javascript: void(0);' class='upload-btn button'>Upload</a>").insertAfter(bgFormInput);
504
- }
505
- $('.upload-btn').on('click', function() {
506
- var _t = $(this),
507
- currentimage = _t.parent().find('.cf7-style-upload-field');
508
- tb_show('New Banner', 'media-upload.php?type=image&TB_iframe=1');
509
- window.send_to_editor = function(html) {
510
- currentimage.val($(html).attr('src'));
511
- currentimage.trigger('change');
512
- _t.parent().find('.image-info-box').text($(html).attr('src').filename('yes'));
513
- tb_remove();
514
- }
515
- });
516
- $('.remove-btn').on('click', function() {
517
- var _t = $(this),
518
- currentimage = _t.parent().find('.cf7-style-upload-field');
519
- currentimage.val(' ');
520
- currentimage.attr('value', ' ');
521
- currentimage.trigger('change');
522
- _t.parent().find('.image-info-box').text('');
523
- });
524
- }
525
-
526
- function codeMirrorInit() {
527
- if ($("#cf7_style_manual_style").length > 0) {
528
- var editor = CodeMirror.fromTextArea(document.getElementById("cf7_style_manual_style"), {
529
- lineNumbers: true,
530
- theme: "default",
531
- mode: "text/css"
532
- });
533
- }
534
- }
535
- if ($('.cf7style-no-forms-added').length > 0) {
536
- $('.generate-preview-button, .generate-preview-option').show();
537
- } else {
538
- $('.generate-button-hidden').show();
539
- }
540
-
541
- $('.generate-preview-button').on('click', function(e) {
542
- e.preventDefault();
543
- $('.cf7style-no-forms-added').hide();
544
-
545
- var form_id = $(this).attr('data-attr-id'),
546
- form_title = $(this).attr('data-attr-title');
547
- $(this).prop('disabled', true);
548
- $(this).parents('tr').find('input').prop('checked', true);
549
-
550
- var paragraph = $("<p />");
551
- $('.preview-form-tag').prepend(paragraph);
552
-
553
- $.ajax({
554
- 'url': ajaxurl,
555
- 'method': 'POST',
556
- 'data': {
557
- 'action': 'cf7_style_generate_preview_dashboard',
558
- 'form_id': form_id,
559
- 'form_title': form_title
560
- },
561
- 'beforeSend': function() {
562
- paragraph.text("Loading...");
563
- $('.multiple-form-generated-preview').hide();
564
- },
565
- 'success': function(data) {
566
- if (data) {
567
- paragraph.remove();
568
- $('.preview-form-tag').append(data);
569
- $('.multiple-form-generated-preview').eq($('.multiple-form-generated-preview').length - 1).show();
570
- initialPreview();
571
- addDummyElements();
572
- hideShowBtns($('.preview-form-container form:visible'));
573
- }
574
- }
575
- });
576
- });
577
-
578
- function injectCheckbox() {
579
-
580
- $('.wp-picker-container').each(function() {
581
- if ($(this).parent().find('label[for*="_color"]').length < 1) {
582
- $('<label><input type="checkbox" class="transparent-box" name="transparent-box">Transparent</label>').insertAfter($(this));
583
- }
584
- });
585
- $('.transparent-box').each(function() {
586
- var curParent = $(this).parent().parent();
587
- if (curParent.find('.cf7-style-color-field').val() == "transparent") {
588
- $(this).prop("checked", true);
589
- }
590
- });
591
- $('.transparent-box').on('click', function() {
592
- var curParent = $(this).parent().parent();
593
- if ($(this).is(':checked')) {
594
- curParent.find('.cf7-style-color-field').val('transparent');
595
- curParent.find('.cf7-style-color-field').attr('value', 'transparent');
596
- curParent.find('.wp-color-result').css('background-color', 'transparent');
597
- } else {
598
- curParent.find('.cf7-style-color-field').val('');
599
- curParent.find('.cf7-style-color-field').attr('value', '');
600
- }
601
- updateHiddenInput($(this).parents('.panel').find('[name^="cf7stylecustom"]'));
602
- });
603
- }
604
-
605
- function returnStep(element) {
606
- return (("%" == element.val() || "em" == element.val()) ? "0.01" : "1");
607
- }
608
-
609
- function changeInputStep() {
610
- $('.panel input[type="number"]:not([id*="opacity"])').each(function() {
611
- var _t = $(this);
612
- _t.attr('step', returnStep(_t.next()));
613
- });
614
- $('.panel select[name*="unit"]').off("change").on("change", function() {
615
- var _t = $(this);
616
- _t.prev().attr('step', returnStep(_t));
617
- if (_t.val() == "px") {
618
- var curVal = Math.floor(_t.prev().val());
619
- _t.prev().val(curVal);
620
- _t.prev().attr('value', curVal);
621
- }
622
- });
623
- }
624
-
625
- var previewEl = $(".generate-preview"),
626
- cf7StylePostType = $(".post-type-cf7_style"),
627
- selectAll = $('#select_all'),
628
- fontSelectVar = $('select[name="cf7_style_font_selector"]'),
629
- sliderWrapper = $('.cf7-style-slider-wrap'),
630
- previewForm = $('.preview-form-container'),
631
- options = {
632
- change: function(event, ui) {
633
- var _t = $(this);
634
- _t.parents('.wp-picker-container').parent().find('.transparent-box').prop("checked", false);
635
- setTimeout(function() {
636
- updateHiddenInput(_t.parents('.panel').find('[name^="cf7stylecustom"]'));
637
- }, 0);
638
- if ($('input[name="element-type"]:checked').val() == "hover") {
639
- initialPreview('hover');
640
- } else {
641
- initialPreview();
642
- }
643
- }
644
- };
645
-
646
- $('.cf7-style-color-field').wpColorPicker(options);
647
- /*Scrolling on settings*/
648
- if (previewEl.length > 0) {
649
- scrolling(previewEl);
650
- }
651
-
652
- if (cf7StylePostType.length > 0) {
653
- /*codemirror*/
654
- codeMirrorInit();
655
- /*backgroundimage*/
656
- addBgImage();
657
- /*Autocomplete number fields*/
658
- autoCompleteOtherValues();
659
- addDummyElements();
660
- var previewForm = $('.preview-form-container').not('.hidden');
661
- /*Hide settings which are not present in the current selected form*/
662
- if( $('.post-new-php').length < 1 ){
663
- hideShowBtns(previewForm);
664
- }
665
- /*Checkbox for select all the forms*/
666
- selectAllForms(selectAll);
667
- /*Change Font*/
668
- changeFont(fontSelectVar.val());
669
- fontSelectVar.on("change", function() {
670
- changeFont($(this).val());
671
- });
672
- /*show the right options*/
673
- showTheOption();
674
- /*remove nonce*/
675
- removePreviewfields(previewForm.find('input[type="hidden"]'));
676
- /*disable submit*/
677
- disableSubmit(previewForm.find('input[type="submit"]'));
678
- }
679
- if (sliderWrapper.length > 0) {
680
- sliderInit(sliderWrapper);
681
- }
682
- $('.close-cf7-panel').on('click', function(e) {
683
- e.preventDefault();
684
- $.ajax({
685
- 'url': ajaxurl,
686
- 'method': 'POST',
687
- 'data': {
688
- 'action': 'cf7_style_remove_welcome_box'
689
- },
690
- 'success': function(data) {
691
- $('.welcome-container').fadeOut('slow');
692
- }
693
- });
694
- });
695
- injectCheckbox();
696
- changeInputStep();
697
  }); /*doc.ready end*/
1
+ /*
2
+ jQuery functions for the Admin area
3
+ */
4
+ jQuery(document).ready(function($) {
5
+
6
+ /* System Status */
7
+
8
+ /* Email address validation */
9
+
10
+ function isValidEmailAddress(emailAddress) {
11
+ var pattern = /^([a-z\d!#$%&'*+\-\/=?^_`{|}~\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]+(\.[a-z\d!#$%&'*+\-\/=?^_`{|}~\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]+)*|"((([ \t]*\r\n)?[ \t]+)?([\x01-\x08\x0b\x0c\x0e-\x1f\x7f\x21\x23-\x5b\x5d-\x7e\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]|\\[\x01-\x09\x0b\x0c\x0d-\x7f\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]))*(([ \t]*\r\n)?[ \t]+)?")@(([a-z\d\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]|[a-z\d\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF][a-z\d\-._~\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]*[a-z\d\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])\.)+([a-z\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]|[a-z\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF][a-z\d\-._~\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]*[a-z\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])\.?$/i;
12
+ return pattern.test(emailAddress);
13
+ }
14
+
15
+ function hideShowBtns(previewForm) {
16
+ if (previewForm.find('label').length < 1) {
17
+ $('.button[data-property="label"]').hide();
18
+ } else {
19
+ $('.button[data-property="label"]').show();
20
+ }
21
+ if (previewForm.find('p').length < 1) {
22
+ $('.button[data-property="p"]').hide();
23
+ } else {
24
+ $('.button[data-property="p"]').show();
25
+ }
26
+ if (previewForm.find('fieldset').length < 1) {
27
+ $('.button[data-property="fieldset"]').hide();
28
+ } else {
29
+ $('.button[data-property="fieldset"]').show();
30
+ }
31
+ if (previewForm.find('select').length < 1) {
32
+ $('.button[data-property="select"]').hide();
33
+ } else {
34
+ $('.button[data-property="select"]').show();
35
+ }
36
+ if (previewForm.find('input[type="checkbox"]').length < 1) {
37
+ $('.button[data-property="checkbox"]').hide();
38
+ } else {
39
+ $('.button[data-property="checkbox"]').show();
40
+ }
41
+ if (previewForm.find('input[type="radio"]').length < 1) {
42
+ $('.button[data-property="radio"]').hide();
43
+ } else {
44
+ $('.button[data-property="radio"]').show();
45
+ }
46
+ }
47
+
48
+ /* Validation border color */
49
+
50
+ function validateInput(elem, result) {
51
+
52
+ if (result == 'valid') {
53
+ elem.css('border-color', '#ddd');
54
+ } else {
55
+ elem.css('border-color', 'red');
56
+ }
57
+ }
58
+
59
+ /* Send Report */
60
+
61
+ var cf7s_status_name = $('.cf7style-name'),
62
+ cf7s_status_email = $('.cf7style-email'),
63
+ cf7s_status_message = $('.cf7style-message'),
64
+ cf7s_status_submit = $('.cf7style-status-submit');
65
+
66
+ cf7s_status_submit.on('click', function(e) {
67
+ e.preventDefault();
68
+
69
+ $('.cf7style-input').each(function(index, value) {
70
+ if ($(this).val() == '') {
71
+ validateInput($(this), 'error');
72
+ } else {
73
+ validateInput($(this), 'valid');
74
+ }
75
+ });
76
+
77
+ if (cf7s_status_name.val() !== '' && cf7s_status_email.val() !== '') {
78
+ if (!isValidEmailAddress(cf7s_status_email.val())) {
79
+ validateInput(cf7s_status_email, 'error');
80
+ } else {
81
+ validateInput(cf7s_status_email, 'valid');
82
+
83
+ var status = $('<div />');
84
+
85
+ $('.cf7style-status-table').each(function(index, value) {
86
+ var table = $("<table />");
87
+ table.html($(this).html());
88
+ status.append(table);
89
+ });
90
+
91
+ $.ajax({
92
+ 'url': ajaxurl,
93
+ 'method': 'POST',
94
+ 'data': {
95
+ 'action': 'cf7_style_send_status_report',
96
+ 'name': cf7s_status_name.val(),
97
+ 'email': cf7s_status_email.val(),
98
+ 'message': cf7s_status_message.val(),
99
+ 'report': status.html()
100
+ },
101
+ 'beforeSend': function() {
102
+ cf7s_status_submit.text('Sending...');
103
+ },
104
+ 'success': function(data) {
105
+ if ($.trim(data) == 'success') {
106
+ cf7s_status_submit.text('Report sent').removeClass('cf7style-status-submit').attr('disabled', 'disabled');
107
+ } else {
108
+ cf7s_status_submit.text('Something went wrong!').removeClass('cf7style-status-submit').attr('disabled', 'disabled');
109
+ }
110
+ }
111
+ });
112
+ }
113
+
114
+ } else {
115
+ console.log('error 1');
116
+ }
117
+ });
118
+
119
+ /* Show info */
120
+
121
+ $('.cf7style-status-info').on('click', function(e) {
122
+ e.preventDefault();
123
+ $('.cf7style-status-table').toggle();
124
+
125
+ });
126
+
127
+ String.prototype.filename = function(extension) {
128
+ var s = this.replace(/\\/g, '/');
129
+ s = s.substring(s.lastIndexOf('/') + 1);
130
+ return extension ? s.replace(/[?#].+$/, '') : s.split('.')[0];
131
+ }
132
+
133
+ function changeFont(value) {
134
+ $(".google-fontos").remove();
135
+ if ("none" != value && "undefined" != typeof value) {
136
+ $("head").append('<link class="google-fontos" rel="stylesheet" href="https://fonts.googleapis.com/css?family=' + value + ':100,200,300,400,500,600,700,800,900&subset=latin,latin-ext,cyrillic,cyrillic-ext,greek-ext,greek,vietnamese" />');
137
+ $(".cf7-style.preview-zone p").css("font-family", "'" + value + "', sans-serif");
138
+ $('.preview-form-container .wpcf7').css("font-family", "'" + value + "', sans-serif");
139
+ }
140
+ }
141
+
142
+ function scrolling(element) {
143
+ $(window).scroll(function() {
144
+ if ($(window).width() > 1600) {
145
+ var offset = element.find('.panel-header').offset(),
146
+ cf7styleOffset = $('#cf7_style_meta_box_style_customizer').offset(),
147
+ diff = $(window).scrollTop() - cf7styleOffset.top;
148
+ if (diff > 0) {
149
+ element.find('.panel-header').css('top', diff);
150
+ }
151
+ if (diff <= 0) {
152
+ element.find('.panel-header').css('top', 0);
153
+ }
154
+ }
155
+ if ($(window).scrollTop() > 700) {
156
+ $('.fixed-save-style').show();
157
+ } else {
158
+ $('.fixed-save-style').hide();
159
+ }
160
+
161
+ }).trigger('scroll');
162
+ }
163
+
164
+ function autoCompleteOtherValues() {
165
+ $("input[type='number']").on("change", function() {
166
+ var _t = $(this),
167
+ value = _t.val(),
168
+ indexor = _t.parent().index(),
169
+ allInput = _t.parent().parent().find("input[type=number]");
170
+ switch (indexor) {
171
+ case 1:
172
+ allInput.each(function() {
173
+ if (parseFloat($(this).attr('step')) == parseFloat(_t.attr('step'))) {
174
+ $(this).val(value);
175
+ }
176
+ });
177
+ break;
178
+ case 2:
179
+ if (parseFloat(allInput.eq(3).attr('step')) == parseFloat(_t.attr('step'))) {
180
+ allInput.eq(3).val(value);
181
+ }
182
+ break;
183
+ }
184
+ });
185
+ }
186
+
187
+ function initialPreview(previewType) {
188
+ var hiddenInputData = $('input[name="cf7styleallvalues"]');
189
+ if (hiddenInputData.length > 0) {
190
+ var loadedData = $('input[name="cf7styleallvalues"]').val(),
191
+ loadedArray = $.parseJSON(loadedData.replace(/'/g, '"'));
192
+ $('.place-style').remove();
193
+ $.each(loadedArray, function(index, value) {
194
+ if (index.indexOf('unit') < 0 && ((previewType == "hover" && index.indexOf('hover') > 0) || (previewType != "hover" && index.indexOf('hover') < 0))) {
195
+ var splitArray = index.split("_"),
196
+ newElem = splitArray[0],
197
+ unit = (previewType == "hover" && index.indexOf('hover') > 0) ? loadedArray[index.replace('hover', '') + "unit_hover"] : loadedArray[index + "_unit"];
198
+ if (splitArray[0] == "placeholder" && value != '') {
199
+ unit = (typeof unit == 'undefined' || value == "") ? "" : unit;
200
+ var newValue = value + unit;
201
+ var $style = $('<style>').attr('class', 'place-style');
202
+ $style.text(
203
+ '.preview-form-container ::-webkit-input-placeholder { ' +
204
+ splitArray[1] + ': ' + newValue + ';' +
205
+ '}' +
206
+ '.preview-form-container ::-moz-placeholder { ' +
207
+ splitArray[1] + ': ' + newValue + ';' +
208
+ '}' +
209
+ '.preview-form-container :-ms-input-placeholder { ' +
210
+ splitArray[1] + ': ' + newValue + ';' +
211
+ '}' +
212
+ '.preview-form-container :-moz-placeholder { ' +
213
+ splitArray[1] + ': ' + newValue + ';' +
214
+ '}');
215
+ $style.appendTo('head');
216
+ return;
217
+ }
218
+
219
+ if (splitArray[0] == "submit") {
220
+ newElem = "input[type='submit']";
221
+ }
222
+ if (splitArray[0] == "form") {
223
+ newElem = ".wpcf7";
224
+ }
225
+ if (splitArray[0] == 'wpcf7-not-valid-tip' || splitArray[0] == 'wpcf7-validation-errors' || splitArray[0] == 'wpcf7-mail-sent-ok') {
226
+ newElem = "." + splitArray[0];
227
+ }
228
+ unit = (typeof unit == 'undefined' || value == "") ? "" : unit;
229
+ var newValue = value + unit;
230
+ if (splitArray[1] == "background-image") {
231
+ newValue = 'url(' + value + ')';
232
+ }
233
+ newElem = (newElem == 'radio') ? 'input[type="radio"]' : (newElem == 'checkbox') ? 'input[type="checkbox"]' : newElem;
234
+ $('.preview-form-container ' + newElem).css(splitArray[1], newValue);
235
+ }
236
+ });
237
+ }
238
+ }
239
+
240
+ function selectAllForms(element) {
241
+ element.on("click", function() {
242
+ $(".cf7style_body_select_all input").prop('checked', ($(this).is(":checked")) ? true : false);
243
+ });
244
+ }
245
+
246
+ function cf7_slider(elem, slideWidth, animationSpeed, showArrows) {
247
+
248
+ var active = elem.find('.active'),
249
+ index = active.index() + 1,
250
+ slide = elem.find('li'),
251
+ sliderViewport = elem.find('ul'),
252
+ arrow = elem.find('.narrow'),
253
+ arrowLeft = elem.find('.narrow.left'),
254
+ arrowRight = elem.find('.narrow.right'),
255
+ totalSlides = elem.find('li').length;
256
+
257
+ arrowRight.addClass('visible');
258
+ sliderViewport.css('width', totalSlides * slideWidth);
259
+
260
+ if (showArrows == false) {
261
+ elem.mouseenter(function() {
262
+ elem.find('.visible').stop().show();
263
+ }).mouseleave(function() {
264
+ elem.find('.visible').stop().hide();
265
+ });
266
+ }
267
+
268
+ arrow.on('click', function(e) {
269
+ e.stopPropagation();
270
+ e.preventDefault();
271
+ var direction = $(this).attr('data-direction');
272
+
273
+ if (direction == "left" && index !== 1) {
274
+ sliderViewport.stop(true, true).animate({
275
+ marginLeft: "+=" + (slideWidth) + "px"
276
+ }, animationSpeed);
277
+
278
+ index--;
279
+ }
280
+
281
+ if (direction == "right" && index !== totalSlides) {
282
+ sliderViewport.stop(true, true).animate({
283
+ marginLeft: -(slideWidth * index) + "px"
284
+ }, animationSpeed);
285
+
286
+ index++;
287
+ }
288
+
289
+ if (index == 1) {
290
+ arrowLeft.hide().removeClass('visible');
291
+ arrowRight.show().addClass('visible');
292
+ }
293
+
294
+ if (index == totalSlides) {
295
+ arrowRight.hide().removeClass('visible');
296
+ }
297
+
298
+ if (index < totalSlides) {
299
+ arrowRight.show().addClass('visible');
300
+ }
301
+
302
+ if (index > 1) {
303
+ arrowLeft.show().addClass('visible');
304
+ }
305
+
306
+ slide.removeClass('active').eq(index - 1).addClass('active');
307
+ });
308
+ sliderViewport.css({
309
+ 'margin-left': '-' + (index - 1) * slideWidth + 'px'
310
+ });
311
+ }
312
+
313
+ function sliderInit(element) {
314
+ cf7_slider(element, 202, 500, true);
315
+ element.find('li').on('click', function() {
316
+ if (!$(this).hasClass('current-saved')) {
317
+ element.find('li').removeClass('current-saved');
318
+ $(this).addClass('current-saved');
319
+ element.find('.overlay em').html('Not Active');
320
+ $(this).find('.overlay em').html('Active');
321
+ $('.cf7style_template').removeAttr('checked');
322
+ $(this).find('.cf7style_template').attr("checked", "checked");
323
+ }
324
+ });
325
+ }
326
+
327
+ $.fn.serializeObject = function() {
328
+ var o = {};
329
+ var a = this.serializeArray();
330
+ $.each(a, function() {
331
+ if (o[this.name] !== undefined) {
332
+ if (!o[this.name].push) {
333
+ o[this.name] = [o[this.name]];
334
+ }
335
+ o[this.name].push(this.value || '');
336
+ } else {
337
+ o[this.name] = this.value || '';
338
+ }
339
+ });
340
+ return o;
341
+ }
342
+
343
+ function updateHiddenInput(current) {
344
+ var loadedString = "",
345
+ loadedArray = $.parseJSON($('input[name="cf7styleallvalues"]').val().replace(/'/g, '"'));
346
+ $.each(current.serializeObject(), function(index, value) {
347
+ if (loadedArray.length == 0) {
348
+ loadedArray = {};
349
+ }
350
+ loadedArray[index.replace(/cf7stylecustom\[/g, '').replace(/]/g, '')] = value;
351
+ });
352
+ loadedString = JSON.stringify(loadedArray);
353
+ loadedString = loadedString.replace(/cf7stylecustom\[/g, '').replace(/]/g, '').replace(/"/g, "'");
354
+ $('input[name="cf7styleallvalues"]').val(loadedString);
355
+ $('input[name="cf7styleallvalues"]').attr('value', loadedString);
356
+ }
357
+
358
+ function showTheOption() {
359
+ initialPreview();
360
+ $('#form-tag a.button').on('click', function(e) {
361
+ e.preventDefault();
362
+ var _t = $(this),
363
+ currentElement = $('.' + _t.attr('data-property') + '-panel'),
364
+ onlyOnce = 0;
365
+ if ($('.modified-style-here').length == 0) {
366
+ if (!_t.hasClass('button-primary')) {
367
+ $('.panel').stop(true, true).animate({
368
+ 'opacity': 0
369
+ }, 300, function() {
370
+ if (onlyOnce === 0) {
371
+ onlyOnce++;
372
+
373
+ $('.panel').addClass('hidden');
374
+ $('.panel').html('');
375
+ currentElement.css('opacity', '0');
376
+ currentElement.removeClass('hidden');
377
+
378
+ $.ajax({
379
+ 'url': ajaxurl,
380
+ 'method': 'POST',
381
+ 'data': {
382
+ 'action': 'cf7_style_load_property',
383
+ 'property': _t.attr('data-property')
384
+ },
385
+ 'beforeSend': function() {
386
+ _t.parent().find('a').prop('disabled', 'true');
387
+ $('.panel-options .loading').removeClass('hidden');
388
+ },
389
+ 'success': function(data) {
390
+ _t.parent().find('a').prop('disabled', 'false');
391
+ onlyOnce = 0;
392
+ currentElement.html(data);
393
+ $('.panel-options .loading').addClass('hidden');
394
+ var loadedData = $('input[name="cf7styleallvalues"]').val(),
395
+ loadedArray = $.parseJSON(loadedData.replace(/'/g, '"'));
396
+ currentElement.find('[name^="cf7stylecustom"]').each(function() {
397
+ if (($(this).attr('id') in loadedArray) && loadedArray[$(this).attr('id')] != "") {
398
+ $(this).val(loadedArray[$(this).attr('id')]);
399
+ }
400
+ });
401
+ currentElement.find('.cf7-style-color-field').wpColorPicker(options);
402
+ autoCompleteOtherValues();
403
+ addBgImage();
404
+ currentElement.stop(true, true).animate({
405
+ 'opacity': 1
406
+ }, 300);
407
+ injectCheckbox();
408
+ changeInputStep();
409
+ }
410
+ });
411
+
412
+ }
413
+ });
414
+
415
+ $(".element-selector input:eq(0)").prop("checked", true);
416
+ }
417
+ $('#form-tag a.button').removeClass('button-primary');
418
+ _t.addClass('button-primary');
419
+ $('input[name="cf7styleactivepane"]').val(_t.attr('data-property'));
420
+ } else {
421
+ $('.panel-options .decision').removeClass('hidden');
422
+ }
423
+ });
424
+
425
+ $('.panel-options .cancel-btn').on('click', function(e) {
426
+ e.preventDefault();
427
+ $('.panel-options .decision').addClass('hidden');
428
+ });
429
+
430
+ $('.element-selector input').on('change', function() {
431
+ $('.element-selector input').prop('checked', false);
432
+ $(this).prop('checked', true);
433
+ if ($(this).val() == "hover") {
434
+ $('.panel:visible li').addClass('hidden');
435
+ $('.panel:visible li.hover-element').removeClass('hidden');
436
+ initialPreview("hover");
437
+ } else {
438
+ $('.panel:visible li.hover-element').addClass('hidden');
439
+ $('.panel:visible li').not('.hover-element').removeClass('hidden');
440
+ initialPreview();
441
+ }
442
+ });
443
+ $('#form-preview').on('change', function() {
444
+ $('.preview-form-container').addClass('hidden');
445
+ $('.preview-form-container').eq($(this).val()).removeClass('hidden');
446
+ hideShowBtns( $('.preview-form-container').eq($(this).val()) );
447
+ });
448
+ var once = 0;
449
+ $(document).on("change", '[name^="cf7stylecustom"]', function() {
450
+ if (once == 0) {
451
+ once++;
452
+ $(this).parents('.panel').addClass('modified-style-here');
453
+ }
454
+ updateHiddenInput($(this).parents('.panel').find('[name^="cf7stylecustom"]'));
455
+ if ($('input[name="element-type"]:checked').val() == "hover") {
456
+ initialPreview('hover');
457
+ } else {
458
+ initialPreview();
459
+ }
460
+ });
461
+ $(document).on("keyup", '[name^="cf7stylecustom"]', function() {
462
+ updateHiddenInput($(this).parents('.panel').find('[name^="cf7stylecustom"]'));
463
+ if ($('input[name="element-type"]:checked').val() == "hover") {
464
+ initialPreview('hover');
465
+ } else {
466
+ initialPreview();
467
+ }
468
+ });
469
+ }
470
+
471
+ function removePreviewfields(element) {
472
+ element.remove();
473
+ }
474
+
475
+ function disableSubmit(element) {
476
+ element.on('click', function(e) {
477
+ e.preventDefault();
478
+ });
479
+ }
480
+
481
+ function addDummyElements() {
482
+ $('.wpcf7 input[aria-required="true"]').each(function() {
483
+ $('<span role="alert" class="wpcf7-not-valid-tip">Required field message example.</span>').insertAfter($(this));
484
+ });
485
+ $('.wpcf7').each(function() {
486
+ $('<div class="wpcf7-response-output wpcf7-display-none wpcf7-validation-errors" style="display: block;" role="alert">Error message example.</div>').appendTo($(this));
487
+ $('<div class="wpcf7-response-output wpcf7-display-none wpcf7-mail-sent-ok" style="display: block;" role="alert">Thank you message example.</div>').appendTo($(this));
488
+ });
489
+ }
490
+
491
+ function addBgImage() {
492
+ var bgFormInput = $('.cf7-style-upload-field');
493
+ bgFormInput.addClass('hidden');
494
+ bgFormInput.each(function() {
495
+ var _t = $(this);
496
+ $('<span class="image-info-box"></span>').insertAfter(_t);
497
+ if (_t.val() != "") {
498
+ _t.parent().find('.image-info-box').text(_t.val().filename('yes'));
499
+ }
500
+ });
501
+ if ($('.upload-btn').length <= 0) {
502
+ $("<a href='javascript: void(0);' class='remove-btn button'>Remove</a>").insertAfter(bgFormInput);
503
+ $("<a href='javascript: void(0);' class='upload-btn button'>Upload</a>").insertAfter(bgFormInput);
504
+ }
505
+ $('.upload-btn').on('click', function() {
506
+ var _t = $(this),
507
+ currentimage = _t.parent().find('.cf7-style-upload-field');
508
+ tb_show('New Banner', 'media-upload.php?type=image&TB_iframe=1');
509
+ window.send_to_editor = function(html) {
510
+ currentimage.val($(html).attr('src'));
511
+ currentimage.trigger('change');
512
+ _t.parent().find('.image-info-box').text($(html).attr('src').filename('yes'));
513
+ tb_remove();
514
+ }
515
+ });
516
+ $('.remove-btn').on('click', function() {
517
+ var _t = $(this),
518
+ currentimage = _t.parent().find('.cf7-style-upload-field');
519
+ currentimage.val(' ');
520
+ currentimage.attr('value', ' ');
521
+ currentimage.trigger('change');
522
+ _t.parent().find('.image-info-box').text('');
523
+ });
524
+ }
525
+
526
+ function codeMirrorInit() {
527
+ if ($("#cf7_style_manual_style").length > 0) {
528
+ var editor = CodeMirror.fromTextArea(document.getElementById("cf7_style_manual_style"), {
529
+ lineNumbers: true,
530
+ theme: "default",
531
+ mode: "text/css"
532
+ });
533
+ }
534
+ }
535
+ if ($('.cf7style-no-forms-added').length > 0) {
536
+ $('.generate-preview-button, .generate-preview-option').show();
537
+ } else {
538
+ $('.generate-button-hidden').show();
539
+ }
540
+
541
+ $('.generate-preview-button').on('click', function(e) {
542
+ e.preventDefault();
543
+ $('.cf7style-no-forms-added').hide();
544
+
545
+ var form_id = $(this).attr('data-attr-id'),
546
+ form_title = $(this).attr('data-attr-title');
547
+ $(this).prop('disabled', true);
548
+ $(this).parents('tr').find('input').prop('checked', true);
549
+
550
+ var paragraph = $("<p />");
551
+ $('.preview-form-tag').prepend(paragraph);
552
+
553
+ $.ajax({
554
+ 'url': ajaxurl,
555
+ 'method': 'POST',
556
+ 'data': {
557
+ 'action': 'cf7_style_generate_preview_dashboard',
558
+ 'form_id': form_id,
559
+ 'form_title': form_title
560
+ },
561
+ 'beforeSend': function() {
562
+ paragraph.text("Loading...");
563
+ $('.multiple-form-generated-preview').hide();
564
+ },
565
+ 'success': function(data) {
566
+ if (data) {
567
+ paragraph.remove();
568
+ $('.preview-form-tag').append(data);
569
+ $('.multiple-form-generated-preview').eq($('.multiple-form-generated-preview').length - 1).show();
570
+ initialPreview();
571
+ addDummyElements();
572
+ hideShowBtns($('.preview-form-container form:visible'));
573
+ }
574
+ }
575
+ });
576
+ });
577
+
578
+ function injectCheckbox() {
579
+
580
+ $('.wp-picker-container').each(function() {
581
+ if ($(this).parent().find('label[for*="_color"]').length < 1) {
582
+ $('<label><input type="checkbox" class="transparent-box" name="transparent-box">Transparent</label>').insertAfter($(this));
583
+ }
584
+ });
585
+ $('.transparent-box').each(function() {
586
+ var curParent = $(this).parent().parent();
587
+ if (curParent.find('.cf7-style-color-field').val() == "transparent") {
588
+ $(this).prop("checked", true);
589
+ }
590
+ });
591
+ $('.transparent-box').on('click', function() {
592
+ var curParent = $(this).parent().parent();
593
+ if ($(this).is(':checked')) {
594
+ curParent.find('.cf7-style-color-field').val('transparent');
595
+ curParent.find('.cf7-style-color-field').attr('value', 'transparent');
596
+ curParent.find('.wp-color-result').css('background-color', 'transparent');
597
+ } else {
598
+ curParent.find('.cf7-style-color-field').val('');
599
+ curParent.find('.cf7-style-color-field').attr('value', '');
600
+ }
601
+ updateHiddenInput($(this).parents('.panel').find('[name^="cf7stylecustom"]'));
602
+ });
603
+ }
604
+
605
+ function returnStep(element) {
606
+ return (("%" == element.val() || "em" == element.val()) ? "0.01" : "1");
607
+ }
608
+
609
+ function changeInputStep() {
610
+ $('.panel input[type="number"]:not([id*="opacity"])').each(function() {
611
+ var _t = $(this);
612
+ _t.attr('step', returnStep(_t.next()));
613
+ });
614
+ $('.panel select[name*="unit"]').off("change").on("change", function() {
615
+ var _t = $(this);
616
+ _t.prev().attr('step', returnStep(_t));
617
+ if (_t.val() == "px") {
618
+ var curVal = Math.floor(_t.prev().val());
619
+ _t.prev().val(curVal);
620
+ _t.prev().attr('value', curVal);
621
+ }
622
+ });
623
+ }
624
+
625
+ var previewEl = $(".generate-preview"),
626
+ cf7StylePostType = $(".post-type-cf7_style"),
627
+ selectAll = $('#select_all'),
628
+ fontSelectVar = $('select[name="cf7_style_font_selector"]'),
629
+ sliderWrapper = $('.cf7-style-slider-wrap'),
630
+ previewForm = $('.preview-form-container'),
631
+ options = {
632
+ change: function(event, ui) {
633
+ var _t = $(this);
634
+ _t.parents('.wp-picker-container').parent().find('.transparent-box').prop("checked", false);
635
+ setTimeout(function() {
636
+ updateHiddenInput(_t.parents('.panel').find('[name^="cf7stylecustom"]'));
637
+ }, 0);
638
+ if ($('input[name="element-type"]:checked').val() == "hover") {
639
+ initialPreview('hover');
640
+ } else {
641
+ initialPreview();
642
+ }
643
+ }
644
+ };
645
+
646
+ $('.cf7-style-color-field').wpColorPicker(options);
647
+ /*Scrolling on settings*/
648
+ if (previewEl.length > 0) {
649
+ scrolling(previewEl);
650
+ }
651
+
652
+ if (cf7StylePostType.length > 0) {
653
+ /*codemirror*/
654
+ codeMirrorInit();
655
+ /*backgroundimage*/
656
+ addBgImage();
657
+ /*Autocomplete number fields*/
658
+ autoCompleteOtherValues();
659
+ addDummyElements();
660
+ var previewForm = $('.preview-form-container').not('.hidden');
661
+ /*Hide settings which are not present in the current selected form*/
662
+ if( $('.post-new-php').length < 1 ){
663
+ hideShowBtns(previewForm);
664
+ }
665
+ /*Checkbox for select all the forms*/
666
+ selectAllForms(selectAll);
667
+ /*Change Font*/
668
+ changeFont(fontSelectVar.val());
669
+ fontSelectVar.on("change", function() {
670
+ changeFont($(this).val());
671
+ });
672
+ /*show the right options*/
673
+ showTheOption();
674
+ /*remove nonce*/
675
+ removePreviewfields(previewForm.find('input[type="hidden"]'));
676
+ /*disable submit*/
677
+ disableSubmit(previewForm.find('input[type="submit"]'));
678
+ }
679
+ if (sliderWrapper.length > 0) {
680
+ sliderInit(sliderWrapper);
681
+ }
682
+ $('.close-cf7-panel').on('click', function(e) {
683
+ e.preventDefault();
684
+ $.ajax({
685
+ 'url': ajaxurl,
686
+ 'method': 'POST',
687
+ 'data': {
688
+ 'action': 'cf7_style_remove_welcome_box'
689
+ },
690
+ 'success': function(data) {
691
+ $('.welcome-container').fadeOut('slow');
692
+ }
693
+ });
694
+ });
695
+ injectCheckbox();
696
+ changeInputStep();
697
  }); /*doc.ready end*/
admin/js/codemirror.js CHANGED
@@ -1,5 +1,5 @@
1
- !function(e){if("object"==typeof exports&&"object"==typeof module)module.exports=e();else{if("function"==typeof define&&define.amd)return define([],e);this.CodeMirror=e()}}(function(){"use strict";function e(r,n){if(!(this instanceof e))return new e(r,n);this.options=n=n?Wi(n):{},Wi(Ko,n,!1),d(n);var i=n.value;"string"==typeof i&&(i=new pl(i,n.mode)),this.doc=i;var o=new e.inputStyles[n.inputStyle](this),l=this.display=new t(r,i,o);l.wrapper.CodeMirror=this,u(this),s(this),n.lineWrapping&&(this.display.wrapper.className+=" CodeMirror-wrap"),n.autofocus&&!wo&&l.input.focus(),m(this),this.state={keyMaps:[],overlays:[],modeGen:0,overwrite:!1,focused:!1,suppressEdits:!1,pasteIncoming:!1,cutIncoming:!1,draggingText:!1,highlight:new Ci,keySeq:null};var a=this;uo&&11>co&&setTimeout(function(){a.display.input.reset(!0)},20),Rt(this),Ui(),mt(this),this.curOp.forceUpdate=!0,Vn(this,i),n.autofocus&&!wo||a.hasFocus()?setTimeout(Oi(ur,this),20):cr(this);for(var c in jo)jo.hasOwnProperty(c)&&jo[c](this,n[c],Xo);C(this),n.finishInit&&n.finishInit(this);for(var f=0;f<qo.length;++f)qo[f](this);bt(this),fo&&n.lineWrapping&&"optimizelegibility"==getComputedStyle(l.lineDiv).textRendering&&(l.lineDiv.style.textRendering="auto")}function t(e,t,r){var n=this;this.input=r,n.scrollbarFiller=Pi("div",null,"CodeMirror-scrollbar-filler"),n.scrollbarFiller.setAttribute("cm-not-content","true"),n.gutterFiller=Pi("div",null,"CodeMirror-gutter-filler"),n.gutterFiller.setAttribute("cm-not-content","true"),n.lineDiv=Pi("div",null,"CodeMirror-code"),n.selectionDiv=Pi("div",null,null,"position: relative; z-index: 1"),n.cursorDiv=Pi("div",null,"CodeMirror-cursors"),n.measure=Pi("div",null,"CodeMirror-measure"),n.lineMeasure=Pi("div",null,"CodeMirror-measure"),n.lineSpace=Pi("div",[n.measure,n.lineMeasure,n.selectionDiv,n.cursorDiv,n.lineDiv],null,"position: relative; outline: none"),n.mover=Pi("div",[Pi("div",[n.lineSpace],"CodeMirror-lines")],null,"position: relative"),n.sizer=Pi("div",[n.mover],"CodeMirror-sizer"),n.sizerWidth=null,n.heightForcer=Pi("div",null,null,"position: absolute; height: "+Ll+"px; width: 1px;"),n.gutters=Pi("div",null,"CodeMirror-gutters"),n.lineGutter=null,n.scroller=Pi("div",[n.sizer,n.heightForcer,n.gutters],"CodeMirror-scroll"),n.scroller.setAttribute("tabIndex","-1"),n.wrapper=Pi("div",[n.scrollbarFiller,n.gutterFiller,n.scroller],"CodeMirror"),uo&&8>co&&(n.gutters.style.zIndex=-1,n.scroller.style.paddingRight=0),fo||lo&&wo||(n.scroller.draggable=!0),e&&(e.appendChild?e.appendChild(n.wrapper):e(n.wrapper)),n.viewFrom=n.viewTo=t.first,n.reportedViewFrom=n.reportedViewTo=t.first,n.view=[],n.renderedView=null,n.externalMeasured=null,n.viewOffset=0,n.lastWrapHeight=n.lastWrapWidth=0,n.updateLineNumbers=null,n.nativeBarWidth=n.barHeight=n.barWidth=0,n.scrollbarsClipped=!1,n.lineNumWidth=n.lineNumInnerWidth=n.lineNumChars=null,n.alignWidgets=!1,n.cachedCharWidth=n.cachedTextHeight=n.cachedPaddingH=null,n.maxLine=null,n.maxLineLength=0,n.maxLineChanged=!1,n.wheelDX=n.wheelDY=n.wheelStartX=n.wheelStartY=null,n.shift=!1,n.selForContextMenu=null,n.activeTouch=null,r.init(n)}function r(t){t.doc.mode=e.getMode(t.options,t.doc.modeOption),n(t)}function n(e){e.doc.iter(function(e){e.stateAfter&&(e.stateAfter=null),e.styles&&(e.styles=null)}),e.doc.frontier=e.doc.first,ze(e,100),e.state.modeGen++,e.curOp&&Dt(e)}function i(e){e.options.lineWrapping?(Bl(e.display.wrapper,"CodeMirror-wrap"),e.display.sizer.style.minWidth="",e.display.sizerWidth=null):(Rl(e.display.wrapper,"CodeMirror-wrap"),h(e)),l(e),Dt(e),it(e),setTimeout(function(){y(e)},100)}function o(e){var t=gt(e.display),r=e.options.lineWrapping,n=r&&Math.max(5,e.display.scroller.clientWidth/vt(e.display)-3);return function(i){if(gn(e.doc,i))return 0;var o=0;if(i.widgets)for(var l=0;l<i.widgets.length;l++)i.widgets[l].height&&(o+=i.widgets[l].height);return r?o+(Math.ceil(i.text.length/n)||1)*t:o+t}}function l(e){var t=e.doc,r=o(e);t.iter(function(e){var t=r(e);t!=e.height&&_n(e,t)})}function s(e){e.display.wrapper.className=e.display.wrapper.className.replace(/\s*cm-s-\S+/g,"")+e.options.theme.replace(/(^|\s)\s*/g," cm-s-"),it(e)}function a(e){u(e),Dt(e),setTimeout(function(){x(e)},20)}function u(e){var t=e.display.gutters,r=e.options.gutters;zi(t);for(var n=0;n<r.length;++n){var i=r[n],o=t.appendChild(Pi("div",null,"CodeMirror-gutter "+i));"CodeMirror-linenumbers"==i&&(e.display.lineGutter=o,o.style.width=(e.display.lineNumWidth||1)+"px")}t.style.display=n?"":"none",c(e)}function c(e){var t=e.display.gutters.offsetWidth;e.display.sizer.style.marginLeft=t+"px"}function f(e){if(0==e.height)return 0;for(var t,r=e.text.length,n=e;t=an(n);){var i=t.find(0,!0);n=i.from.line,r+=i.from.ch-i.to.ch}for(n=e;t=un(n);){var i=t.find(0,!0);r-=n.text.length-i.from.ch,n=i.to.line,r+=n.text.length-i.to.ch}return r}function h(e){var t=e.display,r=e.doc;t.maxLine=Kn(r,r.first),t.maxLineLength=f(t.maxLine),t.maxLineChanged=!0,r.iter(function(e){var r=f(e);r>t.maxLineLength&&(t.maxLineLength=r,t.maxLine=e)})}function d(e){var t=Ti(e.gutters,"CodeMirror-linenumbers");-1==t&&e.lineNumbers?e.gutters=e.gutters.concat(["CodeMirror-linenumbers"]):t>-1&&!e.lineNumbers&&(e.gutters=e.gutters.slice(0),e.gutters.splice(t,1))}function p(e){var t=e.display,r=t.gutters.offsetWidth,n=Math.round(e.doc.height+Ge(e.display));return{clientHeight:t.scroller.clientHeight,viewHeight:t.wrapper.clientHeight,scrollWidth:t.scroller.scrollWidth,clientWidth:t.scroller.clientWidth,viewWidth:t.wrapper.clientWidth,barLeft:e.options.fixedGutter?r:0,docHeight:n,scrollHeight:n+Ve(e)+t.barHeight,nativeBarWidth:t.nativeBarWidth,gutterWidth:r}}function g(e,t,r){this.cm=r;var n=this.vert=Pi("div",[Pi("div",null,null,"min-width: 1px")],"CodeMirror-vscrollbar"),i=this.horiz=Pi("div",[Pi("div",null,null,"height: 100%; min-height: 1px")],"CodeMirror-hscrollbar");e(n),e(i),wl(n,"scroll",function(){n.clientHeight&&t(n.scrollTop,"vertical")}),wl(i,"scroll",function(){i.clientWidth&&t(i.scrollLeft,"horizontal")}),this.checkedOverlay=!1,uo&&8>co&&(this.horiz.style.minHeight=this.vert.style.minWidth="18px")}function v(){}function m(t){t.display.scrollbars&&(t.display.scrollbars.clear(),t.display.scrollbars.addClass&&Rl(t.display.wrapper,t.display.scrollbars.addClass)),t.display.scrollbars=new e.scrollbarModel[t.options.scrollbarStyle](function(e){t.display.wrapper.insertBefore(e,t.display.scrollbarFiller),wl(e,"mousedown",function(){t.state.focused&&setTimeout(function(){t.display.input.focus()},0)}),e.setAttribute("cm-not-content","true")},function(e,r){"horizontal"==r?Qt(t,e):Zt(t,e)},t),t.display.scrollbars.addClass&&Bl(t.display.wrapper,t.display.scrollbars.addClass)}function y(e,t){t||(t=p(e));var r=e.display.barWidth,n=e.display.barHeight;b(e,t);for(var i=0;4>i&&r!=e.display.barWidth||n!=e.display.barHeight;i++)r!=e.display.barWidth&&e.options.lineWrapping&&O(e),b(e,p(e)),r=e.display.barWidth,n=e.display.barHeight}function b(e,t){var r=e.display,n=r.scrollbars.update(t);r.sizer.style.paddingRight=(r.barWidth=n.right)+"px",r.sizer.style.paddingBottom=(r.barHeight=n.bottom)+"px",n.right&&n.bottom?(r.scrollbarFiller.style.display="block",r.scrollbarFiller.style.height=n.bottom+"px",r.scrollbarFiller.style.width=n.right+"px"):r.scrollbarFiller.style.display="",n.bottom&&e.options.coverGutterNextToScrollbar&&e.options.fixedGutter?(r.gutterFiller.style.display="block",r.gutterFiller.style.height=n.bottom+"px",r.gutterFiller.style.width=t.gutterWidth+"px"):r.gutterFiller.style.display=""}function w(e,t,r){var n=r&&null!=r.top?Math.max(0,r.top):e.scroller.scrollTop;n=Math.floor(n-Be(e));var i=r&&null!=r.bottom?r.bottom:n+e.wrapper.clientHeight,o=$n(t,n),l=$n(t,i);if(r&&r.ensure){var s=r.ensure.from.line,a=r.ensure.to.line;o>s?(o=s,l=$n(t,qn(Kn(t,s))+e.wrapper.clientHeight)):Math.min(a,t.lastLine())>=l&&(o=$n(t,qn(Kn(t,a))-e.wrapper.clientHeight),l=a)}return{from:o,to:Math.max(l,o+1)}}function x(e){var t=e.display,r=t.view;if(t.alignWidgets||t.gutters.firstChild&&e.options.fixedGutter){for(var n=L(t)-t.scroller.scrollLeft+e.doc.scrollLeft,i=t.gutters.offsetWidth,o=n+"px",l=0;l<r.length;l++)if(!r[l].hidden){e.options.fixedGutter&&r[l].gutter&&(r[l].gutter.style.left=o);var s=r[l].alignable;if(s)for(var a=0;a<s.length;a++)s[a].style.left=o}e.options.fixedGutter&&(t.gutters.style.left=n+i+"px")}}function C(e){if(!e.options.lineNumbers)return!1;var t=e.doc,r=S(e.options,t.first+t.size-1),n=e.display;if(r.length!=n.lineNumChars){var i=n.measure.appendChild(Pi("div",[Pi("div",r)],"CodeMirror-linenumber CodeMirror-gutter-elt")),o=i.firstChild.offsetWidth,l=i.offsetWidth-o;return n.lineGutter.style.width="",n.lineNumInnerWidth=Math.max(o,n.lineGutter.offsetWidth-l),n.lineNumWidth=n.lineNumInnerWidth+l,n.lineNumChars=n.lineNumInnerWidth?r.length:-1,n.lineGutter.style.width=n.lineNumWidth+"px",c(e),!0}return!1}function S(e,t){return String(e.lineNumberFormatter(t+e.firstLineNumber))}function L(e){return e.scroller.getBoundingClientRect().left-e.sizer.getBoundingClientRect().left}function k(e,t,r){var n=e.display;this.viewport=t,this.visible=w(n,e.doc,t),this.editorIsHidden=!n.wrapper.offsetWidth,this.wrapperHeight=n.wrapper.clientHeight,this.wrapperWidth=n.wrapper.clientWidth,this.oldDisplayWidth=Ke(e),this.force=r,this.dims=H(e),this.events=[]}function T(e){var t=e.display;!t.scrollbarsClipped&&t.scroller.offsetWidth&&(t.nativeBarWidth=t.scroller.offsetWidth-t.scroller.clientWidth,t.heightForcer.style.height=Ve(e)+"px",t.sizer.style.marginBottom=-t.nativeBarWidth+"px",t.sizer.style.borderRightWidth=Ve(e)+"px",t.scrollbarsClipped=!0)}function M(e,t){var r=e.display,n=e.doc;if(t.editorIsHidden)return It(e),!1;if(!t.force&&t.visible.from>=r.viewFrom&&t.visible.to<=r.viewTo&&(null==r.updateLineNumbers||r.updateLineNumbers>=r.viewTo)&&r.renderedView==r.view&&0==Ft(e))return!1;C(e)&&(It(e),t.dims=H(e));var i=n.first+n.size,o=Math.max(t.visible.from-e.options.viewportMargin,n.first),l=Math.min(i,t.visible.to+e.options.viewportMargin);r.viewFrom<o&&o-r.viewFrom<20&&(o=Math.max(n.first,r.viewFrom)),r.viewTo>l&&r.viewTo-l<20&&(l=Math.min(i,r.viewTo)),Mo&&(o=dn(e.doc,o),l=pn(e.doc,l));var s=o!=r.viewFrom||l!=r.viewTo||r.lastWrapHeight!=t.wrapperHeight||r.lastWrapWidth!=t.wrapperWidth;Et(e,o,l),r.viewOffset=qn(Kn(e.doc,r.viewFrom)),e.display.mover.style.top=r.viewOffset+"px";var a=Ft(e);if(!s&&0==a&&!t.force&&r.renderedView==r.view&&(null==r.updateLineNumbers||r.updateLineNumbers>=r.viewTo))return!1;var u=Fi();return a>4&&(r.lineDiv.style.display="none"),I(e,r.updateLineNumbers,t.dims),a>4&&(r.lineDiv.style.display=""),r.renderedView=r.view,u&&Fi()!=u&&u.offsetHeight&&u.focus(),zi(r.cursorDiv),zi(r.selectionDiv),r.gutters.style.height=0,s&&(r.lastWrapHeight=t.wrapperHeight,r.lastWrapWidth=t.wrapperWidth,ze(e,400)),r.updateLineNumbers=null,!0}function N(e,t){for(var r=t.force,n=t.viewport,i=!0;;i=!1){if(i&&e.options.lineWrapping&&t.oldDisplayWidth!=Ke(e))r=!0;else if(r=!1,n&&null!=n.top&&(n={top:Math.min(e.doc.height+Ge(e.display)-je(e),n.top)}),t.visible=w(e.display,e.doc,n),t.visible.from>=e.display.viewFrom&&t.visible.to<=e.display.viewTo)break;if(!M(e,t))break;O(e);var o=p(e);Oe(e),W(e,o),y(e,o)}t.signal(e,"update",e),(e.display.viewFrom!=e.display.reportedViewFrom||e.display.viewTo!=e.display.reportedViewTo)&&(t.signal(e,"viewportChange",e,e.display.viewFrom,e.display.viewTo),e.display.reportedViewFrom=e.display.viewFrom,e.display.reportedViewTo=e.display.viewTo)}function A(e,t){var r=new k(e,t);if(M(e,r)){O(e),N(e,r);var n=p(e);Oe(e),W(e,n),y(e,n),r.finish()}}function W(e,t){e.display.sizer.style.minHeight=t.docHeight+"px";var r=t.docHeight+e.display.barHeight;e.display.heightForcer.style.top=r+"px",e.display.gutters.style.height=Math.max(r+Ve(e),t.clientHeight)+"px"}function O(e){for(var t=e.display,r=t.lineDiv.offsetTop,n=0;n<t.view.length;n++){var i,o=t.view[n];if(!o.hidden){if(uo&&8>co){var l=o.node.offsetTop+o.node.offsetHeight;i=l-r,r=l}else{var s=o.node.getBoundingClientRect();i=s.bottom-s.top}var a=o.line.height-i;if(2>i&&(i=gt(t)),(a>.001||-.001>a)&&(_n(o.line,i),D(o.line),o.rest))for(var u=0;u<o.rest.length;u++)D(o.rest[u])}}}function D(e){if(e.widgets)for(var t=0;t<e.widgets.length;++t)e.widgets[t].height=e.widgets[t].node.offsetHeight}function H(e){for(var t=e.display,r={},n={},i=t.gutters.clientLeft,o=t.gutters.firstChild,l=0;o;o=o.nextSibling,++l)r[e.options.gutters[l]]=o.offsetLeft+o.clientLeft+i,n[e.options.gutters[l]]=o.clientWidth;return{fixedPos:L(t),gutterTotalWidth:t.gutters.offsetWidth,gutterLeft:r,gutterWidth:n,wrapperWidth:t.wrapper.clientWidth}}function I(e,t,r){function n(t){var r=t.nextSibling;return fo&&xo&&e.display.currentWheelTarget==t?t.style.display="none":t.parentNode.removeChild(t),r}for(var i=e.display,o=e.options.lineNumbers,l=i.lineDiv,s=l.firstChild,a=i.view,u=i.viewFrom,c=0;c<a.length;c++){var f=a[c];if(f.hidden);else if(f.node&&f.node.parentNode==l){for(;s!=f.node;)s=n(s);var h=o&&null!=t&&u>=t&&f.lineNumber;f.changes&&(Ti(f.changes,"gutter")>-1&&(h=!1),P(e,f,u,r)),h&&(zi(f.lineNumber),f.lineNumber.appendChild(document.createTextNode(S(e.options,u)))),s=f.node.nextSibling}else{var d=V(e,f,u,r);l.insertBefore(d,s)}u+=f.size}for(;s;)s=n(s)}function P(e,t,r,n){for(var i=0;i<t.changes.length;i++){var o=t.changes[i];"text"==o?R(e,t):"gutter"==o?G(e,t,r,n):"class"==o?B(t):"widget"==o&&U(e,t,n)}t.changes=null}function z(e){return e.node==e.text&&(e.node=Pi("div",null,null,"position: relative"),e.text.parentNode&&e.text.parentNode.replaceChild(e.node,e.text),e.node.appendChild(e.text),uo&&8>co&&(e.node.style.zIndex=2)),e.node}function E(e){var t=e.bgClass?e.bgClass+" "+(e.line.bgClass||""):e.line.bgClass;if(t&&(t+=" CodeMirror-linebackground"),e.background)t?e.background.className=t:(e.background.parentNode.removeChild(e.background),e.background=null);else if(t){var r=z(e);e.background=r.insertBefore(Pi("div",null,t),r.firstChild)}}function F(e,t){var r=e.display.externalMeasured;return r&&r.line==t.line?(e.display.externalMeasured=null,t.measure=r.measure,r.built):On(e,t)}function R(e,t){var r=t.text.className,n=F(e,t);t.text==t.node&&(t.node=n.pre),t.text.parentNode.replaceChild(n.pre,t.text),t.text=n.pre,n.bgClass!=t.bgClass||n.textClass!=t.textClass?(t.bgClass=n.bgClass,t.textClass=n.textClass,B(t)):r&&(t.text.className=r)}function B(e){E(e),e.line.wrapClass?z(e).className=e.line.wrapClass:e.node!=e.text&&(e.node.className="");var t=e.textClass?e.textClass+" "+(e.line.textClass||""):e.line.textClass;e.text.className=t||""}function G(e,t,r,n){t.gutter&&(t.node.removeChild(t.gutter),t.gutter=null);var i=t.line.gutterMarkers;if(e.options.lineNumbers||i){var o=z(t),l=t.gutter=Pi("div",null,"CodeMirror-gutter-wrapper","left: "+(e.options.fixedGutter?n.fixedPos:-n.gutterTotalWidth)+"px; width: "+n.gutterTotalWidth+"px");if(e.display.input.setUneditable(l),o.insertBefore(l,t.text),t.line.gutterClass&&(l.className+=" "+t.line.gutterClass),!e.options.lineNumbers||i&&i["CodeMirror-linenumbers"]||(t.lineNumber=l.appendChild(Pi("div",S(e.options,r),"CodeMirror-linenumber CodeMirror-gutter-elt","left: "+n.gutterLeft["CodeMirror-linenumbers"]+"px; width: "+e.display.lineNumInnerWidth+"px"))),i)for(var s=0;s<e.options.gutters.length;++s){var a=e.options.gutters[s],u=i.hasOwnProperty(a)&&i[a];u&&l.appendChild(Pi("div",[u],"CodeMirror-gutter-elt","left: "+n.gutterLeft[a]+"px; width: "+n.gutterWidth[a]+"px"))}}}function U(e,t,r){t.alignable&&(t.alignable=null);for(var n,i=t.node.firstChild;i;i=n){var n=i.nextSibling;"CodeMirror-linewidget"==i.className&&t.node.removeChild(i)}K(e,t,r)}function V(e,t,r,n){var i=F(e,t);return t.text=t.node=i.pre,i.bgClass&&(t.bgClass=i.bgClass),i.textClass&&(t.textClass=i.textClass),B(t),G(e,t,r,n),K(e,t,n),t.node}function K(e,t,r){if(j(e,t.line,t,r,!0),t.rest)for(var n=0;n<t.rest.length;n++)j(e,t.rest[n],t,r,!1)}function j(e,t,r,n,i){if(t.widgets)for(var o=z(r),l=0,s=t.widgets;l<s.length;++l){var a=s[l],u=Pi("div",[a.node],"CodeMirror-linewidget");a.handleMouseEvents||u.setAttribute("cm-ignore-events","true"),X(a,u,r,n),e.display.input.setUneditable(u),i&&a.above?o.insertBefore(u,r.gutter||r.text):o.appendChild(u),vi(a,"redraw")}}function X(e,t,r,n){if(e.noHScroll){(r.alignable||(r.alignable=[])).push(t);var i=n.wrapperWidth;t.style.left=n.fixedPos+"px",e.coverGutter||(i-=n.gutterTotalWidth,t.style.paddingLeft=n.gutterTotalWidth+"px"),t.style.width=i+"px"}e.coverGutter&&(t.style.zIndex=5,t.style.position="relative",e.noHScroll||(t.style.marginLeft=-n.gutterTotalWidth+"px"))}function _(e){return No(e.line,e.ch)}function Y(e,t){return Ao(e,t)<0?t:e}function $(e,t){return Ao(e,t)<0?e:t}function q(e){e.state.focused||(e.display.input.focus(),ur(e))}function Z(e){return e.options.readOnly||e.doc.cantEdit}function Q(e,t,r,n){var i=e.doc;e.display.shift=!1,n||(n=i.sel);var o=Vl(t),l=null;e.state.pasteIncoming&&n.ranges.length>1&&(Wo&&Wo.join("\n")==t?l=n.ranges.length%Wo.length==0&&Mi(Wo,Vl):o.length==n.ranges.length&&(l=Mi(o,function(e){return[e]})));for(var s=n.ranges.length-1;s>=0;s--){var a=n.ranges[s],u=a.from(),c=a.to();a.empty()&&(r&&r>0?u=No(u.line,u.ch-r):e.state.overwrite&&!e.state.pasteIncoming&&(c=No(c.line,Math.min(Kn(i,c.line).text.length,c.ch+ki(o).length))));var f=e.curOp.updateInput,h={from:u,to:c,text:l?l[s%l.length]:o,origin:e.state.pasteIncoming?"paste":e.state.cutIncoming?"cut":"+input"};if(yr(e.doc,h),vi(e,"inputRead",e,h),t&&!e.state.pasteIncoming&&e.options.electricChars&&e.options.smartIndent&&a.head.ch<100&&(!s||n.ranges[s-1].head.line!=a.head.line)){var d=e.getModeAt(a.head),p=Vo(h);if(d.electricChars){for(var g=0;g<d.electricChars.length;g++)if(t.indexOf(d.electricChars.charAt(g))>-1){Dr(e,p.line,"smart");break}}else d.electricInput&&d.electricInput.test(Kn(i,p.line).text.slice(0,p.ch))&&Dr(e,p.line,"smart")}}Wr(e),e.curOp.updateInput=f,e.curOp.typing=!0,e.state.pasteIncoming=e.state.cutIncoming=!1}function J(e){for(var t=[],r=[],n=0;n<e.doc.sel.ranges.length;n++){var i=e.doc.sel.ranges[n].head.line,o={anchor:No(i,0),head:No(i+1,0)};r.push(o),t.push(e.getRange(o.anchor,o.head))}return{text:t,ranges:r}}function ee(e){e.setAttribute("autocorrect","off"),e.setAttribute("autocapitalize","off"),e.setAttribute("spellcheck","false")}function te(e){this.cm=e,this.prevInput="",this.pollingFast=!1,this.polling=new Ci,this.inaccurateSelection=!1,this.hasSelection=!1}function re(){var e=Pi("textarea",null,null,"position: absolute; padding: 0; width: 1px; height: 1em; outline: none"),t=Pi("div",[e],null,"overflow: hidden; position: relative; width: 3px; height: 0px;");return fo?e.style.width="1000px":e.setAttribute("wrap","off"),bo&&(e.style.border="1px solid black"),ee(e),t}function ne(e){this.cm=e,this.lastAnchorNode=this.lastAnchorOffset=this.lastFocusNode=this.lastFocusOffset=null,this.polling=new Ci}function ie(e,t){var r=qe(e,t.line);if(!r||r.hidden)return null;var n=Kn(e.doc,t.line),i=_e(r,n,t.line),o=Zn(n),l="left";if(o){var s=ro(o,t.ch);l=s%2?"right":"left"}var a=Je(i.map,t.ch,"left");return a.offset="right"==a.collapse?a.end:a.start,a}function oe(e,t){return t&&(e.bad=!0),e}function le(e,t,r){var n;if(t==e.display.lineDiv){if(n=e.display.lineDiv.childNodes[r],!n)return oe(e.clipPos(No(e.display.viewTo-1)),!0);t=null,r=0}else for(n=t;;n=n.parentNode){if(!n||n==e.display.lineDiv)return null;if(n.parentNode&&n.parentNode==e.display.lineDiv)break}for(var i=0;i<e.display.view.length;i++){var o=e.display.view[i];if(o.node==n)return se(o,t,r)}}function se(e,t,r){function n(t,r,n){for(var i=-1;i<(c?c.length:0);i++)for(var o=0>i?u.map:c[i],l=0;l<o.length;l+=3){var s=o[l+2];if(s==t||s==r){var a=Yn(0>i?e.line:e.rest[i]),f=o[l]+n;return(0>n||s!=t)&&(f=o[l+(n?1:0)]),No(a,f)}}}var i=e.text.firstChild,o=!1;if(!t||!zl(i,t))return oe(No(Yn(e.line),0),!0);if(t==i&&(o=!0,t=i.childNodes[r],r=0,!t)){var l=e.rest?ki(e.rest):e.line;return oe(No(Yn(l),l.text.length),o)}var s=3==t.nodeType?t:null,a=t;for(s||1!=t.childNodes.length||3!=t.firstChild.nodeType||(s=t.firstChild,r&&(r=s.nodeValue.length));a.parentNode!=i;)a=a.parentNode;var u=e.measure,c=u.maps,f=n(s,a,r);if(f)return oe(f,o);for(var h=a.nextSibling,d=s?s.nodeValue.length-r:0;h;h=h.nextSibling){if(f=n(h,h.firstChild,0))return oe(No(f.line,f.ch-d),o);d+=h.textContent.length}for(var p=a.previousSibling,d=r;p;p=p.previousSibling){if(f=n(p,p.firstChild,-1))return oe(No(f.line,f.ch+d),o);d+=h.textContent.length}}function ae(e,t,r,n,i){function o(e){return function(t){return t.id==e}}function l(t){if(1==t.nodeType){var r=t.getAttribute("cm-text");if(null!=r)return""==r&&(r=t.textContent.replace(/\u200b/g,"")),void(s+=r);var u,c=t.getAttribute("cm-marker");if(c){var f=e.findMarks(No(n,0),No(i+1,0),o(+c));return void(f.length&&(u=f[0].find())&&(s+=jn(e.doc,u.from,u.to).join("\n")))}if("false"==t.getAttribute("contenteditable"))return;for(var h=0;h<t.childNodes.length;h++)l(t.childNodes[h]);/^(pre|div|p)$/i.test(t.nodeName)&&(a=!0)}else if(3==t.nodeType){var d=t.nodeValue;if(!d)return;a&&(s+="\n",a=!1),s+=d}}for(var s="",a=!1;l(t),t!=r;)t=t.nextSibling;return s}function ue(e,t){this.ranges=e,this.primIndex=t}function ce(e,t){this.anchor=e,this.head=t}function fe(e,t){var r=e[t];e.sort(function(e,t){return Ao(e.from(),t.from())}),t=Ti(e,r);for(var n=1;n<e.length;n++){var i=e[n],o=e[n-1];if(Ao(o.to(),i.from())>=0){var l=$(o.from(),i.from()),s=Y(o.to(),i.to()),a=o.empty()?i.from()==i.head:o.from()==o.head;t>=n&&--t,e.splice(--n,2,new ce(a?s:l,a?l:s))}}return new ue(e,t)}function he(e,t){return new ue([new ce(e,t||e)],0)}function de(e,t){return Math.max(e.first,Math.min(t,e.first+e.size-1))}function pe(e,t){if(t.line<e.first)return No(e.first,0);var r=e.first+e.size-1;return t.line>r?No(r,Kn(e,r).text.length):ge(t,Kn(e,t.line).text.length)}function ge(e,t){var r=e.ch;return null==r||r>t?No(e.line,t):0>r?No(e.line,0):e}function ve(e,t){return t>=e.first&&t<e.first+e.size}function me(e,t){for(var r=[],n=0;n<t.length;n++)r[n]=pe(e,t[n]);return r}function ye(e,t,r,n){if(e.cm&&e.cm.display.shift||e.extend){var i=t.anchor;if(n){var o=Ao(r,i)<0;o!=Ao(n,i)<0?(i=r,r=n):o!=Ao(r,n)<0&&(r=n)}return new ce(i,r)}return new ce(n||r,r)}function be(e,t,r,n){ke(e,new ue([ye(e,e.sel.primary(),t,r)],0),n)}function we(e,t,r){for(var n=[],i=0;i<e.sel.ranges.length;i++)n[i]=ye(e,e.sel.ranges[i],t[i],null);var o=fe(n,e.sel.primIndex);ke(e,o,r)}function xe(e,t,r,n){var i=e.sel.ranges.slice(0);i[t]=r,ke(e,fe(i,e.sel.primIndex),n)}function Ce(e,t,r,n){ke(e,he(t,r),n)}function Se(e,t){var r={ranges:t.ranges,update:function(t){this.ranges=[];for(var r=0;r<t.length;r++)this.ranges[r]=new ce(pe(e,t[r].anchor),pe(e,t[r].head))}};return Cl(e,"beforeSelectionChange",e,r),e.cm&&Cl(e.cm,"beforeSelectionChange",e.cm,r),r.ranges!=t.ranges?fe(r.ranges,r.ranges.length-1):t}function Le(e,t,r){var n=e.history.done,i=ki(n);i&&i.ranges?(n[n.length-1]=t,Te(e,t,r)):ke(e,t,r)}function ke(e,t,r){Te(e,t,r),ii(e,e.sel,e.cm?e.cm.curOp.id:NaN,r)}function Te(e,t,r){(wi(e,"beforeSelectionChange")||e.cm&&wi(e.cm,"beforeSelectionChange"))&&(t=Se(e,t));var n=r&&r.bias||(Ao(t.primary().head,e.sel.primary().head)<0?-1:1);Me(e,Ae(e,t,n,!0)),r&&r.scroll===!1||!e.cm||Wr(e.cm)}function Me(e,t){t.equals(e.sel)||(e.sel=t,e.cm&&(e.cm.curOp.updateInput=e.cm.curOp.selectionChanged=!0,bi(e.cm)),vi(e,"cursorActivity",e))}function Ne(e){Me(e,Ae(e,e.sel,null,!1),Tl)}function Ae(e,t,r,n){for(var i,o=0;o<t.ranges.length;o++){var l=t.ranges[o],s=We(e,l.anchor,r,n),a=We(e,l.head,r,n);(i||s!=l.anchor||a!=l.head)&&(i||(i=t.ranges.slice(0,o)),i[o]=new ce(s,a))}return i?fe(i,t.primIndex):t}function We(e,t,r,n){var i=!1,o=t,l=r||1;e.cantEdit=!1;e:for(;;){var s=Kn(e,o.line);if(s.markedSpans)for(var a=0;a<s.markedSpans.length;++a){var u=s.markedSpans[a],c=u.marker;if((null==u.from||(c.inclusiveLeft?u.from<=o.ch:u.from<o.ch))&&(null==u.to||(c.inclusiveRight?u.to>=o.ch:u.to>o.ch))){if(n&&(Cl(c,"beforeCursorEnter"),c.explicitlyCleared)){if(s.markedSpans){--a;continue}break}if(!c.atomic)continue;var f=c.find(0>l?-1:1);if(0==Ao(f,o)&&(f.ch+=l,f.ch<0?f=f.line>e.first?pe(e,No(f.line-1)):null:f.ch>s.text.length&&(f=f.line<e.first+e.size-1?No(f.line+1,0):null),!f)){if(i)return n?(e.cantEdit=!0,No(e.first,0)):We(e,t,r,!0);i=!0,f=t,l=-l}o=f;continue e}}return o}}function Oe(e){e.display.input.showSelection(e.display.input.prepareSelection())}function De(e,t){for(var r=e.doc,n={},i=n.cursors=document.createDocumentFragment(),o=n.selection=document.createDocumentFragment(),l=0;l<r.sel.ranges.length;l++)if(t!==!1||l!=r.sel.primIndex){var s=r.sel.ranges[l],a=s.empty();(a||e.options.showCursorWhenSelecting)&&He(e,s,i),a||Ie(e,s,o)}return n}function He(e,t,r){var n=ct(e,t.head,"div",null,null,!e.options.singleCursorHeightPerLine),i=r.appendChild(Pi("div"," ","CodeMirror-cursor"));if(i.style.left=n.left+"px",i.style.top=n.top+"px",i.style.height=Math.max(0,n.bottom-n.top)*e.options.cursorHeight+"px",n.other){var o=r.appendChild(Pi("div"," ","CodeMirror-cursor CodeMirror-secondarycursor"));o.style.display="",o.style.left=n.other.left+"px",o.style.top=n.other.top+"px",o.style.height=.85*(n.other.bottom-n.other.top)+"px"}}function Ie(e,t,r){function n(e,t,r,n){0>t&&(t=0),t=Math.round(t),n=Math.round(n),s.appendChild(Pi("div",null,"CodeMirror-selected","position: absolute; left: "+e+"px; top: "+t+"px; width: "+(null==r?c-e:r)+"px; height: "+(n-t)+"px"))}function i(t,r,i){function o(r,n){return ut(e,No(t,r),"div",f,n)}var s,a,f=Kn(l,t),h=f.text.length;return _i(Zn(f),r||0,null==i?h:i,function(e,t,l){var f,d,p,g=o(e,"left");if(e==t)f=g,d=p=g.left;else{if(f=o(t-1,"right"),"rtl"==l){var v=g;g=f,f=v}d=g.left,p=f.right}null==r&&0==e&&(d=u),f.top-g.top>3&&(n(d,g.top,null,g.bottom),d=u,g.bottom<f.top&&n(d,g.bottom,null,f.top)),null==i&&t==h&&(p=c),(!s||g.top<s.top||g.top==s.top&&g.left<s.left)&&(s=g),(!a||f.bottom>a.bottom||f.bottom==a.bottom&&f.right>a.right)&&(a=f),u+1>d&&(d=u),n(d,f.top,p-d,f.bottom)}),{start:s,end:a}}var o=e.display,l=e.doc,s=document.createDocumentFragment(),a=Ue(e.display),u=a.left,c=Math.max(o.sizerWidth,Ke(e)-o.sizer.offsetLeft)-a.right,f=t.from(),h=t.to();if(f.line==h.line)i(f.line,f.ch,h.ch);else{var d=Kn(l,f.line),p=Kn(l,h.line),g=fn(d)==fn(p),v=i(f.line,f.ch,g?d.text.length+1:null).end,m=i(h.line,g?0:null,h.ch).start;g&&(v.top<m.top-2?(n(v.right,v.top,null,v.bottom),n(u,m.top,m.left,m.bottom)):n(v.right,v.top,m.left-v.right,v.bottom)),v.bottom<m.top&&n(u,v.bottom,null,m.top)}r.appendChild(s)}function Pe(e){if(e.state.focused){var t=e.display;clearInterval(t.blinker);var r=!0;t.cursorDiv.style.visibility="",e.options.cursorBlinkRate>0?t.blinker=setInterval(function(){t.cursorDiv.style.visibility=(r=!r)?"":"hidden"},e.options.cursorBlinkRate):e.options.cursorBlinkRate<0&&(t.cursorDiv.style.visibility="hidden")}}function ze(e,t){e.doc.mode.startState&&e.doc.frontier<e.display.viewTo&&e.state.highlight.set(t,Oi(Ee,e))}function Ee(e){var t=e.doc;if(t.frontier<t.first&&(t.frontier=t.first),!(t.frontier>=e.display.viewTo)){var r=+new Date+e.options.workTime,n=Qo(t.mode,Re(e,t.frontier)),i=[];t.iter(t.frontier,Math.min(t.first+t.size,e.display.viewTo+500),function(o){if(t.frontier>=e.display.viewFrom){var l=o.styles,s=Mn(e,o,n,!0);o.styles=s.styles;var a=o.styleClasses,u=s.classes;u?o.styleClasses=u:a&&(o.styleClasses=null);for(var c=!l||l.length!=o.styles.length||a!=u&&(!a||!u||a.bgClass!=u.bgClass||a.textClass!=u.textClass),f=0;!c&&f<l.length;++f)c=l[f]!=o.styles[f];c&&i.push(t.frontier),o.stateAfter=Qo(t.mode,n)}else An(e,o.text,n),o.stateAfter=t.frontier%5==0?Qo(t.mode,n):null;return++t.frontier,+new Date>r?(ze(e,e.options.workDelay),!0):void 0}),i.length&&Tt(e,function(){for(var t=0;t<i.length;t++)Ht(e,i[t],"text")})}}function Fe(e,t,r){for(var n,i,o=e.doc,l=r?-1:t-(e.doc.mode.innerMode?1e3:100),s=t;s>l;--s){if(s<=o.first)return o.first;var a=Kn(o,s-1);if(a.stateAfter&&(!r||s<=o.frontier))return s;var u=Al(a.text,null,e.options.tabSize);(null==i||n>u)&&(i=s-1,n=u)}return i}function Re(e,t,r){var n=e.doc,i=e.display;if(!n.mode.startState)return!0;var o=Fe(e,t,r),l=o>n.first&&Kn(n,o-1).stateAfter;return l=l?Qo(n.mode,l):Jo(n.mode),n.iter(o,t,function(r){An(e,r.text,l);var s=o==t-1||o%5==0||o>=i.viewFrom&&o<i.viewTo;r.stateAfter=s?Qo(n.mode,l):null,++o}),r&&(n.frontier=o),l}function Be(e){return e.lineSpace.offsetTop}function Ge(e){return e.mover.offsetHeight-e.lineSpace.offsetHeight}function Ue(e){if(e.cachedPaddingH)return e.cachedPaddingH;var t=Ei(e.measure,Pi("pre","x")),r=window.getComputedStyle?window.getComputedStyle(t):t.currentStyle,n={left:parseInt(r.paddingLeft),right:parseInt(r.paddingRight)};return isNaN(n.left)||isNaN(n.right)||(e.cachedPaddingH=n),n}function Ve(e){return Ll-e.display.nativeBarWidth}function Ke(e){return e.display.scroller.clientWidth-Ve(e)-e.display.barWidth}function je(e){return e.display.scroller.clientHeight-Ve(e)-e.display.barHeight}function Xe(e,t,r){var n=e.options.lineWrapping,i=n&&Ke(e);if(!t.measure.heights||n&&t.measure.width!=i){var o=t.measure.heights=[];if(n){t.measure.width=i;for(var l=t.text.firstChild.getClientRects(),s=0;s<l.length-1;s++){var a=l[s],u=l[s+1];Math.abs(a.bottom-u.bottom)>2&&o.push((a.bottom+u.top)/2-r.top)}}o.push(r.bottom-r.top)}}function _e(e,t,r){if(e.line==t)return{map:e.measure.map,cache:e.measure.cache};for(var n=0;n<e.rest.length;n++)if(e.rest[n]==t)return{map:e.measure.maps[n],cache:e.measure.caches[n]};for(var n=0;n<e.rest.length;n++)if(Yn(e.rest[n])>r)return{map:e.measure.maps[n],cache:e.measure.caches[n],before:!0}}function Ye(e,t){t=fn(t);var r=Yn(t),n=e.display.externalMeasured=new Wt(e.doc,t,r);n.lineN=r;var i=n.built=On(e,n);return n.text=i.pre,Ei(e.display.lineMeasure,i.pre),n}function $e(e,t,r,n){return Qe(e,Ze(e,t),r,n)}function qe(e,t){if(t>=e.display.viewFrom&&t<e.display.viewTo)return e.display.view[Pt(e,t)];var r=e.display.externalMeasured;return r&&t>=r.lineN&&t<r.lineN+r.size?r:void 0}function Ze(e,t){var r=Yn(t),n=qe(e,r);n&&!n.text?n=null:n&&n.changes&&P(e,n,r,H(e)),n||(n=Ye(e,t));var i=_e(n,t,r);return{line:t,view:n,rect:null,map:i.map,cache:i.cache,before:i.before,hasHeights:!1}}function Qe(e,t,r,n,i){t.before&&(r=-1);var o,l=r+(n||"");return t.cache.hasOwnProperty(l)?o=t.cache[l]:(t.rect||(t.rect=t.view.text.getBoundingClientRect()),t.hasHeights||(Xe(e,t.view,t.rect),t.hasHeights=!0),o=et(e,t,r,n),o.bogus||(t.cache[l]=o)),{left:o.left,right:o.right,top:i?o.rtop:o.top,bottom:i?o.rbottom:o.bottom}}function Je(e,t,r){for(var n,i,o,l,s=0;s<e.length;s+=3){var a=e[s],u=e[s+1];if(a>t?(i=0,o=1,l="left"):u>t?(i=t-a,o=i+1):(s==e.length-3||t==u&&e[s+3]>t)&&(o=u-a,i=o-1,t>=u&&(l="right")),null!=i){if(n=e[s+2],a==u&&r==(n.insertLeft?"left":"right")&&(l=r),"left"==r&&0==i)for(;s&&e[s-2]==e[s-3]&&e[s-1].insertLeft;)n=e[(s-=3)+2],l="left";if("right"==r&&i==u-a)for(;s<e.length-3&&e[s+3]==e[s+4]&&!e[s+5].insertLeft;)n=e[(s+=3)+2],l="right";break}}return{node:n,start:i,end:o,collapse:l,coverStart:a,coverEnd:u}}function et(e,t,r,n){var i,o=Je(t.map,r,n),l=o.node,s=o.start,a=o.end,u=o.collapse;if(3==l.nodeType){for(var c=0;4>c;c++){for(;s&&Ii(t.line.text.charAt(o.coverStart+s));)--s;for(;o.coverStart+a<o.coverEnd&&Ii(t.line.text.charAt(o.coverStart+a));)++a;if(uo&&9>co&&0==s&&a==o.coverEnd-o.coverStart)i=l.parentNode.getBoundingClientRect();else if(uo&&e.options.lineWrapping){var f=Dl(l,s,a).getClientRects();i=f.length?f["right"==n?f.length-1:0]:Io}else i=Dl(l,s,a).getBoundingClientRect()||Io;if(i.left||i.right||0==s)break;a=s,s-=1,u="right"}uo&&11>co&&(i=tt(e.display.measure,i))}else{s>0&&(u=n="right");var f;i=e.options.lineWrapping&&(f=l.getClientRects()).length>1?f["right"==n?f.length-1:0]:l.getBoundingClientRect()}if(uo&&9>co&&!s&&(!i||!i.left&&!i.right)){var h=l.parentNode.getClientRects()[0];i=h?{left:h.left,right:h.left+vt(e.display),top:h.top,bottom:h.bottom}:Io}for(var d=i.top-t.rect.top,p=i.bottom-t.rect.top,g=(d+p)/2,v=t.view.measure.heights,c=0;c<v.length-1&&!(g<v[c]);c++);var m=c?v[c-1]:0,y=v[c],b={left:("right"==u?i.right:i.left)-t.rect.left,right:("left"==u?i.left:i.right)-t.rect.left,top:m,bottom:y};return i.left||i.right||(b.bogus=!0),e.options.singleCursorHeightPerLine||(b.rtop=d,
2
- b.rbottom=p),b}function tt(e,t){if(!window.screen||null==screen.logicalXDPI||screen.logicalXDPI==screen.deviceXDPI||!Xi(e))return t;var r=screen.logicalXDPI/screen.deviceXDPI,n=screen.logicalYDPI/screen.deviceYDPI;return{left:t.left*r,right:t.right*r,top:t.top*n,bottom:t.bottom*n}}function rt(e){if(e.measure&&(e.measure.cache={},e.measure.heights=null,e.rest))for(var t=0;t<e.rest.length;t++)e.measure.caches[t]={}}function nt(e){e.display.externalMeasure=null,zi(e.display.lineMeasure);for(var t=0;t<e.display.view.length;t++)rt(e.display.view[t])}function it(e){nt(e),e.display.cachedCharWidth=e.display.cachedTextHeight=e.display.cachedPaddingH=null,e.options.lineWrapping||(e.display.maxLineChanged=!0),e.display.lineNumChars=null}function ot(){return window.pageXOffset||(document.documentElement||document.body).scrollLeft}function lt(){return window.pageYOffset||(document.documentElement||document.body).scrollTop}function st(e,t,r,n){if(t.widgets)for(var i=0;i<t.widgets.length;++i)if(t.widgets[i].above){var o=yn(t.widgets[i]);r.top+=o,r.bottom+=o}if("line"==n)return r;n||(n="local");var l=qn(t);if("local"==n?l+=Be(e.display):l-=e.display.viewOffset,"page"==n||"window"==n){var s=e.display.lineSpace.getBoundingClientRect();l+=s.top+("window"==n?0:lt());var a=s.left+("window"==n?0:ot());r.left+=a,r.right+=a}return r.top+=l,r.bottom+=l,r}function at(e,t,r){if("div"==r)return t;var n=t.left,i=t.top;if("page"==r)n-=ot(),i-=lt();else if("local"==r||!r){var o=e.display.sizer.getBoundingClientRect();n+=o.left,i+=o.top}var l=e.display.lineSpace.getBoundingClientRect();return{left:n-l.left,top:i-l.top}}function ut(e,t,r,n,i){return n||(n=Kn(e.doc,t.line)),st(e,n,$e(e,n,t.ch,i),r)}function ct(e,t,r,n,i,o){function l(t,l){var s=Qe(e,i,t,l?"right":"left",o);return l?s.left=s.right:s.right=s.left,st(e,n,s,r)}function s(e,t){var r=a[t],n=r.level%2;return e==Yi(r)&&t&&r.level<a[t-1].level?(r=a[--t],e=$i(r)-(r.level%2?0:1),n=!0):e==$i(r)&&t<a.length-1&&r.level<a[t+1].level&&(r=a[++t],e=Yi(r)-r.level%2,n=!1),n&&e==r.to&&e>r.from?l(e-1):l(e,n)}n=n||Kn(e.doc,t.line),i||(i=Ze(e,n));var a=Zn(n),u=t.ch;if(!a)return l(u);var c=ro(a,u),f=s(u,c);return null!=Yl&&(f.other=s(u,Yl)),f}function ft(e,t){var r=0,t=pe(e.doc,t);e.options.lineWrapping||(r=vt(e.display)*t.ch);var n=Kn(e.doc,t.line),i=qn(n)+Be(e.display);return{left:r,right:r,top:i,bottom:i+n.height}}function ht(e,t,r,n){var i=No(e,t);return i.xRel=n,r&&(i.outside=!0),i}function dt(e,t,r){var n=e.doc;if(r+=e.display.viewOffset,0>r)return ht(n.first,0,!0,-1);var i=$n(n,r),o=n.first+n.size-1;if(i>o)return ht(n.first+n.size-1,Kn(n,o).text.length,!0,1);0>t&&(t=0);for(var l=Kn(n,i);;){var s=pt(e,l,i,t,r),a=un(l),u=a&&a.find(0,!0);if(!a||!(s.ch>u.from.ch||s.ch==u.from.ch&&s.xRel>0))return s;i=Yn(l=u.to.line)}}function pt(e,t,r,n,i){function o(n){var i=ct(e,No(r,n),"line",t,u);return s=!0,l>i.bottom?i.left-a:l<i.top?i.left+a:(s=!1,i.left)}var l=i-qn(t),s=!1,a=2*e.display.wrapper.clientWidth,u=Ze(e,t),c=Zn(t),f=t.text.length,h=qi(t),d=Zi(t),p=o(h),g=s,v=o(d),m=s;if(n>v)return ht(r,d,m,1);for(;;){if(c?d==h||d==io(t,h,1):1>=d-h){for(var y=p>n||v-n>=n-p?h:d,b=n-(y==h?p:v);Ii(t.text.charAt(y));)++y;var w=ht(r,y,y==h?g:m,-1>b?-1:b>1?1:0);return w}var x=Math.ceil(f/2),C=h+x;if(c){C=h;for(var S=0;x>S;++S)C=io(t,C,1)}var L=o(C);L>n?(d=C,v=L,(m=s)&&(v+=1e3),f=x):(h=C,p=L,g=s,f-=x)}}function gt(e){if(null!=e.cachedTextHeight)return e.cachedTextHeight;if(null==Oo){Oo=Pi("pre");for(var t=0;49>t;++t)Oo.appendChild(document.createTextNode("x")),Oo.appendChild(Pi("br"));Oo.appendChild(document.createTextNode("x"))}Ei(e.measure,Oo);var r=Oo.offsetHeight/50;return r>3&&(e.cachedTextHeight=r),zi(e.measure),r||1}function vt(e){if(null!=e.cachedCharWidth)return e.cachedCharWidth;var t=Pi("span","xxxxxxxxxx"),r=Pi("pre",[t]);Ei(e.measure,r);var n=t.getBoundingClientRect(),i=(n.right-n.left)/10;return i>2&&(e.cachedCharWidth=i),i||10}function mt(e){e.curOp={cm:e,viewChanged:!1,startHeight:e.doc.height,forceUpdate:!1,updateInput:null,typing:!1,changeObjs:null,cursorActivityHandlers:null,cursorActivityCalled:0,selectionChanged:!1,updateMaxLine:!1,scrollLeft:null,scrollTop:null,scrollToPos:null,id:++zo},Po?Po.ops.push(e.curOp):e.curOp.ownsGroup=Po={ops:[e.curOp],delayedCallbacks:[]}}function yt(e){var t=e.delayedCallbacks,r=0;do{for(;r<t.length;r++)t[r]();for(var n=0;n<e.ops.length;n++){var i=e.ops[n];if(i.cursorActivityHandlers)for(;i.cursorActivityCalled<i.cursorActivityHandlers.length;)i.cursorActivityHandlers[i.cursorActivityCalled++](i.cm)}}while(r<t.length)}function bt(e){var t=e.curOp,r=t.ownsGroup;if(r)try{yt(r)}finally{Po=null;for(var n=0;n<r.ops.length;n++)r.ops[n].cm.curOp=null;wt(r)}}function wt(e){for(var t=e.ops,r=0;r<t.length;r++)xt(t[r]);for(var r=0;r<t.length;r++)Ct(t[r]);for(var r=0;r<t.length;r++)St(t[r]);for(var r=0;r<t.length;r++)Lt(t[r]);for(var r=0;r<t.length;r++)kt(t[r])}function xt(e){var t=e.cm,r=t.display;T(t),e.updateMaxLine&&h(t),e.mustUpdate=e.viewChanged||e.forceUpdate||null!=e.scrollTop||e.scrollToPos&&(e.scrollToPos.from.line<r.viewFrom||e.scrollToPos.to.line>=r.viewTo)||r.maxLineChanged&&t.options.lineWrapping,e.update=e.mustUpdate&&new k(t,e.mustUpdate&&{top:e.scrollTop,ensure:e.scrollToPos},e.forceUpdate)}function Ct(e){e.updatedDisplay=e.mustUpdate&&M(e.cm,e.update)}function St(e){var t=e.cm,r=t.display;e.updatedDisplay&&O(t),e.barMeasure=p(t),r.maxLineChanged&&!t.options.lineWrapping&&(e.adjustWidthTo=$e(t,r.maxLine,r.maxLine.text.length).left+3,t.display.sizerWidth=e.adjustWidthTo,e.barMeasure.scrollWidth=Math.max(r.scroller.clientWidth,r.sizer.offsetLeft+e.adjustWidthTo+Ve(t)+t.display.barWidth),e.maxScrollLeft=Math.max(0,r.sizer.offsetLeft+e.adjustWidthTo-Ke(t))),(e.updatedDisplay||e.selectionChanged)&&(e.preparedSelection=r.input.prepareSelection())}function Lt(e){var t=e.cm;null!=e.adjustWidthTo&&(t.display.sizer.style.minWidth=e.adjustWidthTo+"px",e.maxScrollLeft<t.doc.scrollLeft&&Qt(t,Math.min(t.display.scroller.scrollLeft,e.maxScrollLeft),!0),t.display.maxLineChanged=!1),e.preparedSelection&&t.display.input.showSelection(e.preparedSelection),e.updatedDisplay&&W(t,e.barMeasure),(e.updatedDisplay||e.startHeight!=t.doc.height)&&y(t,e.barMeasure),e.selectionChanged&&Pe(t),t.state.focused&&e.updateInput&&t.display.input.reset(e.typing)}function kt(e){var t=e.cm,r=t.display,n=t.doc;if(e.updatedDisplay&&N(t,e.update),null==r.wheelStartX||null==e.scrollTop&&null==e.scrollLeft&&!e.scrollToPos||(r.wheelStartX=r.wheelStartY=null),null==e.scrollTop||r.scroller.scrollTop==e.scrollTop&&!e.forceScroll||(n.scrollTop=Math.max(0,Math.min(r.scroller.scrollHeight-r.scroller.clientHeight,e.scrollTop)),r.scrollbars.setScrollTop(n.scrollTop),r.scroller.scrollTop=n.scrollTop),null==e.scrollLeft||r.scroller.scrollLeft==e.scrollLeft&&!e.forceScroll||(n.scrollLeft=Math.max(0,Math.min(r.scroller.scrollWidth-Ke(t),e.scrollLeft)),r.scrollbars.setScrollLeft(n.scrollLeft),r.scroller.scrollLeft=n.scrollLeft,x(t)),e.scrollToPos){var i=Tr(t,pe(n,e.scrollToPos.from),pe(n,e.scrollToPos.to),e.scrollToPos.margin);e.scrollToPos.isCursor&&t.state.focused&&kr(t,i)}var o=e.maybeHiddenMarkers,l=e.maybeUnhiddenMarkers;if(o)for(var s=0;s<o.length;++s)o[s].lines.length||Cl(o[s],"hide");if(l)for(var s=0;s<l.length;++s)l[s].lines.length&&Cl(l[s],"unhide");r.wrapper.offsetHeight&&(n.scrollTop=t.display.scroller.scrollTop),e.changeObjs&&Cl(t,"changes",t,e.changeObjs),e.update&&e.update.finish()}function Tt(e,t){if(e.curOp)return t();mt(e);try{return t()}finally{bt(e)}}function Mt(e,t){return function(){if(e.curOp)return t.apply(e,arguments);mt(e);try{return t.apply(e,arguments)}finally{bt(e)}}}function Nt(e){return function(){if(this.curOp)return e.apply(this,arguments);mt(this);try{return e.apply(this,arguments)}finally{bt(this)}}}function At(e){return function(){var t=this.cm;if(!t||t.curOp)return e.apply(this,arguments);mt(t);try{return e.apply(this,arguments)}finally{bt(t)}}}function Wt(e,t,r){this.line=t,this.rest=hn(t),this.size=this.rest?Yn(ki(this.rest))-r+1:1,this.node=this.text=null,this.hidden=gn(e,t)}function Ot(e,t,r){for(var n,i=[],o=t;r>o;o=n){var l=new Wt(e.doc,Kn(e.doc,o),o);n=o+l.size,i.push(l)}return i}function Dt(e,t,r,n){null==t&&(t=e.doc.first),null==r&&(r=e.doc.first+e.doc.size),n||(n=0);var i=e.display;if(n&&r<i.viewTo&&(null==i.updateLineNumbers||i.updateLineNumbers>t)&&(i.updateLineNumbers=t),e.curOp.viewChanged=!0,t>=i.viewTo)Mo&&dn(e.doc,t)<i.viewTo&&It(e);else if(r<=i.viewFrom)Mo&&pn(e.doc,r+n)>i.viewFrom?It(e):(i.viewFrom+=n,i.viewTo+=n);else if(t<=i.viewFrom&&r>=i.viewTo)It(e);else if(t<=i.viewFrom){var o=zt(e,r,r+n,1);o?(i.view=i.view.slice(o.index),i.viewFrom=o.lineN,i.viewTo+=n):It(e)}else if(r>=i.viewTo){var o=zt(e,t,t,-1);o?(i.view=i.view.slice(0,o.index),i.viewTo=o.lineN):It(e)}else{var l=zt(e,t,t,-1),s=zt(e,r,r+n,1);l&&s?(i.view=i.view.slice(0,l.index).concat(Ot(e,l.lineN,s.lineN)).concat(i.view.slice(s.index)),i.viewTo+=n):It(e)}var a=i.externalMeasured;a&&(r<a.lineN?a.lineN+=n:t<a.lineN+a.size&&(i.externalMeasured=null))}function Ht(e,t,r){e.curOp.viewChanged=!0;var n=e.display,i=e.display.externalMeasured;if(i&&t>=i.lineN&&t<i.lineN+i.size&&(n.externalMeasured=null),!(t<n.viewFrom||t>=n.viewTo)){var o=n.view[Pt(e,t)];if(null!=o.node){var l=o.changes||(o.changes=[]);-1==Ti(l,r)&&l.push(r)}}}function It(e){e.display.viewFrom=e.display.viewTo=e.doc.first,e.display.view=[],e.display.viewOffset=0}function Pt(e,t){if(t>=e.display.viewTo)return null;if(t-=e.display.viewFrom,0>t)return null;for(var r=e.display.view,n=0;n<r.length;n++)if(t-=r[n].size,0>t)return n}function zt(e,t,r,n){var i,o=Pt(e,t),l=e.display.view;if(!Mo||r==e.doc.first+e.doc.size)return{index:o,lineN:r};for(var s=0,a=e.display.viewFrom;o>s;s++)a+=l[s].size;if(a!=t){if(n>0){if(o==l.length-1)return null;i=a+l[o].size-t,o++}else i=a-t;t+=i,r+=i}for(;dn(e.doc,r)!=r;){if(o==(0>n?0:l.length-1))return null;r+=n*l[o-(0>n?1:0)].size,o+=n}return{index:o,lineN:r}}function Et(e,t,r){var n=e.display,i=n.view;0==i.length||t>=n.viewTo||r<=n.viewFrom?(n.view=Ot(e,t,r),n.viewFrom=t):(n.viewFrom>t?n.view=Ot(e,t,n.viewFrom).concat(n.view):n.viewFrom<t&&(n.view=n.view.slice(Pt(e,t))),n.viewFrom=t,n.viewTo<r?n.view=n.view.concat(Ot(e,n.viewTo,r)):n.viewTo>r&&(n.view=n.view.slice(0,Pt(e,r)))),n.viewTo=r}function Ft(e){for(var t=e.display.view,r=0,n=0;n<t.length;n++){var i=t[n];i.hidden||i.node&&!i.changes||++r}return r}function Rt(e){function t(){o.activeTouch&&(l=setTimeout(function(){o.activeTouch=null},1e3),s=o.activeTouch,s.end=+new Date)}function r(e){if(1!=e.touches.length)return!1;var t=e.touches[0];return t.radiusX<=1&&t.radiusY<=1}function n(e,t){if(null==t.left)return!0;var r=t.left-e.left,n=t.top-e.top;return r*r+n*n>400}function i(t){yi(e,t)||bl(t)}var o=e.display;wl(o.scroller,"mousedown",Mt(e,Vt)),uo&&11>co?wl(o.scroller,"dblclick",Mt(e,function(t){if(!yi(e,t)){var r=Ut(e,t);if(r&&!Yt(e,t)&&!Gt(e.display,t)){ml(t);var n=e.findWordAt(r);be(e.doc,n.anchor,n.head)}}})):wl(o.scroller,"dblclick",function(t){yi(e,t)||ml(t)}),ko||wl(o.scroller,"contextmenu",function(t){fr(e,t)});var l,s={end:0};wl(o.scroller,"touchstart",function(e){if(!r(e)){clearTimeout(l);var t=+new Date;o.activeTouch={start:t,moved:!1,prev:t-s.end<=300?s:null},1==e.touches.length&&(o.activeTouch.left=e.touches[0].pageX,o.activeTouch.top=e.touches[0].pageY)}}),wl(o.scroller,"touchmove",function(){o.activeTouch&&(o.activeTouch.moved=!0)}),wl(o.scroller,"touchend",function(r){var i=o.activeTouch;if(i&&!Gt(o,r)&&null!=i.left&&!i.moved&&new Date-i.start<300){var l,s=e.coordsChar(o.activeTouch,"page");l=!i.prev||n(i,i.prev)?new ce(s,s):!i.prev.prev||n(i,i.prev.prev)?e.findWordAt(s):new ce(No(s.line,0),pe(e.doc,No(s.line+1,0))),e.setSelection(l.anchor,l.head),e.focus(),ml(r)}t()}),wl(o.scroller,"touchcancel",t),wl(o.scroller,"scroll",function(){o.scroller.clientHeight&&(Zt(e,o.scroller.scrollTop),Qt(e,o.scroller.scrollLeft,!0),Cl(e,"scroll",e))}),wl(o.scroller,"mousewheel",function(t){Jt(e,t)}),wl(o.scroller,"DOMMouseScroll",function(t){Jt(e,t)}),wl(o.wrapper,"scroll",function(){o.wrapper.scrollTop=o.wrapper.scrollLeft=0}),e.options.dragDrop&&(wl(o.scroller,"dragstart",function(t){qt(e,t)}),wl(o.scroller,"dragenter",i),wl(o.scroller,"dragover",i),wl(o.scroller,"drop",Mt(e,$t)));var a=o.input.getField();wl(a,"keyup",function(t){sr.call(e,t)}),wl(a,"keydown",Mt(e,or)),wl(a,"keypress",Mt(e,ar)),wl(a,"focus",Oi(ur,e)),wl(a,"blur",Oi(cr,e))}function Bt(e){var t=e.display;(t.lastWrapHeight!=t.wrapper.clientHeight||t.lastWrapWidth!=t.wrapper.clientWidth)&&(t.cachedCharWidth=t.cachedTextHeight=t.cachedPaddingH=null,t.scrollbarsClipped=!1,e.setSize())}function Gt(e,t){for(var r=pi(t);r!=e.wrapper;r=r.parentNode)if(!r||1==r.nodeType&&"true"==r.getAttribute("cm-ignore-events")||r.parentNode==e.sizer&&r!=e.mover)return!0}function Ut(e,t,r,n){var i=e.display;if(!r&&"true"==pi(t).getAttribute("cm-not-content"))return null;var o,l,s=i.lineSpace.getBoundingClientRect();try{o=t.clientX-s.left,l=t.clientY-s.top}catch(t){return null}var a,u=dt(e,o,l);if(n&&1==u.xRel&&(a=Kn(e.doc,u.line).text).length==u.ch){var c=Al(a,a.length,e.options.tabSize)-a.length;u=No(u.line,Math.max(0,Math.round((o-Ue(e.display).left)/vt(e.display))-c))}return u}function Vt(e){var t=this,r=t.display;if(!(r.activeTouch&&r.input.supportsTouch()||yi(t,e))){if(r.shift=e.shiftKey,Gt(r,e))return void(fo||(r.scroller.draggable=!1,setTimeout(function(){r.scroller.draggable=!0},100)));if(!Yt(t,e)){var n=Ut(t,e);switch(window.focus(),gi(e)){case 1:n?Kt(t,e,n):pi(e)==r.scroller&&ml(e);break;case 2:fo&&(t.state.lastMiddleDown=+new Date),n&&be(t.doc,n),setTimeout(function(){r.input.focus()},20),ml(e);break;case 3:ko&&fr(t,e)}}}}function Kt(e,t,r){uo?setTimeout(Oi(q,e),0):q(e);var n,i=+new Date;Ho&&Ho.time>i-400&&0==Ao(Ho.pos,r)?n="triple":Do&&Do.time>i-400&&0==Ao(Do.pos,r)?(n="double",Ho={time:i,pos:r}):(n="single",Do={time:i,pos:r});var o,l=e.doc.sel,s=xo?t.metaKey:t.ctrlKey;e.options.dragDrop&&Ul&&!Z(e)&&"single"==n&&(o=l.contains(r))>-1&&!l.ranges[o].empty()?jt(e,t,r,s):Xt(e,t,r,n,s)}function jt(e,t,r,n){var i=e.display,o=Mt(e,function(l){fo&&(i.scroller.draggable=!1),e.state.draggingText=!1,xl(document,"mouseup",o),xl(i.scroller,"drop",o),Math.abs(t.clientX-l.clientX)+Math.abs(t.clientY-l.clientY)<10&&(ml(l),n||be(e.doc,r),i.input.focus(),uo&&9==co&&setTimeout(function(){document.body.focus(),i.input.focus()},20))});fo&&(i.scroller.draggable=!0),e.state.draggingText=o,i.scroller.dragDrop&&i.scroller.dragDrop(),wl(document,"mouseup",o),wl(i.scroller,"drop",o)}function Xt(e,t,r,n,i){function o(t){if(0!=Ao(v,t))if(v=t,"rect"==n){for(var i=[],o=e.options.tabSize,l=Al(Kn(u,r.line).text,r.ch,o),s=Al(Kn(u,t.line).text,t.ch,o),a=Math.min(l,s),d=Math.max(l,s),p=Math.min(r.line,t.line),g=Math.min(e.lastLine(),Math.max(r.line,t.line));g>=p;p++){var m=Kn(u,p).text,y=Si(m,a,o);a==d?i.push(new ce(No(p,y),No(p,y))):m.length>y&&i.push(new ce(No(p,y),No(p,Si(m,d,o))))}i.length||i.push(new ce(r,r)),ke(u,fe(h.ranges.slice(0,f).concat(i),f),{origin:"*mouse",scroll:!1}),e.scrollIntoView(t)}else{var b=c,w=b.anchor,x=t;if("single"!=n){if("double"==n)var C=e.findWordAt(t);else var C=new ce(No(t.line,0),pe(u,No(t.line+1,0)));Ao(C.anchor,w)>0?(x=C.head,w=$(b.from(),C.anchor)):(x=C.anchor,w=Y(b.to(),C.head))}var i=h.ranges.slice(0);i[f]=new ce(pe(u,w),x),ke(u,fe(i,f),Ml)}}function l(t){var r=++y,i=Ut(e,t,!0,"rect"==n);if(i)if(0!=Ao(i,v)){q(e),o(i);var s=w(a,u);(i.line>=s.to||i.line<s.from)&&setTimeout(Mt(e,function(){y==r&&l(t)}),150)}else{var c=t.clientY<m.top?-20:t.clientY>m.bottom?20:0;c&&setTimeout(Mt(e,function(){y==r&&(a.scroller.scrollTop+=c,l(t))}),50)}}function s(e){y=1/0,ml(e),a.input.focus(),xl(document,"mousemove",b),xl(document,"mouseup",x),u.history.lastSelOrigin=null}var a=e.display,u=e.doc;ml(t);var c,f,h=u.sel,d=h.ranges;if(i&&!t.shiftKey?(f=u.sel.contains(r),c=f>-1?d[f]:new ce(r,r)):c=u.sel.primary(),t.altKey)n="rect",i||(c=new ce(r,r)),r=Ut(e,t,!0,!0),f=-1;else if("double"==n){var p=e.findWordAt(r);c=e.display.shift||u.extend?ye(u,c,p.anchor,p.head):p}else if("triple"==n){var g=new ce(No(r.line,0),pe(u,No(r.line+1,0)));c=e.display.shift||u.extend?ye(u,c,g.anchor,g.head):g}else c=ye(u,c,r);i?-1==f?(f=d.length,ke(u,fe(d.concat([c]),f),{scroll:!1,origin:"*mouse"})):d.length>1&&d[f].empty()&&"single"==n?(ke(u,fe(d.slice(0,f).concat(d.slice(f+1)),0)),h=u.sel):xe(u,f,c,Ml):(f=0,ke(u,new ue([c],0),Ml),h=u.sel);var v=r,m=a.wrapper.getBoundingClientRect(),y=0,b=Mt(e,function(e){gi(e)?l(e):s(e)}),x=Mt(e,s);wl(document,"mousemove",b),wl(document,"mouseup",x)}function _t(e,t,r,n,i){try{var o=t.clientX,l=t.clientY}catch(t){return!1}if(o>=Math.floor(e.display.gutters.getBoundingClientRect().right))return!1;n&&ml(t);var s=e.display,a=s.lineDiv.getBoundingClientRect();if(l>a.bottom||!wi(e,r))return di(t);l-=a.top-s.viewOffset;for(var u=0;u<e.options.gutters.length;++u){var c=s.gutters.childNodes[u];if(c&&c.getBoundingClientRect().right>=o){var f=$n(e.doc,l),h=e.options.gutters[u];return i(e,r,e,f,h,t),di(t)}}}function Yt(e,t){return _t(e,t,"gutterClick",!0,vi)}function $t(e){var t=this;if(!yi(t,e)&&!Gt(t.display,e)){ml(e),uo&&(Eo=+new Date);var r=Ut(t,e,!0),n=e.dataTransfer.files;if(r&&!Z(t))if(n&&n.length&&window.FileReader&&window.File)for(var i=n.length,o=Array(i),l=0,s=function(e,n){var s=new FileReader;s.onload=Mt(t,function(){if(o[n]=s.result,++l==i){r=pe(t.doc,r);var e={from:r,to:r,text:Vl(o.join("\n")),origin:"paste"};yr(t.doc,e),Le(t.doc,he(r,Vo(e)))}}),s.readAsText(e)},a=0;i>a;++a)s(n[a],a);else{if(t.state.draggingText&&t.doc.sel.contains(r)>-1)return t.state.draggingText(e),void setTimeout(function(){t.display.input.focus()},20);try{var o=e.dataTransfer.getData("Text");if(o){if(t.state.draggingText&&!(xo?e.metaKey:e.ctrlKey))var u=t.listSelections();if(Te(t.doc,he(r,r)),u)for(var a=0;a<u.length;++a)Lr(t.doc,"",u[a].anchor,u[a].head,"drag");t.replaceSelection(o,"around","paste"),t.display.input.focus()}}catch(e){}}}}function qt(e,t){if(uo&&(!e.state.draggingText||+new Date-Eo<100))return void bl(t);if(!yi(e,t)&&!Gt(e.display,t)&&(t.dataTransfer.setData("Text",e.getSelection()),t.dataTransfer.setDragImage&&!vo)){var r=Pi("img",null,null,"position: fixed; left: 0; top: 0;");r.src="data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==",go&&(r.width=r.height=1,e.display.wrapper.appendChild(r),r._top=r.offsetTop),t.dataTransfer.setDragImage(r,0,0),go&&r.parentNode.removeChild(r)}}function Zt(e,t){Math.abs(e.doc.scrollTop-t)<2||(e.doc.scrollTop=t,lo||A(e,{top:t}),e.display.scroller.scrollTop!=t&&(e.display.scroller.scrollTop=t),e.display.scrollbars.setScrollTop(t),lo&&A(e),ze(e,100))}function Qt(e,t,r){(r?t==e.doc.scrollLeft:Math.abs(e.doc.scrollLeft-t)<2)||(t=Math.min(t,e.display.scroller.scrollWidth-e.display.scroller.clientWidth),e.doc.scrollLeft=t,x(e),e.display.scroller.scrollLeft!=t&&(e.display.scroller.scrollLeft=t),e.display.scrollbars.setScrollLeft(t))}function Jt(e,t){var r=Bo(t),n=r.x,i=r.y,o=e.display,l=o.scroller;if(n&&l.scrollWidth>l.clientWidth||i&&l.scrollHeight>l.clientHeight){if(i&&xo&&fo)e:for(var s=t.target,a=o.view;s!=l;s=s.parentNode)for(var u=0;u<a.length;u++)if(a[u].node==s){e.display.currentWheelTarget=s;break e}if(n&&!lo&&!go&&null!=Ro)return i&&Zt(e,Math.max(0,Math.min(l.scrollTop+i*Ro,l.scrollHeight-l.clientHeight))),Qt(e,Math.max(0,Math.min(l.scrollLeft+n*Ro,l.scrollWidth-l.clientWidth))),ml(t),void(o.wheelStartX=null);if(i&&null!=Ro){var c=i*Ro,f=e.doc.scrollTop,h=f+o.wrapper.clientHeight;0>c?f=Math.max(0,f+c-50):h=Math.min(e.doc.height,h+c+50),A(e,{top:f,bottom:h})}20>Fo&&(null==o.wheelStartX?(o.wheelStartX=l.scrollLeft,o.wheelStartY=l.scrollTop,o.wheelDX=n,o.wheelDY=i,setTimeout(function(){if(null!=o.wheelStartX){var e=l.scrollLeft-o.wheelStartX,t=l.scrollTop-o.wheelStartY,r=t&&o.wheelDY&&t/o.wheelDY||e&&o.wheelDX&&e/o.wheelDX;o.wheelStartX=o.wheelStartY=null,r&&(Ro=(Ro*Fo+r)/(Fo+1),++Fo)}},200)):(o.wheelDX+=n,o.wheelDY+=i))}}function er(e,t,r){if("string"==typeof t&&(t=el[t],!t))return!1;e.display.input.ensurePolled();var n=e.display.shift,i=!1;try{Z(e)&&(e.state.suppressEdits=!0),r&&(e.display.shift=!1),i=t(e)!=kl}finally{e.display.shift=n,e.state.suppressEdits=!1}return i}function tr(e,t,r){for(var n=0;n<e.state.keyMaps.length;n++){var i=rl(t,e.state.keyMaps[n],r,e);if(i)return i}return e.options.extraKeys&&rl(t,e.options.extraKeys,r,e)||rl(t,e.options.keyMap,r,e)}function rr(e,t,r,n){var i=e.state.keySeq;if(i){if(nl(t))return"handled";Go.set(50,function(){e.state.keySeq==i&&(e.state.keySeq=null,e.display.input.reset())}),t=i+" "+t}var o=tr(e,t,n);return"multi"==o&&(e.state.keySeq=t),"handled"==o&&vi(e,"keyHandled",e,t,r),("handled"==o||"multi"==o)&&(ml(r),Pe(e)),i&&!o&&/\'$/.test(t)?(ml(r),!0):!!o}function nr(e,t){var r=il(t,!0);return r?t.shiftKey&&!e.state.keySeq?rr(e,"Shift-"+r,t,function(t){return er(e,t,!0)})||rr(e,r,t,function(t){return("string"==typeof t?/^go[A-Z]/.test(t):t.motion)?er(e,t):void 0}):rr(e,r,t,function(t){return er(e,t)}):!1}function ir(e,t,r){return rr(e,"'"+r+"'",t,function(t){return er(e,t,!0)})}function or(e){var t=this;if(q(t),!yi(t,e)){uo&&11>co&&27==e.keyCode&&(e.returnValue=!1);var r=e.keyCode;t.display.shift=16==r||e.shiftKey;var n=nr(t,e);go&&(Uo=n?r:null,!n&&88==r&&!jl&&(xo?e.metaKey:e.ctrlKey)&&t.replaceSelection("",null,"cut")),18!=r||/\bCodeMirror-crosshair\b/.test(t.display.lineDiv.className)||lr(t)}}function lr(e){function t(e){18!=e.keyCode&&e.altKey||(Rl(r,"CodeMirror-crosshair"),xl(document,"keyup",t),xl(document,"mouseover",t))}var r=e.display.lineDiv;Bl(r,"CodeMirror-crosshair"),wl(document,"keyup",t),wl(document,"mouseover",t)}function sr(e){16==e.keyCode&&(this.doc.sel.shift=!1),yi(this,e)}function ar(e){var t=this;if(!(Gt(t.display,e)||yi(t,e)||e.ctrlKey&&!e.altKey||xo&&e.metaKey)){var r=e.keyCode,n=e.charCode;if(go&&r==Uo)return Uo=null,void ml(e);if(!go||e.which&&!(e.which<10)||!nr(t,e)){var i=String.fromCharCode(null==n?r:n);ir(t,e,i)||t.display.input.onKeyPress(e)}}}function ur(e){"nocursor"!=e.options.readOnly&&(e.state.focused||(Cl(e,"focus",e),e.state.focused=!0,Bl(e.display.wrapper,"CodeMirror-focused"),e.curOp||e.display.selForContextMenu==e.doc.sel||(e.display.input.reset(),fo&&setTimeout(function(){e.display.input.reset(!0)},20)),e.display.input.receivedFocus()),Pe(e))}function cr(e){e.state.focused&&(Cl(e,"blur",e),e.state.focused=!1,Rl(e.display.wrapper,"CodeMirror-focused")),clearInterval(e.display.blinker),setTimeout(function(){e.state.focused||(e.display.shift=!1)},150)}function fr(e,t){Gt(e.display,t)||hr(e,t)||e.display.input.onContextMenu(t)}function hr(e,t){return wi(e,"gutterContextMenu")?_t(e,t,"gutterContextMenu",!1,Cl):!1}function dr(e,t){if(Ao(e,t.from)<0)return e;if(Ao(e,t.to)<=0)return Vo(t);var r=e.line+t.text.length-(t.to.line-t.from.line)-1,n=e.ch;return e.line==t.to.line&&(n+=Vo(t).ch-t.to.ch),No(r,n)}function pr(e,t){for(var r=[],n=0;n<e.sel.ranges.length;n++){var i=e.sel.ranges[n];r.push(new ce(dr(i.anchor,t),dr(i.head,t)))}return fe(r,e.sel.primIndex)}function gr(e,t,r){return e.line==t.line?No(r.line,e.ch-t.ch+r.ch):No(r.line+(e.line-t.line),e.ch)}function vr(e,t,r){for(var n=[],i=No(e.first,0),o=i,l=0;l<t.length;l++){var s=t[l],a=gr(s.from,i,o),u=gr(Vo(s),i,o);if(i=s.to,o=u,"around"==r){var c=e.sel.ranges[l],f=Ao(c.head,c.anchor)<0;n[l]=new ce(f?u:a,f?a:u)}else n[l]=new ce(a,a)}return new ue(n,e.sel.primIndex)}function mr(e,t,r){var n={canceled:!1,from:t.from,to:t.to,text:t.text,origin:t.origin,cancel:function(){this.canceled=!0}};return r&&(n.update=function(t,r,n,i){t&&(this.from=pe(e,t)),r&&(this.to=pe(e,r)),n&&(this.text=n),void 0!==i&&(this.origin=i)}),Cl(e,"beforeChange",e,n),e.cm&&Cl(e.cm,"beforeChange",e.cm,n),n.canceled?null:{from:n.from,to:n.to,text:n.text,origin:n.origin}}function yr(e,t,r){if(e.cm){if(!e.cm.curOp)return Mt(e.cm,yr)(e,t,r);if(e.cm.state.suppressEdits)return}if(!(wi(e,"beforeChange")||e.cm&&wi(e.cm,"beforeChange"))||(t=mr(e,t,!0))){var n=To&&!r&&en(e,t.from,t.to);if(n)for(var i=n.length-1;i>=0;--i)br(e,{from:n[i].from,to:n[i].to,text:i?[""]:t.text});else br(e,t)}}function br(e,t){if(1!=t.text.length||""!=t.text[0]||0!=Ao(t.from,t.to)){var r=pr(e,t);ri(e,t,r,e.cm?e.cm.curOp.id:NaN),Cr(e,t,r,Zr(e,t));var n=[];Un(e,function(e,r){r||-1!=Ti(n,e.history)||(hi(e.history,t),n.push(e.history)),Cr(e,t,null,Zr(e,t))})}}function wr(e,t,r){if(!e.cm||!e.cm.state.suppressEdits){for(var n,i=e.history,o=e.sel,l="undo"==t?i.done:i.undone,s="undo"==t?i.undone:i.done,a=0;a<l.length&&(n=l[a],r?!n.ranges||n.equals(e.sel):n.ranges);a++);if(a!=l.length){for(i.lastOrigin=i.lastSelOrigin=null;n=l.pop(),n.ranges;){if(oi(n,s),r&&!n.equals(e.sel))return void ke(e,n,{clearRedo:!1});o=n}var u=[];oi(o,s),s.push({changes:u,generation:i.generation}),i.generation=n.generation||++i.maxGeneration;for(var c=wi(e,"beforeChange")||e.cm&&wi(e.cm,"beforeChange"),a=n.changes.length-1;a>=0;--a){var f=n.changes[a];if(f.origin=t,c&&!mr(e,f,!1))return void(l.length=0);u.push(Jn(e,f));var h=a?pr(e,f):ki(l);Cr(e,f,h,Jr(e,f)),!a&&e.cm&&e.cm.scrollIntoView({from:f.from,to:Vo(f)});var d=[];Un(e,function(e,t){t||-1!=Ti(d,e.history)||(hi(e.history,f),d.push(e.history)),Cr(e,f,null,Jr(e,f))})}}}}function xr(e,t){if(0!=t&&(e.first+=t,e.sel=new ue(Mi(e.sel.ranges,function(e){return new ce(No(e.anchor.line+t,e.anchor.ch),No(e.head.line+t,e.head.ch))}),e.sel.primIndex),e.cm)){Dt(e.cm,e.first,e.first-t,t);for(var r=e.cm.display,n=r.viewFrom;n<r.viewTo;n++)Ht(e.cm,n,"gutter")}}function Cr(e,t,r,n){if(e.cm&&!e.cm.curOp)return Mt(e.cm,Cr)(e,t,r,n);if(t.to.line<e.first)return void xr(e,t.text.length-1-(t.to.line-t.from.line));if(!(t.from.line>e.lastLine())){if(t.from.line<e.first){var i=t.text.length-1-(e.first-t.from.line);xr(e,i),t={from:No(e.first,0),to:No(t.to.line+i,t.to.ch),text:[ki(t.text)],origin:t.origin}}var o=e.lastLine();t.to.line>o&&(t={from:t.from,to:No(o,Kn(e,o).text.length),text:[t.text[0]],origin:t.origin}),t.removed=jn(e,t.from,t.to),r||(r=pr(e,t)),e.cm?Sr(e.cm,t,n):Rn(e,t,n),Te(e,r,Tl)}}function Sr(e,t,r){var n=e.doc,i=e.display,l=t.from,s=t.to,a=!1,u=l.line;e.options.lineWrapping||(u=Yn(fn(Kn(n,l.line))),n.iter(u,s.line+1,function(e){return e==i.maxLine?(a=!0,!0):void 0})),n.sel.contains(t.from,t.to)>-1&&bi(e),Rn(n,t,r,o(e)),e.options.lineWrapping||(n.iter(u,l.line+t.text.length,function(e){var t=f(e);t>i.maxLineLength&&(i.maxLine=e,i.maxLineLength=t,i.maxLineChanged=!0,a=!1)}),a&&(e.curOp.updateMaxLine=!0)),n.frontier=Math.min(n.frontier,l.line),ze(e,400);var c=t.text.length-(s.line-l.line)-1;t.full?Dt(e):l.line!=s.line||1!=t.text.length||Fn(e.doc,t)?Dt(e,l.line,s.line+1,c):Ht(e,l.line,"text");var h=wi(e,"changes"),d=wi(e,"change");if(d||h){var p={from:l,to:s,text:t.text,removed:t.removed,origin:t.origin};d&&vi(e,"change",e,p),h&&(e.curOp.changeObjs||(e.curOp.changeObjs=[])).push(p)}e.display.selForContextMenu=null}function Lr(e,t,r,n,i){if(n||(n=r),Ao(n,r)<0){var o=n;n=r,r=o}"string"==typeof t&&(t=Vl(t)),yr(e,{from:r,to:n,text:t,origin:i})}function kr(e,t){if(!yi(e,"scrollCursorIntoView")){var r=e.display,n=r.sizer.getBoundingClientRect(),i=null;if(t.top+n.top<0?i=!0:t.bottom+n.top>(window.innerHeight||document.documentElement.clientHeight)&&(i=!1),null!=i&&!yo){var o=Pi("div","​",null,"position: absolute; top: "+(t.top-r.viewOffset-Be(e.display))+"px; height: "+(t.bottom-t.top+Ve(e)+r.barHeight)+"px; left: "+t.left+"px; width: 2px;");e.display.lineSpace.appendChild(o),o.scrollIntoView(i),e.display.lineSpace.removeChild(o)}}}function Tr(e,t,r,n){null==n&&(n=0);for(var i=0;5>i;i++){var o=!1,l=ct(e,t),s=r&&r!=t?ct(e,r):l,a=Nr(e,Math.min(l.left,s.left),Math.min(l.top,s.top)-n,Math.max(l.left,s.left),Math.max(l.bottom,s.bottom)+n),u=e.doc.scrollTop,c=e.doc.scrollLeft;if(null!=a.scrollTop&&(Zt(e,a.scrollTop),Math.abs(e.doc.scrollTop-u)>1&&(o=!0)),null!=a.scrollLeft&&(Qt(e,a.scrollLeft),Math.abs(e.doc.scrollLeft-c)>1&&(o=!0)),!o)break}return l}function Mr(e,t,r,n,i){var o=Nr(e,t,r,n,i);null!=o.scrollTop&&Zt(e,o.scrollTop),null!=o.scrollLeft&&Qt(e,o.scrollLeft)}function Nr(e,t,r,n,i){var o=e.display,l=gt(e.display);0>r&&(r=0);var s=e.curOp&&null!=e.curOp.scrollTop?e.curOp.scrollTop:o.scroller.scrollTop,a=je(e),u={};i-r>a&&(i=r+a);var c=e.doc.height+Ge(o),f=l>r,h=i>c-l;if(s>r)u.scrollTop=f?0:r;else if(i>s+a){var d=Math.min(r,(h?c:i)-a);d!=s&&(u.scrollTop=d)}var p=e.curOp&&null!=e.curOp.scrollLeft?e.curOp.scrollLeft:o.scroller.scrollLeft,g=Ke(e)-(e.options.fixedGutter?o.gutters.offsetWidth:0),v=n-t>g;return v&&(n=t+g),10>t?u.scrollLeft=0:p>t?u.scrollLeft=Math.max(0,t-(v?0:10)):n>g+p-3&&(u.scrollLeft=n+(v?0:10)-g),u}function Ar(e,t,r){(null!=t||null!=r)&&Or(e),null!=t&&(e.curOp.scrollLeft=(null==e.curOp.scrollLeft?e.doc.scrollLeft:e.curOp.scrollLeft)+t),null!=r&&(e.curOp.scrollTop=(null==e.curOp.scrollTop?e.doc.scrollTop:e.curOp.scrollTop)+r)}function Wr(e){Or(e);var t=e.getCursor(),r=t,n=t;e.options.lineWrapping||(r=t.ch?No(t.line,t.ch-1):t,n=No(t.line,t.ch+1)),e.curOp.scrollToPos={from:r,to:n,margin:e.options.cursorScrollMargin,isCursor:!0}}function Or(e){var t=e.curOp.scrollToPos;if(t){e.curOp.scrollToPos=null;var r=ft(e,t.from),n=ft(e,t.to),i=Nr(e,Math.min(r.left,n.left),Math.min(r.top,n.top)-t.margin,Math.max(r.right,n.right),Math.max(r.bottom,n.bottom)+t.margin);e.scrollTo(i.scrollLeft,i.scrollTop)}}function Dr(e,t,r,n){var i,o=e.doc;null==r&&(r="add"),"smart"==r&&(o.mode.indent?i=Re(e,t):r="prev");var l=e.options.tabSize,s=Kn(o,t),a=Al(s.text,null,l);s.stateAfter&&(s.stateAfter=null);var u,c=s.text.match(/^\s*/)[0];if(n||/\S/.test(s.text)){if("smart"==r&&(u=o.mode.indent(i,s.text.slice(c.length),s.text),u==kl||u>150)){if(!n)return;r="prev"}}else u=0,r="not";"prev"==r?u=t>o.first?Al(Kn(o,t-1).text,null,l):0:"add"==r?u=a+e.options.indentUnit:"subtract"==r?u=a-e.options.indentUnit:"number"==typeof r&&(u=a+r),u=Math.max(0,u);var f="",h=0;if(e.options.indentWithTabs)for(var d=Math.floor(u/l);d;--d)h+=l,f+=" ";if(u>h&&(f+=Li(u-h)),f!=c)Lr(o,f,No(t,0),No(t,c.length),"+input");else for(var d=0;d<o.sel.ranges.length;d++){var p=o.sel.ranges[d];if(p.head.line==t&&p.head.ch<c.length){var h=No(t,c.length);xe(o,d,new ce(h,h));break}}s.stateAfter=null}function Hr(e,t,r,n){var i=t,o=t;return"number"==typeof t?o=Kn(e,de(e,t)):i=Yn(t),null==i?null:(n(o,i)&&e.cm&&Ht(e.cm,i,r),o)}function Ir(e,t){for(var r=e.doc.sel.ranges,n=[],i=0;i<r.length;i++){for(var o=t(r[i]);n.length&&Ao(o.from,ki(n).to)<=0;){var l=n.pop();if(Ao(l.from,o.from)<0){o.from=l.from;break}}n.push(o)}Tt(e,function(){for(var t=n.length-1;t>=0;t--)Lr(e.doc,"",n[t].from,n[t].to,"+delete");Wr(e)})}function Pr(e,t,r,n,i){function o(){var t=s+r;return t<e.first||t>=e.first+e.size?f=!1:(s=t,c=Kn(e,t))}function l(e){var t=(i?io:oo)(c,a,r,!0);if(null==t){if(e||!o())return f=!1;a=i?(0>r?Zi:qi)(c):0>r?c.text.length:0}else a=t;return!0}var s=t.line,a=t.ch,u=r,c=Kn(e,s),f=!0;if("char"==n)l();else if("column"==n)l(!0);else if("word"==n||"group"==n)for(var h=null,d="group"==n,p=e.cm&&e.cm.getHelper(t,"wordChars"),g=!0;!(0>r)||l(!g);g=!1){var v=c.text.charAt(a)||"\n",m=Di(v,p)?"w":d&&"\n"==v?"n":!d||/\s/.test(v)?null:"p";if(!d||g||m||(m="s"),h&&h!=m){0>r&&(r=1,l());break}if(m&&(h=m),r>0&&!l(!g))break}var y=We(e,No(s,a),u,!0);return f||(y.hitSide=!0),y}function zr(e,t,r,n){var i,o=e.doc,l=t.left;if("page"==n){var s=Math.min(e.display.wrapper.clientHeight,window.innerHeight||document.documentElement.clientHeight);i=t.top+r*(s-(0>r?1.5:.5)*gt(e.display))}else"line"==n&&(i=r>0?t.bottom+3:t.top-3);for(;;){var a=dt(e,l,i);if(!a.outside)break;if(0>r?0>=i:i>=o.height){a.hitSide=!0;break}i+=5*r}return a}function Er(t,r,n,i){e.defaults[t]=r,n&&(jo[t]=i?function(e,t,r){r!=Xo&&n(e,t,r)}:n)}function Fr(e){for(var t,r,n,i,o=e.split(/-(?!$)/),e=o[o.length-1],l=0;l<o.length-1;l++){var s=o[l];if(/^(cmd|meta|m)$/i.test(s))i=!0;else if(/^a(lt)?$/i.test(s))t=!0;else if(/^(c|ctrl|control)$/i.test(s))r=!0;else{if(!/^s(hift)$/i.test(s))throw new Error("Unrecognized modifier name: "+s);n=!0}}return t&&(e="Alt-"+e),r&&(e="Ctrl-"+e),i&&(e="Cmd-"+e),n&&(e="Shift-"+e),e}function Rr(e){return"string"==typeof e?tl[e]:e;
3
- }function Br(e,t,r,n,i){if(n&&n.shared)return Gr(e,t,r,n,i);if(e.cm&&!e.cm.curOp)return Mt(e.cm,Br)(e,t,r,n,i);var o=new sl(e,i),l=Ao(t,r);if(n&&Wi(n,o,!1),l>0||0==l&&o.clearWhenEmpty!==!1)return o;if(o.replacedWith&&(o.collapsed=!0,o.widgetNode=Pi("span",[o.replacedWith],"CodeMirror-widget"),n.handleMouseEvents||o.widgetNode.setAttribute("cm-ignore-events","true"),n.insertLeft&&(o.widgetNode.insertLeft=!0)),o.collapsed){if(cn(e,t.line,t,r,o)||t.line!=r.line&&cn(e,r.line,t,r,o))throw new Error("Inserting collapsed marker partially overlapping an existing one");Mo=!0}o.addToHistory&&ri(e,{from:t,to:r,origin:"markText"},e.sel,NaN);var s,a=t.line,u=e.cm;if(e.iter(a,r.line+1,function(e){u&&o.collapsed&&!u.options.lineWrapping&&fn(e)==u.display.maxLine&&(s=!0),o.collapsed&&a!=t.line&&_n(e,0),Yr(e,new jr(o,a==t.line?t.ch:null,a==r.line?r.ch:null)),++a}),o.collapsed&&e.iter(t.line,r.line+1,function(t){gn(e,t)&&_n(t,0)}),o.clearOnEnter&&wl(o,"beforeCursorEnter",function(){o.clear()}),o.readOnly&&(To=!0,(e.history.done.length||e.history.undone.length)&&e.clearHistory()),o.collapsed&&(o.id=++ll,o.atomic=!0),u){if(s&&(u.curOp.updateMaxLine=!0),o.collapsed)Dt(u,t.line,r.line+1);else if(o.className||o.title||o.startStyle||o.endStyle||o.css)for(var c=t.line;c<=r.line;c++)Ht(u,c,"text");o.atomic&&Ne(u.doc),vi(u,"markerAdded",u,o)}return o}function Gr(e,t,r,n,i){n=Wi(n),n.shared=!1;var o=[Br(e,t,r,n,i)],l=o[0],s=n.widgetNode;return Un(e,function(e){s&&(n.widgetNode=s.cloneNode(!0)),o.push(Br(e,pe(e,t),pe(e,r),n,i));for(var a=0;a<e.linked.length;++a)if(e.linked[a].isParent)return;l=ki(o)}),new al(o,l)}function Ur(e){return e.findMarks(No(e.first,0),e.clipPos(No(e.lastLine())),function(e){return e.parent})}function Vr(e,t){for(var r=0;r<t.length;r++){var n=t[r],i=n.find(),o=e.clipPos(i.from),l=e.clipPos(i.to);if(Ao(o,l)){var s=Br(e,o,l,n.primary,n.primary.type);n.markers.push(s),s.parent=n}}}function Kr(e){for(var t=0;t<e.length;t++){var r=e[t],n=[r.primary.doc];Un(r.primary.doc,function(e){n.push(e)});for(var i=0;i<r.markers.length;i++){var o=r.markers[i];-1==Ti(n,o.doc)&&(o.parent=null,r.markers.splice(i--,1))}}}function jr(e,t,r){this.marker=e,this.from=t,this.to=r}function Xr(e,t){if(e)for(var r=0;r<e.length;++r){var n=e[r];if(n.marker==t)return n}}function _r(e,t){for(var r,n=0;n<e.length;++n)e[n]!=t&&(r||(r=[])).push(e[n]);return r}function Yr(e,t){e.markedSpans=e.markedSpans?e.markedSpans.concat([t]):[t],t.marker.attachLine(e)}function $r(e,t,r){if(e)for(var n,i=0;i<e.length;++i){var o=e[i],l=o.marker,s=null==o.from||(l.inclusiveLeft?o.from<=t:o.from<t);if(s||o.from==t&&"bookmark"==l.type&&(!r||!o.marker.insertLeft)){var a=null==o.to||(l.inclusiveRight?o.to>=t:o.to>t);(n||(n=[])).push(new jr(l,o.from,a?null:o.to))}}return n}function qr(e,t,r){if(e)for(var n,i=0;i<e.length;++i){var o=e[i],l=o.marker,s=null==o.to||(l.inclusiveRight?o.to>=t:o.to>t);if(s||o.from==t&&"bookmark"==l.type&&(!r||o.marker.insertLeft)){var a=null==o.from||(l.inclusiveLeft?o.from<=t:o.from<t);(n||(n=[])).push(new jr(l,a?null:o.from-t,null==o.to?null:o.to-t))}}return n}function Zr(e,t){if(t.full)return null;var r=ve(e,t.from.line)&&Kn(e,t.from.line).markedSpans,n=ve(e,t.to.line)&&Kn(e,t.to.line).markedSpans;if(!r&&!n)return null;var i=t.from.ch,o=t.to.ch,l=0==Ao(t.from,t.to),s=$r(r,i,l),a=qr(n,o,l),u=1==t.text.length,c=ki(t.text).length+(u?i:0);if(s)for(var f=0;f<s.length;++f){var h=s[f];if(null==h.to){var d=Xr(a,h.marker);d?u&&(h.to=null==d.to?null:d.to+c):h.to=i}}if(a)for(var f=0;f<a.length;++f){var h=a[f];if(null!=h.to&&(h.to+=c),null==h.from){var d=Xr(s,h.marker);d||(h.from=c,u&&(s||(s=[])).push(h))}else h.from+=c,u&&(s||(s=[])).push(h)}s&&(s=Qr(s)),a&&a!=s&&(a=Qr(a));var p=[s];if(!u){var g,v=t.text.length-2;if(v>0&&s)for(var f=0;f<s.length;++f)null==s[f].to&&(g||(g=[])).push(new jr(s[f].marker,null,null));for(var f=0;v>f;++f)p.push(g);p.push(a)}return p}function Qr(e){for(var t=0;t<e.length;++t){var r=e[t];null!=r.from&&r.from==r.to&&r.marker.clearWhenEmpty!==!1&&e.splice(t--,1)}return e.length?e:null}function Jr(e,t){var r=ai(e,t),n=Zr(e,t);if(!r)return n;if(!n)return r;for(var i=0;i<r.length;++i){var o=r[i],l=n[i];if(o&&l)e:for(var s=0;s<l.length;++s){for(var a=l[s],u=0;u<o.length;++u)if(o[u].marker==a.marker)continue e;o.push(a)}else l&&(r[i]=l)}return r}function en(e,t,r){var n=null;if(e.iter(t.line,r.line+1,function(e){if(e.markedSpans)for(var t=0;t<e.markedSpans.length;++t){var r=e.markedSpans[t].marker;!r.readOnly||n&&-1!=Ti(n,r)||(n||(n=[])).push(r)}}),!n)return null;for(var i=[{from:t,to:r}],o=0;o<n.length;++o)for(var l=n[o],s=l.find(0),a=0;a<i.length;++a){var u=i[a];if(!(Ao(u.to,s.from)<0||Ao(u.from,s.to)>0)){var c=[a,1],f=Ao(u.from,s.from),h=Ao(u.to,s.to);(0>f||!l.inclusiveLeft&&!f)&&c.push({from:u.from,to:s.from}),(h>0||!l.inclusiveRight&&!h)&&c.push({from:s.to,to:u.to}),i.splice.apply(i,c),a+=c.length-1}}return i}function tn(e){var t=e.markedSpans;if(t){for(var r=0;r<t.length;++r)t[r].marker.detachLine(e);e.markedSpans=null}}function rn(e,t){if(t){for(var r=0;r<t.length;++r)t[r].marker.attachLine(e);e.markedSpans=t}}function nn(e){return e.inclusiveLeft?-1:0}function on(e){return e.inclusiveRight?1:0}function ln(e,t){var r=e.lines.length-t.lines.length;if(0!=r)return r;var n=e.find(),i=t.find(),o=Ao(n.from,i.from)||nn(e)-nn(t);if(o)return-o;var l=Ao(n.to,i.to)||on(e)-on(t);return l?l:t.id-e.id}function sn(e,t){var r,n=Mo&&e.markedSpans;if(n)for(var i,o=0;o<n.length;++o)i=n[o],i.marker.collapsed&&null==(t?i.from:i.to)&&(!r||ln(r,i.marker)<0)&&(r=i.marker);return r}function an(e){return sn(e,!0)}function un(e){return sn(e,!1)}function cn(e,t,r,n,i){var o=Kn(e,t),l=Mo&&o.markedSpans;if(l)for(var s=0;s<l.length;++s){var a=l[s];if(a.marker.collapsed){var u=a.marker.find(0),c=Ao(u.from,r)||nn(a.marker)-nn(i),f=Ao(u.to,n)||on(a.marker)-on(i);if(!(c>=0&&0>=f||0>=c&&f>=0)&&(0>=c&&(Ao(u.to,r)>0||a.marker.inclusiveRight&&i.inclusiveLeft)||c>=0&&(Ao(u.from,n)<0||a.marker.inclusiveLeft&&i.inclusiveRight)))return!0}}}function fn(e){for(var t;t=an(e);)e=t.find(-1,!0).line;return e}function hn(e){for(var t,r;t=un(e);)e=t.find(1,!0).line,(r||(r=[])).push(e);return r}function dn(e,t){var r=Kn(e,t),n=fn(r);return r==n?t:Yn(n)}function pn(e,t){if(t>e.lastLine())return t;var r,n=Kn(e,t);if(!gn(e,n))return t;for(;r=un(n);)n=r.find(1,!0).line;return Yn(n)+1}function gn(e,t){var r=Mo&&t.markedSpans;if(r)for(var n,i=0;i<r.length;++i)if(n=r[i],n.marker.collapsed){if(null==n.from)return!0;if(!n.marker.widgetNode&&0==n.from&&n.marker.inclusiveLeft&&vn(e,t,n))return!0}}function vn(e,t,r){if(null==r.to){var n=r.marker.find(1,!0);return vn(e,n.line,Xr(n.line.markedSpans,r.marker))}if(r.marker.inclusiveRight&&r.to==t.text.length)return!0;for(var i,o=0;o<t.markedSpans.length;++o)if(i=t.markedSpans[o],i.marker.collapsed&&!i.marker.widgetNode&&i.from==r.to&&(null==i.to||i.to!=r.from)&&(i.marker.inclusiveLeft||r.marker.inclusiveRight)&&vn(e,t,i))return!0}function mn(e,t,r){qn(t)<(e.curOp&&e.curOp.scrollTop||e.doc.scrollTop)&&Ar(e,null,r)}function yn(e){if(null!=e.height)return e.height;if(!zl(document.body,e.node)){var t="position: relative;";e.coverGutter&&(t+="margin-left: -"+e.cm.display.gutters.offsetWidth+"px;"),e.noHScroll&&(t+="width: "+e.cm.display.wrapper.clientWidth+"px;"),Ei(e.cm.display.measure,Pi("div",[e.node],null,t))}return e.height=e.node.offsetHeight}function bn(e,t,r,n){var i=new ul(e,r,n);return i.noHScroll&&(e.display.alignWidgets=!0),Hr(e.doc,t,"widget",function(t){var r=t.widgets||(t.widgets=[]);if(null==i.insertAt?r.push(i):r.splice(Math.min(r.length-1,Math.max(0,i.insertAt)),0,i),i.line=t,!gn(e.doc,t)){var n=qn(t)<e.doc.scrollTop;_n(t,t.height+yn(i)),n&&Ar(e,null,i.height),e.curOp.forceUpdate=!0}return!0}),i}function wn(e,t,r,n){e.text=t,e.stateAfter&&(e.stateAfter=null),e.styles&&(e.styles=null),null!=e.order&&(e.order=null),tn(e),rn(e,r);var i=n?n(e):1;i!=e.height&&_n(e,i)}function xn(e){e.parent=null,tn(e)}function Cn(e,t){if(e)for(;;){var r=e.match(/(?:^|\s+)line-(background-)?(\S+)/);if(!r)break;e=e.slice(0,r.index)+e.slice(r.index+r[0].length);var n=r[1]?"bgClass":"textClass";null==t[n]?t[n]=r[2]:new RegExp("(?:^|s)"+r[2]+"(?:$|s)").test(t[n])||(t[n]+=" "+r[2])}return e}function Sn(t,r){if(t.blankLine)return t.blankLine(r);if(t.innerMode){var n=e.innerMode(t,r);return n.mode.blankLine?n.mode.blankLine(n.state):void 0}}function Ln(t,r,n,i){for(var o=0;10>o;o++){i&&(i[0]=e.innerMode(t,n).mode);var l=t.token(r,n);if(r.pos>r.start)return l}throw new Error("Mode "+t.name+" failed to advance stream.")}function kn(e,t,r,n){function i(e){return{start:f.start,end:f.pos,string:f.current(),type:o||null,state:e?Qo(l.mode,c):c}}var o,l=e.doc,s=l.mode;t=pe(l,t);var a,u=Kn(l,t.line),c=Re(e,t.line,r),f=new ol(u.text,e.options.tabSize);for(n&&(a=[]);(n||f.pos<t.ch)&&!f.eol();)f.start=f.pos,o=Ln(s,f,c),n&&a.push(i(!0));return n?a:i()}function Tn(e,t,r,n,i,o,l){var s=r.flattenSpans;null==s&&(s=e.options.flattenSpans);var a,u=0,c=null,f=new ol(t,e.options.tabSize),h=e.options.addModeClass&&[null];for(""==t&&Cn(Sn(r,n),o);!f.eol();){if(f.pos>e.options.maxHighlightLength?(s=!1,l&&An(e,t,n,f.pos),f.pos=t.length,a=null):a=Cn(Ln(r,f,n,h),o),h){var d=h[0].name;d&&(a="m-"+(a?d+" "+a:d))}if(!s||c!=a){for(;u<f.start;)u=Math.min(f.start,u+5e4),i(u,c);c=a}f.start=f.pos}for(;u<f.pos;){var p=Math.min(f.pos,u+5e4);i(p,c),u=p}}function Mn(e,t,r,n){var i=[e.state.modeGen],o={};Tn(e,t.text,e.doc.mode,r,function(e,t){i.push(e,t)},o,n);for(var l=0;l<e.state.overlays.length;++l){var s=e.state.overlays[l],a=1,u=0;Tn(e,t.text,s.mode,!0,function(e,t){for(var r=a;e>u;){var n=i[a];n>e&&i.splice(a,1,e,i[a+1],n),a+=2,u=Math.min(e,n)}if(t)if(s.opaque)i.splice(r,a-r,e,"cm-overlay "+t),a=r+2;else for(;a>r;r+=2){var o=i[r+1];i[r+1]=(o?o+" ":"")+"cm-overlay "+t}},o)}return{styles:i,classes:o.bgClass||o.textClass?o:null}}function Nn(e,t,r){if(!t.styles||t.styles[0]!=e.state.modeGen){var n=Mn(e,t,t.stateAfter=Re(e,Yn(t)));t.styles=n.styles,n.classes?t.styleClasses=n.classes:t.styleClasses&&(t.styleClasses=null),r===e.doc.frontier&&e.doc.frontier++}return t.styles}function An(e,t,r,n){var i=e.doc.mode,o=new ol(t,e.options.tabSize);for(o.start=o.pos=n||0,""==t&&Sn(i,r);!o.eol()&&o.pos<=e.options.maxHighlightLength;)Ln(i,o,r),o.start=o.pos}function Wn(e,t){if(!e||/^\s*$/.test(e))return null;var r=t.addModeClass?hl:fl;return r[e]||(r[e]=e.replace(/\S+/g,"cm-$&"))}function On(e,t){var r=Pi("span",null,null,fo?"padding-right: .1px":null),n={pre:Pi("pre",[r]),content:r,col:0,pos:0,cm:e};t.measure={};for(var i=0;i<=(t.rest?t.rest.length:0);i++){var o,l=i?t.rest[i-1]:t.line;n.pos=0,n.addToken=Hn,(uo||fo)&&e.getOption("lineWrapping")&&(n.addToken=In(n.addToken)),ji(e.display.measure)&&(o=Zn(l))&&(n.addToken=Pn(n.addToken,o)),n.map=[];var s=t!=e.display.externalMeasured&&Yn(l);En(l,n,Nn(e,l,s)),l.styleClasses&&(l.styleClasses.bgClass&&(n.bgClass=Bi(l.styleClasses.bgClass,n.bgClass||"")),l.styleClasses.textClass&&(n.textClass=Bi(l.styleClasses.textClass,n.textClass||""))),0==n.map.length&&n.map.push(0,0,n.content.appendChild(Ki(e.display.measure))),0==i?(t.measure.map=n.map,t.measure.cache={}):((t.measure.maps||(t.measure.maps=[])).push(n.map),(t.measure.caches||(t.measure.caches=[])).push({}))}return fo&&/\bcm-tab\b/.test(n.content.lastChild.className)&&(n.content.className="cm-tab-wrap-hack"),Cl(e,"renderLine",e,t.line,n.pre),n.pre.className&&(n.textClass=Bi(n.pre.className,n.textClass||"")),n}function Dn(e){var t=Pi("span","•","cm-invalidchar");return t.title="\\u"+e.charCodeAt(0).toString(16),t.setAttribute("aria-label",t.title),t}function Hn(e,t,r,n,i,o,l){if(t){var s=e.cm.options.specialChars,a=!1;if(s.test(t))for(var u=document.createDocumentFragment(),c=0;;){s.lastIndex=c;var f=s.exec(t),h=f?f.index-c:t.length-c;if(h){var d=document.createTextNode(t.slice(c,c+h));uo&&9>co?u.appendChild(Pi("span",[d])):u.appendChild(d),e.map.push(e.pos,e.pos+h,d),e.col+=h,e.pos+=h}if(!f)break;if(c+=h+1," "==f[0]){var p=e.cm.options.tabSize,g=p-e.col%p,d=u.appendChild(Pi("span",Li(g),"cm-tab"));d.setAttribute("role","presentation"),d.setAttribute("cm-text"," "),e.col+=g}else{var d=e.cm.options.specialCharPlaceholder(f[0]);d.setAttribute("cm-text",f[0]),uo&&9>co?u.appendChild(Pi("span",[d])):u.appendChild(d),e.col+=1}e.map.push(e.pos,e.pos+1,d),e.pos++}else{e.col+=t.length;var u=document.createTextNode(t);e.map.push(e.pos,e.pos+t.length,u),uo&&9>co&&(a=!0),e.pos+=t.length}if(r||n||i||a||l){var v=r||"";n&&(v+=n),i&&(v+=i);var m=Pi("span",[u],v,l);return o&&(m.title=o),e.content.appendChild(m)}e.content.appendChild(u)}}function In(e){function t(e){for(var t=" ",r=0;r<e.length-2;++r)t+=r%2?" ":" ";return t+=" "}return function(r,n,i,o,l,s){e(r,n.replace(/ {3,}/g,t),i,o,l,s)}}function Pn(e,t){return function(r,n,i,o,l,s){i=i?i+" cm-force-border":"cm-force-border";for(var a=r.pos,u=a+n.length;;){for(var c=0;c<t.length;c++){var f=t[c];if(f.to>a&&f.from<=a)break}if(f.to>=u)return e(r,n,i,o,l,s);e(r,n.slice(0,f.to-a),i,o,null,s),o=null,n=n.slice(f.to-a),a=f.to}}}function zn(e,t,r,n){var i=!n&&r.widgetNode;i&&e.map.push(e.pos,e.pos+t,i),!n&&e.cm.display.input.needsContentAttribute&&(i||(i=e.content.appendChild(document.createElement("span"))),i.setAttribute("cm-marker",r.id)),i&&(e.cm.display.input.setUneditable(i),e.content.appendChild(i)),e.pos+=t}function En(e,t,r){var n=e.markedSpans,i=e.text,o=0;if(n)for(var l,s,a,u,c,f,h,d=i.length,p=0,g=1,v="",m=0;;){if(m==p){a=u=c=f=s="",h=null,m=1/0;for(var y=[],b=0;b<n.length;++b){var w=n[b],x=w.marker;w.from<=p&&(null==w.to||w.to>p)?(null!=w.to&&m>w.to&&(m=w.to,u=""),x.className&&(a+=" "+x.className),x.css&&(s=x.css),x.startStyle&&w.from==p&&(c+=" "+x.startStyle),x.endStyle&&w.to==m&&(u+=" "+x.endStyle),x.title&&!f&&(f=x.title),x.collapsed&&(!h||ln(h.marker,x)<0)&&(h=w)):w.from>p&&m>w.from&&(m=w.from),"bookmark"==x.type&&w.from==p&&x.widgetNode&&y.push(x)}if(h&&(h.from||0)==p&&(zn(t,(null==h.to?d+1:h.to)-p,h.marker,null==h.from),null==h.to))return;if(!h&&y.length)for(var b=0;b<y.length;++b)zn(t,0,y[b])}if(p>=d)break;for(var C=Math.min(d,m);;){if(v){var S=p+v.length;if(!h){var L=S>C?v.slice(0,C-p):v;t.addToken(t,L,l?l+a:a,c,p+L.length==m?u:"",f,s)}if(S>=C){v=v.slice(C-p),p=C;break}p=S,c=""}v=i.slice(o,o=r[g++]),l=Wn(r[g++],t.cm.options)}}else for(var g=1;g<r.length;g+=2)t.addToken(t,i.slice(o,o=r[g]),Wn(r[g+1],t.cm.options))}function Fn(e,t){return 0==t.from.ch&&0==t.to.ch&&""==ki(t.text)&&(!e.cm||e.cm.options.wholeLineUpdateBefore)}function Rn(e,t,r,n){function i(e){return r?r[e]:null}function o(e,r,i){wn(e,r,i,n),vi(e,"change",e,t)}function l(e,t){for(var r=e,o=[];t>r;++r)o.push(new cl(u[r],i(r),n));return o}var s=t.from,a=t.to,u=t.text,c=Kn(e,s.line),f=Kn(e,a.line),h=ki(u),d=i(u.length-1),p=a.line-s.line;if(t.full)e.insert(0,l(0,u.length)),e.remove(u.length,e.size-u.length);else if(Fn(e,t)){var g=l(0,u.length-1);o(f,f.text,d),p&&e.remove(s.line,p),g.length&&e.insert(s.line,g)}else if(c==f)if(1==u.length)o(c,c.text.slice(0,s.ch)+h+c.text.slice(a.ch),d);else{var g=l(1,u.length-1);g.push(new cl(h+c.text.slice(a.ch),d,n)),o(c,c.text.slice(0,s.ch)+u[0],i(0)),e.insert(s.line+1,g)}else if(1==u.length)o(c,c.text.slice(0,s.ch)+u[0]+f.text.slice(a.ch),i(0)),e.remove(s.line+1,p);else{o(c,c.text.slice(0,s.ch)+u[0],i(0)),o(f,h+f.text.slice(a.ch),d);var g=l(1,u.length-1);p>1&&e.remove(s.line+1,p-1),e.insert(s.line+1,g)}vi(e,"change",e,t)}function Bn(e){this.lines=e,this.parent=null;for(var t=0,r=0;t<e.length;++t)e[t].parent=this,r+=e[t].height;this.height=r}function Gn(e){this.children=e;for(var t=0,r=0,n=0;n<e.length;++n){var i=e[n];t+=i.chunkSize(),r+=i.height,i.parent=this}this.size=t,this.height=r,this.parent=null}function Un(e,t,r){function n(e,i,o){if(e.linked)for(var l=0;l<e.linked.length;++l){var s=e.linked[l];if(s.doc!=i){var a=o&&s.sharedHist;(!r||a)&&(t(s.doc,a),n(s.doc,e,a))}}}n(e,null,!0)}function Vn(e,t){if(t.cm)throw new Error("This document is already in use.");e.doc=t,t.cm=e,l(e),r(e),e.options.lineWrapping||h(e),e.options.mode=t.modeOption,Dt(e)}function Kn(e,t){if(t-=e.first,0>t||t>=e.size)throw new Error("There is no line "+(t+e.first)+" in the document.");for(var r=e;!r.lines;)for(var n=0;;++n){var i=r.children[n],o=i.chunkSize();if(o>t){r=i;break}t-=o}return r.lines[t]}function jn(e,t,r){var n=[],i=t.line;return e.iter(t.line,r.line+1,function(e){var o=e.text;i==r.line&&(o=o.slice(0,r.ch)),i==t.line&&(o=o.slice(t.ch)),n.push(o),++i}),n}function Xn(e,t,r){var n=[];return e.iter(t,r,function(e){n.push(e.text)}),n}function _n(e,t){var r=t-e.height;if(r)for(var n=e;n;n=n.parent)n.height+=r}function Yn(e){if(null==e.parent)return null;for(var t=e.parent,r=Ti(t.lines,e),n=t.parent;n;t=n,n=n.parent)for(var i=0;n.children[i]!=t;++i)r+=n.children[i].chunkSize();return r+t.first}function $n(e,t){var r=e.first;e:do{for(var n=0;n<e.children.length;++n){var i=e.children[n],o=i.height;if(o>t){e=i;continue e}t-=o,r+=i.chunkSize()}return r}while(!e.lines);for(var n=0;n<e.lines.length;++n){var l=e.lines[n],s=l.height;if(s>t)break;t-=s}return r+n}function qn(e){e=fn(e);for(var t=0,r=e.parent,n=0;n<r.lines.length;++n){var i=r.lines[n];if(i==e)break;t+=i.height}for(var o=r.parent;o;r=o,o=r.parent)for(var n=0;n<o.children.length;++n){var l=o.children[n];if(l==r)break;t+=l.height}return t}function Zn(e){var t=e.order;return null==t&&(t=e.order=$l(e.text)),t}function Qn(e){this.done=[],this.undone=[],this.undoDepth=1/0,this.lastModTime=this.lastSelTime=0,this.lastOp=this.lastSelOp=null,this.lastOrigin=this.lastSelOrigin=null,this.generation=this.maxGeneration=e||1}function Jn(e,t){var r={from:_(t.from),to:Vo(t),text:jn(e,t.from,t.to)};return li(e,r,t.from.line,t.to.line+1),Un(e,function(e){li(e,r,t.from.line,t.to.line+1)},!0),r}function ei(e){for(;e.length;){var t=ki(e);if(!t.ranges)break;e.pop()}}function ti(e,t){return t?(ei(e.done),ki(e.done)):e.done.length&&!ki(e.done).ranges?ki(e.done):e.done.length>1&&!e.done[e.done.length-2].ranges?(e.done.pop(),ki(e.done)):void 0}function ri(e,t,r,n){var i=e.history;i.undone.length=0;var o,l=+new Date;if((i.lastOp==n||i.lastOrigin==t.origin&&t.origin&&("+"==t.origin.charAt(0)&&e.cm&&i.lastModTime>l-e.cm.options.historyEventDelay||"*"==t.origin.charAt(0)))&&(o=ti(i,i.lastOp==n))){var s=ki(o.changes);0==Ao(t.from,t.to)&&0==Ao(t.from,s.to)?s.to=Vo(t):o.changes.push(Jn(e,t))}else{var a=ki(i.done);for(a&&a.ranges||oi(e.sel,i.done),o={changes:[Jn(e,t)],generation:i.generation},i.done.push(o);i.done.length>i.undoDepth;)i.done.shift(),i.done[0].ranges||i.done.shift()}i.done.push(r),i.generation=++i.maxGeneration,i.lastModTime=i.lastSelTime=l,i.lastOp=i.lastSelOp=n,i.lastOrigin=i.lastSelOrigin=t.origin,s||Cl(e,"historyAdded")}function ni(e,t,r,n){var i=t.charAt(0);return"*"==i||"+"==i&&r.ranges.length==n.ranges.length&&r.somethingSelected()==n.somethingSelected()&&new Date-e.history.lastSelTime<=(e.cm?e.cm.options.historyEventDelay:500)}function ii(e,t,r,n){var i=e.history,o=n&&n.origin;r==i.lastSelOp||o&&i.lastSelOrigin==o&&(i.lastModTime==i.lastSelTime&&i.lastOrigin==o||ni(e,o,ki(i.done),t))?i.done[i.done.length-1]=t:oi(t,i.done),i.lastSelTime=+new Date,i.lastSelOrigin=o,i.lastSelOp=r,n&&n.clearRedo!==!1&&ei(i.undone)}function oi(e,t){var r=ki(t);r&&r.ranges&&r.equals(e)||t.push(e)}function li(e,t,r,n){var i=t["spans_"+e.id],o=0;e.iter(Math.max(e.first,r),Math.min(e.first+e.size,n),function(r){r.markedSpans&&((i||(i=t["spans_"+e.id]={}))[o]=r.markedSpans),++o})}function si(e){if(!e)return null;for(var t,r=0;r<e.length;++r)e[r].marker.explicitlyCleared?t||(t=e.slice(0,r)):t&&t.push(e[r]);return t?t.length?t:null:e}function ai(e,t){var r=t["spans_"+e.id];if(!r)return null;for(var n=0,i=[];n<t.text.length;++n)i.push(si(r[n]));return i}function ui(e,t,r){for(var n=0,i=[];n<e.length;++n){var o=e[n];if(o.ranges)i.push(r?ue.prototype.deepCopy.call(o):o);else{var l=o.changes,s=[];i.push({changes:s});for(var a=0;a<l.length;++a){var u,c=l[a];if(s.push({from:c.from,to:c.to,text:c.text}),t)for(var f in c)(u=f.match(/^spans_(\d+)$/))&&Ti(t,Number(u[1]))>-1&&(ki(s)[f]=c[f],delete c[f])}}}return i}function ci(e,t,r,n){r<e.line?e.line+=n:t<e.line&&(e.line=t,e.ch=0)}function fi(e,t,r,n){for(var i=0;i<e.length;++i){var o=e[i],l=!0;if(o.ranges){o.copied||(o=e[i]=o.deepCopy(),o.copied=!0);for(var s=0;s<o.ranges.length;s++)ci(o.ranges[s].anchor,t,r,n),ci(o.ranges[s].head,t,r,n)}else{for(var s=0;s<o.changes.length;++s){var a=o.changes[s];if(r<a.from.line)a.from=No(a.from.line+n,a.from.ch),a.to=No(a.to.line+n,a.to.ch);else if(t<=a.to.line){l=!1;break}}l||(e.splice(0,i+1),i=0)}}}function hi(e,t){var r=t.from.line,n=t.to.line,i=t.text.length-(n-r)-1;fi(e.done,r,n,i),fi(e.undone,r,n,i)}function di(e){return null!=e.defaultPrevented?e.defaultPrevented:0==e.returnValue}function pi(e){return e.target||e.srcElement}function gi(e){var t=e.which;return null==t&&(1&e.button?t=1:2&e.button?t=3:4&e.button&&(t=2)),xo&&e.ctrlKey&&1==t&&(t=3),t}function vi(e,t){function r(e){return function(){e.apply(null,o)}}var n=e._handlers&&e._handlers[t];if(n){var i,o=Array.prototype.slice.call(arguments,2);Po?i=Po.delayedCallbacks:Sl?i=Sl:(i=Sl=[],setTimeout(mi,0));for(var l=0;l<n.length;++l)i.push(r(n[l]))}}function mi(){var e=Sl;Sl=null;for(var t=0;t<e.length;++t)e[t]()}function yi(e,t,r){return"string"==typeof t&&(t={type:t,preventDefault:function(){this.defaultPrevented=!0}}),Cl(e,r||t.type,e,t),di(t)||t.codemirrorIgnore}function bi(e){var t=e._handlers&&e._handlers.cursorActivity;if(t)for(var r=e.curOp.cursorActivityHandlers||(e.curOp.cursorActivityHandlers=[]),n=0;n<t.length;++n)-1==Ti(r,t[n])&&r.push(t[n])}function wi(e,t){var r=e._handlers&&e._handlers[t];return r&&r.length>0}function xi(e){e.prototype.on=function(e,t){wl(this,e,t)},e.prototype.off=function(e,t){xl(this,e,t)}}function Ci(){this.id=null}function Si(e,t,r){for(var n=0,i=0;;){var o=e.indexOf(" ",n);-1==o&&(o=e.length);var l=o-n;if(o==e.length||i+l>=t)return n+Math.min(l,t-i);if(i+=o-n,i+=r-i%r,n=o+1,i>=t)return n}}function Li(e){for(;Wl.length<=e;)Wl.push(ki(Wl)+" ");return Wl[e]}function ki(e){return e[e.length-1]}function Ti(e,t){for(var r=0;r<e.length;++r)if(e[r]==t)return r;return-1}function Mi(e,t){for(var r=[],n=0;n<e.length;n++)r[n]=t(e[n],n);return r}function Ni(){}function Ai(e,t){var r;return Object.create?r=Object.create(e):(Ni.prototype=e,r=new Ni),t&&Wi(t,r),r}function Wi(e,t,r){t||(t={});for(var n in e)!e.hasOwnProperty(n)||r===!1&&t.hasOwnProperty(n)||(t[n]=e[n]);return t}function Oi(e){var t=Array.prototype.slice.call(arguments,1);return function(){return e.apply(null,t)}}function Di(e,t){return t?t.source.indexOf("\\w")>-1&&Il(e)?!0:t.test(e):Il(e)}function Hi(e){for(var t in e)if(e.hasOwnProperty(t)&&e[t])return!1;return!0}function Ii(e){return e.charCodeAt(0)>=768&&Pl.test(e)}function Pi(e,t,r,n){var i=document.createElement(e);if(r&&(i.className=r),n&&(i.style.cssText=n),"string"==typeof t)i.appendChild(document.createTextNode(t));else if(t)for(var o=0;o<t.length;++o)i.appendChild(t[o]);return i}function zi(e){for(var t=e.childNodes.length;t>0;--t)e.removeChild(e.firstChild);return e}function Ei(e,t){return zi(e).appendChild(t)}function Fi(){return document.activeElement}function Ri(e){return new RegExp("(^|\\s)"+e+"(?:$|\\s)\\s*")}function Bi(e,t){for(var r=e.split(" "),n=0;n<r.length;n++)r[n]&&!Ri(r[n]).test(t)&&(t+=" "+r[n]);return t}function Gi(e){if(document.body.getElementsByClassName)for(var t=document.body.getElementsByClassName("CodeMirror"),r=0;r<t.length;r++){var n=t[r].CodeMirror;n&&e(n)}}function Ui(){Gl||(Vi(),Gl=!0)}function Vi(){var e;wl(window,"resize",function(){null==e&&(e=setTimeout(function(){e=null,Gi(Bt)},100))}),wl(window,"blur",function(){Gi(cr)})}function Ki(e){if(null==El){var t=Pi("span","​");Ei(e,Pi("span",[t,document.createTextNode("x")])),0!=e.firstChild.offsetHeight&&(El=t.offsetWidth<=1&&t.offsetHeight>2&&!(uo&&8>co))}var r=El?Pi("span","​"):Pi("span"," ",null,"display: inline-block; width: 1px; margin-right: -1px");return r.setAttribute("cm-text",""),r}function ji(e){if(null!=Fl)return Fl;var t=Ei(e,document.createTextNode("AخA")),r=Dl(t,0,1).getBoundingClientRect();if(!r||r.left==r.right)return!1;var n=Dl(t,1,2).getBoundingClientRect();return Fl=n.right-r.right<3}function Xi(e){if(null!=Xl)return Xl;var t=Ei(e,Pi("span","x")),r=t.getBoundingClientRect(),n=Dl(t,0,1).getBoundingClientRect();return Xl=Math.abs(r.left-n.left)>1}function _i(e,t,r,n){if(!e)return n(t,r,"ltr");for(var i=!1,o=0;o<e.length;++o){var l=e[o];(l.from<r&&l.to>t||t==r&&l.to==t)&&(n(Math.max(l.from,t),Math.min(l.to,r),1==l.level?"rtl":"ltr"),i=!0)}i||n(t,r,"ltr")}function Yi(e){return e.level%2?e.to:e.from}function $i(e){return e.level%2?e.from:e.to}function qi(e){var t=Zn(e);return t?Yi(t[0]):0}function Zi(e){var t=Zn(e);return t?$i(ki(t)):e.text.length}function Qi(e,t){var r=Kn(e.doc,t),n=fn(r);n!=r&&(t=Yn(n));var i=Zn(n),o=i?i[0].level%2?Zi(n):qi(n):0;return No(t,o)}function Ji(e,t){for(var r,n=Kn(e.doc,t);r=un(n);)n=r.find(1,!0).line,t=null;var i=Zn(n),o=i?i[0].level%2?qi(n):Zi(n):n.text.length;return No(null==t?Yn(n):t,o)}function eo(e,t){var r=Qi(e,t.line),n=Kn(e.doc,r.line),i=Zn(n);if(!i||0==i[0].level){var o=Math.max(0,n.text.search(/\S/)),l=t.line==r.line&&t.ch<=o&&t.ch;return No(r.line,l?0:o)}return r}function to(e,t,r){var n=e[0].level;return t==n?!0:r==n?!1:r>t}function ro(e,t){Yl=null;for(var r,n=0;n<e.length;++n){var i=e[n];if(i.from<t&&i.to>t)return n;if(i.from==t||i.to==t){if(null!=r)return to(e,i.level,e[r].level)?(i.from!=i.to&&(Yl=r),n):(i.from!=i.to&&(Yl=n),r);r=n}}return r}function no(e,t,r,n){if(!n)return t+r;do t+=r;while(t>0&&Ii(e.text.charAt(t)));return t}function io(e,t,r,n){var i=Zn(e);if(!i)return oo(e,t,r,n);for(var o=ro(i,t),l=i[o],s=no(e,t,l.level%2?-r:r,n);;){if(s>l.from&&s<l.to)return s;if(s==l.from||s==l.to)return ro(i,s)==o?s:(l=i[o+=r],r>0==l.level%2?l.to:l.from);if(l=i[o+=r],!l)return null;s=r>0==l.level%2?no(e,l.to,-1,n):no(e,l.from,1,n)}}function oo(e,t,r,n){var i=t+r;if(n)for(;i>0&&Ii(e.text.charAt(i));)i+=r;return 0>i||i>e.text.length?null:i}var lo=/gecko\/\d/i.test(navigator.userAgent),so=/MSIE \d/.test(navigator.userAgent),ao=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent),uo=so||ao,co=uo&&(so?document.documentMode||6:ao[1]),fo=/WebKit\//.test(navigator.userAgent),ho=fo&&/Qt\/\d+\.\d+/.test(navigator.userAgent),po=/Chrome\//.test(navigator.userAgent),go=/Opera\//.test(navigator.userAgent),vo=/Apple Computer/.test(navigator.vendor),mo=/Mac OS X 1\d\D([8-9]|\d\d)\D/.test(navigator.userAgent),yo=/PhantomJS/.test(navigator.userAgent),bo=/AppleWebKit/.test(navigator.userAgent)&&/Mobile\/\w+/.test(navigator.userAgent),wo=bo||/Android|webOS|BlackBerry|Opera Mini|Opera Mobi|IEMobile/i.test(navigator.userAgent),xo=bo||/Mac/.test(navigator.platform),Co=/win/i.test(navigator.platform),So=go&&navigator.userAgent.match(/Version\/(\d*\.\d*)/);So&&(So=Number(So[1])),So&&So>=15&&(go=!1,fo=!0);var Lo=xo&&(ho||go&&(null==So||12.11>So)),ko=lo||uo&&co>=9,To=!1,Mo=!1;g.prototype=Wi({update:function(e){var t=e.scrollWidth>e.clientWidth+1,r=e.scrollHeight>e.clientHeight+1,n=e.nativeBarWidth;if(r){this.vert.style.display="block",this.vert.style.bottom=t?n+"px":"0";var i=e.viewHeight-(t?n:0);this.vert.firstChild.style.height=Math.max(0,e.scrollHeight-e.clientHeight+i)+"px"}else this.vert.style.display="",this.vert.firstChild.style.height="0";if(t){this.horiz.style.display="block",this.horiz.style.right=r?n+"px":"0",this.horiz.style.left=e.barLeft+"px";var o=e.viewWidth-e.barLeft-(r?n:0);this.horiz.firstChild.style.width=e.scrollWidth-e.clientWidth+o+"px"}else this.horiz.style.display="",this.horiz.firstChild.style.width="0";return!this.checkedOverlay&&e.clientHeight>0&&(0==n&&this.overlayHack(),this.checkedOverlay=!0),{right:r?n:0,bottom:t?n:0}},setScrollLeft:function(e){this.horiz.scrollLeft!=e&&(this.horiz.scrollLeft=e)},setScrollTop:function(e){this.vert.scrollTop!=e&&(this.vert.scrollTop=e)},overlayHack:function(){var e=xo&&!mo?"12px":"18px";this.horiz.style.minHeight=this.vert.style.minWidth=e;var t=this,r=function(e){pi(e)!=t.vert&&pi(e)!=t.horiz&&Mt(t.cm,Vt)(e)};wl(this.vert,"mousedown",r),wl(this.horiz,"mousedown",r)},clear:function(){var e=this.horiz.parentNode;e.removeChild(this.horiz),e.removeChild(this.vert)}},g.prototype),v.prototype=Wi({update:function(){return{bottom:0,right:0}},setScrollLeft:function(){},setScrollTop:function(){},clear:function(){}},v.prototype),e.scrollbarModel={"native":g,"null":v},k.prototype.signal=function(e,t){wi(e,t)&&this.events.push(arguments)},k.prototype.finish=function(){for(var e=0;e<this.events.length;e++)Cl.apply(null,this.events[e])};var No=e.Pos=function(e,t){return this instanceof No?(this.line=e,void(this.ch=t)):new No(e,t)},Ao=e.cmpPos=function(e,t){return e.line-t.line||e.ch-t.ch},Wo=null;te.prototype=Wi({init:function(e){function t(e){if(n.somethingSelected())Wo=n.getSelections(),r.inaccurateSelection&&(r.prevInput="",r.inaccurateSelection=!1,o.value=Wo.join("\n"),Ol(o));else{var t=J(n);Wo=t.text,"cut"==e.type?n.setSelections(t.ranges,null,Tl):(r.prevInput="",o.value=t.text.join("\n"),Ol(o))}"cut"==e.type&&(n.state.cutIncoming=!0)}var r=this,n=this.cm,i=this.wrapper=re(),o=this.textarea=i.firstChild;e.wrapper.insertBefore(i,e.wrapper.firstChild),bo&&(o.style.width="0px"),wl(o,"input",function(){uo&&co>=9&&r.hasSelection&&(r.hasSelection=null),r.poll()}),wl(o,"paste",function(){if(fo&&!n.state.fakedLastChar&&!(new Date-n.state.lastMiddleDown<200)){var e=o.selectionStart,t=o.selectionEnd;o.value+="$",o.selectionEnd=t,o.selectionStart=e,n.state.fakedLastChar=!0}n.state.pasteIncoming=!0,r.fastPoll()}),wl(o,"cut",t),wl(o,"copy",t),wl(e.scroller,"paste",function(t){Gt(e,t)||(n.state.pasteIncoming=!0,r.focus())}),wl(e.lineSpace,"selectstart",function(t){Gt(e,t)||ml(t)})},prepareSelection:function(){var e=this.cm,t=e.display,r=e.doc,n=De(e);if(e.options.moveInputWithCursor){var i=ct(e,r.sel.primary().head,"div"),o=t.wrapper.getBoundingClientRect(),l=t.lineDiv.getBoundingClientRect();n.teTop=Math.max(0,Math.min(t.wrapper.clientHeight-10,i.top+l.top-o.top)),n.teLeft=Math.max(0,Math.min(t.wrapper.clientWidth-10,i.left+l.left-o.left))}return n},showSelection:function(e){var t=this.cm,r=t.display;Ei(r.cursorDiv,e.cursors),Ei(r.selectionDiv,e.selection),null!=e.teTop&&(this.wrapper.style.top=e.teTop+"px",this.wrapper.style.left=e.teLeft+"px")},reset:function(e){if(!this.contextMenuPending){var t,r,n=this.cm,i=n.doc;if(n.somethingSelected()){this.prevInput="";var o=i.sel.primary();t=jl&&(o.to().line-o.from().line>100||(r=n.getSelection()).length>1e3);var l=t?"-":r||n.getSelection();this.textarea.value=l,n.state.focused&&Ol(this.textarea),uo&&co>=9&&(this.hasSelection=l)}else e||(this.prevInput=this.textarea.value="",uo&&co>=9&&(this.hasSelection=null));this.inaccurateSelection=t}},getField:function(){return this.textarea},supportsTouch:function(){return!1},focus:function(){if("nocursor"!=this.cm.options.readOnly&&(!wo||Fi()!=this.textarea))try{this.textarea.focus()}catch(e){}},blur:function(){this.textarea.blur()},resetPosition:function(){this.wrapper.style.top=this.wrapper.style.left=0},receivedFocus:function(){this.slowPoll()},slowPoll:function(){var e=this;e.pollingFast||e.polling.set(this.cm.options.pollInterval,function(){e.poll(),e.cm.state.focused&&e.slowPoll()})},fastPoll:function(){function e(){var n=r.poll();n||t?(r.pollingFast=!1,r.slowPoll()):(t=!0,r.polling.set(60,e))}var t=!1,r=this;r.pollingFast=!0,r.polling.set(20,e)},poll:function(){var e=this.cm,t=this.textarea,r=this.prevInput;if(!e.state.focused||Kl(t)&&!r||Z(e)||e.options.disableInput||e.state.keySeq)return!1;e.state.pasteIncoming&&e.state.fakedLastChar&&(t.value=t.value.substring(0,t.value.length-1),e.state.fakedLastChar=!1);var n=t.value;if(n==r&&!e.somethingSelected())return!1;if(uo&&co>=9&&this.hasSelection===n||xo&&/[\uf700-\uf7ff]/.test(n))return e.display.input.reset(),!1;8203!=n.charCodeAt(0)||e.doc.sel!=e.display.selForContextMenu||r||(r="​");for(var i=0,o=Math.min(r.length,n.length);o>i&&r.charCodeAt(i)==n.charCodeAt(i);)++i;var l=this;
4
- return Tt(e,function(){Q(e,n.slice(i),r.length-i),n.length>1e3||n.indexOf("\n")>-1?t.value=l.prevInput="":l.prevInput=n}),!0},ensurePolled:function(){this.pollingFast&&this.poll()&&(this.pollingFast=!1)},onKeyPress:function(){uo&&co>=9&&(this.hasSelection=null),this.fastPoll()},onContextMenu:function(e){function t(){if(null!=l.selectionStart){var e=i.somethingSelected(),t=l.value="​"+(e?l.value:"");n.prevInput=e?"":"​",l.selectionStart=1,l.selectionEnd=t.length,o.selForContextMenu=i.doc.sel}}function r(){if(n.contextMenuPending=!1,n.wrapper.style.position="relative",l.style.cssText=c,uo&&9>co&&o.scrollbars.setScrollTop(o.scroller.scrollTop=a),null!=l.selectionStart){(!uo||uo&&9>co)&&t();var e=0,r=function(){o.selForContextMenu==i.doc.sel&&0==l.selectionStart?Mt(i,el.selectAll)(i):e++<10?o.detectingSelectAll=setTimeout(r,500):o.input.reset()};o.detectingSelectAll=setTimeout(r,200)}}var n=this,i=n.cm,o=i.display,l=n.textarea,s=Ut(i,e),a=o.scroller.scrollTop;if(s&&!go){var u=i.options.resetSelectionOnContextMenu;u&&-1==i.doc.sel.contains(s)&&Mt(i,ke)(i.doc,he(s),Tl);var c=l.style.cssText;if(n.wrapper.style.position="absolute",l.style.cssText="position: fixed; width: 30px; height: 30px; top: "+(e.clientY-5)+"px; left: "+(e.clientX-5)+"px; z-index: 1000; background: "+(uo?"rgba(255, 255, 255, .05)":"transparent")+"; outline: none; border-width: 0; outline: none; overflow: hidden; opacity: .05; filter: alpha(opacity=5);",fo)var f=window.scrollY;if(o.input.focus(),fo&&window.scrollTo(null,f),o.input.reset(),i.somethingSelected()||(l.value=n.prevInput=" "),n.contextMenuPending=!0,o.selForContextMenu=i.doc.sel,clearTimeout(o.detectingSelectAll),uo&&co>=9&&t(),ko){bl(e);var h=function(){xl(window,"mouseup",h),setTimeout(r,20)};wl(window,"mouseup",h)}else setTimeout(r,50)}},setUneditable:Ni,needsContentAttribute:!1},te.prototype),ne.prototype=Wi({init:function(e){function t(e){if(n.somethingSelected())Wo=n.getSelections(),"cut"==e.type&&n.replaceSelection("",null,"cut");else{var t=J(n);Wo=t.text,"cut"==e.type&&n.operation(function(){n.setSelections(t.ranges,0,Tl),n.replaceSelection("",null,"cut")})}if(e.clipboardData&&!bo)e.preventDefault(),e.clipboardData.clearData(),e.clipboardData.setData("text/plain",Wo.join("\n"));else{var r=re(),i=r.firstChild;n.display.lineSpace.insertBefore(r,n.display.lineSpace.firstChild),i.value=Wo.join("\n");var o=document.activeElement;Ol(i),setTimeout(function(){n.display.lineSpace.removeChild(r),o.focus()},50)}}var r=this,n=r.cm,i=r.div=e.lineDiv;i.contentEditable="true",ee(i),wl(i,"paste",function(e){var t=e.clipboardData&&e.clipboardData.getData("text/plain");t&&(e.preventDefault(),n.replaceSelection(t,null,"paste"))}),wl(i,"compositionstart",function(e){var t=e.data;if(r.composing={sel:n.doc.sel,data:t,startData:t},t){var i=n.doc.sel.primary(),o=n.getLine(i.head.line),l=o.indexOf(t,Math.max(0,i.head.ch-t.length));l>-1&&l<=i.head.ch&&(r.composing.sel=he(No(i.head.line,l),No(i.head.line,l+t.length)))}}),wl(i,"compositionupdate",function(e){r.composing.data=e.data}),wl(i,"compositionend",function(e){var t=r.composing;t&&(e.data==t.startData||/\u200b/.test(e.data)||(t.data=e.data),setTimeout(function(){t.handled||r.applyComposition(t),r.composing==t&&(r.composing=null)},50))}),wl(i,"touchstart",function(){r.forceCompositionEnd()}),wl(i,"input",function(){r.composing||r.pollContent()||Tt(r.cm,function(){Dt(n)})}),wl(i,"copy",t),wl(i,"cut",t)},prepareSelection:function(){var e=De(this.cm,!1);return e.focus=this.cm.state.focused,e},showSelection:function(e){e&&this.cm.display.view.length&&(e.focus&&this.showPrimarySelection(),this.showMultipleSelections(e))},showPrimarySelection:function(){var e=window.getSelection(),t=this.cm.doc.sel.primary(),r=le(this.cm,e.anchorNode,e.anchorOffset),n=le(this.cm,e.focusNode,e.focusOffset);if(!r||r.bad||!n||n.bad||0!=Ao($(r,n),t.from())||0!=Ao(Y(r,n),t.to())){var i=ie(this.cm,t.from()),o=ie(this.cm,t.to());if(i||o){var l=this.cm.display.view,s=e.rangeCount&&e.getRangeAt(0);if(i){if(!o){var a=l[l.length-1].measure,u=a.maps?a.maps[a.maps.length-1]:a.map;o={node:u[u.length-1],offset:u[u.length-2]-u[u.length-3]}}}else i={node:l[0].measure.map[2],offset:0};try{var c=Dl(i.node,i.offset,o.offset,o.node)}catch(f){}c&&(e.removeAllRanges(),e.addRange(c),s&&null==e.anchorNode&&e.addRange(s)),this.rememberSelection()}}},showMultipleSelections:function(e){Ei(this.cm.display.cursorDiv,e.cursors),Ei(this.cm.display.selectionDiv,e.selection)},rememberSelection:function(){var e=window.getSelection();this.lastAnchorNode=e.anchorNode,this.lastAnchorOffset=e.anchorOffset,this.lastFocusNode=e.focusNode,this.lastFocusOffset=e.focusOffset},selectionInEditor:function(){var e=window.getSelection();if(!e.rangeCount)return!1;var t=e.getRangeAt(0).commonAncestorContainer;return zl(this.div,t)},focus:function(){"nocursor"!=this.cm.options.readOnly&&this.div.focus()},blur:function(){this.div.blur()},getField:function(){return this.div},supportsTouch:function(){return!0},receivedFocus:function(){function e(){t.cm.state.focused&&(t.pollSelection(),t.polling.set(t.cm.options.pollInterval,e))}var t=this;this.selectionInEditor()?this.pollSelection():Tt(this.cm,function(){t.cm.curOp.selectionChanged=!0}),this.polling.set(this.cm.options.pollInterval,e)},pollSelection:function(){if(!this.composing){var e=window.getSelection(),t=this.cm;if(e.anchorNode!=this.lastAnchorNode||e.anchorOffset!=this.lastAnchorOffset||e.focusNode!=this.lastFocusNode||e.focusOffset!=this.lastFocusOffset){this.rememberSelection();var r=le(t,e.anchorNode,e.anchorOffset),n=le(t,e.focusNode,e.focusOffset);r&&n&&Tt(t,function(){ke(t.doc,he(r,n),Tl),(r.bad||n.bad)&&(t.curOp.selectionChanged=!0)})}}},pollContent:function(){var e=this.cm,t=e.display,r=e.doc.sel.primary(),n=r.from(),i=r.to();if(n.line<t.viewFrom||i.line>t.viewTo-1)return!1;var o;if(n.line==t.viewFrom||0==(o=Pt(e,n.line)))var l=Yn(t.view[0].line),s=t.view[0].node;else var l=Yn(t.view[o].line),s=t.view[o-1].node.nextSibling;var a=Pt(e,i.line);if(a==t.view.length-1)var u=t.viewTo-1,c=t.view[a].node;else var u=Yn(t.view[a+1].line)-1,c=t.view[a+1].node.previousSibling;for(var f=Vl(ae(e,s,c,l,u)),h=jn(e.doc,No(l,0),No(u,Kn(e.doc,u).text.length));f.length>1&&h.length>1;)if(ki(f)==ki(h))f.pop(),h.pop(),u--;else{if(f[0]!=h[0])break;f.shift(),h.shift(),l++}for(var d=0,p=0,g=f[0],v=h[0],m=Math.min(g.length,v.length);m>d&&g.charCodeAt(d)==v.charCodeAt(d);)++d;for(var y=ki(f),b=ki(h),w=Math.min(y.length-(1==f.length?d:0),b.length-(1==h.length?d:0));w>p&&y.charCodeAt(y.length-p-1)==b.charCodeAt(b.length-p-1);)++p;f[f.length-1]=y.slice(0,y.length-p),f[0]=f[0].slice(d);var x=No(l,d),C=No(u,h.length?ki(h).length-p:0);return f.length>1||f[0]||Ao(x,C)?(Lr(e.doc,f,x,C,"+input"),!0):void 0},ensurePolled:function(){this.forceCompositionEnd()},reset:function(){this.forceCompositionEnd()},forceCompositionEnd:function(){this.composing&&!this.composing.handled&&(this.applyComposition(this.composing),this.composing.handled=!0,this.div.blur(),this.div.focus())},applyComposition:function(e){e.data&&e.data!=e.startData&&Mt(this.cm,Q)(this.cm,e.data,0,e.sel)},setUneditable:function(e){e.setAttribute("contenteditable","false")},onKeyPress:function(e){e.preventDefault(),Mt(this.cm,Q)(this.cm,String.fromCharCode(null==e.charCode?e.keyCode:e.charCode),0)},onContextMenu:Ni,resetPosition:Ni,needsContentAttribute:!0},ne.prototype),e.inputStyles={textarea:te,contenteditable:ne},ue.prototype={primary:function(){return this.ranges[this.primIndex]},equals:function(e){if(e==this)return!0;if(e.primIndex!=this.primIndex||e.ranges.length!=this.ranges.length)return!1;for(var t=0;t<this.ranges.length;t++){var r=this.ranges[t],n=e.ranges[t];if(0!=Ao(r.anchor,n.anchor)||0!=Ao(r.head,n.head))return!1}return!0},deepCopy:function(){for(var e=[],t=0;t<this.ranges.length;t++)e[t]=new ce(_(this.ranges[t].anchor),_(this.ranges[t].head));return new ue(e,this.primIndex)},somethingSelected:function(){for(var e=0;e<this.ranges.length;e++)if(!this.ranges[e].empty())return!0;return!1},contains:function(e,t){t||(t=e);for(var r=0;r<this.ranges.length;r++){var n=this.ranges[r];if(Ao(t,n.from())>=0&&Ao(e,n.to())<=0)return r}return-1}},ce.prototype={from:function(){return $(this.anchor,this.head)},to:function(){return Y(this.anchor,this.head)},empty:function(){return this.head.line==this.anchor.line&&this.head.ch==this.anchor.ch}};var Oo,Do,Ho,Io={left:0,right:0,top:0,bottom:0},Po=null,zo=0,Eo=0,Fo=0,Ro=null;uo?Ro=-.53:lo?Ro=15:po?Ro=-.7:vo&&(Ro=-1/3);var Bo=function(e){var t=e.wheelDeltaX,r=e.wheelDeltaY;return null==t&&e.detail&&e.axis==e.HORIZONTAL_AXIS&&(t=e.detail),null==r&&e.detail&&e.axis==e.VERTICAL_AXIS?r=e.detail:null==r&&(r=e.wheelDelta),{x:t,y:r}};e.wheelEventPixels=function(e){var t=Bo(e);return t.x*=Ro,t.y*=Ro,t};var Go=new Ci,Uo=null,Vo=e.changeEnd=function(e){return e.text?No(e.from.line+e.text.length-1,ki(e.text).length+(1==e.text.length?e.from.ch:0)):e.to};e.prototype={constructor:e,focus:function(){window.focus(),this.display.input.focus()},setOption:function(e,t){var r=this.options,n=r[e];(r[e]!=t||"mode"==e)&&(r[e]=t,jo.hasOwnProperty(e)&&Mt(this,jo[e])(this,t,n))},getOption:function(e){return this.options[e]},getDoc:function(){return this.doc},addKeyMap:function(e,t){this.state.keyMaps[t?"push":"unshift"](Rr(e))},removeKeyMap:function(e){for(var t=this.state.keyMaps,r=0;r<t.length;++r)if(t[r]==e||t[r].name==e)return t.splice(r,1),!0},addOverlay:Nt(function(t,r){var n=t.token?t:e.getMode(this.options,t);if(n.startState)throw new Error("Overlays may not be stateful.");this.state.overlays.push({mode:n,modeSpec:t,opaque:r&&r.opaque}),this.state.modeGen++,Dt(this)}),removeOverlay:Nt(function(e){for(var t=this.state.overlays,r=0;r<t.length;++r){var n=t[r].modeSpec;if(n==e||"string"==typeof e&&n.name==e)return t.splice(r,1),this.state.modeGen++,void Dt(this)}}),indentLine:Nt(function(e,t,r){"string"!=typeof t&&"number"!=typeof t&&(t=null==t?this.options.smartIndent?"smart":"prev":t?"add":"subtract"),ve(this.doc,e)&&Dr(this,e,t,r)}),indentSelection:Nt(function(e){for(var t=this.doc.sel.ranges,r=-1,n=0;n<t.length;n++){var i=t[n];if(i.empty())i.head.line>r&&(Dr(this,i.head.line,e,!0),r=i.head.line,n==this.doc.sel.primIndex&&Wr(this));else{var o=i.from(),l=i.to(),s=Math.max(r,o.line);r=Math.min(this.lastLine(),l.line-(l.ch?0:1))+1;for(var a=s;r>a;++a)Dr(this,a,e);var u=this.doc.sel.ranges;0==o.ch&&t.length==u.length&&u[n].from().ch>0&&xe(this.doc,n,new ce(o,u[n].to()),Tl)}}}),getTokenAt:function(e,t){return kn(this,e,t)},getLineTokens:function(e,t){return kn(this,No(e),t,!0)},getTokenTypeAt:function(e){e=pe(this.doc,e);var t,r=Nn(this,Kn(this.doc,e.line)),n=0,i=(r.length-1)/2,o=e.ch;if(0==o)t=r[2];else for(;;){var l=n+i>>1;if((l?r[2*l-1]:0)>=o)i=l;else{if(!(r[2*l+1]<o)){t=r[2*l+2];break}n=l+1}}var s=t?t.indexOf("cm-overlay "):-1;return 0>s?t:0==s?null:t.slice(0,s-1)},getModeAt:function(t){var r=this.doc.mode;return r.innerMode?e.innerMode(r,this.getTokenAt(t).state).mode:r},getHelper:function(e,t){return this.getHelpers(e,t)[0]},getHelpers:function(e,t){var r=[];if(!Zo.hasOwnProperty(t))return Zo;var n=Zo[t],i=this.getModeAt(e);if("string"==typeof i[t])n[i[t]]&&r.push(n[i[t]]);else if(i[t])for(var o=0;o<i[t].length;o++){var l=n[i[t][o]];l&&r.push(l)}else i.helperType&&n[i.helperType]?r.push(n[i.helperType]):n[i.name]&&r.push(n[i.name]);for(var o=0;o<n._global.length;o++){var s=n._global[o];s.pred(i,this)&&-1==Ti(r,s.val)&&r.push(s.val)}return r},getStateAfter:function(e,t){var r=this.doc;return e=de(r,null==e?r.first+r.size-1:e),Re(this,e+1,t)},cursorCoords:function(e,t){var r,n=this.doc.sel.primary();return r=null==e?n.head:"object"==typeof e?pe(this.doc,e):e?n.from():n.to(),ct(this,r,t||"page")},charCoords:function(e,t){return ut(this,pe(this.doc,e),t||"page")},coordsChar:function(e,t){return e=at(this,e,t||"page"),dt(this,e.left,e.top)},lineAtHeight:function(e,t){return e=at(this,{top:e,left:0},t||"page").top,$n(this.doc,e+this.display.viewOffset)},heightAtLine:function(e,t){var r=!1,n=this.doc.first+this.doc.size-1;e<this.doc.first?e=this.doc.first:e>n&&(e=n,r=!0);var i=Kn(this.doc,e);return st(this,i,{top:0,left:0},t||"page").top+(r?this.doc.height-qn(i):0)},defaultTextHeight:function(){return gt(this.display)},defaultCharWidth:function(){return vt(this.display)},setGutterMarker:Nt(function(e,t,r){return Hr(this.doc,e,"gutter",function(e){var n=e.gutterMarkers||(e.gutterMarkers={});return n[t]=r,!r&&Hi(n)&&(e.gutterMarkers=null),!0})}),clearGutter:Nt(function(e){var t=this,r=t.doc,n=r.first;r.iter(function(r){r.gutterMarkers&&r.gutterMarkers[e]&&(r.gutterMarkers[e]=null,Ht(t,n,"gutter"),Hi(r.gutterMarkers)&&(r.gutterMarkers=null)),++n})}),addLineWidget:Nt(function(e,t,r){return bn(this,e,t,r)}),removeLineWidget:function(e){e.clear()},lineInfo:function(e){if("number"==typeof e){if(!ve(this.doc,e))return null;var t=e;if(e=Kn(this.doc,e),!e)return null}else{var t=Yn(e);if(null==t)return null}return{line:t,handle:e,text:e.text,gutterMarkers:e.gutterMarkers,textClass:e.textClass,bgClass:e.bgClass,wrapClass:e.wrapClass,widgets:e.widgets}},getViewport:function(){return{from:this.display.viewFrom,to:this.display.viewTo}},addWidget:function(e,t,r,n,i){var o=this.display;e=ct(this,pe(this.doc,e));var l=e.bottom,s=e.left;if(t.style.position="absolute",t.setAttribute("cm-ignore-events","true"),this.display.input.setUneditable(t),o.sizer.appendChild(t),"over"==n)l=e.top;else if("above"==n||"near"==n){var a=Math.max(o.wrapper.clientHeight,this.doc.height),u=Math.max(o.sizer.clientWidth,o.lineSpace.clientWidth);("above"==n||e.bottom+t.offsetHeight>a)&&e.top>t.offsetHeight?l=e.top-t.offsetHeight:e.bottom+t.offsetHeight<=a&&(l=e.bottom),s+t.offsetWidth>u&&(s=u-t.offsetWidth)}t.style.top=l+"px",t.style.left=t.style.right="","right"==i?(s=o.sizer.clientWidth-t.offsetWidth,t.style.right="0px"):("left"==i?s=0:"middle"==i&&(s=(o.sizer.clientWidth-t.offsetWidth)/2),t.style.left=s+"px"),r&&Mr(this,s,l,s+t.offsetWidth,l+t.offsetHeight)},triggerOnKeyDown:Nt(or),triggerOnKeyPress:Nt(ar),triggerOnKeyUp:sr,execCommand:function(e){return el.hasOwnProperty(e)?el[e](this):void 0},findPosH:function(e,t,r,n){var i=1;0>t&&(i=-1,t=-t);for(var o=0,l=pe(this.doc,e);t>o&&(l=Pr(this.doc,l,i,r,n),!l.hitSide);++o);return l},moveH:Nt(function(e,t){var r=this;r.extendSelectionsBy(function(n){return r.display.shift||r.doc.extend||n.empty()?Pr(r.doc,n.head,e,t,r.options.rtlMoveVisually):0>e?n.from():n.to()},Nl)}),deleteH:Nt(function(e,t){var r=this.doc.sel,n=this.doc;r.somethingSelected()?n.replaceSelection("",null,"+delete"):Ir(this,function(r){var i=Pr(n,r.head,e,t,!1);return 0>e?{from:i,to:r.head}:{from:r.head,to:i}})}),findPosV:function(e,t,r,n){var i=1,o=n;0>t&&(i=-1,t=-t);for(var l=0,s=pe(this.doc,e);t>l;++l){var a=ct(this,s,"div");if(null==o?o=a.left:a.left=o,s=zr(this,a,i,r),s.hitSide)break}return s},moveV:Nt(function(e,t){var r=this,n=this.doc,i=[],o=!r.display.shift&&!n.extend&&n.sel.somethingSelected();if(n.extendSelectionsBy(function(l){if(o)return 0>e?l.from():l.to();var s=ct(r,l.head,"div");null!=l.goalColumn&&(s.left=l.goalColumn),i.push(s.left);var a=zr(r,s,e,t);return"page"==t&&l==n.sel.primary()&&Ar(r,null,ut(r,a,"div").top-s.top),a},Nl),i.length)for(var l=0;l<n.sel.ranges.length;l++)n.sel.ranges[l].goalColumn=i[l]}),findWordAt:function(e){var t=this.doc,r=Kn(t,e.line).text,n=e.ch,i=e.ch;if(r){var o=this.getHelper(e,"wordChars");(e.xRel<0||i==r.length)&&n?--n:++i;for(var l=r.charAt(n),s=Di(l,o)?function(e){return Di(e,o)}:/\s/.test(l)?function(e){return/\s/.test(e)}:function(e){return!/\s/.test(e)&&!Di(e)};n>0&&s(r.charAt(n-1));)--n;for(;i<r.length&&s(r.charAt(i));)++i}return new ce(No(e.line,n),No(e.line,i))},toggleOverwrite:function(e){(null==e||e!=this.state.overwrite)&&((this.state.overwrite=!this.state.overwrite)?Bl(this.display.cursorDiv,"CodeMirror-overwrite"):Rl(this.display.cursorDiv,"CodeMirror-overwrite"),Cl(this,"overwriteToggle",this,this.state.overwrite))},hasFocus:function(){return this.display.input.getField()==Fi()},scrollTo:Nt(function(e,t){(null!=e||null!=t)&&Or(this),null!=e&&(this.curOp.scrollLeft=e),null!=t&&(this.curOp.scrollTop=t)}),getScrollInfo:function(){var e=this.display.scroller;return{left:e.scrollLeft,top:e.scrollTop,height:e.scrollHeight-Ve(this)-this.display.barHeight,width:e.scrollWidth-Ve(this)-this.display.barWidth,clientHeight:je(this),clientWidth:Ke(this)}},scrollIntoView:Nt(function(e,t){if(null==e?(e={from:this.doc.sel.primary().head,to:null},null==t&&(t=this.options.cursorScrollMargin)):"number"==typeof e?e={from:No(e,0),to:null}:null==e.from&&(e={from:e,to:null}),e.to||(e.to=e.from),e.margin=t||0,null!=e.from.line)Or(this),this.curOp.scrollToPos=e;else{var r=Nr(this,Math.min(e.from.left,e.to.left),Math.min(e.from.top,e.to.top)-e.margin,Math.max(e.from.right,e.to.right),Math.max(e.from.bottom,e.to.bottom)+e.margin);this.scrollTo(r.scrollLeft,r.scrollTop)}}),setSize:Nt(function(e,t){function r(e){return"number"==typeof e||/^\d+$/.test(String(e))?e+"px":e}var n=this;null!=e&&(n.display.wrapper.style.width=r(e)),null!=t&&(n.display.wrapper.style.height=r(t)),n.options.lineWrapping&&nt(this);var i=n.display.viewFrom;n.doc.iter(i,n.display.viewTo,function(e){if(e.widgets)for(var t=0;t<e.widgets.length;t++)if(e.widgets[t].noHScroll){Ht(n,i,"widget");break}++i}),n.curOp.forceUpdate=!0,Cl(n,"refresh",this)}),operation:function(e){return Tt(this,e)},refresh:Nt(function(){var e=this.display.cachedTextHeight;Dt(this),this.curOp.forceUpdate=!0,it(this),this.scrollTo(this.doc.scrollLeft,this.doc.scrollTop),c(this),(null==e||Math.abs(e-gt(this.display))>.5)&&l(this),Cl(this,"refresh",this)}),swapDoc:Nt(function(e){var t=this.doc;return t.cm=null,Vn(this,e),it(this),this.display.input.reset(),this.scrollTo(e.scrollLeft,e.scrollTop),this.curOp.forceScroll=!0,vi(this,"swapDoc",this,t),t}),getInputField:function(){return this.display.input.getField()},getWrapperElement:function(){return this.display.wrapper},getScrollerElement:function(){return this.display.scroller},getGutterElement:function(){return this.display.gutters}},xi(e);var Ko=e.defaults={},jo=e.optionHandlers={},Xo=e.Init={toString:function(){return"CodeMirror.Init"}};Er("value","",function(e,t){e.setValue(t)},!0),Er("mode",null,function(e,t){e.doc.modeOption=t,r(e)},!0),Er("indentUnit",2,r,!0),Er("indentWithTabs",!1),Er("smartIndent",!0),Er("tabSize",4,function(e){n(e),it(e),Dt(e)},!0),Er("specialChars",/[\t\u0000-\u0019\u00ad\u200b-\u200f\u2028\u2029\ufeff]/g,function(e,t){e.options.specialChars=new RegExp(t.source+(t.test(" ")?"":"| "),"g"),e.refresh()},!0),Er("specialCharPlaceholder",Dn,function(e){e.refresh()},!0),Er("electricChars",!0),Er("inputStyle",wo?"contenteditable":"textarea",function(){throw new Error("inputStyle can not (yet) be changed in a running editor")},!0),Er("rtlMoveVisually",!Co),Er("wholeLineUpdateBefore",!0),Er("theme","default",function(e){s(e),a(e)},!0),Er("keyMap","default",function(t,r,n){var i=Rr(r),o=n!=e.Init&&Rr(n);o&&o.detach&&o.detach(t,i),i.attach&&i.attach(t,o||null)}),Er("extraKeys",null),Er("lineWrapping",!1,i,!0),Er("gutters",[],function(e){d(e.options),a(e)},!0),Er("fixedGutter",!0,function(e,t){e.display.gutters.style.left=t?L(e.display)+"px":"0",e.refresh()},!0),Er("coverGutterNextToScrollbar",!1,function(e){y(e)},!0),Er("scrollbarStyle","native",function(e){m(e),y(e),e.display.scrollbars.setScrollTop(e.doc.scrollTop),e.display.scrollbars.setScrollLeft(e.doc.scrollLeft)},!0),Er("lineNumbers",!1,function(e){d(e.options),a(e)},!0),Er("firstLineNumber",1,a,!0),Er("lineNumberFormatter",function(e){return e},a,!0),Er("showCursorWhenSelecting",!1,Oe,!0),Er("resetSelectionOnContextMenu",!0),Er("readOnly",!1,function(e,t){"nocursor"==t?(cr(e),e.display.input.blur(),e.display.disabled=!0):(e.display.disabled=!1,t||e.display.input.reset())}),Er("disableInput",!1,function(e,t){t||e.display.input.reset()},!0),Er("dragDrop",!0),Er("cursorBlinkRate",530),Er("cursorScrollMargin",0),Er("cursorHeight",1,Oe,!0),Er("singleCursorHeightPerLine",!0,Oe,!0),Er("workTime",100),Er("workDelay",100),Er("flattenSpans",!0,n,!0),Er("addModeClass",!1,n,!0),Er("pollInterval",100),Er("undoDepth",200,function(e,t){e.doc.history.undoDepth=t}),Er("historyEventDelay",1250),Er("viewportMargin",10,function(e){e.refresh()},!0),Er("maxHighlightLength",1e4,n,!0),Er("moveInputWithCursor",!0,function(e,t){t||e.display.input.resetPosition()}),Er("tabindex",null,function(e,t){e.display.input.getField().tabIndex=t||""}),Er("autofocus",null);var _o=e.modes={},Yo=e.mimeModes={};e.defineMode=function(t,r){e.defaults.mode||"null"==t||(e.defaults.mode=t),arguments.length>2&&(r.dependencies=Array.prototype.slice.call(arguments,2)),_o[t]=r},e.defineMIME=function(e,t){Yo[e]=t},e.resolveMode=function(t){if("string"==typeof t&&Yo.hasOwnProperty(t))t=Yo[t];else if(t&&"string"==typeof t.name&&Yo.hasOwnProperty(t.name)){var r=Yo[t.name];"string"==typeof r&&(r={name:r}),t=Ai(r,t),t.name=r.name}else if("string"==typeof t&&/^[\w\-]+\/[\w\-]+\+xml$/.test(t))return e.resolveMode("application/xml");return"string"==typeof t?{name:t}:t||{name:"null"}},e.getMode=function(t,r){var r=e.resolveMode(r),n=_o[r.name];if(!n)return e.getMode(t,"text/plain");var i=n(t,r);if($o.hasOwnProperty(r.name)){var o=$o[r.name];for(var l in o)o.hasOwnProperty(l)&&(i.hasOwnProperty(l)&&(i["_"+l]=i[l]),i[l]=o[l])}if(i.name=r.name,r.helperType&&(i.helperType=r.helperType),r.modeProps)for(var l in r.modeProps)i[l]=r.modeProps[l];return i},e.defineMode("null",function(){return{token:function(e){e.skipToEnd()}}}),e.defineMIME("text/plain","null");var $o=e.modeExtensions={};e.extendMode=function(e,t){var r=$o.hasOwnProperty(e)?$o[e]:$o[e]={};Wi(t,r)},e.defineExtension=function(t,r){e.prototype[t]=r},e.defineDocExtension=function(e,t){pl.prototype[e]=t},e.defineOption=Er;var qo=[];e.defineInitHook=function(e){qo.push(e)};var Zo=e.helpers={};e.registerHelper=function(t,r,n){Zo.hasOwnProperty(t)||(Zo[t]=e[t]={_global:[]}),Zo[t][r]=n},e.registerGlobalHelper=function(t,r,n,i){e.registerHelper(t,r,i),Zo[t]._global.push({pred:n,val:i})};var Qo=e.copyState=function(e,t){if(t===!0)return t;if(e.copyState)return e.copyState(t);var r={};for(var n in t){var i=t[n];i instanceof Array&&(i=i.concat([])),r[n]=i}return r},Jo=e.startState=function(e,t,r){return e.startState?e.startState(t,r):!0};e.innerMode=function(e,t){for(;e.innerMode;){var r=e.innerMode(t);if(!r||r.mode==e)break;t=r.state,e=r.mode}return r||{mode:e,state:t}};var el=e.commands={selectAll:function(e){e.setSelection(No(e.firstLine(),0),No(e.lastLine()),Tl)},singleSelection:function(e){e.setSelection(e.getCursor("anchor"),e.getCursor("head"),Tl)},killLine:function(e){Ir(e,function(t){if(t.empty()){var r=Kn(e.doc,t.head.line).text.length;return t.head.ch==r&&t.head.line<e.lastLine()?{from:t.head,to:No(t.head.line+1,0)}:{from:t.head,to:No(t.head.line,r)}}return{from:t.from(),to:t.to()}})},deleteLine:function(e){Ir(e,function(t){return{from:No(t.from().line,0),to:pe(e.doc,No(t.to().line+1,0))}})},delLineLeft:function(e){Ir(e,function(e){return{from:No(e.from().line,0),to:e.from()}})},delWrappedLineLeft:function(e){Ir(e,function(t){var r=e.charCoords(t.head,"div").top+5,n=e.coordsChar({left:0,top:r},"div");return{from:n,to:t.from()}})},delWrappedLineRight:function(e){Ir(e,function(t){var r=e.charCoords(t.head,"div").top+5,n=e.coordsChar({left:e.display.lineDiv.offsetWidth+100,top:r},"div");return{from:t.from(),to:n}})},undo:function(e){e.undo()},redo:function(e){e.redo()},undoSelection:function(e){e.undoSelection()},redoSelection:function(e){e.redoSelection()},goDocStart:function(e){e.extendSelection(No(e.firstLine(),0))},goDocEnd:function(e){e.extendSelection(No(e.lastLine()))},goLineStart:function(e){e.extendSelectionsBy(function(t){return Qi(e,t.head.line)},{origin:"+move",bias:1})},goLineStartSmart:function(e){e.extendSelectionsBy(function(t){return eo(e,t.head)},{origin:"+move",bias:1})},goLineEnd:function(e){e.extendSelectionsBy(function(t){return Ji(e,t.head.line)},{origin:"+move",bias:-1})},goLineRight:function(e){e.extendSelectionsBy(function(t){var r=e.charCoords(t.head,"div").top+5;return e.coordsChar({left:e.display.lineDiv.offsetWidth+100,top:r},"div")},Nl)},goLineLeft:function(e){e.extendSelectionsBy(function(t){var r=e.charCoords(t.head,"div").top+5;return e.coordsChar({left:0,top:r},"div")},Nl)},goLineLeftSmart:function(e){e.extendSelectionsBy(function(t){var r=e.charCoords(t.head,"div").top+5,n=e.coordsChar({left:0,top:r},"div");return n.ch<e.getLine(n.line).search(/\S/)?eo(e,t.head):n},Nl)},goLineUp:function(e){e.moveV(-1,"line")},goLineDown:function(e){e.moveV(1,"line")},goPageUp:function(e){e.moveV(-1,"page")},goPageDown:function(e){e.moveV(1,"page")},goCharLeft:function(e){e.moveH(-1,"char")},goCharRight:function(e){e.moveH(1,"char")},goColumnLeft:function(e){e.moveH(-1,"column")},goColumnRight:function(e){e.moveH(1,"column")},goWordLeft:function(e){e.moveH(-1,"word")},goGroupRight:function(e){e.moveH(1,"group")},goGroupLeft:function(e){e.moveH(-1,"group")},goWordRight:function(e){e.moveH(1,"word")},delCharBefore:function(e){e.deleteH(-1,"char")},delCharAfter:function(e){e.deleteH(1,"char")},delWordBefore:function(e){e.deleteH(-1,"word")},delWordAfter:function(e){e.deleteH(1,"word")},delGroupBefore:function(e){e.deleteH(-1,"group")},delGroupAfter:function(e){e.deleteH(1,"group")},indentAuto:function(e){e.indentSelection("smart")},indentMore:function(e){e.indentSelection("add")},indentLess:function(e){e.indentSelection("subtract")},insertTab:function(e){e.replaceSelection(" ")},insertSoftTab:function(e){for(var t=[],r=e.listSelections(),n=e.options.tabSize,i=0;i<r.length;i++){var o=r[i].from(),l=Al(e.getLine(o.line),o.ch,n);t.push(new Array(n-l%n+1).join(" "))}e.replaceSelections(t)},defaultTab:function(e){e.somethingSelected()?e.indentSelection("add"):e.execCommand("insertTab")},transposeChars:function(e){Tt(e,function(){for(var t=e.listSelections(),r=[],n=0;n<t.length;n++){var i=t[n].head,o=Kn(e.doc,i.line).text;if(o)if(i.ch==o.length&&(i=new No(i.line,i.ch-1)),i.ch>0)i=new No(i.line,i.ch+1),e.replaceRange(o.charAt(i.ch-1)+o.charAt(i.ch-2),No(i.line,i.ch-2),i,"+transpose");else if(i.line>e.doc.first){var l=Kn(e.doc,i.line-1).text;l&&e.replaceRange(o.charAt(0)+"\n"+l.charAt(l.length-1),No(i.line-1,l.length-1),No(i.line,1),"+transpose")}r.push(new ce(i,i))}e.setSelections(r)})},newlineAndIndent:function(e){Tt(e,function(){for(var t=e.listSelections().length,r=0;t>r;r++){var n=e.listSelections()[r];e.replaceRange("\n",n.anchor,n.head,"+input"),e.indentLine(n.from().line+1,null,!0),Wr(e)}})},toggleOverwrite:function(e){e.toggleOverwrite()}},tl=e.keyMap={};tl.basic={Left:"goCharLeft",Right:"goCharRight",Up:"goLineUp",Down:"goLineDown",End:"goLineEnd",Home:"goLineStartSmart",PageUp:"goPageUp",PageDown:"goPageDown",Delete:"delCharAfter",Backspace:"delCharBefore","Shift-Backspace":"delCharBefore",Tab:"defaultTab","Shift-Tab":"indentAuto",Enter:"newlineAndIndent",Insert:"toggleOverwrite",Esc:"singleSelection"},tl.pcDefault={"Ctrl-A":"selectAll","Ctrl-D":"deleteLine","Ctrl-Z":"undo","Shift-Ctrl-Z":"redo","Ctrl-Y":"redo","Ctrl-Home":"goDocStart","Ctrl-End":"goDocEnd","Ctrl-Up":"goLineUp","Ctrl-Down":"goLineDown","Ctrl-Left":"goGroupLeft","Ctrl-Right":"goGroupRight","Alt-Left":"goLineStart","Alt-Right":"goLineEnd","Ctrl-Backspace":"delGroupBefore","Ctrl-Delete":"delGroupAfter","Ctrl-S":"save","Ctrl-F":"find","Ctrl-G":"findNext","Shift-Ctrl-G":"findPrev","Shift-Ctrl-F":"replace","Shift-Ctrl-R":"replaceAll","Ctrl-[":"indentLess","Ctrl-]":"indentMore","Ctrl-U":"undoSelection","Shift-Ctrl-U":"redoSelection","Alt-U":"redoSelection",fallthrough:"basic"},tl.emacsy={"Ctrl-F":"goCharRight","Ctrl-B":"goCharLeft","Ctrl-P":"goLineUp","Ctrl-N":"goLineDown","Alt-F":"goWordRight","Alt-B":"goWordLeft","Ctrl-A":"goLineStart","Ctrl-E":"goLineEnd","Ctrl-V":"goPageDown","Shift-Ctrl-V":"goPageUp","Ctrl-D":"delCharAfter","Ctrl-H":"delCharBefore","Alt-D":"delWordAfter","Alt-Backspace":"delWordBefore","Ctrl-K":"killLine","Ctrl-T":"transposeChars"},tl.macDefault={"Cmd-A":"selectAll","Cmd-D":"deleteLine","Cmd-Z":"undo","Shift-Cmd-Z":"redo","Cmd-Y":"redo","Cmd-Home":"goDocStart","Cmd-Up":"goDocStart","Cmd-End":"goDocEnd","Cmd-Down":"goDocEnd","Alt-Left":"goGroupLeft","Alt-Right":"goGroupRight","Cmd-Left":"goLineLeft","Cmd-Right":"goLineRight","Alt-Backspace":"delGroupBefore","Ctrl-Alt-Backspace":"delGroupAfter","Alt-Delete":"delGroupAfter","Cmd-S":"save","Cmd-F":"find","Cmd-G":"findNext","Shift-Cmd-G":"findPrev","Cmd-Alt-F":"replace","Shift-Cmd-Alt-F":"replaceAll","Cmd-[":"indentLess","Cmd-]":"indentMore","Cmd-Backspace":"delWrappedLineLeft","Cmd-Delete":"delWrappedLineRight","Cmd-U":"undoSelection","Shift-Cmd-U":"redoSelection","Ctrl-Up":"goDocStart","Ctrl-Down":"goDocEnd",fallthrough:["basic","emacsy"]},tl["default"]=xo?tl.macDefault:tl.pcDefault,e.normalizeKeyMap=function(e){var t={};for(var r in e)if(e.hasOwnProperty(r)){var n=e[r];if(/^(name|fallthrough|(de|at)tach)$/.test(r))continue;if("..."==n){delete e[r];continue}for(var i=Mi(r.split(" "),Fr),o=0;o<i.length;o++){var l,s;o==i.length-1?(s=r,l=n):(s=i.slice(0,o+1).join(" "),l="...");var a=t[s];if(a){if(a!=l)throw new Error("Inconsistent bindings for "+s)}else t[s]=l}delete e[r]}for(var u in t)e[u]=t[u];return e};var rl=e.lookupKey=function(e,t,r,n){t=Rr(t);var i=t.call?t.call(e,n):t[e];if(i===!1)return"nothing";if("..."===i)return"multi";if(null!=i&&r(i))return"handled";if(t.fallthrough){if("[object Array]"!=Object.prototype.toString.call(t.fallthrough))return rl(e,t.fallthrough,r,n);for(var o=0;o<t.fallthrough.length;o++){var l=rl(e,t.fallthrough[o],r,n);if(l)return l}}},nl=e.isModifierKey=function(e){var t="string"==typeof e?e:_l[e.keyCode];return"Ctrl"==t||"Alt"==t||"Shift"==t||"Mod"==t},il=e.keyName=function(e,t){if(go&&34==e.keyCode&&e["char"])return!1;var r=_l[e.keyCode],n=r;return null==n||e.altGraphKey?!1:(e.altKey&&"Alt"!=r&&(n="Alt-"+n),(Lo?e.metaKey:e.ctrlKey)&&"Ctrl"!=r&&(n="Ctrl-"+n),(Lo?e.ctrlKey:e.metaKey)&&"Cmd"!=r&&(n="Cmd-"+n),!t&&e.shiftKey&&"Shift"!=r&&(n="Shift-"+n),n)};e.fromTextArea=function(t,r){function n(){t.value=u.getValue()}if(r=r?Wi(r):{},r.value=t.value,!r.tabindex&&t.tabIndex&&(r.tabindex=t.tabIndex),!r.placeholder&&t.placeholder&&(r.placeholder=t.placeholder),null==r.autofocus){var i=Fi();r.autofocus=i==t||null!=t.getAttribute("autofocus")&&i==document.body}if(t.form&&(wl(t.form,"submit",n),!r.leaveSubmitMethodAlone)){var o=t.form,l=o.submit;try{var s=o.submit=function(){n(),o.submit=l,o.submit(),o.submit=s}}catch(a){}}r.finishInit=function(e){e.save=n,e.getTextArea=function(){return t},e.toTextArea=function(){e.toTextArea=isNaN,n(),t.parentNode.removeChild(e.getWrapperElement()),t.style.display="",t.form&&(xl(t.form,"submit",n),"function"==typeof t.form.submit&&(t.form.submit=l))}},t.style.display="none";var u=e(function(e){t.parentNode.insertBefore(e,t.nextSibling)},r);return u};var ol=e.StringStream=function(e,t){this.pos=this.start=0,this.string=e,this.tabSize=t||8,this.lastColumnPos=this.lastColumnValue=0,this.lineStart=0};ol.prototype={eol:function(){return this.pos>=this.string.length},sol:function(){return this.pos==this.lineStart},peek:function(){return this.string.charAt(this.pos)||void 0},next:function(){return this.pos<this.string.length?this.string.charAt(this.pos++):void 0},eat:function(e){var t=this.string.charAt(this.pos);if("string"==typeof e)var r=t==e;else var r=t&&(e.test?e.test(t):e(t));return r?(++this.pos,t):void 0},eatWhile:function(e){for(var t=this.pos;this.eat(e););return this.pos>t},eatSpace:function(){for(var e=this.pos;/[\s\u00a0]/.test(this.string.charAt(this.pos));)++this.pos;return this.pos>e},skipToEnd:function(){this.pos=this.string.length},skipTo:function(e){var t=this.string.indexOf(e,this.pos);return t>-1?(this.pos=t,!0):void 0},backUp:function(e){this.pos-=e},column:function(){return this.lastColumnPos<this.start&&(this.lastColumnValue=Al(this.string,this.start,this.tabSize,this.lastColumnPos,this.lastColumnValue),this.lastColumnPos=this.start),
5
  this.lastColumnValue-(this.lineStart?Al(this.string,this.lineStart,this.tabSize):0)},indentation:function(){return Al(this.string,null,this.tabSize)-(this.lineStart?Al(this.string,this.lineStart,this.tabSize):0)},match:function(e,t,r){if("string"!=typeof e){var n=this.string.slice(this.pos).match(e);return n&&n.index>0?null:(n&&t!==!1&&(this.pos+=n[0].length),n)}var i=function(e){return r?e.toLowerCase():e},o=this.string.substr(this.pos,e.length);return i(o)==i(e)?(t!==!1&&(this.pos+=e.length),!0):void 0},current:function(){return this.string.slice(this.start,this.pos)},hideFirstChars:function(e,t){this.lineStart+=e;try{return t()}finally{this.lineStart-=e}}};var ll=0,sl=e.TextMarker=function(e,t){this.lines=[],this.type=t,this.doc=e,this.id=++ll};xi(sl),sl.prototype.clear=function(){if(!this.explicitlyCleared){var e=this.doc.cm,t=e&&!e.curOp;if(t&&mt(e),wi(this,"clear")){var r=this.find();r&&vi(this,"clear",r.from,r.to)}for(var n=null,i=null,o=0;o<this.lines.length;++o){var l=this.lines[o],s=Xr(l.markedSpans,this);e&&!this.collapsed?Ht(e,Yn(l),"text"):e&&(null!=s.to&&(i=Yn(l)),null!=s.from&&(n=Yn(l))),l.markedSpans=_r(l.markedSpans,s),null==s.from&&this.collapsed&&!gn(this.doc,l)&&e&&_n(l,gt(e.display))}if(e&&this.collapsed&&!e.options.lineWrapping)for(var o=0;o<this.lines.length;++o){var a=fn(this.lines[o]),u=f(a);u>e.display.maxLineLength&&(e.display.maxLine=a,e.display.maxLineLength=u,e.display.maxLineChanged=!0)}null!=n&&e&&this.collapsed&&Dt(e,n,i+1),this.lines.length=0,this.explicitlyCleared=!0,this.atomic&&this.doc.cantEdit&&(this.doc.cantEdit=!1,e&&Ne(e.doc)),e&&vi(e,"markerCleared",e,this),t&&bt(e),this.parent&&this.parent.clear()}},sl.prototype.find=function(e,t){null==e&&"bookmark"==this.type&&(e=1);for(var r,n,i=0;i<this.lines.length;++i){var o=this.lines[i],l=Xr(o.markedSpans,this);if(null!=l.from&&(r=No(t?o:Yn(o),l.from),-1==e))return r;if(null!=l.to&&(n=No(t?o:Yn(o),l.to),1==e))return n}return r&&{from:r,to:n}},sl.prototype.changed=function(){var e=this.find(-1,!0),t=this,r=this.doc.cm;e&&r&&Tt(r,function(){var n=e.line,i=Yn(e.line),o=qe(r,i);if(o&&(rt(o),r.curOp.selectionChanged=r.curOp.forceUpdate=!0),r.curOp.updateMaxLine=!0,!gn(t.doc,n)&&null!=t.height){var l=t.height;t.height=null;var s=yn(t)-l;s&&_n(n,n.height+s)}})},sl.prototype.attachLine=function(e){if(!this.lines.length&&this.doc.cm){var t=this.doc.cm.curOp;t.maybeHiddenMarkers&&-1!=Ti(t.maybeHiddenMarkers,this)||(t.maybeUnhiddenMarkers||(t.maybeUnhiddenMarkers=[])).push(this)}this.lines.push(e)},sl.prototype.detachLine=function(e){if(this.lines.splice(Ti(this.lines,e),1),!this.lines.length&&this.doc.cm){var t=this.doc.cm.curOp;(t.maybeHiddenMarkers||(t.maybeHiddenMarkers=[])).push(this)}};var ll=0,al=e.SharedTextMarker=function(e,t){this.markers=e,this.primary=t;for(var r=0;r<e.length;++r)e[r].parent=this};xi(al),al.prototype.clear=function(){if(!this.explicitlyCleared){this.explicitlyCleared=!0;for(var e=0;e<this.markers.length;++e)this.markers[e].clear();vi(this,"clear")}},al.prototype.find=function(e,t){return this.primary.find(e,t)};var ul=e.LineWidget=function(e,t,r){if(r)for(var n in r)r.hasOwnProperty(n)&&(this[n]=r[n]);this.cm=e,this.node=t};xi(ul),ul.prototype.clear=function(){var e=this.cm,t=this.line.widgets,r=this.line,n=Yn(r);if(null!=n&&t){for(var i=0;i<t.length;++i)t[i]==this&&t.splice(i--,1);t.length||(r.widgets=null);var o=yn(this);Tt(e,function(){mn(e,r,-o),Ht(e,n,"widget"),_n(r,Math.max(0,r.height-o))})}},ul.prototype.changed=function(){var e=this.height,t=this.cm,r=this.line;this.height=null;var n=yn(this)-e;n&&Tt(t,function(){t.curOp.forceUpdate=!0,mn(t,r,n),_n(r,r.height+n)})};var cl=e.Line=function(e,t,r){this.text=e,rn(this,t),this.height=r?r(this):1};xi(cl),cl.prototype.lineNo=function(){return Yn(this)};var fl={},hl={};Bn.prototype={chunkSize:function(){return this.lines.length},removeInner:function(e,t){for(var r=e,n=e+t;n>r;++r){var i=this.lines[r];this.height-=i.height,xn(i),vi(i,"delete")}this.lines.splice(e,t)},collapse:function(e){e.push.apply(e,this.lines)},insertInner:function(e,t,r){this.height+=r,this.lines=this.lines.slice(0,e).concat(t).concat(this.lines.slice(e));for(var n=0;n<t.length;++n)t[n].parent=this},iterN:function(e,t,r){for(var n=e+t;n>e;++e)if(r(this.lines[e]))return!0}},Gn.prototype={chunkSize:function(){return this.size},removeInner:function(e,t){this.size-=t;for(var r=0;r<this.children.length;++r){var n=this.children[r],i=n.chunkSize();if(i>e){var o=Math.min(t,i-e),l=n.height;if(n.removeInner(e,o),this.height-=l-n.height,i==o&&(this.children.splice(r--,1),n.parent=null),0==(t-=o))break;e=0}else e-=i}if(this.size-t<25&&(this.children.length>1||!(this.children[0]instanceof Bn))){var s=[];this.collapse(s),this.children=[new Bn(s)],this.children[0].parent=this}},collapse:function(e){for(var t=0;t<this.children.length;++t)this.children[t].collapse(e)},insertInner:function(e,t,r){this.size+=t.length,this.height+=r;for(var n=0;n<this.children.length;++n){var i=this.children[n],o=i.chunkSize();if(o>=e){if(i.insertInner(e,t,r),i.lines&&i.lines.length>50){for(;i.lines.length>50;){var l=i.lines.splice(i.lines.length-25,25),s=new Bn(l);i.height-=s.height,this.children.splice(n+1,0,s),s.parent=this}this.maybeSpill()}break}e-=o}},maybeSpill:function(){if(!(this.children.length<=10)){var e=this;do{var t=e.children.splice(e.children.length-5,5),r=new Gn(t);if(e.parent){e.size-=r.size,e.height-=r.height;var n=Ti(e.parent.children,e);e.parent.children.splice(n+1,0,r)}else{var i=new Gn(e.children);i.parent=e,e.children=[i,r],e=i}r.parent=e.parent}while(e.children.length>10);e.parent.maybeSpill()}},iterN:function(e,t,r){for(var n=0;n<this.children.length;++n){var i=this.children[n],o=i.chunkSize();if(o>e){var l=Math.min(t,o-e);if(i.iterN(e,l,r))return!0;if(0==(t-=l))break;e=0}else e-=o}}};var dl=0,pl=e.Doc=function(e,t,r){if(!(this instanceof pl))return new pl(e,t,r);null==r&&(r=0),Gn.call(this,[new Bn([new cl("",null)])]),this.first=r,this.scrollTop=this.scrollLeft=0,this.cantEdit=!1,this.cleanGeneration=1,this.frontier=r;var n=No(r,0);this.sel=he(n),this.history=new Qn(null),this.id=++dl,this.modeOption=t,"string"==typeof e&&(e=Vl(e)),Rn(this,{from:n,to:n,text:e}),ke(this,he(n),Tl)};pl.prototype=Ai(Gn.prototype,{constructor:pl,iter:function(e,t,r){r?this.iterN(e-this.first,t-e,r):this.iterN(this.first,this.first+this.size,e)},insert:function(e,t){for(var r=0,n=0;n<t.length;++n)r+=t[n].height;this.insertInner(e-this.first,t,r)},remove:function(e,t){this.removeInner(e-this.first,t)},getValue:function(e){var t=Xn(this,this.first,this.first+this.size);return e===!1?t:t.join(e||"\n")},setValue:At(function(e){var t=No(this.first,0),r=this.first+this.size-1;yr(this,{from:t,to:No(r,Kn(this,r).text.length),text:Vl(e),origin:"setValue",full:!0},!0),ke(this,he(t))}),replaceRange:function(e,t,r,n){t=pe(this,t),r=r?pe(this,r):t,Lr(this,e,t,r,n)},getRange:function(e,t,r){var n=jn(this,pe(this,e),pe(this,t));return r===!1?n:n.join(r||"\n")},getLine:function(e){var t=this.getLineHandle(e);return t&&t.text},getLineHandle:function(e){return ve(this,e)?Kn(this,e):void 0},getLineNumber:function(e){return Yn(e)},getLineHandleVisualStart:function(e){return"number"==typeof e&&(e=Kn(this,e)),fn(e)},lineCount:function(){return this.size},firstLine:function(){return this.first},lastLine:function(){return this.first+this.size-1},clipPos:function(e){return pe(this,e)},getCursor:function(e){var t,r=this.sel.primary();return t=null==e||"head"==e?r.head:"anchor"==e?r.anchor:"end"==e||"to"==e||e===!1?r.to():r.from()},listSelections:function(){return this.sel.ranges},somethingSelected:function(){return this.sel.somethingSelected()},setCursor:At(function(e,t,r){Ce(this,pe(this,"number"==typeof e?No(e,t||0):e),null,r)}),setSelection:At(function(e,t,r){Ce(this,pe(this,e),pe(this,t||e),r)}),extendSelection:At(function(e,t,r){be(this,pe(this,e),t&&pe(this,t),r)}),extendSelections:At(function(e,t){we(this,me(this,e,t))}),extendSelectionsBy:At(function(e,t){we(this,Mi(this.sel.ranges,e),t)}),setSelections:At(function(e,t,r){if(e.length){for(var n=0,i=[];n<e.length;n++)i[n]=new ce(pe(this,e[n].anchor),pe(this,e[n].head));null==t&&(t=Math.min(e.length-1,this.sel.primIndex)),ke(this,fe(i,t),r)}}),addSelection:At(function(e,t,r){var n=this.sel.ranges.slice(0);n.push(new ce(pe(this,e),pe(this,t||e))),ke(this,fe(n,n.length-1),r)}),getSelection:function(e){for(var t,r=this.sel.ranges,n=0;n<r.length;n++){var i=jn(this,r[n].from(),r[n].to());t=t?t.concat(i):i}return e===!1?t:t.join(e||"\n")},getSelections:function(e){for(var t=[],r=this.sel.ranges,n=0;n<r.length;n++){var i=jn(this,r[n].from(),r[n].to());e!==!1&&(i=i.join(e||"\n")),t[n]=i}return t},replaceSelection:function(e,t,r){for(var n=[],i=0;i<this.sel.ranges.length;i++)n[i]=e;this.replaceSelections(n,t,r||"+input")},replaceSelections:At(function(e,t,r){for(var n=[],i=this.sel,o=0;o<i.ranges.length;o++){var l=i.ranges[o];n[o]={from:l.from(),to:l.to(),text:Vl(e[o]),origin:r}}for(var s=t&&"end"!=t&&vr(this,n,t),o=n.length-1;o>=0;o--)yr(this,n[o]);s?Le(this,s):this.cm&&Wr(this.cm)}),undo:At(function(){wr(this,"undo")}),redo:At(function(){wr(this,"redo")}),undoSelection:At(function(){wr(this,"undo",!0)}),redoSelection:At(function(){wr(this,"redo",!0)}),setExtending:function(e){this.extend=e},getExtending:function(){return this.extend},historySize:function(){for(var e=this.history,t=0,r=0,n=0;n<e.done.length;n++)e.done[n].ranges||++t;for(var n=0;n<e.undone.length;n++)e.undone[n].ranges||++r;return{undo:t,redo:r}},clearHistory:function(){this.history=new Qn(this.history.maxGeneration)},markClean:function(){this.cleanGeneration=this.changeGeneration(!0)},changeGeneration:function(e){return e&&(this.history.lastOp=this.history.lastSelOp=this.history.lastOrigin=null),this.history.generation},isClean:function(e){return this.history.generation==(e||this.cleanGeneration)},getHistory:function(){return{done:ui(this.history.done),undone:ui(this.history.undone)}},setHistory:function(e){var t=this.history=new Qn(this.history.maxGeneration);t.done=ui(e.done.slice(0),null,!0),t.undone=ui(e.undone.slice(0),null,!0)},addLineClass:At(function(e,t,r){return Hr(this,e,"gutter"==t?"gutter":"class",function(e){var n="text"==t?"textClass":"background"==t?"bgClass":"gutter"==t?"gutterClass":"wrapClass";if(e[n]){if(Ri(r).test(e[n]))return!1;e[n]+=" "+r}else e[n]=r;return!0})}),removeLineClass:At(function(e,t,r){return Hr(this,e,"gutter"==t?"gutter":"class",function(e){var n="text"==t?"textClass":"background"==t?"bgClass":"gutter"==t?"gutterClass":"wrapClass",i=e[n];if(!i)return!1;if(null==r)e[n]=null;else{var o=i.match(Ri(r));if(!o)return!1;var l=o.index+o[0].length;e[n]=i.slice(0,o.index)+(o.index&&l!=i.length?" ":"")+i.slice(l)||null}return!0})}),markText:function(e,t,r){return Br(this,pe(this,e),pe(this,t),r,"range")},setBookmark:function(e,t){var r={replacedWith:t&&(null==t.nodeType?t.widget:t),insertLeft:t&&t.insertLeft,clearWhenEmpty:!1,shared:t&&t.shared};return e=pe(this,e),Br(this,e,e,r,"bookmark")},findMarksAt:function(e){e=pe(this,e);var t=[],r=Kn(this,e.line).markedSpans;if(r)for(var n=0;n<r.length;++n){var i=r[n];(null==i.from||i.from<=e.ch)&&(null==i.to||i.to>=e.ch)&&t.push(i.marker.parent||i.marker)}return t},findMarks:function(e,t,r){e=pe(this,e),t=pe(this,t);var n=[],i=e.line;return this.iter(e.line,t.line+1,function(o){var l=o.markedSpans;if(l)for(var s=0;s<l.length;s++){var a=l[s];i==e.line&&e.ch>a.to||null==a.from&&i!=e.line||i==t.line&&a.from>t.ch||r&&!r(a.marker)||n.push(a.marker.parent||a.marker)}++i}),n},getAllMarks:function(){var e=[];return this.iter(function(t){var r=t.markedSpans;if(r)for(var n=0;n<r.length;++n)null!=r[n].from&&e.push(r[n].marker)}),e},posFromIndex:function(e){var t,r=this.first;return this.iter(function(n){var i=n.text.length+1;return i>e?(t=e,!0):(e-=i,void++r)}),pe(this,No(r,t))},indexFromPos:function(e){e=pe(this,e);var t=e.ch;return e.line<this.first||e.ch<0?0:(this.iter(this.first,e.line,function(e){t+=e.text.length+1}),t)},copy:function(e){var t=new pl(Xn(this,this.first,this.first+this.size),this.modeOption,this.first);return t.scrollTop=this.scrollTop,t.scrollLeft=this.scrollLeft,t.sel=this.sel,t.extend=!1,e&&(t.history.undoDepth=this.history.undoDepth,t.setHistory(this.getHistory())),t},linkedDoc:function(e){e||(e={});var t=this.first,r=this.first+this.size;null!=e.from&&e.from>t&&(t=e.from),null!=e.to&&e.to<r&&(r=e.to);var n=new pl(Xn(this,t,r),e.mode||this.modeOption,t);return e.sharedHist&&(n.history=this.history),(this.linked||(this.linked=[])).push({doc:n,sharedHist:e.sharedHist}),n.linked=[{doc:this,isParent:!0,sharedHist:e.sharedHist}],Vr(n,Ur(this)),n},unlinkDoc:function(t){if(t instanceof e&&(t=t.doc),this.linked)for(var r=0;r<this.linked.length;++r){var n=this.linked[r];if(n.doc==t){this.linked.splice(r,1),t.unlinkDoc(this),Kr(Ur(this));break}}if(t.history==this.history){var i=[t.id];Un(t,function(e){i.push(e.id)},!0),t.history=new Qn(null),t.history.done=ui(this.history.done,i),t.history.undone=ui(this.history.undone,i)}},iterLinkedDocs:function(e){Un(this,e)},getMode:function(){return this.mode},getEditor:function(){return this.cm}}),pl.prototype.eachLine=pl.prototype.iter;var gl="iter insert remove copy getEditor".split(" ");for(var vl in pl.prototype)pl.prototype.hasOwnProperty(vl)&&Ti(gl,vl)<0&&(e.prototype[vl]=function(e){return function(){return e.apply(this.doc,arguments)}}(pl.prototype[vl]));xi(pl);var ml=e.e_preventDefault=function(e){e.preventDefault?e.preventDefault():e.returnValue=!1},yl=e.e_stopPropagation=function(e){e.stopPropagation?e.stopPropagation():e.cancelBubble=!0},bl=e.e_stop=function(e){ml(e),yl(e)},wl=e.on=function(e,t,r){if(e.addEventListener)e.addEventListener(t,r,!1);else if(e.attachEvent)e.attachEvent("on"+t,r);else{var n=e._handlers||(e._handlers={}),i=n[t]||(n[t]=[]);i.push(r)}},xl=e.off=function(e,t,r){if(e.removeEventListener)e.removeEventListener(t,r,!1);else if(e.detachEvent)e.detachEvent("on"+t,r);else{var n=e._handlers&&e._handlers[t];if(!n)return;for(var i=0;i<n.length;++i)if(n[i]==r){n.splice(i,1);break}}},Cl=e.signal=function(e,t){var r=e._handlers&&e._handlers[t];if(r)for(var n=Array.prototype.slice.call(arguments,2),i=0;i<r.length;++i)r[i].apply(null,n)},Sl=null,Ll=30,kl=e.Pass={toString:function(){return"CodeMirror.Pass"}},Tl={scroll:!1},Ml={origin:"*mouse"},Nl={origin:"+move"};Ci.prototype.set=function(e,t){clearTimeout(this.id),this.id=setTimeout(t,e)};var Al=e.countColumn=function(e,t,r,n,i){null==t&&(t=e.search(/[^\s\u00a0]/),-1==t&&(t=e.length));for(var o=n||0,l=i||0;;){var s=e.indexOf(" ",o);if(0>s||s>=t)return l+(t-o);l+=s-o,l+=r-l%r,o=s+1}},Wl=[""],Ol=function(e){e.select()};bo?Ol=function(e){e.selectionStart=0,e.selectionEnd=e.value.length}:uo&&(Ol=function(e){try{e.select()}catch(t){}});var Dl,Hl=/[\u00df\u0590-\u05f4\u0600-\u06ff\u3040-\u309f\u30a0-\u30ff\u3400-\u4db5\u4e00-\u9fcc\uac00-\ud7af]/,Il=e.isWordChar=function(e){return/\w/.test(e)||e>"€"&&(e.toUpperCase()!=e.toLowerCase()||Hl.test(e))},Pl=/[\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]/;Dl=document.createRange?function(e,t,r,n){var i=document.createRange();return i.setEnd(n||e,r),i.setStart(e,t),i}:function(e,t,r){var n=document.body.createTextRange();try{n.moveToElementText(e.parentNode)}catch(i){return n}return n.collapse(!0),n.moveEnd("character",r),n.moveStart("character",t),n};var zl=e.contains=function(e,t){if(3==t.nodeType&&(t=t.parentNode),e.contains)return e.contains(t);do if(11==t.nodeType&&(t=t.host),t==e)return!0;while(t=t.parentNode)};uo&&11>co&&(Fi=function(){try{return document.activeElement}catch(e){return document.body}});var El,Fl,Rl=e.rmClass=function(e,t){var r=e.className,n=Ri(t).exec(r);if(n){var i=r.slice(n.index+n[0].length);e.className=r.slice(0,n.index)+(i?n[1]+i:"")}},Bl=e.addClass=function(e,t){var r=e.className;Ri(t).test(r)||(e.className+=(r?" ":"")+t)},Gl=!1,Ul=function(){if(uo&&9>co)return!1;var e=Pi("div");return"draggable"in e||"dragDrop"in e}(),Vl=e.splitLines=3!="\n\nb".split(/\n/).length?function(e){for(var t=0,r=[],n=e.length;n>=t;){var i=e.indexOf("\n",t);-1==i&&(i=e.length);var o=e.slice(t,"\r"==e.charAt(i-1)?i-1:i),l=o.indexOf("\r");-1!=l?(r.push(o.slice(0,l)),t+=l+1):(r.push(o),t=i+1)}return r}:function(e){return e.split(/\r\n?|\n/)},Kl=window.getSelection?function(e){try{return e.selectionStart!=e.selectionEnd}catch(t){return!1}}:function(e){try{var t=e.ownerDocument.selection.createRange()}catch(r){}return t&&t.parentElement()==e?0!=t.compareEndPoints("StartToEnd",t):!1},jl=function(){var e=Pi("div");return"oncopy"in e?!0:(e.setAttribute("oncopy","return;"),"function"==typeof e.oncopy)}(),Xl=null,_l={3:"Enter",8:"Backspace",9:"Tab",13:"Enter",16:"Shift",17:"Ctrl",18:"Alt",19:"Pause",20:"CapsLock",27:"Esc",32:"Space",33:"PageUp",34:"PageDown",35:"End",36:"Home",37:"Left",38:"Up",39:"Right",40:"Down",44:"PrintScrn",45:"Insert",46:"Delete",59:";",61:"=",91:"Mod",92:"Mod",93:"Mod",107:"=",109:"-",127:"Delete",173:"-",186:";",187:"=",188:",",189:"-",190:".",191:"/",192:"`",219:"[",220:"\\",221:"]",222:"'",63232:"Up",63233:"Down",63234:"Left",63235:"Right",63272:"Delete",63273:"Home",63275:"End",63276:"PageUp",63277:"PageDown",63302:"Insert"};e.keyNames=_l,function(){for(var e=0;10>e;e++)_l[e+48]=_l[e+96]=String(e);for(var e=65;90>=e;e++)_l[e]=String.fromCharCode(e);for(var e=1;12>=e;e++)_l[e+111]=_l[e+63235]="F"+e}();var Yl,$l=function(){function e(e){return 247>=e?r.charAt(e):e>=1424&&1524>=e?"R":e>=1536&&1773>=e?n.charAt(e-1536):e>=1774&&2220>=e?"r":e>=8192&&8203>=e?"w":8204==e?"b":"L"}function t(e,t,r){this.level=e,this.from=t,this.to=r}var r="bbbbbbbbbtstwsbbbbbbbbbbbbbbssstwNN%%%NNNNNN,N,N1111111111NNNNNNNLLLLLLLLLLLLLLLLLLLLLLLLLLNNNNNNLLLLLLLLLLLLLLLLLLLLLLLLLLNNNNbbbbbbsbbbbbbbbbbbbbbbbbbbbbbbbbb,N%%%%NNNNLNNNNN%%11NLNNN1LNNNNNLLLLLLLLLLLLLLLLLLLLLLLNLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLN",n="rrrrrrrrrrrr,rNNmmmmmmrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrmmmmmmmmmmmmmmrrrrrrrnnnnnnnnnn%nnrrrmrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrmmmmmmmmmmmmmmmmmmmNmmmm",i=/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac]/,o=/[stwN]/,l=/[LRr]/,s=/[Lb1n]/,a=/[1n]/,u="L";return function(r){if(!i.test(r))return!1;for(var n,c=r.length,f=[],h=0;c>h;++h)f.push(n=e(r.charCodeAt(h)));for(var h=0,d=u;c>h;++h){var n=f[h];"m"==n?f[h]=d:d=n}for(var h=0,p=u;c>h;++h){var n=f[h];"1"==n&&"r"==p?f[h]="n":l.test(n)&&(p=n,"r"==n&&(f[h]="R"))}for(var h=1,d=f[0];c-1>h;++h){var n=f[h];"+"==n&&"1"==d&&"1"==f[h+1]?f[h]="1":","!=n||d!=f[h+1]||"1"!=d&&"n"!=d||(f[h]=d),d=n}for(var h=0;c>h;++h){var n=f[h];if(","==n)f[h]="N";else if("%"==n){for(var g=h+1;c>g&&"%"==f[g];++g);for(var v=h&&"!"==f[h-1]||c>g&&"1"==f[g]?"1":"N",m=h;g>m;++m)f[m]=v;h=g-1}}for(var h=0,p=u;c>h;++h){var n=f[h];"L"==p&&"1"==n?f[h]="L":l.test(n)&&(p=n)}for(var h=0;c>h;++h)if(o.test(f[h])){for(var g=h+1;c>g&&o.test(f[g]);++g);for(var y="L"==(h?f[h-1]:u),b="L"==(c>g?f[g]:u),v=y||b?"L":"R",m=h;g>m;++m)f[m]=v;h=g-1}for(var w,x=[],h=0;c>h;)if(s.test(f[h])){var C=h;for(++h;c>h&&s.test(f[h]);++h);x.push(new t(0,C,h))}else{var S=h,L=x.length;for(++h;c>h&&"L"!=f[h];++h);for(var m=S;h>m;)if(a.test(f[m])){m>S&&x.splice(L,0,new t(1,S,m));var k=m;for(++m;h>m&&a.test(f[m]);++m);x.splice(L,0,new t(2,k,m)),S=m}else++m;h>S&&x.splice(L,0,new t(1,S,h))}return 1==x[0].level&&(w=r.match(/^\s+/))&&(x[0].from=w[0].length,x.unshift(new t(0,0,w[0].length))),1==ki(x).level&&(w=r.match(/\s+$/))&&(ki(x).to-=w[0].length,x.push(new t(0,c-w[0].length,c))),x[0].level!=ki(x).level&&x.push(new t(x[0].level,c,c)),x}}();return e.version="5.0.0",e});
1
+ !function(e){if("object"==typeof exports&&"object"==typeof module)module.exports=e();else{if("function"==typeof define&&define.amd)return define([],e);this.CodeMirror=e()}}(function(){"use strict";function e(r,n){if(!(this instanceof e))return new e(r,n);this.options=n=n?Wi(n):{},Wi(Ko,n,!1),d(n);var i=n.value;"string"==typeof i&&(i=new pl(i,n.mode)),this.doc=i;var o=new e.inputStyles[n.inputStyle](this),l=this.display=new t(r,i,o);l.wrapper.CodeMirror=this,u(this),s(this),n.lineWrapping&&(this.display.wrapper.className+=" CodeMirror-wrap"),n.autofocus&&!wo&&l.input.focus(),m(this),this.state={keyMaps:[],overlays:[],modeGen:0,overwrite:!1,focused:!1,suppressEdits:!1,pasteIncoming:!1,cutIncoming:!1,draggingText:!1,highlight:new Ci,keySeq:null};var a=this;uo&&11>co&&setTimeout(function(){a.display.input.reset(!0)},20),Rt(this),Ui(),mt(this),this.curOp.forceUpdate=!0,Vn(this,i),n.autofocus&&!wo||a.hasFocus()?setTimeout(Oi(ur,this),20):cr(this);for(var c in jo)jo.hasOwnProperty(c)&&jo[c](this,n[c],Xo);C(this),n.finishInit&&n.finishInit(this);for(var f=0;f<qo.length;++f)qo[f](this);bt(this),fo&&n.lineWrapping&&"optimizelegibility"==getComputedStyle(l.lineDiv).textRendering&&(l.lineDiv.style.textRendering="auto")}function t(e,t,r){var n=this;this.input=r,n.scrollbarFiller=Pi("div",null,"CodeMirror-scrollbar-filler"),n.scrollbarFiller.setAttribute("cm-not-content","true"),n.gutterFiller=Pi("div",null,"CodeMirror-gutter-filler"),n.gutterFiller.setAttribute("cm-not-content","true"),n.lineDiv=Pi("div",null,"CodeMirror-code"),n.selectionDiv=Pi("div",null,null,"position: relative; z-index: 1"),n.cursorDiv=Pi("div",null,"CodeMirror-cursors"),n.measure=Pi("div",null,"CodeMirror-measure"),n.lineMeasure=Pi("div",null,"CodeMirror-measure"),n.lineSpace=Pi("div",[n.measure,n.lineMeasure,n.selectionDiv,n.cursorDiv,n.lineDiv],null,"position: relative; outline: none"),n.mover=Pi("div",[Pi("div",[n.lineSpace],"CodeMirror-lines")],null,"position: relative"),n.sizer=Pi("div",[n.mover],"CodeMirror-sizer"),n.sizerWidth=null,n.heightForcer=Pi("div",null,null,"position: absolute; height: "+Ll+"px; width: 1px;"),n.gutters=Pi("div",null,"CodeMirror-gutters"),n.lineGutter=null,n.scroller=Pi("div",[n.sizer,n.heightForcer,n.gutters],"CodeMirror-scroll"),n.scroller.setAttribute("tabIndex","-1"),n.wrapper=Pi("div",[n.scrollbarFiller,n.gutterFiller,n.scroller],"CodeMirror"),uo&&8>co&&(n.gutters.style.zIndex=-1,n.scroller.style.paddingRight=0),fo||lo&&wo||(n.scroller.draggable=!0),e&&(e.appendChild?e.appendChild(n.wrapper):e(n.wrapper)),n.viewFrom=n.viewTo=t.first,n.reportedViewFrom=n.reportedViewTo=t.first,n.view=[],n.renderedView=null,n.externalMeasured=null,n.viewOffset=0,n.lastWrapHeight=n.lastWrapWidth=0,n.updateLineNumbers=null,n.nativeBarWidth=n.barHeight=n.barWidth=0,n.scrollbarsClipped=!1,n.lineNumWidth=n.lineNumInnerWidth=n.lineNumChars=null,n.alignWidgets=!1,n.cachedCharWidth=n.cachedTextHeight=n.cachedPaddingH=null,n.maxLine=null,n.maxLineLength=0,n.maxLineChanged=!1,n.wheelDX=n.wheelDY=n.wheelStartX=n.wheelStartY=null,n.shift=!1,n.selForContextMenu=null,n.activeTouch=null,r.init(n)}function r(t){t.doc.mode=e.getMode(t.options,t.doc.modeOption),n(t)}function n(e){e.doc.iter(function(e){e.stateAfter&&(e.stateAfter=null),e.styles&&(e.styles=null)}),e.doc.frontier=e.doc.first,ze(e,100),e.state.modeGen++,e.curOp&&Dt(e)}function i(e){e.options.lineWrapping?(Bl(e.display.wrapper,"CodeMirror-wrap"),e.display.sizer.style.minWidth="",e.display.sizerWidth=null):(Rl(e.display.wrapper,"CodeMirror-wrap"),h(e)),l(e),Dt(e),it(e),setTimeout(function(){y(e)},100)}function o(e){var t=gt(e.display),r=e.options.lineWrapping,n=r&&Math.max(5,e.display.scroller.clientWidth/vt(e.display)-3);return function(i){if(gn(e.doc,i))return 0;var o=0;if(i.widgets)for(var l=0;l<i.widgets.length;l++)i.widgets[l].height&&(o+=i.widgets[l].height);return r?o+(Math.ceil(i.text.length/n)||1)*t:o+t}}function l(e){var t=e.doc,r=o(e);t.iter(function(e){var t=r(e);t!=e.height&&_n(e,t)})}function s(e){e.display.wrapper.className=e.display.wrapper.className.replace(/\s*cm-s-\S+/g,"")+e.options.theme.replace(/(^|\s)\s*/g," cm-s-"),it(e)}function a(e){u(e),Dt(e),setTimeout(function(){x(e)},20)}function u(e){var t=e.display.gutters,r=e.options.gutters;zi(t);for(var n=0;n<r.length;++n){var i=r[n],o=t.appendChild(Pi("div",null,"CodeMirror-gutter "+i));"CodeMirror-linenumbers"==i&&(e.display.lineGutter=o,o.style.width=(e.display.lineNumWidth||1)+"px")}t.style.display=n?"":"none",c(e)}function c(e){var t=e.display.gutters.offsetWidth;e.display.sizer.style.marginLeft=t+"px"}function f(e){if(0==e.height)return 0;for(var t,r=e.text.length,n=e;t=an(n);){var i=t.find(0,!0);n=i.from.line,r+=i.from.ch-i.to.ch}for(n=e;t=un(n);){var i=t.find(0,!0);r-=n.text.length-i.from.ch,n=i.to.line,r+=n.text.length-i.to.ch}return r}function h(e){var t=e.display,r=e.doc;t.maxLine=Kn(r,r.first),t.maxLineLength=f(t.maxLine),t.maxLineChanged=!0,r.iter(function(e){var r=f(e);r>t.maxLineLength&&(t.maxLineLength=r,t.maxLine=e)})}function d(e){var t=Ti(e.gutters,"CodeMirror-linenumbers");-1==t&&e.lineNumbers?e.gutters=e.gutters.concat(["CodeMirror-linenumbers"]):t>-1&&!e.lineNumbers&&(e.gutters=e.gutters.slice(0),e.gutters.splice(t,1))}function p(e){var t=e.display,r=t.gutters.offsetWidth,n=Math.round(e.doc.height+Ge(e.display));return{clientHeight:t.scroller.clientHeight,viewHeight:t.wrapper.clientHeight,scrollWidth:t.scroller.scrollWidth,clientWidth:t.scroller.clientWidth,viewWidth:t.wrapper.clientWidth,barLeft:e.options.fixedGutter?r:0,docHeight:n,scrollHeight:n+Ve(e)+t.barHeight,nativeBarWidth:t.nativeBarWidth,gutterWidth:r}}function g(e,t,r){this.cm=r;var n=this.vert=Pi("div",[Pi("div",null,null,"min-width: 1px")],"CodeMirror-vscrollbar"),i=this.horiz=Pi("div",[Pi("div",null,null,"height: 100%; min-height: 1px")],"CodeMirror-hscrollbar");e(n),e(i),wl(n,"scroll",function(){n.clientHeight&&t(n.scrollTop,"vertical")}),wl(i,"scroll",function(){i.clientWidth&&t(i.scrollLeft,"horizontal")}),this.checkedOverlay=!1,uo&&8>co&&(this.horiz.style.minHeight=this.vert.style.minWidth="18px")}function v(){}function m(t){t.display.scrollbars&&(t.display.scrollbars.clear(),t.display.scrollbars.addClass&&Rl(t.display.wrapper,t.display.scrollbars.addClass)),t.display.scrollbars=new e.scrollbarModel[t.options.scrollbarStyle](function(e){t.display.wrapper.insertBefore(e,t.display.scrollbarFiller),wl(e,"mousedown",function(){t.state.focused&&setTimeout(function(){t.display.input.focus()},0)}),e.setAttribute("cm-not-content","true")},function(e,r){"horizontal"==r?Qt(t,e):Zt(t,e)},t),t.display.scrollbars.addClass&&Bl(t.display.wrapper,t.display.scrollbars.addClass)}function y(e,t){t||(t=p(e));var r=e.display.barWidth,n=e.display.barHeight;b(e,t);for(var i=0;4>i&&r!=e.display.barWidth||n!=e.display.barHeight;i++)r!=e.display.barWidth&&e.options.lineWrapping&&O(e),b(e,p(e)),r=e.display.barWidth,n=e.display.barHeight}function b(e,t){var r=e.display,n=r.scrollbars.update(t);r.sizer.style.paddingRight=(r.barWidth=n.right)+"px",r.sizer.style.paddingBottom=(r.barHeight=n.bottom)+"px",n.right&&n.bottom?(r.scrollbarFiller.style.display="block",r.scrollbarFiller.style.height=n.bottom+"px",r.scrollbarFiller.style.width=n.right+"px"):r.scrollbarFiller.style.display="",n.bottom&&e.options.coverGutterNextToScrollbar&&e.options.fixedGutter?(r.gutterFiller.style.display="block",r.gutterFiller.style.height=n.bottom+"px",r.gutterFiller.style.width=t.gutterWidth+"px"):r.gutterFiller.style.display=""}function w(e,t,r){var n=r&&null!=r.top?Math.max(0,r.top):e.scroller.scrollTop;n=Math.floor(n-Be(e));var i=r&&null!=r.bottom?r.bottom:n+e.wrapper.clientHeight,o=$n(t,n),l=$n(t,i);if(r&&r.ensure){var s=r.ensure.from.line,a=r.ensure.to.line;o>s?(o=s,l=$n(t,qn(Kn(t,s))+e.wrapper.clientHeight)):Math.min(a,t.lastLine())>=l&&(o=$n(t,qn(Kn(t,a))-e.wrapper.clientHeight),l=a)}return{from:o,to:Math.max(l,o+1)}}function x(e){var t=e.display,r=t.view;if(t.alignWidgets||t.gutters.firstChild&&e.options.fixedGutter){for(var n=L(t)-t.scroller.scrollLeft+e.doc.scrollLeft,i=t.gutters.offsetWidth,o=n+"px",l=0;l<r.length;l++)if(!r[l].hidden){e.options.fixedGutter&&r[l].gutter&&(r[l].gutter.style.left=o);var s=r[l].alignable;if(s)for(var a=0;a<s.length;a++)s[a].style.left=o}e.options.fixedGutter&&(t.gutters.style.left=n+i+"px")}}function C(e){if(!e.options.lineNumbers)return!1;var t=e.doc,r=S(e.options,t.first+t.size-1),n=e.display;if(r.length!=n.lineNumChars){var i=n.measure.appendChild(Pi("div",[Pi("div",r)],"CodeMirror-linenumber CodeMirror-gutter-elt")),o=i.firstChild.offsetWidth,l=i.offsetWidth-o;return n.lineGutter.style.width="",n.lineNumInnerWidth=Math.max(o,n.lineGutter.offsetWidth-l),n.lineNumWidth=n.lineNumInnerWidth+l,n.lineNumChars=n.lineNumInnerWidth?r.length:-1,n.lineGutter.style.width=n.lineNumWidth+"px",c(e),!0}return!1}function S(e,t){return String(e.lineNumberFormatter(t+e.firstLineNumber))}function L(e){return e.scroller.getBoundingClientRect().left-e.sizer.getBoundingClientRect().left}function k(e,t,r){var n=e.display;this.viewport=t,this.visible=w(n,e.doc,t),this.editorIsHidden=!n.wrapper.offsetWidth,this.wrapperHeight=n.wrapper.clientHeight,this.wrapperWidth=n.wrapper.clientWidth,this.oldDisplayWidth=Ke(e),this.force=r,this.dims=H(e),this.events=[]}function T(e){var t=e.display;!t.scrollbarsClipped&&t.scroller.offsetWidth&&(t.nativeBarWidth=t.scroller.offsetWidth-t.scroller.clientWidth,t.heightForcer.style.height=Ve(e)+"px",t.sizer.style.marginBottom=-t.nativeBarWidth+"px",t.sizer.style.borderRightWidth=Ve(e)+"px",t.scrollbarsClipped=!0)}function M(e,t){var r=e.display,n=e.doc;if(t.editorIsHidden)return It(e),!1;if(!t.force&&t.visible.from>=r.viewFrom&&t.visible.to<=r.viewTo&&(null==r.updateLineNumbers||r.updateLineNumbers>=r.viewTo)&&r.renderedView==r.view&&0==Ft(e))return!1;C(e)&&(It(e),t.dims=H(e));var i=n.first+n.size,o=Math.max(t.visible.from-e.options.viewportMargin,n.first),l=Math.min(i,t.visible.to+e.options.viewportMargin);r.viewFrom<o&&o-r.viewFrom<20&&(o=Math.max(n.first,r.viewFrom)),r.viewTo>l&&r.viewTo-l<20&&(l=Math.min(i,r.viewTo)),Mo&&(o=dn(e.doc,o),l=pn(e.doc,l));var s=o!=r.viewFrom||l!=r.viewTo||r.lastWrapHeight!=t.wrapperHeight||r.lastWrapWidth!=t.wrapperWidth;Et(e,o,l),r.viewOffset=qn(Kn(e.doc,r.viewFrom)),e.display.mover.style.top=r.viewOffset+"px";var a=Ft(e);if(!s&&0==a&&!t.force&&r.renderedView==r.view&&(null==r.updateLineNumbers||r.updateLineNumbers>=r.viewTo))return!1;var u=Fi();return a>4&&(r.lineDiv.style.display="none"),I(e,r.updateLineNumbers,t.dims),a>4&&(r.lineDiv.style.display=""),r.renderedView=r.view,u&&Fi()!=u&&u.offsetHeight&&u.focus(),zi(r.cursorDiv),zi(r.selectionDiv),r.gutters.style.height=0,s&&(r.lastWrapHeight=t.wrapperHeight,r.lastWrapWidth=t.wrapperWidth,ze(e,400)),r.updateLineNumbers=null,!0}function N(e,t){for(var r=t.force,n=t.viewport,i=!0;;i=!1){if(i&&e.options.lineWrapping&&t.oldDisplayWidth!=Ke(e))r=!0;else if(r=!1,n&&null!=n.top&&(n={top:Math.min(e.doc.height+Ge(e.display)-je(e),n.top)}),t.visible=w(e.display,e.doc,n),t.visible.from>=e.display.viewFrom&&t.visible.to<=e.display.viewTo)break;if(!M(e,t))break;O(e);var o=p(e);Oe(e),W(e,o),y(e,o)}t.signal(e,"update",e),(e.display.viewFrom!=e.display.reportedViewFrom||e.display.viewTo!=e.display.reportedViewTo)&&(t.signal(e,"viewportChange",e,e.display.viewFrom,e.display.viewTo),e.display.reportedViewFrom=e.display.viewFrom,e.display.reportedViewTo=e.display.viewTo)}function A(e,t){var r=new k(e,t);if(M(e,r)){O(e),N(e,r);var n=p(e);Oe(e),W(e,n),y(e,n),r.finish()}}function W(e,t){e.display.sizer.style.minHeight=t.docHeight+"px";var r=t.docHeight+e.display.barHeight;e.display.heightForcer.style.top=r+"px",e.display.gutters.style.height=Math.max(r+Ve(e),t.clientHeight)+"px"}function O(e){for(var t=e.display,r=t.lineDiv.offsetTop,n=0;n<t.view.length;n++){var i,o=t.view[n];if(!o.hidden){if(uo&&8>co){var l=o.node.offsetTop+o.node.offsetHeight;i=l-r,r=l}else{var s=o.node.getBoundingClientRect();i=s.bottom-s.top}var a=o.line.height-i;if(2>i&&(i=gt(t)),(a>.001||-.001>a)&&(_n(o.line,i),D(o.line),o.rest))for(var u=0;u<o.rest.length;u++)D(o.rest[u])}}}function D(e){if(e.widgets)for(var t=0;t<e.widgets.length;++t)e.widgets[t].height=e.widgets[t].node.offsetHeight}function H(e){for(var t=e.display,r={},n={},i=t.gutters.clientLeft,o=t.gutters.firstChild,l=0;o;o=o.nextSibling,++l)r[e.options.gutters[l]]=o.offsetLeft+o.clientLeft+i,n[e.options.gutters[l]]=o.clientWidth;return{fixedPos:L(t),gutterTotalWidth:t.gutters.offsetWidth,gutterLeft:r,gutterWidth:n,wrapperWidth:t.wrapper.clientWidth}}function I(e,t,r){function n(t){var r=t.nextSibling;return fo&&xo&&e.display.currentWheelTarget==t?t.style.display="none":t.parentNode.removeChild(t),r}for(var i=e.display,o=e.options.lineNumbers,l=i.lineDiv,s=l.firstChild,a=i.view,u=i.viewFrom,c=0;c<a.length;c++){var f=a[c];if(f.hidden);else if(f.node&&f.node.parentNode==l){for(;s!=f.node;)s=n(s);var h=o&&null!=t&&u>=t&&f.lineNumber;f.changes&&(Ti(f.changes,"gutter")>-1&&(h=!1),P(e,f,u,r)),h&&(zi(f.lineNumber),f.lineNumber.appendChild(document.createTextNode(S(e.options,u)))),s=f.node.nextSibling}else{var d=V(e,f,u,r);l.insertBefore(d,s)}u+=f.size}for(;s;)s=n(s)}function P(e,t,r,n){for(var i=0;i<t.changes.length;i++){var o=t.changes[i];"text"==o?R(e,t):"gutter"==o?G(e,t,r,n):"class"==o?B(t):"widget"==o&&U(e,t,n)}t.changes=null}function z(e){return e.node==e.text&&(e.node=Pi("div",null,null,"position: relative"),e.text.parentNode&&e.text.parentNode.replaceChild(e.node,e.text),e.node.appendChild(e.text),uo&&8>co&&(e.node.style.zIndex=2)),e.node}function E(e){var t=e.bgClass?e.bgClass+" "+(e.line.bgClass||""):e.line.bgClass;if(t&&(t+=" CodeMirror-linebackground"),e.background)t?e.background.className=t:(e.background.parentNode.removeChild(e.background),e.background=null);else if(t){var r=z(e);e.background=r.insertBefore(Pi("div",null,t),r.firstChild)}}function F(e,t){var r=e.display.externalMeasured;return r&&r.line==t.line?(e.display.externalMeasured=null,t.measure=r.measure,r.built):On(e,t)}function R(e,t){var r=t.text.className,n=F(e,t);t.text==t.node&&(t.node=n.pre),t.text.parentNode.replaceChild(n.pre,t.text),t.text=n.pre,n.bgClass!=t.bgClass||n.textClass!=t.textClass?(t.bgClass=n.bgClass,t.textClass=n.textClass,B(t)):r&&(t.text.className=r)}function B(e){E(e),e.line.wrapClass?z(e).className=e.line.wrapClass:e.node!=e.text&&(e.node.className="");var t=e.textClass?e.textClass+" "+(e.line.textClass||""):e.line.textClass;e.text.className=t||""}function G(e,t,r,n){t.gutter&&(t.node.removeChild(t.gutter),t.gutter=null);var i=t.line.gutterMarkers;if(e.options.lineNumbers||i){var o=z(t),l=t.gutter=Pi("div",null,"CodeMirror-gutter-wrapper","left: "+(e.options.fixedGutter?n.fixedPos:-n.gutterTotalWidth)+"px; width: "+n.gutterTotalWidth+"px");if(e.display.input.setUneditable(l),o.insertBefore(l,t.text),t.line.gutterClass&&(l.className+=" "+t.line.gutterClass),!e.options.lineNumbers||i&&i["CodeMirror-linenumbers"]||(t.lineNumber=l.appendChild(Pi("div",S(e.options,r),"CodeMirror-linenumber CodeMirror-gutter-elt","left: "+n.gutterLeft["CodeMirror-linenumbers"]+"px; width: "+e.display.lineNumInnerWidth+"px"))),i)for(var s=0;s<e.options.gutters.length;++s){var a=e.options.gutters[s],u=i.hasOwnProperty(a)&&i[a];u&&l.appendChild(Pi("div",[u],"CodeMirror-gutter-elt","left: "+n.gutterLeft[a]+"px; width: "+n.gutterWidth[a]+"px"))}}}function U(e,t,r){t.alignable&&(t.alignable=null);for(var n,i=t.node.firstChild;i;i=n){var n=i.nextSibling;"CodeMirror-linewidget"==i.className&&t.node.removeChild(i)}K(e,t,r)}function V(e,t,r,n){var i=F(e,t);return t.text=t.node=i.pre,i.bgClass&&(t.bgClass=i.bgClass),i.textClass&&(t.textClass=i.textClass),B(t),G(e,t,r,n),K(e,t,n),t.node}function K(e,t,r){if(j(e,t.line,t,r,!0),t.rest)for(var n=0;n<t.rest.length;n++)j(e,t.rest[n],t,r,!1)}function j(e,t,r,n,i){if(t.widgets)for(var o=z(r),l=0,s=t.widgets;l<s.length;++l){var a=s[l],u=Pi("div",[a.node],"CodeMirror-linewidget");a.handleMouseEvents||u.setAttribute("cm-ignore-events","true"),X(a,u,r,n),e.display.input.setUneditable(u),i&&a.above?o.insertBefore(u,r.gutter||r.text):o.appendChild(u),vi(a,"redraw")}}function X(e,t,r,n){if(e.noHScroll){(r.alignable||(r.alignable=[])).push(t);var i=n.wrapperWidth;t.style.left=n.fixedPos+"px",e.coverGutter||(i-=n.gutterTotalWidth,t.style.paddingLeft=n.gutterTotalWidth+"px"),t.style.width=i+"px"}e.coverGutter&&(t.style.zIndex=5,t.style.position="relative",e.noHScroll||(t.style.marginLeft=-n.gutterTotalWidth+"px"))}function _(e){return No(e.line,e.ch)}function Y(e,t){return Ao(e,t)<0?t:e}function $(e,t){return Ao(e,t)<0?e:t}function q(e){e.state.focused||(e.display.input.focus(),ur(e))}function Z(e){return e.options.readOnly||e.doc.cantEdit}function Q(e,t,r,n){var i=e.doc;e.display.shift=!1,n||(n=i.sel);var o=Vl(t),l=null;e.state.pasteIncoming&&n.ranges.length>1&&(Wo&&Wo.join("\n")==t?l=n.ranges.length%Wo.length==0&&Mi(Wo,Vl):o.length==n.ranges.length&&(l=Mi(o,function(e){return[e]})));for(var s=n.ranges.length-1;s>=0;s--){var a=n.ranges[s],u=a.from(),c=a.to();a.empty()&&(r&&r>0?u=No(u.line,u.ch-r):e.state.overwrite&&!e.state.pasteIncoming&&(c=No(c.line,Math.min(Kn(i,c.line).text.length,c.ch+ki(o).length))));var f=e.curOp.updateInput,h={from:u,to:c,text:l?l[s%l.length]:o,origin:e.state.pasteIncoming?"paste":e.state.cutIncoming?"cut":"+input"};if(yr(e.doc,h),vi(e,"inputRead",e,h),t&&!e.state.pasteIncoming&&e.options.electricChars&&e.options.smartIndent&&a.head.ch<100&&(!s||n.ranges[s-1].head.line!=a.head.line)){var d=e.getModeAt(a.head),p=Vo(h);if(d.electricChars){for(var g=0;g<d.electricChars.length;g++)if(t.indexOf(d.electricChars.charAt(g))>-1){Dr(e,p.line,"smart");break}}else d.electricInput&&d.electricInput.test(Kn(i,p.line).text.slice(0,p.ch))&&Dr(e,p.line,"smart")}}Wr(e),e.curOp.updateInput=f,e.curOp.typing=!0,e.state.pasteIncoming=e.state.cutIncoming=!1}function J(e){for(var t=[],r=[],n=0;n<e.doc.sel.ranges.length;n++){var i=e.doc.sel.ranges[n].head.line,o={anchor:No(i,0),head:No(i+1,0)};r.push(o),t.push(e.getRange(o.anchor,o.head))}return{text:t,ranges:r}}function ee(e){e.setAttribute("autocorrect","off"),e.setAttribute("autocapitalize","off"),e.setAttribute("spellcheck","false")}function te(e){this.cm=e,this.prevInput="",this.pollingFast=!1,this.polling=new Ci,this.inaccurateSelection=!1,this.hasSelection=!1}function re(){var e=Pi("textarea",null,null,"position: absolute; padding: 0; width: 1px; height: 1em; outline: none"),t=Pi("div",[e],null,"overflow: hidden; position: relative; width: 3px; height: 0px;");return fo?e.style.width="1000px":e.setAttribute("wrap","off"),bo&&(e.style.border="1px solid black"),ee(e),t}function ne(e){this.cm=e,this.lastAnchorNode=this.lastAnchorOffset=this.lastFocusNode=this.lastFocusOffset=null,this.polling=new Ci}function ie(e,t){var r=qe(e,t.line);if(!r||r.hidden)return null;var n=Kn(e.doc,t.line),i=_e(r,n,t.line),o=Zn(n),l="left";if(o){var s=ro(o,t.ch);l=s%2?"right":"left"}var a=Je(i.map,t.ch,"left");return a.offset="right"==a.collapse?a.end:a.start,a}function oe(e,t){return t&&(e.bad=!0),e}function le(e,t,r){var n;if(t==e.display.lineDiv){if(n=e.display.lineDiv.childNodes[r],!n)return oe(e.clipPos(No(e.display.viewTo-1)),!0);t=null,r=0}else for(n=t;;n=n.parentNode){if(!n||n==e.display.lineDiv)return null;if(n.parentNode&&n.parentNode==e.display.lineDiv)break}for(var i=0;i<e.display.view.length;i++){var o=e.display.view[i];if(o.node==n)return se(o,t,r)}}function se(e,t,r){function n(t,r,n){for(var i=-1;i<(c?c.length:0);i++)for(var o=0>i?u.map:c[i],l=0;l<o.length;l+=3){var s=o[l+2];if(s==t||s==r){var a=Yn(0>i?e.line:e.rest[i]),f=o[l]+n;return(0>n||s!=t)&&(f=o[l+(n?1:0)]),No(a,f)}}}var i=e.text.firstChild,o=!1;if(!t||!zl(i,t))return oe(No(Yn(e.line),0),!0);if(t==i&&(o=!0,t=i.childNodes[r],r=0,!t)){var l=e.rest?ki(e.rest):e.line;return oe(No(Yn(l),l.text.length),o)}var s=3==t.nodeType?t:null,a=t;for(s||1!=t.childNodes.length||3!=t.firstChild.nodeType||(s=t.firstChild,r&&(r=s.nodeValue.length));a.parentNode!=i;)a=a.parentNode;var u=e.measure,c=u.maps,f=n(s,a,r);if(f)return oe(f,o);for(var h=a.nextSibling,d=s?s.nodeValue.length-r:0;h;h=h.nextSibling){if(f=n(h,h.firstChild,0))return oe(No(f.line,f.ch-d),o);d+=h.textContent.length}for(var p=a.previousSibling,d=r;p;p=p.previousSibling){if(f=n(p,p.firstChild,-1))return oe(No(f.line,f.ch+d),o);d+=h.textContent.length}}function ae(e,t,r,n,i){function o(e){return function(t){return t.id==e}}function l(t){if(1==t.nodeType){var r=t.getAttribute("cm-text");if(null!=r)return""==r&&(r=t.textContent.replace(/\u200b/g,"")),void(s+=r);var u,c=t.getAttribute("cm-marker");if(c){var f=e.findMarks(No(n,0),No(i+1,0),o(+c));return void(f.length&&(u=f[0].find())&&(s+=jn(e.doc,u.from,u.to).join("\n")))}if("false"==t.getAttribute("contenteditable"))return;for(var h=0;h<t.childNodes.length;h++)l(t.childNodes[h]);/^(pre|div|p)$/i.test(t.nodeName)&&(a=!0)}else if(3==t.nodeType){var d=t.nodeValue;if(!d)return;a&&(s+="\n",a=!1),s+=d}}for(var s="",a=!1;l(t),t!=r;)t=t.nextSibling;return s}function ue(e,t){this.ranges=e,this.primIndex=t}function ce(e,t){this.anchor=e,this.head=t}function fe(e,t){var r=e[t];e.sort(function(e,t){return Ao(e.from(),t.from())}),t=Ti(e,r);for(var n=1;n<e.length;n++){var i=e[n],o=e[n-1];if(Ao(o.to(),i.from())>=0){var l=$(o.from(),i.from()),s=Y(o.to(),i.to()),a=o.empty()?i.from()==i.head:o.from()==o.head;t>=n&&--t,e.splice(--n,2,new ce(a?s:l,a?l:s))}}return new ue(e,t)}function he(e,t){return new ue([new ce(e,t||e)],0)}function de(e,t){return Math.max(e.first,Math.min(t,e.first+e.size-1))}function pe(e,t){if(t.line<e.first)return No(e.first,0);var r=e.first+e.size-1;return t.line>r?No(r,Kn(e,r).text.length):ge(t,Kn(e,t.line).text.length)}function ge(e,t){var r=e.ch;return null==r||r>t?No(e.line,t):0>r?No(e.line,0):e}function ve(e,t){return t>=e.first&&t<e.first+e.size}function me(e,t){for(var r=[],n=0;n<t.length;n++)r[n]=pe(e,t[n]);return r}function ye(e,t,r,n){if(e.cm&&e.cm.display.shift||e.extend){var i=t.anchor;if(n){var o=Ao(r,i)<0;o!=Ao(n,i)<0?(i=r,r=n):o!=Ao(r,n)<0&&(r=n)}return new ce(i,r)}return new ce(n||r,r)}function be(e,t,r,n){ke(e,new ue([ye(e,e.sel.primary(),t,r)],0),n)}function we(e,t,r){for(var n=[],i=0;i<e.sel.ranges.length;i++)n[i]=ye(e,e.sel.ranges[i],t[i],null);var o=fe(n,e.sel.primIndex);ke(e,o,r)}function xe(e,t,r,n){var i=e.sel.ranges.slice(0);i[t]=r,ke(e,fe(i,e.sel.primIndex),n)}function Ce(e,t,r,n){ke(e,he(t,r),n)}function Se(e,t){var r={ranges:t.ranges,update:function(t){this.ranges=[];for(var r=0;r<t.length;r++)this.ranges[r]=new ce(pe(e,t[r].anchor),pe(e,t[r].head))}};return Cl(e,"beforeSelectionChange",e,r),e.cm&&Cl(e.cm,"beforeSelectionChange",e.cm,r),r.ranges!=t.ranges?fe(r.ranges,r.ranges.length-1):t}function Le(e,t,r){var n=e.history.done,i=ki(n);i&&i.ranges?(n[n.length-1]=t,Te(e,t,r)):ke(e,t,r)}function ke(e,t,r){Te(e,t,r),ii(e,e.sel,e.cm?e.cm.curOp.id:NaN,r)}function Te(e,t,r){(wi(e,"beforeSelectionChange")||e.cm&&wi(e.cm,"beforeSelectionChange"))&&(t=Se(e,t));var n=r&&r.bias||(Ao(t.primary().head,e.sel.primary().head)<0?-1:1);Me(e,Ae(e,t,n,!0)),r&&r.scroll===!1||!e.cm||Wr(e.cm)}function Me(e,t){t.equals(e.sel)||(e.sel=t,e.cm&&(e.cm.curOp.updateInput=e.cm.curOp.selectionChanged=!0,bi(e.cm)),vi(e,"cursorActivity",e))}function Ne(e){Me(e,Ae(e,e.sel,null,!1),Tl)}function Ae(e,t,r,n){for(var i,o=0;o<t.ranges.length;o++){var l=t.ranges[o],s=We(e,l.anchor,r,n),a=We(e,l.head,r,n);(i||s!=l.anchor||a!=l.head)&&(i||(i=t.ranges.slice(0,o)),i[o]=new ce(s,a))}return i?fe(i,t.primIndex):t}function We(e,t,r,n){var i=!1,o=t,l=r||1;e.cantEdit=!1;e:for(;;){var s=Kn(e,o.line);if(s.markedSpans)for(var a=0;a<s.markedSpans.length;++a){var u=s.markedSpans[a],c=u.marker;if((null==u.from||(c.inclusiveLeft?u.from<=o.ch:u.from<o.ch))&&(null==u.to||(c.inclusiveRight?u.to>=o.ch:u.to>o.ch))){if(n&&(Cl(c,"beforeCursorEnter"),c.explicitlyCleared)){if(s.markedSpans){--a;continue}break}if(!c.atomic)continue;var f=c.find(0>l?-1:1);if(0==Ao(f,o)&&(f.ch+=l,f.ch<0?f=f.line>e.first?pe(e,No(f.line-1)):null:f.ch>s.text.length&&(f=f.line<e.first+e.size-1?No(f.line+1,0):null),!f)){if(i)return n?(e.cantEdit=!0,No(e.first,0)):We(e,t,r,!0);i=!0,f=t,l=-l}o=f;continue e}}return o}}function Oe(e){e.display.input.showSelection(e.display.input.prepareSelection())}function De(e,t){for(var r=e.doc,n={},i=n.cursors=document.createDocumentFragment(),o=n.selection=document.createDocumentFragment(),l=0;l<r.sel.ranges.length;l++)if(t!==!1||l!=r.sel.primIndex){var s=r.sel.ranges[l],a=s.empty();(a||e.options.showCursorWhenSelecting)&&He(e,s,i),a||Ie(e,s,o)}return n}function He(e,t,r){var n=ct(e,t.head,"div",null,null,!e.options.singleCursorHeightPerLine),i=r.appendChild(Pi("div"," ","CodeMirror-cursor"));if(i.style.left=n.left+"px",i.style.top=n.top+"px",i.style.height=Math.max(0,n.bottom-n.top)*e.options.cursorHeight+"px",n.other){var o=r.appendChild(Pi("div"," ","CodeMirror-cursor CodeMirror-secondarycursor"));o.style.display="",o.style.left=n.other.left+"px",o.style.top=n.other.top+"px",o.style.height=.85*(n.other.bottom-n.other.top)+"px"}}function Ie(e,t,r){function n(e,t,r,n){0>t&&(t=0),t=Math.round(t),n=Math.round(n),s.appendChild(Pi("div",null,"CodeMirror-selected","position: absolute; left: "+e+"px; top: "+t+"px; width: "+(null==r?c-e:r)+"px; height: "+(n-t)+"px"))}function i(t,r,i){function o(r,n){return ut(e,No(t,r),"div",f,n)}var s,a,f=Kn(l,t),h=f.text.length;return _i(Zn(f),r||0,null==i?h:i,function(e,t,l){var f,d,p,g=o(e,"left");if(e==t)f=g,d=p=g.left;else{if(f=o(t-1,"right"),"rtl"==l){var v=g;g=f,f=v}d=g.left,p=f.right}null==r&&0==e&&(d=u),f.top-g.top>3&&(n(d,g.top,null,g.bottom),d=u,g.bottom<f.top&&n(d,g.bottom,null,f.top)),null==i&&t==h&&(p=c),(!s||g.top<s.top||g.top==s.top&&g.left<s.left)&&(s=g),(!a||f.bottom>a.bottom||f.bottom==a.bottom&&f.right>a.right)&&(a=f),u+1>d&&(d=u),n(d,f.top,p-d,f.bottom)}),{start:s,end:a}}var o=e.display,l=e.doc,s=document.createDocumentFragment(),a=Ue(e.display),u=a.left,c=Math.max(o.sizerWidth,Ke(e)-o.sizer.offsetLeft)-a.right,f=t.from(),h=t.to();if(f.line==h.line)i(f.line,f.ch,h.ch);else{var d=Kn(l,f.line),p=Kn(l,h.line),g=fn(d)==fn(p),v=i(f.line,f.ch,g?d.text.length+1:null).end,m=i(h.line,g?0:null,h.ch).start;g&&(v.top<m.top-2?(n(v.right,v.top,null,v.bottom),n(u,m.top,m.left,m.bottom)):n(v.right,v.top,m.left-v.right,v.bottom)),v.bottom<m.top&&n(u,v.bottom,null,m.top)}r.appendChild(s)}function Pe(e){if(e.state.focused){var t=e.display;clearInterval(t.blinker);var r=!0;t.cursorDiv.style.visibility="",e.options.cursorBlinkRate>0?t.blinker=setInterval(function(){t.cursorDiv.style.visibility=(r=!r)?"":"hidden"},e.options.cursorBlinkRate):e.options.cursorBlinkRate<0&&(t.cursorDiv.style.visibility="hidden")}}function ze(e,t){e.doc.mode.startState&&e.doc.frontier<e.display.viewTo&&e.state.highlight.set(t,Oi(Ee,e))}function Ee(e){var t=e.doc;if(t.frontier<t.first&&(t.frontier=t.first),!(t.frontier>=e.display.viewTo)){var r=+new Date+e.options.workTime,n=Qo(t.mode,Re(e,t.frontier)),i=[];t.iter(t.frontier,Math.min(t.first+t.size,e.display.viewTo+500),function(o){if(t.frontier>=e.display.viewFrom){var l=o.styles,s=Mn(e,o,n,!0);o.styles=s.styles;var a=o.styleClasses,u=s.classes;u?o.styleClasses=u:a&&(o.styleClasses=null);for(var c=!l||l.length!=o.styles.length||a!=u&&(!a||!u||a.bgClass!=u.bgClass||a.textClass!=u.textClass),f=0;!c&&f<l.length;++f)c=l[f]!=o.styles[f];c&&i.push(t.frontier),o.stateAfter=Qo(t.mode,n)}else An(e,o.text,n),o.stateAfter=t.frontier%5==0?Qo(t.mode,n):null;return++t.frontier,+new Date>r?(ze(e,e.options.workDelay),!0):void 0}),i.length&&Tt(e,function(){for(var t=0;t<i.length;t++)Ht(e,i[t],"text")})}}function Fe(e,t,r){for(var n,i,o=e.doc,l=r?-1:t-(e.doc.mode.innerMode?1e3:100),s=t;s>l;--s){if(s<=o.first)return o.first;var a=Kn(o,s-1);if(a.stateAfter&&(!r||s<=o.frontier))return s;var u=Al(a.text,null,e.options.tabSize);(null==i||n>u)&&(i=s-1,n=u)}return i}function Re(e,t,r){var n=e.doc,i=e.display;if(!n.mode.startState)return!0;var o=Fe(e,t,r),l=o>n.first&&Kn(n,o-1).stateAfter;return l=l?Qo(n.mode,l):Jo(n.mode),n.iter(o,t,function(r){An(e,r.text,l);var s=o==t-1||o%5==0||o>=i.viewFrom&&o<i.viewTo;r.stateAfter=s?Qo(n.mode,l):null,++o}),r&&(n.frontier=o),l}function Be(e){return e.lineSpace.offsetTop}function Ge(e){return e.mover.offsetHeight-e.lineSpace.offsetHeight}function Ue(e){if(e.cachedPaddingH)return e.cachedPaddingH;var t=Ei(e.measure,Pi("pre","x")),r=window.getComputedStyle?window.getComputedStyle(t):t.currentStyle,n={left:parseInt(r.paddingLeft),right:parseInt(r.paddingRight)};return isNaN(n.left)||isNaN(n.right)||(e.cachedPaddingH=n),n}function Ve(e){return Ll-e.display.nativeBarWidth}function Ke(e){return e.display.scroller.clientWidth-Ve(e)-e.display.barWidth}function je(e){return e.display.scroller.clientHeight-Ve(e)-e.display.barHeight}function Xe(e,t,r){var n=e.options.lineWrapping,i=n&&Ke(e);if(!t.measure.heights||n&&t.measure.width!=i){var o=t.measure.heights=[];if(n){t.measure.width=i;for(var l=t.text.firstChild.getClientRects(),s=0;s<l.length-1;s++){var a=l[s],u=l[s+1];Math.abs(a.bottom-u.bottom)>2&&o.push((a.bottom+u.top)/2-r.top)}}o.push(r.bottom-r.top)}}function _e(e,t,r){if(e.line==t)return{map:e.measure.map,cache:e.measure.cache};for(var n=0;n<e.rest.length;n++)if(e.rest[n]==t)return{map:e.measure.maps[n],cache:e.measure.caches[n]};for(var n=0;n<e.rest.length;n++)if(Yn(e.rest[n])>r)return{map:e.measure.maps[n],cache:e.measure.caches[n],before:!0}}function Ye(e,t){t=fn(t);var r=Yn(t),n=e.display.externalMeasured=new Wt(e.doc,t,r);n.lineN=r;var i=n.built=On(e,n);return n.text=i.pre,Ei(e.display.lineMeasure,i.pre),n}function $e(e,t,r,n){return Qe(e,Ze(e,t),r,n)}function qe(e,t){if(t>=e.display.viewFrom&&t<e.display.viewTo)return e.display.view[Pt(e,t)];var r=e.display.externalMeasured;return r&&t>=r.lineN&&t<r.lineN+r.size?r:void 0}function Ze(e,t){var r=Yn(t),n=qe(e,r);n&&!n.text?n=null:n&&n.changes&&P(e,n,r,H(e)),n||(n=Ye(e,t));var i=_e(n,t,r);return{line:t,view:n,rect:null,map:i.map,cache:i.cache,before:i.before,hasHeights:!1}}function Qe(e,t,r,n,i){t.before&&(r=-1);var o,l=r+(n||"");return t.cache.hasOwnProperty(l)?o=t.cache[l]:(t.rect||(t.rect=t.view.text.getBoundingClientRect()),t.hasHeights||(Xe(e,t.view,t.rect),t.hasHeights=!0),o=et(e,t,r,n),o.bogus||(t.cache[l]=o)),{left:o.left,right:o.right,top:i?o.rtop:o.top,bottom:i?o.rbottom:o.bottom}}function Je(e,t,r){for(var n,i,o,l,s=0;s<e.length;s+=3){var a=e[s],u=e[s+1];if(a>t?(i=0,o=1,l="left"):u>t?(i=t-a,o=i+1):(s==e.length-3||t==u&&e[s+3]>t)&&(o=u-a,i=o-1,t>=u&&(l="right")),null!=i){if(n=e[s+2],a==u&&r==(n.insertLeft?"left":"right")&&(l=r),"left"==r&&0==i)for(;s&&e[s-2]==e[s-3]&&e[s-1].insertLeft;)n=e[(s-=3)+2],l="left";if("right"==r&&i==u-a)for(;s<e.length-3&&e[s+3]==e[s+4]&&!e[s+5].insertLeft;)n=e[(s+=3)+2],l="right";break}}return{node:n,start:i,end:o,collapse:l,coverStart:a,coverEnd:u}}function et(e,t,r,n){var i,o=Je(t.map,r,n),l=o.node,s=o.start,a=o.end,u=o.collapse;if(3==l.nodeType){for(var c=0;4>c;c++){for(;s&&Ii(t.line.text.charAt(o.coverStart+s));)--s;for(;o.coverStart+a<o.coverEnd&&Ii(t.line.text.charAt(o.coverStart+a));)++a;if(uo&&9>co&&0==s&&a==o.coverEnd-o.coverStart)i=l.parentNode.getBoundingClientRect();else if(uo&&e.options.lineWrapping){var f=Dl(l,s,a).getClientRects();i=f.length?f["right"==n?f.length-1:0]:Io}else i=Dl(l,s,a).getBoundingClientRect()||Io;if(i.left||i.right||0==s)break;a=s,s-=1,u="right"}uo&&11>co&&(i=tt(e.display.measure,i))}else{s>0&&(u=n="right");var f;i=e.options.lineWrapping&&(f=l.getClientRects()).length>1?f["right"==n?f.length-1:0]:l.getBoundingClientRect()}if(uo&&9>co&&!s&&(!i||!i.left&&!i.right)){var h=l.parentNode.getClientRects()[0];i=h?{left:h.left,right:h.left+vt(e.display),top:h.top,bottom:h.bottom}:Io}for(var d=i.top-t.rect.top,p=i.bottom-t.rect.top,g=(d+p)/2,v=t.view.measure.heights,c=0;c<v.length-1&&!(g<v[c]);c++);var m=c?v[c-1]:0,y=v[c],b={left:("right"==u?i.right:i.left)-t.rect.left,right:("left"==u?i.left:i.right)-t.rect.left,top:m,bottom:y};return i.left||i.right||(b.bogus=!0),e.options.singleCursorHeightPerLine||(b.rtop=d,
2
+ b.rbottom=p),b}function tt(e,t){if(!window.screen||null==screen.logicalXDPI||screen.logicalXDPI==screen.deviceXDPI||!Xi(e))return t;var r=screen.logicalXDPI/screen.deviceXDPI,n=screen.logicalYDPI/screen.deviceYDPI;return{left:t.left*r,right:t.right*r,top:t.top*n,bottom:t.bottom*n}}function rt(e){if(e.measure&&(e.measure.cache={},e.measure.heights=null,e.rest))for(var t=0;t<e.rest.length;t++)e.measure.caches[t]={}}function nt(e){e.display.externalMeasure=null,zi(e.display.lineMeasure);for(var t=0;t<e.display.view.length;t++)rt(e.display.view[t])}function it(e){nt(e),e.display.cachedCharWidth=e.display.cachedTextHeight=e.display.cachedPaddingH=null,e.options.lineWrapping||(e.display.maxLineChanged=!0),e.display.lineNumChars=null}function ot(){return window.pageXOffset||(document.documentElement||document.body).scrollLeft}function lt(){return window.pageYOffset||(document.documentElement||document.body).scrollTop}function st(e,t,r,n){if(t.widgets)for(var i=0;i<t.widgets.length;++i)if(t.widgets[i].above){var o=yn(t.widgets[i]);r.top+=o,r.bottom+=o}if("line"==n)return r;n||(n="local");var l=qn(t);if("local"==n?l+=Be(e.display):l-=e.display.viewOffset,"page"==n||"window"==n){var s=e.display.lineSpace.getBoundingClientRect();l+=s.top+("window"==n?0:lt());var a=s.left+("window"==n?0:ot());r.left+=a,r.right+=a}return r.top+=l,r.bottom+=l,r}function at(e,t,r){if("div"==r)return t;var n=t.left,i=t.top;if("page"==r)n-=ot(),i-=lt();else if("local"==r||!r){var o=e.display.sizer.getBoundingClientRect();n+=o.left,i+=o.top}var l=e.display.lineSpace.getBoundingClientRect();return{left:n-l.left,top:i-l.top}}function ut(e,t,r,n,i){return n||(n=Kn(e.doc,t.line)),st(e,n,$e(e,n,t.ch,i),r)}function ct(e,t,r,n,i,o){function l(t,l){var s=Qe(e,i,t,l?"right":"left",o);return l?s.left=s.right:s.right=s.left,st(e,n,s,r)}function s(e,t){var r=a[t],n=r.level%2;return e==Yi(r)&&t&&r.level<a[t-1].level?(r=a[--t],e=$i(r)-(r.level%2?0:1),n=!0):e==$i(r)&&t<a.length-1&&r.level<a[t+1].level&&(r=a[++t],e=Yi(r)-r.level%2,n=!1),n&&e==r.to&&e>r.from?l(e-1):l(e,n)}n=n||Kn(e.doc,t.line),i||(i=Ze(e,n));var a=Zn(n),u=t.ch;if(!a)return l(u);var c=ro(a,u),f=s(u,c);return null!=Yl&&(f.other=s(u,Yl)),f}function ft(e,t){var r=0,t=pe(e.doc,t);e.options.lineWrapping||(r=vt(e.display)*t.ch);var n=Kn(e.doc,t.line),i=qn(n)+Be(e.display);return{left:r,right:r,top:i,bottom:i+n.height}}function ht(e,t,r,n){var i=No(e,t);return i.xRel=n,r&&(i.outside=!0),i}function dt(e,t,r){var n=e.doc;if(r+=e.display.viewOffset,0>r)return ht(n.first,0,!0,-1);var i=$n(n,r),o=n.first+n.size-1;if(i>o)return ht(n.first+n.size-1,Kn(n,o).text.length,!0,1);0>t&&(t=0);for(var l=Kn(n,i);;){var s=pt(e,l,i,t,r),a=un(l),u=a&&a.find(0,!0);if(!a||!(s.ch>u.from.ch||s.ch==u.from.ch&&s.xRel>0))return s;i=Yn(l=u.to.line)}}function pt(e,t,r,n,i){function o(n){var i=ct(e,No(r,n),"line",t,u);return s=!0,l>i.bottom?i.left-a:l<i.top?i.left+a:(s=!1,i.left)}var l=i-qn(t),s=!1,a=2*e.display.wrapper.clientWidth,u=Ze(e,t),c=Zn(t),f=t.text.length,h=qi(t),d=Zi(t),p=o(h),g=s,v=o(d),m=s;if(n>v)return ht(r,d,m,1);for(;;){if(c?d==h||d==io(t,h,1):1>=d-h){for(var y=p>n||v-n>=n-p?h:d,b=n-(y==h?p:v);Ii(t.text.charAt(y));)++y;var w=ht(r,y,y==h?g:m,-1>b?-1:b>1?1:0);return w}var x=Math.ceil(f/2),C=h+x;if(c){C=h;for(var S=0;x>S;++S)C=io(t,C,1)}var L=o(C);L>n?(d=C,v=L,(m=s)&&(v+=1e3),f=x):(h=C,p=L,g=s,f-=x)}}function gt(e){if(null!=e.cachedTextHeight)return e.cachedTextHeight;if(null==Oo){Oo=Pi("pre");for(var t=0;49>t;++t)Oo.appendChild(document.createTextNode("x")),Oo.appendChild(Pi("br"));Oo.appendChild(document.createTextNode("x"))}Ei(e.measure,Oo);var r=Oo.offsetHeight/50;return r>3&&(e.cachedTextHeight=r),zi(e.measure),r||1}function vt(e){if(null!=e.cachedCharWidth)return e.cachedCharWidth;var t=Pi("span","xxxxxxxxxx"),r=Pi("pre",[t]);Ei(e.measure,r);var n=t.getBoundingClientRect(),i=(n.right-n.left)/10;return i>2&&(e.cachedCharWidth=i),i||10}function mt(e){e.curOp={cm:e,viewChanged:!1,startHeight:e.doc.height,forceUpdate:!1,updateInput:null,typing:!1,changeObjs:null,cursorActivityHandlers:null,cursorActivityCalled:0,selectionChanged:!1,updateMaxLine:!1,scrollLeft:null,scrollTop:null,scrollToPos:null,id:++zo},Po?Po.ops.push(e.curOp):e.curOp.ownsGroup=Po={ops:[e.curOp],delayedCallbacks:[]}}function yt(e){var t=e.delayedCallbacks,r=0;do{for(;r<t.length;r++)t[r]();for(var n=0;n<e.ops.length;n++){var i=e.ops[n];if(i.cursorActivityHandlers)for(;i.cursorActivityCalled<i.cursorActivityHandlers.length;)i.cursorActivityHandlers[i.cursorActivityCalled++](i.cm)}}while(r<t.length)}function bt(e){var t=e.curOp,r=t.ownsGroup;if(r)try{yt(r)}finally{Po=null;for(var n=0;n<r.ops.length;n++)r.ops[n].cm.curOp=null;wt(r)}}function wt(e){for(var t=e.ops,r=0;r<t.length;r++)xt(t[r]);for(var r=0;r<t.length;r++)Ct(t[r]);for(var r=0;r<t.length;r++)St(t[r]);for(var r=0;r<t.length;r++)Lt(t[r]);for(var r=0;r<t.length;r++)kt(t[r])}function xt(e){var t=e.cm,r=t.display;T(t),e.updateMaxLine&&h(t),e.mustUpdate=e.viewChanged||e.forceUpdate||null!=e.scrollTop||e.scrollToPos&&(e.scrollToPos.from.line<r.viewFrom||e.scrollToPos.to.line>=r.viewTo)||r.maxLineChanged&&t.options.lineWrapping,e.update=e.mustUpdate&&new k(t,e.mustUpdate&&{top:e.scrollTop,ensure:e.scrollToPos},e.forceUpdate)}function Ct(e){e.updatedDisplay=e.mustUpdate&&M(e.cm,e.update)}function St(e){var t=e.cm,r=t.display;e.updatedDisplay&&O(t),e.barMeasure=p(t),r.maxLineChanged&&!t.options.lineWrapping&&(e.adjustWidthTo=$e(t,r.maxLine,r.maxLine.text.length).left+3,t.display.sizerWidth=e.adjustWidthTo,e.barMeasure.scrollWidth=Math.max(r.scroller.clientWidth,r.sizer.offsetLeft+e.adjustWidthTo+Ve(t)+t.display.barWidth),e.maxScrollLeft=Math.max(0,r.sizer.offsetLeft+e.adjustWidthTo-Ke(t))),(e.updatedDisplay||e.selectionChanged)&&(e.preparedSelection=r.input.prepareSelection())}function Lt(e){var t=e.cm;null!=e.adjustWidthTo&&(t.display.sizer.style.minWidth=e.adjustWidthTo+"px",e.maxScrollLeft<t.doc.scrollLeft&&Qt(t,Math.min(t.display.scroller.scrollLeft,e.maxScrollLeft),!0),t.display.maxLineChanged=!1),e.preparedSelection&&t.display.input.showSelection(e.preparedSelection),e.updatedDisplay&&W(t,e.barMeasure),(e.updatedDisplay||e.startHeight!=t.doc.height)&&y(t,e.barMeasure),e.selectionChanged&&Pe(t),t.state.focused&&e.updateInput&&t.display.input.reset(e.typing)}function kt(e){var t=e.cm,r=t.display,n=t.doc;if(e.updatedDisplay&&N(t,e.update),null==r.wheelStartX||null==e.scrollTop&&null==e.scrollLeft&&!e.scrollToPos||(r.wheelStartX=r.wheelStartY=null),null==e.scrollTop||r.scroller.scrollTop==e.scrollTop&&!e.forceScroll||(n.scrollTop=Math.max(0,Math.min(r.scroller.scrollHeight-r.scroller.clientHeight,e.scrollTop)),r.scrollbars.setScrollTop(n.scrollTop),r.scroller.scrollTop=n.scrollTop),null==e.scrollLeft||r.scroller.scrollLeft==e.scrollLeft&&!e.forceScroll||(n.scrollLeft=Math.max(0,Math.min(r.scroller.scrollWidth-Ke(t),e.scrollLeft)),r.scrollbars.setScrollLeft(n.scrollLeft),r.scroller.scrollLeft=n.scrollLeft,x(t)),e.scrollToPos){var i=Tr(t,pe(n,e.scrollToPos.from),pe(n,e.scrollToPos.to),e.scrollToPos.margin);e.scrollToPos.isCursor&&t.state.focused&&kr(t,i)}var o=e.maybeHiddenMarkers,l=e.maybeUnhiddenMarkers;if(o)for(var s=0;s<o.length;++s)o[s].lines.length||Cl(o[s],"hide");if(l)for(var s=0;s<l.length;++s)l[s].lines.length&&Cl(l[s],"unhide");r.wrapper.offsetHeight&&(n.scrollTop=t.display.scroller.scrollTop),e.changeObjs&&Cl(t,"changes",t,e.changeObjs),e.update&&e.update.finish()}function Tt(e,t){if(e.curOp)return t();mt(e);try{return t()}finally{bt(e)}}function Mt(e,t){return function(){if(e.curOp)return t.apply(e,arguments);mt(e);try{return t.apply(e,arguments)}finally{bt(e)}}}function Nt(e){return function(){if(this.curOp)return e.apply(this,arguments);mt(this);try{return e.apply(this,arguments)}finally{bt(this)}}}function At(e){return function(){var t=this.cm;if(!t||t.curOp)return e.apply(this,arguments);mt(t);try{return e.apply(this,arguments)}finally{bt(t)}}}function Wt(e,t,r){this.line=t,this.rest=hn(t),this.size=this.rest?Yn(ki(this.rest))-r+1:1,this.node=this.text=null,this.hidden=gn(e,t)}function Ot(e,t,r){for(var n,i=[],o=t;r>o;o=n){var l=new Wt(e.doc,Kn(e.doc,o),o);n=o+l.size,i.push(l)}return i}function Dt(e,t,r,n){null==t&&(t=e.doc.first),null==r&&(r=e.doc.first+e.doc.size),n||(n=0);var i=e.display;if(n&&r<i.viewTo&&(null==i.updateLineNumbers||i.updateLineNumbers>t)&&(i.updateLineNumbers=t),e.curOp.viewChanged=!0,t>=i.viewTo)Mo&&dn(e.doc,t)<i.viewTo&&It(e);else if(r<=i.viewFrom)Mo&&pn(e.doc,r+n)>i.viewFrom?It(e):(i.viewFrom+=n,i.viewTo+=n);else if(t<=i.viewFrom&&r>=i.viewTo)It(e);else if(t<=i.viewFrom){var o=zt(e,r,r+n,1);o?(i.view=i.view.slice(o.index),i.viewFrom=o.lineN,i.viewTo+=n):It(e)}else if(r>=i.viewTo){var o=zt(e,t,t,-1);o?(i.view=i.view.slice(0,o.index),i.viewTo=o.lineN):It(e)}else{var l=zt(e,t,t,-1),s=zt(e,r,r+n,1);l&&s?(i.view=i.view.slice(0,l.index).concat(Ot(e,l.lineN,s.lineN)).concat(i.view.slice(s.index)),i.viewTo+=n):It(e)}var a=i.externalMeasured;a&&(r<a.lineN?a.lineN+=n:t<a.lineN+a.size&&(i.externalMeasured=null))}function Ht(e,t,r){e.curOp.viewChanged=!0;var n=e.display,i=e.display.externalMeasured;if(i&&t>=i.lineN&&t<i.lineN+i.size&&(n.externalMeasured=null),!(t<n.viewFrom||t>=n.viewTo)){var o=n.view[Pt(e,t)];if(null!=o.node){var l=o.changes||(o.changes=[]);-1==Ti(l,r)&&l.push(r)}}}function It(e){e.display.viewFrom=e.display.viewTo=e.doc.first,e.display.view=[],e.display.viewOffset=0}function Pt(e,t){if(t>=e.display.viewTo)return null;if(t-=e.display.viewFrom,0>t)return null;for(var r=e.display.view,n=0;n<r.length;n++)if(t-=r[n].size,0>t)return n}function zt(e,t,r,n){var i,o=Pt(e,t),l=e.display.view;if(!Mo||r==e.doc.first+e.doc.size)return{index:o,lineN:r};for(var s=0,a=e.display.viewFrom;o>s;s++)a+=l[s].size;if(a!=t){if(n>0){if(o==l.length-1)return null;i=a+l[o].size-t,o++}else i=a-t;t+=i,r+=i}for(;dn(e.doc,r)!=r;){if(o==(0>n?0:l.length-1))return null;r+=n*l[o-(0>n?1:0)].size,o+=n}return{index:o,lineN:r}}function Et(e,t,r){var n=e.display,i=n.view;0==i.length||t>=n.viewTo||r<=n.viewFrom?(n.view=Ot(e,t,r),n.viewFrom=t):(n.viewFrom>t?n.view=Ot(e,t,n.viewFrom).concat(n.view):n.viewFrom<t&&(n.view=n.view.slice(Pt(e,t))),n.viewFrom=t,n.viewTo<r?n.view=n.view.concat(Ot(e,n.viewTo,r)):n.viewTo>r&&(n.view=n.view.slice(0,Pt(e,r)))),n.viewTo=r}function Ft(e){for(var t=e.display.view,r=0,n=0;n<t.length;n++){var i=t[n];i.hidden||i.node&&!i.changes||++r}return r}function Rt(e){function t(){o.activeTouch&&(l=setTimeout(function(){o.activeTouch=null},1e3),s=o.activeTouch,s.end=+new Date)}function r(e){if(1!=e.touches.length)return!1;var t=e.touches[0];return t.radiusX<=1&&t.radiusY<=1}function n(e,t){if(null==t.left)return!0;var r=t.left-e.left,n=t.top-e.top;return r*r+n*n>400}function i(t){yi(e,t)||bl(t)}var o=e.display;wl(o.scroller,"mousedown",Mt(e,Vt)),uo&&11>co?wl(o.scroller,"dblclick",Mt(e,function(t){if(!yi(e,t)){var r=Ut(e,t);if(r&&!Yt(e,t)&&!Gt(e.display,t)){ml(t);var n=e.findWordAt(r);be(e.doc,n.anchor,n.head)}}})):wl(o.scroller,"dblclick",function(t){yi(e,t)||ml(t)}),ko||wl(o.scroller,"contextmenu",function(t){fr(e,t)});var l,s={end:0};wl(o.scroller,"touchstart",function(e){if(!r(e)){clearTimeout(l);var t=+new Date;o.activeTouch={start:t,moved:!1,prev:t-s.end<=300?s:null},1==e.touches.length&&(o.activeTouch.left=e.touches[0].pageX,o.activeTouch.top=e.touches[0].pageY)}}),wl(o.scroller,"touchmove",function(){o.activeTouch&&(o.activeTouch.moved=!0)}),wl(o.scroller,"touchend",function(r){var i=o.activeTouch;if(i&&!Gt(o,r)&&null!=i.left&&!i.moved&&new Date-i.start<300){var l,s=e.coordsChar(o.activeTouch,"page");l=!i.prev||n(i,i.prev)?new ce(s,s):!i.prev.prev||n(i,i.prev.prev)?e.findWordAt(s):new ce(No(s.line,0),pe(e.doc,No(s.line+1,0))),e.setSelection(l.anchor,l.head),e.focus(),ml(r)}t()}),wl(o.scroller,"touchcancel",t),wl(o.scroller,"scroll",function(){o.scroller.clientHeight&&(Zt(e,o.scroller.scrollTop),Qt(e,o.scroller.scrollLeft,!0),Cl(e,"scroll",e))}),wl(o.scroller,"mousewheel",function(t){Jt(e,t)}),wl(o.scroller,"DOMMouseScroll",function(t){Jt(e,t)}),wl(o.wrapper,"scroll",function(){o.wrapper.scrollTop=o.wrapper.scrollLeft=0}),e.options.dragDrop&&(wl(o.scroller,"dragstart",function(t){qt(e,t)}),wl(o.scroller,"dragenter",i),wl(o.scroller,"dragover",i),wl(o.scroller,"drop",Mt(e,$t)));var a=o.input.getField();wl(a,"keyup",function(t){sr.call(e,t)}),wl(a,"keydown",Mt(e,or)),wl(a,"keypress",Mt(e,ar)),wl(a,"focus",Oi(ur,e)),wl(a,"blur",Oi(cr,e))}function Bt(e){var t=e.display;(t.lastWrapHeight!=t.wrapper.clientHeight||t.lastWrapWidth!=t.wrapper.clientWidth)&&(t.cachedCharWidth=t.cachedTextHeight=t.cachedPaddingH=null,t.scrollbarsClipped=!1,e.setSize())}function Gt(e,t){for(var r=pi(t);r!=e.wrapper;r=r.parentNode)if(!r||1==r.nodeType&&"true"==r.getAttribute("cm-ignore-events")||r.parentNode==e.sizer&&r!=e.mover)return!0}function Ut(e,t,r,n){var i=e.display;if(!r&&"true"==pi(t).getAttribute("cm-not-content"))return null;var o,l,s=i.lineSpace.getBoundingClientRect();try{o=t.clientX-s.left,l=t.clientY-s.top}catch(t){return null}var a,u=dt(e,o,l);if(n&&1==u.xRel&&(a=Kn(e.doc,u.line).text).length==u.ch){var c=Al(a,a.length,e.options.tabSize)-a.length;u=No(u.line,Math.max(0,Math.round((o-Ue(e.display).left)/vt(e.display))-c))}return u}function Vt(e){var t=this,r=t.display;if(!(r.activeTouch&&r.input.supportsTouch()||yi(t,e))){if(r.shift=e.shiftKey,Gt(r,e))return void(fo||(r.scroller.draggable=!1,setTimeout(function(){r.scroller.draggable=!0},100)));if(!Yt(t,e)){var n=Ut(t,e);switch(window.focus(),gi(e)){case 1:n?Kt(t,e,n):pi(e)==r.scroller&&ml(e);break;case 2:fo&&(t.state.lastMiddleDown=+new Date),n&&be(t.doc,n),setTimeout(function(){r.input.focus()},20),ml(e);break;case 3:ko&&fr(t,e)}}}}function Kt(e,t,r){uo?setTimeout(Oi(q,e),0):q(e);var n,i=+new Date;Ho&&Ho.time>i-400&&0==Ao(Ho.pos,r)?n="triple":Do&&Do.time>i-400&&0==Ao(Do.pos,r)?(n="double",Ho={time:i,pos:r}):(n="single",Do={time:i,pos:r});var o,l=e.doc.sel,s=xo?t.metaKey:t.ctrlKey;e.options.dragDrop&&Ul&&!Z(e)&&"single"==n&&(o=l.contains(r))>-1&&!l.ranges[o].empty()?jt(e,t,r,s):Xt(e,t,r,n,s)}function jt(e,t,r,n){var i=e.display,o=Mt(e,function(l){fo&&(i.scroller.draggable=!1),e.state.draggingText=!1,xl(document,"mouseup",o),xl(i.scroller,"drop",o),Math.abs(t.clientX-l.clientX)+Math.abs(t.clientY-l.clientY)<10&&(ml(l),n||be(e.doc,r),i.input.focus(),uo&&9==co&&setTimeout(function(){document.body.focus(),i.input.focus()},20))});fo&&(i.scroller.draggable=!0),e.state.draggingText=o,i.scroller.dragDrop&&i.scroller.dragDrop(),wl(document,"mouseup",o),wl(i.scroller,"drop",o)}function Xt(e,t,r,n,i){function o(t){if(0!=Ao(v,t))if(v=t,"rect"==n){for(var i=[],o=e.options.tabSize,l=Al(Kn(u,r.line).text,r.ch,o),s=Al(Kn(u,t.line).text,t.ch,o),a=Math.min(l,s),d=Math.max(l,s),p=Math.min(r.line,t.line),g=Math.min(e.lastLine(),Math.max(r.line,t.line));g>=p;p++){var m=Kn(u,p).text,y=Si(m,a,o);a==d?i.push(new ce(No(p,y),No(p,y))):m.length>y&&i.push(new ce(No(p,y),No(p,Si(m,d,o))))}i.length||i.push(new ce(r,r)),ke(u,fe(h.ranges.slice(0,f).concat(i),f),{origin:"*mouse",scroll:!1}),e.scrollIntoView(t)}else{var b=c,w=b.anchor,x=t;if("single"!=n){if("double"==n)var C=e.findWordAt(t);else var C=new ce(No(t.line,0),pe(u,No(t.line+1,0)));Ao(C.anchor,w)>0?(x=C.head,w=$(b.from(),C.anchor)):(x=C.anchor,w=Y(b.to(),C.head))}var i=h.ranges.slice(0);i[f]=new ce(pe(u,w),x),ke(u,fe(i,f),Ml)}}function l(t){var r=++y,i=Ut(e,t,!0,"rect"==n);if(i)if(0!=Ao(i,v)){q(e),o(i);var s=w(a,u);(i.line>=s.to||i.line<s.from)&&setTimeout(Mt(e,function(){y==r&&l(t)}),150)}else{var c=t.clientY<m.top?-20:t.clientY>m.bottom?20:0;c&&setTimeout(Mt(e,function(){y==r&&(a.scroller.scrollTop+=c,l(t))}),50)}}function s(e){y=1/0,ml(e),a.input.focus(),xl(document,"mousemove",b),xl(document,"mouseup",x),u.history.lastSelOrigin=null}var a=e.display,u=e.doc;ml(t);var c,f,h=u.sel,d=h.ranges;if(i&&!t.shiftKey?(f=u.sel.contains(r),c=f>-1?d[f]:new ce(r,r)):c=u.sel.primary(),t.altKey)n="rect",i||(c=new ce(r,r)),r=Ut(e,t,!0,!0),f=-1;else if("double"==n){var p=e.findWordAt(r);c=e.display.shift||u.extend?ye(u,c,p.anchor,p.head):p}else if("triple"==n){var g=new ce(No(r.line,0),pe(u,No(r.line+1,0)));c=e.display.shift||u.extend?ye(u,c,g.anchor,g.head):g}else c=ye(u,c,r);i?-1==f?(f=d.length,ke(u,fe(d.concat([c]),f),{scroll:!1,origin:"*mouse"})):d.length>1&&d[f].empty()&&"single"==n?(ke(u,fe(d.slice(0,f).concat(d.slice(f+1)),0)),h=u.sel):xe(u,f,c,Ml):(f=0,ke(u,new ue([c],0),Ml),h=u.sel);var v=r,m=a.wrapper.getBoundingClientRect(),y=0,b=Mt(e,function(e){gi(e)?l(e):s(e)}),x=Mt(e,s);wl(document,"mousemove",b),wl(document,"mouseup",x)}function _t(e,t,r,n,i){try{var o=t.clientX,l=t.clientY}catch(t){return!1}if(o>=Math.floor(e.display.gutters.getBoundingClientRect().right))return!1;n&&ml(t);var s=e.display,a=s.lineDiv.getBoundingClientRect();if(l>a.bottom||!wi(e,r))return di(t);l-=a.top-s.viewOffset;for(var u=0;u<e.options.gutters.length;++u){var c=s.gutters.childNodes[u];if(c&&c.getBoundingClientRect().right>=o){var f=$n(e.doc,l),h=e.options.gutters[u];return i(e,r,e,f,h,t),di(t)}}}function Yt(e,t){return _t(e,t,"gutterClick",!0,vi)}function $t(e){var t=this;if(!yi(t,e)&&!Gt(t.display,e)){ml(e),uo&&(Eo=+new Date);var r=Ut(t,e,!0),n=e.dataTransfer.files;if(r&&!Z(t))if(n&&n.length&&window.FileReader&&window.File)for(var i=n.length,o=Array(i),l=0,s=function(e,n){var s=new FileReader;s.onload=Mt(t,function(){if(o[n]=s.result,++l==i){r=pe(t.doc,r);var e={from:r,to:r,text:Vl(o.join("\n")),origin:"paste"};yr(t.doc,e),Le(t.doc,he(r,Vo(e)))}}),s.readAsText(e)},a=0;i>a;++a)s(n[a],a);else{if(t.state.draggingText&&t.doc.sel.contains(r)>-1)return t.state.draggingText(e),void setTimeout(function(){t.display.input.focus()},20);try{var o=e.dataTransfer.getData("Text");if(o){if(t.state.draggingText&&!(xo?e.metaKey:e.ctrlKey))var u=t.listSelections();if(Te(t.doc,he(r,r)),u)for(var a=0;a<u.length;++a)Lr(t.doc,"",u[a].anchor,u[a].head,"drag");t.replaceSelection(o,"around","paste"),t.display.input.focus()}}catch(e){}}}}function qt(e,t){if(uo&&(!e.state.draggingText||+new Date-Eo<100))return void bl(t);if(!yi(e,t)&&!Gt(e.display,t)&&(t.dataTransfer.setData("Text",e.getSelection()),t.dataTransfer.setDragImage&&!vo)){var r=Pi("img",null,null,"position: fixed; left: 0; top: 0;");r.src="data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==",go&&(r.width=r.height=1,e.display.wrapper.appendChild(r),r._top=r.offsetTop),t.dataTransfer.setDragImage(r,0,0),go&&r.parentNode.removeChild(r)}}function Zt(e,t){Math.abs(e.doc.scrollTop-t)<2||(e.doc.scrollTop=t,lo||A(e,{top:t}),e.display.scroller.scrollTop!=t&&(e.display.scroller.scrollTop=t),e.display.scrollbars.setScrollTop(t),lo&&A(e),ze(e,100))}function Qt(e,t,r){(r?t==e.doc.scrollLeft:Math.abs(e.doc.scrollLeft-t)<2)||(t=Math.min(t,e.display.scroller.scrollWidth-e.display.scroller.clientWidth),e.doc.scrollLeft=t,x(e),e.display.scroller.scrollLeft!=t&&(e.display.scroller.scrollLeft=t),e.display.scrollbars.setScrollLeft(t))}function Jt(e,t){var r=Bo(t),n=r.x,i=r.y,o=e.display,l=o.scroller;if(n&&l.scrollWidth>l.clientWidth||i&&l.scrollHeight>l.clientHeight){if(i&&xo&&fo)e:for(var s=t.target,a=o.view;s!=l;s=s.parentNode)for(var u=0;u<a.length;u++)if(a[u].node==s){e.display.currentWheelTarget=s;break e}if(n&&!lo&&!go&&null!=Ro)return i&&Zt(e,Math.max(0,Math.min(l.scrollTop+i*Ro,l.scrollHeight-l.clientHeight))),Qt(e,Math.max(0,Math.min(l.scrollLeft+n*Ro,l.scrollWidth-l.clientWidth))),ml(t),void(o.wheelStartX=null);if(i&&null!=Ro){var c=i*Ro,f=e.doc.scrollTop,h=f+o.wrapper.clientHeight;0>c?f=Math.max(0,f+c-50):h=Math.min(e.doc.height,h+c+50),A(e,{top:f,bottom:h})}20>Fo&&(null==o.wheelStartX?(o.wheelStartX=l.scrollLeft,o.wheelStartY=l.scrollTop,o.wheelDX=n,o.wheelDY=i,setTimeout(function(){if(null!=o.wheelStartX){var e=l.scrollLeft-o.wheelStartX,t=l.scrollTop-o.wheelStartY,r=t&&o.wheelDY&&t/o.wheelDY||e&&o.wheelDX&&e/o.wheelDX;o.wheelStartX=o.wheelStartY=null,r&&(Ro=(Ro*Fo+r)/(Fo+1),++Fo)}},200)):(o.wheelDX+=n,o.wheelDY+=i))}}function er(e,t,r){if("string"==typeof t&&(t=el[t],!t))return!1;e.display.input.ensurePolled();var n=e.display.shift,i=!1;try{Z(e)&&(e.state.suppressEdits=!0),r&&(e.display.shift=!1),i=t(e)!=kl}finally{e.display.shift=n,e.state.suppressEdits=!1}return i}function tr(e,t,r){for(var n=0;n<e.state.keyMaps.length;n++){var i=rl(t,e.state.keyMaps[n],r,e);if(i)return i}return e.options.extraKeys&&rl(t,e.options.extraKeys,r,e)||rl(t,e.options.keyMap,r,e)}function rr(e,t,r,n){var i=e.state.keySeq;if(i){if(nl(t))return"handled";Go.set(50,function(){e.state.keySeq==i&&(e.state.keySeq=null,e.display.input.reset())}),t=i+" "+t}var o=tr(e,t,n);return"multi"==o&&(e.state.keySeq=t),"handled"==o&&vi(e,"keyHandled",e,t,r),("handled"==o||"multi"==o)&&(ml(r),Pe(e)),i&&!o&&/\'$/.test(t)?(ml(r),!0):!!o}function nr(e,t){var r=il(t,!0);return r?t.shiftKey&&!e.state.keySeq?rr(e,"Shift-"+r,t,function(t){return er(e,t,!0)})||rr(e,r,t,function(t){return("string"==typeof t?/^go[A-Z]/.test(t):t.motion)?er(e,t):void 0}):rr(e,r,t,function(t){return er(e,t)}):!1}function ir(e,t,r){return rr(e,"'"+r+"'",t,function(t){return er(e,t,!0)})}function or(e){var t=this;if(q(t),!yi(t,e)){uo&&11>co&&27==e.keyCode&&(e.returnValue=!1);var r=e.keyCode;t.display.shift=16==r||e.shiftKey;var n=nr(t,e);go&&(Uo=n?r:null,!n&&88==r&&!jl&&(xo?e.metaKey:e.ctrlKey)&&t.replaceSelection("",null,"cut")),18!=r||/\bCodeMirror-crosshair\b/.test(t.display.lineDiv.className)||lr(t)}}function lr(e){function t(e){18!=e.keyCode&&e.altKey||(Rl(r,"CodeMirror-crosshair"),xl(document,"keyup",t),xl(document,"mouseover",t))}var r=e.display.lineDiv;Bl(r,"CodeMirror-crosshair"),wl(document,"keyup",t),wl(document,"mouseover",t)}function sr(e){16==e.keyCode&&(this.doc.sel.shift=!1),yi(this,e)}function ar(e){var t=this;if(!(Gt(t.display,e)||yi(t,e)||e.ctrlKey&&!e.altKey||xo&&e.metaKey)){var r=e.keyCode,n=e.charCode;if(go&&r==Uo)return Uo=null,void ml(e);if(!go||e.which&&!(e.which<10)||!nr(t,e)){var i=String.fromCharCode(null==n?r:n);ir(t,e,i)||t.display.input.onKeyPress(e)}}}function ur(e){"nocursor"!=e.options.readOnly&&(e.state.focused||(Cl(e,"focus",e),e.state.focused=!0,Bl(e.display.wrapper,"CodeMirror-focused"),e.curOp||e.display.selForContextMenu==e.doc.sel||(e.display.input.reset(),fo&&setTimeout(function(){e.display.input.reset(!0)},20)),e.display.input.receivedFocus()),Pe(e))}function cr(e){e.state.focused&&(Cl(e,"blur",e),e.state.focused=!1,Rl(e.display.wrapper,"CodeMirror-focused")),clearInterval(e.display.blinker),setTimeout(function(){e.state.focused||(e.display.shift=!1)},150)}function fr(e,t){Gt(e.display,t)||hr(e,t)||e.display.input.onContextMenu(t)}function hr(e,t){return wi(e,"gutterContextMenu")?_t(e,t,"gutterContextMenu",!1,Cl):!1}function dr(e,t){if(Ao(e,t.from)<0)return e;if(Ao(e,t.to)<=0)return Vo(t);var r=e.line+t.text.length-(t.to.line-t.from.line)-1,n=e.ch;return e.line==t.to.line&&(n+=Vo(t).ch-t.to.ch),No(r,n)}function pr(e,t){for(var r=[],n=0;n<e.sel.ranges.length;n++){var i=e.sel.ranges[n];r.push(new ce(dr(i.anchor,t),dr(i.head,t)))}return fe(r,e.sel.primIndex)}function gr(e,t,r){return e.line==t.line?No(r.line,e.ch-t.ch+r.ch):No(r.line+(e.line-t.line),e.ch)}function vr(e,t,r){for(var n=[],i=No(e.first,0),o=i,l=0;l<t.length;l++){var s=t[l],a=gr(s.from,i,o),u=gr(Vo(s),i,o);if(i=s.to,o=u,"around"==r){var c=e.sel.ranges[l],f=Ao(c.head,c.anchor)<0;n[l]=new ce(f?u:a,f?a:u)}else n[l]=new ce(a,a)}return new ue(n,e.sel.primIndex)}function mr(e,t,r){var n={canceled:!1,from:t.from,to:t.to,text:t.text,origin:t.origin,cancel:function(){this.canceled=!0}};return r&&(n.update=function(t,r,n,i){t&&(this.from=pe(e,t)),r&&(this.to=pe(e,r)),n&&(this.text=n),void 0!==i&&(this.origin=i)}),Cl(e,"beforeChange",e,n),e.cm&&Cl(e.cm,"beforeChange",e.cm,n),n.canceled?null:{from:n.from,to:n.to,text:n.text,origin:n.origin}}function yr(e,t,r){if(e.cm){if(!e.cm.curOp)return Mt(e.cm,yr)(e,t,r);if(e.cm.state.suppressEdits)return}if(!(wi(e,"beforeChange")||e.cm&&wi(e.cm,"beforeChange"))||(t=mr(e,t,!0))){var n=To&&!r&&en(e,t.from,t.to);if(n)for(var i=n.length-1;i>=0;--i)br(e,{from:n[i].from,to:n[i].to,text:i?[""]:t.text});else br(e,t)}}function br(e,t){if(1!=t.text.length||""!=t.text[0]||0!=Ao(t.from,t.to)){var r=pr(e,t);ri(e,t,r,e.cm?e.cm.curOp.id:NaN),Cr(e,t,r,Zr(e,t));var n=[];Un(e,function(e,r){r||-1!=Ti(n,e.history)||(hi(e.history,t),n.push(e.history)),Cr(e,t,null,Zr(e,t))})}}function wr(e,t,r){if(!e.cm||!e.cm.state.suppressEdits){for(var n,i=e.history,o=e.sel,l="undo"==t?i.done:i.undone,s="undo"==t?i.undone:i.done,a=0;a<l.length&&(n=l[a],r?!n.ranges||n.equals(e.sel):n.ranges);a++);if(a!=l.length){for(i.lastOrigin=i.lastSelOrigin=null;n=l.pop(),n.ranges;){if(oi(n,s),r&&!n.equals(e.sel))return void ke(e,n,{clearRedo:!1});o=n}var u=[];oi(o,s),s.push({changes:u,generation:i.generation}),i.generation=n.generation||++i.maxGeneration;for(var c=wi(e,"beforeChange")||e.cm&&wi(e.cm,"beforeChange"),a=n.changes.length-1;a>=0;--a){var f=n.changes[a];if(f.origin=t,c&&!mr(e,f,!1))return void(l.length=0);u.push(Jn(e,f));var h=a?pr(e,f):ki(l);Cr(e,f,h,Jr(e,f)),!a&&e.cm&&e.cm.scrollIntoView({from:f.from,to:Vo(f)});var d=[];Un(e,function(e,t){t||-1!=Ti(d,e.history)||(hi(e.history,f),d.push(e.history)),Cr(e,f,null,Jr(e,f))})}}}}function xr(e,t){if(0!=t&&(e.first+=t,e.sel=new ue(Mi(e.sel.ranges,function(e){return new ce(No(e.anchor.line+t,e.anchor.ch),No(e.head.line+t,e.head.ch))}),e.sel.primIndex),e.cm)){Dt(e.cm,e.first,e.first-t,t);for(var r=e.cm.display,n=r.viewFrom;n<r.viewTo;n++)Ht(e.cm,n,"gutter")}}function Cr(e,t,r,n){if(e.cm&&!e.cm.curOp)return Mt(e.cm,Cr)(e,t,r,n);if(t.to.line<e.first)return void xr(e,t.text.length-1-(t.to.line-t.from.line));if(!(t.from.line>e.lastLine())){if(t.from.line<e.first){var i=t.text.length-1-(e.first-t.from.line);xr(e,i),t={from:No(e.first,0),to:No(t.to.line+i,t.to.ch),text:[ki(t.text)],origin:t.origin}}var o=e.lastLine();t.to.line>o&&(t={from:t.from,to:No(o,Kn(e,o).text.length),text:[t.text[0]],origin:t.origin}),t.removed=jn(e,t.from,t.to),r||(r=pr(e,t)),e.cm?Sr(e.cm,t,n):Rn(e,t,n),Te(e,r,Tl)}}function Sr(e,t,r){var n=e.doc,i=e.display,l=t.from,s=t.to,a=!1,u=l.line;e.options.lineWrapping||(u=Yn(fn(Kn(n,l.line))),n.iter(u,s.line+1,function(e){return e==i.maxLine?(a=!0,!0):void 0})),n.sel.contains(t.from,t.to)>-1&&bi(e),Rn(n,t,r,o(e)),e.options.lineWrapping||(n.iter(u,l.line+t.text.length,function(e){var t=f(e);t>i.maxLineLength&&(i.maxLine=e,i.maxLineLength=t,i.maxLineChanged=!0,a=!1)}),a&&(e.curOp.updateMaxLine=!0)),n.frontier=Math.min(n.frontier,l.line),ze(e,400);var c=t.text.length-(s.line-l.line)-1;t.full?Dt(e):l.line!=s.line||1!=t.text.length||Fn(e.doc,t)?Dt(e,l.line,s.line+1,c):Ht(e,l.line,"text");var h=wi(e,"changes"),d=wi(e,"change");if(d||h){var p={from:l,to:s,text:t.text,removed:t.removed,origin:t.origin};d&&vi(e,"change",e,p),h&&(e.curOp.changeObjs||(e.curOp.changeObjs=[])).push(p)}e.display.selForContextMenu=null}function Lr(e,t,r,n,i){if(n||(n=r),Ao(n,r)<0){var o=n;n=r,r=o}"string"==typeof t&&(t=Vl(t)),yr(e,{from:r,to:n,text:t,origin:i})}function kr(e,t){if(!yi(e,"scrollCursorIntoView")){var r=e.display,n=r.sizer.getBoundingClientRect(),i=null;if(t.top+n.top<0?i=!0:t.bottom+n.top>(window.innerHeight||document.documentElement.clientHeight)&&(i=!1),null!=i&&!yo){var o=Pi("div","​",null,"position: absolute; top: "+(t.top-r.viewOffset-Be(e.display))+"px; height: "+(t.bottom-t.top+Ve(e)+r.barHeight)+"px; left: "+t.left+"px; width: 2px;");e.display.lineSpace.appendChild(o),o.scrollIntoView(i),e.display.lineSpace.removeChild(o)}}}function Tr(e,t,r,n){null==n&&(n=0);for(var i=0;5>i;i++){var o=!1,l=ct(e,t),s=r&&r!=t?ct(e,r):l,a=Nr(e,Math.min(l.left,s.left),Math.min(l.top,s.top)-n,Math.max(l.left,s.left),Math.max(l.bottom,s.bottom)+n),u=e.doc.scrollTop,c=e.doc.scrollLeft;if(null!=a.scrollTop&&(Zt(e,a.scrollTop),Math.abs(e.doc.scrollTop-u)>1&&(o=!0)),null!=a.scrollLeft&&(Qt(e,a.scrollLeft),Math.abs(e.doc.scrollLeft-c)>1&&(o=!0)),!o)break}return l}function Mr(e,t,r,n,i){var o=Nr(e,t,r,n,i);null!=o.scrollTop&&Zt(e,o.scrollTop),null!=o.scrollLeft&&Qt(e,o.scrollLeft)}function Nr(e,t,r,n,i){var o=e.display,l=gt(e.display);0>r&&(r=0);var s=e.curOp&&null!=e.curOp.scrollTop?e.curOp.scrollTop:o.scroller.scrollTop,a=je(e),u={};i-r>a&&(i=r+a);var c=e.doc.height+Ge(o),f=l>r,h=i>c-l;if(s>r)u.scrollTop=f?0:r;else if(i>s+a){var d=Math.min(r,(h?c:i)-a);d!=s&&(u.scrollTop=d)}var p=e.curOp&&null!=e.curOp.scrollLeft?e.curOp.scrollLeft:o.scroller.scrollLeft,g=Ke(e)-(e.options.fixedGutter?o.gutters.offsetWidth:0),v=n-t>g;return v&&(n=t+g),10>t?u.scrollLeft=0:p>t?u.scrollLeft=Math.max(0,t-(v?0:10)):n>g+p-3&&(u.scrollLeft=n+(v?0:10)-g),u}function Ar(e,t,r){(null!=t||null!=r)&&Or(e),null!=t&&(e.curOp.scrollLeft=(null==e.curOp.scrollLeft?e.doc.scrollLeft:e.curOp.scrollLeft)+t),null!=r&&(e.curOp.scrollTop=(null==e.curOp.scrollTop?e.doc.scrollTop:e.curOp.scrollTop)+r)}function Wr(e){Or(e);var t=e.getCursor(),r=t,n=t;e.options.lineWrapping||(r=t.ch?No(t.line,t.ch-1):t,n=No(t.line,t.ch+1)),e.curOp.scrollToPos={from:r,to:n,margin:e.options.cursorScrollMargin,isCursor:!0}}function Or(e){var t=e.curOp.scrollToPos;if(t){e.curOp.scrollToPos=null;var r=ft(e,t.from),n=ft(e,t.to),i=Nr(e,Math.min(r.left,n.left),Math.min(r.top,n.top)-t.margin,Math.max(r.right,n.right),Math.max(r.bottom,n.bottom)+t.margin);e.scrollTo(i.scrollLeft,i.scrollTop)}}function Dr(e,t,r,n){var i,o=e.doc;null==r&&(r="add"),"smart"==r&&(o.mode.indent?i=Re(e,t):r="prev");var l=e.options.tabSize,s=Kn(o,t),a=Al(s.text,null,l);s.stateAfter&&(s.stateAfter=null);var u,c=s.text.match(/^\s*/)[0];if(n||/\S/.test(s.text)){if("smart"==r&&(u=o.mode.indent(i,s.text.slice(c.length),s.text),u==kl||u>150)){if(!n)return;r="prev"}}else u=0,r="not";"prev"==r?u=t>o.first?Al(Kn(o,t-1).text,null,l):0:"add"==r?u=a+e.options.indentUnit:"subtract"==r?u=a-e.options.indentUnit:"number"==typeof r&&(u=a+r),u=Math.max(0,u);var f="",h=0;if(e.options.indentWithTabs)for(var d=Math.floor(u/l);d;--d)h+=l,f+=" ";if(u>h&&(f+=Li(u-h)),f!=c)Lr(o,f,No(t,0),No(t,c.length),"+input");else for(var d=0;d<o.sel.ranges.length;d++){var p=o.sel.ranges[d];if(p.head.line==t&&p.head.ch<c.length){var h=No(t,c.length);xe(o,d,new ce(h,h));break}}s.stateAfter=null}function Hr(e,t,r,n){var i=t,o=t;return"number"==typeof t?o=Kn(e,de(e,t)):i=Yn(t),null==i?null:(n(o,i)&&e.cm&&Ht(e.cm,i,r),o)}function Ir(e,t){for(var r=e.doc.sel.ranges,n=[],i=0;i<r.length;i++){for(var o=t(r[i]);n.length&&Ao(o.from,ki(n).to)<=0;){var l=n.pop();if(Ao(l.from,o.from)<0){o.from=l.from;break}}n.push(o)}Tt(e,function(){for(var t=n.length-1;t>=0;t--)Lr(e.doc,"",n[t].from,n[t].to,"+delete");Wr(e)})}function Pr(e,t,r,n,i){function o(){var t=s+r;return t<e.first||t>=e.first+e.size?f=!1:(s=t,c=Kn(e,t))}function l(e){var t=(i?io:oo)(c,a,r,!0);if(null==t){if(e||!o())return f=!1;a=i?(0>r?Zi:qi)(c):0>r?c.text.length:0}else a=t;return!0}var s=t.line,a=t.ch,u=r,c=Kn(e,s),f=!0;if("char"==n)l();else if("column"==n)l(!0);else if("word"==n||"group"==n)for(var h=null,d="group"==n,p=e.cm&&e.cm.getHelper(t,"wordChars"),g=!0;!(0>r)||l(!g);g=!1){var v=c.text.charAt(a)||"\n",m=Di(v,p)?"w":d&&"\n"==v?"n":!d||/\s/.test(v)?null:"p";if(!d||g||m||(m="s"),h&&h!=m){0>r&&(r=1,l());break}if(m&&(h=m),r>0&&!l(!g))break}var y=We(e,No(s,a),u,!0);return f||(y.hitSide=!0),y}function zr(e,t,r,n){var i,o=e.doc,l=t.left;if("page"==n){var s=Math.min(e.display.wrapper.clientHeight,window.innerHeight||document.documentElement.clientHeight);i=t.top+r*(s-(0>r?1.5:.5)*gt(e.display))}else"line"==n&&(i=r>0?t.bottom+3:t.top-3);for(;;){var a=dt(e,l,i);if(!a.outside)break;if(0>r?0>=i:i>=o.height){a.hitSide=!0;break}i+=5*r}return a}function Er(t,r,n,i){e.defaults[t]=r,n&&(jo[t]=i?function(e,t,r){r!=Xo&&n(e,t,r)}:n)}function Fr(e){for(var t,r,n,i,o=e.split(/-(?!$)/),e=o[o.length-1],l=0;l<o.length-1;l++){var s=o[l];if(/^(cmd|meta|m)$/i.test(s))i=!0;else if(/^a(lt)?$/i.test(s))t=!0;else if(/^(c|ctrl|control)$/i.test(s))r=!0;else{if(!/^s(hift)$/i.test(s))throw new Error("Unrecognized modifier name: "+s);n=!0}}return t&&(e="Alt-"+e),r&&(e="Ctrl-"+e),i&&(e="Cmd-"+e),n&&(e="Shift-"+e),e}function Rr(e){return"string"==typeof e?tl[e]:e;
3
+ }function Br(e,t,r,n,i){if(n&&n.shared)return Gr(e,t,r,n,i);if(e.cm&&!e.cm.curOp)return Mt(e.cm,Br)(e,t,r,n,i);var o=new sl(e,i),l=Ao(t,r);if(n&&Wi(n,o,!1),l>0||0==l&&o.clearWhenEmpty!==!1)return o;if(o.replacedWith&&(o.collapsed=!0,o.widgetNode=Pi("span",[o.replacedWith],"CodeMirror-widget"),n.handleMouseEvents||o.widgetNode.setAttribute("cm-ignore-events","true"),n.insertLeft&&(o.widgetNode.insertLeft=!0)),o.collapsed){if(cn(e,t.line,t,r,o)||t.line!=r.line&&cn(e,r.line,t,r,o))throw new Error("Inserting collapsed marker partially overlapping an existing one");Mo=!0}o.addToHistory&&ri(e,{from:t,to:r,origin:"markText"},e.sel,NaN);var s,a=t.line,u=e.cm;if(e.iter(a,r.line+1,function(e){u&&o.collapsed&&!u.options.lineWrapping&&fn(e)==u.display.maxLine&&(s=!0),o.collapsed&&a!=t.line&&_n(e,0),Yr(e,new jr(o,a==t.line?t.ch:null,a==r.line?r.ch:null)),++a}),o.collapsed&&e.iter(t.line,r.line+1,function(t){gn(e,t)&&_n(t,0)}),o.clearOnEnter&&wl(o,"beforeCursorEnter",function(){o.clear()}),o.readOnly&&(To=!0,(e.history.done.length||e.history.undone.length)&&e.clearHistory()),o.collapsed&&(o.id=++ll,o.atomic=!0),u){if(s&&(u.curOp.updateMaxLine=!0),o.collapsed)Dt(u,t.line,r.line+1);else if(o.className||o.title||o.startStyle||o.endStyle||o.css)for(var c=t.line;c<=r.line;c++)Ht(u,c,"text");o.atomic&&Ne(u.doc),vi(u,"markerAdded",u,o)}return o}function Gr(e,t,r,n,i){n=Wi(n),n.shared=!1;var o=[Br(e,t,r,n,i)],l=o[0],s=n.widgetNode;return Un(e,function(e){s&&(n.widgetNode=s.cloneNode(!0)),o.push(Br(e,pe(e,t),pe(e,r),n,i));for(var a=0;a<e.linked.length;++a)if(e.linked[a].isParent)return;l=ki(o)}),new al(o,l)}function Ur(e){return e.findMarks(No(e.first,0),e.clipPos(No(e.lastLine())),function(e){return e.parent})}function Vr(e,t){for(var r=0;r<t.length;r++){var n=t[r],i=n.find(),o=e.clipPos(i.from),l=e.clipPos(i.to);if(Ao(o,l)){var s=Br(e,o,l,n.primary,n.primary.type);n.markers.push(s),s.parent=n}}}function Kr(e){for(var t=0;t<e.length;t++){var r=e[t],n=[r.primary.doc];Un(r.primary.doc,function(e){n.push(e)});for(var i=0;i<r.markers.length;i++){var o=r.markers[i];-1==Ti(n,o.doc)&&(o.parent=null,r.markers.splice(i--,1))}}}function jr(e,t,r){this.marker=e,this.from=t,this.to=r}function Xr(e,t){if(e)for(var r=0;r<e.length;++r){var n=e[r];if(n.marker==t)return n}}function _r(e,t){for(var r,n=0;n<e.length;++n)e[n]!=t&&(r||(r=[])).push(e[n]);return r}function Yr(e,t){e.markedSpans=e.markedSpans?e.markedSpans.concat([t]):[t],t.marker.attachLine(e)}function $r(e,t,r){if(e)for(var n,i=0;i<e.length;++i){var o=e[i],l=o.marker,s=null==o.from||(l.inclusiveLeft?o.from<=t:o.from<t);if(s||o.from==t&&"bookmark"==l.type&&(!r||!o.marker.insertLeft)){var a=null==o.to||(l.inclusiveRight?o.to>=t:o.to>t);(n||(n=[])).push(new jr(l,o.from,a?null:o.to))}}return n}function qr(e,t,r){if(e)for(var n,i=0;i<e.length;++i){var o=e[i],l=o.marker,s=null==o.to||(l.inclusiveRight?o.to>=t:o.to>t);if(s||o.from==t&&"bookmark"==l.type&&(!r||o.marker.insertLeft)){var a=null==o.from||(l.inclusiveLeft?o.from<=t:o.from<t);(n||(n=[])).push(new jr(l,a?null:o.from-t,null==o.to?null:o.to-t))}}return n}function Zr(e,t){if(t.full)return null;var r=ve(e,t.from.line)&&Kn(e,t.from.line).markedSpans,n=ve(e,t.to.line)&&Kn(e,t.to.line).markedSpans;if(!r&&!n)return null;var i=t.from.ch,o=t.to.ch,l=0==Ao(t.from,t.to),s=$r(r,i,l),a=qr(n,o,l),u=1==t.text.length,c=ki(t.text).length+(u?i:0);if(s)for(var f=0;f<s.length;++f){var h=s[f];if(null==h.to){var d=Xr(a,h.marker);d?u&&(h.to=null==d.to?null:d.to+c):h.to=i}}if(a)for(var f=0;f<a.length;++f){var h=a[f];if(null!=h.to&&(h.to+=c),null==h.from){var d=Xr(s,h.marker);d||(h.from=c,u&&(s||(s=[])).push(h))}else h.from+=c,u&&(s||(s=[])).push(h)}s&&(s=Qr(s)),a&&a!=s&&(a=Qr(a));var p=[s];if(!u){var g,v=t.text.length-2;if(v>0&&s)for(var f=0;f<s.length;++f)null==s[f].to&&(g||(g=[])).push(new jr(s[f].marker,null,null));for(var f=0;v>f;++f)p.push(g);p.push(a)}return p}function Qr(e){for(var t=0;t<e.length;++t){var r=e[t];null!=r.from&&r.from==r.to&&r.marker.clearWhenEmpty!==!1&&e.splice(t--,1)}return e.length?e:null}function Jr(e,t){var r=ai(e,t),n=Zr(e,t);if(!r)return n;if(!n)return r;for(var i=0;i<r.length;++i){var o=r[i],l=n[i];if(o&&l)e:for(var s=0;s<l.length;++s){for(var a=l[s],u=0;u<o.length;++u)if(o[u].marker==a.marker)continue e;o.push(a)}else l&&(r[i]=l)}return r}function en(e,t,r){var n=null;if(e.iter(t.line,r.line+1,function(e){if(e.markedSpans)for(var t=0;t<e.markedSpans.length;++t){var r=e.markedSpans[t].marker;!r.readOnly||n&&-1!=Ti(n,r)||(n||(n=[])).push(r)}}),!n)return null;for(var i=[{from:t,to:r}],o=0;o<n.length;++o)for(var l=n[o],s=l.find(0),a=0;a<i.length;++a){var u=i[a];if(!(Ao(u.to,s.from)<0||Ao(u.from,s.to)>0)){var c=[a,1],f=Ao(u.from,s.from),h=Ao(u.to,s.to);(0>f||!l.inclusiveLeft&&!f)&&c.push({from:u.from,to:s.from}),(h>0||!l.inclusiveRight&&!h)&&c.push({from:s.to,to:u.to}),i.splice.apply(i,c),a+=c.length-1}}return i}function tn(e){var t=e.markedSpans;if(t){for(var r=0;r<t.length;++r)t[r].marker.detachLine(e);e.markedSpans=null}}function rn(e,t){if(t){for(var r=0;r<t.length;++r)t[r].marker.attachLine(e);e.markedSpans=t}}function nn(e){return e.inclusiveLeft?-1:0}function on(e){return e.inclusiveRight?1:0}function ln(e,t){var r=e.lines.length-t.lines.length;if(0!=r)return r;var n=e.find(),i=t.find(),o=Ao(n.from,i.from)||nn(e)-nn(t);if(o)return-o;var l=Ao(n.to,i.to)||on(e)-on(t);return l?l:t.id-e.id}function sn(e,t){var r,n=Mo&&e.markedSpans;if(n)for(var i,o=0;o<n.length;++o)i=n[o],i.marker.collapsed&&null==(t?i.from:i.to)&&(!r||ln(r,i.marker)<0)&&(r=i.marker);return r}function an(e){return sn(e,!0)}function un(e){return sn(e,!1)}function cn(e,t,r,n,i){var o=Kn(e,t),l=Mo&&o.markedSpans;if(l)for(var s=0;s<l.length;++s){var a=l[s];if(a.marker.collapsed){var u=a.marker.find(0),c=Ao(u.from,r)||nn(a.marker)-nn(i),f=Ao(u.to,n)||on(a.marker)-on(i);if(!(c>=0&&0>=f||0>=c&&f>=0)&&(0>=c&&(Ao(u.to,r)>0||a.marker.inclusiveRight&&i.inclusiveLeft)||c>=0&&(Ao(u.from,n)<0||a.marker.inclusiveLeft&&i.inclusiveRight)))return!0}}}function fn(e){for(var t;t=an(e);)e=t.find(-1,!0).line;return e}function hn(e){for(var t,r;t=un(e);)e=t.find(1,!0).line,(r||(r=[])).push(e);return r}function dn(e,t){var r=Kn(e,t),n=fn(r);return r==n?t:Yn(n)}function pn(e,t){if(t>e.lastLine())return t;var r,n=Kn(e,t);if(!gn(e,n))return t;for(;r=un(n);)n=r.find(1,!0).line;return Yn(n)+1}function gn(e,t){var r=Mo&&t.markedSpans;if(r)for(var n,i=0;i<r.length;++i)if(n=r[i],n.marker.collapsed){if(null==n.from)return!0;if(!n.marker.widgetNode&&0==n.from&&n.marker.inclusiveLeft&&vn(e,t,n))return!0}}function vn(e,t,r){if(null==r.to){var n=r.marker.find(1,!0);return vn(e,n.line,Xr(n.line.markedSpans,r.marker))}if(r.marker.inclusiveRight&&r.to==t.text.length)return!0;for(var i,o=0;o<t.markedSpans.length;++o)if(i=t.markedSpans[o],i.marker.collapsed&&!i.marker.widgetNode&&i.from==r.to&&(null==i.to||i.to!=r.from)&&(i.marker.inclusiveLeft||r.marker.inclusiveRight)&&vn(e,t,i))return!0}function mn(e,t,r){qn(t)<(e.curOp&&e.curOp.scrollTop||e.doc.scrollTop)&&Ar(e,null,r)}function yn(e){if(null!=e.height)return e.height;if(!zl(document.body,e.node)){var t="position: relative;";e.coverGutter&&(t+="margin-left: -"+e.cm.display.gutters.offsetWidth+"px;"),e.noHScroll&&(t+="width: "+e.cm.display.wrapper.clientWidth+"px;"),Ei(e.cm.display.measure,Pi("div",[e.node],null,t))}return e.height=e.node.offsetHeight}function bn(e,t,r,n){var i=new ul(e,r,n);return i.noHScroll&&(e.display.alignWidgets=!0),Hr(e.doc,t,"widget",function(t){var r=t.widgets||(t.widgets=[]);if(null==i.insertAt?r.push(i):r.splice(Math.min(r.length-1,Math.max(0,i.insertAt)),0,i),i.line=t,!gn(e.doc,t)){var n=qn(t)<e.doc.scrollTop;_n(t,t.height+yn(i)),n&&Ar(e,null,i.height),e.curOp.forceUpdate=!0}return!0}),i}function wn(e,t,r,n){e.text=t,e.stateAfter&&(e.stateAfter=null),e.styles&&(e.styles=null),null!=e.order&&(e.order=null),tn(e),rn(e,r);var i=n?n(e):1;i!=e.height&&_n(e,i)}function xn(e){e.parent=null,tn(e)}function Cn(e,t){if(e)for(;;){var r=e.match(/(?:^|\s+)line-(background-)?(\S+)/);if(!r)break;e=e.slice(0,r.index)+e.slice(r.index+r[0].length);var n=r[1]?"bgClass":"textClass";null==t[n]?t[n]=r[2]:new RegExp("(?:^|s)"+r[2]+"(?:$|s)").test(t[n])||(t[n]+=" "+r[2])}return e}function Sn(t,r){if(t.blankLine)return t.blankLine(r);if(t.innerMode){var n=e.innerMode(t,r);return n.mode.blankLine?n.mode.blankLine(n.state):void 0}}function Ln(t,r,n,i){for(var o=0;10>o;o++){i&&(i[0]=e.innerMode(t,n).mode);var l=t.token(r,n);if(r.pos>r.start)return l}throw new Error("Mode "+t.name+" failed to advance stream.")}function kn(e,t,r,n){function i(e){return{start:f.start,end:f.pos,string:f.current(),type:o||null,state:e?Qo(l.mode,c):c}}var o,l=e.doc,s=l.mode;t=pe(l,t);var a,u=Kn(l,t.line),c=Re(e,t.line,r),f=new ol(u.text,e.options.tabSize);for(n&&(a=[]);(n||f.pos<t.ch)&&!f.eol();)f.start=f.pos,o=Ln(s,f,c),n&&a.push(i(!0));return n?a:i()}function Tn(e,t,r,n,i,o,l){var s=r.flattenSpans;null==s&&(s=e.options.flattenSpans);var a,u=0,c=null,f=new ol(t,e.options.tabSize),h=e.options.addModeClass&&[null];for(""==t&&Cn(Sn(r,n),o);!f.eol();){if(f.pos>e.options.maxHighlightLength?(s=!1,l&&An(e,t,n,f.pos),f.pos=t.length,a=null):a=Cn(Ln(r,f,n,h),o),h){var d=h[0].name;d&&(a="m-"+(a?d+" "+a:d))}if(!s||c!=a){for(;u<f.start;)u=Math.min(f.start,u+5e4),i(u,c);c=a}f.start=f.pos}for(;u<f.pos;){var p=Math.min(f.pos,u+5e4);i(p,c),u=p}}function Mn(e,t,r,n){var i=[e.state.modeGen],o={};Tn(e,t.text,e.doc.mode,r,function(e,t){i.push(e,t)},o,n);for(var l=0;l<e.state.overlays.length;++l){var s=e.state.overlays[l],a=1,u=0;Tn(e,t.text,s.mode,!0,function(e,t){for(var r=a;e>u;){var n=i[a];n>e&&i.splice(a,1,e,i[a+1],n),a+=2,u=Math.min(e,n)}if(t)if(s.opaque)i.splice(r,a-r,e,"cm-overlay "+t),a=r+2;else for(;a>r;r+=2){var o=i[r+1];i[r+1]=(o?o+" ":"")+"cm-overlay "+t}},o)}return{styles:i,classes:o.bgClass||o.textClass?o:null}}function Nn(e,t,r){if(!t.styles||t.styles[0]!=e.state.modeGen){var n=Mn(e,t,t.stateAfter=Re(e,Yn(t)));t.styles=n.styles,n.classes?t.styleClasses=n.classes:t.styleClasses&&(t.styleClasses=null),r===e.doc.frontier&&e.doc.frontier++}return t.styles}function An(e,t,r,n){var i=e.doc.mode,o=new ol(t,e.options.tabSize);for(o.start=o.pos=n||0,""==t&&Sn(i,r);!o.eol()&&o.pos<=e.options.maxHighlightLength;)Ln(i,o,r),o.start=o.pos}function Wn(e,t){if(!e||/^\s*$/.test(e))return null;var r=t.addModeClass?hl:fl;return r[e]||(r[e]=e.replace(/\S+/g,"cm-$&"))}function On(e,t){var r=Pi("span",null,null,fo?"padding-right: .1px":null),n={pre:Pi("pre",[r]),content:r,col:0,pos:0,cm:e};t.measure={};for(var i=0;i<=(t.rest?t.rest.length:0);i++){var o,l=i?t.rest[i-1]:t.line;n.pos=0,n.addToken=Hn,(uo||fo)&&e.getOption("lineWrapping")&&(n.addToken=In(n.addToken)),ji(e.display.measure)&&(o=Zn(l))&&(n.addToken=Pn(n.addToken,o)),n.map=[];var s=t!=e.display.externalMeasured&&Yn(l);En(l,n,Nn(e,l,s)),l.styleClasses&&(l.styleClasses.bgClass&&(n.bgClass=Bi(l.styleClasses.bgClass,n.bgClass||"")),l.styleClasses.textClass&&(n.textClass=Bi(l.styleClasses.textClass,n.textClass||""))),0==n.map.length&&n.map.push(0,0,n.content.appendChild(Ki(e.display.measure))),0==i?(t.measure.map=n.map,t.measure.cache={}):((t.measure.maps||(t.measure.maps=[])).push(n.map),(t.measure.caches||(t.measure.caches=[])).push({}))}return fo&&/\bcm-tab\b/.test(n.content.lastChild.className)&&(n.content.className="cm-tab-wrap-hack"),Cl(e,"renderLine",e,t.line,n.pre),n.pre.className&&(n.textClass=Bi(n.pre.className,n.textClass||"")),n}function Dn(e){var t=Pi("span","•","cm-invalidchar");return t.title="\\u"+e.charCodeAt(0).toString(16),t.setAttribute("aria-label",t.title),t}function Hn(e,t,r,n,i,o,l){if(t){var s=e.cm.options.specialChars,a=!1;if(s.test(t))for(var u=document.createDocumentFragment(),c=0;;){s.lastIndex=c;var f=s.exec(t),h=f?f.index-c:t.length-c;if(h){var d=document.createTextNode(t.slice(c,c+h));uo&&9>co?u.appendChild(Pi("span",[d])):u.appendChild(d),e.map.push(e.pos,e.pos+h,d),e.col+=h,e.pos+=h}if(!f)break;if(c+=h+1," "==f[0]){var p=e.cm.options.tabSize,g=p-e.col%p,d=u.appendChild(Pi("span",Li(g),"cm-tab"));d.setAttribute("role","presentation"),d.setAttribute("cm-text"," "),e.col+=g}else{var d=e.cm.options.specialCharPlaceholder(f[0]);d.setAttribute("cm-text",f[0]),uo&&9>co?u.appendChild(Pi("span",[d])):u.appendChild(d),e.col+=1}e.map.push(e.pos,e.pos+1,d),e.pos++}else{e.col+=t.length;var u=document.createTextNode(t);e.map.push(e.pos,e.pos+t.length,u),uo&&9>co&&(a=!0),e.pos+=t.length}if(r||n||i||a||l){var v=r||"";n&&(v+=n),i&&(v+=i);var m=Pi("span",[u],v,l);return o&&(m.title=o),e.content.appendChild(m)}e.content.appendChild(u)}}function In(e){function t(e){for(var t=" ",r=0;r<e.length-2;++r)t+=r%2?" ":" ";return t+=" "}return function(r,n,i,o,l,s){e(r,n.replace(/ {3,}/g,t),i,o,l,s)}}function Pn(e,t){return function(r,n,i,o,l,s){i=i?i+" cm-force-border":"cm-force-border";for(var a=r.pos,u=a+n.length;;){for(var c=0;c<t.length;c++){var f=t[c];if(f.to>a&&f.from<=a)break}if(f.to>=u)return e(r,n,i,o,l,s);e(r,n.slice(0,f.to-a),i,o,null,s),o=null,n=n.slice(f.to-a),a=f.to}}}function zn(e,t,r,n){var i=!n&&r.widgetNode;i&&e.map.push(e.pos,e.pos+t,i),!n&&e.cm.display.input.needsContentAttribute&&(i||(i=e.content.appendChild(document.createElement("span"))),i.setAttribute("cm-marker",r.id)),i&&(e.cm.display.input.setUneditable(i),e.content.appendChild(i)),e.pos+=t}function En(e,t,r){var n=e.markedSpans,i=e.text,o=0;if(n)for(var l,s,a,u,c,f,h,d=i.length,p=0,g=1,v="",m=0;;){if(m==p){a=u=c=f=s="",h=null,m=1/0;for(var y=[],b=0;b<n.length;++b){var w=n[b],x=w.marker;w.from<=p&&(null==w.to||w.to>p)?(null!=w.to&&m>w.to&&(m=w.to,u=""),x.className&&(a+=" "+x.className),x.css&&(s=x.css),x.startStyle&&w.from==p&&(c+=" "+x.startStyle),x.endStyle&&w.to==m&&(u+=" "+x.endStyle),x.title&&!f&&(f=x.title),x.collapsed&&(!h||ln(h.marker,x)<0)&&(h=w)):w.from>p&&m>w.from&&(m=w.from),"bookmark"==x.type&&w.from==p&&x.widgetNode&&y.push(x)}if(h&&(h.from||0)==p&&(zn(t,(null==h.to?d+1:h.to)-p,h.marker,null==h.from),null==h.to))return;if(!h&&y.length)for(var b=0;b<y.length;++b)zn(t,0,y[b])}if(p>=d)break;for(var C=Math.min(d,m);;){if(v){var S=p+v.length;if(!h){var L=S>C?v.slice(0,C-p):v;t.addToken(t,L,l?l+a:a,c,p+L.length==m?u:"",f,s)}if(S>=C){v=v.slice(C-p),p=C;break}p=S,c=""}v=i.slice(o,o=r[g++]),l=Wn(r[g++],t.cm.options)}}else for(var g=1;g<r.length;g+=2)t.addToken(t,i.slice(o,o=r[g]),Wn(r[g+1],t.cm.options))}function Fn(e,t){return 0==t.from.ch&&0==t.to.ch&&""==ki(t.text)&&(!e.cm||e.cm.options.wholeLineUpdateBefore)}function Rn(e,t,r,n){function i(e){return r?r[e]:null}function o(e,r,i){wn(e,r,i,n),vi(e,"change",e,t)}function l(e,t){for(var r=e,o=[];t>r;++r)o.push(new cl(u[r],i(r),n));return o}var s=t.from,a=t.to,u=t.text,c=Kn(e,s.line),f=Kn(e,a.line),h=ki(u),d=i(u.length-1),p=a.line-s.line;if(t.full)e.insert(0,l(0,u.length)),e.remove(u.length,e.size-u.length);else if(Fn(e,t)){var g=l(0,u.length-1);o(f,f.text,d),p&&e.remove(s.line,p),g.length&&e.insert(s.line,g)}else if(c==f)if(1==u.length)o(c,c.text.slice(0,s.ch)+h+c.text.slice(a.ch),d);else{var g=l(1,u.length-1);g.push(new cl(h+c.text.slice(a.ch),d,n)),o(c,c.text.slice(0,s.ch)+u[0],i(0)),e.insert(s.line+1,g)}else if(1==u.length)o(c,c.text.slice(0,s.ch)+u[0]+f.text.slice(a.ch),i(0)),e.remove(s.line+1,p);else{o(c,c.text.slice(0,s.ch)+u[0],i(0)),o(f,h+f.text.slice(a.ch),d);var g=l(1,u.length-1);p>1&&e.remove(s.line+1,p-1),e.insert(s.line+1,g)}vi(e,"change",e,t)}function Bn(e){this.lines=e,this.parent=null;for(var t=0,r=0;t<e.length;++t)e[t].parent=this,r+=e[t].height;this.height=r}function Gn(e){this.children=e;for(var t=0,r=0,n=0;n<e.length;++n){var i=e[n];t+=i.chunkSize(),r+=i.height,i.parent=this}this.size=t,this.height=r,this.parent=null}function Un(e,t,r){function n(e,i,o){if(e.linked)for(var l=0;l<e.linked.length;++l){var s=e.linked[l];if(s.doc!=i){var a=o&&s.sharedHist;(!r||a)&&(t(s.doc,a),n(s.doc,e,a))}}}n(e,null,!0)}function Vn(e,t){if(t.cm)throw new Error("This document is already in use.");e.doc=t,t.cm=e,l(e),r(e),e.options.lineWrapping||h(e),e.options.mode=t.modeOption,Dt(e)}function Kn(e,t){if(t-=e.first,0>t||t>=e.size)throw new Error("There is no line "+(t+e.first)+" in the document.");for(var r=e;!r.lines;)for(var n=0;;++n){var i=r.children[n],o=i.chunkSize();if(o>t){r=i;break}t-=o}return r.lines[t]}function jn(e,t,r){var n=[],i=t.line;return e.iter(t.line,r.line+1,function(e){var o=e.text;i==r.line&&(o=o.slice(0,r.ch)),i==t.line&&(o=o.slice(t.ch)),n.push(o),++i}),n}function Xn(e,t,r){var n=[];return e.iter(t,r,function(e){n.push(e.text)}),n}function _n(e,t){var r=t-e.height;if(r)for(var n=e;n;n=n.parent)n.height+=r}function Yn(e){if(null==e.parent)return null;for(var t=e.parent,r=Ti(t.lines,e),n=t.parent;n;t=n,n=n.parent)for(var i=0;n.children[i]!=t;++i)r+=n.children[i].chunkSize();return r+t.first}function $n(e,t){var r=e.first;e:do{for(var n=0;n<e.children.length;++n){var i=e.children[n],o=i.height;if(o>t){e=i;continue e}t-=o,r+=i.chunkSize()}return r}while(!e.lines);for(var n=0;n<e.lines.length;++n){var l=e.lines[n],s=l.height;if(s>t)break;t-=s}return r+n}function qn(e){e=fn(e);for(var t=0,r=e.parent,n=0;n<r.lines.length;++n){var i=r.lines[n];if(i==e)break;t+=i.height}for(var o=r.parent;o;r=o,o=r.parent)for(var n=0;n<o.children.length;++n){var l=o.children[n];if(l==r)break;t+=l.height}return t}function Zn(e){var t=e.order;return null==t&&(t=e.order=$l(e.text)),t}function Qn(e){this.done=[],this.undone=[],this.undoDepth=1/0,this.lastModTime=this.lastSelTime=0,this.lastOp=this.lastSelOp=null,this.lastOrigin=this.lastSelOrigin=null,this.generation=this.maxGeneration=e||1}function Jn(e,t){var r={from:_(t.from),to:Vo(t),text:jn(e,t.from,t.to)};return li(e,r,t.from.line,t.to.line+1),Un(e,function(e){li(e,r,t.from.line,t.to.line+1)},!0),r}function ei(e){for(;e.length;){var t=ki(e);if(!t.ranges)break;e.pop()}}function ti(e,t){return t?(ei(e.done),ki(e.done)):e.done.length&&!ki(e.done).ranges?ki(e.done):e.done.length>1&&!e.done[e.done.length-2].ranges?(e.done.pop(),ki(e.done)):void 0}function ri(e,t,r,n){var i=e.history;i.undone.length=0;var o,l=+new Date;if((i.lastOp==n||i.lastOrigin==t.origin&&t.origin&&("+"==t.origin.charAt(0)&&e.cm&&i.lastModTime>l-e.cm.options.historyEventDelay||"*"==t.origin.charAt(0)))&&(o=ti(i,i.lastOp==n))){var s=ki(o.changes);0==Ao(t.from,t.to)&&0==Ao(t.from,s.to)?s.to=Vo(t):o.changes.push(Jn(e,t))}else{var a=ki(i.done);for(a&&a.ranges||oi(e.sel,i.done),o={changes:[Jn(e,t)],generation:i.generation},i.done.push(o);i.done.length>i.undoDepth;)i.done.shift(),i.done[0].ranges||i.done.shift()}i.done.push(r),i.generation=++i.maxGeneration,i.lastModTime=i.lastSelTime=l,i.lastOp=i.lastSelOp=n,i.lastOrigin=i.lastSelOrigin=t.origin,s||Cl(e,"historyAdded")}function ni(e,t,r,n){var i=t.charAt(0);return"*"==i||"+"==i&&r.ranges.length==n.ranges.length&&r.somethingSelected()==n.somethingSelected()&&new Date-e.history.lastSelTime<=(e.cm?e.cm.options.historyEventDelay:500)}function ii(e,t,r,n){var i=e.history,o=n&&n.origin;r==i.lastSelOp||o&&i.lastSelOrigin==o&&(i.lastModTime==i.lastSelTime&&i.lastOrigin==o||ni(e,o,ki(i.done),t))?i.done[i.done.length-1]=t:oi(t,i.done),i.lastSelTime=+new Date,i.lastSelOrigin=o,i.lastSelOp=r,n&&n.clearRedo!==!1&&ei(i.undone)}function oi(e,t){var r=ki(t);r&&r.ranges&&r.equals(e)||t.push(e)}function li(e,t,r,n){var i=t["spans_"+e.id],o=0;e.iter(Math.max(e.first,r),Math.min(e.first+e.size,n),function(r){r.markedSpans&&((i||(i=t["spans_"+e.id]={}))[o]=r.markedSpans),++o})}function si(e){if(!e)return null;for(var t,r=0;r<e.length;++r)e[r].marker.explicitlyCleared?t||(t=e.slice(0,r)):t&&t.push(e[r]);return t?t.length?t:null:e}function ai(e,t){var r=t["spans_"+e.id];if(!r)return null;for(var n=0,i=[];n<t.text.length;++n)i.push(si(r[n]));return i}function ui(e,t,r){for(var n=0,i=[];n<e.length;++n){var o=e[n];if(o.ranges)i.push(r?ue.prototype.deepCopy.call(o):o);else{var l=o.changes,s=[];i.push({changes:s});for(var a=0;a<l.length;++a){var u,c=l[a];if(s.push({from:c.from,to:c.to,text:c.text}),t)for(var f in c)(u=f.match(/^spans_(\d+)$/))&&Ti(t,Number(u[1]))>-1&&(ki(s)[f]=c[f],delete c[f])}}}return i}function ci(e,t,r,n){r<e.line?e.line+=n:t<e.line&&(e.line=t,e.ch=0)}function fi(e,t,r,n){for(var i=0;i<e.length;++i){var o=e[i],l=!0;if(o.ranges){o.copied||(o=e[i]=o.deepCopy(),o.copied=!0);for(var s=0;s<o.ranges.length;s++)ci(o.ranges[s].anchor,t,r,n),ci(o.ranges[s].head,t,r,n)}else{for(var s=0;s<o.changes.length;++s){var a=o.changes[s];if(r<a.from.line)a.from=No(a.from.line+n,a.from.ch),a.to=No(a.to.line+n,a.to.ch);else if(t<=a.to.line){l=!1;break}}l||(e.splice(0,i+1),i=0)}}}function hi(e,t){var r=t.from.line,n=t.to.line,i=t.text.length-(n-r)-1;fi(e.done,r,n,i),fi(e.undone,r,n,i)}function di(e){return null!=e.defaultPrevented?e.defaultPrevented:0==e.returnValue}function pi(e){return e.target||e.srcElement}function gi(e){var t=e.which;return null==t&&(1&e.button?t=1:2&e.button?t=3:4&e.button&&(t=2)),xo&&e.ctrlKey&&1==t&&(t=3),t}function vi(e,t){function r(e){return function(){e.apply(null,o)}}var n=e._handlers&&e._handlers[t];if(n){var i,o=Array.prototype.slice.call(arguments,2);Po?i=Po.delayedCallbacks:Sl?i=Sl:(i=Sl=[],setTimeout(mi,0));for(var l=0;l<n.length;++l)i.push(r(n[l]))}}function mi(){var e=Sl;Sl=null;for(var t=0;t<e.length;++t)e[t]()}function yi(e,t,r){return"string"==typeof t&&(t={type:t,preventDefault:function(){this.defaultPrevented=!0}}),Cl(e,r||t.type,e,t),di(t)||t.codemirrorIgnore}function bi(e){var t=e._handlers&&e._handlers.cursorActivity;if(t)for(var r=e.curOp.cursorActivityHandlers||(e.curOp.cursorActivityHandlers=[]),n=0;n<t.length;++n)-1==Ti(r,t[n])&&r.push(t[n])}function wi(e,t){var r=e._handlers&&e._handlers[t];return r&&r.length>0}function xi(e){e.prototype.on=function(e,t){wl(this,e,t)},e.prototype.off=function(e,t){xl(this,e,t)}}function Ci(){this.id=null}function Si(e,t,r){for(var n=0,i=0;;){var o=e.indexOf(" ",n);-1==o&&(o=e.length);var l=o-n;if(o==e.length||i+l>=t)return n+Math.min(l,t-i);if(i+=o-n,i+=r-i%r,n=o+1,i>=t)return n}}function Li(e){for(;Wl.length<=e;)Wl.push(ki(Wl)+" ");return Wl[e]}function ki(e){return e[e.length-1]}function Ti(e,t){for(var r=0;r<e.length;++r)if(e[r]==t)return r;return-1}function Mi(e,t){for(var r=[],n=0;n<e.length;n++)r[n]=t(e[n],n);return r}function Ni(){}function Ai(e,t){var r;return Object.create?r=Object.create(e):(Ni.prototype=e,r=new Ni),t&&Wi(t,r),r}function Wi(e,t,r){t||(t={});for(var n in e)!e.hasOwnProperty(n)||r===!1&&t.hasOwnProperty(n)||(t[n]=e[n]);return t}function Oi(e){var t=Array.prototype.slice.call(arguments,1);return function(){return e.apply(null,t)}}function Di(e,t){return t?t.source.indexOf("\\w")>-1&&Il(e)?!0:t.test(e):Il(e)}function Hi(e){for(var t in e)if(e.hasOwnProperty(t)&&e[t])return!1;return!0}function Ii(e){return e.charCodeAt(0)>=768&&Pl.test(e)}function Pi(e,t,r,n){var i=document.createElement(e);if(r&&(i.className=r),n&&(i.style.cssText=n),"string"==typeof t)i.appendChild(document.createTextNode(t));else if(t)for(var o=0;o<t.length;++o)i.appendChild(t[o]);return i}function zi(e){for(var t=e.childNodes.length;t>0;--t)e.removeChild(e.firstChild);return e}function Ei(e,t){return zi(e).appendChild(t)}function Fi(){return document.activeElement}function Ri(e){return new RegExp("(^|\\s)"+e+"(?:$|\\s)\\s*")}function Bi(e,t){for(var r=e.split(" "),n=0;n<r.length;n++)r[n]&&!Ri(r[n]).test(t)&&(t+=" "+r[n]);return t}function Gi(e){if(document.body.getElementsByClassName)for(var t=document.body.getElementsByClassName("CodeMirror"),r=0;r<t.length;r++){var n=t[r].CodeMirror;n&&e(n)}}function Ui(){Gl||(Vi(),Gl=!0)}function Vi(){var e;wl(window,"resize",function(){null==e&&(e=setTimeout(function(){e=null,Gi(Bt)},100))}),wl(window,"blur",function(){Gi(cr)})}function Ki(e){if(null==El){var t=Pi("span","​");Ei(e,Pi("span",[t,document.createTextNode("x")])),0!=e.firstChild.offsetHeight&&(El=t.offsetWidth<=1&&t.offsetHeight>2&&!(uo&&8>co))}var r=El?Pi("span","​"):Pi("span"," ",null,"display: inline-block; width: 1px; margin-right: -1px");return r.setAttribute("cm-text",""),r}function ji(e){if(null!=Fl)return Fl;var t=Ei(e,document.createTextNode("AخA")),r=Dl(t,0,1).getBoundingClientRect();if(!r||r.left==r.right)return!1;var n=Dl(t,1,2).getBoundingClientRect();return Fl=n.right-r.right<3}function Xi(e){if(null!=Xl)return Xl;var t=Ei(e,Pi("span","x")),r=t.getBoundingClientRect(),n=Dl(t,0,1).getBoundingClientRect();return Xl=Math.abs(r.left-n.left)>1}function _i(e,t,r,n){if(!e)return n(t,r,"ltr");for(var i=!1,o=0;o<e.length;++o){var l=e[o];(l.from<r&&l.to>t||t==r&&l.to==t)&&(n(Math.max(l.from,t),Math.min(l.to,r),1==l.level?"rtl":"ltr"),i=!0)}i||n(t,r,"ltr")}function Yi(e){return e.level%2?e.to:e.from}function $i(e){return e.level%2?e.from:e.to}function qi(e){var t=Zn(e);return t?Yi(t[0]):0}function Zi(e){var t=Zn(e);return t?$i(ki(t)):e.text.length}function Qi(e,t){var r=Kn(e.doc,t),n=fn(r);n!=r&&(t=Yn(n));var i=Zn(n),o=i?i[0].level%2?Zi(n):qi(n):0;return No(t,o)}function Ji(e,t){for(var r,n=Kn(e.doc,t);r=un(n);)n=r.find(1,!0).line,t=null;var i=Zn(n),o=i?i[0].level%2?qi(n):Zi(n):n.text.length;return No(null==t?Yn(n):t,o)}function eo(e,t){var r=Qi(e,t.line),n=Kn(e.doc,r.line),i=Zn(n);if(!i||0==i[0].level){var o=Math.max(0,n.text.search(/\S/)),l=t.line==r.line&&t.ch<=o&&t.ch;return No(r.line,l?0:o)}return r}function to(e,t,r){var n=e[0].level;return t==n?!0:r==n?!1:r>t}function ro(e,t){Yl=null;for(var r,n=0;n<e.length;++n){var i=e[n];if(i.from<t&&i.to>t)return n;if(i.from==t||i.to==t){if(null!=r)return to(e,i.level,e[r].level)?(i.from!=i.to&&(Yl=r),n):(i.from!=i.to&&(Yl=n),r);r=n}}return r}function no(e,t,r,n){if(!n)return t+r;do t+=r;while(t>0&&Ii(e.text.charAt(t)));return t}function io(e,t,r,n){var i=Zn(e);if(!i)return oo(e,t,r,n);for(var o=ro(i,t),l=i[o],s=no(e,t,l.level%2?-r:r,n);;){if(s>l.from&&s<l.to)return s;if(s==l.from||s==l.to)return ro(i,s)==o?s:(l=i[o+=r],r>0==l.level%2?l.to:l.from);if(l=i[o+=r],!l)return null;s=r>0==l.level%2?no(e,l.to,-1,n):no(e,l.from,1,n)}}function oo(e,t,r,n){var i=t+r;if(n)for(;i>0&&Ii(e.text.charAt(i));)i+=r;return 0>i||i>e.text.length?null:i}var lo=/gecko\/\d/i.test(navigator.userAgent),so=/MSIE \d/.test(navigator.userAgent),ao=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent),uo=so||ao,co=uo&&(so?document.documentMode||6:ao[1]),fo=/WebKit\//.test(navigator.userAgent),ho=fo&&/Qt\/\d+\.\d+/.test(navigator.userAgent),po=/Chrome\//.test(navigator.userAgent),go=/Opera\//.test(navigator.userAgent),vo=/Apple Computer/.test(navigator.vendor),mo=/Mac OS X 1\d\D([8-9]|\d\d)\D/.test(navigator.userAgent),yo=/PhantomJS/.test(navigator.userAgent),bo=/AppleWebKit/.test(navigator.userAgent)&&/Mobile\/\w+/.test(navigator.userAgent),wo=bo||/Android|webOS|BlackBerry|Opera Mini|Opera Mobi|IEMobile/i.test(navigator.userAgent),xo=bo||/Mac/.test(navigator.platform),Co=/win/i.test(navigator.platform),So=go&&navigator.userAgent.match(/Version\/(\d*\.\d*)/);So&&(So=Number(So[1])),So&&So>=15&&(go=!1,fo=!0);var Lo=xo&&(ho||go&&(null==So||12.11>So)),ko=lo||uo&&co>=9,To=!1,Mo=!1;g.prototype=Wi({update:function(e){var t=e.scrollWidth>e.clientWidth+1,r=e.scrollHeight>e.clientHeight+1,n=e.nativeBarWidth;if(r){this.vert.style.display="block",this.vert.style.bottom=t?n+"px":"0";var i=e.viewHeight-(t?n:0);this.vert.firstChild.style.height=Math.max(0,e.scrollHeight-e.clientHeight+i)+"px"}else this.vert.style.display="",this.vert.firstChild.style.height="0";if(t){this.horiz.style.display="block",this.horiz.style.right=r?n+"px":"0",this.horiz.style.left=e.barLeft+"px";var o=e.viewWidth-e.barLeft-(r?n:0);this.horiz.firstChild.style.width=e.scrollWidth-e.clientWidth+o+"px"}else this.horiz.style.display="",this.horiz.firstChild.style.width="0";return!this.checkedOverlay&&e.clientHeight>0&&(0==n&&this.overlayHack(),this.checkedOverlay=!0),{right:r?n:0,bottom:t?n:0}},setScrollLeft:function(e){this.horiz.scrollLeft!=e&&(this.horiz.scrollLeft=e)},setScrollTop:function(e){this.vert.scrollTop!=e&&(this.vert.scrollTop=e)},overlayHack:function(){var e=xo&&!mo?"12px":"18px";this.horiz.style.minHeight=this.vert.style.minWidth=e;var t=this,r=function(e){pi(e)!=t.vert&&pi(e)!=t.horiz&&Mt(t.cm,Vt)(e)};wl(this.vert,"mousedown",r),wl(this.horiz,"mousedown",r)},clear:function(){var e=this.horiz.parentNode;e.removeChild(this.horiz),e.removeChild(this.vert)}},g.prototype),v.prototype=Wi({update:function(){return{bottom:0,right:0}},setScrollLeft:function(){},setScrollTop:function(){},clear:function(){}},v.prototype),e.scrollbarModel={"native":g,"null":v},k.prototype.signal=function(e,t){wi(e,t)&&this.events.push(arguments)},k.prototype.finish=function(){for(var e=0;e<this.events.length;e++)Cl.apply(null,this.events[e])};var No=e.Pos=function(e,t){return this instanceof No?(this.line=e,void(this.ch=t)):new No(e,t)},Ao=e.cmpPos=function(e,t){return e.line-t.line||e.ch-t.ch},Wo=null;te.prototype=Wi({init:function(e){function t(e){if(n.somethingSelected())Wo=n.getSelections(),r.inaccurateSelection&&(r.prevInput="",r.inaccurateSelection=!1,o.value=Wo.join("\n"),Ol(o));else{var t=J(n);Wo=t.text,"cut"==e.type?n.setSelections(t.ranges,null,Tl):(r.prevInput="",o.value=t.text.join("\n"),Ol(o))}"cut"==e.type&&(n.state.cutIncoming=!0)}var r=this,n=this.cm,i=this.wrapper=re(),o=this.textarea=i.firstChild;e.wrapper.insertBefore(i,e.wrapper.firstChild),bo&&(o.style.width="0px"),wl(o,"input",function(){uo&&co>=9&&r.hasSelection&&(r.hasSelection=null),r.poll()}),wl(o,"paste",function(){if(fo&&!n.state.fakedLastChar&&!(new Date-n.state.lastMiddleDown<200)){var e=o.selectionStart,t=o.selectionEnd;o.value+="$",o.selectionEnd=t,o.selectionStart=e,n.state.fakedLastChar=!0}n.state.pasteIncoming=!0,r.fastPoll()}),wl(o,"cut",t),wl(o,"copy",t),wl(e.scroller,"paste",function(t){Gt(e,t)||(n.state.pasteIncoming=!0,r.focus())}),wl(e.lineSpace,"selectstart",function(t){Gt(e,t)||ml(t)})},prepareSelection:function(){var e=this.cm,t=e.display,r=e.doc,n=De(e);if(e.options.moveInputWithCursor){var i=ct(e,r.sel.primary().head,"div"),o=t.wrapper.getBoundingClientRect(),l=t.lineDiv.getBoundingClientRect();n.teTop=Math.max(0,Math.min(t.wrapper.clientHeight-10,i.top+l.top-o.top)),n.teLeft=Math.max(0,Math.min(t.wrapper.clientWidth-10,i.left+l.left-o.left))}return n},showSelection:function(e){var t=this.cm,r=t.display;Ei(r.cursorDiv,e.cursors),Ei(r.selectionDiv,e.selection),null!=e.teTop&&(this.wrapper.style.top=e.teTop+"px",this.wrapper.style.left=e.teLeft+"px")},reset:function(e){if(!this.contextMenuPending){var t,r,n=this.cm,i=n.doc;if(n.somethingSelected()){this.prevInput="";var o=i.sel.primary();t=jl&&(o.to().line-o.from().line>100||(r=n.getSelection()).length>1e3);var l=t?"-":r||n.getSelection();this.textarea.value=l,n.state.focused&&Ol(this.textarea),uo&&co>=9&&(this.hasSelection=l)}else e||(this.prevInput=this.textarea.value="",uo&&co>=9&&(this.hasSelection=null));this.inaccurateSelection=t}},getField:function(){return this.textarea},supportsTouch:function(){return!1},focus:function(){if("nocursor"!=this.cm.options.readOnly&&(!wo||Fi()!=this.textarea))try{this.textarea.focus()}catch(e){}},blur:function(){this.textarea.blur()},resetPosition:function(){this.wrapper.style.top=this.wrapper.style.left=0},receivedFocus:function(){this.slowPoll()},slowPoll:function(){var e=this;e.pollingFast||e.polling.set(this.cm.options.pollInterval,function(){e.poll(),e.cm.state.focused&&e.slowPoll()})},fastPoll:function(){function e(){var n=r.poll();n||t?(r.pollingFast=!1,r.slowPoll()):(t=!0,r.polling.set(60,e))}var t=!1,r=this;r.pollingFast=!0,r.polling.set(20,e)},poll:function(){var e=this.cm,t=this.textarea,r=this.prevInput;if(!e.state.focused||Kl(t)&&!r||Z(e)||e.options.disableInput||e.state.keySeq)return!1;e.state.pasteIncoming&&e.state.fakedLastChar&&(t.value=t.value.substring(0,t.value.length-1),e.state.fakedLastChar=!1);var n=t.value;if(n==r&&!e.somethingSelected())return!1;if(uo&&co>=9&&this.hasSelection===n||xo&&/[\uf700-\uf7ff]/.test(n))return e.display.input.reset(),!1;8203!=n.charCodeAt(0)||e.doc.sel!=e.display.selForContextMenu||r||(r="​");for(var i=0,o=Math.min(r.length,n.length);o>i&&r.charCodeAt(i)==n.charCodeAt(i);)++i;var l=this;
4
+ return Tt(e,function(){Q(e,n.slice(i),r.length-i),n.length>1e3||n.indexOf("\n")>-1?t.value=l.prevInput="":l.prevInput=n}),!0},ensurePolled:function(){this.pollingFast&&this.poll()&&(this.pollingFast=!1)},onKeyPress:function(){uo&&co>=9&&(this.hasSelection=null),this.fastPoll()},onContextMenu:function(e){function t(){if(null!=l.selectionStart){var e=i.somethingSelected(),t=l.value="​"+(e?l.value:"");n.prevInput=e?"":"​",l.selectionStart=1,l.selectionEnd=t.length,o.selForContextMenu=i.doc.sel}}function r(){if(n.contextMenuPending=!1,n.wrapper.style.position="relative",l.style.cssText=c,uo&&9>co&&o.scrollbars.setScrollTop(o.scroller.scrollTop=a),null!=l.selectionStart){(!uo||uo&&9>co)&&t();var e=0,r=function(){o.selForContextMenu==i.doc.sel&&0==l.selectionStart?Mt(i,el.selectAll)(i):e++<10?o.detectingSelectAll=setTimeout(r,500):o.input.reset()};o.detectingSelectAll=setTimeout(r,200)}}var n=this,i=n.cm,o=i.display,l=n.textarea,s=Ut(i,e),a=o.scroller.scrollTop;if(s&&!go){var u=i.options.resetSelectionOnContextMenu;u&&-1==i.doc.sel.contains(s)&&Mt(i,ke)(i.doc,he(s),Tl);var c=l.style.cssText;if(n.wrapper.style.position="absolute",l.style.cssText="position: fixed; width: 30px; height: 30px; top: "+(e.clientY-5)+"px; left: "+(e.clientX-5)+"px; z-index: 1000; background: "+(uo?"rgba(255, 255, 255, .05)":"transparent")+"; outline: none; border-width: 0; outline: none; overflow: hidden; opacity: .05; filter: alpha(opacity=5);",fo)var f=window.scrollY;if(o.input.focus(),fo&&window.scrollTo(null,f),o.input.reset(),i.somethingSelected()||(l.value=n.prevInput=" "),n.contextMenuPending=!0,o.selForContextMenu=i.doc.sel,clearTimeout(o.detectingSelectAll),uo&&co>=9&&t(),ko){bl(e);var h=function(){xl(window,"mouseup",h),setTimeout(r,20)};wl(window,"mouseup",h)}else setTimeout(r,50)}},setUneditable:Ni,needsContentAttribute:!1},te.prototype),ne.prototype=Wi({init:function(e){function t(e){if(n.somethingSelected())Wo=n.getSelections(),"cut"==e.type&&n.replaceSelection("",null,"cut");else{var t=J(n);Wo=t.text,"cut"==e.type&&n.operation(function(){n.setSelections(t.ranges,0,Tl),n.replaceSelection("",null,"cut")})}if(e.clipboardData&&!bo)e.preventDefault(),e.clipboardData.clearData(),e.clipboardData.setData("text/plain",Wo.join("\n"));else{var r=re(),i=r.firstChild;n.display.lineSpace.insertBefore(r,n.display.lineSpace.firstChild),i.value=Wo.join("\n");var o=document.activeElement;Ol(i),setTimeout(function(){n.display.lineSpace.removeChild(r),o.focus()},50)}}var r=this,n=r.cm,i=r.div=e.lineDiv;i.contentEditable="true",ee(i),wl(i,"paste",function(e){var t=e.clipboardData&&e.clipboardData.getData("text/plain");t&&(e.preventDefault(),n.replaceSelection(t,null,"paste"))}),wl(i,"compositionstart",function(e){var t=e.data;if(r.composing={sel:n.doc.sel,data:t,startData:t},t){var i=n.doc.sel.primary(),o=n.getLine(i.head.line),l=o.indexOf(t,Math.max(0,i.head.ch-t.length));l>-1&&l<=i.head.ch&&(r.composing.sel=he(No(i.head.line,l),No(i.head.line,l+t.length)))}}),wl(i,"compositionupdate",function(e){r.composing.data=e.data}),wl(i,"compositionend",function(e){var t=r.composing;t&&(e.data==t.startData||/\u200b/.test(e.data)||(t.data=e.data),setTimeout(function(){t.handled||r.applyComposition(t),r.composing==t&&(r.composing=null)},50))}),wl(i,"touchstart",function(){r.forceCompositionEnd()}),wl(i,"input",function(){r.composing||r.pollContent()||Tt(r.cm,function(){Dt(n)})}),wl(i,"copy",t),wl(i,"cut",t)},prepareSelection:function(){var e=De(this.cm,!1);return e.focus=this.cm.state.focused,e},showSelection:function(e){e&&this.cm.display.view.length&&(e.focus&&this.showPrimarySelection(),this.showMultipleSelections(e))},showPrimarySelection:function(){var e=window.getSelection(),t=this.cm.doc.sel.primary(),r=le(this.cm,e.anchorNode,e.anchorOffset),n=le(this.cm,e.focusNode,e.focusOffset);if(!r||r.bad||!n||n.bad||0!=Ao($(r,n),t.from())||0!=Ao(Y(r,n),t.to())){var i=ie(this.cm,t.from()),o=ie(this.cm,t.to());if(i||o){var l=this.cm.display.view,s=e.rangeCount&&e.getRangeAt(0);if(i){if(!o){var a=l[l.length-1].measure,u=a.maps?a.maps[a.maps.length-1]:a.map;o={node:u[u.length-1],offset:u[u.length-2]-u[u.length-3]}}}else i={node:l[0].measure.map[2],offset:0};try{var c=Dl(i.node,i.offset,o.offset,o.node)}catch(f){}c&&(e.removeAllRanges(),e.addRange(c),s&&null==e.anchorNode&&e.addRange(s)),this.rememberSelection()}}},showMultipleSelections:function(e){Ei(this.cm.display.cursorDiv,e.cursors),Ei(this.cm.display.selectionDiv,e.selection)},rememberSelection:function(){var e=window.getSelection();this.lastAnchorNode=e.anchorNode,this.lastAnchorOffset=e.anchorOffset,this.lastFocusNode=e.focusNode,this.lastFocusOffset=e.focusOffset},selectionInEditor:function(){var e=window.getSelection();if(!e.rangeCount)return!1;var t=e.getRangeAt(0).commonAncestorContainer;return zl(this.div,t)},focus:function(){"nocursor"!=this.cm.options.readOnly&&this.div.focus()},blur:function(){this.div.blur()},getField:function(){return this.div},supportsTouch:function(){return!0},receivedFocus:function(){function e(){t.cm.state.focused&&(t.pollSelection(),t.polling.set(t.cm.options.pollInterval,e))}var t=this;this.selectionInEditor()?this.pollSelection():Tt(this.cm,function(){t.cm.curOp.selectionChanged=!0}),this.polling.set(this.cm.options.pollInterval,e)},pollSelection:function(){if(!this.composing){var e=window.getSelection(),t=this.cm;if(e.anchorNode!=this.lastAnchorNode||e.anchorOffset!=this.lastAnchorOffset||e.focusNode!=this.lastFocusNode||e.focusOffset!=this.lastFocusOffset){this.rememberSelection();var r=le(t,e.anchorNode,e.anchorOffset),n=le(t,e.focusNode,e.focusOffset);r&&n&&Tt(t,function(){ke(t.doc,he(r,n),Tl),(r.bad||n.bad)&&(t.curOp.selectionChanged=!0)})}}},pollContent:function(){var e=this.cm,t=e.display,r=e.doc.sel.primary(),n=r.from(),i=r.to();if(n.line<t.viewFrom||i.line>t.viewTo-1)return!1;var o;if(n.line==t.viewFrom||0==(o=Pt(e,n.line)))var l=Yn(t.view[0].line),s=t.view[0].node;else var l=Yn(t.view[o].line),s=t.view[o-1].node.nextSibling;var a=Pt(e,i.line);if(a==t.view.length-1)var u=t.viewTo-1,c=t.view[a].node;else var u=Yn(t.view[a+1].line)-1,c=t.view[a+1].node.previousSibling;for(var f=Vl(ae(e,s,c,l,u)),h=jn(e.doc,No(l,0),No(u,Kn(e.doc,u).text.length));f.length>1&&h.length>1;)if(ki(f)==ki(h))f.pop(),h.pop(),u--;else{if(f[0]!=h[0])break;f.shift(),h.shift(),l++}for(var d=0,p=0,g=f[0],v=h[0],m=Math.min(g.length,v.length);m>d&&g.charCodeAt(d)==v.charCodeAt(d);)++d;for(var y=ki(f),b=ki(h),w=Math.min(y.length-(1==f.length?d:0),b.length-(1==h.length?d:0));w>p&&y.charCodeAt(y.length-p-1)==b.charCodeAt(b.length-p-1);)++p;f[f.length-1]=y.slice(0,y.length-p),f[0]=f[0].slice(d);var x=No(l,d),C=No(u,h.length?ki(h).length-p:0);return f.length>1||f[0]||Ao(x,C)?(Lr(e.doc,f,x,C,"+input"),!0):void 0},ensurePolled:function(){this.forceCompositionEnd()},reset:function(){this.forceCompositionEnd()},forceCompositionEnd:function(){this.composing&&!this.composing.handled&&(this.applyComposition(this.composing),this.composing.handled=!0,this.div.blur(),this.div.focus())},applyComposition:function(e){e.data&&e.data!=e.startData&&Mt(this.cm,Q)(this.cm,e.data,0,e.sel)},setUneditable:function(e){e.setAttribute("contenteditable","false")},onKeyPress:function(e){e.preventDefault(),Mt(this.cm,Q)(this.cm,String.fromCharCode(null==e.charCode?e.keyCode:e.charCode),0)},onContextMenu:Ni,resetPosition:Ni,needsContentAttribute:!0},ne.prototype),e.inputStyles={textarea:te,contenteditable:ne},ue.prototype={primary:function(){return this.ranges[this.primIndex]},equals:function(e){if(e==this)return!0;if(e.primIndex!=this.primIndex||e.ranges.length!=this.ranges.length)return!1;for(var t=0;t<this.ranges.length;t++){var r=this.ranges[t],n=e.ranges[t];if(0!=Ao(r.anchor,n.anchor)||0!=Ao(r.head,n.head))return!1}return!0},deepCopy:function(){for(var e=[],t=0;t<this.ranges.length;t++)e[t]=new ce(_(this.ranges[t].anchor),_(this.ranges[t].head));return new ue(e,this.primIndex)},somethingSelected:function(){for(var e=0;e<this.ranges.length;e++)if(!this.ranges[e].empty())return!0;return!1},contains:function(e,t){t||(t=e);for(var r=0;r<this.ranges.length;r++){var n=this.ranges[r];if(Ao(t,n.from())>=0&&Ao(e,n.to())<=0)return r}return-1}},ce.prototype={from:function(){return $(this.anchor,this.head)},to:function(){return Y(this.anchor,this.head)},empty:function(){return this.head.line==this.anchor.line&&this.head.ch==this.anchor.ch}};var Oo,Do,Ho,Io={left:0,right:0,top:0,bottom:0},Po=null,zo=0,Eo=0,Fo=0,Ro=null;uo?Ro=-.53:lo?Ro=15:po?Ro=-.7:vo&&(Ro=-1/3);var Bo=function(e){var t=e.wheelDeltaX,r=e.wheelDeltaY;return null==t&&e.detail&&e.axis==e.HORIZONTAL_AXIS&&(t=e.detail),null==r&&e.detail&&e.axis==e.VERTICAL_AXIS?r=e.detail:null==r&&(r=e.wheelDelta),{x:t,y:r}};e.wheelEventPixels=function(e){var t=Bo(e);return t.x*=Ro,t.y*=Ro,t};var Go=new Ci,Uo=null,Vo=e.changeEnd=function(e){return e.text?No(e.from.line+e.text.length-1,ki(e.text).length+(1==e.text.length?e.from.ch:0)):e.to};e.prototype={constructor:e,focus:function(){window.focus(),this.display.input.focus()},setOption:function(e,t){var r=this.options,n=r[e];(r[e]!=t||"mode"==e)&&(r[e]=t,jo.hasOwnProperty(e)&&Mt(this,jo[e])(this,t,n))},getOption:function(e){return this.options[e]},getDoc:function(){return this.doc},addKeyMap:function(e,t){this.state.keyMaps[t?"push":"unshift"](Rr(e))},removeKeyMap:function(e){for(var t=this.state.keyMaps,r=0;r<t.length;++r)if(t[r]==e||t[r].name==e)return t.splice(r,1),!0},addOverlay:Nt(function(t,r){var n=t.token?t:e.getMode(this.options,t);if(n.startState)throw new Error("Overlays may not be stateful.");this.state.overlays.push({mode:n,modeSpec:t,opaque:r&&r.opaque}),this.state.modeGen++,Dt(this)}),removeOverlay:Nt(function(e){for(var t=this.state.overlays,r=0;r<t.length;++r){var n=t[r].modeSpec;if(n==e||"string"==typeof e&&n.name==e)return t.splice(r,1),this.state.modeGen++,void Dt(this)}}),indentLine:Nt(function(e,t,r){"string"!=typeof t&&"number"!=typeof t&&(t=null==t?this.options.smartIndent?"smart":"prev":t?"add":"subtract"),ve(this.doc,e)&&Dr(this,e,t,r)}),indentSelection:Nt(function(e){for(var t=this.doc.sel.ranges,r=-1,n=0;n<t.length;n++){var i=t[n];if(i.empty())i.head.line>r&&(Dr(this,i.head.line,e,!0),r=i.head.line,n==this.doc.sel.primIndex&&Wr(this));else{var o=i.from(),l=i.to(),s=Math.max(r,o.line);r=Math.min(this.lastLine(),l.line-(l.ch?0:1))+1;for(var a=s;r>a;++a)Dr(this,a,e);var u=this.doc.sel.ranges;0==o.ch&&t.length==u.length&&u[n].from().ch>0&&xe(this.doc,n,new ce(o,u[n].to()),Tl)}}}),getTokenAt:function(e,t){return kn(this,e,t)},getLineTokens:function(e,t){return kn(this,No(e),t,!0)},getTokenTypeAt:function(e){e=pe(this.doc,e);var t,r=Nn(this,Kn(this.doc,e.line)),n=0,i=(r.length-1)/2,o=e.ch;if(0==o)t=r[2];else for(;;){var l=n+i>>1;if((l?r[2*l-1]:0)>=o)i=l;else{if(!(r[2*l+1]<o)){t=r[2*l+2];break}n=l+1}}var s=t?t.indexOf("cm-overlay "):-1;return 0>s?t:0==s?null:t.slice(0,s-1)},getModeAt:function(t){var r=this.doc.mode;return r.innerMode?e.innerMode(r,this.getTokenAt(t).state).mode:r},getHelper:function(e,t){return this.getHelpers(e,t)[0]},getHelpers:function(e,t){var r=[];if(!Zo.hasOwnProperty(t))return Zo;var n=Zo[t],i=this.getModeAt(e);if("string"==typeof i[t])n[i[t]]&&r.push(n[i[t]]);else if(i[t])for(var o=0;o<i[t].length;o++){var l=n[i[t][o]];l&&r.push(l)}else i.helperType&&n[i.helperType]?r.push(n[i.helperType]):n[i.name]&&r.push(n[i.name]);for(var o=0;o<n._global.length;o++){var s=n._global[o];s.pred(i,this)&&-1==Ti(r,s.val)&&r.push(s.val)}return r},getStateAfter:function(e,t){var r=this.doc;return e=de(r,null==e?r.first+r.size-1:e),Re(this,e+1,t)},cursorCoords:function(e,t){var r,n=this.doc.sel.primary();return r=null==e?n.head:"object"==typeof e?pe(this.doc,e):e?n.from():n.to(),ct(this,r,t||"page")},charCoords:function(e,t){return ut(this,pe(this.doc,e),t||"page")},coordsChar:function(e,t){return e=at(this,e,t||"page"),dt(this,e.left,e.top)},lineAtHeight:function(e,t){return e=at(this,{top:e,left:0},t||"page").top,$n(this.doc,e+this.display.viewOffset)},heightAtLine:function(e,t){var r=!1,n=this.doc.first+this.doc.size-1;e<this.doc.first?e=this.doc.first:e>n&&(e=n,r=!0);var i=Kn(this.doc,e);return st(this,i,{top:0,left:0},t||"page").top+(r?this.doc.height-qn(i):0)},defaultTextHeight:function(){return gt(this.display)},defaultCharWidth:function(){return vt(this.display)},setGutterMarker:Nt(function(e,t,r){return Hr(this.doc,e,"gutter",function(e){var n=e.gutterMarkers||(e.gutterMarkers={});return n[t]=r,!r&&Hi(n)&&(e.gutterMarkers=null),!0})}),clearGutter:Nt(function(e){var t=this,r=t.doc,n=r.first;r.iter(function(r){r.gutterMarkers&&r.gutterMarkers[e]&&(r.gutterMarkers[e]=null,Ht(t,n,"gutter"),Hi(r.gutterMarkers)&&(r.gutterMarkers=null)),++n})}),addLineWidget:Nt(function(e,t,r){return bn(this,e,t,r)}),removeLineWidget:function(e){e.clear()},lineInfo:function(e){if("number"==typeof e){if(!ve(this.doc,e))return null;var t=e;if(e=Kn(this.doc,e),!e)return null}else{var t=Yn(e);if(null==t)return null}return{line:t,handle:e,text:e.text,gutterMarkers:e.gutterMarkers,textClass:e.textClass,bgClass:e.bgClass,wrapClass:e.wrapClass,widgets:e.widgets}},getViewport:function(){return{from:this.display.viewFrom,to:this.display.viewTo}},addWidget:function(e,t,r,n,i){var o=this.display;e=ct(this,pe(this.doc,e));var l=e.bottom,s=e.left;if(t.style.position="absolute",t.setAttribute("cm-ignore-events","true"),this.display.input.setUneditable(t),o.sizer.appendChild(t),"over"==n)l=e.top;else if("above"==n||"near"==n){var a=Math.max(o.wrapper.clientHeight,this.doc.height),u=Math.max(o.sizer.clientWidth,o.lineSpace.clientWidth);("above"==n||e.bottom+t.offsetHeight>a)&&e.top>t.offsetHeight?l=e.top-t.offsetHeight:e.bottom+t.offsetHeight<=a&&(l=e.bottom),s+t.offsetWidth>u&&(s=u-t.offsetWidth)}t.style.top=l+"px",t.style.left=t.style.right="","right"==i?(s=o.sizer.clientWidth-t.offsetWidth,t.style.right="0px"):("left"==i?s=0:"middle"==i&&(s=(o.sizer.clientWidth-t.offsetWidth)/2),t.style.left=s+"px"),r&&Mr(this,s,l,s+t.offsetWidth,l+t.offsetHeight)},triggerOnKeyDown:Nt(or),triggerOnKeyPress:Nt(ar),triggerOnKeyUp:sr,execCommand:function(e){return el.hasOwnProperty(e)?el[e](this):void 0},findPosH:function(e,t,r,n){var i=1;0>t&&(i=-1,t=-t);for(var o=0,l=pe(this.doc,e);t>o&&(l=Pr(this.doc,l,i,r,n),!l.hitSide);++o);return l},moveH:Nt(function(e,t){var r=this;r.extendSelectionsBy(function(n){return r.display.shift||r.doc.extend||n.empty()?Pr(r.doc,n.head,e,t,r.options.rtlMoveVisually):0>e?n.from():n.to()},Nl)}),deleteH:Nt(function(e,t){var r=this.doc.sel,n=this.doc;r.somethingSelected()?n.replaceSelection("",null,"+delete"):Ir(this,function(r){var i=Pr(n,r.head,e,t,!1);return 0>e?{from:i,to:r.head}:{from:r.head,to:i}})}),findPosV:function(e,t,r,n){var i=1,o=n;0>t&&(i=-1,t=-t);for(var l=0,s=pe(this.doc,e);t>l;++l){var a=ct(this,s,"div");if(null==o?o=a.left:a.left=o,s=zr(this,a,i,r),s.hitSide)break}return s},moveV:Nt(function(e,t){var r=this,n=this.doc,i=[],o=!r.display.shift&&!n.extend&&n.sel.somethingSelected();if(n.extendSelectionsBy(function(l){if(o)return 0>e?l.from():l.to();var s=ct(r,l.head,"div");null!=l.goalColumn&&(s.left=l.goalColumn),i.push(s.left);var a=zr(r,s,e,t);return"page"==t&&l==n.sel.primary()&&Ar(r,null,ut(r,a,"div").top-s.top),a},Nl),i.length)for(var l=0;l<n.sel.ranges.length;l++)n.sel.ranges[l].goalColumn=i[l]}),findWordAt:function(e){var t=this.doc,r=Kn(t,e.line).text,n=e.ch,i=e.ch;if(r){var o=this.getHelper(e,"wordChars");(e.xRel<0||i==r.length)&&n?--n:++i;for(var l=r.charAt(n),s=Di(l,o)?function(e){return Di(e,o)}:/\s/.test(l)?function(e){return/\s/.test(e)}:function(e){return!/\s/.test(e)&&!Di(e)};n>0&&s(r.charAt(n-1));)--n;for(;i<r.length&&s(r.charAt(i));)++i}return new ce(No(e.line,n),No(e.line,i))},toggleOverwrite:function(e){(null==e||e!=this.state.overwrite)&&((this.state.overwrite=!this.state.overwrite)?Bl(this.display.cursorDiv,"CodeMirror-overwrite"):Rl(this.display.cursorDiv,"CodeMirror-overwrite"),Cl(this,"overwriteToggle",this,this.state.overwrite))},hasFocus:function(){return this.display.input.getField()==Fi()},scrollTo:Nt(function(e,t){(null!=e||null!=t)&&Or(this),null!=e&&(this.curOp.scrollLeft=e),null!=t&&(this.curOp.scrollTop=t)}),getScrollInfo:function(){var e=this.display.scroller;return{left:e.scrollLeft,top:e.scrollTop,height:e.scrollHeight-Ve(this)-this.display.barHeight,width:e.scrollWidth-Ve(this)-this.display.barWidth,clientHeight:je(this),clientWidth:Ke(this)}},scrollIntoView:Nt(function(e,t){if(null==e?(e={from:this.doc.sel.primary().head,to:null},null==t&&(t=this.options.cursorScrollMargin)):"number"==typeof e?e={from:No(e,0),to:null}:null==e.from&&(e={from:e,to:null}),e.to||(e.to=e.from),e.margin=t||0,null!=e.from.line)Or(this),this.curOp.scrollToPos=e;else{var r=Nr(this,Math.min(e.from.left,e.to.left),Math.min(e.from.top,e.to.top)-e.margin,Math.max(e.from.right,e.to.right),Math.max(e.from.bottom,e.to.bottom)+e.margin);this.scrollTo(r.scrollLeft,r.scrollTop)}}),setSize:Nt(function(e,t){function r(e){return"number"==typeof e||/^\d+$/.test(String(e))?e+"px":e}var n=this;null!=e&&(n.display.wrapper.style.width=r(e)),null!=t&&(n.display.wrapper.style.height=r(t)),n.options.lineWrapping&&nt(this);var i=n.display.viewFrom;n.doc.iter(i,n.display.viewTo,function(e){if(e.widgets)for(var t=0;t<e.widgets.length;t++)if(e.widgets[t].noHScroll){Ht(n,i,"widget");break}++i}),n.curOp.forceUpdate=!0,Cl(n,"refresh",this)}),operation:function(e){return Tt(this,e)},refresh:Nt(function(){var e=this.display.cachedTextHeight;Dt(this),this.curOp.forceUpdate=!0,it(this),this.scrollTo(this.doc.scrollLeft,this.doc.scrollTop),c(this),(null==e||Math.abs(e-gt(this.display))>.5)&&l(this),Cl(this,"refresh",this)}),swapDoc:Nt(function(e){var t=this.doc;return t.cm=null,Vn(this,e),it(this),this.display.input.reset(),this.scrollTo(e.scrollLeft,e.scrollTop),this.curOp.forceScroll=!0,vi(this,"swapDoc",this,t),t}),getInputField:function(){return this.display.input.getField()},getWrapperElement:function(){return this.display.wrapper},getScrollerElement:function(){return this.display.scroller},getGutterElement:function(){return this.display.gutters}},xi(e);var Ko=e.defaults={},jo=e.optionHandlers={},Xo=e.Init={toString:function(){return"CodeMirror.Init"}};Er("value","",function(e,t){e.setValue(t)},!0),Er("mode",null,function(e,t){e.doc.modeOption=t,r(e)},!0),Er("indentUnit",2,r,!0),Er("indentWithTabs",!1),Er("smartIndent",!0),Er("tabSize",4,function(e){n(e),it(e),Dt(e)},!0),Er("specialChars",/[\t\u0000-\u0019\u00ad\u200b-\u200f\u2028\u2029\ufeff]/g,function(e,t){e.options.specialChars=new RegExp(t.source+(t.test(" ")?"":"| "),"g"),e.refresh()},!0),Er("specialCharPlaceholder",Dn,function(e){e.refresh()},!0),Er("electricChars",!0),Er("inputStyle",wo?"contenteditable":"textarea",function(){throw new Error("inputStyle can not (yet) be changed in a running editor")},!0),Er("rtlMoveVisually",!Co),Er("wholeLineUpdateBefore",!0),Er("theme","default",function(e){s(e),a(e)},!0),Er("keyMap","default",function(t,r,n){var i=Rr(r),o=n!=e.Init&&Rr(n);o&&o.detach&&o.detach(t,i),i.attach&&i.attach(t,o||null)}),Er("extraKeys",null),Er("lineWrapping",!1,i,!0),Er("gutters",[],function(e){d(e.options),a(e)},!0),Er("fixedGutter",!0,function(e,t){e.display.gutters.style.left=t?L(e.display)+"px":"0",e.refresh()},!0),Er("coverGutterNextToScrollbar",!1,function(e){y(e)},!0),Er("scrollbarStyle","native",function(e){m(e),y(e),e.display.scrollbars.setScrollTop(e.doc.scrollTop),e.display.scrollbars.setScrollLeft(e.doc.scrollLeft)},!0),Er("lineNumbers",!1,function(e){d(e.options),a(e)},!0),Er("firstLineNumber",1,a,!0),Er("lineNumberFormatter",function(e){return e},a,!0),Er("showCursorWhenSelecting",!1,Oe,!0),Er("resetSelectionOnContextMenu",!0),Er("readOnly",!1,function(e,t){"nocursor"==t?(cr(e),e.display.input.blur(),e.display.disabled=!0):(e.display.disabled=!1,t||e.display.input.reset())}),Er("disableInput",!1,function(e,t){t||e.display.input.reset()},!0),Er("dragDrop",!0),Er("cursorBlinkRate",530),Er("cursorScrollMargin",0),Er("cursorHeight",1,Oe,!0),Er("singleCursorHeightPerLine",!0,Oe,!0),Er("workTime",100),Er("workDelay",100),Er("flattenSpans",!0,n,!0),Er("addModeClass",!1,n,!0),Er("pollInterval",100),Er("undoDepth",200,function(e,t){e.doc.history.undoDepth=t}),Er("historyEventDelay",1250),Er("viewportMargin",10,function(e){e.refresh()},!0),Er("maxHighlightLength",1e4,n,!0),Er("moveInputWithCursor",!0,function(e,t){t||e.display.input.resetPosition()}),Er("tabindex",null,function(e,t){e.display.input.getField().tabIndex=t||""}),Er("autofocus",null);var _o=e.modes={},Yo=e.mimeModes={};e.defineMode=function(t,r){e.defaults.mode||"null"==t||(e.defaults.mode=t),arguments.length>2&&(r.dependencies=Array.prototype.slice.call(arguments,2)),_o[t]=r},e.defineMIME=function(e,t){Yo[e]=t},e.resolveMode=function(t){if("string"==typeof t&&Yo.hasOwnProperty(t))t=Yo[t];else if(t&&"string"==typeof t.name&&Yo.hasOwnProperty(t.name)){var r=Yo[t.name];"string"==typeof r&&(r={name:r}),t=Ai(r,t),t.name=r.name}else if("string"==typeof t&&/^[\w\-]+\/[\w\-]+\+xml$/.test(t))return e.resolveMode("application/xml");return"string"==typeof t?{name:t}:t||{name:"null"}},e.getMode=function(t,r){var r=e.resolveMode(r),n=_o[r.name];if(!n)return e.getMode(t,"text/plain");var i=n(t,r);if($o.hasOwnProperty(r.name)){var o=$o[r.name];for(var l in o)o.hasOwnProperty(l)&&(i.hasOwnProperty(l)&&(i["_"+l]=i[l]),i[l]=o[l])}if(i.name=r.name,r.helperType&&(i.helperType=r.helperType),r.modeProps)for(var l in r.modeProps)i[l]=r.modeProps[l];return i},e.defineMode("null",function(){return{token:function(e){e.skipToEnd()}}}),e.defineMIME("text/plain","null");var $o=e.modeExtensions={};e.extendMode=function(e,t){var r=$o.hasOwnProperty(e)?$o[e]:$o[e]={};Wi(t,r)},e.defineExtension=function(t,r){e.prototype[t]=r},e.defineDocExtension=function(e,t){pl.prototype[e]=t},e.defineOption=Er;var qo=[];e.defineInitHook=function(e){qo.push(e)};var Zo=e.helpers={};e.registerHelper=function(t,r,n){Zo.hasOwnProperty(t)||(Zo[t]=e[t]={_global:[]}),Zo[t][r]=n},e.registerGlobalHelper=function(t,r,n,i){e.registerHelper(t,r,i),Zo[t]._global.push({pred:n,val:i})};var Qo=e.copyState=function(e,t){if(t===!0)return t;if(e.copyState)return e.copyState(t);var r={};for(var n in t){var i=t[n];i instanceof Array&&(i=i.concat([])),r[n]=i}return r},Jo=e.startState=function(e,t,r){return e.startState?e.startState(t,r):!0};e.innerMode=function(e,t){for(;e.innerMode;){var r=e.innerMode(t);if(!r||r.mode==e)break;t=r.state,e=r.mode}return r||{mode:e,state:t}};var el=e.commands={selectAll:function(e){e.setSelection(No(e.firstLine(),0),No(e.lastLine()),Tl)},singleSelection:function(e){e.setSelection(e.getCursor("anchor"),e.getCursor("head"),Tl)},killLine:function(e){Ir(e,function(t){if(t.empty()){var r=Kn(e.doc,t.head.line).text.length;return t.head.ch==r&&t.head.line<e.lastLine()?{from:t.head,to:No(t.head.line+1,0)}:{from:t.head,to:No(t.head.line,r)}}return{from:t.from(),to:t.to()}})},deleteLine:function(e){Ir(e,function(t){return{from:No(t.from().line,0),to:pe(e.doc,No(t.to().line+1,0))}})},delLineLeft:function(e){Ir(e,function(e){return{from:No(e.from().line,0),to:e.from()}})},delWrappedLineLeft:function(e){Ir(e,function(t){var r=e.charCoords(t.head,"div").top+5,n=e.coordsChar({left:0,top:r},"div");return{from:n,to:t.from()}})},delWrappedLineRight:function(e){Ir(e,function(t){var r=e.charCoords(t.head,"div").top+5,n=e.coordsChar({left:e.display.lineDiv.offsetWidth+100,top:r},"div");return{from:t.from(),to:n}})},undo:function(e){e.undo()},redo:function(e){e.redo()},undoSelection:function(e){e.undoSelection()},redoSelection:function(e){e.redoSelection()},goDocStart:function(e){e.extendSelection(No(e.firstLine(),0))},goDocEnd:function(e){e.extendSelection(No(e.lastLine()))},goLineStart:function(e){e.extendSelectionsBy(function(t){return Qi(e,t.head.line)},{origin:"+move",bias:1})},goLineStartSmart:function(e){e.extendSelectionsBy(function(t){return eo(e,t.head)},{origin:"+move",bias:1})},goLineEnd:function(e){e.extendSelectionsBy(function(t){return Ji(e,t.head.line)},{origin:"+move",bias:-1})},goLineRight:function(e){e.extendSelectionsBy(function(t){var r=e.charCoords(t.head,"div").top+5;return e.coordsChar({left:e.display.lineDiv.offsetWidth+100,top:r},"div")},Nl)},goLineLeft:function(e){e.extendSelectionsBy(function(t){var r=e.charCoords(t.head,"div").top+5;return e.coordsChar({left:0,top:r},"div")},Nl)},goLineLeftSmart:function(e){e.extendSelectionsBy(function(t){var r=e.charCoords(t.head,"div").top+5,n=e.coordsChar({left:0,top:r},"div");return n.ch<e.getLine(n.line).search(/\S/)?eo(e,t.head):n},Nl)},goLineUp:function(e){e.moveV(-1,"line")},goLineDown:function(e){e.moveV(1,"line")},goPageUp:function(e){e.moveV(-1,"page")},goPageDown:function(e){e.moveV(1,"page")},goCharLeft:function(e){e.moveH(-1,"char")},goCharRight:function(e){e.moveH(1,"char")},goColumnLeft:function(e){e.moveH(-1,"column")},goColumnRight:function(e){e.moveH(1,"column")},goWordLeft:function(e){e.moveH(-1,"word")},goGroupRight:function(e){e.moveH(1,"group")},goGroupLeft:function(e){e.moveH(-1,"group")},goWordRight:function(e){e.moveH(1,"word")},delCharBefore:function(e){e.deleteH(-1,"char")},delCharAfter:function(e){e.deleteH(1,"char")},delWordBefore:function(e){e.deleteH(-1,"word")},delWordAfter:function(e){e.deleteH(1,"word")},delGroupBefore:function(e){e.deleteH(-1,"group")},delGroupAfter:function(e){e.deleteH(1,"group")},indentAuto:function(e){e.indentSelection("smart")},indentMore:function(e){e.indentSelection("add")},indentLess:function(e){e.indentSelection("subtract")},insertTab:function(e){e.replaceSelection(" ")},insertSoftTab:function(e){for(var t=[],r=e.listSelections(),n=e.options.tabSize,i=0;i<r.length;i++){var o=r[i].from(),l=Al(e.getLine(o.line),o.ch,n);t.push(new Array(n-l%n+1).join(" "))}e.replaceSelections(t)},defaultTab:function(e){e.somethingSelected()?e.indentSelection("add"):e.execCommand("insertTab")},transposeChars:function(e){Tt(e,function(){for(var t=e.listSelections(),r=[],n=0;n<t.length;n++){var i=t[n].head,o=Kn(e.doc,i.line).text;if(o)if(i.ch==o.length&&(i=new No(i.line,i.ch-1)),i.ch>0)i=new No(i.line,i.ch+1),e.replaceRange(o.charAt(i.ch-1)+o.charAt(i.ch-2),No(i.line,i.ch-2),i,"+transpose");else if(i.line>e.doc.first){var l=Kn(e.doc,i.line-1).text;l&&e.replaceRange(o.charAt(0)+"\n"+l.charAt(l.length-1),No(i.line-1,l.length-1),No(i.line,1),"+transpose")}r.push(new ce(i,i))}e.setSelections(r)})},newlineAndIndent:function(e){Tt(e,function(){for(var t=e.listSelections().length,r=0;t>r;r++){var n=e.listSelections()[r];e.replaceRange("\n",n.anchor,n.head,"+input"),e.indentLine(n.from().line+1,null,!0),Wr(e)}})},toggleOverwrite:function(e){e.toggleOverwrite()}},tl=e.keyMap={};tl.basic={Left:"goCharLeft",Right:"goCharRight",Up:"goLineUp",Down:"goLineDown",End:"goLineEnd",Home:"goLineStartSmart",PageUp:"goPageUp",PageDown:"goPageDown",Delete:"delCharAfter",Backspace:"delCharBefore","Shift-Backspace":"delCharBefore",Tab:"defaultTab","Shift-Tab":"indentAuto",Enter:"newlineAndIndent",Insert:"toggleOverwrite",Esc:"singleSelection"},tl.pcDefault={"Ctrl-A":"selectAll","Ctrl-D":"deleteLine","Ctrl-Z":"undo","Shift-Ctrl-Z":"redo","Ctrl-Y":"redo","Ctrl-Home":"goDocStart","Ctrl-End":"goDocEnd","Ctrl-Up":"goLineUp","Ctrl-Down":"goLineDown","Ctrl-Left":"goGroupLeft","Ctrl-Right":"goGroupRight","Alt-Left":"goLineStart","Alt-Right":"goLineEnd","Ctrl-Backspace":"delGroupBefore","Ctrl-Delete":"delGroupAfter","Ctrl-S":"save","Ctrl-F":"find","Ctrl-G":"findNext","Shift-Ctrl-G":"findPrev","Shift-Ctrl-F":"replace","Shift-Ctrl-R":"replaceAll","Ctrl-[":"indentLess","Ctrl-]":"indentMore","Ctrl-U":"undoSelection","Shift-Ctrl-U":"redoSelection","Alt-U":"redoSelection",fallthrough:"basic"},tl.emacsy={"Ctrl-F":"goCharRight","Ctrl-B":"goCharLeft","Ctrl-P":"goLineUp","Ctrl-N":"goLineDown","Alt-F":"goWordRight","Alt-B":"goWordLeft","Ctrl-A":"goLineStart","Ctrl-E":"goLineEnd","Ctrl-V":"goPageDown","Shift-Ctrl-V":"goPageUp","Ctrl-D":"delCharAfter","Ctrl-H":"delCharBefore","Alt-D":"delWordAfter","Alt-Backspace":"delWordBefore","Ctrl-K":"killLine","Ctrl-T":"transposeChars"},tl.macDefault={"Cmd-A":"selectAll","Cmd-D":"deleteLine","Cmd-Z":"undo","Shift-Cmd-Z":"redo","Cmd-Y":"redo","Cmd-Home":"goDocStart","Cmd-Up":"goDocStart","Cmd-End":"goDocEnd","Cmd-Down":"goDocEnd","Alt-Left":"goGroupLeft","Alt-Right":"goGroupRight","Cmd-Left":"goLineLeft","Cmd-Right":"goLineRight","Alt-Backspace":"delGroupBefore","Ctrl-Alt-Backspace":"delGroupAfter","Alt-Delete":"delGroupAfter","Cmd-S":"save","Cmd-F":"find","Cmd-G":"findNext","Shift-Cmd-G":"findPrev","Cmd-Alt-F":"replace","Shift-Cmd-Alt-F":"replaceAll","Cmd-[":"indentLess","Cmd-]":"indentMore","Cmd-Backspace":"delWrappedLineLeft","Cmd-Delete":"delWrappedLineRight","Cmd-U":"undoSelection","Shift-Cmd-U":"redoSelection","Ctrl-Up":"goDocStart","Ctrl-Down":"goDocEnd",fallthrough:["basic","emacsy"]},tl["default"]=xo?tl.macDefault:tl.pcDefault,e.normalizeKeyMap=function(e){var t={};for(var r in e)if(e.hasOwnProperty(r)){var n=e[r];if(/^(name|fallthrough|(de|at)tach)$/.test(r))continue;if("..."==n){delete e[r];continue}for(var i=Mi(r.split(" "),Fr),o=0;o<i.length;o++){var l,s;o==i.length-1?(s=r,l=n):(s=i.slice(0,o+1).join(" "),l="...");var a=t[s];if(a){if(a!=l)throw new Error("Inconsistent bindings for "+s)}else t[s]=l}delete e[r]}for(var u in t)e[u]=t[u];return e};var rl=e.lookupKey=function(e,t,r,n){t=Rr(t);var i=t.call?t.call(e,n):t[e];if(i===!1)return"nothing";if("..."===i)return"multi";if(null!=i&&r(i))return"handled";if(t.fallthrough){if("[object Array]"!=Object.prototype.toString.call(t.fallthrough))return rl(e,t.fallthrough,r,n);for(var o=0;o<t.fallthrough.length;o++){var l=rl(e,t.fallthrough[o],r,n);if(l)return l}}},nl=e.isModifierKey=function(e){var t="string"==typeof e?e:_l[e.keyCode];return"Ctrl"==t||"Alt"==t||"Shift"==t||"Mod"==t},il=e.keyName=function(e,t){if(go&&34==e.keyCode&&e["char"])return!1;var r=_l[e.keyCode],n=r;return null==n||e.altGraphKey?!1:(e.altKey&&"Alt"!=r&&(n="Alt-"+n),(Lo?e.metaKey:e.ctrlKey)&&"Ctrl"!=r&&(n="Ctrl-"+n),(Lo?e.ctrlKey:e.metaKey)&&"Cmd"!=r&&(n="Cmd-"+n),!t&&e.shiftKey&&"Shift"!=r&&(n="Shift-"+n),n)};e.fromTextArea=function(t,r){function n(){t.value=u.getValue()}if(r=r?Wi(r):{},r.value=t.value,!r.tabindex&&t.tabIndex&&(r.tabindex=t.tabIndex),!r.placeholder&&t.placeholder&&(r.placeholder=t.placeholder),null==r.autofocus){var i=Fi();r.autofocus=i==t||null!=t.getAttribute("autofocus")&&i==document.body}if(t.form&&(wl(t.form,"submit",n),!r.leaveSubmitMethodAlone)){var o=t.form,l=o.submit;try{var s=o.submit=function(){n(),o.submit=l,o.submit(),o.submit=s}}catch(a){}}r.finishInit=function(e){e.save=n,e.getTextArea=function(){return t},e.toTextArea=function(){e.toTextArea=isNaN,n(),t.parentNode.removeChild(e.getWrapperElement()),t.style.display="",t.form&&(xl(t.form,"submit",n),"function"==typeof t.form.submit&&(t.form.submit=l))}},t.style.display="none";var u=e(function(e){t.parentNode.insertBefore(e,t.nextSibling)},r);return u};var ol=e.StringStream=function(e,t){this.pos=this.start=0,this.string=e,this.tabSize=t||8,this.lastColumnPos=this.lastColumnValue=0,this.lineStart=0};ol.prototype={eol:function(){return this.pos>=this.string.length},sol:function(){return this.pos==this.lineStart},peek:function(){return this.string.charAt(this.pos)||void 0},next:function(){return this.pos<this.string.length?this.string.charAt(this.pos++):void 0},eat:function(e){var t=this.string.charAt(this.pos);if("string"==typeof e)var r=t==e;else var r=t&&(e.test?e.test(t):e(t));return r?(++this.pos,t):void 0},eatWhile:function(e){for(var t=this.pos;this.eat(e););return this.pos>t},eatSpace:function(){for(var e=this.pos;/[\s\u00a0]/.test(this.string.charAt(this.pos));)++this.pos;return this.pos>e},skipToEnd:function(){this.pos=this.string.length},skipTo:function(e){var t=this.string.indexOf(e,this.pos);return t>-1?(this.pos=t,!0):void 0},backUp:function(e){this.pos-=e},column:function(){return this.lastColumnPos<this.start&&(this.lastColumnValue=Al(this.string,this.start,this.tabSize,this.lastColumnPos,this.lastColumnValue),this.lastColumnPos=this.start),
5
  this.lastColumnValue-(this.lineStart?Al(this.string,this.lineStart,this.tabSize):0)},indentation:function(){return Al(this.string,null,this.tabSize)-(this.lineStart?Al(this.string,this.lineStart,this.tabSize):0)},match:function(e,t,r){if("string"!=typeof e){var n=this.string.slice(this.pos).match(e);return n&&n.index>0?null:(n&&t!==!1&&(this.pos+=n[0].length),n)}var i=function(e){return r?e.toLowerCase():e},o=this.string.substr(this.pos,e.length);return i(o)==i(e)?(t!==!1&&(this.pos+=e.length),!0):void 0},current:function(){return this.string.slice(this.start,this.pos)},hideFirstChars:function(e,t){this.lineStart+=e;try{return t()}finally{this.lineStart-=e}}};var ll=0,sl=e.TextMarker=function(e,t){this.lines=[],this.type=t,this.doc=e,this.id=++ll};xi(sl),sl.prototype.clear=function(){if(!this.explicitlyCleared){var e=this.doc.cm,t=e&&!e.curOp;if(t&&mt(e),wi(this,"clear")){var r=this.find();r&&vi(this,"clear",r.from,r.to)}for(var n=null,i=null,o=0;o<this.lines.length;++o){var l=this.lines[o],s=Xr(l.markedSpans,this);e&&!this.collapsed?Ht(e,Yn(l),"text"):e&&(null!=s.to&&(i=Yn(l)),null!=s.from&&(n=Yn(l))),l.markedSpans=_r(l.markedSpans,s),null==s.from&&this.collapsed&&!gn(this.doc,l)&&e&&_n(l,gt(e.display))}if(e&&this.collapsed&&!e.options.lineWrapping)for(var o=0;o<this.lines.length;++o){var a=fn(this.lines[o]),u=f(a);u>e.display.maxLineLength&&(e.display.maxLine=a,e.display.maxLineLength=u,e.display.maxLineChanged=!0)}null!=n&&e&&this.collapsed&&Dt(e,n,i+1),this.lines.length=0,this.explicitlyCleared=!0,this.atomic&&this.doc.cantEdit&&(this.doc.cantEdit=!1,e&&Ne(e.doc)),e&&vi(e,"markerCleared",e,this),t&&bt(e),this.parent&&this.parent.clear()}},sl.prototype.find=function(e,t){null==e&&"bookmark"==this.type&&(e=1);for(var r,n,i=0;i<this.lines.length;++i){var o=this.lines[i],l=Xr(o.markedSpans,this);if(null!=l.from&&(r=No(t?o:Yn(o),l.from),-1==e))return r;if(null!=l.to&&(n=No(t?o:Yn(o),l.to),1==e))return n}return r&&{from:r,to:n}},sl.prototype.changed=function(){var e=this.find(-1,!0),t=this,r=this.doc.cm;e&&r&&Tt(r,function(){var n=e.line,i=Yn(e.line),o=qe(r,i);if(o&&(rt(o),r.curOp.selectionChanged=r.curOp.forceUpdate=!0),r.curOp.updateMaxLine=!0,!gn(t.doc,n)&&null!=t.height){var l=t.height;t.height=null;var s=yn(t)-l;s&&_n(n,n.height+s)}})},sl.prototype.attachLine=function(e){if(!this.lines.length&&this.doc.cm){var t=this.doc.cm.curOp;t.maybeHiddenMarkers&&-1!=Ti(t.maybeHiddenMarkers,this)||(t.maybeUnhiddenMarkers||(t.maybeUnhiddenMarkers=[])).push(this)}this.lines.push(e)},sl.prototype.detachLine=function(e){if(this.lines.splice(Ti(this.lines,e),1),!this.lines.length&&this.doc.cm){var t=this.doc.cm.curOp;(t.maybeHiddenMarkers||(t.maybeHiddenMarkers=[])).push(this)}};var ll=0,al=e.SharedTextMarker=function(e,t){this.markers=e,this.primary=t;for(var r=0;r<e.length;++r)e[r].parent=this};xi(al),al.prototype.clear=function(){if(!this.explicitlyCleared){this.explicitlyCleared=!0;for(var e=0;e<this.markers.length;++e)this.markers[e].clear();vi(this,"clear")}},al.prototype.find=function(e,t){return this.primary.find(e,t)};var ul=e.LineWidget=function(e,t,r){if(r)for(var n in r)r.hasOwnProperty(n)&&(this[n]=r[n]);this.cm=e,this.node=t};xi(ul),ul.prototype.clear=function(){var e=this.cm,t=this.line.widgets,r=this.line,n=Yn(r);if(null!=n&&t){for(var i=0;i<t.length;++i)t[i]==this&&t.splice(i--,1);t.length||(r.widgets=null);var o=yn(this);Tt(e,function(){mn(e,r,-o),Ht(e,n,"widget"),_n(r,Math.max(0,r.height-o))})}},ul.prototype.changed=function(){var e=this.height,t=this.cm,r=this.line;this.height=null;var n=yn(this)-e;n&&Tt(t,function(){t.curOp.forceUpdate=!0,mn(t,r,n),_n(r,r.height+n)})};var cl=e.Line=function(e,t,r){this.text=e,rn(this,t),this.height=r?r(this):1};xi(cl),cl.prototype.lineNo=function(){return Yn(this)};var fl={},hl={};Bn.prototype={chunkSize:function(){return this.lines.length},removeInner:function(e,t){for(var r=e,n=e+t;n>r;++r){var i=this.lines[r];this.height-=i.height,xn(i),vi(i,"delete")}this.lines.splice(e,t)},collapse:function(e){e.push.apply(e,this.lines)},insertInner:function(e,t,r){this.height+=r,this.lines=this.lines.slice(0,e).concat(t).concat(this.lines.slice(e));for(var n=0;n<t.length;++n)t[n].parent=this},iterN:function(e,t,r){for(var n=e+t;n>e;++e)if(r(this.lines[e]))return!0}},Gn.prototype={chunkSize:function(){return this.size},removeInner:function(e,t){this.size-=t;for(var r=0;r<this.children.length;++r){var n=this.children[r],i=n.chunkSize();if(i>e){var o=Math.min(t,i-e),l=n.height;if(n.removeInner(e,o),this.height-=l-n.height,i==o&&(this.children.splice(r--,1),n.parent=null),0==(t-=o))break;e=0}else e-=i}if(this.size-t<25&&(this.children.length>1||!(this.children[0]instanceof Bn))){var s=[];this.collapse(s),this.children=[new Bn(s)],this.children[0].parent=this}},collapse:function(e){for(var t=0;t<this.children.length;++t)this.children[t].collapse(e)},insertInner:function(e,t,r){this.size+=t.length,this.height+=r;for(var n=0;n<this.children.length;++n){var i=this.children[n],o=i.chunkSize();if(o>=e){if(i.insertInner(e,t,r),i.lines&&i.lines.length>50){for(;i.lines.length>50;){var l=i.lines.splice(i.lines.length-25,25),s=new Bn(l);i.height-=s.height,this.children.splice(n+1,0,s),s.parent=this}this.maybeSpill()}break}e-=o}},maybeSpill:function(){if(!(this.children.length<=10)){var e=this;do{var t=e.children.splice(e.children.length-5,5),r=new Gn(t);if(e.parent){e.size-=r.size,e.height-=r.height;var n=Ti(e.parent.children,e);e.parent.children.splice(n+1,0,r)}else{var i=new Gn(e.children);i.parent=e,e.children=[i,r],e=i}r.parent=e.parent}while(e.children.length>10);e.parent.maybeSpill()}},iterN:function(e,t,r){for(var n=0;n<this.children.length;++n){var i=this.children[n],o=i.chunkSize();if(o>e){var l=Math.min(t,o-e);if(i.iterN(e,l,r))return!0;if(0==(t-=l))break;e=0}else e-=o}}};var dl=0,pl=e.Doc=function(e,t,r){if(!(this instanceof pl))return new pl(e,t,r);null==r&&(r=0),Gn.call(this,[new Bn([new cl("",null)])]),this.first=r,this.scrollTop=this.scrollLeft=0,this.cantEdit=!1,this.cleanGeneration=1,this.frontier=r;var n=No(r,0);this.sel=he(n),this.history=new Qn(null),this.id=++dl,this.modeOption=t,"string"==typeof e&&(e=Vl(e)),Rn(this,{from:n,to:n,text:e}),ke(this,he(n),Tl)};pl.prototype=Ai(Gn.prototype,{constructor:pl,iter:function(e,t,r){r?this.iterN(e-this.first,t-e,r):this.iterN(this.first,this.first+this.size,e)},insert:function(e,t){for(var r=0,n=0;n<t.length;++n)r+=t[n].height;this.insertInner(e-this.first,t,r)},remove:function(e,t){this.removeInner(e-this.first,t)},getValue:function(e){var t=Xn(this,this.first,this.first+this.size);return e===!1?t:t.join(e||"\n")},setValue:At(function(e){var t=No(this.first,0),r=this.first+this.size-1;yr(this,{from:t,to:No(r,Kn(this,r).text.length),text:Vl(e),origin:"setValue",full:!0},!0),ke(this,he(t))}),replaceRange:function(e,t,r,n){t=pe(this,t),r=r?pe(this,r):t,Lr(this,e,t,r,n)},getRange:function(e,t,r){var n=jn(this,pe(this,e),pe(this,t));return r===!1?n:n.join(r||"\n")},getLine:function(e){var t=this.getLineHandle(e);return t&&t.text},getLineHandle:function(e){return ve(this,e)?Kn(this,e):void 0},getLineNumber:function(e){return Yn(e)},getLineHandleVisualStart:function(e){return"number"==typeof e&&(e=Kn(this,e)),fn(e)},lineCount:function(){return this.size},firstLine:function(){return this.first},lastLine:function(){return this.first+this.size-1},clipPos:function(e){return pe(this,e)},getCursor:function(e){var t,r=this.sel.primary();return t=null==e||"head"==e?r.head:"anchor"==e?r.anchor:"end"==e||"to"==e||e===!1?r.to():r.from()},listSelections:function(){return this.sel.ranges},somethingSelected:function(){return this.sel.somethingSelected()},setCursor:At(function(e,t,r){Ce(this,pe(this,"number"==typeof e?No(e,t||0):e),null,r)}),setSelection:At(function(e,t,r){Ce(this,pe(this,e),pe(this,t||e),r)}),extendSelection:At(function(e,t,r){be(this,pe(this,e),t&&pe(this,t),r)}),extendSelections:At(function(e,t){we(this,me(this,e,t))}),extendSelectionsBy:At(function(e,t){we(this,Mi(this.sel.ranges,e),t)}),setSelections:At(function(e,t,r){if(e.length){for(var n=0,i=[];n<e.length;n++)i[n]=new ce(pe(this,e[n].anchor),pe(this,e[n].head));null==t&&(t=Math.min(e.length-1,this.sel.primIndex)),ke(this,fe(i,t),r)}}),addSelection:At(function(e,t,r){var n=this.sel.ranges.slice(0);n.push(new ce(pe(this,e),pe(this,t||e))),ke(this,fe(n,n.length-1),r)}),getSelection:function(e){for(var t,r=this.sel.ranges,n=0;n<r.length;n++){var i=jn(this,r[n].from(),r[n].to());t=t?t.concat(i):i}return e===!1?t:t.join(e||"\n")},getSelections:function(e){for(var t=[],r=this.sel.ranges,n=0;n<r.length;n++){var i=jn(this,r[n].from(),r[n].to());e!==!1&&(i=i.join(e||"\n")),t[n]=i}return t},replaceSelection:function(e,t,r){for(var n=[],i=0;i<this.sel.ranges.length;i++)n[i]=e;this.replaceSelections(n,t,r||"+input")},replaceSelections:At(function(e,t,r){for(var n=[],i=this.sel,o=0;o<i.ranges.length;o++){var l=i.ranges[o];n[o]={from:l.from(),to:l.to(),text:Vl(e[o]),origin:r}}for(var s=t&&"end"!=t&&vr(this,n,t),o=n.length-1;o>=0;o--)yr(this,n[o]);s?Le(this,s):this.cm&&Wr(this.cm)}),undo:At(function(){wr(this,"undo")}),redo:At(function(){wr(this,"redo")}),undoSelection:At(function(){wr(this,"undo",!0)}),redoSelection:At(function(){wr(this,"redo",!0)}),setExtending:function(e){this.extend=e},getExtending:function(){return this.extend},historySize:function(){for(var e=this.history,t=0,r=0,n=0;n<e.done.length;n++)e.done[n].ranges||++t;for(var n=0;n<e.undone.length;n++)e.undone[n].ranges||++r;return{undo:t,redo:r}},clearHistory:function(){this.history=new Qn(this.history.maxGeneration)},markClean:function(){this.cleanGeneration=this.changeGeneration(!0)},changeGeneration:function(e){return e&&(this.history.lastOp=this.history.lastSelOp=this.history.lastOrigin=null),this.history.generation},isClean:function(e){return this.history.generation==(e||this.cleanGeneration)},getHistory:function(){return{done:ui(this.history.done),undone:ui(this.history.undone)}},setHistory:function(e){var t=this.history=new Qn(this.history.maxGeneration);t.done=ui(e.done.slice(0),null,!0),t.undone=ui(e.undone.slice(0),null,!0)},addLineClass:At(function(e,t,r){return Hr(this,e,"gutter"==t?"gutter":"class",function(e){var n="text"==t?"textClass":"background"==t?"bgClass":"gutter"==t?"gutterClass":"wrapClass";if(e[n]){if(Ri(r).test(e[n]))return!1;e[n]+=" "+r}else e[n]=r;return!0})}),removeLineClass:At(function(e,t,r){return Hr(this,e,"gutter"==t?"gutter":"class",function(e){var n="text"==t?"textClass":"background"==t?"bgClass":"gutter"==t?"gutterClass":"wrapClass",i=e[n];if(!i)return!1;if(null==r)e[n]=null;else{var o=i.match(Ri(r));if(!o)return!1;var l=o.index+o[0].length;e[n]=i.slice(0,o.index)+(o.index&&l!=i.length?" ":"")+i.slice(l)||null}return!0})}),markText:function(e,t,r){return Br(this,pe(this,e),pe(this,t),r,"range")},setBookmark:function(e,t){var r={replacedWith:t&&(null==t.nodeType?t.widget:t),insertLeft:t&&t.insertLeft,clearWhenEmpty:!1,shared:t&&t.shared};return e=pe(this,e),Br(this,e,e,r,"bookmark")},findMarksAt:function(e){e=pe(this,e);var t=[],r=Kn(this,e.line).markedSpans;if(r)for(var n=0;n<r.length;++n){var i=r[n];(null==i.from||i.from<=e.ch)&&(null==i.to||i.to>=e.ch)&&t.push(i.marker.parent||i.marker)}return t},findMarks:function(e,t,r){e=pe(this,e),t=pe(this,t);var n=[],i=e.line;return this.iter(e.line,t.line+1,function(o){var l=o.markedSpans;if(l)for(var s=0;s<l.length;s++){var a=l[s];i==e.line&&e.ch>a.to||null==a.from&&i!=e.line||i==t.line&&a.from>t.ch||r&&!r(a.marker)||n.push(a.marker.parent||a.marker)}++i}),n},getAllMarks:function(){var e=[];return this.iter(function(t){var r=t.markedSpans;if(r)for(var n=0;n<r.length;++n)null!=r[n].from&&e.push(r[n].marker)}),e},posFromIndex:function(e){var t,r=this.first;return this.iter(function(n){var i=n.text.length+1;return i>e?(t=e,!0):(e-=i,void++r)}),pe(this,No(r,t))},indexFromPos:function(e){e=pe(this,e);var t=e.ch;return e.line<this.first||e.ch<0?0:(this.iter(this.first,e.line,function(e){t+=e.text.length+1}),t)},copy:function(e){var t=new pl(Xn(this,this.first,this.first+this.size),this.modeOption,this.first);return t.scrollTop=this.scrollTop,t.scrollLeft=this.scrollLeft,t.sel=this.sel,t.extend=!1,e&&(t.history.undoDepth=this.history.undoDepth,t.setHistory(this.getHistory())),t},linkedDoc:function(e){e||(e={});var t=this.first,r=this.first+this.size;null!=e.from&&e.from>t&&(t=e.from),null!=e.to&&e.to<r&&(r=e.to);var n=new pl(Xn(this,t,r),e.mode||this.modeOption,t);return e.sharedHist&&(n.history=this.history),(this.linked||(this.linked=[])).push({doc:n,sharedHist:e.sharedHist}),n.linked=[{doc:this,isParent:!0,sharedHist:e.sharedHist}],Vr(n,Ur(this)),n},unlinkDoc:function(t){if(t instanceof e&&(t=t.doc),this.linked)for(var r=0;r<this.linked.length;++r){var n=this.linked[r];if(n.doc==t){this.linked.splice(r,1),t.unlinkDoc(this),Kr(Ur(this));break}}if(t.history==this.history){var i=[t.id];Un(t,function(e){i.push(e.id)},!0),t.history=new Qn(null),t.history.done=ui(this.history.done,i),t.history.undone=ui(this.history.undone,i)}},iterLinkedDocs:function(e){Un(this,e)},getMode:function(){return this.mode},getEditor:function(){return this.cm}}),pl.prototype.eachLine=pl.prototype.iter;var gl="iter insert remove copy getEditor".split(" ");for(var vl in pl.prototype)pl.prototype.hasOwnProperty(vl)&&Ti(gl,vl)<0&&(e.prototype[vl]=function(e){return function(){return e.apply(this.doc,arguments)}}(pl.prototype[vl]));xi(pl);var ml=e.e_preventDefault=function(e){e.preventDefault?e.preventDefault():e.returnValue=!1},yl=e.e_stopPropagation=function(e){e.stopPropagation?e.stopPropagation():e.cancelBubble=!0},bl=e.e_stop=function(e){ml(e),yl(e)},wl=e.on=function(e,t,r){if(e.addEventListener)e.addEventListener(t,r,!1);else if(e.attachEvent)e.attachEvent("on"+t,r);else{var n=e._handlers||(e._handlers={}),i=n[t]||(n[t]=[]);i.push(r)}},xl=e.off=function(e,t,r){if(e.removeEventListener)e.removeEventListener(t,r,!1);else if(e.detachEvent)e.detachEvent("on"+t,r);else{var n=e._handlers&&e._handlers[t];if(!n)return;for(var i=0;i<n.length;++i)if(n[i]==r){n.splice(i,1);break}}},Cl=e.signal=function(e,t){var r=e._handlers&&e._handlers[t];if(r)for(var n=Array.prototype.slice.call(arguments,2),i=0;i<r.length;++i)r[i].apply(null,n)},Sl=null,Ll=30,kl=e.Pass={toString:function(){return"CodeMirror.Pass"}},Tl={scroll:!1},Ml={origin:"*mouse"},Nl={origin:"+move"};Ci.prototype.set=function(e,t){clearTimeout(this.id),this.id=setTimeout(t,e)};var Al=e.countColumn=function(e,t,r,n,i){null==t&&(t=e.search(/[^\s\u00a0]/),-1==t&&(t=e.length));for(var o=n||0,l=i||0;;){var s=e.indexOf(" ",o);if(0>s||s>=t)return l+(t-o);l+=s-o,l+=r-l%r,o=s+1}},Wl=[""],Ol=function(e){e.select()};bo?Ol=function(e){e.selectionStart=0,e.selectionEnd=e.value.length}:uo&&(Ol=function(e){try{e.select()}catch(t){}});var Dl,Hl=/[\u00df\u0590-\u05f4\u0600-\u06ff\u3040-\u309f\u30a0-\u30ff\u3400-\u4db5\u4e00-\u9fcc\uac00-\ud7af]/,Il=e.isWordChar=function(e){return/\w/.test(e)||e>"€"&&(e.toUpperCase()!=e.toLowerCase()||Hl.test(e))},Pl=/[\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]/;Dl=document.createRange?function(e,t,r,n){var i=document.createRange();return i.setEnd(n||e,r),i.setStart(e,t),i}:function(e,t,r){var n=document.body.createTextRange();try{n.moveToElementText(e.parentNode)}catch(i){return n}return n.collapse(!0),n.moveEnd("character",r),n.moveStart("character",t),n};var zl=e.contains=function(e,t){if(3==t.nodeType&&(t=t.parentNode),e.contains)return e.contains(t);do if(11==t.nodeType&&(t=t.host),t==e)return!0;while(t=t.parentNode)};uo&&11>co&&(Fi=function(){try{return document.activeElement}catch(e){return document.body}});var El,Fl,Rl=e.rmClass=function(e,t){var r=e.className,n=Ri(t).exec(r);if(n){var i=r.slice(n.index+n[0].length);e.className=r.slice(0,n.index)+(i?n[1]+i:"")}},Bl=e.addClass=function(e,t){var r=e.className;Ri(t).test(r)||(e.className+=(r?" ":"")+t)},Gl=!1,Ul=function(){if(uo&&9>co)return!1;var e=Pi("div");return"draggable"in e||"dragDrop"in e}(),Vl=e.splitLines=3!="\n\nb".split(/\n/).length?function(e){for(var t=0,r=[],n=e.length;n>=t;){var i=e.indexOf("\n",t);-1==i&&(i=e.length);var o=e.slice(t,"\r"==e.charAt(i-1)?i-1:i),l=o.indexOf("\r");-1!=l?(r.push(o.slice(0,l)),t+=l+1):(r.push(o),t=i+1)}return r}:function(e){return e.split(/\r\n?|\n/)},Kl=window.getSelection?function(e){try{return e.selectionStart!=e.selectionEnd}catch(t){return!1}}:function(e){try{var t=e.ownerDocument.selection.createRange()}catch(r){}return t&&t.parentElement()==e?0!=t.compareEndPoints("StartToEnd",t):!1},jl=function(){var e=Pi("div");return"oncopy"in e?!0:(e.setAttribute("oncopy","return;"),"function"==typeof e.oncopy)}(),Xl=null,_l={3:"Enter",8:"Backspace",9:"Tab",13:"Enter",16:"Shift",17:"Ctrl",18:"Alt",19:"Pause",20:"CapsLock",27:"Esc",32:"Space",33:"PageUp",34:"PageDown",35:"End",36:"Home",37:"Left",38:"Up",39:"Right",40:"Down",44:"PrintScrn",45:"Insert",46:"Delete",59:";",61:"=",91:"Mod",92:"Mod",93:"Mod",107:"=",109:"-",127:"Delete",173:"-",186:";",187:"=",188:",",189:"-",190:".",191:"/",192:"`",219:"[",220:"\\",221:"]",222:"'",63232:"Up",63233:"Down",63234:"Left",63235:"Right",63272:"Delete",63273:"Home",63275:"End",63276:"PageUp",63277:"PageDown",63302:"Insert"};e.keyNames=_l,function(){for(var e=0;10>e;e++)_l[e+48]=_l[e+96]=String(e);for(var e=65;90>=e;e++)_l[e]=String.fromCharCode(e);for(var e=1;12>=e;e++)_l[e+111]=_l[e+63235]="F"+e}();var Yl,$l=function(){function e(e){return 247>=e?r.charAt(e):e>=1424&&1524>=e?"R":e>=1536&&1773>=e?n.charAt(e-1536):e>=1774&&2220>=e?"r":e>=8192&&8203>=e?"w":8204==e?"b":"L"}function t(e,t,r){this.level=e,this.from=t,this.to=r}var r="bbbbbbbbbtstwsbbbbbbbbbbbbbbssstwNN%%%NNNNNN,N,N1111111111NNNNNNNLLLLLLLLLLLLLLLLLLLLLLLLLLNNNNNNLLLLLLLLLLLLLLLLLLLLLLLLLLNNNNbbbbbbsbbbbbbbbbbbbbbbbbbbbbbbbbb,N%%%%NNNNLNNNNN%%11NLNNN1LNNNNNLLLLLLLLLLLLLLLLLLLLLLLNLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLN",n="rrrrrrrrrrrr,rNNmmmmmmrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrmmmmmmmmmmmmmmrrrrrrrnnnnnnnnnn%nnrrrmrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrmmmmmmmmmmmmmmmmmmmNmmmm",i=/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac]/,o=/[stwN]/,l=/[LRr]/,s=/[Lb1n]/,a=/[1n]/,u="L";return function(r){if(!i.test(r))return!1;for(var n,c=r.length,f=[],h=0;c>h;++h)f.push(n=e(r.charCodeAt(h)));for(var h=0,d=u;c>h;++h){var n=f[h];"m"==n?f[h]=d:d=n}for(var h=0,p=u;c>h;++h){var n=f[h];"1"==n&&"r"==p?f[h]="n":l.test(n)&&(p=n,"r"==n&&(f[h]="R"))}for(var h=1,d=f[0];c-1>h;++h){var n=f[h];"+"==n&&"1"==d&&"1"==f[h+1]?f[h]="1":","!=n||d!=f[h+1]||"1"!=d&&"n"!=d||(f[h]=d),d=n}for(var h=0;c>h;++h){var n=f[h];if(","==n)f[h]="N";else if("%"==n){for(var g=h+1;c>g&&"%"==f[g];++g);for(var v=h&&"!"==f[h-1]||c>g&&"1"==f[g]?"1":"N",m=h;g>m;++m)f[m]=v;h=g-1}}for(var h=0,p=u;c>h;++h){var n=f[h];"L"==p&&"1"==n?f[h]="L":l.test(n)&&(p=n)}for(var h=0;c>h;++h)if(o.test(f[h])){for(var g=h+1;c>g&&o.test(f[g]);++g);for(var y="L"==(h?f[h-1]:u),b="L"==(c>g?f[g]:u),v=y||b?"L":"R",m=h;g>m;++m)f[m]=v;h=g-1}for(var w,x=[],h=0;c>h;)if(s.test(f[h])){var C=h;for(++h;c>h&&s.test(f[h]);++h);x.push(new t(0,C,h))}else{var S=h,L=x.length;for(++h;c>h&&"L"!=f[h];++h);for(var m=S;h>m;)if(a.test(f[m])){m>S&&x.splice(L,0,new t(1,S,m));var k=m;for(++m;h>m&&a.test(f[m]);++m);x.splice(L,0,new t(2,k,m)),S=m}else++m;h>S&&x.splice(L,0,new t(1,S,h))}return 1==x[0].level&&(w=r.match(/^\s+/))&&(x[0].from=w[0].length,x.unshift(new t(0,0,w[0].length))),1==ki(x).level&&(w=r.match(/\s+$/))&&(ki(x).to-=w[0].length,x.push(new t(0,c-w[0].length,c))),x[0].level!=ki(x).level&&x.push(new t(x[0].level,c,c)),x}}();return e.version="5.0.0",e});
admin/js/overall.js CHANGED
@@ -1,88 +1,88 @@
1
- jQuery(document).ready(function($) {
2
-
3
- function dismissRemoveMessage() {
4
- $.ajax({
5
- 'url': ajaxurl,
6
- 'method': 'POST',
7
- 'data': {
8
- 'action': 'cf7_style_remove_box'
9
- },
10
- 'success': function(data) {}
11
- });
12
- }
13
-
14
- if ($('.post-type-cf7_style.post-php').length > 0) {
15
- $('.meta-box-sortables').sortable({
16
- disabled: true
17
- });
18
- }
19
- $('.cf7_style_page_cf7style-settings .cf7style-tooltip').on('click', function(e) {
20
- e.preventDefault();
21
- e.stopPropagation();
22
- $('.cf7style-tooltip-content').removeClass('show');
23
- if ($(this).hasClass('on')) {
24
- $('.cf7style-tooltip-content').removeClass('show');
25
- $('.cf7_style_page_cf7style-settings .cf7style-tooltip').removeClass('on');
26
- } else {
27
- $(this).find('.cf7style-tooltip-content').addClass('show');
28
- $(this).addClass('on');
29
- }
30
- });
31
- $('.cf7_style_page_cf7style-settings').on('click', function(e) {
32
- $('.cf7style-tooltip-content').removeClass('show');
33
- $('.cf7_style_page_cf7style-settings .cf7style-tooltip').removeClass('on');
34
- });
35
- $('.cf7style-tooltip-content').on('click', function(e){
36
- e.stopPropagation();
37
- });
38
- $('.remove_template_notice').on('click', function(e) {
39
- e.preventDefault();
40
- $('.template-message-box').fadeOut('slow');
41
- dismissRemoveMessage();
42
- });
43
- $(document).on('click', '.cf7style-pointer a.close', function(e) {
44
- e.preventDefault();
45
- if ($('#cf7_style_allow_tracking').is(':checked')) {
46
- $.post(ajaxurl, "action=cf7_style_allow_tracking&cf7_style_allow_tracking=1", function(res) {});
47
- } else {
48
- $.post(ajaxurl, "action=cf7_style_show_tracking&cf7_style_allow_tracking=0", function(res) {});
49
- }
50
- });
51
- $('input[name="custom_template_check"]').on('change', function() {
52
- if ($(this).is(':checked')) {
53
- $('.double-check').show();
54
- } else {
55
- $('.double-check').hide();
56
- }
57
- });
58
- $('.confirm-remove-template').on('click', function(e) {
59
- e.preventDefault();
60
- var curParent = $(this).parent();
61
- if ($('input[name="double_check_template"]:checked').val() == "no") {
62
- curParent.hide();
63
- $('input[name="custom_template_check"]').attr('checked', 'checked');
64
- } else {
65
- dismissRemoveMessage();
66
- $.ajax({
67
- 'url': ajaxurl,
68
- 'method': 'POST',
69
- 'data': {
70
- 'action': 'cf7_style_remove_templates'
71
- },
72
- 'success': function(data) {
73
- if (data) {
74
- $('<p class="succeded">Predefined templates successfully removed.</p>').appendTo(curParent);
75
- setTimeout(function() {
76
- curParent.fadeOut('slow');
77
- curParent.parent().fadeOut('slow', function() {
78
- setTimeout(function() {
79
- window.location.reload(false);
80
- }, 300);
81
- });
82
- }, 2000);
83
- }
84
- }
85
- });
86
- }
87
- });
88
- });
1
+ jQuery(document).ready(function($) {
2
+
3
+ function dismissRemoveMessage() {
4
+ $.ajax({
5
+ 'url': ajaxurl,
6
+ 'method': 'POST',
7
+ 'data': {
8
+ 'action': 'cf7_style_remove_box'
9
+ },
10
+ 'success': function(data) {}
11
+ });
12
+ }
13
+
14
+ if ($('.post-type-cf7_style.post-php').length > 0) {
15
+ $('.meta-box-sortables').sortable({
16
+ disabled: true
17
+ });
18
+ }
19
+ $('.cf7_style_page_cf7style-settings .cf7style-tooltip').on('click', function(e) {
20
+ e.preventDefault();
21
+ e.stopPropagation();
22
+ $('.cf7style-tooltip-content').removeClass('show');
23
+ if ($(this).hasClass('on')) {
24
+ $('.cf7style-tooltip-content').removeClass('show');
25
+ $('.cf7_style_page_cf7style-settings .cf7style-tooltip').removeClass('on');
26
+ } else {
27
+ $(this).find('.cf7style-tooltip-content').addClass('show');
28
+ $(this).addClass('on');
29
+ }
30
+ });
31
+ $('.cf7_style_page_cf7style-settings').on('click', function(e) {
32
+ $('.cf7style-tooltip-content').removeClass('show');
33
+ $('.cf7_style_page_cf7style-settings .cf7style-tooltip').removeClass('on');
34
+ });
35
+ $('.cf7style-tooltip-content').on('click', function(e){
36
+ e.stopPropagation();
37
+ });
38
+ $('.remove_template_notice').on('click', function(e) {
39
+ e.preventDefault();
40
+ $('.template-message-box').fadeOut('slow');
41
+ dismissRemoveMessage();
42
+ });
43
+ $(document).on('click', '.cf7style-pointer a.close', function(e) {
44
+ e.preventDefault();
45
+ if ($('#cf7_style_allow_tracking').is(':checked')) {
46
+ $.post(ajaxurl, "action=cf7_style_allow_tracking&cf7_style_allow_tracking=1", function(res) {});
47
+ } else {
48
+ $.post(ajaxurl, "action=cf7_style_show_tracking&cf7_style_allow_tracking=0", function(res) {});
49
+ }
50
+ });
51
+ $('input[name="custom_template_check"]').on('change', function() {
52
+ if ($(this).is(':checked')) {
53
+ $('.double-check').show();
54
+ } else {
55
+ $('.double-check').hide();
56
+ }
57
+ });
58
+ $('.confirm-remove-template').on('click', function(e) {
59
+ e.preventDefault();
60
+ var curParent = $(this).parent();
61
+ if ($('input[name="double_check_template"]:checked').val() == "no") {
62
+ curParent.hide();
63
+ $('input[name="custom_template_check"]').attr('checked', 'checked');
64
+ } else {
65
+ dismissRemoveMessage();
66
+ $.ajax({
67
+ 'url': ajaxurl,
68
+ 'method': 'POST',
69
+ 'data': {
70
+ 'action': 'cf7_style_remove_templates'
71
+ },
72
+ 'success': function(data) {
73
+ if (data) {
74
+ $('<p class="succeded">Predefined templates successfully removed.</p>').appendTo(curParent);
75
+ setTimeout(function() {
76
+ curParent.fadeOut('slow');
77
+ curParent.parent().fadeOut('slow', function() {
78
+ setTimeout(function() {
79
+ window.location.reload(false);
80
+ }, 300);
81
+ });
82
+ }, 2000);
83
+ }
84
+ }
85
+ });
86
+ }
87
+ });
88
+ });
admin/js/quick.edit.js CHANGED
@@ -1,70 +1,70 @@
1
- ( function( $ ) {
2
- // we create a copy of the WP inline edit post function
3
- var $wp_inline_edit = inlineEditPost.edit;
4
-
5
- // and then we overwrite the function with our own code
6
- inlineEditPost.edit = function( id ) {
7
-
8
- // "call" the original WP edit function
9
- $wp_inline_edit.apply( this, arguments );
10
-
11
- // get the post ID
12
- var $post_id = 0;
13
- if ( typeof( id ) == 'object' )
14
- $post_id = parseInt( this.getId( id ) );
15
-
16
- if ( $post_id > 0 ) {
17
- //console.log( "Post id: " + $post_id );
18
-
19
- var forms = [];
20
- var unchecked = [];
21
- checkbox = jQuery( '.data input[type="checkbox"]' );
22
-
23
- jQuery.each( checkbox, function( index, value ) {
24
- forms.push( $( this ).attr( 'data-id' ) );
25
- } );
26
-
27
- var uniqueNames = [];
28
- $.each( forms, function( i, el ) {
29
- if( $.inArray( el, uniqueNames ) === -1 ) uniqueNames.push( el );
30
- } );
31
-
32
- jQuery.each( uniqueNames, function( index, value ) {
33
- var form = $("#form\\[" + value + "\\]")
34
-
35
- if( form.attr( 'data-style' ) == $post_id ) {
36
- form.prop( 'checked', true );
37
- form.parent().parent().next().hide();
38
- } else {
39
- form.prop( 'checked', false );
40
- form.parent().parent().next().show();
41
- }
42
-
43
- // reset hidden fields
44
- $( '.cf7-quick-edit .hidden-fields' ).html( '' );
45
-
46
- if( form.is( ":checked" ) ) {
47
-
48
- unchecked.push( form.attr( 'data-id' ) );
49
-
50
- form.on( "click", function() {
51
- if( ! form.prop( "checked" ) ) {
52
- $( '.cf7-quick-edit .hidden-fields' ).append( '<input type="hidden" name="remove-' + form.attr( 'id' ) + '" id="remove-' + form.attr( 'id' ) + '" value="on">' );
53
- } else {
54
- $("#remove-form\\[" + form.attr( 'data-id' ) + "\\]").remove();
55
- }
56
- } );
57
- }
58
-
59
- } );
60
- }
61
-
62
- };
63
-
64
- $( ".inline-edit-cf7_style .button-primary" ).on( "click", function() {
65
- var url = window.location.href;
66
- $( ".cf7-quick-edit" ).load( url + " .cf7-quick-edit >" );
67
- } );
68
-
69
-
70
  } )( jQuery );
1
+ ( function( $ ) {
2
+ // we create a copy of the WP inline edit post function
3
+ var $wp_inline_edit = inlineEditPost.edit;
4
+
5
+ // and then we overwrite the function with our own code
6
+ inlineEditPost.edit = function( id ) {
7
+
8
+ // "call" the original WP edit function
9
+ $wp_inline_edit.apply( this, arguments );
10
+
11
+ // get the post ID
12
+ var $post_id = 0;
13
+ if ( typeof( id ) == 'object' )
14
+ $post_id = parseInt( this.getId( id ) );
15
+
16
+ if ( $post_id > 0 ) {
17
+ //console.log( "Post id: " + $post_id );
18
+
19
+ var forms = [];
20
+ var unchecked = [];
21
+ checkbox = jQuery( '.data input[type="checkbox"]' );
22
+
23
+ jQuery.each( checkbox, function( index, value ) {
24
+ forms.push( $( this ).attr( 'data-id' ) );
25
+ } );
26
+
27
+ var uniqueNames = [];
28
+ $.each( forms, function( i, el ) {
29
+ if( $.inArray( el, uniqueNames ) === -1 ) uniqueNames.push( el );
30
+ } );
31
+
32
+ jQuery.each( uniqueNames, function( index, value ) {
33
+ var form = $("#form\\[" + value + "\\]")
34
+
35
+ if( form.attr( 'data-style' ) == $post_id ) {
36
+ form.prop( 'checked', true );
37
+ form.parent().parent().next().hide();
38
+ } else {
39
+ form.prop( 'checked', false );
40
+ form.parent().parent().next().show();
41
+ }
42
+
43
+ // reset hidden fields
44
+ $( '.cf7-quick-edit .hidden-fields' ).html( '' );
45
+
46
+ if( form.is( ":checked" ) ) {
47
+
48
+ unchecked.push( form.attr( 'data-id' ) );
49
+
50
+ form.on( "click", function() {
51
+ if( ! form.prop( "checked" ) ) {
52
+ $( '.cf7-quick-edit .hidden-fields' ).append( '<input type="hidden" name="remove-' + form.attr( 'id' ) + '" id="remove-' + form.attr( 'id' ) + '" value="on">' );
53
+ } else {
54
+ $("#remove-form\\[" + form.attr( 'data-id' ) + "\\]").remove();
55
+ }
56
+ } );
57
+ }
58
+
59
+ } );
60
+ }
61
+
62
+ };
63
+
64
+ $( ".inline-edit-cf7_style .button-primary" ).on( "click", function() {
65
+ var url = window.location.href;
66
+ $( ".cf7-quick-edit" ).load( url + " .cf7-quick-edit >" );
67
+ } );
68
+
69
+
70
  } )( jQuery );
admin/predefined_tpls.php CHANGED
@@ -1,3 +1,3 @@
1
- <?php
2
-
3
  $tpl_string = '[{"title":"Monochrome Light","category":"simple pattern style","image":"/admin/images/monochrome-light.png"},{"title":"Transparent Two Columns","category":"simple pattern style","image":"/admin/images/transparent-two-columns.png"},{"title":"Minimal Brown","category":"simple pattern style","image":"/admin/images/minimal-brown.png"},{"title":"Monochrome","category":"simple pattern style","image":"/admin/images/monochrome.png"},{"title":"Twenty Fifteen Pattern","category":"simple pattern style","image":"/admin/images/cf7_simple_twentyfifteen_pattern.jpg"},{"title":"Christmas Classic","category":"christmas style","image":"/admin/images/cf7_xmas_classic.jpg"},{"title":"Christmas Red","category":"christmas style","image":"/admin/images/cf7_xmas_red.jpg"},{"title":"Christmas Simple","category":"christmas style","image":"/admin/images/cf7_xmas_simple.jpg"},{"title":"Valentine\'s Day Classic","category":"valentine\'s day style","image":"/admin/images/cf7_vday_classic.jpg"},{"title":"Valentine\'s Day Roses","category":"valentine\'s day style","image":"/admin/images/cf7_vday_roses.jpg"},{"title":"Valentine\'s Day Birds","category":"valentine\'s day style","image":"/admin/images/cf7_vday_birds.jpg"},{"title":"Valentine\'s Day Blue Birds","category":"valentine\'s day style","image":"/admin/images/cf7_vday_blue_birds.jpg"}]';
1
+ <?php
2
+
3
  $tpl_string = '[{"title":"Monochrome Light","category":"simple pattern style","image":"/admin/images/monochrome-light.png"},{"title":"Transparent Two Columns","category":"simple pattern style","image":"/admin/images/transparent-two-columns.png"},{"title":"Minimal Brown","category":"simple pattern style","image":"/admin/images/minimal-brown.png"},{"title":"Monochrome","category":"simple pattern style","image":"/admin/images/monochrome.png"},{"title":"Twenty Fifteen Pattern","category":"simple pattern style","image":"/admin/images/cf7_simple_twentyfifteen_pattern.jpg"},{"title":"Christmas Classic","category":"christmas style","image":"/admin/images/cf7_xmas_classic.jpg"},{"title":"Christmas Red","category":"christmas style","image":"/admin/images/cf7_xmas_red.jpg"},{"title":"Christmas Simple","category":"christmas style","image":"/admin/images/cf7_xmas_simple.jpg"},{"title":"Valentine\'s Day Classic","category":"valentine\'s day style","image":"/admin/images/cf7_vday_classic.jpg"},{"title":"Valentine\'s Day Roses","category":"valentine\'s day style","image":"/admin/images/cf7_vday_roses.jpg"},{"title":"Valentine\'s Day Birds","category":"valentine\'s day style","image":"/admin/images/cf7_vday_birds.jpg"},{"title":"Valentine\'s Day Blue Birds","category":"valentine\'s day style","image":"/admin/images/cf7_vday_blue_birds.jpg"}]';
admin/settings_setup.php CHANGED
@@ -1,3 +1,3 @@
1
- <?php
2
-
3
  $setting_str = '{"width":{"name":"Width","slug":"width","type":{"numeric":{"title":"Width","style":"width","property":"0","unit":["px","%","em"]}},"desc":"Change the default width of the current element."},"opacity":{"name":"Opacity","slug":"opacity","type":{"numeric":{"title":"Opacity","style":"opacity","property":"1"}},"desc":"Change the default width of the current element."},"height":{"name":"Height","slug":"height","type":{"numeric":{"title":"Height","style":"height","property":"0","unit":["px","%","em"]}},"desc":"Change the default height of the current element."},"background":{"name":"Background","slug":"background","type":{"color-picker":{"title":"Background Color","style":"background-color","property":"#fff"},"input":{"title":"Background Image","style":"background-image","property":"none"},"select1":{"title":"Background Position","style":"background-position","property":["left top","left center","left bottom","center top","center center","center bottom","right top","right center","right bottom"]},"select2":{"title":"Background Size","style":"background-size","property":["inherit","cover","contain"]},"select3":{"title":"Background Repeat","style":"background-repeat","property":["no-repeat","repeat-x","repeat-y","repeat","space","round"]},"select4":{"title":"Background Attachment","style":"background-attachment","property":["inherit","fixed","scroll","local"]}},"desc":"Change the default background properties of the current element."},"border":{"name":"Border","slug":"border","type":{"numeric1":{"title":"Border Width","style":"border-width","property":"0 0 0 0","unit":["px","%","em"]},"select":{"title":"Border Style","style":"border-style","property":["none","solid","dotted","double","groove","ridge","inset","outset"]},"color-picker":{"title":"Border color","style":"border-color","property":"#fff"},"numeric2":{"title":"Border radius","style":"border-radius","property":"0 0 0 0","unit":["px","%","em"]}},"desc":"Add custom border."},"font":{"name":"Font","slug":"font","type":{"numeric1":{"title":"Font size","style":"font-size","property":"0","unit":["px","%","em"]},"select2":{"title":"Font weight","style":"font-weight","property":["inherit","normal","bold","lighter","bolder","300","400","600","700"]},"select1":{"title":"Font style","style":"font-style","property":["normal","italic","oblique"]},"select4":{"title":"Text Align","style":"text-align","property":["left","right","center","justify","start","end"]},"select3":{"title":"Text transform","style":"text-transform","property":["inherit","capitalize","uppercase","lowercase","none"]},"select5":{"title":"Text decoration","style":"text-decoration","property":["none","underline","inherit","initial","unset"]},"numeric2":{"title":"Line Height","style":"line-height","property":"0","unit":["px","%","em"]},"numeric3":{"title":"Text indent","style":"text-indent","property":"0","unit":["px","%","em"]},"color-picker":{"title":"Color","style":"color","property":"#fff"}},"desc":"Add custom font."},"placefont":{"name":"Font","slug":"font","type":{"numeric1":{"title":"Font size","style":"font-size","property":"0","unit":["px","%","em"]},"select2":{"title":"Font weight","style":"font-weight","property":["inherit","normal","bold","lighter","bolder","300","400","600","700"]},"select1":{"title":"Font style","style":"font-style","property":["normal","italic","oblique"]},"numeric2":{"title":"Line Height","style":"line-height","property":"0","unit":["px","%","em"]},"numeric3":{"title":"Text indent","style":"text-indent","property":"0","unit":["px","%","em"]},"color-picker":{"title":"Color","style":"color","property":"#fff"}},"desc":"Add custom font."},"margin":{"name":"Margin","slug":"margin","type":{"numeric":{"title":"Margin","style":"margin","property":"0 0 0 0","unit":["px","%","em"]}},"desc":"Add custom margin."},"padding":{"name":"Padding","slug":"padding","type":{"numeric":{"title":"Padding","style":"padding","property":"0 0 0 0","unit":["px","%","em"]}},"desc":"Add custom padding."},"float":{"name":"Position","slug":"float","type":{"select":{"title":"Position","style":"float","property":["inherit","none","left","right"]}},"desc":"Add custom float."},"display":{"name":"Display","slug":"display","type":{"select":{"title":"Display","style":"display","property":["inherit","none","inline","inline-block","block"]}},"desc":"Add custom display."},"box-sizing":{"name":"Box sizing","slug":"box-sizing","type":{"select":{"title":"Box sizing","style":"box-sizing","property":["inherit","initial","unset","content-box","border-box"]}},"desc":"Add custom box sizing."},"comming-soon":{"name":"Comming Soon","slug":"box-sizing","type":{"comming-soon":{}}}}';
1
+ <?php
2
+
3
  $setting_str = '{"width":{"name":"Width","slug":"width","type":{"numeric":{"title":"Width","style":"width","property":"0","unit":["px","%","em"]}},"desc":"Change the default width of the current element."},"opacity":{"name":"Opacity","slug":"opacity","type":{"numeric":{"title":"Opacity","style":"opacity","property":"1"}},"desc":"Change the default width of the current element."},"height":{"name":"Height","slug":"height","type":{"numeric":{"title":"Height","style":"height","property":"0","unit":["px","%","em"]}},"desc":"Change the default height of the current element."},"background":{"name":"Background","slug":"background","type":{"color-picker":{"title":"Background Color","style":"background-color","property":"#fff"},"input":{"title":"Background Image","style":"background-image","property":"none"},"select1":{"title":"Background Position","style":"background-position","property":["left top","left center","left bottom","center top","center center","center bottom","right top","right center","right bottom"]},"select2":{"title":"Background Size","style":"background-size","property":["inherit","cover","contain"]},"select3":{"title":"Background Repeat","style":"background-repeat","property":["no-repeat","repeat-x","repeat-y","repeat","space","round"]},"select4":{"title":"Background Attachment","style":"background-attachment","property":["inherit","fixed","scroll","local"]}},"desc":"Change the default background properties of the current element."},"border":{"name":"Border","slug":"border","type":{"numeric1":{"title":"Border Width","style":"border-width","property":"0 0 0 0","unit":["px","%","em"]},"select":{"title":"Border Style","style":"border-style","property":["none","solid","dotted","double","groove","ridge","inset","outset"]},"color-picker":{"title":"Border color","style":"border-color","property":"#fff"},"numeric2":{"title":"Border radius","style":"border-radius","property":"0 0 0 0","unit":["px","%","em"]}},"desc":"Add custom border."},"font":{"name":"Font","slug":"font","type":{"numeric1":{"title":"Font size","style":"font-size","property":"0","unit":["px","%","em"]},"select2":{"title":"Font weight","style":"font-weight","property":["inherit","normal","bold","lighter","bolder","300","400","600","700"]},"select1":{"title":"Font style","style":"font-style","property":["normal","italic","oblique"]},"select4":{"title":"Text Align","style":"text-align","property":["left","right","center","justify","start","end"]},"select3":{"title":"Text transform","style":"text-transform","property":["inherit","capitalize","uppercase","lowercase","none"]},"select5":{"title":"Text decoration","style":"text-decoration","property":["none","underline","inherit","initial","unset"]},"numeric2":{"title":"Line Height","style":"line-height","property":"0","unit":["px","%","em"]},"numeric3":{"title":"Text indent","style":"text-indent","property":"0","unit":["px","%","em"]},"color-picker":{"title":"Color","style":"color","property":"#fff"}},"desc":"Add custom font."},"placefont":{"name":"Font","slug":"font","type":{"numeric1":{"title":"Font size","style":"font-size","property":"0","unit":["px","%","em"]},"select2":{"title":"Font weight","style":"font-weight","property":["inherit","normal","bold","lighter","bolder","300","400","600","700"]},"select1":{"title":"Font style","style":"font-style","property":["normal","italic","oblique"]},"numeric2":{"title":"Line Height","style":"line-height","property":"0","unit":["px","%","em"]},"numeric3":{"title":"Text indent","style":"text-indent","property":"0","unit":["px","%","em"]},"color-picker":{"title":"Color","style":"color","property":"#fff"}},"desc":"Add custom font."},"margin":{"name":"Margin","slug":"margin","type":{"numeric":{"title":"Margin","style":"margin","property":"0 0 0 0","unit":["px","%","em"]}},"desc":"Add custom margin."},"padding":{"name":"Padding","slug":"padding","type":{"numeric":{"title":"Padding","style":"padding","property":"0 0 0 0","unit":["px","%","em"]}},"desc":"Add custom padding."},"float":{"name":"Position","slug":"float","type":{"select":{"title":"Position","style":"float","property":["inherit","none","left","right"]}},"desc":"Add custom float."},"display":{"name":"Display","slug":"display","type":{"select":{"title":"Display","style":"display","property":["inherit","none","inline","inline-block","block"]}},"desc":"Add custom display."},"box-sizing":{"name":"Box sizing","slug":"box-sizing","type":{"select":{"title":"Box sizing","style":"box-sizing","property":["inherit","initial","unset","content-box","border-box"]}},"desc":"Add custom box sizing."},"comming-soon":{"name":"Comming Soon","slug":"box-sizing","type":{"comming-soon":{}}}}';
cf7-style-match-old.php CHANGED
@@ -1,297 +1,297 @@
1
- <?php
2
-
3
- if ( !defined( 'ABSPATH' ) ) {
4
- exit;
5
- }
6
-
7
- function get_new_styler_data($a){
8
- $t = array();
9
- $u = "px";
10
- foreach ( $a as $k => $d ) {
11
- if( $d != 'Default' && $d != ''){
12
- if($k=="form-padding" || $k=="form-margin" ||$k=="input-margin" ||$k=="input-padding" ){
13
- $d = str_replace("px", "", $d);
14
- $da = explode(" ", $d);
15
- $nr = count($da);
16
- $tfn = "";
17
- }
18
- switch($k){
19
- case 'form-background' :
20
- $t['form_background-color'] = $d;
21
- break;
22
- case 'form-width' : $t['form_width'] = $d;
23
- $t['form_width_unit'] = $u;
24
- break;
25
- case 'form-border-width' :
26
- $t['form_border-top-width'] = $d;
27
- $t['form_border-top-width_unit'] = $u;
28
- $t['form_border-right-width'] = $d;
29
- $t['form_border-right-width_unit'] = $u;
30
- $t['form_border-bottom-width'] = $d;
31
- $t['form_border-bottom-width_unit'] = $u;
32
- $t['form_border-left-width'] = $d;
33
- $t['form_border-left-width_unit'] = $u;
34
- break;
35
- case 'form-border-style' :
36
- $t['form_border-style'] = $d;
37
- break;
38
- case 'form-padding' :
39
- $tfn = "form_padding";
40
- break;
41
- case 'form-margin' :
42
- $tfn = "form_margin";
43
- break;
44
- case 'form-border-color' :
45
- $t['form_border-color'] = $d;
46
- break;
47
- case 'form-border-radius' :
48
- $t['form_border-top-left-radius'] = $d;
49
- $t['form_border-top-left-radius_unit'] = $u;
50
- $t['form_border-top-right-radius'] = $d;
51
- $t['form_border-top-right-radius_unit'] = $u;
52
- $t['form_border-bottom-left-radius'] = $d;
53
- $t['form_border-bottom-left-radius_unit'] = $u;
54
- $t['form_border-bottom-right-radius'] = $d;
55
- $t['form_border-bottom-right-radius_unit'] = $u;
56
- break;
57
- case 'form-line-height' :
58
- $t['form_line-height']= $d;
59
- $t['form_line-height_unit']= $u;
60
- break;
61
- case 'input-background' :
62
- $t['input_background-color'] = $d;
63
- break;
64
- case 'input-color' :
65
- $t['input_color'] = $d;
66
- break;
67
- case 'input-border-color' :
68
- $t['input_border-color'] = $d;
69
- break;
70
- case 'input-font-size' :
71
- $t['input_font-size'] = $d;
72
- $t['input_font-size_unit'] = $u;
73
- break;
74
- case 'input-line-height' :
75
- $t['input_line-height'] = $d;
76
- $t['input_line-height_unit'] = $u;
77
- break;
78
- case 'input-border-width' :
79
- $t['input_border-top-width'] = $d;
80
- $t['input_border-top-width_unit'] = $u;
81
- $t['input_border-right-width'] = $d;
82
- $t['input_border-right-width_unit'] = $u;
83
- $t['input_border-bottom-width'] = $d;
84
- $t['input_border-bottom-width_unit'] = $u;
85
- $t['input_border-left-width'] = $d;
86
- $t['input_border-left-width_unit'] = $u;
87
- break;
88
- case 'input-border-style' :
89
- $t['input_border-style'] = $d;
90
- break;
91
- case 'input-border-radius' :
92
- $t['input_border-top-left-radius'] = $d;
93
- $t['input_border-top-left-radius_unit'] = $u;
94
- $t['input_border-top-right-radius'] = $d;
95
- $t['input_border-top-right-radius_unit'] = $u;
96
- $t['input_border-bottom-left-radius'] = $d;
97
- $t['input_border-bottom-left-radius_unit'] = $u;
98
- $t['input_border-bottom-right-radius'] = $d;
99
- $t['input_border-bottom-right-radius_unit'] = $u;
100
- break;
101
- case 'input-font-style' :
102
- $t['input_font-style'] = $d;
103
- break;
104
- case 'input-font-weight' :
105
- $t['input_font-weight'] = $d;
106
- break;
107
- case 'input-width' : $t['input_width'] = $d;
108
- $t['input_width_unit'] = $u;
109
- break;
110
- case 'input-box-sizing' :
111
- $t['input_box-sizing']= $d;
112
- break;
113
- case 'input-height' :
114
- $t['input_height'] = $d;
115
- $t['input_height_unit'] = $u;
116
- break;
117
- case 'input-padding' :
118
- $tfn = "input_padding";
119
- break;
120
- case 'input-margin' :
121
- $tfn = "input_margin";
122
- break;
123
- case 'textarea-background-color' :
124
- $t['textarea_background-color'] = $d;
125
- break;
126
- case 'textarea-height' :
127
- $t['textarea_height'] = $d;
128
- $t['textarea_height_unit'] = $u;
129
- break;
130
- case 'textarea-width' :
131
- $t['textarea_width'] = $d;
132
- $t['textarea_width_unit'] = $u;
133
- break;
134
- case 'textarea-box-sizing' :
135
- $t['textarea_box-sizing'] = $d;
136
- break;
137
- case 'textarea-border-size' :
138
- $t['textarea_border-top-width'] = $d;
139
- $t['textarea_border-top-width_unit'] = $u;
140
- $t['textarea_border-right-width'] = $d;
141
- $t['textarea_border-right-width_unit'] = $u;
142
- $t['textarea_border-bottom-width'] = $d;
143
- $t['textarea_border-bottom-width_unit'] = $u;
144
- $t['textarea_border-left-width'] = $d;
145
- $t['textarea_border-left-width_unit'] = $u;
146
- break;
147
- case 'textarea-border-color' :
148
- $t['textarea_border-color']= $d;
149
- break;
150
- case 'textarea-border-style' :
151
- $t['textarea_border-style'] = $d;
152
- break;
153
- case 'textarea-border-radius' :
154
- $t['textarea_border-top-left-radius'] = $d;
155
- $t['textarea_border-top-left-radius_unit'] = $u;
156
- $t['textarea_border-top-right-radius'] = $d;
157
- $t['textarea_border-top-right-radius_unit'] = $u;
158
- $t['textarea_border-bottom-left-radius'] = $d;
159
- $t['textarea_border-bottom-left-radius_unit'] = $u;
160
- $t['textarea_border-bottom-right-radius'] = $d;
161
- $t['textarea_border-bottom-right-radius_unit'] = $u;
162
- break;
163
- case 'textarea-font-size' :
164
- $t['textarea_font-size'] = $d;
165
- $t['textarea_font-size_unit'] = $u;
166
- break;
167
- case 'textarea-line-height' :
168
- $t['textarea_line-height'] = $d;
169
- $t['textarea_line-height_unit'] = $u;
170
- break;
171
- case 'textarea-font-style' :
172
- $t['textarea_font-style'] = $d;
173
- break;
174
- case 'label-font-style' :
175
- $t['label_font-style']= $d;
176
- $t['p_font-style']= $d;
177
- break;
178
- case 'label-font-weight' :
179
- $t['label_font-weight'] = $d;
180
- $t['p_font-weight'] = $d;
181
- break;
182
- case 'label-font-size' :
183
- $t['label_font-size'] = $d;
184
- $t['label_font-size_unit'] = $u;
185
- $t['p_font-size'] = $d;
186
- $t['p_font-size_unit'] = $u;
187
- break;
188
- case 'label-line-height' :
189
- $t['label_line-height']= $d;
190
- $t['label_line-height_unit']= $u;
191
- $t['p_line-height']= $d;
192
- $t['p_line-height_unit']= $u;
193
- break;
194
- case 'label-color' :
195
- $t['label_color'] = $d;
196
- $t['p_color'] = $d;
197
- break;
198
- case 'submit-button-width' :
199
- $t['submit_width'] = $d;
200
- $t['submit_width_unit'] = $u;
201
- break;
202
- case 'submit-button-box-sizing' :
203
- $t['submit_box-sizing'] = $d;
204
- break;
205
- case 'submit-button-height' :
206
- $t['submit_height'] = $d;
207
- $t['submit_height_unit'] = $u;
208
- break;
209
- case 'submit-button-border-radius' :
210
- $t['submit_border-top-left-radius'] = $d;
211
- $t['submit_border-top-left-radius_unit'] = $u;
212
- $t['submit_border-top-right-radius'] = $d;
213
- $t['submit_border-top-right-radius_unit'] = $u;
214
- $t['submit_border-bottom-left-radius'] = $d;
215
- $t['submit_border-bottom-left-radius_unit'] = $u;
216
- $t['submit_border-bottom-right-radius'] = $d;
217
- $t['submit_border-bottom-right-radius_unit'] = $u;
218
- break;
219
- case 'submit-button-font-size' :
220
- $t['submit_font-size'] = $d;
221
- $t['submit_font-size_unit'] = $u;
222
- break;
223
- case 'submit-button-line-height' :
224
- $t['submit_line-height'] = $d;
225
- $t['submit_line-height_unit'] = $u;
226
- break;
227
- case 'submit-button-border-width' :
228
- $t['submit_border-top-width'] = $d;
229
- $t['submit_border-top-width_unit'] = $u;
230
- $t['submit_border-right-width'] = $d;
231
- $t['submit_border-right-width_unit'] = $u;
232
- $t['submit_border-bottom-width'] = $d;
233
- $t['submit_border-bottom-width_unit']= $u;
234
- $t['submit_border-left-width']= $d;
235
- $t['submit_border-left-width_unit']= $u;
236
- break;
237
- case 'submit-button-border-style':
238
- $t['submit_border-style'] = $d;
239
- break;
240
- case 'submit-button-border-color' :
241
- $t['submit_border-color'] = $d;
242
- break;
243
- case 'submit-button-color' :
244
- $t['submit_color'] = $d;
245
- break;
246
- case 'submit-button-background' :
247
- $t['submit_background-color'] = $d;
248
- break;
249
- }
250
- if($k=="form-padding" || $k=="form-margin" ||$k=="input-margin" ||$k=="input-padding" ){
251
- switch($nr){
252
- case 1:
253
- $t[$tfn.'-top'] = $d;
254
- $t[$tfn.'-top_unit'] = $u;
255
- $t[$tfn.'-right'] = $d;
256
- $t[$tfn.'-right_unit'] = $u;
257
- $t[$tfn.'-bottom'] = $d;
258
- $t[$tfn.'-bottom_unit'] = $u;
259
- $t[$tfn.'-left'] = $d;
260
- $t[$tfn.'-left_unit'] = $u;
261
- break;
262
- case 2:
263
- $t[$tfn.'-top'] = $da[0];
264
- $t[$tfn.'-top_unit'] = $u;
265
- $t[$tfn.'-right'] = $da[1];
266
- $t[$tfn.'-right_unit'] = $u;
267
- $t[$tfn.'-bottom'] = $da[0];
268
- $t[$tfn.'-bottom_unit'] = $u;
269
- $t[$tfn.'-left'] = $da[1];
270
- $t[$tfn.'-left_unit'] = $u;
271
- break;
272
- case 3:
273
- $t[$tfn.'-top'] = $da[0];
274
- $t[$tfn.'-top_unit'] = $u;
275
- $t[$tfn.'-right'] = $da[1];
276
- $t[$tfn.'-right_unit'] = $u;
277
- $t[$tfn.'-bottom'] = $da[2];
278
- $t[$tfn.'-bottom_unit'] = $u;
279
- $t[$tfn.'-left'] = $da[1];
280
- $t[$tfn.'-left_unit'] = $u;
281
- break;
282
- case 4:
283
- $t[$tfn.'-top'] = $da[0];
284
- $t[$tfn.'-top_unit'] = $u;
285
- $t[$tfn.'-right'] = $da[1];
286
- $t[$tfn.'-right_unit'] = $u;
287
- $t[$tfn.'-bottom'] = $da[2];
288
- $t[$tfn.'-bottom_unit'] = $u;
289
- $t[$tfn.'-left'] = $da[3];
290
- $t[$tfn.'-left_unit'] = $u;
291
- break;
292
- }
293
- }
294
- }
295
- }
296
- return $t;
297
  }
1
+ <?php
2
+
3
+ if ( !defined( 'ABSPATH' ) ) {
4
+ exit;
5
+ }
6
+
7
+ function get_new_styler_data($a){
8
+ $t = array();
9
+ $u = "px";
10
+ foreach ( $a as $k => $d ) {
11
+ if( $d != 'Default' && $d != ''){
12
+ if($k=="form-padding" || $k=="form-margin" ||$k=="input-margin" ||$k=="input-padding" ){
13
+ $d = str_replace("px", "", $d);
14
+ $da = explode(" ", $d);
15
+ $nr = count($da);
16
+ $tfn = "";
17
+ }
18
+ switch($k){
19
+ case 'form-background' :
20
+ $t['form_background-color'] = $d;
21
+ break;
22
+ case 'form-width' : $t['form_width'] = $d;
23
+ $t['form_width_unit'] = $u;
24
+ break;
25
+ case 'form-border-width' :
26
+ $t['form_border-top-width'] = $d;
27
+ $t['form_border-top-width_unit'] = $u;
28
+ $t['form_border-right-width'] = $d;
29
+ $t['form_border-right-width_unit'] = $u;
30
+ $t['form_border-bottom-width'] = $d;
31
+ $t['form_border-bottom-width_unit'] = $u;
32
+ $t['form_border-left-width'] = $d;
33
+ $t['form_border-left-width_unit'] = $u;
34
+ break;
35
+ case 'form-border-style' :
36
+ $t['form_border-style'] = $d;
37
+ break;
38
+ case 'form-padding' :
39
+ $tfn = "form_padding";
40
+ break;
41
+ case 'form-margin' :
42
+ $tfn = "form_margin";
43
+ break;
44
+ case 'form-border-color' :
45
+ $t['form_border-color'] = $d;
46
+ break;
47
+ case 'form-border-radius' :
48
+ $t['form_border-top-left-radius'] = $d;
49
+ $t['form_border-top-left-radius_unit'] = $u;
50
+ $t['form_border-top-right-radius'] = $d;
51
+ $t['form_border-top-right-radius_unit'] = $u;
52
+ $t['form_border-bottom-left-radius'] = $d;
53
+ $t['form_border-bottom-left-radius_unit'] = $u;
54
+ $t['form_border-bottom-right-radius'] = $d;
55
+ $t['form_border-bottom-right-radius_unit'] = $u;
56
+ break;
57
+ case 'form-line-height' :
58
+ $t['form_line-height']= $d;
59
+ $t['form_line-height_unit']= $u;
60
+ break;
61
+ case 'input-background' :
62
+ $t['input_background-color'] = $d;
63
+ break;
64
+ case 'input-color' :
65
+ $t['input_color'] = $d;
66
+ break;
67
+ case 'input-border-color' :
68
+ $t['input_border-color'] = $d;
69
+ break;
70
+ case 'input-font-size' :
71
+ $t['input_font-size'] = $d;
72
+ $t['input_font-size_unit'] = $u;
73
+ break;
74
+ case 'input-line-height' :
75
+ $t['input_line-height'] = $d;
76
+ $t['input_line-height_unit'] = $u;
77
+ break;
78
+ case 'input-border-width' :
79
+ $t['input_border-top-width'] = $d;
80
+ $t['input_border-top-width_unit'] = $u;
81
+ $t['input_border-right-width'] = $d;
82
+ $t['input_border-right-width_unit'] = $u;
83
+ $t['input_border-bottom-width'] = $d;
84
+ $t['input_border-bottom-width_unit'] = $u;
85
+ $t['input_border-left-width'] = $d;
86
+ $t['input_border-left-width_unit'] = $u;
87
+ break;
88
+ case 'input-border-style' :
89
+ $t['input_border-style'] = $d;
90
+ break;
91
+ case 'input-border-radius' :
92
+ $t['input_border-top-left-radius'] = $d;
93
+ $t['input_border-top-left-radius_unit'] = $u;
94
+ $t['input_border-top-right-radius'] = $d;
95
+ $t['input_border-top-right-radius_unit'] = $u;
96
+ $t['input_border-bottom-left-radius'] = $d;
97
+ $t['input_border-bottom-left-radius_unit'] = $u;
98
+ $t['input_border-bottom-right-radius'] = $d;
99
+ $t['input_border-bottom-right-radius_unit'] = $u;
100
+ break;
101
+ case 'input-font-style' :
102
+ $t['input_font-style'] = $d;
103
+ break;
104
+ case 'input-font-weight' :
105
+ $t['input_font-weight'] = $d;
106
+ break;
107
+ case 'input-width' : $t['input_width'] = $d;
108
+ $t['input_width_unit'] = $u;
109
+ break;
110
+ case 'input-box-sizing' :
111
+ $t['input_box-sizing']= $d;
112
+ break;
113
+ case 'input-height' :
114
+ $t['input_height'] = $d;
115
+ $t['input_height_unit'] = $u;
116
+ break;
117
+ case 'input-padding' :
118
+ $tfn = "input_padding";
119
+ break;
120
+ case 'input-margin' :
121
+ $tfn = "input_margin";
122
+ break;
123
+ case 'textarea-background-color' :
124
+ $t['textarea_background-color'] = $d;
125
+ break;
126
+ case 'textarea-height' :
127
+ $t['textarea_height'] = $d;
128
+ $t['textarea_height_unit'] = $u;
129
+ break;
130
+ case 'textarea-width' :
131
+ $t['textarea_width'] = $d;
132
+ $t['textarea_width_unit'] = $u;
133
+ break;
134
+ case 'textarea-box-sizing' :
135
+ $t['textarea_box-sizing'] = $d;
136
+ break;
137
+ case 'textarea-border-size' :
138
+ $t['textarea_border-top-width'] = $d;
139
+ $t['textarea_border-top-width_unit'] = $u;
140
+ $t['textarea_border-right-width'] = $d;
141
+ $t['textarea_border-right-width_unit'] = $u;
142
+ $t['textarea_border-bottom-width'] = $d;
143
+ $t['textarea_border-bottom-width_unit'] = $u;
144
+ $t['textarea_border-left-width'] = $d;
145
+ $t['textarea_border-left-width_unit'] = $u;
146
+ break;
147
+ case 'textarea-border-color' :
148
+ $t['textarea_border-color']= $d;
149
+ break;
150
+ case 'textarea-border-style' :
151
+ $t['textarea_border-style'] = $d;
152
+ break;
153
+ case 'textarea-border-radius' :
154
+ $t['textarea_border-top-left-radius'] = $d;
155
+ $t['textarea_border-top-left-radius_unit'] = $u;
156
+ $t['textarea_border-top-right-radius'] = $d;
157
+ $t['textarea_border-top-right-radius_unit'] = $u;
158
+ $t['textarea_border-bottom-left-radius'] = $d;
159
+ $t['textarea_border-bottom-left-radius_unit'] = $u;
160
+ $t['textarea_border-bottom-right-radius'] = $d;
161
+ $t['textarea_border-bottom-right-radius_unit'] = $u;
162
+ break;
163
+ case 'textarea-font-size' :
164
+ $t['textarea_font-size'] = $d;
165
+ $t['textarea_font-size_unit'] = $u;
166
+ break;
167
+ case 'textarea-line-height' :
168
+ $t['textarea_line-height'] = $d;
169
+ $t['textarea_line-height_unit'] = $u;
170
+ break;
171
+ case 'textarea-font-style' :
172
+ $t['textarea_font-style'] = $d;
173
+ break;
174
+ case 'label-font-style' :
175
+ $t['label_font-style']= $d;
176
+ $t['p_font-style']= $d;
177
+ break;
178
+ case 'label-font-weight' :
179
+ $t['label_font-weight'] = $d;
180
+ $t['p_font-weight'] = $d;
181
+ break;
182
+ case 'label-font-size' :
183
+ $t['label_font-size'] = $d;
184
+ $t['label_font-size_unit'] = $u;
185
+ $t['p_font-size'] = $d;
186
+ $t['p_font-size_unit'] = $u;
187
+ break;
188
+ case 'label-line-height' :
189
+ $t['label_line-height']= $d;
190
+ $t['label_line-height_unit']= $u;
191
+ $t['p_line-height']= $d;
192
+ $t['p_line-height_unit']= $u;
193
+ break;
194
+ case 'label-color' :
195
+ $t['label_color'] = $d;
196
+ $t['p_color'] = $d;
197
+ break;
198
+ case 'submit-button-width' :
199
+ $t['submit_width'] = $d;
200
+ $t['submit_width_unit'] = $u;
201
+ break;
202
+ case 'submit-button-box-sizing' :
203
+ $t['submit_box-sizing'] = $d;
204
+ break;
205
+ case 'submit-button-height' :
206
+ $t['submit_height'] = $d;
207
+ $t['submit_height_unit'] = $u;
208
+ break;
209
+ case 'submit-button-border-radius' :
210
+ $t['submit_border-top-left-radius'] = $d;
211
+ $t['submit_border-top-left-radius_unit'] = $u;
212
+ $t['submit_border-top-right-radius'] = $d;
213
+ $t['submit_border-top-right-radius_unit'] = $u;
214
+ $t['submit_border-bottom-left-radius'] = $d;
215
+ $t['submit_border-bottom-left-radius_unit'] = $u;
216
+ $t['submit_border-bottom-right-radius'] = $d;
217
+ $t['submit_border-bottom-right-radius_unit'] = $u;
218
+ break;
219
+ case 'submit-button-font-size' :
220
+ $t['submit_font-size'] = $d;
221
+ $t['submit_font-size_unit'] = $u;
222
+ break;
223
+ case 'submit-button-line-height' :
224
+ $t['submit_line-height'] = $d;
225
+ $t['submit_line-height_unit'] = $u;
226
+ break;
227
+ case 'submit-button-border-width' :
228
+ $t['submit_border-top-width'] = $d;
229
+ $t['submit_border-top-width_unit'] = $u;
230
+ $t['submit_border-right-width'] = $d;
231
+ $t['submit_border-right-width_unit'] = $u;
232
+ $t['submit_border-bottom-width'] = $d;
233
+ $t['submit_border-bottom-width_unit']= $u;
234
+ $t['submit_border-left-width']= $d;
235
+ $t['submit_border-left-width_unit']= $u;
236
+ break;
237
+ case 'submit-button-border-style':
238
+ $t['submit_border-style'] = $d;
239
+ break;
240
+ case 'submit-button-border-color' :
241
+ $t['submit_border-color'] = $d;
242
+ break;
243
+ case 'submit-button-color' :
244
+ $t['submit_color'] = $d;
245
+ break;
246
+ case 'submit-button-background' :
247
+ $t['submit_background-color'] = $d;
248
+ break;
249
+ }
250
+ if($k=="form-padding" || $k=="form-margin" ||$k=="input-margin" ||$k=="input-padding" ){
251
+ switch($nr){
252
+ case 1:
253
+ $t[$tfn.'-top'] = $d;
254
+ $t[$tfn.'-top_unit'] = $u;
255
+ $t[$tfn.'-right'] = $d;
256
+ $t[$tfn.'-right_unit'] = $u;
257
+ $t[$tfn.'-bottom'] = $d;
258
+ $t[$tfn.'-bottom_unit'] = $u;
259
+ $t[$tfn.'-left'] = $d;
260
+ $t[$tfn.'-left_unit'] = $u;
261
+ break;
262
+ case 2:
263
+ $t[$tfn.'-top'] = $da[0];
264
+ $t[$tfn.'-top_unit'] = $u;
265
+ $t[$tfn.'-right'] = $da[1];
266
+ $t[$tfn.'-right_unit'] = $u;
267
+ $t[$tfn.'-bottom'] = $da[0];
268
+ $t[$tfn.'-bottom_unit'] = $u;
269
+ $t[$tfn.'-left'] = $da[1];
270
+ $t[$tfn.'-left_unit'] = $u;
271
+ break;
272
+ case 3:
273
+ $t[$tfn.'-top'] = $da[0];
274
+ $t[$tfn.'-top_unit'] = $u;
275
+ $t[$tfn.'-right'] = $da[1];
276
+ $t[$tfn.'-right_unit'] = $u;
277
+ $t[$tfn.'-bottom'] = $da[2];
278
+ $t[$tfn.'-bottom_unit'] = $u;
279
+ $t[$tfn.'-left'] = $da[1];
280
+ $t[$tfn.'-left_unit'] = $u;
281
+ break;
282
+ case 4:
283
+ $t[$tfn.'-top'] = $da[0];
284
+ $t[$tfn.'-top_unit'] = $u;
285
+ $t[$tfn.'-right'] = $da[1];
286
+ $t[$tfn.'-right_unit'] = $u;
287
+ $t[$tfn.'-bottom'] = $da[2];
288
+ $t[$tfn.'-bottom_unit'] = $u;
289
+ $t[$tfn.'-left'] = $da[3];
290
+ $t[$tfn.'-left_unit'] = $u;
291
+ break;
292
+ }
293
+ }
294
+ }
295
+ }
296
+ return $t;
297
  }
cf7-style-meta-box.php CHANGED
@@ -1,576 +1,583 @@
1
- <?php
2
-
3
- if ( !defined( 'ABSPATH' ) ) {
4
- exit;
5
- }
6
-
7
- function active_styles() {
8
-
9
- $args = array(
10
- 'post_type'=>'wpcf7_contact_form',
11
- 'post_status'=>'publish',
12
- 'posts_per_page'=> -1
13
- );
14
- $active_styles = array();
15
- $forms = new WP_Query( $args );
16
-
17
- if( $forms->have_posts() ) :
18
- while( $forms->have_posts() ) : $forms->the_post();
19
- $form_title = get_the_title();
20
- $id = get_the_ID();
21
- $style_id = get_post_meta( $id, 'cf7_style_id', true );
22
- if ( ! empty( $style_id ) || $style_id != 0 ) {
23
- $active_styles[] = $style_id;
24
- }
25
- endwhile;
26
- wp_reset_postdata();
27
- endif;
28
- return $active_styles;
29
- }
30
-
31
-
32
- /**
33
- * Calls the class the meta box. Used for selecting forms for each style.
34
- */
35
- function cf7_style_meta_form_init() {
36
- new cf7_style_meta_boxes();
37
- }
38
-
39
- if ( is_admin() ) {
40
- add_action( 'load-post.php', 'cf7_style_meta_form_init' );
41
- add_action( 'load-post-new.php', 'cf7_style_meta_form_init' );
42
- }
43
-
44
- function filter_w_zeros($var){
45
- return ($var !== NULL && $var !== FALSE && $var !== '');
46
- }
47
-
48
- /**
49
- * The Class for creating all of the meta boxes
50
- */
51
- class cf7_style_meta_boxes {
52
-
53
- /**
54
- * Hook into the appropriate actions when the class is constructed.
55
- */
56
- public function __construct() {
57
- //selector init
58
- add_action( 'add_meta_boxes', array( $this, 'add_meta_box_style_selector' ) );
59
- add_action( 'save_post', array( $this, 'save_style_selector' ) );
60
- //fonts
61
- add_action( 'add_meta_boxes', array( $this, 'add_meta_box_font_selector' ) );
62
- add_action( 'save_post', array( $this, 'save_font_id' ) );
63
- //image meta box init
64
- add_action( 'add_meta_boxes', array( $this, 'add_meta_box_style_image' ) );
65
- //add paypal button
66
- add_action( 'add_meta_boxes', array( $this, 'add_meta_box_style_paypal' ) );
67
- //custom style meta box1
68
- add_action( 'add_meta_boxes', array( $this, 'add_meta_box_style_customizer' ), 10, 2 );
69
- add_action( 'save_post', array( $this, 'save_style_customizer' ) );
70
- }
71
-
72
- /**************************************************
73
- * Adds the meta box container for style selector.
74
- * STYLE SELECTOR STARTS HERE
75
- */
76
- public function add_meta_box_style_selector( $post_type ) {
77
- $post_types = array('cf7_style'); //limit meta box to certain post types
78
- if ( in_array( $post_type, $post_types )) {
79
- add_meta_box(
80
- 'cf7_style_meta_box_form_selector'
81
- ,__( 'Select forms for current style', 'contact-form-7-style' )
82
- ,array( $this, 'render_meta_box_selector' )
83
- ,$post_type
84
- ,'advanced'
85
- ,'high'
86
- );
87
- }
88
- }
89
- public function add_meta_box_style_customizer( $post_type, $post ) {
90
-
91
- $post_types = array('cf7_style'); //limit meta box to certain post types
92
- $custom_cat = get_the_terms( $post->ID, "style_category" );
93
- $custom_name = ( empty( $custom_cat ) ) ? "custom style" : $custom_cat[0]->name;
94
- if ( in_array( $post_type, $post_types ) && ( $custom_name == "custom style" ) ) {
95
- add_meta_box(
96
- 'cf7_style_meta_box_style_customizer'
97
- ,__( 'Custom style settings', 'contact-form-7-style' )
98
- ,array( $this, 'render_meta_box_style_customizer' )
99
- ,$post_type
100
- ,'advanced'
101
- ,'high'
102
- );
103
- }
104
- }
105
-
106
- public function render_meta_box_style_customizer( $post ) {
107
- require_once WPCF7S_PLUGIN_DIR . '/options.php';
108
- }
109
-
110
- public function save_style_customizer( $post_id ) {
111
-
112
- if ( ! isset( $_POST['cf_7_style_customizer_custom_box_nonce'] ) )
113
- return $post_id;
114
-
115
- $nonce = sanitize_text_field($_POST['cf_7_style_customizer_custom_box_nonce']);
116
-
117
-
118
- // Verify that the nonce is valid.
119
- if ( ! wp_verify_nonce( $nonce, 'cf_7_style_style_customizer_inner_custom_box' ) ) {
120
- return $post_id;
121
- }
122
-
123
- if ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) {
124
- return $post_id;
125
- }
126
-
127
- if ( 'page' == $_POST['post_type'] ) {
128
- if ( ! current_user_can( 'edit_page', $post_id ) ) {
129
- return $post_id;
130
- }
131
- } else {
132
- if ( ! current_user_can( 'edit_post', $post_id ) ) {
133
- return $post_id;
134
- }
135
-
136
- }
137
-
138
- $posted_data = $_POST['cf7styleallvalues'];
139
- $posted_data = str_replace("\'", '"', $posted_data);
140
- $posted_data = json_decode($posted_data, true);
141
-
142
- foreach ( $posted_data as $p_key => $p_value) {
143
- if( strpos($p_key, '_unit' ) !== false){
144
- $no_unit = str_replace("_unit","", $p_key );
145
- if( !array_key_exists($no_unit, $posted_data) || empty( $posted_data[$no_unit]) ){
146
- unset($posted_data[$p_key]);
147
- }
148
- }
149
- }
150
-
151
- ksort($posted_data);
152
-
153
- $active_pane = sanitize_text_field($_POST['cf7styleactivepane']);
154
- if( isset( $active_pane )){
155
- update_post_meta( $post_id, 'cf7_style_active_panel', $active_pane, "");
156
- }
157
- if ( is_array( $posted_data ) && isset( $posted_data ) ) {
158
- update_post_meta( $post_id, 'cf7_style_custom_styler', array_filter($posted_data,'filter_w_zeros') , "");
159
- }
160
-
161
- }
162
-
163
- /**
164
- * Save the style selector when the post is saved.
165
- */
166
- public function save_style_selector( $post_id ) {
167
- if ( ! isset( $_POST['cf_7_style_selector_custom_box_nonce'] ) )
168
- return $post_id;
169
-
170
- $nonce = $_POST['cf_7_style_selector_custom_box_nonce'];
171
-
172
- // Verify that the nonce is valid.
173
- if ( ! wp_verify_nonce( $nonce, 'cf_7_style_selector_inner_custom_box' ) ) {
174
- return $post_id;
175
- }
176
-
177
- if ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) {
178
- return $post_id;
179
- }
180
-
181
- if ( 'page' == $_POST['post_type'] ) {
182
- if ( ! current_user_can( 'edit_page', $post_id ) ) {
183
- return $post_id;
184
- }
185
- } else {
186
- if ( ! current_user_can( 'edit_post', $post_id ) ) {
187
- return $post_id;
188
- }
189
-
190
- }
191
-
192
- //getting all the cf7 forms
193
- $cf7formsargs = array(
194
- 'post_type' => 'wpcf7_contact_form',
195
- 'posts_per_page' => -1
196
- );
197
- $cf7forms = get_posts( $cf7formsargs );
198
-
199
- //for each checked form, saving the style id
200
- foreach ( $cf7forms as $cf7form ) {
201
- if ( isset( $_POST[$cf7form->post_name] ) ) {
202
- //if ( !empty( $_POST[$cf7form->post_name] ) ) {
203
- update_post_meta( $cf7form->ID, 'cf7_style_id', $post_id);
204
- //}
205
- } else {
206
- $getthisstyle = get_post_meta( $cf7form->ID, 'cf7_style_id', $post_id );
207
-
208
- if ( !empty( $getthisstyle ) && $post_id == $getthisstyle ) {
209
- update_post_meta( $cf7form->ID, 'cf7_style_id', '' );
210
- }
211
-
212
- if ( !empty( $getthisstyle ) ) {
213
- //update_post_meta( $cf7form->ID, 'cf7_style_id', $getthisstyle );
214
- }
215
- }
216
- }
217
- }
218
-
219
- /**
220
- * Render Meta Box content.
221
- */
222
- public function render_meta_box_selector( $post ) {
223
- wp_nonce_field( 'cf_7_style_selector_inner_custom_box', 'cf_7_style_selector_custom_box_nonce' );
224
-
225
- // Display the form, using the current value.
226
- $args = array(
227
- 'post_type' => 'wpcf7_contact_form',
228
- 'posts_per_page' => -1
229
- );
230
- $currentpostid = get_the_ID();
231
-
232
- $query = new WP_Query( $args );
233
- echo '<table class="wp-list-table fixed pages widefat">';
234
- echo '<thead>';
235
- echo '<tr>';
236
- echo '<th class="manage-column">' . __('Contact form 7 forms', 'contact-form-7-style' ) . '</th>';
237
- echo '<th class="manage-column different-style"><input type="checkbox" id="select_all"/><label for="select_all">' . __('Select all','contact-form-7-style' ) . '</label></th>';
238
- echo '<th class="generate-preview-option">' . __( "Generate preview", 'contact-form-7-style' ) . '</th>';
239
- echo '<th class="gotoform-option">' . __( "Navigate to CF7 form", 'contact-form-7-style' ) . '</th>';
240
- echo '</tr>';
241
- echo '</thead>';
242
- echo '<tbody class="cf7style_body_select_all">';
243
- if ( $query->have_posts() ) {
244
- while ( $query->have_posts() ) : $query->the_post();
245
- $cf7ID = get_the_ID();
246
- $cf7stylehas = get_post_meta( $cf7ID, 'cf7_style_id', true );
247
- ?>
248
- <tr>
249
- <td>
250
- <label for="<?php echo cf7_style_the_slug(); ?>"><?php the_title(); ?></label>
251
- </td>
252
- <td>
253
- <input type="checkbox" id="<?php echo cf7_style_the_slug(); ?>" name="<?php echo cf7_style_the_slug(); ?>" value="<?php echo get_the_ID(); ?>" <?php if ( $currentpostid == $cf7stylehas ) { echo 'checked'; } ?> />
254
- </td>
255
- <td class="generate-preview-option">
256
- <button class="button-primary generate-preview-button" data-attr-title="<?php the_title(); ?>" data-attr-id="<?php the_ID(); ?>"><?php _e( "Generate preview", 'contact-form-7-style' ); ?></button>
257
- </td>
258
- <td class="gotoform-option">
259
- <a class="button-primary" href="<?php echo esc_url(admin_url('?page=wpcf7&post='.$cf7ID.'&action=edit' )) ?>" target="_blank" title="<?php the_title(); ?>"><?php _e( "Go To CF7", 'contact-form-7-style' ); ?></a>
260
- </td>
261
- </tr>
262
- <tr>
263
- <td colspan="2">
264
- <?php if ( $currentpostid != $cf7stylehas && !empty( $cf7stylehas ) ) {
265
- echo '<p class="description">' . __('Notice: This form allready has a selected style. Checking this one will overwrite the ', 'contact-form-7-style' ) . '<a href="' . get_admin_url() . 'post.php?post_type=cf7_style&post=' . $cf7stylehas . '&action=edit">' . __('other one.', 'contact-form-7-style' ) . '</a></p>';
266
- } ?>
267
- </td>
268
- <td class="generate-preview-option">&nbsp;</td>
269
- </tr>
270
- <?php endwhile; wp_reset_postdata();
271
- echo '</tbody>';
272
- echo '</table>';
273
- } else {
274
- echo '<tr><td><p class="description">' . __( 'Please create a form. You can do it by clicking', 'contact-form-7-style' ) . '<a href="' . admin_url() . 'admin.php?page=wpcf7-new" target="_blank">' . __(' here', 'contact-form-7-style' ) . '</a></p></td></tr></table>';
275
- }
276
- }
277
- /**
278
- *STYLE SELECTOR ENDS HERE
279
- *****************************
280
- */
281
-
282
- /*************************************************
283
- * Adds the meta box container for IMAGE PREVIEW
284
- * IMAGE META BOX STARTS HERE
285
- */
286
- public function add_meta_box_style_image( $post_type ) {
287
- $post_types = array('cf7_style'); //limit meta box to certain post types
288
- if ( in_array( $post_type, $post_types )) {
289
- add_meta_box(
290
- 'cf7_style_meta_box_image'
291
- ,__( 'Preview', 'contact-form-7-style' )
292
- ,array( $this, 'render_meta_box_image' )
293
- ,$post_type
294
- ,'side'
295
- ,'high'
296
- );
297
- }
298
- }
299
- /*
300
- * renders the image
301
- */
302
- public function render_meta_box_image( $post ) {
303
- $image = get_post_meta( $post->ID, 'cf7_style_image_preview', true );
304
- if ( !empty( $image ) ) {
305
- echo '<img src="' . plugins_url() . '/contact-form-7-style' . $image . '" alt="' . $post->title . '" />';
306
- } else {
307
- //here will be the placeholder in case the image is not available
308
- $image = 'default_form.jpg';
309
- echo '<img src="' . plugins_url() . '/contact-form-7-style/images/' . $image . '" alt="' . $post->title . '" />';
310
- }
311
- }
312
-
313
- /**
314
- *IMAGE META BOX ENDS HERE
315
- ***************************
316
- */
317
- /*
318
- * Meta box for font selector
319
- */
320
- public function add_meta_box_font_selector( $post_type ) {
321
- $post_types = array('cf7_style'); //limit meta box to certain post types
322
- if ( in_array( $post_type, $post_types )) {
323
- add_meta_box(
324
- 'cf7_style_meta_box_font_selector'
325
- ,__( 'Select a Google Font', 'contact-form-7-style' )
326
- ,array( $this, 'render_font_selector' )
327
- ,$post_type
328
- ,'advanced'
329
- ,'high'
330
- );
331
- }
332
- }
333
- public function render_font_selector( $post ) {
334
- wp_nonce_field( 'cf_7_style_font_inner_custom_box', 'cf_7_style_font_custom_box_nonce' );
335
- //getting all google fonts
336
- $google_list = wp_safe_remote_get( 'https://www.googleapis.com/webfonts/v1/webfonts?key=AIzaSyBAympIKDNKmfxhI3udY-U_9vDWSdfHrEo' );
337
- $response = wp_remote_retrieve_body( $google_list );
338
-
339
- $font_obj = json_decode( $response );
340
- $cf7_style_font = get_post_meta( $post->ID, 'cf7_style_font', true );
341
- $selected = '';
342
- echo '<select name="cf7_style_font_selector">';
343
- echo '<option value="none">'.__( 'None', 'contact-form-7-style' ).'</option>';
344
- foreach ( $font_obj->items as $font) {
345
- echo '<option value="' . $font->family . '"' . ( $cf7_style_font == $font->family ? 'selected="selected"' : '' ) . '>' . $font->family . '</option>';
346
- }
347
- echo '</select>'; ?>
348
- <div class="cf7-style preview-zone">
349
- <h4><?php _e( "Preview Selected font:", "contact-form-7-style" ) ?></h4>
350
- <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Curabitur rhoncus ultrices neque sit amet consequat. Aenean facilisis massa convallis nisl viverra eleifend. Nam fermentum mauris eu eleifend posuere.</p>
351
- </div>
352
- <div class="clear"></div>
353
- <?php
354
- }
355
-
356
- /**
357
- * Save the font id
358
- */
359
- public function save_font_id( $post_id ) {
360
- if ( ! isset( $_POST['cf_7_style_font_custom_box_nonce'] ) )
361
- return $post_id;
362
-
363
- $nonce = $_POST['cf_7_style_font_custom_box_nonce'];
364
-
365
- if ( ! wp_verify_nonce( $nonce, 'cf_7_style_font_inner_custom_box' ) ) {
366
- return $post_id;
367
- }
368
-
369
- if ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) {
370
- return $post_id;
371
- }
372
-
373
- if ( 'page' == $_POST['post_type'] ) {
374
- if ( ! current_user_can( 'edit_page', $post_id ) ) {
375
- return $post_id;
376
- }
377
- } else {
378
- if ( ! current_user_can( 'edit_post', $post_id ) ) {
379
- return $post_id;
380
- }
381
-
382
- }
383
-
384
- if ( isset ( $_POST['cf7_style_font_selector'] ) ) {
385
- update_post_meta( $post_id, 'cf7_style_font', sanitize_text_field( $_POST['cf7_style_font_selector'] ));
386
- }
387
- }
388
- /*************************************************
389
- * Adds the meta box container for IMAGE PREVIEW
390
- * IMAGE META BOX STARTS HERE
391
- */
392
- public function add_meta_box_style_paypal( $post_type ) {
393
- $post_types = array('cf7_style'); //limit meta box to certain post types
394
- if ( in_array( $post_type, $post_types )) {
395
- add_meta_box(
396
- 'cf7_style_meta_box_paypal'
397
- ,__( 'Donate', 'contact-form-7-style' )
398
- ,array( $this, 'render_meta_paypal' )
399
- ,$post_type
400
- ,'side'
401
- ,'high'
402
- );
403
- }
404
- }
405
- /*
406
- * renders the image
407
- */
408
- public function render_meta_paypal( $post ) { ?>
409
- <p><?php _e( "Your donation will motivate us to work more and improve this plugin.", "contact-form-7-style" ); ?></p>
410
- <a href="http://cf7style.com/back-this-project/" target="_blank">
411
- <img src="<?php echo WPCF7S_LOCATION;?>admin/images/paypal.svg">
412
- </a>
413
- <?php }
414
- }
415
-
416
- //gets the slug of a post
417
- function cf7_style_the_slug() {
418
- global $post;
419
- $post_data = get_post($post->ID, ARRAY_A);
420
- $slug = $post_data['post_name'];
421
- return $slug;
422
- }
423
- //enques the font
424
- function enque_selected_font() {
425
- if ( is_page() || is_single() || is_home() ) {
426
- global $post;
427
- $active_styles = active_styles();
428
- foreach( $active_styles as $cf7s_id ) {
429
- if ( $cf7s_id ) {
430
- $fontid = get_post_meta( $cf7s_id, 'cf7_style_font', true );
431
- $googlefont = preg_replace( "/ /", "+", $fontid );
432
- if( ! empty( $googlefont ) && "none" !== $googlefont ) {
433
- wp_register_style( 'googlefont-cf7style-' . $cf7s_id, 'https://fonts.googleapis.com/css?family=' . $googlefont . ':100,200,300,400,500,600,700,800,900&subset=latin,latin-ext,cyrillic,cyrillic-ext,greek-ext,greek,vietnamese', array(), false, 'all' );
434
- wp_enqueue_style( 'googlefont-cf7style-' . $cf7s_id );
435
- }
436
- }
437
- }
438
- }
439
- }
440
- add_action( 'wp_enqueue_scripts', 'enque_selected_font' );
441
-
442
- /*
443
- * returns the name of the font on the current page/post
444
- */
445
- function return_font_name( $cf7s_id ) {
446
- if ( $cf7s_id ) {
447
- $fontname = get_post_meta( $cf7s_id, 'cf7_style_font', true );
448
- return ( $fontname );
449
- }
450
- return false;
451
- }
452
-
453
- /*
454
- * hides change permalink and view buttons on editing screen
455
- */
456
-
457
- add_action('admin_head', 'hide_edit_permalinks_on_style_customizer');
458
- function hide_edit_permalinks_on_style_customizer() {
459
- $currentScreen = get_current_screen();
460
- if(empty($currentScreen)) { return false;}
461
- if ( $currentScreen->post_type == 'cf7_style' ) {
462
- ?>
463
- <style type="text/css">
464
- #titlediv {
465
- margin-bottom: 10px;
466
- }
467
- #edit-slug-box, .inline-edit-col-left, .inline-edit-col-right, .view{
468
- display: none;
469
- }
470
- .inline-edit-col-left.cf7-quick-edit {
471
- display: block;
472
- }
473
- .inline-edit-cf7_style {
474
- background: #eaeaea;
475
- padding: 20px 0;
476
- }
477
- </style>
478
- <?php }
479
- }
480
-
481
-
482
- /**
483
- * Quick edit
484
- */
485
-
486
- add_action( 'quick_edit_custom_box', 'manage_wp_posts_qe_bulk_quick_edit_custom_box', 10, 2 );
487
- function manage_wp_posts_qe_bulk_quick_edit_custom_box( $column_name, $post_type ) {
488
-
489
- if( $post_type == 'cf7_style' && $column_name == 'preview-style' ) {
490
-
491
- switch ( $post_type ) {
492
- case 'cf7_style': ?>
493
- <fieldset class="inline-edit-col-left cf7-quick-edit" style="clear:both">
494
- <div class="hidden-fields"></div>
495
- <h4><?php _e( "Activate this template on the following forms:", "contact-form-7-style" ); ?></h4>
496
- <div class="inline-edit-col">
497
- <span class="data">
498
- <?php
499
- $args = array(
500
- 'post_type' => 'wpcf7_contact_form',
501
- 'post_status' => 'publish',
502
- 'posts_per_page' => -1
503
- );
504
- $forms = new WP_Query( $args );
505
-
506
- if( $forms->have_posts() ) :
507
- while( $forms->have_posts() ) : $forms->the_post();
508
- $form_title = get_the_title();
509
- $id = get_the_ID();
510
- $form_id = "form-" . $id;
511
- $form_style = get_post_meta( get_the_ID(), 'cf7_style_id', true );
512
-
513
- echo "<p><span class='input-text-wrap'><input type='checkbox' name='form[{$id}]' id='form[{$id}]' data-id='{$id}' data-style='{$form_style}' /><label for='form[{$id}]' style='display:inline'>{$form_title}</label></span></p>";
514
- if( ! empty( $form_style ) && $id != $form_style ) {
515
- $template = get_the_title( $form_style );
516
- $permalink = admin_url() . "post.php?post={$form_style}&action=edit";
517
- echo "<span class='notice'>".__( "Notice: This form allready has a selected style. Checking this one will overwrite the", "contact-form-7-style" )." <a href='{$permalink}' title='{$template}'>".__( "other one", "contact-form-7-style" )."</a>.</span>";
518
- }
519
- endwhile;
520
- wp_reset_postdata();
521
- endif; ?>
522
- </span>
523
- </div>
524
- </fieldset><?php
525
- break;
526
- }
527
- }
528
- }
529
-
530
-
531
- /**
532
- * Populate Quick Edit fields
533
- */
534
-
535
- add_action( 'admin_print_scripts-edit.php', 'manage_wp_posts_be_qe_enqueue_admin_scripts' );
536
- function manage_wp_posts_be_qe_enqueue_admin_scripts() {
537
- // if using code as plugin
538
- wp_enqueue_script( 'manage-wp-posts-using-bulk-quick-edit', trailingslashit( plugin_dir_url( __FILE__ ) ) . 'admin/js/quick.edit-min.js', array( 'jquery', 'inline-edit-post' ), '', true );
539
- }
540
-
541
-
542
- /**
543
- * Save quick edit templates
544
- */
545
-
546
- add_action( 'save_post_cf7_style', 'manage_wp_posts_be_qe_save_post', 10, 2 );
547
- function manage_wp_posts_be_qe_save_post( $post_id, $post ) {
548
- // pointless if $_POST is empty (this happens on bulk edit)
549
- if ( empty( $_POST ) )
550
- return $post_id;
551
-
552
- // verify quick edit nonce
553
- if ( isset( $_POST[ '_inline_edit' ] ) && ! wp_verify_nonce( $_POST[ '_inline_edit' ], 'inlineeditnonce' ) )
554
- return $post_id;
555
-
556
- // don't save for autosave
557
- if ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE )
558
- return $post_id;
559
-
560
- // dont save for revisions
561
- if ( isset( $post->post_type ) && $post->post_type == 'revision' )
562
- return $post_id;
563
-
564
- if( isset( $_POST['form'] ) ) {
565
- foreach( $_POST['form'] as $form_id => $value ) {
566
- update_post_meta( $form_id, 'cf7_style_id', $post_id );
567
- }
568
- }
569
-
570
- if( isset( $_POST['remove-form'] ) ) {
571
- foreach( $_POST['remove-form'] as $form_id => $value ) {
572
- update_post_meta( $form_id, 'cf7_style_id', '' );
573
- }
574
- }
575
-
 
 
 
 
 
 
 
576
  }
1
+ <?php
2
+
3
+ if ( !defined( 'ABSPATH' ) ) {
4
+ exit;
5
+ }
6
+
7
+ function active_styles() {
8
+
9
+ $args = array(
10
+ 'post_type'=>'wpcf7_contact_form',
11
+ 'post_status'=>'publish',
12
+ 'posts_per_page'=> -1
13
+ );
14
+ $active_styles = array();
15
+ $forms = new WP_Query( $args );
16
+
17
+ if( $forms->have_posts() ) :
18
+ while( $forms->have_posts() ) : $forms->the_post();
19
+ $form_title = get_the_title();
20
+ $id = get_the_ID();
21
+ $style_id = get_post_meta( $id, 'cf7_style_id', true );
22
+ if ( ! empty( $style_id ) || $style_id != 0 ) {
23
+ $active_styles[] = $style_id;
24
+ }
25
+ endwhile;
26
+ wp_reset_postdata();
27
+ endif;
28
+ return $active_styles;
29
+ }
30
+
31
+
32
+ /**
33
+ * Calls the class the meta box. Used for selecting forms for each style.
34
+ */
35
+ function cf7_style_meta_form_init() {
36
+ new cf7_style_meta_boxes();
37
+ }
38
+
39
+ if ( is_admin() ) {
40
+ add_action( 'load-post.php', 'cf7_style_meta_form_init' );
41
+ add_action( 'load-post-new.php', 'cf7_style_meta_form_init' );
42
+ }
43
+
44
+ function filter_w_zeros($var){
45
+ return ($var !== NULL && $var !== FALSE && $var !== '');
46
+ }
47
+
48
+ /**
49
+ * The Class for creating all of the meta boxes
50
+ */
51
+ class cf7_style_meta_boxes {
52
+
53
+ /**
54
+ * Hook into the appropriate actions when the class is constructed.
55
+ */
56
+ public function __construct() {
57
+ //selector init
58
+ add_action( 'add_meta_boxes', array( $this, 'add_meta_box_style_selector' ) );
59
+ add_action( 'save_post', array( $this, 'save_style_selector' ) );
60
+ //fonts
61
+ add_action( 'add_meta_boxes', array( $this, 'add_meta_box_font_selector' ) );
62
+ add_action( 'save_post', array( $this, 'save_font_id' ) );
63
+ //image meta box init
64
+ add_action( 'add_meta_boxes', array( $this, 'add_meta_box_style_image' ) );
65
+ //add paypal button
66
+ add_action( 'add_meta_boxes', array( $this, 'add_meta_box_style_paypal' ) );
67
+ //custom style meta box1
68
+ add_action( 'add_meta_boxes', array( $this, 'add_meta_box_style_customizer' ), 10, 2 );
69
+ add_action( 'save_post', array( $this, 'save_style_customizer' ) );
70
+ }
71
+
72
+ /**************************************************
73
+ * Adds the meta box container for style selector.
74
+ * STYLE SELECTOR STARTS HERE
75
+ */
76
+ public function add_meta_box_style_selector( $post_type ) {
77
+ $post_types = array('cf7_style'); //limit meta box to certain post types
78
+ if ( in_array( $post_type, $post_types )) {
79
+ add_meta_box(
80
+ 'cf7_style_meta_box_form_selector'
81
+ ,__( 'Select forms for current style', 'contact-form-7-style' )
82
+ ,array( $this, 'render_meta_box_selector' )
83
+ ,$post_type
84
+ ,'advanced'
85
+ ,'high'
86
+ );
87
+ }
88
+ }
89
+ public function add_meta_box_style_customizer( $post_type, $post ) {
90
+
91
+ $post_types = array('cf7_style'); //limit meta box to certain post types
92
+ $custom_cat = get_the_terms( $post->ID, "style_category" );
93
+ $custom_name = ( empty( $custom_cat ) ) ? "custom style" : $custom_cat[0]->name;
94
+ if ( in_array( $post_type, $post_types ) && ( $custom_name == "custom style" ) ) {
95
+ add_meta_box(
96
+ 'cf7_style_meta_box_style_customizer'
97
+ ,__( 'Custom style settings', 'contact-form-7-style' )
98
+ ,array( $this, 'render_meta_box_style_customizer' )
99
+ ,$post_type
100
+ ,'advanced'
101
+ ,'high'
102
+ );
103
+ }
104
+ }
105
+
106
+ public function render_meta_box_style_customizer( $post ) {
107
+ require_once WPCF7S_PLUGIN_DIR . '/options.php';
108
+ }
109
+
110
+ public function save_style_customizer( $post_id ) {
111
+
112
+ if ( ! isset( $_POST['cf_7_style_customizer_custom_box_nonce'] ) )
113
+ return $post_id;
114
+
115
+ $nonce = sanitize_text_field($_POST['cf_7_style_customizer_custom_box_nonce']);
116
+
117
+
118
+ // Verify that the nonce is valid.
119
+ if ( ! wp_verify_nonce( $nonce, 'cf_7_style_style_customizer_inner_custom_box' ) ) {
120
+ return $post_id;
121
+ }
122
+
123
+ if ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) {
124
+ return $post_id;
125
+ }
126
+
127
+ if ( 'page' == sanitize_text_field($_POST['post_type']) ) {
128
+ if ( ! current_user_can( 'edit_page', $post_id ) ) {
129
+ return $post_id;
130
+ }
131
+ } else {
132
+ if ( ! current_user_can( 'edit_post', $post_id ) ) {
133
+ return $post_id;
134
+ }
135
+
136
+ }
137
+
138
+ $posted_data = sanitize_text_field($_POST['cf7styleallvalues']);
139
+ $posted_data = str_replace("\'", '"', $posted_data);
140
+ $posted_data = json_decode($posted_data, true);
141
+
142
+ foreach ( $posted_data as $p_key => $p_value) {
143
+ if( strpos($p_key, '_unit' ) !== false){
144
+ $no_unit = str_replace("_unit","", $p_key );
145
+ if( !array_key_exists($no_unit, $posted_data) || empty( $posted_data[$no_unit]) ){
146
+ unset($posted_data[$p_key]);
147
+ }
148
+ }
149
+ }
150
+
151
+ ksort($posted_data);
152
+
153
+ $active_pane = sanitize_text_field($_POST['cf7styleactivepane']);
154
+ if( isset( $active_pane )){
155
+ update_post_meta( $post_id, 'cf7_style_active_panel', $active_pane, "");
156
+ }
157
+ if ( is_array( $posted_data ) && isset( $posted_data ) ) {
158
+ update_post_meta( $post_id, 'cf7_style_custom_styler', array_filter($posted_data,'filter_w_zeros') , "");
159
+ }
160
+
161
+ }
162
+
163
+ /**
164
+ * Save the style selector when the post is saved.
165
+ */
166
+ public function save_style_selector( $post_id ) {
167
+ if ( ! isset( $_POST['cf_7_style_selector_custom_box_nonce'] ) )
168
+ return $post_id;
169
+
170
+ $nonce = sanitize_text_field( $_POST['cf_7_style_selector_custom_box_nonce'] );
171
+
172
+ // Verify that the nonce is valid.
173
+ if ( ! wp_verify_nonce( $nonce, 'cf_7_style_selector_inner_custom_box' ) ) {
174
+ return $post_id;
175
+ }
176
+
177
+ if ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) {
178
+ return $post_id;
179
+ }
180
+
181
+ if ( 'page' == sanitize_text_field( $_POST['post_type'] ) ) {
182
+ if ( ! current_user_can( 'edit_page', $post_id ) ) {
183
+ return $post_id;
184
+ }
185
+ } else {
186
+ if ( ! current_user_can( 'edit_post', $post_id ) ) {
187
+ return $post_id;
188
+ }
189
+
190
+ }
191
+
192
+ //getting all the cf7 forms
193
+ $cf7formsargs = array(
194
+ 'post_type' => 'wpcf7_contact_form',
195
+ 'posts_per_page' => -1
196
+ );
197
+ $cf7forms = get_posts( $cf7formsargs );
198
+
199
+ //for each checked form, saving the style id
200
+ foreach ( $cf7forms as $cf7form ) {
201
+ if ( isset( $_POST[$cf7form->post_name] ) ) {
202
+ //if ( !empty( $_POST[$cf7form->post_name] ) ) {
203
+ update_post_meta( $cf7form->ID, 'cf7_style_id', $post_id);
204
+ //}
205
+ } else {
206
+ $getthisstyle = get_post_meta( $cf7form->ID, 'cf7_style_id', $post_id );
207
+
208
+ if ( !empty( $getthisstyle ) && $post_id == $getthisstyle ) {
209
+ update_post_meta( $cf7form->ID, 'cf7_style_id', '' );
210
+ }
211
+
212
+ if ( !empty( $getthisstyle ) ) {
213
+ //update_post_meta( $cf7form->ID, 'cf7_style_id', $getthisstyle );
214
+ }
215
+ }
216
+ }
217
+ }
218
+
219
+ /**
220
+ * Render Meta Box content.
221
+ */
222
+ public function render_meta_box_selector( $post ) {
223
+ wp_nonce_field( 'cf_7_style_selector_inner_custom_box', 'cf_7_style_selector_custom_box_nonce' );
224
+
225
+ // Display the form, using the current value.
226
+ $args = array(
227
+ 'post_type' => 'wpcf7_contact_form',
228
+ 'posts_per_page' => -1
229
+ );
230
+ $currentpostid = get_the_ID();
231
+
232
+ $query = new WP_Query( $args );
233
+ echo '<table class="wp-list-table fixed pages widefat">';
234
+ echo '<thead>';
235
+ echo '<tr>';
236
+ echo '<th class="manage-column">' . __('Contact form 7 forms', 'contact-form-7-style' ) . '</th>';
237
+ echo '<th class="manage-column different-style"><input type="checkbox" id="select_all"/><label for="select_all">' . __('Select all','contact-form-7-style' ) . '</label></th>';
238
+ echo '<th class="generate-preview-option">' . __( "Generate preview", 'contact-form-7-style' ) . '</th>';
239
+ echo '<th class="gotoform-option">' . __( "Navigate to CF7 form", 'contact-form-7-style' ) . '</th>';
240
+ echo '</tr>';
241
+ echo '</thead>';
242
+ echo '<tbody class="cf7style_body_select_all">';
243
+ if ( $query->have_posts() ) {
244
+ while ( $query->have_posts() ) : $query->the_post();
245
+ $cf7ID = get_the_ID();
246
+ $cf7stylehas = get_post_meta( $cf7ID, 'cf7_style_id', true );
247
+ ?>
248
+ <tr>
249
+ <td>
250
+ <label for="<?php echo cf7_style_the_slug(); ?>"><?php the_title(); ?></label>
251
+ </td>
252
+ <td>
253
+ <input type="checkbox" id="<?php echo cf7_style_the_slug(); ?>" name="<?php echo cf7_style_the_slug(); ?>" value="<?php echo get_the_ID(); ?>" <?php if ( $currentpostid == $cf7stylehas ) { echo 'checked'; } ?> />
254
+ </td>
255
+ <td class="generate-preview-option">
256
+ <button class="button-primary generate-preview-button" data-attr-title="<?php the_title(); ?>" data-attr-id="<?php the_ID(); ?>"><?php _e( "Generate preview", 'contact-form-7-style' ); ?></button>
257
+ </td>
258
+ <td class="gotoform-option">
259
+ <a class="button-primary" href="<?php echo esc_url(admin_url('?page=wpcf7&post='.$cf7ID.'&action=edit' )) ?>" target="_blank" title="<?php the_title(); ?>"><?php _e( "Go To CF7", 'contact-form-7-style' ); ?></a>
260
+ </td>
261
+ </tr>
262
+ <tr>
263
+ <td colspan="2">
264
+ <?php if ( $currentpostid != $cf7stylehas && !empty( $cf7stylehas ) ) {
265
+ echo '<p class="description">' . __('Notice: This form allready has a selected style. Checking this one will overwrite the ', 'contact-form-7-style' ) . '<a href="' . get_admin_url() . 'post.php?post_type=cf7_style&post=' . $cf7stylehas . '&action=edit">' . __('other one.', 'contact-form-7-style' ) . '</a></p>';
266
+ } ?>
267
+ </td>
268
+ <td class="generate-preview-option">&nbsp;</td>
269
+ </tr>
270
+ <?php endwhile; wp_reset_postdata();
271
+ echo '</tbody>';
272
+ echo '</table>';
273
+ } else {
274
+ echo '<tr><td><p class="description">' . __( 'Please create a form. You can do it by clicking', 'contact-form-7-style' ) . '<a href="' . admin_url() . 'admin.php?page=wpcf7-new" target="_blank">' . __(' here', 'contact-form-7-style' ) . '</a></p></td></tr></table>';
275
+ }
276
+ }
277
+ /**
278
+ *STYLE SELECTOR ENDS HERE
279
+ *****************************
280
+ */
281
+
282
+ /*************************************************
283
+ * Adds the meta box container for IMAGE PREVIEW
284
+ * IMAGE META BOX STARTS HERE
285
+ */
286
+ public function add_meta_box_style_image( $post_type ) {
287
+ $post_types = array('cf7_style'); //limit meta box to certain post types
288
+ if ( in_array( $post_type, $post_types )) {
289
+ add_meta_box(
290
+ 'cf7_style_meta_box_image'
291
+ ,__( 'Preview', 'contact-form-7-style' )
292
+ ,array( $this, 'render_meta_box_image' )
293
+ ,$post_type
294
+ ,'side'
295
+ ,'high'
296
+ );
297
+ }
298
+ }
299
+ /*
300
+ * renders the image
301
+ */
302
+ public function render_meta_box_image( $post ) {
303
+ $image = get_post_meta( $post->ID, 'cf7_style_image_preview', true );
304
+ if ( !empty( $image ) ) {
305
+ echo '<img src="' . plugins_url() . '/contact-form-7-style' . $image . '" alt="' . $post->title . '" />';
306
+ } else {
307
+ //here will be the placeholder in case the image is not available
308
+ $image = 'default_form.jpg';
309
+ echo '<img src="' . plugins_url() . '/contact-form-7-style/images/' . $image . '" alt="' . $post->title . '" />';
310
+ }
311
+ }
312
+
313
+ /**
314
+ *IMAGE META BOX ENDS HERE
315
+ ***************************
316
+ */
317
+ /*
318
+ * Meta box for font selector
319
+ */
320
+ public function add_meta_box_font_selector( $post_type ) {
321
+ $post_types = array('cf7_style'); //limit meta box to certain post types
322
+ if ( in_array( $post_type, $post_types )) {
323
+ add_meta_box(
324
+ 'cf7_style_meta_box_font_selector'
325
+ ,__( 'Select a Google Font', 'contact-form-7-style' )
326
+ ,array( $this, 'render_font_selector' )
327
+ ,$post_type
328
+ ,'advanced'
329
+ ,'high'
330
+ );
331
+ }
332
+ }
333
+ public function render_font_selector( $post ) {
334
+ wp_nonce_field( 'cf_7_style_font_inner_custom_box', 'cf_7_style_font_custom_box_nonce' );
335
+ //getting all google fonts
336
+ $google_list = wp_safe_remote_get( 'https://www.googleapis.com/webfonts/v1/webfonts?key=AIzaSyC_tPK6QXRn_0gC3NFAyPsfDxeG4nmtMCU' );
337
+ $response = wp_remote_retrieve_body( $google_list );
338
+
339
+ $font_obj = json_decode( $response );
340
+ $cf7_style_font = get_post_meta( $post->ID, 'cf7_style_font', true );
341
+ $selected = '';
342
+ echo '<select name="cf7_style_font_selector">';
343
+ echo '<option value="none">'.__( 'None', 'contact-form-7-style' ).'</option>';
344
+ foreach ( $font_obj->items as $font) {
345
+ echo '<option value="' . $font->family . '"' . ( $cf7_style_font == $font->family ? 'selected="selected"' : '' ) . '>' . $font->family . '</option>';
346
+ }
347
+ echo '</select>'; ?>
348
+ <div class="cf7-style preview-zone">
349
+ <h4><?php _e( "Preview Selected font:", "contact-form-7-style" ) ?></h4>
350
+ <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Curabitur rhoncus ultrices neque sit amet consequat. Aenean facilisis massa convallis nisl viverra eleifend. Nam fermentum mauris eu eleifend posuere.</p>
351
+ </div>
352
+ <div class="clear"></div>
353
+ <?php
354
+ }
355
+
356
+ /**
357
+ * Save the font id
358
+ */
359
+ public function save_font_id( $post_id ) {
360
+ if ( ! isset( $_POST['cf_7_style_font_custom_box_nonce'] ) )
361
+ return $post_id;
362
+
363
+ $nonce = sanitize_text_field( $_POST['cf_7_style_font_custom_box_nonce'] );
364
+
365
+ if ( ! wp_verify_nonce( $nonce, 'cf_7_style_font_inner_custom_box' ) ) {
366
+ return $post_id;
367
+ }
368
+
369
+ if ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) {
370
+ return $post_id;
371
+ }
372
+
373
+ if ( 'page' == sanitize_text_field( $_POST['post_type'] ) ) {
374
+ if ( ! current_user_can( 'edit_page', $post_id ) ) {
375
+ return $post_id;
376
+ }
377
+ } else {
378
+ if ( ! current_user_can( 'edit_post', $post_id ) ) {
379
+ return $post_id;
380
+ }
381
+
382
+ }
383
+
384
+ if ( isset ( $_POST['cf7_style_font_selector'] ) ) {
385
+ update_post_meta( $post_id, 'cf7_style_font', sanitize_text_field( $_POST['cf7_style_font_selector'] ));
386
+ }
387
+ }
388
+ /*************************************************
389
+ * Adds the meta box container for IMAGE PREVIEW
390
+ * IMAGE META BOX STARTS HERE
391
+ */
392
+ public function add_meta_box_style_paypal( $post_type ) {
393
+ $post_types = array('cf7_style'); //limit meta box to certain post types
394
+ if ( in_array( $post_type, $post_types )) {
395
+ add_meta_box(
396
+ 'cf7_style_meta_box_paypal'
397
+ ,__( 'Donate', 'contact-form-7-style' )
398
+ ,array( $this, 'render_meta_paypal' )
399
+ ,$post_type
400
+ ,'side'
401
+ ,'high'
402
+ );
403
+ }
404
+ }
405
+ /*
406
+ * renders the image
407
+ */
408
+ public function render_meta_paypal( $post ) { ?>
409
+ <p><?php _e( "Your donation will motivate us to work more and improve this plugin.", "contact-form-7-style" ); ?></p>
410
+ <a href="http://cf7style.com/back-this-project/" target="_blank">
411
+ <img src="<?php echo WPCF7S_LOCATION;?>admin/images/paypal.svg">
412
+ </a>
413
+ <?php }
414
+ }
415
+
416
+ //gets the slug of a post
417
+ function cf7_style_the_slug() {
418
+ global $post;
419
+ $post_data = get_post($post->ID, ARRAY_A);
420
+ $slug = $post_data['post_name'];
421
+ return $slug;
422
+ }
423
+ //enques the font
424
+ function enque_selected_font() {
425
+ if ( is_page() || is_single() || is_home() ) {
426
+ global $post;
427
+ $active_styles = active_styles();
428
+ foreach( $active_styles as $cf7s_id ) {
429
+ if ( $cf7s_id ) {
430
+ $fontid = get_post_meta( $cf7s_id, 'cf7_style_font', true );
431
+ $googlefont = preg_replace( "/ /", "+", $fontid );
432
+ if( ! empty( $googlefont ) && "none" !== $googlefont ) {
433
+ wp_register_style( 'googlefont-cf7style-' . $cf7s_id, 'https://fonts.googleapis.com/css?family=' . $googlefont . ':100,200,300,400,500,600,700,800,900&subset=latin,latin-ext,cyrillic,cyrillic-ext,greek-ext,greek,vietnamese', array(), false, 'all' );
434
+ wp_enqueue_style( 'googlefont-cf7style-' . $cf7s_id );
435
+ }
436
+ }
437
+ }
438
+ }
439
+ }
440
+ add_action( 'wp_enqueue_scripts', 'enque_selected_font' );
441
+
442
+ /*
443
+ * returns the name of the font on the current page/post
444
+ */
445
+ function return_font_name( $cf7s_id ) {
446
+ if ( $cf7s_id ) {
447
+ $fontname = get_post_meta( $cf7s_id, 'cf7_style_font', true );
448
+ return ( $fontname );
449
+ }
450
+ return false;
451
+ }
452
+
453
+ /*
454
+ * hides change permalink and view buttons on editing screen
455
+ */
456
+
457
+ add_action('admin_head', 'hide_edit_permalinks_on_style_customizer');
458
+ function hide_edit_permalinks_on_style_customizer() {
459
+ $currentScreen = get_current_screen();
460
+ if(empty($currentScreen)) { return false;}
461
+ if ( $currentScreen->post_type == 'cf7_style' ) {
462
+ ?>
463
+ <style type="text/css">
464
+ #titlediv {
465
+ margin-bottom: 10px;
466
+ }
467
+ #edit-slug-box, .inline-edit-col-left, .inline-edit-col-right, .view{
468
+ display: none;
469
+ }
470
+ .inline-edit-col-left.cf7-quick-edit {
471
+ display: block;
472
+ }
473
+ .inline-edit-cf7_style {
474
+ background: #eaeaea;
475
+ padding: 20px 0;
476
+ }
477
+ </style>
478
+ <?php }
479
+ }
480
+
481
+
482
+ /**
483
+ * Quick edit
484
+ */
485
+
486
+ add_action( 'quick_edit_custom_box', 'manage_wp_posts_qe_bulk_quick_edit_custom_box', 10, 2 );
487
+ function manage_wp_posts_qe_bulk_quick_edit_custom_box( $column_name, $post_type ) {
488
+
489
+ if( $post_type == 'cf7_style' && $column_name == 'preview-style' ) {
490
+
491
+ switch ( $post_type ) {
492
+ case 'cf7_style': ?>
493
+ <fieldset class="inline-edit-col-left cf7-quick-edit" style="clear:both">
494
+ <div class="hidden-fields"></div>
495
+ <h4><?php _e( "Activate this template on the following forms:", "contact-form-7-style" ); ?></h4>
496
+ <div class="inline-edit-col">
497
+ <span class="data">
498
+ <?php
499
+ $args = array(
500
+ 'post_type' => 'wpcf7_contact_form',
501
+ 'post_status' => 'publish',
502
+ 'posts_per_page' => -1
503
+ );
504
+ $forms = new WP_Query( $args );
505
+
506
+ if( $forms->have_posts() ) :
507
+ while( $forms->have_posts() ) : $forms->the_post();
508
+ $form_title = get_the_title();
509
+ $id = get_the_ID();
510
+ $form_id = "form-" . $id;
511
+ $form_style = get_post_meta( get_the_ID(), 'cf7_style_id', true );
512
+
513
+ echo "<p><span class='input-text-wrap'><input type='checkbox' name='form[{$id}]' id='form[{$id}]' data-id='{$id}' data-style='{$form_style}' /><label for='form[{$id}]' style='display:inline'>{$form_title}</label></span></p>";
514
+ if( ! empty( $form_style ) && $id != $form_style ) {
515
+ $template = get_the_title( $form_style );
516
+ $permalink = admin_url() . "post.php?post={$form_style}&action=edit";
517
+ echo "<span class='notice'>".__( "Notice: This form allready has a selected style. Checking this one will overwrite the", "contact-form-7-style" )." <a href='{$permalink}' title='{$template}'>".__( "other one", "contact-form-7-style" )."</a>.</span>";
518
+ }
519
+ endwhile;
520
+ wp_reset_postdata();
521
+ endif; ?>
522
+ </span>
523
+ </div>
524
+ </fieldset><?php
525
+ break;
526
+ }
527
+ }
528
+ }
529
+
530
+
531
+ /**
532
+ * Populate Quick Edit fields
533
+ */
534
+
535
+ add_action( 'admin_print_scripts-edit.php', 'manage_wp_posts_be_qe_enqueue_admin_scripts' );
536
+ function manage_wp_posts_be_qe_enqueue_admin_scripts() {
537
+ // if using code as plugin
538
+ wp_enqueue_script( 'manage-wp-posts-using-bulk-quick-edit', trailingslashit( plugin_dir_url( __FILE__ ) ) . 'admin/js/quick.edit-min.js', array( 'jquery', 'inline-edit-post' ), '', true );
539
+ }
540
+
541
+
542
+ /**
543
+ * Save quick edit templates
544
+ */
545
+
546
+ add_action( 'save_post_cf7_style', 'manage_wp_posts_be_qe_save_post', 10, 2 );
547
+ function manage_wp_posts_be_qe_save_post( $post_id, $post ) {
548
+ // pointless if $_POST is empty (this happens on bulk edit)
549
+ if ( empty( $_POST ) )
550
+ return $post_id;
551
+
552
+ // verify quick edit nonce
553
+ if ( isset( $_POST[ '_inline_edit' ] ) && ! wp_verify_nonce( sanitize_text_field( $_POST[ '_inline_edit' ] ), 'inlineeditnonce' ) )
554
+ return $post_id;
555
+
556
+ // don't save for autosave
557
+ if ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE )
558
+ return $post_id;
559
+
560
+ // dont save for revisions
561
+ if ( isset( $post->post_type ) && $post->post_type == 'revision' )
562
+ return $post_id;
563
+
564
+ $form_array = isset( $_POST['form'] ) ? (array) $_POST['form'] : array();
565
+ $form_array = array_map( 'esc_attr', $form_array );
566
+
567
+ if( !empty( $form_array ) ) {
568
+
569
+ foreach( $form_array as $form_id => $value ) {
570
+ update_post_meta( $form_id, 'cf7_style_id', $post_id );
571
+ }
572
+ }
573
+
574
+ $remove_form_array = isset( $_POST['remove-form'] ) ? (array) $_POST['remove-form'] : array();
575
+ $remove_form_array = array_map( 'esc_attr', $remove_form_array );
576
+
577
+ if( !empty($remove_form_array) ) {
578
+ foreach( $remove_form_array as $form_id => $value ) {
579
+ update_post_meta( $form_id, 'cf7_style_id', '' );
580
+ }
581
+ }
582
+
583
  }
cf7-style.php CHANGED
@@ -1,140 +1,140 @@
1
- <?php
2
- /*
3
- Plugin Name: Contact Form 7 Style
4
- Plugin URI: http://wordpress.reea.net/contact-form-7-style/
5
- Description: Simple style customization and templating for Contact Form 7 forms. Requires Contact Form 7 plugin installed.
6
- Version: 3.1.8
7
- Author: Johnny, dorumarginean, mlehelsz, MirceaR
8
- Author URI: http://cf7style.com
9
- License: GPL2
10
- @Author: Johnny, dorumarginean, mlehelsz, MirceaR
11
- */
12
-
13
- if ( !defined( 'ABSPATH' ) ) {
14
- exit;
15
- }
16
-
17
- /*
18
- * Include the plugin options
19
- */
20
- define( 'WPCF7S_PLUGIN', __FILE__ );
21
- define( 'WPCF7S_PLUGIN_DIR', untrailingslashit( dirname( WPCF7S_PLUGIN ) ) );
22
- define( 'WPCF7S_LOCATION',plugin_dir_url( WPCF7S_PLUGIN ) );
23
- define( 'WPCF7S_PLUGIN_VER', '3.1.8' );
24
- define( 'WPCF7S_REQ_PLUGIN', 'contact-form-7/wp-contact-form-7.php' );
25
-
26
- /*
27
- * Get contact form 7 ID
28
- */
29
- require_once( 'inc/get_form_id.php' );
30
-
31
- /*
32
- * Load Custom CSS generator function here
33
- */
34
- require_once( 'inc/custom_css_generator.php' );
35
-
36
-
37
- /*
38
- * Check for Contact Form 7 plugin
39
- * Add proper messages to admin pages : missing CF7, not active CF7, success CF7k, remove predefined templates
40
- */
41
- require_once( 'inc/admin_notices_activation.php' );
42
-
43
- /*
44
- * Check for current version
45
- */
46
- require_once( 'inc/check_cfstyle_version.php' );
47
-
48
- /*
49
- * Create custom post type and taxonomy and populate with predefined templates
50
- * Create custom style layout with metaboxes
51
- * Front-End part: run style generator
52
- */
53
- require_once( 'inc/init_style.php' );
54
-
55
- /*
56
- * Add CF7Style edit URL to wpadminbar with bird icon
57
- * Last positioned element
58
- */
59
- require_once( 'inc/adminbar_add_link.php' );
60
-
61
- /*
62
- * Add required admin styles and scripts
63
- */
64
- require_once( 'inc/add_required_admin_scripts.php' );
65
-
66
- /*
67
- * Add required frontend styles and scripts
68
- */
69
- require_once( 'inc/add_required_frontend_scripts.php' );
70
-
71
-
72
- /*
73
- * Add filters to dashboard for CF7Style plugin
74
- */
75
- require_once( 'inc/taxonomy_filters_add.php' );
76
-
77
- /*
78
- * Add cf7style proper class to CF7 form where needed
79
- */
80
- require_once( 'inc/cf7_add_form_class.php' );
81
-
82
- /*
83
- * Add Preview style column to the Contact Styles listing table
84
- */
85
- require_once( 'inc/dashboard_table_add_preview.php' );
86
-
87
- /*
88
- * Check for Predefined templates and update options : "cf7_style_no_temps" and "cf7_style_deleted"
89
- */
90
- require_once( 'inc/check_deleted_templates.php' );
91
-
92
- /*
93
- * Deactivation hook
94
- */
95
- require_once( 'inc/deactivate_style.php' );
96
-
97
- /*
98
- * Welcome panel
99
- */
100
- require_once( 'misc/welcome.php' );
101
-
102
- /*
103
- * Slider meta box in CF7
104
- */
105
- require_once( 'inc/slider_meta_box.php' );
106
-
107
- /*
108
- * global css page
109
- */
110
- require_once( 'inc/editor_page.php' );
111
-
112
- /*
113
- * Remove Predefined templates
114
- */
115
- require_once( 'inc/remove_predefined_templates.php' );
116
-
117
- /*
118
- * CTA: Close delete predefined box will hide the notice for removing the predefined templates
119
- */
120
- require_once( 'inc/dashboard_hide_delete_tpl_box.php' );
121
-
122
- /*
123
- * CTA: Close welcome box will hide the welcome elements
124
- */
125
- require_once( 'inc/dashboard_hide_welcome_box.php' );
126
-
127
- /*
128
- * Frontend edit link
129
- */
130
- require_once( 'inc/frontend_edit_style_link.php' );
131
-
132
- /*
133
- * Dashboard generate preview on user interaction
134
- */
135
- require_once( 'inc/dashboard_generate_preview.php' );
136
-
137
- /*
138
- * Dashboard generate custom style desired properties
139
- */
140
- require_once( 'inc/dashboard_load_custom_property.php' );
1
+ <?php
2
+ /*
3
+ Plugin Name: Contact Form 7 Style
4
+ Plugin URI: http://wordpress.reea.net/contact-form-7-style/
5
+ Description: Simple style customization and templating for Contact Form 7 forms. Requires Contact Form 7 plugin installed.
6
+ Version: 3.1.9
7
+ Author: Johnny, mlehelsz
8
+ Author URI: http://cf7style.com
9
+ License: GPL2
10
+ @Author: Johnny, mlehelsz
11
+ */
12
+
13
+ if ( !defined( 'ABSPATH' ) ) {
14
+ exit;
15
+ }
16
+
17
+ /*
18
+ * Include the plugin options
19
+ */
20
+ define( 'WPCF7S_PLUGIN', __FILE__ );
21
+ define( 'WPCF7S_PLUGIN_DIR', untrailingslashit( dirname( WPCF7S_PLUGIN ) ) );
22
+ define( 'WPCF7S_LOCATION',plugin_dir_url( WPCF7S_PLUGIN ) );
23
+ define( 'WPCF7S_PLUGIN_VER', '3.1.9' );
24
+ define( 'WPCF7S_REQ_PLUGIN', 'contact-form-7/wp-contact-form-7.php' );
25
+
26
+ /*
27
+ * Get contact form 7 ID
28
+ */
29
+ require_once( 'inc/get_form_id.php' );
30
+
31
+ /*
32
+ * Load Custom CSS generator function here
33
+ */
34
+ require_once( 'inc/custom_css_generator.php' );
35
+
36
+
37
+ /*
38
+ * Check for Contact Form 7 plugin
39
+ * Add proper messages to admin pages : missing CF7, not active CF7, success CF7k, remove predefined templates
40
+ */
41
+ require_once( 'inc/admin_notices_activation.php' );
42
+
43
+ /*
44
+ * Check for current version
45
+ */
46
+ require_once( 'inc/check_cfstyle_version.php' );
47
+
48
+ /*
49
+ * Create custom post type and taxonomy and populate with predefined templates
50
+ * Create custom style layout with metaboxes
51
+ * Front-End part: run style generator
52
+ */
53
+ require_once( 'inc/init_style.php' );
54
+
55
+ /*
56
+ * Add CF7Style edit URL to wpadminbar with bird icon
57
+ * Last positioned element
58
+ */
59
+ require_once( 'inc/adminbar_add_link.php' );
60
+
61
+ /*
62
+ * Add required admin styles and scripts
63
+ */
64
+ require_once( 'inc/add_required_admin_scripts.php' );
65
+
66
+ /*
67
+ * Add required frontend styles and scripts
68
+ */
69
+ require_once( 'inc/add_required_frontend_scripts.php' );
70
+
71
+
72
+ /*
73
+ * Add filters to dashboard for CF7Style plugin
74
+ */
75
+ require_once( 'inc/taxonomy_filters_add.php' );
76
+
77
+ /*
78
+ * Add cf7style proper class to CF7 form where needed
79
+ */
80
+ require_once( 'inc/cf7_add_form_class.php' );
81
+
82
+ /*
83
+ * Add Preview style column to the Contact Styles listing table
84
+ */
85
+ require_once( 'inc/dashboard_table_add_preview.php' );
86
+
87
+ /*
88
+ * Check for Predefined templates and update options : "cf7_style_no_temps" and "cf7_style_deleted"
89
+ */
90
+ require_once( 'inc/check_deleted_templates.php' );
91
+
92
+ /*
93
+ * Deactivation hook
94
+ */
95
+ require_once( 'inc/deactivate_style.php' );
96
+
97
+ /*
98
+ * Welcome panel
99
+ */
100
+ require_once( 'misc/welcome.php' );
101
+
102
+ /*
103
+ * Slider meta box in CF7
104
+ */
105
+ require_once( 'inc/slider_meta_box.php' );
106
+
107
+ /*
108
+ * global css page
109
+ */
110
+ require_once( 'inc/editor_page.php' );
111
+
112
+ /*
113
+ * Remove Predefined templates
114
+ */
115
+ require_once( 'inc/remove_predefined_templates.php' );
116
+
117
+ /*
118
+ * CTA: Close delete predefined box will hide the notice for removing the predefined templates
119
+ */
120
+ require_once( 'inc/dashboard_hide_delete_tpl_box.php' );
121
+
122
+ /*
123
+ * CTA: Close welcome box will hide the welcome elements
124
+ */
125
+ require_once( 'inc/dashboard_hide_welcome_box.php' );
126
+
127
+ /*
128
+ * Frontend edit link
129
+ */
130
+ require_once( 'inc/frontend_edit_style_link.php' );
131
+
132
+ /*
133
+ * Dashboard generate preview on user interaction
134
+ */
135
+ require_once( 'inc/dashboard_generate_preview.php' );
136
+
137
+ /*
138
+ * Dashboard generate custom style desired properties
139
+ */
140
+ require_once( 'inc/dashboard_load_custom_property.php' );
inc/add_required_admin_scripts.php CHANGED
@@ -1,33 +1,33 @@
1
- <?php
2
-
3
- if ( !defined( 'ABSPATH' ) ) {
4
- exit;
5
- }
6
-
7
- function cf7_style_admin_scripts($hook){
8
- global $post_type;
9
- if (!wp_script_is( 'jquery', 'enqueued' )) {
10
- wp_enqueue_script('jquery');
11
- }
12
- wp_enqueue_style( "cf7-style-bar-style", WPCF7S_LOCATION . "css/admin-bar.css", array(), WPCF7S_PLUGIN_VER, "all");
13
- wp_enqueue_script( "cf7_style_overall", WPCF7S_LOCATION . "admin/js/overall-min.js", array('jquery'), WPCF7S_PLUGIN_VER, true );
14
- if( 'cf7_style_page_cf7style-css-editor' == $hook ){
15
- wp_enqueue_script( "cf7_style_codemirror_js", WPCF7S_LOCATION . "admin/js/codemirror.js", array( 'jquery' ), WPCF7S_PLUGIN_VER, true );
16
- wp_enqueue_style( "cf7-style-codemirror-style", WPCF7S_LOCATION . "admin/css/codemirror.css", array(), WPCF7S_PLUGIN_VER, "all" );
17
- wp_enqueue_script( "cf7-style-codemirror-mode", WPCF7S_LOCATION . "admin/js/mode/css/css.js", array( 'jquery' ), WPCF7S_PLUGIN_VER, true );
18
- }
19
- if( 'cf7_style' == $post_type){
20
- wp_enqueue_style( 'wp-color-picker' );
21
- wp_enqueue_script( 'thickbox' );
22
- wp_enqueue_style( 'thickbox' );
23
- wp_enqueue_script( 'media-upload' );
24
- }
25
- if( 'plugins.php'== $hook || 'cf7_style' == $post_type || 'toplevel_page_wpcf7' == $hook || 'cf7_style_page_cf7style-css-editor' == $hook || 'cf7_style_page_system-status' == $hook || 'cf7_style_page_cf7style-settings' == $hook ){
26
- wp_enqueue_style( "cf7-style-fontello-ie7", WPCF7S_LOCATION . "admin/css/fontello-ie7.css", false, WPCF7S_PLUGIN_VER, "all");
27
- wp_enqueue_style( "cf7-style-fontello", WPCF7S_LOCATION . "admin/css/fontello.css", false, WPCF7S_PLUGIN_VER, "all");
28
- wp_enqueue_style( "cf7-style-admin-style", WPCF7S_LOCATION . "admin/css/admin.css", false, WPCF7S_PLUGIN_VER, "all");
29
- wp_enqueue_script( "cf7_style_admin_js", WPCF7S_LOCATION . "admin/js/admin-min.js", array( 'wp-color-picker', 'jquery' ), WPCF7S_PLUGIN_VER, true );
30
- }
31
- }
32
-
33
  add_action( 'admin_enqueue_scripts', 'cf7_style_admin_scripts' );
1
+ <?php
2
+
3
+ if ( !defined( 'ABSPATH' ) ) {
4
+ exit;
5
+ }
6
+
7
+ function cf7_style_admin_scripts($hook){
8
+ global $post_type;
9
+ if (!wp_script_is( 'jquery', 'enqueued' )) {
10
+ wp_enqueue_script('jquery');
11
+ }
12
+ wp_enqueue_style( "cf7-style-bar-style", WPCF7S_LOCATION . "css/admin-bar.css", array(), WPCF7S_PLUGIN_VER, "all");
13
+ wp_enqueue_script( "cf7_style_overall", WPCF7S_LOCATION . "admin/js/overall-min.js", array('jquery'), WPCF7S_PLUGIN_VER, true );
14
+ if( 'cf7_style_page_cf7style-css-editor' == $hook ){
15
+ wp_enqueue_script( "cf7_style_codemirror_js", WPCF7S_LOCATION . "admin/js/codemirror.js", array( 'jquery' ), WPCF7S_PLUGIN_VER, true );
16
+ wp_enqueue_style( "cf7-style-codemirror-style", WPCF7S_LOCATION . "admin/css/codemirror.css", array(), WPCF7S_PLUGIN_VER, "all" );
17
+ wp_enqueue_script( "cf7-style-codemirror-mode", WPCF7S_LOCATION . "admin/js/mode/css/css.js", array( 'jquery' ), WPCF7S_PLUGIN_VER, true );
18
+ }
19
+ if( 'cf7_style' == $post_type){
20
+ wp_enqueue_style( 'wp-color-picker' );
21
+ wp_enqueue_script( 'thickbox' );
22
+ wp_enqueue_style( 'thickbox' );
23
+ wp_enqueue_script( 'media-upload' );
24
+ }
25
+ if( 'plugins.php'== $hook || 'cf7_style' == $post_type || 'toplevel_page_wpcf7' == $hook || 'cf7_style_page_cf7style-css-editor' == $hook || 'cf7_style_page_system-status' == $hook || 'cf7_style_page_cf7style-settings' == $hook ){
26
+ wp_enqueue_style( "cf7-style-fontello-ie7", WPCF7S_LOCATION . "admin/css/fontello-ie7.css", false, WPCF7S_PLUGIN_VER, "all");
27
+ wp_enqueue_style( "cf7-style-fontello", WPCF7S_LOCATION . "admin/css/fontello.css", false, WPCF7S_PLUGIN_VER, "all");
28
+ wp_enqueue_style( "cf7-style-admin-style", WPCF7S_LOCATION . "admin/css/admin.css", false, WPCF7S_PLUGIN_VER, "all");
29
+ wp_enqueue_script( "cf7_style_admin_js", WPCF7S_LOCATION . "admin/js/admin-min.js", array( 'wp-color-picker', 'jquery' ), WPCF7S_PLUGIN_VER, true );
30
+ }
31
+ }
32
+
33
  add_action( 'admin_enqueue_scripts', 'cf7_style_admin_scripts' );
inc/add_required_frontend_scripts.php CHANGED
@@ -1,19 +1,19 @@
1
- <?php
2
-
3
- if ( !defined( 'ABSPATH' ) ) {
4
- exit;
5
- }
6
-
7
- function cf7_style_frontend_scripts(){
8
- if (!wp_script_is( 'jquery', 'enqueued' )) {
9
- wp_enqueue_script('jquery');
10
- }
11
- if(is_user_logged_in()){
12
- wp_enqueue_style( "cf7-style-bar-style", WPCF7S_LOCATION . "css/admin-bar.css", array(), WPCF7S_PLUGIN_VER, "all");
13
- }
14
- wp_enqueue_style( "cf7-style-frontend-style", WPCF7S_LOCATION . "css/frontend.css", array(), WPCF7S_PLUGIN_VER, "all");
15
- wp_enqueue_style( "cf7-style-responsive-style", WPCF7S_LOCATION . "css/responsive.css", array(), WPCF7S_PLUGIN_VER, "all");
16
- wp_enqueue_script( "cf7-style-frontend-script", WPCF7S_LOCATION . "js/frontend-min.js", array( 'jquery' ), WPCF7S_PLUGIN_VER, true);
17
- }
18
-
19
  add_action( 'wp_enqueue_scripts', 'cf7_style_frontend_scripts' );
1
+ <?php
2
+
3
+ if ( !defined( 'ABSPATH' ) ) {
4
+ exit;
5
+ }
6
+
7
+ function cf7_style_frontend_scripts(){
8
+ if (!wp_script_is( 'jquery', 'enqueued' )) {
9
+ wp_enqueue_script('jquery');
10
+ }
11
+ if(is_user_logged_in()){
12
+ wp_enqueue_style( "cf7-style-bar-style", WPCF7S_LOCATION . "css/admin-bar.css", array(), WPCF7S_PLUGIN_VER, "all");
13
+ }
14
+ wp_enqueue_style( "cf7-style-frontend-style", WPCF7S_LOCATION . "css/frontend.css", array(), WPCF7S_PLUGIN_VER, "all");
15
+ wp_enqueue_style( "cf7-style-responsive-style", WPCF7S_LOCATION . "css/responsive.css", array(), WPCF7S_PLUGIN_VER, "all");
16
+ wp_enqueue_script( "cf7-style-frontend-script", WPCF7S_LOCATION . "js/frontend-min.js", array( 'jquery' ), WPCF7S_PLUGIN_VER, true);
17
+ }
18
+
19
  add_action( 'wp_enqueue_scripts', 'cf7_style_frontend_scripts' );
inc/admin_notices_activation.php CHANGED
@@ -1,116 +1,116 @@
1
- <?php
2
-
3
- if ( !defined( 'ABSPATH' ) ) {
4
- exit;
5
- }
6
-
7
- /*
8
- * notice for the user
9
- */
10
- function cf7_designer_deactivation_notice() { ?>
11
- <div class="error">
12
- <p><?php _e( "You cannot activate CF7 Designer while CF7 Style is activated!", "contact-form-7-style" ) ?></p>
13
- </div>
14
- <?php }
15
-
16
- /*
17
- * Function created for deactivated Contact Form 7 Designer plugin.
18
- * This is because styles of that plugin is in conflict with ours.
19
- * No one should add an id in the html tag.
20
- */
21
-
22
- function deactivate_contact_form_7_designer_plugin() {
23
- if ( is_plugin_active('contact-form-7-designer/cf7-styles.php') ) {
24
- deactivate_plugins('contact-form-7-designer/cf7-styles.php');
25
- add_action( 'admin_notices', 'cf7_designer_deactivation_notice' );
26
- }
27
- }
28
-
29
- function cf7_style_rq_plugin($req=false) {
30
-
31
- $all_plugins = get_plugins();
32
-
33
- if( $req == true && array_key_exists( WPCF7S_REQ_PLUGIN, $all_plugins)) return true;
34
- if(!$req) {
35
- $active_plugins = get_option( 'active_plugins' );
36
- if( is_multisite() ) {
37
- $active_plugins = array_merge($active_plugins, array_keys(get_site_option( 'active_sitewide_plugins')));
38
- }
39
- if(in_array( WPCF7S_REQ_PLUGIN, $active_plugins )) return true;
40
- }
41
- return false;
42
- }
43
-
44
- /**
45
- * Check if Contact Form 7 is activated
46
- */
47
- function contact_form_7_check() {
48
-
49
- if(!cf7_style_rq_plugin(true)){
50
- $html = '<div class="error">';
51
- $html .= '<p>';
52
- $html .= __( "Contact form 7 - Style is an addon. Please install", "contact-form-7-style" ).' <a href="'.esc_url(admin_url('plugin-install.php?s=contact+form+7&tab=search&type=term' )).'">Contact form 7</a>.';
53
- $html .= '</p>';
54
- $html .= '</div><!-- /.updated -->';
55
- echo $html;
56
- } else {
57
- if ( !cf7_style_rq_plugin()) {
58
- $html = '<div class="error">';
59
- $html .= '<p>';
60
- $html .= __( "Contact form 7 - Style is an addon. Please activate", "contact-form-7-style" ).' <a href="'.esc_url(wp_nonce_url(admin_url('plugins.php?action=activate&plugin=' . WPCF7S_REQ_PLUGIN ), 'activate-plugin_' . WPCF7S_REQ_PLUGIN )).'">Contact form 7</a>.';
61
- $html .= '</p>';
62
- $html .= '</div><!-- /.updated -->';
63
- echo $html;
64
- } else {
65
- // Get the cf7_style_cookie
66
- $cf7_style_cookie = get_option( 'cf7_style_cookie' );
67
- if( $cf7_style_cookie != true ) {
68
-
69
- $html = '<div class="updated">';
70
- $html .= '<p>';
71
- $html .= __( "Contact Form 7 - Style addon is now activated. Navigate to", "contact-form-7-style" ).' <a href="' . get_bloginfo( "url" ) . '/wp-admin/edit.php?post_type=cf7_style">'.__( "Contact Style", "contact-form-7-style" ).'</a> '.__( "to get started.", "contact-form-7-style" );
72
- $html .= '</p>';
73
- $html .= '</div><!-- /.updated -->';
74
- echo $html;
75
- update_option( 'cf7_style_cookie', true );
76
- } // end if !$cf7_style_cookie
77
- $cf7_style_templates = get_option( 'cf7_style_no_temps' );
78
- if($cf7_style_templates != "hide_box"){
79
- $box = '<div class="updated template-message-box">';
80
- $box .= '<p><label><input type="checkbox" name="custom_template_check" />'.__( "Click here, if you want to delete ALL predefined Contact Form 7 Style templates.", "contact-form-7-style" ).'</label></p>';
81
- $box .= '<p><small>'.__( "This works only if the predefined templates are not in the", "contact-form-7-style" ).' <a href="'.admin_url('edit.php?post_status=trash&post_type=cf7_style').'">'.__( "Trash", "contact-form-7-style" ).'</a>.</small></p>';
82
- $box .= '<div class="double-check hidden">';
83
- $box .= '<label>'.__( "Are you sure you want to remove? ", "contact-form-7-style" );
84
- $box .= '<br/><span>( '.__( "All Contact Form 7 Style predefined templates attached to your Contact Form 7 form will be removed", "contact-form-7-style" ).' ) &nbsp;&nbsp;</span>';
85
- $box .= '<span> '.__( "Yes", "contact-form-7-style" ).'</span><input type="radio" name="double_check_template" value="yes" />';
86
- $box .= '</label><label>';
87
- $box .= '<span> '.__( "No", "contact-form-7-style" ).'</span><input type="radio" name="double_check_template" value="no" checked="checked" /></label>';
88
- $box .= '<a href="#" class="confirm-remove-template button"> '.__( "Confirm", "contact-form-7-style" ).'</a>';
89
- $box .= '</div><a href="#" class="remove_template_notice">'.__( "Dismiss", "contact-form-7-style" ).'</a>';
90
- $box .= '<div style="clear:both;"></div>';
91
- $box .= '</div>';
92
- $screen = get_current_screen();
93
- if( !empty($screen) && ($screen->id == 'edit-cf7_style' || $screen->id == 'cf7_style') ){
94
- echo $box;
95
- }
96
- }
97
- }
98
- } // end if $active_plugins
99
- }
100
- function cf7_style_activator(){
101
-
102
- deactivate_contact_form_7_designer_plugin();
103
-
104
- add_action( 'admin_notices', 'contact_form_7_check' );
105
-
106
- if(!cf7_style_rq_plugin()) {
107
-
108
- deactivate_plugins( plugin_basename( WPCF7S_PLUGIN ) );
109
-
110
- if ( isset( $_GET['activate'] ) ) {
111
- unset( $_GET['activate'] );
112
- }
113
- }
114
-
115
- }
116
  add_action( 'admin_init', 'cf7_style_activator' );
1
+ <?php
2
+
3
+ if ( !defined( 'ABSPATH' ) ) {
4
+ exit;
5
+ }
6
+
7
+ /*
8
+ * notice for the user
9
+ */
10
+ function cf7_designer_deactivation_notice() { ?>
11
+ <div class="error">
12
+ <p><?php _e( "You cannot activate CF7 Designer while CF7 Style is activated!", "contact-form-7-style" ) ?></p>
13
+ </div>
14
+ <?php }
15
+
16
+ /*
17
+ * Function created for deactivated Contact Form 7 Designer plugin.
18
+ * This is because styles of that plugin is in conflict with ours.
19
+ * No one should add an id in the html tag.
20
+ */
21
+
22
+ function deactivate_contact_form_7_designer_plugin() {
23
+ if ( is_plugin_active('contact-form-7-designer/cf7-styles.php') ) {
24
+ deactivate_plugins('contact-form-7-designer/cf7-styles.php');
25
+ add_action( 'admin_notices', 'cf7_designer_deactivation_notice' );
26
+ }
27
+ }
28
+
29
+ function cf7_style_rq_plugin($req=false) {
30
+
31
+ $all_plugins = get_plugins();
32
+
33
+ if( $req == true && array_key_exists( WPCF7S_REQ_PLUGIN, $all_plugins)) return true;
34
+ if(!$req) {
35
+ $active_plugins = get_option( 'active_plugins' );
36
+ if( is_multisite() ) {
37
+ $active_plugins = array_merge($active_plugins, array_keys(get_site_option( 'active_sitewide_plugins')));
38
+ }
39
+ if(in_array( WPCF7S_REQ_PLUGIN, $active_plugins )) return true;
40
+ }
41
+ return false;
42
+ }
43
+
44
+ /**
45
+ * Check if Contact Form 7 is activated
46
+ */
47
+ function contact_form_7_check() {
48
+
49
+ if(!cf7_style_rq_plugin(true)){
50
+ $html = '<div class="error">';
51
+ $html .= '<p>';
52
+ $html .= __( "Contact form 7 - Style is an addon. Please install", "contact-form-7-style" ).' <a href="'.esc_url(admin_url('plugin-install.php?s=contact+form+7&tab=search&type=term' )).'">Contact form 7</a>.';
53
+ $html .= '</p>';
54
+ $html .= '</div><!-- /.updated -->';
55
+ echo $html;
56
+ } else {
57
+ if ( !cf7_style_rq_plugin()) {
58
+ $html = '<div class="error">';
59
+ $html .= '<p>';
60
+ $html .= __( "Contact form 7 - Style is an addon. Please activate", "contact-form-7-style" ).' <a href="'.esc_url(wp_nonce_url(admin_url('plugins.php?action=activate&plugin=' . WPCF7S_REQ_PLUGIN ), 'activate-plugin_' . WPCF7S_REQ_PLUGIN )).'">Contact form 7</a>.';
61
+ $html .= '</p>';
62
+ $html .= '</div><!-- /.updated -->';
63
+ echo $html;
64
+ } else {
65
+ // Get the cf7_style_cookie
66
+ $cf7_style_cookie = get_option( 'cf7_style_cookie' );
67
+ if( $cf7_style_cookie != true ) {
68
+
69
+ $html = '<div class="updated">';
70
+ $html .= '<p>';
71
+ $html .= __( "Contact Form 7 - Style addon is now activated. Navigate to", "contact-form-7-style" ).' <a href="' . get_bloginfo( "url" ) . '/wp-admin/edit.php?post_type=cf7_style">'.__( "Contact Style", "contact-form-7-style" ).'</a> '.__( "to get started.", "contact-form-7-style" );
72
+ $html .= '</p>';
73
+ $html .= '</div><!-- /.updated -->';
74
+ echo $html;
75
+ update_option( 'cf7_style_cookie', true );
76
+ } // end if !$cf7_style_cookie
77
+ $cf7_style_templates = get_option( 'cf7_style_no_temps' );
78
+ if($cf7_style_templates != "hide_box"){
79
+ $box = '<div class="updated template-message-box">';
80
+ $box .= '<p><label><input type="checkbox" name="custom_template_check" />'.__( "Click here, if you want to delete ALL predefined Contact Form 7 Style templates.", "contact-form-7-style" ).'</label></p>';
81
+ $box .= '<p><small>'.__( "This works only if the predefined templates are not in the", "contact-form-7-style" ).' <a href="'.admin_url('edit.php?post_status=trash&post_type=cf7_style').'">'.__( "Trash", "contact-form-7-style" ).'</a>.</small></p>';
82
+ $box .= '<div class="double-check hidden">';
83
+ $box .= '<label>'.__( "Are you sure you want to remove? ", "contact-form-7-style" );
84
+ $box .= '<br/><span>( '.__( "All Contact Form 7 Style predefined templates attached to your Contact Form 7 form will be removed", "contact-form-7-style" ).' ) &nbsp;&nbsp;</span>';
85
+ $box .= '<span> '.__( "Yes", "contact-form-7-style" ).'</span><input type="radio" name="double_check_template" value="yes" />';
86
+ $box .= '</label><label>';
87
+ $box .= '<span> '.__( "No", "contact-form-7-style" ).'</span><input type="radio" name="double_check_template" value="no" checked="checked" /></label>';
88
+ $box .= '<a href="#" class="confirm-remove-template button"> '.__( "Confirm", "contact-form-7-style" ).'</a>';
89
+ $box .= '</div><a href="#" class="remove_template_notice">'.__( "Dismiss", "contact-form-7-style" ).'</a>';
90
+ $box .= '<div style="clear:both;"></div>';
91
+ $box .= '</div>';
92
+ $screen = get_current_screen();
93
+ if( !empty($screen) && ($screen->id == 'edit-cf7_style' || $screen->id == 'cf7_style') ){
94
+ echo $box;
95
+ }
96
+ }
97
+ }
98
+ } // end if $active_plugins
99
+ }
100
+ function cf7_style_activator(){
101
+
102
+ deactivate_contact_form_7_designer_plugin();
103
+
104
+ add_action( 'admin_notices', 'contact_form_7_check' );
105
+
106
+ if(!cf7_style_rq_plugin()) {
107
+
108
+ deactivate_plugins( plugin_basename( WPCF7S_PLUGIN ) );
109
+
110
+ if ( isset( $_GET['activate'] ) ) {
111
+ unset( $_GET['activate'] );
112
+ }
113
+ }
114
+
115
+ }
116
  add_action( 'admin_init', 'cf7_style_activator' );
inc/adminbar_add_link.php CHANGED
@@ -1,24 +1,24 @@
1
- <?php
2
-
3
- if ( !defined( 'ABSPATH' ) ) {
4
- exit;
5
- }
6
-
7
- function cf7style_toolbar_link($wp_admin_bar) {
8
- $render_cfs_bar = get_option( 'cf7_style_adminbar');
9
- if( $render_cfs_bar == '1' ){
10
- $args = array(
11
- 'id' => 'cf7-style',
12
- 'title' => 'Contact Form 7 Style',
13
- 'href' => admin_url("edit.php?post_type=cf7_style"),
14
- 'meta' => array(
15
- 'class' => 'contact-style',
16
- 'title' => 'Contact Form 7 Style',
17
- 'html' => '<span class="admin-style-icon"><i class="dashicons-before dashicons-twitter" aria-hidden="true"></i></span>'
18
- )
19
- );
20
- $wp_admin_bar->add_node($args);
21
- }
22
- }
23
-
24
  add_action('admin_bar_menu', 'cf7style_toolbar_link', 999);
1
+ <?php
2
+
3
+ if ( !defined( 'ABSPATH' ) ) {
4
+ exit;
5
+ }
6
+
7
+ function cf7style_toolbar_link($wp_admin_bar) {
8
+ $render_cfs_bar = get_option( 'cf7_style_adminbar');
9
+ if( $render_cfs_bar == '1' ){
10
+ $args = array(
11
+ 'id' => 'cf7-style',
12
+ 'title' => 'Contact Form 7 Style',
13
+ 'href' => admin_url("edit.php?post_type=cf7_style"),
14
+ 'meta' => array(
15
+ 'class' => 'contact-style',
16
+ 'title' => 'Contact Form 7 Style',
17
+ 'html' => '<span class="admin-style-icon"><i class="dashicons-before dashicons-twitter" aria-hidden="true"></i></span>'
18
+ )
19
+ );
20
+ $wp_admin_bar->add_node($args);
21
+ }
22
+ }
23
+
24
  add_action('admin_bar_menu', 'cf7style_toolbar_link', 999);
inc/cf7_add_form_class.php CHANGED
@@ -1,44 +1,44 @@
1
- <?php
2
-
3
- /**
4
- * Add cf7skins classes to the CF7 HTML form class
5
- *
6
- * Based on selected template & style
7
- * eg. class="wpcf7-form cf7t-fieldset cf7s-wild-west"
8
- *
9
- * @uses 'wpcf7_form_class_attr' filter in WPCF7_ContactForm->form_html()
10
- * @uses wpcf7_get_current_contact_form()
11
- * @file wp-content\plugins\contact-form-7\includes\contact-form.php
12
- *
13
- * @param $class is the CF7 HTML form class
14
- * @since 0.0.1
15
- */
16
-
17
- if ( !defined( 'ABSPATH' ) ) {
18
- exit;
19
- }
20
-
21
- function form_class_attr( $class, $id ) {
22
-
23
- // Get the current CF7 form ID
24
- $cf7 = wpcf7_get_current_contact_form(); // Current contact form 7 object
25
- $form_id = get_form_id( $cf7 );
26
- $template_class ='';
27
- $cf7_style_id = get_post_meta( $form_id, 'cf7_style_id' );
28
- if ( isset( $cf7_style_id[0] ) ) {
29
- $cf7_style_data = get_post( $cf7_style_id[0], OBJECT );
30
- $template_class = ( has_term( 'custom-style', 'style_category', $cf7_style_data ) ) ?
31
- "cf7-style-" . $cf7_style_id[0] : $cf7_style_data->post_name;
32
- }
33
-
34
- // Return the modified class
35
- return $template_class;
36
- }
37
-
38
- function cf7_style_add_class( $class ){
39
- global $post;
40
- $class.= " cf7-style ".form_class_attr( $post, "no" );
41
- return $class;
42
- }// end of cf7_style_add_class
43
-
44
  add_filter( 'wpcf7_form_class_attr', 'cf7_style_add_class' );
1
+ <?php
2
+
3
+ /**
4
+ * Add cf7skins classes to the CF7 HTML form class
5
+ *
6
+ * Based on selected template & style
7
+ * eg. class="wpcf7-form cf7t-fieldset cf7s-wild-west"
8
+ *
9
+ * @uses 'wpcf7_form_class_attr' filter in WPCF7_ContactForm->form_html()
10
+ * @uses wpcf7_get_current_contact_form()
11
+ * @file wp-content\plugins\contact-form-7\includes\contact-form.php
12
+ *
13
+ * @param $class is the CF7 HTML form class
14
+ * @since 0.0.1
15
+ */
16
+
17
+ if ( !defined( 'ABSPATH' ) ) {
18
+ exit;
19
+ }
20
+
21
+ function form_class_attr( $class, $id ) {
22
+
23
+ // Get the current CF7 form ID
24
+ $cf7 = wpcf7_get_current_contact_form(); // Current contact form 7 object
25
+ $form_id = get_form_id( $cf7 );
26
+ $template_class ='';
27
+ $cf7_style_id = get_post_meta( $form_id, 'cf7_style_id' );
28
+ if ( isset( $cf7_style_id[0] ) ) {
29
+ $cf7_style_data = get_post( $cf7_style_id[0], OBJECT );
30
+ $template_class = ( has_term( 'custom-style', 'style_category', $cf7_style_data ) ) ?
31
+ "cf7-style-" . $cf7_style_id[0] : $cf7_style_data->post_name;
32
+ }
33
+
34
+ // Return the modified class
35
+ return $template_class;
36
+ }
37
+
38
+ function cf7_style_add_class( $class ){
39
+ global $post;
40
+ $class.= " cf7-style ".form_class_attr( $post, "no" );
41
+ return $class;
42
+ }// end of cf7_style_add_class
43
+
44
  add_filter( 'wpcf7_form_class_attr', 'cf7_style_add_class' );
inc/check_cfstyle_version.php CHANGED
@@ -1,23 +1,23 @@
1
- <?php
2
-
3
- if ( !defined( 'ABSPATH' ) ) {
4
- exit;
5
- }
6
-
7
- function cf7_style_create_posts(){
8
- update_option( 'cf7_style_no_temps', 'show_box' );
9
- update_option( 'cf7_style_welcome', 'show_box' );
10
- update_option( 'cf7_style_update_saved', 'yes' );
11
- update_option( 'cf7_style_allow_tracking', '5' );
12
- update_option( 'cf7_style_add_categories', '0' );
13
- update_option( 'cf7_style_adminbar', '1' );
14
- }
15
-
16
- function cf7style_update_db_check() {
17
- if (get_option( 'cf7_style_plugin_version' ) != WPCF7S_PLUGIN_VER) {
18
- cf7_style_create_posts();
19
- update_option( 'cf7_style_plugin_version', WPCF7S_PLUGIN_VER );
20
- }
21
- }
22
-
23
  add_action( 'plugins_loaded', 'cf7style_update_db_check' );
1
+ <?php
2
+
3
+ if ( !defined( 'ABSPATH' ) ) {
4
+ exit;
5
+ }
6
+
7
+ function cf7_style_create_posts(){
8
+ update_option( 'cf7_style_no_temps', 'show_box' );
9
+ update_option( 'cf7_style_welcome', 'show_box' );
10
+ update_option( 'cf7_style_update_saved', 'yes' );
11
+ update_option( 'cf7_style_allow_tracking', '5' );
12
+ update_option( 'cf7_style_add_categories', '0' );
13
+ update_option( 'cf7_style_adminbar', '1' );
14
+ }
15
+
16
+ function cf7style_update_db_check() {
17
+ if (get_option( 'cf7_style_plugin_version' ) != WPCF7S_PLUGIN_VER) {
18
+ cf7_style_create_posts();
19
+ update_option( 'cf7_style_plugin_version', WPCF7S_PLUGIN_VER );
20
+ }
21
+ }
22
+
23
  add_action( 'plugins_loaded', 'cf7style_update_db_check' );
inc/check_deleted_templates.php CHANGED
@@ -1,32 +1,32 @@
1
- <?php
2
-
3
- if ( !defined( 'ABSPATH' ) ) {
4
- exit;
5
- }
6
-
7
- function cf7style_check_deleted( $postid ){
8
- global $post_type;
9
- if ( $post_type != 'cf7_style' ) return;
10
- $check_deleted = get_option('cf7_style_deleted');
11
- $clr_form_args = array(
12
- 'post_type' => 'wpcf7_contact_form',
13
- 'posts_per_page' => -1,
14
- 'meta_key' => 'cf7_style_id',
15
- 'meta_value' => $postid
16
- );
17
- $form_query = new WP_Query( $clr_form_args );
18
- if ( $form_query->have_posts() ) {
19
- while ( $form_query->have_posts() ) {
20
- $form_query->the_post();
21
- /*form id*/
22
- update_post_meta( get_the_ID(), 'cf7_style_id', '');
23
- }
24
- wp_reset_postdata();
25
- }
26
- if("yes" != $check_deleted){
27
- update_option( 'cf7_style_no_temps', 'hide_box' );
28
- update_option('cf7_style_deleted','yes');
29
- }
30
- }
31
-
32
  add_action( 'before_delete_post', 'cf7style_check_deleted' );
1
+ <?php
2
+
3
+ if ( !defined( 'ABSPATH' ) ) {
4
+ exit;
5
+ }
6
+
7
+ function cf7style_check_deleted( $postid ){
8
+ global $post_type;
9
+ if ( $post_type != 'cf7_style' ) return;
10
+ $check_deleted = get_option('cf7_style_deleted');
11
+ $clr_form_args = array(
12
+ 'post_type' => 'wpcf7_contact_form',
13
+ 'posts_per_page' => -1,
14
+ 'meta_key' => 'cf7_style_id',
15
+ 'meta_value' => $postid
16
+ );
17
+ $form_query = new WP_Query( $clr_form_args );
18
+ if ( $form_query->have_posts() ) {
19
+ while ( $form_query->have_posts() ) {
20
+ $form_query->the_post();
21
+ /*form id*/
22
+ update_post_meta( get_the_ID(), 'cf7_style_id', '');
23
+ }
24
+ wp_reset_postdata();
25
+ }
26
+ if("yes" != $check_deleted){
27
+ update_option( 'cf7_style_no_temps', 'hide_box' );
28
+ update_option('cf7_style_deleted','yes');
29
+ }
30
+ }
31
+
32
  add_action( 'before_delete_post', 'cf7style_check_deleted' );
inc/custom_css_generator.php CHANGED
@@ -1,178 +1,178 @@
1
- <?php
2
-
3
- if ( !defined( 'ABSPATH' ) ) {
4
- exit;
5
- }
6
-
7
- function generate_row($f_keypart, $s_keypart, $temp_element, $setting_key, $setting, $cf7s_custom_settings, $css_base, $type, $cf7s_force_css){
8
- $unit = '';
9
- $innerstyle = '';
10
- $kkey = ( $type == ":hover") ? '_hover' : '';
11
- if( $temp_element != $f_keypart ){
12
- $temp_element = $f_keypart;
13
- $type_s = ( strpos($setting_key,'placeholder') === false ) ? $type : '';
14
- $innerstyle .= $css_base.$type_s.' {';
15
- }
16
- if( strpos($setting_key,'_unit') === false){
17
- $unitkey = ( $type == ":hover") ? $f_keypart.'_'.$s_keypart.'_unit'.$kkey : $setting_key.'_unit';
18
-
19
- $unit = ( array_key_exists( $unitkey ,$cf7s_custom_settings)) ? $cf7s_custom_settings[$unitkey] : '';
20
-
21
- $setting = ( strpos($s_keypart,'background-image') === false ) ? $setting : 'url("'.$setting.'")';
22
-
23
- $innerstyle .= $s_keypart.": ".$setting.$unit.$cf7s_force_css. ";";
24
- }
25
-
26
- return array(
27
- 'temp' => $temp_element,
28
- 'style' => $innerstyle);
29
- }
30
-
31
- function generate_css_code($style, $cf7s_custom_settings, $classelem, $cf7s_force_css, $type, $placenot ) {
32
-
33
- $result = array();
34
- $temp_element = '';
35
-
36
- reset($cf7s_custom_settings);
37
- $first_setting_key = key($cf7s_custom_settings);
38
-
39
- /* get last key of custom style settings array */
40
- end($cf7s_custom_settings);
41
- $last_setting_key = key($cf7s_custom_settings);
42
-
43
- foreach( $cf7s_custom_settings as $setting_key => $setting ){
44
-
45
- $endtag = ( $first_setting_key == $setting_key ) ? "" : "}";
46
-
47
- $setting_key_part = explode( "_", $setting_key );
48
-
49
- $html_element = ( $setting_key_part[0] == "submit" || $setting_key_part[0] == "radio" || $setting_key_part[0] == "checkbox" ) ?
50
- " input[type='". $setting_key_part[0]."']" : ( ( $setting_key_part[0] == "form" ) ? "" : (( $setting_key_part[0] == "wpcf7-not-valid-tip" || $setting_key_part[0] == "wpcf7-validation-errors" || $setting_key_part[0] == "wpcf7-mail-sent-ok" ) ?
51
- " .". $setting_key_part[0] : ' '.$setting_key_part[0]) );
52
-
53
- $html_element = ( $placenot == '' ) ? $html_element : ' '.$placenot;
54
-
55
- $css_base = $endtag.$classelem.$html_element;
56
-
57
- $result = generate_row($setting_key_part[0], $setting_key_part[1], $temp_element, $setting_key, $setting, $cf7s_custom_settings, $css_base, $type, $cf7s_force_css);
58
- $temp_element = $result['temp'];
59
- $style .= $result['style'];
60
-
61
- if( $last_setting_key == $setting_key ){
62
- $style .= '}';
63
- }
64
- }/*foreach end*/
65
- return $style;
66
- }
67
-
68
- function cf7_style_custom_css_generator(){
69
- global $post;
70
- if( empty( $post ) ) {
71
- return false;
72
- }
73
- $args = array(
74
- 'post_type' => 'wpcf7_contact_form',
75
- 'post_status' => 'publish',
76
- 'posts_per_page' => -1
77
- );
78
-
79
- $placeholder_fallback = array('::-webkit-input-placeholder','::-moz-placeholder',':-ms-input-placeholder',':-moz-placeholder');
80
- $placeholder_hover_fallback = array('[placeholder]:hover::-webkit-input-placeholder','[placeholder]:hover::-moz-placeholder','[placeholder]:hover:-ms-input-placeholder','[placeholder]:hover:-moz-placeholder');
81
-
82
- $forms = new WP_Query( $args );
83
- //$total_num_posts = $forms->found_posts;
84
- $style = "";
85
- $cf7s_manual_style = html_entity_decode( stripslashes(get_option( 'cf7_style_manual_style', true )),ENT_QUOTES );
86
- $cf7s_manual_style = ( $cf7s_manual_style == '1' ) ? "" : $cf7s_manual_style;
87
- $cf7s_force_css = get_option( 'cf7_style_forcecss', true );
88
-
89
- $cf7s_force_css = ('1' === $cf7s_force_css ) ? " !important" : "";
90
- $active_styles = array();
91
- $style_number = 0;
92
- if( $forms->have_posts() ) :
93
- while( $forms->have_posts() ) : $forms->the_post();
94
- $id = get_the_ID();
95
- $cf7s_id = get_post_meta( $id, 'cf7_style_id', true );
96
- $form_title = get_the_title($cf7s_id);
97
- if ( ( ! empty( $cf7s_id ) || $cf7s_id !== 0 ) && ! in_array( $cf7s_id, $active_styles ) ) {
98
- array_push( $active_styles, $cf7s_id );
99
- $cf7_style_data = get_post( $cf7s_id, OBJECT );
100
- $check_custom_style = has_term( 'custom-style', 'style_category', $cf7_style_data );
101
- /*Check if custom style or template*/
102
- $cf7s_slug = ( $check_custom_style ) ? $cf7s_id : sanitize_title( $form_title);
103
- /*check if custom again*/
104
- if( $check_custom_style ){
105
-
106
- $cf7s_custom_settings = maybe_unserialize( get_post_meta( $cf7s_id, 'cf7_style_custom_styler', true ));
107
- $cf7s_custom_settings = ( empty($cf7s_custom_settings) ) ? array() : $cf7s_custom_settings;
108
-
109
- $classelem = "body .cf7-style." . ( ( is_numeric( $cf7s_slug ) ) ? "cf7-style-".$cf7s_slug : $cf7s_slug );
110
-
111
- $normal_arr = array();
112
- $hover_arr = array();
113
-
114
- $placeholder_arr = array();
115
- $placeholder_hover_arr = array();
116
-
117
- foreach( $cf7s_custom_settings as $setting_key => $setting ){
118
- if( strpos($setting_key,'_hover') === false ){
119
- if( strpos($setting_key,'placeholder') !== false ){
120
- $placeholder_arr[$setting_key] = $setting;
121
- } else {
122
- $normal_arr[$setting_key] = $setting;
123
- }
124
- } else {
125
-
126
- if( strpos($setting_key,'placeholder') !== false ){
127
- $placeholder_hover_arr[$setting_key] = $setting;
128
- } else {
129
- $hover_arr[$setting_key] = $setting;
130
- }
131
- }
132
- }
133
-
134
- $style .= generate_css_code( (( $style_number == 0) ? $style : ''), $normal_arr, $classelem, $cf7s_force_css, '', '' );
135
- $style .= generate_css_code( '', $hover_arr, $classelem, $cf7s_force_css, ':hover', '' );
136
-
137
- if( !empty($placeholder_arr) ){
138
- foreach ($placeholder_fallback as $placeh) {
139
- $style .= generate_css_code( '', $placeholder_arr, $classelem, $cf7s_force_css, '', $placeh);
140
- }
141
- }
142
-
143
- if( !empty($placeholder_hover_arr) ){
144
- foreach ($placeholder_hover_fallback as $placeh) {
145
- $style .= generate_css_code( '', $placeholder_hover_arr, $classelem, $cf7s_force_css, ':hover', $placeh);
146
- }
147
- }
148
-
149
- }/*custom end*/
150
-
151
- $font_family = return_font_name( $cf7s_id );
152
-
153
- if( ! empty( $font_family ) && "none" !== $font_family ) {
154
- if (is_numeric($cf7s_slug)) {
155
- $cf7s_slug = "cf7-style-".$cf7s_slug;
156
- }
157
- $style .= 'body .cf7-style.' . $cf7s_slug . ",body .cf7-style." . $cf7s_slug . " input[type='submit'] {font-family: '" . $font_family . "',sans-serif;} ";
158
- }
159
- $style_number++;
160
- }/*Main if ends here*/
161
- endwhile;
162
- $style_manual = "";
163
- $style_start = "\n<style class='cf7-style' media='screen' type='text/css'>\n";
164
- if( !empty( $cf7s_manual_style ) ){
165
- $style_manual = "\n".$cf7s_manual_style."\n";
166
- }
167
- $cur_css = $style_start;
168
- $cur_css .= $style;
169
- $cur_css .= $style_manual;
170
- if( ( $style_number !== 0 ) && $style_number == count( $active_styles ) ) {
171
- $cur_css .= "\n</style>\n";
172
- }
173
- $cur_css = str_replace(' 0px;', ' 0;', $cur_css);
174
-
175
- echo $cur_css;
176
- wp_reset_postdata();
177
- endif;
178
  }// end of cf7_style_custom_css_generator
1
+ <?php
2
+
3
+ if ( !defined( 'ABSPATH' ) ) {
4
+ exit;
5
+ }
6
+
7
+ function generate_row($f_keypart, $s_keypart, $temp_element, $setting_key, $setting, $cf7s_custom_settings, $css_base, $type, $cf7s_force_css){
8
+ $unit = '';
9
+ $innerstyle = '';
10
+ $kkey = ( $type == ":hover") ? '_hover' : '';
11
+ if( $temp_element != $f_keypart ){
12
+ $temp_element = $f_keypart;
13
+ $type_s = ( strpos($setting_key,'placeholder') === false ) ? $type : '';
14
+ $innerstyle .= $css_base.$type_s.' {';
15
+ }
16
+ if( strpos($setting_key,'_unit') === false){
17
+ $unitkey = ( $type == ":hover") ? $f_keypart.'_'.$s_keypart.'_unit'.$kkey : $setting_key.'_unit';
18
+
19
+ $unit = ( array_key_exists( $unitkey ,$cf7s_custom_settings)) ? $cf7s_custom_settings[$unitkey] : '';
20
+
21
+ $setting = ( strpos($s_keypart,'background-image') === false ) ? $setting : 'url("'.$setting.'")';
22
+
23
+ $innerstyle .= $s_keypart.": ".$setting.$unit.$cf7s_force_css. ";";
24
+ }
25
+
26
+ return array(
27
+ 'temp' => $temp_element,
28
+ 'style' => $innerstyle);
29
+ }
30
+
31
+ function generate_css_code($style, $cf7s_custom_settings, $classelem, $cf7s_force_css, $type, $placenot ) {
32
+
33
+ $result = array();
34
+ $temp_element = '';
35
+
36
+ reset($cf7s_custom_settings);
37
+ $first_setting_key = key($cf7s_custom_settings);
38
+
39
+ /* get last key of custom style settings array */
40
+ end($cf7s_custom_settings);
41
+ $last_setting_key = key($cf7s_custom_settings);
42
+
43
+ foreach( $cf7s_custom_settings as $setting_key => $setting ){
44
+
45
+ $endtag = ( $first_setting_key == $setting_key ) ? "" : "}";
46
+
47
+ $setting_key_part = explode( "_", $setting_key );
48
+
49
+ $html_element = ( $setting_key_part[0] == "submit" || $setting_key_part[0] == "radio" || $setting_key_part[0] == "checkbox" ) ?
50
+ " input[type='". $setting_key_part[0]."']" : ( ( $setting_key_part[0] == "form" ) ? "" : (( $setting_key_part[0] == "wpcf7-not-valid-tip" || $setting_key_part[0] == "wpcf7-validation-errors" || $setting_key_part[0] == "wpcf7-mail-sent-ok" ) ?
51
+ " .". $setting_key_part[0] : ' '.$setting_key_part[0]) );
52
+
53
+ $html_element = ( $placenot == '' ) ? $html_element : ' '.$placenot;
54
+
55
+ $css_base = $endtag.$classelem.$html_element;
56
+
57
+ $result = generate_row($setting_key_part[0], $setting_key_part[1], $temp_element, $setting_key, $setting, $cf7s_custom_settings, $css_base, $type, $cf7s_force_css);
58
+ $temp_element = $result['temp'];
59
+ $style .= $result['style'];
60
+
61
+ if( $last_setting_key == $setting_key ){
62
+ $style .= '}';
63
+ }
64
+ }/*foreach end*/
65
+ return $style;
66
+ }
67
+
68
+ function cf7_style_custom_css_generator(){
69
+ global $post;
70
+ if( empty( $post ) ) {
71
+ return false;
72
+ }
73
+ $args = array(
74
+ 'post_type' => 'wpcf7_contact_form',
75
+ 'post_status' => 'publish',
76
+ 'posts_per_page' => -1
77
+ );
78
+
79
+ $placeholder_fallback = array('::-webkit-input-placeholder','::-moz-placeholder',':-ms-input-placeholder',':-moz-placeholder');
80
+ $placeholder_hover_fallback = array('[placeholder]:hover::-webkit-input-placeholder','[placeholder]:hover::-moz-placeholder','[placeholder]:hover:-ms-input-placeholder','[placeholder]:hover:-moz-placeholder');
81
+
82
+ $forms = new WP_Query( $args );
83
+ //$total_num_posts = $forms->found_posts;
84
+ $style = "";
85
+ $cf7s_manual_style = html_entity_decode( stripslashes(get_option( 'cf7_style_manual_style', true )),ENT_QUOTES );
86
+ $cf7s_manual_style = ( $cf7s_manual_style == '1' ) ? "" : $cf7s_manual_style;
87
+ $cf7s_force_css = get_option( 'cf7_style_forcecss', true );
88
+
89
+ $cf7s_force_css = ('1' === $cf7s_force_css ) ? " !important" : "";
90
+ $active_styles = array();
91
+ $style_number = 0;
92
+ if( $forms->have_posts() ) :
93
+ while( $forms->have_posts() ) : $forms->the_post();
94
+ $id = get_the_ID();
95
+ $cf7s_id = get_post_meta( $id, 'cf7_style_id', true );
96
+ $form_title = get_the_title($cf7s_id);
97
+ if ( ( ! empty( $cf7s_id ) || $cf7s_id !== 0 ) && ! in_array( $cf7s_id, $active_styles ) ) {
98
+ array_push( $active_styles, $cf7s_id );
99
+ $cf7_style_data = get_post( $cf7s_id, OBJECT );
100
+ $check_custom_style = has_term( 'custom-style', 'style_category', $cf7_style_data );
101
+ /*Check if custom style or template*/
102
+ $cf7s_slug = ( $check_custom_style ) ? $cf7s_id : sanitize_title( $form_title);
103
+ /*check if custom again*/
104
+ if( $check_custom_style ){
105
+
106
+ $cf7s_custom_settings = maybe_unserialize( get_post_meta( $cf7s_id, 'cf7_style_custom_styler', true ));
107
+ $cf7s_custom_settings = ( empty($cf7s_custom_settings) ) ? array() : $cf7s_custom_settings;
108
+
109
+ $classelem = "body .cf7-style." . ( ( is_numeric( $cf7s_slug ) ) ? "cf7-style-".$cf7s_slug : $cf7s_slug );
110
+
111
+ $normal_arr = array();
112
+ $hover_arr = array();
113
+
114
+ $placeholder_arr = array();
115
+ $placeholder_hover_arr = array();
116
+
117
+ foreach( $cf7s_custom_settings as $setting_key => $setting ){
118
+ if( strpos($setting_key,'_hover') === false ){
119
+ if( strpos($setting_key,'placeholder') !== false ){
120
+ $placeholder_arr[$setting_key] = $setting;
121
+ } else {
122
+ $normal_arr[$setting_key] = $setting;
123
+ }
124
+ } else {
125
+
126
+ if( strpos($setting_key,'placeholder') !== false ){
127
+ $placeholder_hover_arr[$setting_key] = $setting;
128
+ } else {
129
+ $hover_arr[$setting_key] = $setting;
130
+ }
131
+ }
132
+ }
133
+
134
+ $style .= generate_css_code( (( $style_number == 0) ? $style : ''), $normal_arr, $classelem, $cf7s_force_css, '', '' );
135
+ $style .= generate_css_code( '', $hover_arr, $classelem, $cf7s_force_css, ':hover', '' );
136
+
137
+ if( !empty($placeholder_arr) ){
138
+ foreach ($placeholder_fallback as $placeh) {
139
+ $style .= generate_css_code( '', $placeholder_arr, $classelem, $cf7s_force_css, '', $placeh);
140
+ }
141
+ }
142
+
143
+ if( !empty($placeholder_hover_arr) ){
144
+ foreach ($placeholder_hover_fallback as $placeh) {
145
+ $style .= generate_css_code( '', $placeholder_hover_arr, $classelem, $cf7s_force_css, ':hover', $placeh);
146
+ }
147
+ }
148
+
149
+ }/*custom end*/
150
+
151
+ $font_family = return_font_name( $cf7s_id );
152
+
153
+ if( ! empty( $font_family ) && "none" !== $font_family ) {
154
+ if (is_numeric($cf7s_slug)) {
155
+ $cf7s_slug = "cf7-style-".$cf7s_slug;
156
+ }
157
+ $style .= 'body .cf7-style.' . $cf7s_slug . ",body .cf7-style." . $cf7s_slug . " input[type='submit'] {font-family: '" . $font_family . "',sans-serif;} ";
158
+ }
159
+ $style_number++;
160
+ }/*Main if ends here*/
161
+ endwhile;
162
+ $style_manual = "";
163
+ $style_start = "\n<style class='cf7-style' media='screen' type='text/css'>\n";
164
+ if( !empty( $cf7s_manual_style ) ){
165
+ $style_manual = "\n".$cf7s_manual_style."\n";
166
+ }
167
+ $cur_css = $style_start;
168
+ $cur_css .= $style;
169
+ $cur_css .= $style_manual;
170
+ if( ( $style_number !== 0 ) && $style_number == count( $active_styles ) ) {
171
+ $cur_css .= "\n</style>\n";
172
+ }
173
+ $cur_css = str_replace(' 0px;', ' 0;', $cur_css);
174
+
175
+ echo $cur_css;
176
+ wp_reset_postdata();
177
+ endif;
178
  }// end of cf7_style_custom_css_generator
inc/dashboard_generate_preview.php CHANGED
@@ -1,16 +1,16 @@
1
- <?php
2
-
3
- if ( !defined( 'ABSPATH' ) ) {
4
- exit;
5
- }
6
-
7
- function cf7_style_generate_preview_dashboard() {
8
-
9
- $form_id = sanitize_text_field( $_POST['form_id'] );
10
- $form_title = sanitize_text_field( $_POST['form_title'] );
11
- $form = "<div class='multiple-form-generated-preview preview-form-container'><h4>" . $form_title . "</h4>" . do_shortcode( '[contact-form-7 id="'. $form_id .'" title="'. $form_title .'"]' ) . "</div>";
12
- echo $form;
13
-
14
- wp_die();
15
- }
16
  add_action( 'wp_ajax_cf7_style_generate_preview_dashboard', 'cf7_style_generate_preview_dashboard' );
1
+ <?php
2
+
3
+ if ( !defined( 'ABSPATH' ) ) {
4
+ exit;
5
+ }
6
+
7
+ function cf7_style_generate_preview_dashboard() {
8
+
9
+ $form_id = sanitize_text_field( $_POST['form_id'] );
10
+ $form_title = sanitize_text_field( $_POST['form_title'] );
11
+ $form = "<div class='multiple-form-generated-preview preview-form-container'><h4>" . $form_title . "</h4>" . do_shortcode( '[contact-form-7 id="'. $form_id .'" title="'. $form_title .'"]' ) . "</div>";
12
+ echo $form;
13
+
14
+ wp_die();
15
+ }
16
  add_action( 'wp_ajax_cf7_style_generate_preview_dashboard', 'cf7_style_generate_preview_dashboard' );
inc/dashboard_hide_delete_tpl_box.php CHANGED
@@ -1,12 +1,12 @@
1
- <?php
2
-
3
- if ( !defined( 'ABSPATH' ) ) {
4
- exit;
5
- }
6
-
7
- function cf7_style_remove_box() {
8
- global $wpdb;
9
- update_option( 'cf7_style_no_temps', 'hide_box' );
10
- wp_die();
11
- }
12
  add_action( 'wp_ajax_cf7_style_remove_box', 'cf7_style_remove_box' );
1
+ <?php
2
+
3
+ if ( !defined( 'ABSPATH' ) ) {
4
+ exit;
5
+ }
6
+
7
+ function cf7_style_remove_box() {
8
+ global $wpdb;
9
+ update_option( 'cf7_style_no_temps', 'hide_box' );
10
+ wp_die();
11
+ }
12
  add_action( 'wp_ajax_cf7_style_remove_box', 'cf7_style_remove_box' );
inc/dashboard_hide_welcome_box.php CHANGED
@@ -1,12 +1,12 @@
1
- <?php
2
-
3
- if ( !defined( 'ABSPATH' ) ) {
4
- exit;
5
- }
6
-
7
- function cf7_style_remove_welcome_box() {
8
- global $wpdb;
9
- update_option( 'cf7_style_welcome', 'hide_box' );
10
- wp_die();
11
- }
12
  add_action( 'wp_ajax_cf7_style_remove_welcome_box', 'cf7_style_remove_welcome_box' );
1
+ <?php
2
+
3
+ if ( !defined( 'ABSPATH' ) ) {
4
+ exit;
5
+ }
6
+
7
+ function cf7_style_remove_welcome_box() {
8
+ global $wpdb;
9
+ update_option( 'cf7_style_welcome', 'hide_box' );
10
+ wp_die();
11
+ }
12
  add_action( 'wp_ajax_cf7_style_remove_welcome_box', 'cf7_style_remove_welcome_box' );
inc/dashboard_load_custom_property.php CHANGED
@@ -1,44 +1,44 @@
1
- <?php
2
-
3
- if ( !defined( 'ABSPATH' ) ) {
4
- exit;
5
- }
6
-
7
- function cf7_style_load_property() {
8
-
9
- $form_property = sanitize_text_field( $_POST['property'] );
10
- $form_panel = "";
11
- $saved_values = maybe_unserialize(get_post_meta( $post->ID, 'cf7_style_custom_styler', true ));
12
- $saved_values = (empty($saved_values)) ? array() : $saved_values;
13
- require_once( WPCF7S_PLUGIN_DIR.'/plugin-options.php' );
14
- foreach( $elements as $property => $property_value ) {
15
- if( $property == $form_property ) {
16
- if( $property_value['description'] != ""){
17
- $form_panel .= '<h4 class="description-title">'.$property_value['description'].'</h4>';
18
- }
19
- foreach( $property_value['settings'] as $sub_property_key => $sub_property_value ) {
20
- $property = strtolower( $property );
21
- $sub_property_slug = strtolower( $options[$sub_property_value]['slug'] );
22
- $style_element_name = strtolower($options[$sub_property_value]['name']);
23
- $half_width_class = ( $style_element_name == "box sizing" || $style_element_name == "display" || $style_element_name == "position" || $style_element_name == "width" || $style_element_name == "height") ? "half-size" : "";
24
- $form_panel .= '<div class="element-styling '.$half_width_class.' '.$style_element_name.'"><h3><span>&lt;'.$property.'&gt;</span> '.$style_element_name . '</h3>';
25
- if( $options[$sub_property_value]['type'] ) {
26
- $form_panel .= "<ul>";
27
- foreach( $options[$sub_property_value]['type'] as $key => $value ) {
28
- if( $key != "comming-soon" ){
29
- $form_panel .= generate_property_fields( $key, $value, $property, $sub_property_slug, $saved_values, '');
30
- $form_panel .= generate_property_fields( $key, $value, $property, $sub_property_slug, $saved_values, '_hover');
31
- } else {
32
- $form_panel .= "<li></li>";
33
- }
34
- }
35
- $form_panel .= "</ul>";
36
- $form_panel .= "</div>";
37
- }
38
- }
39
- }
40
- }
41
- print_r($form_panel);
42
- wp_die();
43
- }
44
  add_action( 'wp_ajax_cf7_style_load_property', 'cf7_style_load_property' );
1
+ <?php
2
+
3
+ if ( !defined( 'ABSPATH' ) ) {
4
+ exit;
5
+ }
6
+
7
+ function cf7_style_load_property() {
8
+
9
+ $form_property = sanitize_text_field( $_POST['property'] );
10
+ $form_panel = "";
11
+ $saved_values = maybe_unserialize(get_post_meta( $post->ID, 'cf7_style_custom_styler', true ));
12
+ $saved_values = (empty($saved_values)) ? array() : $saved_values;
13
+ require_once( WPCF7S_PLUGIN_DIR.'/plugin-options.php' );
14
+ foreach( $elements as $property => $property_value ) {
15
+ if( $property == $form_property ) {
16
+ if( $property_value['description'] != ""){
17
+ $form_panel .= '<h4 class="description-title">'.$property_value['description'].'</h4>';
18
+ }
19
+ foreach( $property_value['settings'] as $sub_property_key => $sub_property_value ) {
20
+ $property = strtolower( $property );
21
+ $sub_property_slug = strtolower( $options[$sub_property_value]['slug'] );
22
+ $style_element_name = strtolower($options[$sub_property_value]['name']);
23
+ $half_width_class = ( $style_element_name == "box sizing" || $style_element_name == "display" || $style_element_name == "position" || $style_element_name == "width" || $style_element_name == "height") ? "half-size" : "";
24
+ $form_panel .= '<div class="element-styling '.$half_width_class.' '.$style_element_name.'"><h3><span>&lt;'.$property.'&gt;</span> '.$style_element_name . '</h3>';
25
+ if( $options[$sub_property_value]['type'] ) {
26
+ $form_panel .= "<ul>";
27
+ foreach( $options[$sub_property_value]['type'] as $key => $value ) {
28
+ if( $key != "comming-soon" ){
29
+ $form_panel .= generate_property_fields( $key, $value, $property, $sub_property_slug, $saved_values, '');
30
+ $form_panel .= generate_property_fields( $key, $value, $property, $sub_property_slug, $saved_values, '_hover');
31
+ } else {
32
+ $form_panel .= "<li></li>";
33
+ }
34
+ }
35
+ $form_panel .= "</ul>";
36
+ $form_panel .= "</div>";
37
+ }
38
+ }
39
+ }
40
+ }
41
+ print_r($form_panel);
42
+ wp_die();
43
+ }
44
  add_action( 'wp_ajax_cf7_style_load_property', 'cf7_style_load_property' );
inc/dashboard_table_add_preview.php CHANGED
@@ -1,27 +1,27 @@
1
- <?php
2
-
3
- if ( !defined( 'ABSPATH' ) ) {
4
- exit;
5
- }
6
-
7
- function cf7_style_event_table_head( $defaults ) {
8
- $new = array();
9
- foreach( $defaults as $key=>$value) {
10
- if( $key=='title') { // when we find the date column
11
- $new['preview-style'] = 'Preview Style';
12
- }
13
- $new[$key]=$value;
14
- }
15
- return $new;
16
- }
17
-
18
- function cf7_style_event_table_content( $column_name, $post_id ) {
19
- // cf7_style_image_preview
20
- if ( $column_name == 'preview-style' ) {
21
- $img_src = get_post_meta( $post_id, 'cf7_style_image_preview', true );
22
- echo "<a href='".admin_url() ."post.php?post=".$post_id."&action=edit"."'><span class='thumb-preview'><img src='" . plugins_url() ."/"."contact-form-7-style". ( empty( $img_src ) ? "/images/default_form.jpg" : $img_src ) . "' alt='".get_the_title( $post_id )."' title='".get_the_title( $post_id )."'/><div class='previewed-img'><img src='" . plugins_url() ."/"."contact-form-7-style". ( empty( $img_src ) ? "/images/default_form.jpg" : $img_src ) . "' alt='".get_the_title( $post_id )."' title='Edit ".get_the_title( $post_id )." Style'/></div></span></a>" ;
23
- }
24
- }
25
-
26
- add_filter( 'manage_cf7_style_posts_columns', 'cf7_style_event_table_head');
27
  add_action( 'manage_cf7_style_posts_custom_column', 'cf7_style_event_table_content', 10, 2 );
1
+ <?php
2
+
3
+ if ( !defined( 'ABSPATH' ) ) {
4
+ exit;
5
+ }
6
+
7
+ function cf7_style_event_table_head( $defaults ) {
8
+ $new = array();
9
+ foreach( $defaults as $key=>$value) {
10
+ if( $key=='title') { // when we find the date column
11
+ $new['preview-style'] = 'Preview Style';
12
+ }
13
+ $new[$key]=$value;
14
+ }
15
+ return $new;
16
+ }
17
+
18
+ function cf7_style_event_table_content( $column_name, $post_id ) {
19
+ // cf7_style_image_preview
20
+ if ( $column_name == 'preview-style' ) {
21
+ $img_src = get_post_meta( $post_id, 'cf7_style_image_preview', true );
22
+ echo "<a href='".admin_url() ."post.php?post=".$post_id."&action=edit"."'><span class='thumb-preview'><img src='" . plugins_url() ."/"."contact-form-7-style". ( empty( $img_src ) ? "/images/default_form.jpg" : $img_src ) . "' alt='".get_the_title( $post_id )."' title='".get_the_title( $post_id )."'/><div class='previewed-img'><img src='" . plugins_url() ."/"."contact-form-7-style". ( empty( $img_src ) ? "/images/default_form.jpg" : $img_src ) . "' alt='".get_the_title( $post_id )."' title='Edit ".get_the_title( $post_id )." Style'/></div></span></a>" ;
23
+ }
24
+ }
25
+
26
+ add_filter( 'manage_cf7_style_posts_columns', 'cf7_style_event_table_head');
27
  add_action( 'manage_cf7_style_posts_custom_column', 'cf7_style_event_table_content', 10, 2 );
inc/deactivate_style.php CHANGED
@@ -1,14 +1,14 @@
1
- <?php
2
- /*
3
- * Reset the cf7_style_cookie option
4
- */
5
-
6
- if ( !defined( 'ABSPATH' ) ) {
7
- exit;
8
- }
9
-
10
- function cf7_style_deactivate() {
11
- update_option( 'cf7_style_cookie', false );
12
- update_option( 'cf7_style_add_categories', 0 );
13
- }
14
  register_deactivation_hook( __FILE__, 'cf7_style_deactivate' );
1
+ <?php
2
+ /*
3
+ * Reset the cf7_style_cookie option
4
+ */
5
+
6
+ if ( !defined( 'ABSPATH' ) ) {
7
+ exit;
8
+ }
9
+
10
+ function cf7_style_deactivate() {
11
+ update_option( 'cf7_style_cookie', false );
12
+ update_option( 'cf7_style_add_categories', 0 );
13
+ }
14
  register_deactivation_hook( __FILE__, 'cf7_style_deactivate' );
inc/editor_page.php CHANGED
@@ -1,206 +1,206 @@
1
- <?php
2
- /*
3
- * page to save global css
4
- */
5
-
6
- if ( !defined( 'ABSPATH' ) ) {
7
- exit;
8
- }
9
-
10
- if ( !function_exists( 'cf7style_editor_page_init' ) ) {
11
- add_action('admin_menu', 'cf7style_editor_page_init');
12
- function cf7style_editor_page_init() {
13
- add_submenu_page(
14
- 'edit.php?post_type=cf7_style',
15
- __( "'CSS Editor", "contact-form-7-style" ),
16
- __( "CSS Editor", "contact-form-7-style" ),
17
- 'manage_options',
18
- 'cf7style-css-editor',
19
- 'cf7style_editor_page_view'
20
- );
21
- add_submenu_page(
22
- 'edit.php?post_type=cf7_style',
23
- __( "Settings", "contact-form-7-style" ),
24
- __( "Settings", "contact-form-7-style" ),
25
- 'manage_options',
26
- 'cf7style-settings',
27
- 'cf7style_settings_view'
28
- );
29
- }
30
- }
31
-
32
- if ( !function_exists( 'cf7style_settings_view' ) ) {
33
- function cf7style_settings_view() { ?>
34
- <form method="POST" action="">
35
- <?php
36
- do_settings_sections( 'cf7style-settings' );
37
- submit_button( __( "Save Settings", "contact-form-7-style" ), 'primary' , 'cf7styletracking');?>
38
- </form>
39
- <?php }
40
- }
41
-
42
- if ( !function_exists( 'cf7style_editor_page_view' ) ) {
43
- function cf7style_editor_page_view() {
44
- do_settings_sections( 'cf7style-css-editor' );
45
- }
46
- }
47
- $initiatenewoptions = new init_sections_register_fields();
48
-
49
- class init_sections_register_fields {
50
- public function __construct( ) {
51
- add_filter( 'admin_init' , array( $this , 'register_new_fields' ) );
52
- }
53
- function cf7style_render_checkbox( $option, $args, $description, $tulip ){
54
- $tulip = $tulip ? '<div class="cf7style-tooltip" title="more info"><i class="fa fa-question-circle" aria-hidden="true">?</i><div class="cf7style-tooltip-content">'.$tulip.'<div/></div>' : '';
55
- return '<label><input type="checkbox" value="1" '.checked( 1, $option,false).' id="'.$args[0].'[' . $args[0] . ']" name="'.$args[0].'" />'.__( $description, 'contact-form-7-style' ).'</label>'.$tulip;
56
- }
57
- function cf7style_templates_structure ( $args) {
58
- $html = "";
59
- $html .= '</tr>';
60
- $html .= '<tr><td colspan="2">';
61
- $option = get_option( $args[0] );
62
- if( $option == '1'){
63
- update_option( 'cf7_style_add_categories', 0 );
64
- }
65
- if( isset($_POST[ 'cf7styletracking' ]) ){
66
- update_option( 'cf7_style_no_temps', 'show_box' );
67
- }
68
- $html .= $this->cf7style_render_checkbox( $option, $args, 'Install predefined templates', '<p>'.__( "From here you will be able to import the Contact Form 7 Style predefined templates.", "contact-form-7-style" ).'</p><p><small>'.__( "This works only if the predefined templates are Deleted Permanently (they don't appear in", "contact-form-7-style" ).' <a href="'.admin_url('edit.php?post_status=trash&post_type=cf7_style').'">'.__( "Trash", "contact-form-7-style" ).'</a> ).</small></p>' );
69
- $html .= '</td></tr><tr><td colspan="2">';
70
- return $html;
71
- }
72
-
73
- function cf7style_tooltip_structure( $args ) {
74
- $html = "";
75
- $html .= '</tr>';
76
- $html .= '<tr><td colspan="2">';
77
- $option = get_option( $args[0] );
78
- if( isset( $_POST[ 'cf7_style_form_tooltip' ] ) ) {
79
- update_option( 'cf7_style_form_tooltip', '1' );
80
- }
81
- $html .= $this->cf7style_render_checkbox( $option, $args, 'Show the frontend form edit button', '' );
82
- $html .= '</td></tr><tr><td colspan="2">';
83
- return $html;
84
- }
85
-
86
- function cf7style_forcecss_structure( $args ) {
87
- $html = "";
88
- $html .= '</tr>';
89
- $html .= '<tr><td colspan="2">';
90
- $option = get_option( $args[0] );
91
- if( isset( $_POST[ 'cf7_style_forcecss' ] ) ) {
92
- update_option( 'cf7_style_forcecss', '1' );
93
- }
94
- $html .= $this->cf7style_render_checkbox( $option, $args, 'Force CSS', '' );
95
- $html .= '</td></tr><tr><td colspan="2">';
96
- return $html;
97
- }
98
-
99
- function cf7style_adminbar_structure( $args ) {
100
- $html = "";
101
- $html .= '</tr>';
102
- $html .= '<tr><td colspan="2">';
103
- $option = get_option( $args[0] );
104
- if( isset( $_POST[ 'cf7_style_adminbar' ] ) ) {
105
- update_option( 'cf7_style_adminbar', '1' );
106
-
107
- }
108
- $html .= $this->cf7style_render_checkbox( $option, $args, 'Add Contact Form 7 Style in the adminbar', '' );
109
- $html .= '</td></tr><tr><td colspan="2">';
110
- return $html;
111
- }
112
-
113
- function register_new_fields() {
114
- add_settings_section(
115
- 'cf7styleeditor',
116
- __('Global CSS', 'contact-form-7-style'),
117
- array( $this, 'description' ),
118
- 'cf7style-css-editor'
119
- );
120
- add_settings_section(
121
- 'cf7stylesettings',
122
- __('Contact Form 7 Style Settings', 'contact-form-7-style'),
123
- array( $this, 'settings_description' ),
124
- 'cf7style-settings'
125
- );
126
- $fields = array (
127
- 'cf7_style_manual_style' => 'CSS',
128
- );
129
-
130
- $set_fields = array (
131
- 'cf7_style_deleted' => __('Import predefined Contact Form 7 Style templates', 'contact-form-7-style'),
132
- 'cf7_style_form_tooltip' => __( 'Display form edit tooltip on frontend?', 'contact-form-7-style' ),
133
- 'cf7_style_forcecss' => __( 'Active theme overrides your form styling?', 'contact-form-7-style' ),
134
- 'cf7_style_adminbar' => __( 'Display Contact Form 7 Style in admin bar?', 'contact-form-7-style' )
135
- );
136
- foreach ( $set_fields as $field => $value ) {
137
- add_settings_field(
138
- $field,
139
- $value,
140
- array($this, 'setting_inputs'),
141
- 'cf7style-settings',
142
- 'cf7stylesettings',
143
- array( $field )
144
- );
145
- register_setting( 'general', $field, 'esc_attr' );
146
- }
147
-
148
- foreach ( $fields as $field => $value ) {
149
- add_settings_field(
150
- $field,
151
- $value,
152
- array($this, 'text_inputs'),
153
- 'cf7style-css-editor',
154
- 'cf7styleeditor',
155
- array( $field )
156
- );
157
- register_setting( 'general', $field, 'esc_attr' );
158
- }
159
- }
160
-
161
- function setting_inputs( $args ){
162
-
163
- if(isset( $_POST[ $args[0] ] )){
164
- update_option( $args[0], 1 );
165
- echo "<script>location.reload();</script>";
166
- } else {
167
- if(isset($_POST[ 'cf7styletracking' ])){
168
- update_option( $args[0], 0 );
169
- }
170
- if( isset( $_POST['cf7_style_form_tooltip'] ) ) {
171
- update_option( $args[0], 0 );
172
- }
173
- }
174
- switch($args[0]) {
175
- case 'cf7_style_deleted':
176
- echo $this->cf7style_templates_structure( $args );
177
- break;
178
- case 'cf7_style_form_tooltip' :
179
- echo $this->cf7style_tooltip_structure( $args );
180
- break;
181
- case 'cf7_style_forcecss' :
182
- echo $this->cf7style_forcecss_structure( $args );
183
- break;
184
- case 'cf7_style_adminbar' :
185
- echo $this->cf7style_adminbar_structure( $args );
186
- break;
187
- }
188
-
189
- }
190
- function text_inputs( $args ) {
191
- if ( isset( $_POST[ $args[0] ] ) ) {
192
- update_option( $args[0], $_POST[$args[0]] );
193
- }
194
- $option = stripslashes(get_option( $args[0] ));
195
-
196
- echo '<form method="POST" action="">';
197
- echo '<textarea id="'.$args[0].'" name="'.$args[0].'" />' . $option. '</textarea>';
198
- submit_button( 'Save CSS', 'primary' );
199
- echo '</form>';
200
- }
201
- function description() {
202
- echo '<p>'.__('On this page You can add a custom CSS mark-up, especially rules which could not be loaded via the style customizer above.', 'contact-form-7-style').'</p>';
203
- }
204
- function settings_description() {
205
- }
206
  }
1
+ <?php
2
+ /*
3
+ * page to save global css
4
+ */
5
+
6
+ if ( !defined( 'ABSPATH' ) ) {
7
+ exit;
8
+ }
9
+
10
+ if ( !function_exists( 'cf7style_editor_page_init' ) ) {
11
+ add_action('admin_menu', 'cf7style_editor_page_init');
12
+ function cf7style_editor_page_init() {
13
+ add_submenu_page(
14
+ 'edit.php?post_type=cf7_style',
15
+ __( "'CSS Editor", "contact-form-7-style" ),
16
+ __( "CSS Editor", "contact-form-7-style" ),
17
+ 'manage_options',
18
+ 'cf7style-css-editor',
19
+ 'cf7style_editor_page_view'
20
+ );
21
+ add_submenu_page(
22
+ 'edit.php?post_type=cf7_style',
23
+ __( "Settings", "contact-form-7-style" ),
24
+ __( "Settings", "contact-form-7-style" ),
25
+ 'manage_options',
26
+ 'cf7style-settings',
27
+ 'cf7style_settings_view'
28
+ );
29
+ }
30
+ }
31
+
32
+ if ( !function_exists( 'cf7style_settings_view' ) ) {
33
+ function cf7style_settings_view() { ?>
34
+ <form method="POST" action="">
35
+ <?php
36
+ do_settings_sections( 'cf7style-settings' );
37
+ submit_button( __( "Save Settings", "contact-form-7-style" ), 'primary' , 'cf7styletracking');?>
38
+ </form>
39
+ <?php }
40
+ }
41
+
42
+ if ( !function_exists( 'cf7style_editor_page_view' ) ) {
43
+ function cf7style_editor_page_view() {
44
+ do_settings_sections( 'cf7style-css-editor' );
45
+ }
46
+ }
47
+ $initiatenewoptions = new init_sections_register_fields();
48
+
49
+ class init_sections_register_fields {
50
+ public function __construct( ) {
51
+ add_filter( 'admin_init' , array( $this , 'register_new_fields' ) );
52
+ }
53
+ function cf7style_render_checkbox( $option, $args, $description, $tulip ){
54
+ $tulip = $tulip ? '<div class="cf7style-tooltip" title="more info"><i class="fa fa-question-circle" aria-hidden="true">?</i><div class="cf7style-tooltip-content">'.$tulip.'<div/></div>' : '';
55
+ return '<label><input type="checkbox" value="1" '.checked( 1, $option,false).' id="'.$args[0].'[' . $args[0] . ']" name="'.$args[0].'" />'.__( $description, 'contact-form-7-style' ).'</label>'.$tulip;
56
+ }
57
+ function cf7style_templates_structure ( $args) {
58
+ $html = "";
59
+ $html .= '</tr>';
60
+ $html .= '<tr><td colspan="2">';
61
+ $option = get_option( $args[0] );
62
+ if( $option == '1'){
63
+ update_option( 'cf7_style_add_categories', 0 );
64
+ }
65
+ if( isset($_POST[ 'cf7styletracking' ]) ){
66
+ update_option( 'cf7_style_no_temps', 'show_box' );
67
+ }
68
+ $html .= $this->cf7style_render_checkbox( $option, $args, 'Install predefined templates', '<p>'.__( "From here you will be able to import the Contact Form 7 Style predefined templates.", "contact-form-7-style" ).'</p><p><small>'.__( "This works only if the predefined templates are Deleted Permanently (they don't appear in", "contact-form-7-style" ).' <a href="'.admin_url('edit.php?post_status=trash&post_type=cf7_style').'">'.__( "Trash", "contact-form-7-style" ).'</a> ).</small></p>' );
69
+ $html .= '</td></tr><tr><td colspan="2">';
70
+ return $html;
71
+ }
72
+
73
+ function cf7style_tooltip_structure( $args ) {
74
+ $html = "";
75
+ $html .= '</tr>';
76
+ $html .= '<tr><td colspan="2">';
77
+ $option = get_option( $args[0] );
78
+ if( isset( $_POST[ 'cf7_style_form_tooltip' ] ) ) {
79
+ update_option( 'cf7_style_form_tooltip', '1' );
80
+ }
81
+ $html .= $this->cf7style_render_checkbox( $option, $args, 'Show the frontend form edit button', '' );
82
+ $html .= '</td></tr><tr><td colspan="2">';
83
+ return $html;
84
+ }
85
+
86
+ function cf7style_forcecss_structure( $args ) {
87
+ $html = "";
88
+ $html .= '</tr>';
89
+ $html .= '<tr><td colspan="2">';
90
+ $option = get_option( $args[0] );
91
+ if( isset( $_POST[ 'cf7_style_forcecss' ] ) ) {
92
+ update_option( 'cf7_style_forcecss', '1' );
93
+ }
94
+ $html .= $this->cf7style_render_checkbox( $option, $args, 'Force CSS', '' );
95
+ $html .= '</td></tr><tr><td colspan="2">';
96
+ return $html;
97
+ }
98
+
99
+ function cf7style_adminbar_structure( $args ) {
100
+ $html = "";
101
+ $html .= '</tr>';
102
+ $html .= '<tr><td colspan="2">';
103
+ $option = get_option( $args[0] );
104
+ if( isset( $_POST[ 'cf7_style_adminbar' ] ) ) {
105
+ update_option( 'cf7_style_adminbar', '1' );
106
+
107
+ }
108
+ $html .= $this->cf7style_render_checkbox( $option, $args, 'Add Contact Form 7 Style in the adminbar', '' );
109
+ $html .= '</td></tr><tr><td colspan="2">';
110
+ return $html;
111
+ }
112
+
113
+ function register_new_fields() {
114
+ add_settings_section(
115
+ 'cf7styleeditor',
116
+ __('Global CSS', 'contact-form-7-style'),
117
+ array( $this, 'description' ),
118
+ 'cf7style-css-editor'
119
+ );
120
+ add_settings_section(
121
+ 'cf7stylesettings',
122
+ __('Contact Form 7 Style Settings', 'contact-form-7-style'),
123
+ array( $this, 'settings_description' ),
124
+ 'cf7style-settings'
125
+ );
126
+ $fields = array (
127
+ 'cf7_style_manual_style' => 'CSS',
128
+ );
129
+
130
+ $set_fields = array (
131
+ 'cf7_style_deleted' => __('Import predefined Contact Form 7 Style templates', 'contact-form-7-style'),
132
+ 'cf7_style_form_tooltip' => __( 'Display form edit tooltip on frontend?', 'contact-form-7-style' ),
133
+ 'cf7_style_forcecss' => __( 'Active theme overrides your form styling?', 'contact-form-7-style' ),
134
+ 'cf7_style_adminbar' => __( 'Display Contact Form 7 Style in admin bar?', 'contact-form-7-style' )
135
+ );
136
+ foreach ( $set_fields as $field => $value ) {
137
+ add_settings_field(
138
+ $field,
139
+ $value,
140
+ array($this, 'setting_inputs'),
141
+ 'cf7style-settings',
142
+ 'cf7stylesettings',
143
+ array( $field )
144
+ );
145
+ register_setting( 'general', $field, 'esc_attr' );
146
+ }
147
+
148
+ foreach ( $fields as $field => $value ) {
149
+ add_settings_field(
150
+ $field,
151
+ $value,
152
+ array($this, 'text_inputs'),
153
+ 'cf7style-css-editor',
154
+ 'cf7styleeditor',
155
+ array( $field )
156
+ );
157
+ register_setting( 'general', $field, 'esc_attr' );
158
+ }
159
+ }
160
+
161
+ function setting_inputs( $args ){
162
+
163
+ if(isset( $_POST[ $args[0] ] )){
164
+ update_option( $args[0], 1 );
165
+ echo "<script>location.reload();</script>";
166
+ } else {
167
+ if(isset($_POST[ 'cf7styletracking' ])){
168
+ update_option( $args[0], 0 );
169
+ }
170
+ if( isset( $_POST['cf7_style_form_tooltip'] ) ) {
171
+ update_option( $args[0], 0 );
172
+ }
173
+ }
174
+ switch($args[0]) {
175
+ case 'cf7_style_deleted':
176
+ echo $this->cf7style_templates_structure( $args );
177
+ break;
178
+ case 'cf7_style_form_tooltip' :
179
+ echo $this->cf7style_tooltip_structure( $args );
180
+ break;
181
+ case 'cf7_style_forcecss' :
182
+ echo $this->cf7style_forcecss_structure( $args );
183
+ break;
184
+ case 'cf7_style_adminbar' :
185
+ echo $this->cf7style_adminbar_structure( $args );
186
+ break;
187
+ }
188
+
189
+ }
190
+ function text_inputs( $args ) {
191
+ if ( isset( $_POST[ $args[0] ] ) ) {
192
+ update_option( $args[0], $_POST[$args[0]] );
193
+ }
194
+ $option = stripslashes(get_option( $args[0] ));
195
+
196
+ echo '<form method="POST" action="">';
197
+ echo '<textarea id="'.$args[0].'" name="'.$args[0].'" />' . $option. '</textarea>';
198
+ submit_button( 'Save CSS', 'primary' );
199
+ echo '</form>';
200
+ }
201
+ function description() {
202
+ echo '<p>'.__('On this page You can add a custom CSS mark-up, especially rules which could not be loaded via the style customizer above.', 'contact-form-7-style').'</p>';
203
+ }
204
+ function settings_description() {
205
+ }
206
  }
inc/frontend_edit_style_link.php CHANGED
@@ -1,26 +1,26 @@
1
- <?php
2
-
3
- if ( !defined( 'ABSPATH' ) ) {
4
- exit;
5
- }
6
-
7
- function cf7_style_frontend_edit_link( $form ) {
8
-
9
- if( is_user_logged_in() && current_user_can( 'manage_options' ) && !is_admin() && get_option( 'cf7_style_form_tooltip' ) == 1 ) {
10
-
11
- $cf7 = wpcf7_get_current_contact_form(); // Current contact form 7 object
12
- $form_id = get_form_id( $cf7 );
13
- $cf7_style_id = get_post_meta( $form_id, 'cf7_style_id', true );
14
-
15
- if( empty( $cf7_style_id ) ) {
16
- $form .= "<a href='" . admin_url( 'edit.php?post_type=cf7_style' ) . "' class='frontend-edit-style-link'>" . __( 'Add Style', 'contact-form-7-style' ) . "</a>";
17
- } else {
18
- $cf7_style_data = get_post( $cf7_style_id, OBJECT );
19
- $template_type = ( has_term( 'custom-style', 'style_category', $cf7_style_data ) ) ? __( 'Edit custom style', 'contact-form-7-style' ) : __( 'Edit predifined template', 'contact-form-7-style' );
20
- $form .= "<a href='" . admin_url( 'post.php?post=' . $cf7_style_id . '&action=edit' ) . "' class='frontend-edit-style-link'>" . $template_type . "</a>";
21
- }
22
- }
23
-
24
- return $form;
25
- }
26
  add_filter( 'wpcf7_form_elements', 'cf7_style_frontend_edit_link' );
1
+ <?php
2
+
3
+ if ( !defined( 'ABSPATH' ) ) {
4
+ exit;
5
+ }
6
+
7
+ function cf7_style_frontend_edit_link( $form ) {
8
+
9
+ if( is_user_logged_in() && current_user_can( 'manage_options' ) && !is_admin() && get_option( 'cf7_style_form_tooltip' ) == 1 ) {
10
+
11
+ $cf7 = wpcf7_get_current_contact_form(); // Current contact form 7 object
12
+ $form_id = get_form_id( $cf7 );
13
+ $cf7_style_id = get_post_meta( $form_id, 'cf7_style_id', true );
14
+
15
+ if( empty( $cf7_style_id ) ) {
16
+ $form .= "<a href='" . admin_url( 'edit.php?post_type=cf7_style' ) . "' class='frontend-edit-style-link'>" . __( 'Add Style', 'contact-form-7-style' ) . "</a>";
17
+ } else {
18
+ $cf7_style_data = get_post( $cf7_style_id, OBJECT );
19
+ $template_type = ( has_term( 'custom-style', 'style_category', $cf7_style_data ) ) ? __( 'Edit custom style', 'contact-form-7-style' ) : __( 'Edit predifined template', 'contact-form-7-style' );
20
+ $form .= "<a href='" . admin_url( 'post.php?post=' . $cf7_style_id . '&action=edit' ) . "' class='frontend-edit-style-link'>" . $template_type . "</a>";
21
+ }
22
+ }
23
+
24
+ return $form;
25
+ }
26
  add_filter( 'wpcf7_form_elements', 'cf7_style_frontend_edit_link' );
inc/get_form_id.php CHANGED
@@ -1,24 +1,24 @@
1
- <?php
2
-
3
- /**
4
- * Get contact form 7 id
5
- *
6
- * Back compat for CF7 3.9
7
- * @see http://contactform7.com/2014/07/02/contact-form-7-39-beta/
8
- *
9
- * @param $cf7 Contact Form 7 object
10
- * @since 0.1.0
11
- */
12
-
13
- if ( !defined( 'ABSPATH' ) ) {
14
- exit;
15
- }
16
-
17
- function get_form_id( $cf7 ) {
18
- if ( version_compare( WPCF7_VERSION, '3.9-alpha', '>' ) ) {
19
- if (!is_object($cf7)) {
20
- return false;
21
- }
22
- return $cf7->id();
23
- }
24
  }
1
+ <?php
2
+
3
+ /**
4
+ * Get contact form 7 id
5
+ *
6
+ * Back compat for CF7 3.9
7
+ * @see http://contactform7.com/2014/07/02/contact-form-7-39-beta/
8
+ *
9
+ * @param $cf7 Contact Form 7 object
10
+ * @since 0.1.0
11
+ */
12
+
13
+ if ( !defined( 'ABSPATH' ) ) {
14
+ exit;
15
+ }
16
+
17
+ function get_form_id( $cf7 ) {
18
+ if ( version_compare( WPCF7_VERSION, '3.9-alpha', '>' ) ) {
19
+ if (!is_object($cf7)) {
20
+ return false;
21
+ }
22
+ return $cf7->id();
23
+ }
24
  }
inc/init_style.php CHANGED
@@ -1,185 +1,214 @@
1
- <?php
2
-
3
- /*
4
- Create the Contact style post type and custom taxonomy
5
- CPT: cf7_style
6
- Taxonomy: style_category
7
- */
8
-
9
- if ( !defined( 'ABSPATH' ) ) {
10
- exit;
11
- }
12
-
13
- function get_predefined_cf7_style_template_data() {
14
- $request_json = wp_remote_get( WPCF7S_LOCATION.'admin/predefined-templates.json' );
15
-
16
- if ( is_wp_error( $request_json ) || ( array_key_exists('response', $request_json ) && $request_json['response']['code'] != '200' ) ) {
17
- require WPCF7S_PLUGIN_DIR.'/admin/predefined_tpls.php';
18
- $templates = json_decode( $tpl_string, true );
19
- return $templates;
20
- }
21
- $templates = json_decode( wp_remote_retrieve_body( $request_json ), true );
22
- return $templates;
23
- }// end of get_predefined_cf7_style_template_data
24
-
25
- function cf7_style_set_style_category_on_publish( $ID, $post ) {
26
- wp_set_object_terms( $ID, 'custom style', 'style_category' );
27
- } // end cf7_style_set_style_category_on_publish
28
-
29
- function cf7_style_create_post( $slug, $title, $image, $temp_cat) {
30
- // Initialize the page ID to -1. This indicates no action has been taken.
31
- $post_id = -1;
32
- $was_deleted = get_option('cf7_style_deleted');
33
- if( null == get_page_by_title( $title, "OBJECT", "cf7_style" ) && $was_deleted != "yes" ) {
34
- // Set the post ID so that we know the post was created successfully
35
- $post_id = wp_insert_post(
36
- array(
37
- 'comment_status' => 'closed',
38
- 'ping_status' => 'closed',
39
- 'post_name' => $slug,
40
- 'post_title' => $title,
41
- 'post_status' => 'publish',
42
- 'post_type' => 'cf7_style'
43
- )
44
- );
45
- //if is_wp_error doesn't trigger, then we add the image
46
- if ( is_wp_error( $post_id ) ) {
47
- $errors = $post_id->get_error_messages();
48
- foreach ($errors as $error) {
49
- echo $error . '<br>';
50
- }
51
- } else {
52
- update_post_meta( $post_id, 'cf7_style_image_preview', $image );
53
- wp_set_object_terms( $post_id, $temp_cat, 'style_category' );
54
- }
55
- // Otherwise, we'll stop
56
- } else {
57
- // Arbitrarily use -2 to indicate that the page with the title already exists
58
- $post_id = -2;
59
- } // end if
60
- } // end cf7_style_create_post
61
-
62
- function cf7style_load_elements(){
63
-
64
- $labels = array(
65
- 'name' => _x( 'Contact Styles', 'Post Type General Name', 'contact-form-7-style' ),
66
- 'singular_name' => _x( 'Contact Style', 'Post Type Singular Name', 'contact-form-7-style' ),
67
- 'menu_name' => __( 'Contact Style', 'contact-form-7-style' ),
68
- 'parent_item_colon' => __( 'Parent Style:', 'contact-form-7-style' ),
69
- 'all_items' => __( 'All Styles', 'contact-form-7-style' ),
70
- 'view_item' => __( 'View Style', 'contact-form-7-style' ),
71
- 'add_new_item' => __( 'Add New', 'contact-form-7-style' ),
72
- 'add_new' => __( 'Add New', 'contact-form-7-style' ),
73
- 'edit_item' => __( 'Edit Style', 'contact-form-7-style' ),
74
- 'update_item' => __( 'Update Style', 'contact-form-7-style' ),
75
- 'search_items' => __( 'Search Style', 'contact-form-7-style' ),
76
- 'not_found' => __( 'Not found', 'contact-form-7-style' ),
77
- 'not_found_in_trash' => __( 'Not found in Trash', 'contact-form-7-style' )
78
- );
79
- $args = array(
80
- 'label' => __( 'cf7_style', 'contact-form-7-style' ),
81
- 'description' => __( 'Add/remove contact style', 'contact-form-7-style' ),
82
- 'labels' => $labels,
83
- 'supports' => array( 'title' ),
84
- 'hierarchical' => false,
85
- 'taxonomies' => array('style_category'),
86
- 'public' => true,
87
- 'show_ui' => true,
88
- 'show_in_menu' => true,
89
- 'show_in_nav_menus' => false,
90
- 'show_in_admin_bar' => false,
91
- 'menu_icon' => "dashicons-twitter",
92
- 'menu_position' => 28.555555,
93
- 'can_export' => true,
94
- 'has_archive' => false,
95
- 'exclude_from_search' => true,
96
- 'publicly_queryable' => false,
97
- 'capability_type' => 'page'
98
- );
99
- /*register custom post type CF7_STYLE*/
100
- register_post_type( 'cf7_style', $args );
101
-
102
- $labels = array(
103
- 'name' => _x( 'Categories', 'Taxonomy General Name', 'contact-form-7-style' ),
104
- 'singular_name' => _x( 'Categories', 'Taxonomy Singular Name', 'contact-form-7-style' ),
105
- 'menu_name' => __( 'Categories', 'contact-form-7-style' ),
106
- 'all_items' => __( 'All Categories', 'contact-form-7-style' ),
107
- 'parent_item' => __( 'Parent Categories', 'contact-form-7-style' ),
108
- 'parent_item_colon' => __( 'Parent Categories:', 'contact-form-7-style' ),
109
- 'new_item_name' => __( 'New Categories Name', 'contact-form-7-style' ),
110
- 'add_new_item' => __( 'Add New Categories', 'contact-form-7-style' ),
111
- 'edit_item' => __( 'Edit Categories', 'contact-form-7-style' ),
112
- 'update_item' => __( 'Update Categories', 'contact-form-7-style' ),
113
- 'separate_items_with_commas' => __( 'Separate Categories with commas', 'contact-form-7-style' ),
114
- 'search_items' => __( 'Search Categories', 'contact-form-7-style' ),
115
- 'add_or_remove_items' => __( 'Add or remove Categories', 'contact-form-7-style' ),
116
- 'choose_from_most_used' => __( 'Choose from the most used Categories', 'contact-form-7-style' ),
117
- 'not_found' => __( 'Not Found', 'contact-form-7-style' ),
118
- );
119
- $args = array(
120
- 'labels' => $labels,
121
- 'hierarchical' => true,
122
- 'public' => true,
123
- 'show_ui' => false,
124
- 'show_admin_column' => true,
125
- 'show_in_nav_menus' => false,
126
- 'show_tagcloud' => true,
127
- );
128
- //register tax
129
- register_taxonomy( 'style_category', array( 'cf7_style' ), $args );
130
- $add_post_or_not = get_option( 'cf7_style_add_categories', 0 );
131
- if( $add_post_or_not == 0 ){
132
- $tpl_data = get_predefined_cf7_style_template_data();
133
- if( $tpl_data ){
134
- foreach ( $tpl_data as $style ) {
135
- cf7_style_create_post( strtolower( str_replace( " ", "-", $style['title'] ) ), $style['title'], $style['image'], $style[ 'category' ] );
136
- }
137
- update_option( 'cf7_style_add_categories', 1 );
138
- }
139
-
140
- }
141
-
142
- $cf7_style_update_saved = get_option( 'cf7_style_update_saved' );
143
- if( $cf7_style_update_saved == "yes" ) {
144
- $cf7_style_args = array(
145
- 'post_type' => 'cf7_style',
146
- 'style_category' => 'custom-style',
147
- 'posts_per_page' => '-1'
148
- );
149
- $cf7s_manual_old_style = "";
150
- $new_settings = array();
151
- $cf7_style_query = new WP_Query( $cf7_style_args );
152
- if ( $cf7_style_query->have_posts() ) {
153
- while ( $cf7_style_query->have_posts() ) {
154
- $cf7_style_query->the_post();
155
- $cur_style_id = get_the_ID();
156
- $cur_manual_style = get_post_meta( $cur_style_id, 'cf7_style_manual_style', true );
157
- $cur_custom_styles = maybe_unserialize( get_post_meta( $cur_style_id, 'cf7_style_custom_styles', true ));
158
- if($cur_manual_style){
159
- $cf7s_manual_old_style .= $cur_manual_style;
160
- update_post_meta( $cur_style_id, 'cf7_style_manual_style', '' );
161
- }
162
- if($cur_custom_styles){
163
- $cf7s_custom_old_settings = $cur_custom_styles;
164
- require_once( WPCF7S_PLUGIN_DIR.'/cf7-style-match-old.php' );
165
- $new_settings = get_new_styler_data( $cf7s_custom_old_settings );
166
- update_post_meta( $cur_style_id, 'cf7_style_manual_styles', '');
167
- update_post_meta( $cur_style_id, 'cf7_style_custom_styles', '');
168
- update_post_meta( $cur_style_id, 'cf7_style_custom_styler', $new_settings, "");
169
- }
170
- }
171
- wp_reset_postdata();
172
- if($cf7s_manual_old_style){
173
- update_option( 'cf7_style_manual_style', $cf7s_manual_old_style );
174
- }
175
- }
176
- update_option( 'cf7_style_update_saved', 'no' );
177
- }
178
- require_once( WPCF7S_PLUGIN_DIR.'/cf7-style-meta-box.php' );
179
- if ( ! is_admin() ) {
180
- add_action('wp_head', 'cf7_style_custom_css_generator');
181
- }
182
- }
183
-
184
- add_action( 'init', 'cf7style_load_elements' );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
185
  add_action( 'publish_cf7_style', 'cf7_style_set_style_category_on_publish', 10, 2 );
1
+ <?php
2
+
3
+ /*
4
+ Create the Contact style post type and custom taxonomy
5
+ CPT: cf7_style
6
+ Taxonomy: style_category
7
+ */
8
+
9
+ if ( !defined( 'ABSPATH' ) ) {
10
+ exit;
11
+ }
12
+
13
+ function get_predefined_cf7_style_template_data() {
14
+ $request_json = wp_remote_get( WPCF7S_LOCATION.'admin/predefined-templates.json' );
15
+
16
+ if ( is_wp_error( $request_json ) || ( array_key_exists('response', $request_json ) && $request_json['response']['code'] != '200' ) ) {
17
+ require WPCF7S_PLUGIN_DIR.'/admin/predefined_tpls.php';
18
+ $templates = json_decode( $tpl_string, true );
19
+ return $templates;
20
+ }
21
+ $templates = json_decode( wp_remote_retrieve_body( $request_json ), true );
22
+ return $templates;
23
+ }// end of get_predefined_cf7_style_template_data
24
+
25
+ function cf7_style_set_style_category_on_publish( $ID, $post ) {
26
+ $temporizator = 0;
27
+ $tpl_data = get_predefined_cf7_style_template_data();
28
+ if( $tpl_data ){
29
+ foreach ( $tpl_data as $predefined_post_titles ) {
30
+ if( $post->post_title == $predefined_post_titles[ "title" ] ){
31
+ $temporizator++;
32
+ }
33
+ }
34
+ }
35
+ if( 0 == $temporizator ) {
36
+ wp_set_object_terms( $ID, 'custom style', 'style_category' );
37
+ }
38
+ } // end cf7_style_set_style_category_on_publish
39
+
40
+ function cf7_style_create_post( $slug, $title, $image) {
41
+ // Initialize the page ID to -1. This indicates no action has been taken.
42
+ $post_id = -1;
43
+ $was_deleted = get_option('cf7_style_deleted');
44
+ if( null == get_page_by_title( $title, "OBJECT", "cf7_style" ) && $was_deleted != "yes" ) {
45
+ // Set the post ID so that we know the post was created successfully
46
+ $post_id = wp_insert_post(
47
+ array(
48
+ 'comment_status' => 'closed',
49
+ 'ping_status' => 'closed',
50
+ 'post_name' => $slug,
51
+ 'post_title' => $title,
52
+ 'post_status' => 'publish',
53
+ 'post_type' => 'cf7_style'
54
+ )
55
+ );
56
+ //if is_wp_error doesn't trigger, then we add the image
57
+ if ( is_wp_error( $post_id ) ) {
58
+ $errors = $post_id->get_error_messages();
59
+ foreach ($errors as $error) {
60
+ echo $error . '<br>';
61
+ }
62
+ } else {
63
+ update_post_meta( $post_id, 'cf7_style_image_preview', $image );
64
+ //wp_set_object_terms( $post_id, $temp_cat, 'style_category' );
65
+ }
66
+ // Otherwise, we'll stop
67
+ } else {
68
+ // Arbitrarily use -2 to indicate that the page with the title already exists
69
+ $post_id = -2;
70
+ } // end if
71
+ } // end cf7_style_create_post
72
+
73
+ function cf7style_load_elements(){
74
+
75
+ $labels = array(
76
+ 'name' => _x( 'Contact Styles', 'Post Type General Name', 'contact-form-7-style' ),
77
+ 'singular_name' => _x( 'Contact Style', 'Post Type Singular Name', 'contact-form-7-style' ),
78
+ 'menu_name' => __( 'Contact Style', 'contact-form-7-style' ),
79
+ 'parent_item_colon' => __( 'Parent Style:', 'contact-form-7-style' ),
80
+ 'all_items' => __( 'All Styles', 'contact-form-7-style' ),
81
+ 'view_item' => __( 'View Style', 'contact-form-7-style' ),
82
+ 'add_new_item' => __( 'Add New', 'contact-form-7-style' ),
83
+ 'add_new' => __( 'Add New', 'contact-form-7-style' ),
84
+ 'edit_item' => __( 'Edit Style', 'contact-form-7-style' ),
85
+ 'update_item' => __( 'Update Style', 'contact-form-7-style' ),
86
+ 'search_items' => __( 'Search Style', 'contact-form-7-style' ),
87
+ 'not_found' => __( 'Not found', 'contact-form-7-style' ),
88
+ 'not_found_in_trash' => __( 'Not found in Trash', 'contact-form-7-style' )
89
+ );
90
+ $args = array(
91
+ 'label' => __( 'cf7_style', 'contact-form-7-style' ),
92
+ 'description' => __( 'Add/remove contact style', 'contact-form-7-style' ),
93
+ 'labels' => $labels,
94
+ 'supports' => array( 'title' ),
95
+ 'hierarchical' => false,
96
+ 'taxonomies' => array('style_category'),
97
+ 'public' => true,
98
+ 'show_ui' => true,
99
+ 'show_in_menu' => true,
100
+ 'show_in_nav_menus' => false,
101
+ 'show_in_admin_bar' => false,
102
+ 'menu_icon' => "dashicons-twitter",
103
+ 'menu_position' => 28.555555,
104
+ 'can_export' => true,
105
+ 'has_archive' => false,
106
+ 'exclude_from_search' => true,
107
+ 'publicly_queryable' => false,
108
+ 'capability_type' => 'page'
109
+ );
110
+ /*register custom post type CF7_STYLE*/
111
+ register_post_type( 'cf7_style', $args );
112
+
113
+ $labels = array(
114
+ 'name' => _x( 'Categories', 'Taxonomy General Name', 'contact-form-7-style' ),
115
+ 'singular_name' => _x( 'Categories', 'Taxonomy Singular Name', 'contact-form-7-style' ),
116
+ 'menu_name' => __( 'Categories', 'contact-form-7-style' ),
117
+ 'all_items' => __( 'All Categories', 'contact-form-7-style' ),
118
+ 'parent_item' => __( 'Parent Categories', 'contact-form-7-style' ),
119
+ 'parent_item_colon' => __( 'Parent Categories:', 'contact-form-7-style' ),
120
+ 'new_item_name' => __( 'New Categories Name', 'contact-form-7-style' ),
121
+ 'add_new_item' => __( 'Add New Categories', 'contact-form-7-style' ),
122
+ 'edit_item' => __( 'Edit Categories', 'contact-form-7-style' ),
123
+ 'update_item' => __( 'Update Categories', 'contact-form-7-style' ),
124
+ 'separate_items_with_commas' => __( 'Separate Categories with commas', 'contact-form-7-style' ),
125
+ 'search_items' => __( 'Search Categories', 'contact-form-7-style' ),
126
+ 'add_or_remove_items' => __( 'Add or remove Categories', 'contact-form-7-style' ),
127
+ 'choose_from_most_used' => __( 'Choose from the most used Categories', 'contact-form-7-style' ),
128
+ 'not_found' => __( 'Not Found', 'contact-form-7-style' ),
129
+ );
130
+ $args = array(
131
+ 'labels' => $labels,
132
+ 'hierarchical' => true,
133
+ 'public' => true,
134
+ 'show_ui' => false,
135
+ 'show_admin_column' => true,
136
+ 'show_in_nav_menus' => false,
137
+ 'show_tagcloud' => true,
138
+ );
139
+ //register tax
140
+ register_taxonomy( 'style_category', array( 'cf7_style' ), $args );
141
+ $tpl_data = get_predefined_cf7_style_template_data();
142
+ if( $tpl_data ){
143
+ foreach ( $tpl_data as $style ) {
144
+ cf7_style_create_post( strtolower( str_replace( " ", "-", $style['title'] ) ), $style['title'], $style['image'] );
145
+ }
146
+ if( get_option( 'cf7_style_add_categories', 0 ) == 0 ){
147
+ $cf7_style_args = array(
148
+ 'post_type' => 'cf7_style',
149
+ 'posts_per_page' => '-1'
150
+ );
151
+
152
+ $cf7_style_query = new WP_Query( $cf7_style_args );
153
+ if ( $cf7_style_query->have_posts() ) {
154
+ while ( $cf7_style_query->have_posts() ) {
155
+ $cf7_style_query->the_post();
156
+ $temp_title = get_the_title();
157
+ $temp_ID = get_the_ID();
158
+
159
+ foreach ( $tpl_data as $style ) {
160
+ if( $temp_title == wptexturize( $style[ 'title' ] ) ) {
161
+ wp_set_object_terms( $temp_ID, $style[ 'category' ], 'style_category' );
162
+ }
163
+ }
164
+ }
165
+ wp_reset_postdata();
166
+ update_option( 'cf7_style_add_categories', 1 );
167
+ }
168
+ }
169
+ }
170
+
171
+ $cf7_style_update_saved = get_option( 'cf7_style_update_saved' );
172
+ if( $cf7_style_update_saved == "yes" ) {
173
+ $cf7_style_args = array(
174
+ 'post_type' => 'cf7_style',
175
+ 'style_category' => 'custom-style',
176
+ 'posts_per_page' => '-1'
177
+ );
178
+ $cf7s_manual_old_style = "";
179
+ $new_settings = array();
180
+ $cf7_style_query = new WP_Query( $cf7_style_args );
181
+ if ( $cf7_style_query->have_posts() ) {
182
+ while ( $cf7_style_query->have_posts() ) {
183
+ $cf7_style_query->the_post();
184
+ $cur_style_id = get_the_ID();
185
+ $cur_manual_style = get_post_meta( $cur_style_id, 'cf7_style_manual_style', true );
186
+ $cur_custom_styles = maybe_unserialize( get_post_meta( $cur_style_id, 'cf7_style_custom_styles', true ));
187
+ if($cur_manual_style){
188
+ $cf7s_manual_old_style .= $cur_manual_style;
189
+ update_post_meta( $cur_style_id, 'cf7_style_manual_style', '' );
190
+ }
191
+ if($cur_custom_styles){
192
+ $cf7s_custom_old_settings = $cur_custom_styles;
193
+ require_once( WPCF7S_PLUGIN_DIR.'/cf7-style-match-old.php' );
194
+ $new_settings = get_new_styler_data( $cf7s_custom_old_settings );
195
+ update_post_meta( $cur_style_id, 'cf7_style_manual_styles', '');
196
+ update_post_meta( $cur_style_id, 'cf7_style_custom_styles', '');
197
+ update_post_meta( $cur_style_id, 'cf7_style_custom_styler', $new_settings, "");
198
+ }
199
+ }
200
+ wp_reset_postdata();
201
+ if($cf7s_manual_old_style){
202
+ update_option( 'cf7_style_manual_style', $cf7s_manual_old_style );
203
+ }
204
+ }
205
+ update_option( 'cf7_style_update_saved', 'no' );
206
+ }
207
+ require_once( WPCF7S_PLUGIN_DIR.'/cf7-style-meta-box.php' );
208
+ if ( ! is_admin() ) {
209
+ add_action('wp_head', 'cf7_style_custom_css_generator');
210
+ }
211
+ }
212
+
213
+ add_action( 'init', 'cf7style_load_elements' );
214
  add_action( 'publish_cf7_style', 'cf7_style_set_style_category_on_publish', 10, 2 );
inc/remove_predefined_templates.php CHANGED
@@ -1,50 +1,50 @@
1
- <?php
2
-
3
- if ( !defined( 'ABSPATH' ) ) {
4
- exit;
5
- }
6
-
7
- function cf7_style_remove_templates() {
8
- global $wpdb;
9
- update_option( 'cf7_style_deleted', 'yes' );
10
- update_option( 'cf7_style_add_categories', 0 );
11
- $del_args = array(
12
- 'posts_per_page' => -1,
13
- 'post_type' => 'cf7_style',
14
- 'tax_query' => array(
15
- array(
16
- 'taxonomy' => 'style_category',
17
- 'field' => 'slug',
18
- 'terms' => 'custom-style',
19
- 'operator' => 'NOT IN',
20
- ),
21
- ),
22
- );
23
- $del_query = new WP_Query( $del_args );
24
- if ( $del_query->have_posts() ) {
25
- while ( $del_query->have_posts() ) {
26
- $del_query->the_post();
27
- $style_id = get_the_ID();
28
- $clr_form_args = array(
29
- 'post_type' => 'wpcf7_contact_form',
30
- 'posts_per_page' => -1,
31
- 'meta_key' => 'cf7_style_id',
32
- 'meta_value' => $style_id
33
- );
34
- $form_query = new WP_Query( $clr_form_args );
35
- if ( $form_query->have_posts() ) {
36
- while ( $form_query->have_posts() ) {
37
- $form_query->the_post();
38
- /*form id*/
39
- update_post_meta( get_the_ID(), 'cf7_style_id', '');
40
- }
41
- wp_reset_postdata();
42
- }
43
- wp_delete_post( $style_id,false);
44
- }
45
- wp_reset_postdata();
46
- print_r('success');
47
- }
48
- wp_die();
49
- }
50
  add_action( 'wp_ajax_cf7_style_remove_templates', 'cf7_style_remove_templates' );
1
+ <?php
2
+
3
+ if ( !defined( 'ABSPATH' ) ) {
4
+ exit;
5
+ }
6
+
7
+ function cf7_style_remove_templates() {
8
+ global $wpdb;
9
+ update_option( 'cf7_style_deleted', 'yes' );
10
+ update_option( 'cf7_style_add_categories', 0 );
11
+ $del_args = array(
12
+ 'posts_per_page' => -1,
13
+ 'post_type' => 'cf7_style',
14
+ 'tax_query' => array(
15
+ array(
16
+ 'taxonomy' => 'style_category',
17
+ 'field' => 'slug',
18
+ 'terms' => 'custom-style',
19
+ 'operator' => 'NOT IN',
20
+ ),
21
+ ),
22
+ );
23
+ $del_query = new WP_Query( $del_args );
24
+ if ( $del_query->have_posts() ) {
25
+ while ( $del_query->have_posts() ) {
26
+ $del_query->the_post();
27
+ $style_id = get_the_ID();
28
+ $clr_form_args = array(
29
+ 'post_type' => 'wpcf7_contact_form',
30
+ 'posts_per_page' => -1,
31
+ 'meta_key' => 'cf7_style_id',
32
+ 'meta_value' => $style_id
33
+ );
34
+ $form_query = new WP_Query( $clr_form_args );
35
+ if ( $form_query->have_posts() ) {
36
+ while ( $form_query->have_posts() ) {
37
+ $form_query->the_post();
38
+ /*form id*/
39
+ update_post_meta( get_the_ID(), 'cf7_style_id', '');
40
+ }
41
+ wp_reset_postdata();
42
+ }
43
+ wp_delete_post( $style_id,false);
44
+ }
45
+ wp_reset_postdata();
46
+ print_r('success');
47
+ }
48
+ wp_die();
49
+ }
50
  add_action( 'wp_ajax_cf7_style_remove_templates', 'cf7_style_remove_templates' );
inc/slider_meta_box.php CHANGED
@@ -1,114 +1,114 @@
1
- <?php
2
- /*
3
- * function for displaying the meta box
4
- */
5
-
6
- if ( !defined( 'ABSPATH' ) ) {
7
- exit;
8
- }
9
-
10
- function cf7_style_display_slider( $post ) {
11
- $stylearray = array(
12
- 'post_type' => 'cf7_style',
13
- 'posts_per_page' => -1,
14
- 'order' => 'DESC',
15
- 'orderby' => 'ID'
16
- );
17
- $styles = get_posts( $stylearray );
18
- $activetemplate = get_post_meta( $post->id(), 'cf7_style_id', true );
19
-
20
- ?>
21
- <div class="cf7-style-slider">
22
- <div class="cf7-style-slider-wrap">
23
- <ul class="cf7slider">
24
- <?php
25
- $i = 1;
26
- foreach ($styles as $style) {
27
- $previewimage = get_post_meta( $style->ID, 'cf7_style_image_preview', true ); ?>
28
- <li class="slide <?php echo ( ( $activetemplate == $style->ID ) ? 'active current-saved' : '' );?>">
29
- <span>
30
- <div class="overlay">
31
- <em><?php echo ( ( $activetemplate == $style->ID ) ? 'Active' : 'Not Active' );?></em>
32
- </div>
33
- <img src="<?php echo plugins_url(); ?>/contact-form-7-style/<?php echo ( !empty( $previewimage ) ? $previewimage : '/images/default_form.jpg' ); ?>" alt="" />
34
- <input type="radio" id="cf7style_template_<?php echo $i; ?>" name="cf7style_template" class="cf7style_template" value="<?php echo $style->ID; ?>" <?php echo ( ( $activetemplate == $style->ID ) ? 'checked' : '' );?> />
35
-
36
- <?php echo $style->post_title; ?>
37
- </span>
38
- </li>
39
- <?php $i++; } ?>
40
- </ul>
41
- <div class="cf7arrows">
42
- <div><a href="#" class="narrow left" data-direction="left"></a></div>
43
- <div><a href="#" class="narrow right" data-direction="right"></a></div>
44
- </div>
45
- </div>
46
- </div>
47
-
48
- <?php }
49
- /*
50
- * saving stuff
51
- */
52
- function cf7_style_save_meta_box_data( $post_id ) {
53
- if ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) {
54
- return;
55
- }
56
- if ( isset( $_POST['wpcf7-new'] ) ) {
57
- if ( ! current_user_can( 'edit_page', $post_id ) ) {
58
- return;
59
- }
60
- } else {
61
- if ( ! current_user_can( 'edit_post', $post_id ) ) {
62
- return;
63
- }
64
- }
65
- if ( ! isset( $_POST['cf7style_template'] ) ) {
66
- return;
67
- }
68
-
69
- if ( !is_numeric( $_POST['cf7style_template'] ) ) {
70
- die('No tricks please');
71
- }
72
- $styleid = sanitize_text_field( $_POST['cf7style_template'] );
73
- update_post_meta( $post_id, 'cf7_style_id', $styleid );
74
- }
75
- add_action( 'save_post', 'cf7_style_save_meta_box_data' );
76
-
77
-
78
- /*
79
- * new panel
80
- */
81
- function cf7style_add_template_panel ( $panels ) {
82
- $panels['Cf7StyleTemplate'] = array(
83
- 'title' => __( 'Contact Form 7 Style Template', 'contact-form-7' ),
84
- 'callback' => 'cf7_style_display_slider'
85
- );
86
- return $panels;
87
- }
88
-
89
-
90
-
91
- /*
92
- * old meta box
93
- */
94
- function cf7style_meta_box ( $post_id ) {
95
- add_meta_box('cf7_style_slider', 'Choose a template', 'cf7_style_display_slider', null, 'mail', 'core');
96
- }
97
-
98
- /*
99
- * depending on what CF7 version is active,
100
- * we use the appropiate hook!
101
- */
102
- function init_meta_box_by_version() {
103
- $plugin_folder = get_plugins( '/' . 'contact-form-7' );
104
- $plugin_file = 'wp-contact-form-7.php';
105
- if($plugin_folder){
106
- $CF7Version = $plugin_folder[$plugin_file]['Version'];
107
- if ( $CF7Version < 4.2 ) {
108
- add_action( 'wpcf7_add_meta_boxes', 'cf7style_meta_box' );
109
- } else {
110
- add_filter( 'wpcf7_editor_panels', 'cf7style_add_template_panel' );
111
- }
112
- }
113
- }
114
  add_action( 'admin_init', 'init_meta_box_by_version' );
1
+ <?php
2
+ /*
3
+ * function for displaying the meta box
4
+ */
5
+
6
+ if ( !defined( 'ABSPATH' ) ) {
7
+ exit;
8
+ }
9
+
10
+ function cf7_style_display_slider( $post ) {
11
+ $stylearray = array(
12
+ 'post_type' => 'cf7_style',
13
+ 'posts_per_page' => -1,
14
+ 'order' => 'DESC',
15
+ 'orderby' => 'ID'
16
+ );
17
+ $styles = get_posts( $stylearray );
18
+ $activetemplate = get_post_meta( $post->id(), 'cf7_style_id', true );
19
+
20
+ ?>
21
+ <div class="cf7-style-slider">
22
+ <div class="cf7-style-slider-wrap">
23
+ <ul class="cf7slider">
24
+ <?php
25
+ $i = 1;
26
+ foreach ($styles as $style) {
27
+ $previewimage = get_post_meta( $style->ID, 'cf7_style_image_preview', true ); ?>
28
+ <li class="slide <?php echo ( ( $activetemplate == $style->ID ) ? 'active current-saved' : '' );?>">
29
+ <span>
30
+ <div class="overlay">
31
+ <em><?php echo ( ( $activetemplate == $style->ID ) ? 'Active' : 'Not Active' );?></em>
32
+ </div>
33
+ <img src="<?php echo plugins_url(); ?>/contact-form-7-style/<?php echo ( !empty( $previewimage ) ? $previewimage : '/images/default_form.jpg' ); ?>" alt="" />
34
+ <input type="radio" id="cf7style_template_<?php echo $i; ?>" name="cf7style_template" class="cf7style_template" value="<?php echo $style->ID; ?>" <?php echo ( ( $activetemplate == $style->ID ) ? 'checked' : '' );?> />
35
+
36
+ <?php echo $style->post_title; ?>
37
+ </span>
38
+ </li>
39
+ <?php $i++; } ?>
40
+ </ul>
41
+ <div class="cf7arrows">
42
+ <div><a href="#" class="narrow left" data-direction="left"></a></div>
43
+ <div><a href="#" class="narrow right" data-direction="right"></a></div>
44
+ </div>
45
+ </div>
46
+ </div>
47
+
48
+ <?php }
49
+ /*
50
+ * saving stuff
51
+ */
52
+ function cf7_style_save_meta_box_data( $post_id ) {
53
+ if ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) {
54
+ return;
55
+ }
56
+ if ( isset( $_POST['wpcf7-new'] ) ) {
57
+ if ( ! current_user_can( 'edit_page', $post_id ) ) {
58
+ return;
59
+ }
60
+ } else {
61
+ if ( ! current_user_can( 'edit_post', $post_id ) ) {
62
+ return;
63
+ }
64
+ }
65
+ if ( ! isset( $_POST['cf7style_template'] ) ) {
66
+ return;
67
+ }
68
+
69
+ if ( !is_numeric( $_POST['cf7style_template'] ) ) {
70
+ die('No tricks please');
71
+ }
72
+ $styleid = sanitize_text_field( $_POST['cf7style_template'] );
73
+ update_post_meta( $post_id, 'cf7_style_id', $styleid );
74
+ }
75
+ add_action( 'save_post', 'cf7_style_save_meta_box_data' );
76
+
77
+
78
+ /*
79
+ * new panel
80
+ */
81
+ function cf7style_add_template_panel ( $panels ) {
82
+ $panels['Cf7StyleTemplate'] = array(
83
+ 'title' => __( 'Contact Form 7 Style Template', 'contact-form-7' ),
84
+ 'callback' => 'cf7_style_display_slider'
85
+ );
86
+ return $panels;
87
+ }
88
+
89
+
90
+
91
+ /*
92
+ * old meta box
93
+ */
94
+ function cf7style_meta_box ( $post_id ) {
95
+ add_meta_box('cf7_style_slider', 'Choose a template', 'cf7_style_display_slider', null, 'mail', 'core');
96
+ }
97
+
98
+ /*
99
+ * depending on what CF7 version is active,
100
+ * we use the appropiate hook!
101
+ */
102
+ function init_meta_box_by_version() {
103
+ $plugin_folder = get_plugins( '/' . 'contact-form-7' );
104
+ $plugin_file = 'wp-contact-form-7.php';
105
+ if($plugin_folder){
106
+ $CF7Version = $plugin_folder[$plugin_file]['Version'];
107
+ if ( $CF7Version < 4.2 ) {
108
+ add_action( 'wpcf7_add_meta_boxes', 'cf7style_meta_box' );
109
+ } else {
110
+ add_filter( 'wpcf7_editor_panels', 'cf7style_add_template_panel' );
111
+ }
112
+ }
113
+ }
114
  add_action( 'admin_init', 'init_meta_box_by_version' );
inc/system_status.php ADDED
@@ -0,0 +1,305 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * CF7 Style System status
4
+ */
5
+
6
+ if ( !defined( 'ABSPATH' ) ) {
7
+ exit;
8
+ }
9
+
10
+ function cf7style_system_status() {
11
+
12
+ /**
13
+ * let_to_num function.
14
+ *
15
+ * This function transforms the php.ini notation for numbers (like '2M') to an integer.
16
+ *
17
+ * @param $size
18
+ * @return int
19
+ */
20
+ function cf7style_let_to_num( $size ) {
21
+ $l = substr( $size, -1 );
22
+ $ret = substr( $size, 0, -1 );
23
+ switch ( strtoupper( $l ) ) {
24
+ case 'P':
25
+ $ret *= 1024;
26
+ case 'T':
27
+ $ret *= 1024;
28
+ case 'G':
29
+ $ret *= 1024;
30
+ case 'M':
31
+ $ret *= 1024;
32
+ case 'K':
33
+ $ret *= 1024;
34
+ }
35
+ return $ret;
36
+ }
37
+
38
+
39
+ // Cache variables
40
+ $html = '';
41
+ $table = '';
42
+ $form = '';
43
+ $table_start = '<table class="wp-list-table widefat striped cf7style-status-table">';
44
+ $table_end = '</table><small>&nbsp;</small>';
45
+
46
+ $html .= '<div class="wrap">';
47
+ $html .= '<h2>' . __( "System Status", "contact-form-7-style" ) . '</h2>';
48
+ $html .= '<p>' . __( "The Contact Form 7 Style System Status is a tool for troubleshooting issues with your site.", "contact-form-7-style" ) . '</p>';
49
+ $html .= '<p>' . __( "With the informations gathered from you we can debug and analyze and try to offer you a fix.", "contact-form-7-style" ) . '</p>';
50
+ $html .= '<p>' . __( "The System Status is the best way for Contact Form 7 Style Support to help you!", "contact-form-7-style" ) . '</p>';
51
+
52
+ // Form
53
+ $form .= '<form class="cf7style-status-form">';
54
+ $form .= '<p><input type="text" name="cf7style-name" class="cf7style-name cf7style-input" placeholder="' . __( "Your name", "contact-form-7-style" ) .'" /></p>';
55
+ $form .= '<p><input type="email" name="cf7style-email" class="cf7style-email cf7style-input" placeholder="' . __( "Your email", "contact-form-7-style" ) .'" /></p>';
56
+ $form .= '<p><textarea name="cf7style-message" class="cf7style-message cf7style-input" placeholder="' . __( "Your message", "cf7style-message", "contact-form-7-style" ) . '"></textarea></p>';
57
+ $form .= '<button class="button cf7style-status-info">' . __( "Show the environment report", "contact-form-7-style" ) . '</button>';
58
+
59
+ // Debug - system status send button
60
+ //delete_transient( 'cf7style_system_report' );
61
+
62
+ $report_status = get_transient( 'cf7style_system_report' );
63
+
64
+ if( $report_status && 'sent' == $report_status ) {
65
+ $form .= '<button class="button-primary" disabled="disabled">' . __( "Report sent", "contact-form-7-style" ) . '</button>';
66
+ } else {
67
+ $form .= '<button class="button-primary cf7style-status-submit">' . __( "I think I have a CF7 Style issue. Send Report to CF7 Style Support team.", "contact-form-7-style" ) . '</button>';
68
+ }
69
+
70
+ $form .= '</form>';
71
+
72
+ $html .= $form;
73
+
74
+ // General
75
+ $table .= $table_start;
76
+ $table .= '<thead><tr><th colspan="2"><strong>' . __( "Your WordPress Setup", "contact-form-7-style" ) . '</strong></th></tr></thead>';
77
+
78
+ // Home URL
79
+ $table .= "<tr><td>" . __( 'Home URL:', 'contact-form-7-style' ) . "</td>";
80
+ $table .= "<td>" . home_url() . "</td></tr>";
81
+
82
+ // Site URL
83
+ $table .= "<tr><td>" . __( 'Site URL:', 'contact-form-7-style' ) . "</td>";
84
+ $table .= "<td>" . site_url() . "</td></tr>";
85
+
86
+ // CF7 Style Version
87
+ $table .= "<tr><td>" . __( 'Contact Form 7 Style Version:', 'contact-form-7-style' ) . "</td>";
88
+ $table .= "<td>" . WPCF7S_PLUGIN_VER . "</td></tr>";
89
+
90
+ // WP Version
91
+ $table .= "<tr><td>" . __( 'WP Version:', 'contact-form-7-style' ) . "</td>";
92
+ $table .= "<td>" . get_bloginfo( 'version' ) . "</td></tr>";
93
+
94
+ // WP Multisite
95
+ $table .= "<tr><td>" . __( 'WP Multisite:', 'contact-form-7-style' ) . "</td>";
96
+ $table .= "<td>" . ( ( is_multisite() ) ? "Yes" : "No" ) . "</td></tr>";
97
+
98
+ // WP Memory Limit
99
+ $memory = cf7style_let_to_num( WP_MEMORY_LIMIT );
100
+ $table .= "<tr><td>" . __( ' WP Memory Limit:', 'contact-form-7-style' ) . "</td>";
101
+
102
+ if ( $memory < 100663296 ) {
103
+ $table .= '<td><mark class="error">' . sprintf( __( '%s - Recommended memory at least 96MB. See: <a href="%s" target="_blank">Increasing memory allocated to PHP</a>', 'contact-form-7-style' ), size_format( $memory ), 'http://codex.wordpress.org/Editing_wp-config.php#Increasing_memory_allocated_to_PHP' ) . '</mark></td></tr>';
104
+ } else {
105
+ $table .= '<td><mark class="yes">' . size_format( $memory ) . '</mark></td></tr>';
106
+ }
107
+
108
+ // WP Debug Mode
109
+ $table .= "<tr><td>" . __( 'WP Debug Mode:', 'contact-form-7-style' ) . "</td>";
110
+ $table .= "<td>" . ( ( WP_DEBUG ) ? "enabled" : "disabled" ) . "</td></tr>";
111
+
112
+ // Language
113
+ $table .= "<tr><td>" . __( 'Language:', 'contact-form-7-style' ) . "</td>";
114
+ $table .= "<td>" . get_locale() . "</td></tr>";
115
+
116
+ // Email address for feedback
117
+ $table .= "<tr><td>" . __( 'Site email address', 'contact-form-7-style' ) . "</td>";
118
+ $table .= "<td>" . get_option( 'admin_email' ) . "</td></tr>";
119
+
120
+ $table .= $table_end;
121
+
122
+
123
+ // Your Server Setup
124
+ $table .= $table_start;
125
+ $table .= '<thead><tr><th colspan="2"><strong>' . __( "Your Server Setup", "contact-form-7-style" ) . '</strong></th></tr></thead>';
126
+
127
+ // Server info
128
+ $table .= "<tr><td>" . __( 'Server info', 'contact-form-7-style' ) . "</td>";
129
+ $table .= "<td>" . esc_html( $_SERVER['SERVER_SOFTWARE'] ) . "</td></tr>";
130
+
131
+ // PHP version
132
+ $table .= "<tr><td>" . __( 'PHP Version', 'contact-form-7-style' ) . "</td>";
133
+ if ( function_exists( 'phpversion' ) ) :
134
+
135
+ $php_version = phpversion();
136
+
137
+ if ( version_compare( $php_version, '5.6', '<' ) ) {
138
+ $table .= '<td><mark class="error">' . sprintf( __( '%s - WordPress recommends a minimum PHP version of 5.6. See: %s', 'contact-form-7-style' ), esc_html( $php_version ), '<a href="https://wordpress.org/about/requirements/" target="_blank">' . __( 'WordPress Requirements', 'contact-form-7-style' ) . '</a>' ) . '</mark></td></tr>';
139
+ } else {
140
+ $table .= '<td><mark class="yes">' . esc_html( $php_version ) . '</mark></td></tr>';
141
+ }
142
+ else :
143
+ $table .= '<td>' . __( "Couldn't determine PHP version because phpversion() doesn't exist.", 'contact-form-7-style' ) . '</td></tr>';
144
+ endif;
145
+
146
+ if ( function_exists( 'ini_get' ) ) :
147
+
148
+ // PHP Post Max Size
149
+ $table .= "<tr><td>" . __( 'PHP Post Max Size:', 'contact-form-7-style' ) . "</td>";
150
+ $table .= "<td>" . size_format( cf7style_let_to_num( ini_get( 'post_max_size' ) ) ) . "</td></tr>";
151
+
152
+ endif;
153
+
154
+ // MySQL Version
155
+
156
+ /** @global wpdb $wpdb */
157
+ global $wpdb;
158
+
159
+ $table .= "<tr><td>" . __( 'MySQL Version:', 'contact-form-7-style' ) . "</td>";
160
+ $table .= "<td>" . $wpdb->db_version() . "</td></tr>";
161
+
162
+ // Max Upload Size
163
+ $table .= "<tr><td>" . __( 'Max Upload Size', 'contact-form-7-style' ) . "</td>";
164
+ $table .= "<td>" . size_format( wp_max_upload_size() ) . "</td></tr>";
165
+
166
+ // Default Timezone
167
+ $default_timezone = date_default_timezone_get();
168
+
169
+ $table .= "<tr><td>" . __( 'Default Timezone:', 'contact-form-7-style' ) . "</td>";
170
+ $table .= '<td>' . $default_timezone . '</td></tr>';
171
+
172
+ $table .= $table_end;
173
+
174
+
175
+ // Active Plugins
176
+ $active_plugins_count = count( (array) get_option( 'active_plugins' ) );
177
+
178
+ $table .= $table_start;
179
+ $table .= '<thead><tr><th colspan="2"><strong>' . __( "Active Plugins", "contact-form-7-style" ) . ' (' . $active_plugins_count . ')</strong></th></tr></thead>';
180
+
181
+ $active_plugins = (array) get_option( 'active_plugins', array() );
182
+
183
+ if ( is_multisite() ) {
184
+ $network_activated_plugins = array_keys( get_site_option( 'active_sitewide_plugins', array() ) );
185
+ $active_plugins = array_merge( $active_plugins, $network_activated_plugins );
186
+ }
187
+
188
+ foreach ( $active_plugins as $plugin ) {
189
+
190
+ $plugin_data = @get_plugin_data( WP_PLUGIN_DIR . '/' . $plugin );
191
+ $dirname = dirname( $plugin );
192
+ $version_string = '';
193
+ $network_string = '';
194
+
195
+ if ( ! empty( $plugin_data['Name'] ) ) {
196
+
197
+ // Link the plugin name to the plugin url if available.
198
+ $plugin_name = esc_html( $plugin_data['Name'] );
199
+
200
+ if ( ! empty( $plugin_data['PluginURI'] ) ) {
201
+ $plugin_name = '<a href="' . esc_url( $plugin_data['PluginURI'] ) . '" title="' . esc_attr__( 'Visit plugin homepage' , 'contact-form-7-style' ) . '" target="_blank">' . $plugin_name . '</a>';
202
+ }
203
+
204
+ $table .= "<tr><td>" . $plugin_name. "</td>";
205
+ $table .= "<td>" . sprintf( _x( 'by %s', 'by author', 'contact-form-7-style' ), $plugin_data['Author'] ) . ' &ndash; ' . __( 'Version', 'contact-form-7-style' ) . ' ' . esc_html( $plugin_data['Version'] ) . $version_string . $network_string . "</td></tr>";
206
+
207
+ }
208
+
209
+ }
210
+
211
+ $table .= $table_end;
212
+
213
+
214
+ // Active Theme
215
+ $active_theme = wp_get_theme();
216
+
217
+ $table .= $table_start;
218
+ $table .= '<thead><tr><th colspan="2"><strong>' . __( "Theme", "contact-form-7-style" ) . '</strong></th></tr></thead>';
219
+
220
+ $table .= "<tr><td>" . __( 'Name:', 'contact-form-7-style' ) . "</td>";
221
+ $table .= "<td>" . $active_theme->Name . "</td></tr>";
222
+
223
+ $table .= "<tr><td>" . __( 'Version:', 'contact-form-7-style' ) . "</td>";
224
+ $table .= "<td>" . $active_theme->Version . "</td></tr>";
225
+
226
+ $table .= "<tr><td>" . __( 'Child Theme:', 'contact-form-7-style' ) . "</td>";
227
+ $table .= "<td>" . ( ( is_child_theme() ) ? 'Yes' : 'No' ) . "</td></tr>";
228
+
229
+ $table .= "<tr><td>" . __( 'Theme URL:', 'contact-form-7-style' ) . "</td>";
230
+ $table .= "<td>" . $active_theme->get( 'ThemeURI' ) . "</td></tr>";
231
+
232
+ $table .= $table_end;
233
+
234
+ $html .= $table;
235
+ $html .= '</div>';
236
+
237
+ echo $html;
238
+ }
239
+
240
+ add_action( 'admin_menu', 'cf7style_register_help_submenu_page' );
241
+
242
+ function cf7style_register_help_submenu_page() {
243
+ add_submenu_page(
244
+ 'edit.php?post_type=cf7_style',
245
+ 'System Status',
246
+ 'System Status',
247
+ 'manage_options',
248
+ 'system-status',
249
+ 'cf7style_system_status'
250
+ );
251
+ }
252
+
253
+
254
+ /**
255
+ * Send status report
256
+ */
257
+
258
+ function cf7_style_send_status_report() {
259
+
260
+ $name = sanitize_text_field( $_POST['name'] );
261
+ $email = sanitize_email( $_POST['email'] );
262
+ $message = sanitize_text_field( $_POST['message'] );
263
+ $site_name = get_bloginfo( 'name' );
264
+
265
+ $to = 'cf7style@gmail.com';
266
+ $subject = __( 'CF7 Style System Status', 'contact-form-7-style' ) . " - {$site_name}";
267
+ $body = wp_kses_post( $_POST['report'] );
268
+ $body .= "<table><tr><td>Name: " . $name . "</td></tr>";
269
+ $body .= "<tr><td>Email: " . $email . "</td></tr>";
270
+ $body .= "<tr><td>Message: " . $message . "</td></tr></table>";
271
+ $headers = array( 'Content-Type: text/html; charset=UTF-8' );
272
+
273
+ $wp_mail = wp_mail( $to, $subject, $body, $headers );
274
+
275
+ // Auto-response
276
+ $auto_response = "<table><tr><td>" . __( 'Hey there', 'contact-form-7-style' ) . ",</td></tr><tr><td></td></tr>";
277
+ $auto_response .= "<tr><td>" . __( 'Thank you for using Contact Form 7 Style', 'contact-form-7-style' ) . ".</td></tr>";
278
+ $auto_response .= "<tr><td>" . __( 'One of our consultants will reply as soon as possible', 'contact-form-7-style' ) . ".</td></tr>";
279
+ $auto_response .= "<tr><td></td></tr><tr><td></td></tr>";
280
+ $auto_response .= "<tr style='font-size: 13px;'><td>" . __( 'Thank you!', 'contact-form-7-style' ) . "</td></tr>";
281
+ $auto_response .= "<tr style='font-size: 13px;'><td>" . __( 'Contact Form 7 Style Support Team', 'contact-form-7-style' ) . "</td></tr><tr><td></td></tr></table>";
282
+
283
+ $auto_response .= "<table style='font-size: 12px; color: #777;'>";
284
+ $auto_response .= "<tr><td></td></tr><tr><td></td></tr>";
285
+ $auto_response .= "<tr><td>" . __( 'If you like this plugin we hope that you will help support our continued development', 'contact-form-7-style' ) . ".</td></tr>";
286
+ $auto_response .= "<tr><td>" . __( 'The two best ways to offer your support is to', 'contact-form-7-style' ) . " <a href='http://cf7style.com/back-this-project/'>";
287
+ $auto_response .= __( 'send us a Donation', 'contact-form-7-style' ) . "</a>. ";
288
+ $auto_response .= __( 'Even $1 helps encourage us to do more', 'contact-form-7-style' ) . ".</td></tr>";
289
+ $auto_response .= "<tr><td>" . __( 'If you can’t donate, please help us reach our 5-star rating by', 'contact-form-7-style' );
290
+ $auto_response .= " <a href='https://wordpress.org/support/view/plugin-reviews/contact-form-7-style#postform'>" . __( 'rating this plugin', 'contact-form-7-style' ) . "</a>.";
291
+ $auto_response .= "</td></tr><tr><td></td></tr>";
292
+ $auto_response .= "<tr><td>" . __( 'All contributions will be gratefully acknowledged', 'contact-form-7-style' ) . "!</td></tr></table>";
293
+
294
+ $wp_mail2 = wp_mail( $email, $subject, $auto_response, $headers );
295
+
296
+ if( false === $wp_mail ) {
297
+ echo 'error';
298
+ } else {
299
+ set_transient( 'cf7style_system_report', 'sent', DAY_IN_SECONDS );
300
+ echo 'success';
301
+ }
302
+
303
+ wp_die();
304
+ }
305
+ add_action( 'wp_ajax_cf7_style_send_status_report', 'cf7_style_send_status_report' );
inc/taxonomy_filters_add.php CHANGED
@@ -1,32 +1,32 @@
1
- <?php
2
-
3
- if ( !defined( 'ABSPATH' ) ) {
4
- exit;
5
- }
6
-
7
- function cf7_style_add_taxonomy_filters() {
8
- global $typenow;
9
- // an array of all the taxonomyies you want to display. Use the taxonomy name or slug
10
- $taxonomies = array( 'style_category' );
11
- // must set this to the post type you want the filter(s) displayed on
12
- if( $typenow == 'cf7_style' ){
13
- foreach ( $taxonomies as $tax_slug ) {
14
- $tax_obj = get_taxonomy( $tax_slug );
15
-
16
- $tax_name = $tax_obj->labels->name;
17
- $terms = get_terms( $tax_slug );
18
- if( count( $terms ) > 0 ) {
19
- echo "<select name='$tax_slug' id='$tax_slug' class='postform'>";
20
- echo "<option value=''>Show All $tax_name</option>";
21
- foreach ( $terms as $term ) {
22
- $resultA = "<option value='".$term->slug."' selected='selected'>".$term->name .' (' . $term->count .')'."</option>";
23
- $resultB = "<option value='".$term->slug."'>".$term->name .' (' . $term->count .')'."</option>";
24
- echo ( isset( $_GET[$tax_slug] ) ) ? ( ( $_GET[$tax_slug] == $term->slug ) ? $resultA : $resultB ) : $resultB;
25
- }
26
- echo "</select>";
27
- }
28
- }
29
- }
30
- }// end cf7_style_add_taxonomy_filters
31
-
32
  add_action( 'restrict_manage_posts', 'cf7_style_add_taxonomy_filters' );
1
+ <?php
2
+
3
+ if ( !defined( 'ABSPATH' ) ) {
4
+ exit;
5
+ }
6
+
7
+ function cf7_style_add_taxonomy_filters() {
8
+ global $typenow;
9
+ // an array of all the taxonomyies you want to display. Use the taxonomy name or slug
10
+ $taxonomies = array( 'style_category' );
11
+ // must set this to the post type you want the filter(s) displayed on
12
+ if( $typenow == 'cf7_style' ){
13
+ foreach ( $taxonomies as $tax_slug ) {
14
+ $tax_obj = get_taxonomy( $tax_slug );
15
+
16
+ $tax_name = $tax_obj->labels->name;
17
+ $terms = get_terms( $tax_slug );
18
+ if( count( $terms ) > 0 ) {
19
+ echo "<select name='$tax_slug' id='$tax_slug' class='postform'>";
20
+ echo "<option value=''>Show All $tax_name</option>";
21
+ foreach ( $terms as $term ) {
22
+ $resultA = "<option value='".$term->slug."' selected='selected'>".$term->name .' (' . $term->count .')'."</option>";
23
+ $resultB = "<option value='".$term->slug."'>".$term->name .' (' . $term->count .')'."</option>";
24
+ echo ( isset( $_GET[$tax_slug] ) ) ? ( ( $_GET[$tax_slug] == $term->slug ) ? $resultA : $resultB ) : $resultB;
25
+ }
26
+ echo "</select>";
27
+ }
28
+ }
29
+ }
30
+ }// end cf7_style_add_taxonomy_filters
31
+
32
  add_action( 'restrict_manage_posts', 'cf7_style_add_taxonomy_filters' );
js/frontend.js CHANGED
@@ -1,43 +1,43 @@
1
- /*
2
- jQuery functions for the Front end area
3
- */
4
- jQuery(document).ready( function( $ ) {
5
- // Valentine's Day Classic
6
- $(".valentines-day-classic").prepend("<div class='heart'></div>");
7
-
8
- //valentine's Day Rose
9
- if( $(".valentines-day-roses").length > 0 ){
10
- $(".valentines-day-roses").append("<div class='letter-box'></div>").find("input, select").parents('p').appendTo($(".letter-box"));
11
- }
12
-
13
-
14
- //valentine's Day Birds
15
- $('.valentines-day-birds').wrap("<div class='valentines-day-birds-container'></div>");
16
- $('.valentines-day-birds').prepend("<div class='bg-header'></div>").append("<div class='bg-bottom'></div>");
17
-
18
- // Valentine's Day Blue Birds
19
- $('.valentines-day-blue-birds').prepend('<div class="header"></div>').append('<div class="footer"></div>');
20
-
21
-
22
- // Xmas Classic
23
- $('.christmas-classic').wrap("<div class='christmas-classic-container'></div>");
24
- $('.christmas-classic').prepend('<div class="header"></div><div class="left"></div>').append('<div class="footer"></div>');
25
-
26
- // Xmas Red
27
- $('.christmas-red').wrap("<div class='christmas-red-container'></div>");
28
- $('.christmas-red').prepend('<div class="header"></div><div class="left"></div>').append('<div class="footer"></div>');
29
- $('.christmas-red .wpcf7-radio .wpcf7-list-item').first().addClass('active');
30
- $('.christmas-red .wpcf7-radio .wpcf7-list-item input').on( 'click', function() {
31
- $('.christmas-red .wpcf7-radio .wpcf7-list-item, .christmas-red .wpcf7-radio .wpcf7-list-item label').removeClass('active');
32
- $(this).parent().addClass('active');
33
- });
34
-
35
- $('.christmas-red .wpcf7-checkbox .wpcf7-list-item input').on( 'click', function() {
36
- $(this).parent().toggleClass('active');
37
- });
38
-
39
- // Xmas Simple
40
- $('.christmas-simple').wrap("<div class='christmas-simple-container'></div>");
41
- $('.christmas-simple').prepend( '<div class="header"></div><div class="middle"></div><div class="ribbon"></div>' ).append('<div class="footer"></div>');
42
-
43
  });
1
+ /*
2
+ jQuery functions for the Front end area
3
+ */
4
+ jQuery(document).ready( function( $ ) {
5
+ // Valentine's Day Classic
6
+ $(".valentines-day-classic").prepend("<div class='heart'></div>");
7
+
8
+ //valentine's Day Rose
9
+ if( $(".valentines-day-roses").length > 0 ){
10
+ $(".valentines-day-roses").append("<div class='letter-box'></div>").find("input, select").parents('p').appendTo($(".letter-box"));
11
+ }
12
+
13
+
14
+ //valentine's Day Birds
15
+ $('.valentines-day-birds').wrap("<div class='valentines-day-birds-container'></div>");
16
+ $('.valentines-day-birds').prepend("<div class='bg-header'></div>").append("<div class='bg-bottom'></div>");
17
+
18
+ // Valentine's Day Blue Birds
19
+ $('.valentines-day-blue-birds').prepend('<div class="header"></div>').append('<div class="footer"></div>');
20
+
21
+
22
+ // Xmas Classic
23
+ $('.christmas-classic').wrap("<div class='christmas-classic-container'></div>");
24
+ $('.christmas-classic').prepend('<div class="header"></div><div class="left"></div>').append('<div class="footer"></div>');
25
+
26
+ // Xmas Red
27
+ $('.christmas-red').wrap("<div class='christmas-red-container'></div>");
28
+ $('.christmas-red').prepend('<div class="header"></div><div class="left"></div>').append('<div class="footer"></div>');
29
+ $('.christmas-red .wpcf7-radio .wpcf7-list-item').first().addClass('active');
30
+ $('.christmas-red .wpcf7-radio .wpcf7-list-item input').on( 'click', function() {
31
+ $('.christmas-red .wpcf7-radio .wpcf7-list-item, .christmas-red .wpcf7-radio .wpcf7-list-item label').removeClass('active');
32
+ $(this).parent().addClass('active');
33
+ });
34
+
35
+ $('.christmas-red .wpcf7-checkbox .wpcf7-list-item input').on( 'click', function() {
36
+ $(this).parent().toggleClass('active');
37
+ });
38
+
39
+ // Xmas Simple
40
+ $('.christmas-simple').wrap("<div class='christmas-simple-container'></div>");
41
+ $('.christmas-simple').prepend( '<div class="header"></div><div class="middle"></div><div class="ribbon"></div>' ).append('<div class="footer"></div>');
42
+
43
  });
misc/tracking.php ADDED
@@ -0,0 +1,149 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * on deactivation, if tracking is on, it will send info to plugin authors that the plugin is no longer active
4
+ */
5
+
6
+ if ( !defined( 'ABSPATH' ) ) {
7
+ exit;
8
+ }
9
+
10
+
11
+ define( 'CF7_STYLE_PLUGIN_PATH', WP_PLUGIN_DIR . '/contact-form-7-style/' );
12
+ if ( !function_exists( 'cf7_style_announce_authors_about_deactivation' ) ) {
13
+ function cf7_style_announce_authors_about_deactivation () {
14
+ $allowedornot = get_option( 'cf7_style_allow_tracking' );
15
+ if( '1' == $allowedornot){
16
+ cf7style_send_tracking_info( $allowedornot, '1' );
17
+ }
18
+
19
+ }
20
+ register_deactivation_hook( CF7_STYLE_PLUGIN_PATH . 'cf7-style.php' , 'cf7_style_announce_authors_about_deactivation' );
21
+ }
22
+ /*
23
+ * on activation, if tracking is on, it will send info to plugin authors that the plugin is active.
24
+ */
25
+ if ( !function_exists( 'cf7_style_announce_authors_about_activation' ) ) {
26
+ function cf7_style_announce_authors_about_activation () {
27
+ $allowedornot = get_option( 'cf7_style_allow_tracking' );
28
+ if( '1' == $allowedornot){
29
+ cf7style_send_tracking_info( $allowedornot, '1' );
30
+ }
31
+ }
32
+ register_activation_hook( CF7_STYLE_PLUGIN_PATH . 'cf7-style.php' , 'cf7_style_announce_authors_about_activation' );
33
+ }
34
+ /*
35
+ * enque pointer
36
+ */
37
+ if ( !function_exists( 'cf7_style_tracking_enque_script' ) ) {
38
+ add_action( 'admin_enqueue_scripts', 'cf7_style_tracking_enque_script' );
39
+ function cf7_style_tracking_enque_script() {
40
+ $activeordismiss = get_option( 'cf7_style_allow_tracking' );
41
+ if ( $activeordismiss !== '0' && $activeordismiss !== '1' ) {
42
+ wp_enqueue_style( 'wp-pointer' );
43
+ wp_enqueue_script( 'wp-pointer' );
44
+ add_action( 'admin_print_footer_scripts', 'cf7_style_print_tooltip' );
45
+ }
46
+ }
47
+ }
48
+
49
+ /*
50
+ * prints the tooltip
51
+ */
52
+ if ( !function_exists( 'cf7_style_print_tooltip' ) ) {
53
+ function cf7_style_print_tooltip() {
54
+ $pointer_content = '<h3>'.__( "Thank You for choosing<br/>Contact Form 7 Style!", "contact-form-7-style" ).'</h3>';
55
+ $pointer_content .= '<p>'.__( "Want to help make CF7 Style even more better? Allow Us to collect non-sensitive diagnostic data.", "contact-form-7-style" ).'</p>';
56
+ $pointer_content .= '<p>'.__( "We will only collect your website URL, WordPress version, CF7Style plugin version and active status.", "contact-form-7-style" ).'</p>';
57
+ $pointer_content .= '<p><label>'.__( "Allow collecting data:", "contact-form-7-style" ).'<input id="cf7_style_allow_tracking" type="checkbox" checked="checked" value="1" name="cf7_style_allow_tracking" /></label> </p>'; ?>
58
+ <script type="text/javascript">
59
+ //<![CDATA[
60
+ jQuery(document).ready( function($) {
61
+ $('.menu-icon-cf7_style').eq(0).pointer({
62
+ pointerClass: 'cf7style-pointer',
63
+ content: '<?php echo $pointer_content; ?>',
64
+ position: 'left',
65
+ close: function() {
66
+ $('.cf7style-pointer').hide();
67
+ return false;
68
+ }
69
+ }).pointer('open');
70
+ });
71
+ //]]>
72
+ </script>
73
+ <style type="text/css">
74
+ .cf7style-pointer .wp-pointer-arrow {
75
+ top: 20px;
76
+ left: -1px;
77
+ }
78
+ </style>
79
+ <?php
80
+ }
81
+ }
82
+
83
+ /*
84
+ * allow tracking set option
85
+ */
86
+ if ( !function_exists( 'cf7_style_allow_tracking' ) ) {
87
+ function cf7_style_allow_tracking() {
88
+ if ( $_POST['action'] == 'cf7_style_allow_tracking' ) {
89
+ if ( !is_numeric( $_POST['cf7_style_allow_tracking'] ) ) {
90
+ die();
91
+ }
92
+ $allowedornot = $_POST['cf7_style_allow_tracking'];
93
+ if ( $allowedornot == '1' ) {
94
+ update_option( 'cf7_style_allow_tracking', '1' );
95
+ cf7style_send_tracking_info( $allowedornot, '1' );
96
+ }
97
+ die();
98
+ }
99
+ }
100
+ add_action( 'wp_ajax_cf7_style_allow_tracking', 'cf7_style_allow_tracking' );
101
+ }
102
+ if ( !function_exists( 'cf7_style_show_tracking' ) ) {
103
+ function cf7_style_show_tracking() {
104
+ if ( $_POST['action'] == 'cf7_style_show_tracking' ) {
105
+ if ( !is_numeric( $_POST['cf7_style_allow_tracking'] ) ) {
106
+ die();
107
+ }
108
+ $allowedornot = $_POST['cf7_style_allow_tracking'];
109
+ if ( $allowedornot == '0' ) {
110
+ update_option( 'cf7_style_allow_tracking', '0' );
111
+ }
112
+ die();
113
+ }
114
+ }
115
+ add_action( 'wp_ajax_cf7_style_show_tracking', 'cf7_style_show_tracking' );
116
+ }
117
+
118
+
119
+ /*
120
+ * send traciking info function
121
+ */
122
+ if ( !function_exists( 'cf7style_send_tracking_info' ) ) {
123
+ function cf7style_send_tracking_info( $allowedornot, $activated ) {
124
+ $url = 'http://cf7style.com/tracking/index.php';
125
+ $plugin_folder = get_plugins( '/' . 'contact-form-7-style' );
126
+ $plugin_file = 'cf7-style.php';
127
+ $plugindata = $plugin_folder[$plugin_file]['Version'];
128
+ $multi = ( is_multisite() ? '1' : '0' );
129
+ $data = array (
130
+ 'allowed' => $allowedornot,
131
+ 'wpversion' => get_bloginfo('version'),
132
+ 'styleversion' => $plugindata,
133
+ 'siteurl' => site_url(),
134
+ 'multisite' => $multi,
135
+ 'activated' => $activated
136
+ );
137
+ if(function_exists('curl_version')){
138
+ $cf7curl = curl_init();
139
+ $Curl = $url.'?method=withstyle&data='.base64_encode(json_encode($data)).'&format=json';
140
+ $curlconfig = array (
141
+ CURLOPT_URL => $Curl,
142
+ CURLOPT_RETURNTRANSFER => true
143
+ );
144
+ curl_setopt_array( $cf7curl, $curlconfig );
145
+ $output = curl_exec($cf7curl);
146
+ curl_close($cf7curl);
147
+ }
148
+ }
149
+ }
misc/welcome.php CHANGED
@@ -1,78 +1,78 @@
1
- <?php
2
- /*
3
- * Welcome panel html
4
- */
5
-
6
- if ( !defined( 'ABSPATH' ) ) {
7
- exit;
8
- }
9
-
10
- if ( !function_exists( 'cf7_style_show_welcome_panel' ) ) {
11
- function cf7_style_show_welcome_panel() {
12
- $welm = get_option( 'cf7_style_welcome' );
13
- if( $welm == "show_box") {
14
- ?>
15
- <div class="wrap welcome-container">
16
- <table class="wp-list-table fixed cf7style-welcome-panel ">
17
- <tbody>
18
- <tr>
19
- <td>
20
- <h3><?php _e( "Need support?", "contact-form-7-style" ); ?></h3>
21
- <p><?php _e( "Support can be found", "contact-form-7-style" ); ?> <a href="https://wordpress.org/support/plugin/contact-form-7-style" target="_blank"><?php _e( "here", "contact-form-7-style" ); ?></a> <?php _e( "or you can", "contact-form-7-style" ); ?> <a href="http://cf7style.com/contact/" target="_blank"><?php _e( "contact us", "contact-form-7-style" ); ?></a> <?php _e( "for any related question!", "contact-form-7-style" ); ?></p>
22
- <p><?php _e( "Thank you for using Contact Form 7 Style!", "contact-form-7-style" ); ?></p>
23
- </td>
24
- <td>
25
- <ul>
26
- <li><h3><?php _e( "Get Started", "contact-form-7-style" ); ?></h3></li>
27
- <li><a href="<?php echo admin_url('post-new.php?post_type=cf7_style'); ?>"><?php _e( "Creating you first custom template", "contact-form-7-style" ); ?></a></li>
28
- <li><a href="<?php echo admin_url('edit.php?post_type=cf7_style'); ?>"><?php _e( "Using predefined templates", "contact-form-7-style" ); ?></a></li>
29
- <li><a href="<?php echo admin_url('edit.php?post_type=cf7_style&page=cf7style-css-editor'); ?>"><?php _e( "Adding Extra CSS", "contact-form-7-style" ); ?></a></li>
30
- </ul>
31
- </td>
32
- <td>
33
- <ul>
34
- <li>
35
- <h3><?php _e( "Information", "contact-form-7-style" ); ?></h3>
36
- </li>
37
- <li><a href="http://cf7style.com/#team" target="_blank"><?php _e( "Who we are?", "contact-form-7-style" ); ?></a></li>
38
- <li><a href="http://cf7style.com/#why-cf7style" target="_blank"><?php _e( "Why use our plugin?", "contact-form-7-style" ); ?></a></li>
39
- <li><a href="http://cf7style.com/faq/" target="_blank"><?php _e( "FAQ", "contact-form-7-style" ); ?></a></li>
40
- </ul>
41
- </td>
42
- <td>
43
- <h3><?php _e( "Buy us a coffee", "contact-form-7-style" ); ?></h3>
44
- <p><?php _e( "Supporting and developing this plugin takes us a lot of effort and energy.", "contact-form-7-style" ); ?></p>
45
- <p><?php _e( "You would help us a lot if you make a donation. We thank you in advance.", "contact-form-7-style" ); ?></p>
46
- </td>
47
- <td>
48
- <h3>&nbsp;</h3>
49
- <a href="http://cf7style.com/back-this-project/" target="_blank">
50
- <?php echo '<img src="' . plugins_url( 'contact-form-7-style/admin/images/donate1.jpg' ) . '" > ';?>
51
- </a>
52
- </td>
53
- </tr>
54
- <tr>
55
- <td colspan="5">
56
- <a class="close-cf7-panel" href="#"><?php _e( "Dismiss", "contact-form-7-style" ); ?></a>
57
- </td>
58
- </tr>
59
- </tbody>
60
- </table>
61
- </div>
62
- <?php }
63
- }
64
- }
65
-
66
- /*
67
- * Welcome panel initialization on Cf7Style screen
68
- */
69
- if ( !function_exists( 'cf7style_screen_page' ) ) {
70
- function cf7style_screen_page() {
71
- $screen = get_current_screen();
72
- if ( $screen->id == 'edit-cf7_style' ) {
73
- add_action( 'admin_notices' , 'cf7_style_show_welcome_panel' );
74
- }
75
- }
76
- add_action( 'current_screen', 'cf7style_screen_page' );
77
- }
78
-
1
+ <?php
2
+ /*
3
+ * Welcome panel html
4
+ */
5
+
6
+ if ( !defined( 'ABSPATH' ) ) {
7
+ exit;
8
+ }
9
+
10
+ if ( !function_exists( 'cf7_style_show_welcome_panel' ) ) {
11
+ function cf7_style_show_welcome_panel() {
12
+ $welm = get_option( 'cf7_style_welcome' );
13
+ if( $welm == "show_box") {
14
+ ?>
15
+ <div class="wrap welcome-container">
16
+ <table class="wp-list-table fixed cf7style-welcome-panel ">
17
+ <tbody>
18
+ <tr>
19
+ <td>
20
+ <h3><?php _e( "Need support?", "contact-form-7-style" ); ?></h3>
21
+ <p><?php _e( "Support can be found", "contact-form-7-style" ); ?> <a href="https://wordpress.org/support/plugin/contact-form-7-style" target="_blank"><?php _e( "here", "contact-form-7-style" ); ?></a> <?php _e( "or you can", "contact-form-7-style" ); ?> <a href="http://cf7style.com/contact/" target="_blank"><?php _e( "contact us", "contact-form-7-style" ); ?></a> <?php _e( "for any related question!", "contact-form-7-style" ); ?></p>
22
+ <p><?php _e( "Thank you for using Contact Form 7 Style!", "contact-form-7-style" ); ?></p>
23
+ </td>
24
+ <td>
25
+ <ul>
26
+ <li><h3><?php _e( "Get Started", "contact-form-7-style" ); ?></h3></li>
27
+ <li><a href="<?php echo admin_url('post-new.php?post_type=cf7_style'); ?>"><?php _e( "Creating you first custom template", "contact-form-7-style" ); ?></a></li>
28
+ <li><a href="<?php echo admin_url('edit.php?post_type=cf7_style'); ?>"><?php _e( "Using predefined templates", "contact-form-7-style" ); ?></a></li>
29
+ <li><a href="<?php echo admin_url('edit.php?post_type=cf7_style&page=cf7style-css-editor'); ?>"><?php _e( "Adding Extra CSS", "contact-form-7-style" ); ?></a></li>
30
+ </ul>
31
+ </td>
32
+ <td>
33
+ <ul>
34
+ <li>
35
+ <h3><?php _e( "Information", "contact-form-7-style" ); ?></h3>
36
+ </li>
37
+ <li><a href="http://cf7style.com/#team" target="_blank"><?php _e( "Who we are?", "contact-form-7-style" ); ?></a></li>
38
+ <li><a href="http://cf7style.com/#why-cf7style" target="_blank"><?php _e( "Why use our plugin?", "contact-form-7-style" ); ?></a></li>
39
+ <li><a href="http://cf7style.com/faq/" target="_blank"><?php _e( "FAQ", "contact-form-7-style" ); ?></a></li>
40
+ </ul>
41
+ </td>
42
+ <td>
43
+ <h3><?php _e( "Buy us a coffee", "contact-form-7-style" ); ?></h3>
44
+ <p><?php _e( "Supporting and developing this plugin takes us a lot of effort and energy.", "contact-form-7-style" ); ?></p>
45
+ <p><?php _e( "You would help us a lot if you make a donation. We thank you in advance.", "contact-form-7-style" ); ?></p>
46
+ </td>
47
+ <td>
48
+ <h3>&nbsp;</h3>
49
+ <a href="http://cf7style.com/back-this-project/" target="_blank">
50
+ <?php echo '<img src="' . plugins_url( 'contact-form-7-style/admin/images/donate1.jpg' ) . '" > ';?>
51
+ </a>
52
+ </td>
53
+ </tr>
54
+ <tr>
55
+ <td colspan="5">
56
+ <a class="close-cf7-panel" href="#"><?php _e( "Dismiss", "contact-form-7-style" ); ?></a>
57
+ </td>
58
+ </tr>
59
+ </tbody>
60
+ </table>
61
+ </div>
62
+ <?php }
63
+ }
64
+ }
65
+
66
+ /*
67
+ * Welcome panel initialization on Cf7Style screen
68
+ */
69
+ if ( !function_exists( 'cf7style_screen_page' ) ) {
70
+ function cf7style_screen_page() {
71
+ $screen = get_current_screen();
72
+ if ( $screen->id == 'edit-cf7_style' ) {
73
+ add_action( 'admin_notices' , 'cf7_style_show_welcome_panel' );
74
+ }
75
+ }
76
+ add_action( 'current_screen', 'cf7style_screen_page' );
77
+ }
78
+
options.php CHANGED
@@ -1,141 +1,141 @@
1
- <?php
2
- /**
3
- * Contact Form 7 Style Options
4
- */
5
-
6
- if ( !defined( 'ABSPATH' ) ) {
7
- exit;
8
- }
9
-
10
- require_once 'plugin-options.php';
11
-
12
- /**
13
- * Get saved values
14
- */
15
-
16
- wp_nonce_field( 'cf_7_style_style_customizer_inner_custom_box', 'cf_7_style_customizer_custom_box_nonce' );
17
- $saved_values = maybe_unserialize(get_post_meta( $post->ID, 'cf7_style_custom_styler', true ));
18
- $saved_values = (empty($saved_values)) ? array() : $saved_values;
19
- $encoded_data = str_replace( "\"", "'", json_encode( $saved_values));
20
- $active_panel = get_post_meta( $post->ID, 'cf7_style_active_panel', 'form' );
21
- $active_panel = ( $active_panel=="" ) ? "form" : $active_panel;
22
- $form_tags = '<div id="form-tag">';
23
- $form_tags .= '<h4>'. __( "Choose element", 'contact-form-7-style' ).'</h4>';
24
- $form_panel = "";
25
- $form_index = 0;
26
- foreach( $elements as $property => $property_value ) {
27
- $selected_class = ( $active_panel == $property) ? ' button-primary' : '';
28
- $hidden_class = ( $active_panel != $property || ( $active_panel =="" && $form_index++ > 0)) ? ' hidden' : '';
29
- $form_tags .= "<a href='#' class='button".$selected_class."' data-property='".$property."'>" . $property_value['name'] . "</a>";
30
- $form_panel .= "<div class='". $property ."-panel panel".$hidden_class." clearfix'>";
31
- if( $property == $active_panel ) {
32
- if( $property_value['description'] != ""){
33
- $form_panel .= '<h4 class="description-title">'.$property_value['description'].'</h4>';
34
- }
35
- foreach( $property_value['settings'] as $sub_property_key => $sub_property_value ) {
36
- $property = strtolower( $property );
37
- $sub_property_slug = strtolower( $options[$sub_property_value]['slug'] );
38
- $style_element_name = strtolower($options[$sub_property_value]['name']);
39
- $half_width_class = ( $style_element_name == "box sizing" || $style_element_name == "display" || $style_element_name == "position" || $style_element_name == "width" || $style_element_name == "height") ? "half-size" : "";
40
- $form_panel .= '<div class="element-styling '.$half_width_class.' '.$style_element_name.'"><h3><span>&lt;'.$property.'&gt;</span> '.$style_element_name . '</h3>';
41
- if( $options[$sub_property_value]['type'] ) {
42
- $form_panel .= "<ul>";
43
- foreach( $options[$sub_property_value]['type'] as $key => $value ) {
44
- if( $key != "comming-soon" ){
45
- $form_panel .= generate_property_fields( $key, $value, $property, $sub_property_slug, $saved_values, '');
46
- $form_panel .= generate_property_fields( $key, $value, $property, $sub_property_slug, $saved_values, '_hover');
47
- } else {
48
- $form_panel .= "<li></li>";
49
- }
50
- }
51
- $form_panel .= "</ul>";
52
- $form_panel .= "</div>";
53
- }
54
- }
55
- }
56
- $form_panel .= "</div>";
57
- }
58
- ?>
59
-
60
- <div class="generate-preview">
61
- <?php
62
- $form_args = array(
63
- 'post_type' => 'wpcf7_contact_form',
64
- 'posts_per_page' => -1,
65
- 'meta_key' => 'cf7_style_id',
66
- 'meta_value' => $post->ID
67
- );
68
- $indexter = 0;
69
- $form_el = array();
70
- $form_query = new WP_Query( $form_args );
71
- while ( $form_query->have_posts() ) : $form_query->the_post();
72
- $cur_title = get_the_title();
73
- $form_el[$indexter]['form'] = do_shortcode( '[contact-form-7 id="'.get_the_ID().'" title="'.$cur_title.'"]' );
74
- $form_el[$indexter++]['form_title'] = $cur_title;
75
- endwhile;
76
- wp_reset_postdata();
77
- $form_choose ="";
78
- if($indexter > 1){
79
- $form_choose = '<div class="choose-preview"><h4>'.__( "Choose form to preview:", 'contact-form-7-style' ).'</h4>';
80
- $form_choose .= '<select name="form-preview" id="form-preview">';
81
- foreach ($form_el as $key => $cur_form) {
82
- $form_choose .= '<option value="'.$key.'" '.selected($key,0,false).'>'.$cur_form['form_title'].'</option>';
83
- }
84
- $form_choose .= "</select></div>";
85
- }
86
- $form_tags .= '</div>';?>
87
- <div class="panel-options">
88
- <h3><?php echo __( "Customize form", 'contact-form-7-style' );?></h3>
89
- <?php echo $form_tags; ?>
90
- <div class="element-selector clearfix">
91
- <h4><?php echo __( "Choose element state", 'contact-form-7-style' ); ?></h4>
92
- <label><input type="radio" name="element-type" checked = "checked" value="normal" /> <?php echo __( "normal state", 'contact-form-7-style' ); ?></label>
93
- <label><input type="radio" name="element-type" value="hover" /> <?php echo __( ":hover state", 'contact-form-7-style' ); ?></label>
94
- <div class="hidden"><input type="text" name="cf7styleactivepane" value="<?php echo $active_panel; ?>"></div>
95
- <div class="hidden"><input type="text" name="cf7styleallvalues" value="<?php echo $encoded_data; ?>"></div>
96
- </div>
97
- <?php echo $form_panel; ?>
98
- <div class="loading hidden">
99
- <img src="<?php echo WPCF7S_LOCATION; ?>admin/images/gears.svg" alt="loading...">
100
- </div><!-- /.loading hidden -->
101
- <div class="decision hidden">
102
- <?php $check_screen = get_current_screen(); ?>
103
- <?php if( $check_screen->action == "add" && $check_screen->post_type == "cf7_style" ){ ?>
104
- <input type="submit" name="publish" class="button button-primary button-large save-btn" value="<?php echo __( 'Publish Style', 'contact-form-7-style' );?>">
105
- <?php } else { ?>
106
- <input name="save" type="submit" class="button button-primary button-large save-btn" value="<?php echo __( 'Update Style', 'contact-form-7-style' );?>">
107
- <?php } ?>
108
- <a href="#" class="button button-primary cancel-btn"><?php echo __( "Cancel", 'contact-form-7-style' );?></a>
109
- </div><!-- /.decision hidden -->
110
- </div>
111
- <div class='panel-header'>
112
-
113
- <h3><?php echo __( "Preview Area", 'contact-form-7-style' ); ?></h3>
114
- <?php echo $form_choose; ?>
115
- <div class='preview-form-tag' id="preview">
116
- <?php
117
- $indexter = 0;
118
-
119
- // Show default form when on first custom style edit
120
- if( empty( $form_el ) ) {
121
- echo "<p class='cf7style-no-forms-added'>" . __( 'Please check one of the forms above and press generate preview button to activate the preview mode.', 'contact-form-7-style' ) . "</p>";
122
- }
123
-
124
- foreach ( $form_el as $key => $cur_form ) {
125
- $extra_class= ($indexter++ != 0) ? 'hidden' : ''; ?>
126
- <div class="preview-form-container <?php echo $extra_class; ?>">
127
- <h4><?php echo $cur_form['form_title']; ?></h4>
128
- <?php echo $cur_form['form']; ?>
129
- </div>
130
- <?php } ?>
131
- </div>
132
- </div>
133
- </div>
134
- <?php $check_screen = get_current_screen(); ?>
135
- <div class="fixed-save-style">
136
- <?php if( $check_screen->action == "add" && $check_screen->post_type == "cf7_style" ){ ?>
137
- <input type="submit" name="publish" class="button button-primary button-large" value="<?php echo __( 'Publish Style', 'contact-form-7-style' );?>">
138
- <?php } else { ?>
139
- <input name="save" type="submit" class="button button-primary button-large" value="<?php echo __( 'Update Style', 'contact-form-7-style' );?>">
140
- <?php } ?>
141
  </div>
1
+ <?php
2
+ /**
3
+ * Contact Form 7 Style Options
4
+ */
5
+
6
+ if ( !defined( 'ABSPATH' ) ) {
7
+ exit;
8
+ }
9
+
10
+ require_once 'plugin-options.php';
11
+
12
+ /**
13
+ * Get saved values
14
+ */
15
+
16
+ wp_nonce_field( 'cf_7_style_style_customizer_inner_custom_box', 'cf_7_style_customizer_custom_box_nonce' );
17
+ $saved_values = maybe_unserialize(get_post_meta( $post->ID, 'cf7_style_custom_styler', true ));
18
+ $saved_values = (empty($saved_values)) ? array() : $saved_values;
19
+ $encoded_data = str_replace( "\"", "'", json_encode( $saved_values));
20
+ $active_panel = get_post_meta( $post->ID, 'cf7_style_active_panel', 'form' );
21
+ $active_panel = ( $active_panel=="" ) ? "form" : $active_panel;
22
+ $form_tags = '<div id="form-tag">';
23
+ $form_tags .= '<h4>'. __( "Choose element", 'contact-form-7-style' ).'</h4>';
24
+ $form_panel = "";
25
+ $form_index = 0;
26
+ foreach( $elements as $property => $property_value ) {
27
+ $selected_class = ( $active_panel == $property) ? ' button-primary' : '';
28
+ $hidden_class = ( $active_panel != $property || ( $active_panel =="" && $form_index++ > 0)) ? ' hidden' : '';
29
+ $form_tags .= "<a href='#' class='button".$selected_class."' data-property='".$property."'>" . $property_value['name'] . "</a>";
30
+ $form_panel .= "<div class='". $property ."-panel panel".$hidden_class." clearfix'>";
31
+ if( $property == $active_panel ) {
32
+ if( $property_value['description'] != ""){
33
+ $form_panel .= '<h4 class="description-title">'.$property_value['description'].'</h4>';
34
+ }
35
+ foreach( $property_value['settings'] as $sub_property_key => $sub_property_value ) {
36
+ $property = strtolower( $property );
37
+ $sub_property_slug = strtolower( $options[$sub_property_value]['slug'] );
38
+ $style_element_name = strtolower($options[$sub_property_value]['name']);
39
+ $half_width_class = ( $style_element_name == "box sizing" || $style_element_name == "display" || $style_element_name == "position" || $style_element_name == "width" || $style_element_name == "height") ? "half-size" : "";
40
+ $form_panel .= '<div class="element-styling '.$half_width_class.' '.$style_element_name.'"><h3><span>&lt;'.$property.'&gt;</span> '.$style_element_name . '</h3>';
41
+ if( $options[$sub_property_value]['type'] ) {
42
+ $form_panel .= "<ul>";
43
+ foreach( $options[$sub_property_value]['type'] as $key => $value ) {
44
+ if( $key != "comming-soon" ){
45
+ $form_panel .= generate_property_fields( $key, $value, $property, $sub_property_slug, $saved_values, '');
46
+ $form_panel .= generate_property_fields( $key, $value, $property, $sub_property_slug, $saved_values, '_hover');
47
+ } else {
48
+ $form_panel .= "<li></li>";
49
+ }
50
+ }
51
+ $form_panel .= "</ul>";
52
+ $form_panel .= "</div>";
53
+ }
54
+ }
55
+ }
56
+ $form_panel .= "</div>";
57
+ }
58
+ ?>
59
+
60
+ <div class="generate-preview">
61
+ <?php
62
+ $form_args = array(
63
+ 'post_type' => 'wpcf7_contact_form',
64
+ 'posts_per_page' => -1,
65
+ 'meta_key' => 'cf7_style_id',
66
+ 'meta_value' => $post->ID
67
+ );
68
+ $indexter = 0;
69
+ $form_el = array();
70
+ $form_query = new WP_Query( $form_args );
71
+ while ( $form_query->have_posts() ) : $form_query->the_post();
72
+ $cur_title = get_the_title();
73
+ $form_el[$indexter]['form'] = do_shortcode( '[contact-form-7 id="'.get_the_ID().'" title="'.$cur_title.'"]' );
74
+ $form_el[$indexter++]['form_title'] = $cur_title;
75
+ endwhile;
76
+ wp_reset_postdata();
77
+ $form_choose ="";
78
+ if($indexter > 1){
79
+ $form_choose = '<div class="choose-preview"><h4>'.__( "Choose form to preview:", 'contact-form-7-style' ).'</h4>';
80
+ $form_choose .= '<select name="form-preview" id="form-preview">';
81
+ foreach ($form_el as $key => $cur_form) {
82
+ $form_choose .= '<option value="'.$key.'" '.selected($key,0,false).'>'.$cur_form['form_title'].'</option>';
83
+ }
84
+ $form_choose .= "</select></div>";
85
+ }
86
+ $form_tags .= '</div>';?>
87
+ <div class="panel-options">
88
+ <h3><?php echo __( "Customize form", 'contact-form-7-style' );?></h3>
89
+ <?php echo $form_tags; ?>
90
+ <div class="element-selector clearfix">
91
+ <h4><?php echo __( "Choose element state", 'contact-form-7-style' ); ?></h4>
92
+ <label><input type="radio" name="element-type" checked = "checked" value="normal" /> <?php echo __( "normal state", 'contact-form-7-style' ); ?></label>
93
+ <label><input type="radio" name="element-type" value="hover" /> <?php echo __( ":hover state", 'contact-form-7-style' ); ?></label>
94
+ <div class="hidden"><input type="text" name="cf7styleactivepane" value="<?php echo $active_panel; ?>"></div>
95
+ <div class="hidden"><input type="text" name="cf7styleallvalues" value="<?php echo $encoded_data; ?>"></div>
96
+ </div>
97
+ <?php echo $form_panel; ?>
98
+ <div class="loading hidden">
99
+ <img src="<?php echo WPCF7S_LOCATION; ?>admin/images/gears.svg" alt="loading...">
100
+ </div><!-- /.loading hidden -->
101
+ <div class="decision hidden">
102
+ <?php $check_screen = get_current_screen(); ?>
103
+ <?php if( $check_screen->action == "add" && $check_screen->post_type == "cf7_style" ){ ?>
104
+ <input type="submit" name="publish" class="button button-primary button-large save-btn" value="<?php echo __( 'Publish Style', 'contact-form-7-style' );?>">
105
+ <?php } else { ?>
106
+ <input name="save" type="submit" class="button button-primary button-large save-btn" value="<?php echo __( 'Update Style', 'contact-form-7-style' );?>">
107
+ <?php } ?>
108
+ <a href="#" class="button button-primary cancel-btn"><?php echo __( "Cancel", 'contact-form-7-style' );?></a>
109
+ </div><!-- /.decision hidden -->
110
+ </div>
111
+ <div class='panel-header'>
112
+
113
+ <h3><?php echo __( "Preview Area", 'contact-form-7-style' ); ?></h3>
114
+ <?php echo $form_choose; ?>
115
+ <div class='preview-form-tag' id="preview">
116
+ <?php
117
+ $indexter = 0;
118
+
119
+ // Show default form when on first custom style edit
120
+ if( empty( $form_el ) ) {
121
+ echo "<p class='cf7style-no-forms-added'>" . __( 'Please check one of the forms above and press generate preview button to activate the preview mode.', 'contact-form-7-style' ) . "</p>";
122
+ }
123
+
124
+ foreach ( $form_el as $key => $cur_form ) {
125
+ $extra_class= ($indexter++ != 0) ? 'hidden' : ''; ?>
126
+ <div class="preview-form-container <?php echo $extra_class; ?>">
127
+ <h4><?php echo $cur_form['form_title']; ?></h4>
128
+ <?php echo $cur_form['form']; ?>
129
+ </div>
130
+ <?php } ?>
131
+ </div>
132
+ </div>
133
+ </div>
134
+ <?php $check_screen = get_current_screen(); ?>
135
+ <div class="fixed-save-style">
136
+ <?php if( $check_screen->action == "add" && $check_screen->post_type == "cf7_style" ){ ?>
137
+ <input type="submit" name="publish" class="button button-primary button-large" value="<?php echo __( 'Publish Style', 'contact-form-7-style' );?>">
138
+ <?php } else { ?>
139
+ <input name="save" type="submit" class="button button-primary button-large" value="<?php echo __( 'Update Style', 'contact-form-7-style' );?>">
140
+ <?php } ?>
141
  </div>
plugin-options.php CHANGED
@@ -1,230 +1,230 @@
1
- <?php
2
-
3
- if ( !defined( 'ABSPATH' ) ) {
4
- exit;
5
- }
6
-
7
- $request_json = wp_remote_get( WPCF7S_LOCATION.'admin/settings-setup.json' );
8
-
9
- if ( is_wp_error( $request_json ) || ( array_key_exists('response', $request_json ) && $request_json['response']['code'] != '200' ) ) {
10
- require WPCF7S_PLUGIN_DIR.'/admin/settings_setup.php';
11
- $options = json_decode( $setting_str, true );
12
- } else {
13
- $options = json_decode( wp_remote_retrieve_body( $request_json ) , true);
14
- }
15
-
16
-
17
-
18
- /**
19
- * Generate property fields
20
- */
21
-
22
- function generate_property_fields( $key, $std, $name, $type, $saved_values, $selector_type ) {
23
- $temp = '';
24
- /*Had to remove numbers which adds the UNIQUE keys!*/
25
- $title_addon = ($selector_type != "") ? str_replace('_', ' ', $selector_type): "";
26
- $hidden_element = ($selector_type != "") ? "class='hidden".$title_addon."-element'": "";
27
- $current_key = preg_replace('/[0-9]+/', '', strtolower( $key ) );
28
- switch ( $current_key ) {
29
- case 'color-picker':
30
- case 'input':
31
- $field_class = ($current_key == "input") ? "cf7-style-upload-field" : "cf7-style-color-field";
32
- $saved_one = (array_key_exists( $name . "_". $std["style"].$selector_type, $saved_values)) ? $saved_values[ $name . "_". $std["style"].$selector_type] : "";
33
- return "<li ".$hidden_element."><label for='". $name . "_". $std["style"] .$selector_type."'><strong>".$std["title"].$title_addon.":</strong></label>".(($current_key == "color-picker") ? "<span class='icon smaller'><i class='icon-eyedropper' aria-hidden='true'></i></span>" : "")."<input type='text' id='". $name . "_". $std["style"] .$selector_type."' name='cf7stylecustom[". $name . "_". $std["style"] .$selector_type."]' value='". $saved_one ."' class='".$field_class."' /></li>";
34
- break;
35
- case 'comming-soon':
36
- return "<li></li>";
37
- break;
38
- case 'numeric':
39
- $val = explode( " ", $std["property"] );
40
- $temp .= "<li ".$hidden_element.">";
41
- if( $std["property"] == "0 0 0 0"){
42
- if( $std["style"] == "border-radius"){
43
- $element= array( "top-left", "top-right-radius", "bottom-left-radius", "bottom-right-radius" );
44
- $temp .= "<label for='".$name . "_border-top-left-radius".$selector_type."'><strong>".$std["title"].":</strong>";
45
- } else {
46
- $element= array( "top", "right", "bottom", "left" );
47
- $labelos = explode( "-",$std["style"]);
48
- if( $std["style"] == "border-radius"){
49
- $ending = "-top-".$labelos[1].$selector_type;
50
- } else {
51
- $ending = "-top".$selector_type;
52
- }
53
- $temp .= "<label for='".$name . "_". $labelos[0].$ending."'><strong>".$std["title"].$title_addon.":</strong>";
54
- }
55
- }else {
56
- $temp .= "<label for='".$name . "_". $std["style"].$selector_type."'><strong>".$std["title"].$title_addon.":</strong>";
57
- }
58
- $incrementor = 0;
59
- $indexer = 0;
60
- $arrows = array('up', 'right', 'down' , 'left');
61
- $fonts = array( 'font-size' => 'text-height', 'line-height' => 'font', 'text-indent' => 'indent-right');
62
- foreach( $val as $elem_key => $elem_value ) {
63
- if( $std["property"] == "0 0 0 0"){
64
- /*Add new style properties if 4 value property inserted*/
65
- $newproperty = explode("-", $std["style"]);
66
- $endstyling = $element[ $incrementor];
67
- if( $std["style"] == "border-radius"){
68
- $endstyling = $element[ $incrementor ]."-".end($newproperty);
69
- }
70
- $std["style"] = $newproperty[0] ."-".$endstyling;
71
- $incrementor++;
72
- }
73
- $test = ( $std["style"] == "border-top" || $std["style"] == "border-right" || $std["style"] == "border-bottom" || $std["style"] == "border-left") ? '-width' : '' ;
74
- $saved_one = ( array_key_exists( $name . "_". $std["style"].$test.$selector_type, $saved_values)) ? $saved_values [ $name . "_". $std["style"].$test.$selector_type ] : "";
75
- switch ($type){
76
- case "width" : $temp .= '<span class="element-wrapper"><span class="icon"><i class="icon-resize-horizontal" aria-hidden="true"></i></span>'; break;
77
- case "height" : $temp .= '<span class="element-wrapper"><span class="icon"><i class="icon-resize-vertical" aria-hidden="true"></i></span>'; break;
78
- case "opacity" : $temp .= '<span class="element-wrapper"><span class="icon"><i class="icon-adjust" aria-hidden="true"></i></span>'; break;
79
- case "border" :
80
- case "margin" :
81
- case "padding": $temp .= '<span class="element-wrapper"><span class="icon"><i class="icon-'.$arrows[$indexer++].'" aria-hidden="true"></i></span>'; break;
82
- case "font" : $temp .= '<span class="element-wrapper"><span class="icon"><i class="icon-'.$fonts[$std["style"]].'" aria-hidden="true"></i></span>';break;
83
- }
84
- $min_val = ("margin" == $type) ? '-1000' : '0';
85
- $max_val = ("opacity" == $type) ? '1' : '1000';
86
- $step_value = ("opacity" == $type) ? '0.01' : '1';
87
- $temp .= "<input type='number' step='".$step_value."' min='".$min_val."' max='".$max_val."' id='". $name . "_". $std["style"].$test.$selector_type."' name='cf7stylecustom[". $name . "_". $std["style"].$test.$selector_type."]' value='". $saved_one ."' />";
88
- if( array_key_exists('unit', $std) ) {
89
- $temp .= "<select id='". $name . "_". $std["style"] .$test . "_unit".$selector_type."' name='cf7stylecustom[". $name . "_". $std["style"] .$test ."_unit".$selector_type."]'>";
90
-
91
- foreach( $std["unit"] as $unit_val ) {
92
- $saved_one_unit = ( array_key_exists( $name . "_". $std["style"]. "_unit".$selector_type, $saved_values) ) ? $saved_values[ $name . "_". $std["style"]. "_unit".$selector_type ] : "";
93
- $temp .= "<option ". selected( $saved_one_unit , $unit_val, false ) . ">". $unit_val ."</option>";
94
- }
95
-
96
- $temp .= "</select>";
97
- }
98
- switch ($type){
99
- case "width" :
100
- case "height" :
101
- case "border" :
102
- case "margin" :
103
- case "padding":
104
- case "opacity":
105
- case "font" : $temp .= '</span>';break;
106
- }
107
- }
108
- $temp .= "</label></li>";
109
- return $temp;
110
- break;
111
-
112
- case 'select':
113
- $fonts = array( 'font-style' => 'italic', 'font-weight' => 'bold', 'text-align' => 'align-center', 'text-decoration' => 'underline', 'text-transform' => 'header' );
114
- $temp .= "<li ".$hidden_element."><label for='".$name . "_" . $std["style"].$selector_type."'><strong>".$std["title"].$title_addon.":</strong>";
115
- switch ($type){
116
- case "font" : $temp .= '<span class="icon"><i class="icon-'.$fonts[$std["style"]].'" aria-hidden="true"></i></span>';break;
117
- }
118
- $temp .= "<select id='". $name . "_" . $std["style"].$selector_type. "' name='cf7stylecustom[". $name . "_" . $std["style"] .$selector_type."]'>";
119
- $temp .= '<option value="">'.__( "Choose value", 'contact-form-7-style' ).'</option>';
120
- foreach( $std["property"] as $key => $value ) {
121
- $saved_one = ( array_key_exists($name . "_". $std["style"].$selector_type, $saved_values) ) ? $saved_values[ $name . "_". $std["style"].$selector_type] : "";
122
- $temp .= "<option ". selected( $saved_one , $value, false ) . ">". $value ."</option>";
123
- }
124
- $temp .= "</select></label></li>";
125
- return $temp;
126
-
127
- break;
128
-
129
- default:
130
-
131
- break;
132
- }
133
-
134
- }
135
-
136
- /**
137
- * Elements
138
- */
139
-
140
- $sameElements = array( "width", "height", "background", "margin", "padding", "font", "border", "float", "display", "box-sizing" );
141
- $containerElements = array( "width", "height", "margin", "padding", "font", "border", "float", "box-sizing" );
142
- $placeholderElements = array( "placefont", "opacity" );
143
- $elements = array(
144
- 'form' => array(
145
- 'name' => 'form',
146
- 'description' => 'The Contact Form 7 form element\'s design can be modified below:',
147
- 'settings' => array("width", "height", "background", "margin", "padding", "border", "float", "box-sizing" )
148
- ),
149
- 'input' => array(
150
- 'name' => 'input',
151
- 'description' => 'This section allows styling of text, email, URL and contact numbers fields.',
152
- 'settings' => $sameElements
153
- ),
154
- 'textarea' => array(
155
- 'name' => 'text area',
156
- 'description' => 'This section allows styling the textarea fields.',
157
- 'settings' => $sameElements
158
- ),
159
- "p" => array(
160
- 'name' => 'text',
161
- 'description' => '',
162
- 'settings' => $containerElements
163
- ),
164
- "placeholder" => array(
165
- 'name' => 'placeholder',
166
- 'description' => 'This section allows styling the placholder element of the input fields if present',
167
- 'settings' => $placeholderElements
168
- ),
169
- 'label' => array(
170
- 'name' => 'input label',
171
- 'description' => 'This section allows styling the input label.',
172
- 'settings' => $containerElements
173
- ),
174
- 'fieldset' => array(
175
- 'name' => 'fieldset',
176
- 'description' => '',
177
- 'settings' => $containerElements
178
- ),
179
- 'submit' => array(
180
- 'name' => 'submit button',
181
- 'description' => 'This section allows styling the submit button.',
182
- 'settings' => $sameElements
183
- ),
184
- 'select' => array(
185
- 'name' => 'dropdown menu',
186
- 'description' => 'This section allows styling the dropdown menus.',
187
- 'settings' => $sameElements
188
- ),
189
- 'checkbox' => array(
190
- 'name' => 'checkboxes',
191
- 'description' => '',
192
- 'settings' => array( "width", "height" )
193
- ),
194
- 'radio' => array(
195
- 'name' => 'radio buttons',
196
- 'description' => '',
197
- 'settings' => array( "width", "height" )
198
- ),
199
- 'wpcf7-not-valid-tip' => array(
200
- 'name' => 'error messages',
201
- 'description' => 'There is a field that the sender must fill in, this message can be modified below.',
202
- 'settings' => $sameElements
203
- ),
204
- 'wpcf7-validation-errors' => array(
205
- 'name' => 'validation errors',
206
- 'description' => 'This section allows styling the error message when the user submits the whole form.',
207
- 'settings' => $sameElements
208
- ),
209
- 'wpcf7-mail-sent-ok' => array(
210
- 'name' => 'successfully sent message',
211
- 'description' => 'This section allows styling the message which appears on succesfull submit.',
212
- 'settings' => $sameElements
213
- ),
214
- 'acceptance' => array(
215
- 'name' => 'acceptance',
216
- 'description' => '',
217
- 'settings' => array("comming-soon")
218
- ),
219
- 'file' => array(
220
- 'name' => 'file',
221
- 'description' => '',
222
- 'settings' => array("comming-soon")
223
- ),
224
- 'quiz' => array(
225
- 'name' => 'quiz',
226
- 'description' => '',
227
- 'settings' => array("comming-soon")
228
- ),
229
- );
230
-
1
+ <?php
2
+
3
+ if ( !defined( 'ABSPATH' ) ) {
4
+ exit;
5
+ }
6
+
7
+ $request_json = wp_remote_get( WPCF7S_LOCATION.'admin/settings-setup.json' );
8
+
9
+ if ( is_wp_error( $request_json ) || ( array_key_exists('response', $request_json ) && $request_json['response']['code'] != '200' ) ) {
10
+ require WPCF7S_PLUGIN_DIR.'/admin/settings_setup.php';
11
+ $options = json_decode( $setting_str, true );
12
+ } else {
13
+ $options = json_decode( wp_remote_retrieve_body( $request_json ) , true);
14
+ }
15
+
16
+
17
+
18
+ /**
19
+ * Generate property fields
20
+ */
21
+
22
+ function generate_property_fields( $key, $std, $name, $type, $saved_values, $selector_type ) {
23
+ $temp = '';
24
+ /*Had to remove numbers which adds the UNIQUE keys!*/
25
+ $title_addon = ($selector_type != "") ? str_replace('_', ' ', $selector_type): "";
26
+ $hidden_element = ($selector_type != "") ? "class='hidden".$title_addon."-element'": "";
27
+ $current_key = preg_replace('/[0-9]+/', '', strtolower( $key ) );
28
+ switch ( $current_key ) {
29
+ case 'color-picker':
30
+ case 'input':
31
+ $field_class = ($current_key == "input") ? "cf7-style-upload-field" : "cf7-style-color-field";
32
+ $saved_one = (array_key_exists( $name . "_". $std["style"].$selector_type, $saved_values)) ? $saved_values[ $name . "_". $std["style"].$selector_type] : "";
33
+ return "<li ".$hidden_element."><label for='". $name . "_". $std["style"] .$selector_type."'><strong>".$std["title"].$title_addon.":</strong></label>".(($current_key == "color-picker") ? "<span class='icon smaller'><i class='icon-eyedropper' aria-hidden='true'></i></span>" : "")."<input type='text' id='". $name . "_". $std["style"] .$selector_type."' name='cf7stylecustom[". $name . "_". $std["style"] .$selector_type."]' value='". $saved_one ."' class='".$field_class."' /></li>";
34
+ break;
35
+ case 'comming-soon':
36
+ return "<li></li>";
37
+ break;
38
+ case 'numeric':
39
+ $val = explode( " ", $std["property"] );
40
+ $temp .= "<li ".$hidden_element.">";
41
+ if( $std["property"] == "0 0 0 0"){
42
+ if( $std["style"] == "border-radius"){
43
+ $element= array( "top-left", "top-right-radius", "bottom-left-radius", "bottom-right-radius" );
44
+ $temp .= "<label for='".$name . "_border-top-left-radius".$selector_type."'><strong>".$std["title"].":</strong>";
45
+ } else {
46
+ $element= array( "top", "right", "bottom", "left" );
47
+ $labelos = explode( "-",$std["style"]);
48
+ if( $std["style"] == "border-radius"){
49
+ $ending = "-top-".$labelos[1].$selector_type;
50
+ } else {
51
+ $ending = "-top".$selector_type;
52
+ }
53
+ $temp .= "<label for='".$name . "_". $labelos[0].$ending."'><strong>".$std["title"].$title_addon.":</strong>";
54
+ }
55
+ }else {
56
+ $temp .= "<label for='".$name . "_". $std["style"].$selector_type."'><strong>".$std["title"].$title_addon.":</strong>";
57
+ }
58
+ $incrementor = 0;
59
+ $indexer = 0;
60
+ $arrows = array('up', 'right', 'down' , 'left');
61
+ $fonts = array( 'font-size' => 'text-height', 'line-height' => 'font', 'text-indent' => 'indent-right');
62
+ foreach( $val as $elem_key => $elem_value ) {
63
+ if( $std["property"] == "0 0 0 0"){
64
+ /*Add new style properties if 4 value property inserted*/
65
+ $newproperty = explode("-", $std["style"]);
66
+ $endstyling = $element[ $incrementor];
67
+ if( $std["style"] == "border-radius"){
68
+ $endstyling = $element[ $incrementor ]."-".end($newproperty);
69
+ }
70
+ $std["style"] = $newproperty[0] ."-".$endstyling;
71
+ $incrementor++;
72
+ }
73
+ $test = ( $std["style"] == "border-top" || $std["style"] == "border-right" || $std["style"] == "border-bottom" || $std["style"] == "border-left") ? '-width' : '' ;
74
+ $saved_one = ( array_key_exists( $name . "_". $std["style"].$test.$selector_type, $saved_values)) ? $saved_values [ $name . "_". $std["style"].$test.$selector_type ] : "";
75
+ switch ($type){
76
+ case "width" : $temp .= '<span class="element-wrapper"><span class="icon"><i class="icon-resize-horizontal" aria-hidden="true"></i></span>'; break;
77
+ case "height" : $temp .= '<span class="element-wrapper"><span class="icon"><i class="icon-resize-vertical" aria-hidden="true"></i></span>'; break;
78
+ case "opacity" : $temp .= '<span class="element-wrapper"><span class="icon"><i class="icon-adjust" aria-hidden="true"></i></span>'; break;
79
+ case "border" :
80
+ case "margin" :
81
+ case "padding": $temp .= '<span class="element-wrapper"><span class="icon"><i class="icon-'.$arrows[$indexer++].'" aria-hidden="true"></i></span>'; break;
82
+ case "font" : $temp .= '<span class="element-wrapper"><span class="icon"><i class="icon-'.$fonts[$std["style"]].'" aria-hidden="true"></i></span>';break;
83
+ }
84
+ $min_val = ("margin" == $type) ? '-1000' : '0';
85
+ $max_val = ("opacity" == $type) ? '1' : '1000';
86
+ $step_value = ("opacity" == $type) ? '0.01' : '1';
87
+ $temp .= "<input type='number' step='".$step_value."' min='".$min_val."' max='".$max_val."' id='". $name . "_". $std["style"].$test.$selector_type."' name='cf7stylecustom[". $name . "_". $std["style"].$test.$selector_type."]' value='". $saved_one ."' />";
88
+ if( array_key_exists('unit', $std) ) {
89
+ $temp .= "<select id='". $name . "_". $std["style"] .$test . "_unit".$selector_type."' name='cf7stylecustom[". $name . "_". $std["style"] .$test ."_unit".$selector_type."]'>";
90
+
91
+ foreach( $std["unit"] as $unit_val ) {
92
+ $saved_one_unit = ( array_key_exists( $name . "_". $std["style"]. "_unit".$selector_type, $saved_values) ) ? $saved_values[ $name . "_". $std["style"]. "_unit".$selector_type ] : "";
93
+ $temp .= "<option ". selected( $saved_one_unit , $unit_val, false ) . ">". $unit_val ."</option>";
94
+ }
95
+
96
+ $temp .= "</select>";
97
+ }
98
+ switch ($type){
99
+ case "width" :
100
+ case "height" :
101
+ case "border" :
102
+ case "margin" :
103
+ case "padding":
104
+ case "opacity":
105
+ case "font" : $temp .= '</span>';break;
106
+ }
107
+ }
108
+ $temp .= "</label></li>";
109
+ return $temp;
110
+ break;
111
+
112
+ case 'select':
113
+ $fonts = array( 'font-style' => 'italic', 'font-weight' => 'bold', 'text-align' => 'align-center', 'text-decoration' => 'underline', 'text-transform' => 'header' );
114
+ $temp .= "<li ".$hidden_element."><label for='".$name . "_" . $std["style"].$selector_type."'><strong>".$std["title"].$title_addon.":</strong>";
115
+ switch ($type){
116
+ case "font" : $temp .= '<span class="icon"><i class="icon-'.$fonts[$std["style"]].'" aria-hidden="true"></i></span>';break;
117
+ }
118
+ $temp .= "<select id='". $name . "_" . $std["style"].$selector_type. "' name='cf7stylecustom[". $name . "_" . $std["style"] .$selector_type."]'>";
119
+ $temp .= '<option value="">'.__( "Choose value", 'contact-form-7-style' ).'</option>';
120
+ foreach( $std["property"] as $key => $value ) {
121
+ $saved_one = ( array_key_exists($name . "_". $std["style"].$selector_type, $saved_values) ) ? $saved_values[ $name . "_". $std["style"].$selector_type] : "";
122
+ $temp .= "<option ". selected( $saved_one , $value, false ) . ">". $value ."</option>";
123
+ }
124
+ $temp .= "</select></label></li>";
125
+ return $temp;
126
+
127
+ break;
128
+
129
+ default:
130
+
131
+ break;
132
+ }
133
+
134
+ }
135
+
136
+ /**
137
+ * Elements
138
+ */
139
+
140
+ $sameElements = array( "width", "height", "background", "margin", "padding", "font", "border", "float", "display", "box-sizing" );
141
+ $containerElements = array( "width", "height", "margin", "padding", "font", "border", "float", "box-sizing" );
142
+ $placeholderElements = array( "placefont", "opacity" );
143
+ $elements = array(
144
+ 'form' => array(
145
+ 'name' => 'form',
146
+ 'description' => 'The Contact Form 7 form element\'s design can be modified below:',
147
+ 'settings' => array("width", "height", "background", "margin", "padding", "border", "float", "box-sizing" )
148
+ ),
149
+ 'input' => array(
150
+ 'name' => 'input',
151
+ 'description' => 'This section allows styling of text, email, URL and contact numbers fields.',
152
+ 'settings' => $sameElements
153
+ ),
154
+ 'textarea' => array(
155
+ 'name' => 'text area',
156
+ 'description' => 'This section allows styling the textarea fields.',
157
+ 'settings' => $sameElements
158
+ ),
159
+ "p" => array(
160
+ 'name' => 'text',
161
+ 'description' => '',
162
+ 'settings' => $containerElements
163
+ ),
164
+ "placeholder" => array(
165
+ 'name' => 'placeholder',
166
+ 'description' => 'This section allows styling the placholder element of the input fields if present',
167
+ 'settings' => $placeholderElements
168
+ ),
169
+ 'label' => array(
170
+ 'name' => 'input label',
171
+ 'description' => 'This section allows styling the input label.',
172
+ 'settings' => $containerElements
173
+ ),
174
+ 'fieldset' => array(
175
+ 'name' => 'fieldset',
176
+ 'description' => '',
177
+ 'settings' => $containerElements
178
+ ),
179
+ 'submit' => array(
180
+ 'name' => 'submit button',
181
+ 'description' => 'This section allows styling the submit button.',
182
+ 'settings' => $sameElements
183
+ ),
184
+ 'select' => array(
185
+ 'name' => 'dropdown menu',
186
+ 'description' => 'This section allows styling the dropdown menus.',
187
+ 'settings' => $sameElements
188
+ ),
189
+ 'checkbox' => array(
190
+ 'name' => 'checkboxes',
191
+ 'description' => '',
192
+ 'settings' => array( "width", "height" )
193
+ ),
194
+ 'radio' => array(
195
+ 'name' => 'radio buttons',
196
+ 'description' => '',
197
+ 'settings' => array( "width", "height" )
198
+ ),
199
+ 'wpcf7-not-valid-tip' => array(
200
+ 'name' => 'error messages',
201
+ 'description' => 'There is a field that the sender must fill in, this message can be modified below.',
202
+ 'settings' => $sameElements
203
+ ),
204
+ 'wpcf7-validation-errors' => array(
205
+ 'name' => 'validation errors',
206
+ 'description' => 'This section allows styling the error message when the user submits the whole form.',
207
+ 'settings' => $sameElements
208
+ ),
209
+ 'wpcf7-mail-sent-ok' => array(
210
+ 'name' => 'successfully sent message',
211
+ 'description' => 'This section allows styling the message which appears on succesfull submit.',
212
+ 'settings' => $sameElements
213
+ ),
214
+ 'acceptance' => array(
215
+ 'name' => 'acceptance',
216
+ 'description' => '',
217
+ 'settings' => array("comming-soon")
218
+ ),
219
+ 'file' => array(
220
+ 'name' => 'file',
221
+ 'description' => '',
222
+ 'settings' => array("comming-soon")
223
+ ),
224
+ 'quiz' => array(
225
+ 'name' => 'quiz',
226
+ 'description' => '',
227
+ 'settings' => array("comming-soon")
228
+ ),
229
+ );
230
+
readme.txt CHANGED
@@ -1,286 +1,294 @@
1
- === Contact Form 7 Style ===
2
- Contributors: ionut.iclanzan, dorumarginean, mlehelsz, mircear
3
- Donate link: http://cf7style.com/back-this-project/
4
- Tags: contact form 7, contact form 7 style, contact form 7 templates, contact form 7 styling, CF7, CF7 style, styling contact form, styling contact form 7, multiple form styling, custom form styling, CF7 addon, customize, templates, valentine's day templates, Christmas templates, manual styling, live preview, hover state styling, CF7 form messages styling
5
- Requires at least: 4.0.1
6
- Tested up to: 5.0.3
7
- Stable tag: 3.1.8
8
- Requires PHP: 5.6.0
9
- License: GPLv2 or later
10
- License URI: http://www.gnu.org/licenses/gpl-2.0.html
11
-
12
- Simple style customization and templating for Contact Form 7 forms. Requires Contact Form 7 plugin installed.
13
-
14
- == Description ==
15
-
16
- [Contact Form 7 Style](http://cf7style.com/) plugin is an addon for [Contact Form 7](http://wordpress.org/plugins/contact-form-7/) which needs to be installed on your WordPress website.
17
- > This plugin requires the <a href="http://wordpress.org/extend/plugins/contact-form-7/" rel="nofollow">Contact Form 7 plugin</a><BR>
18
- <BR>
19
- > <a href="http://cf7style.com/downloads-history/" target="_blank">Downloads history</a> can be checked out on the cf7style.com website.<BR>
20
-
21
- [youtube https://www.youtube.com/watch?v=dByaDeVlmAc]
22
-
23
- Supports custom styling, which can be easily managed via admin dashboard. Also has predefined templates like Simple Pattern, Valentine's Day, Christmas that can be activated on your Contact Form 7. <BR>
24
-
25
-
26
- **Custom style options: <BR>**
27
- - color styling, <BR>
28
- - custom fonts ( google fonts included ), <BR>
29
- - styling for input fields, text, textarea, labels, submit button, messages, placeholders, <BR>
30
- - border-color, <BR>
31
- - form background-color, <BR>
32
- - form transparent background-color, <BR>
33
- - form background-image, <BR>
34
- - form container styling, <BR>
35
- - form container background-image styling, <BR>
36
- - form placeholder opacity styling, <BR>
37
- - customized style can be imported / exported <BR>
38
- - quick edit option <BR>
39
- - support multiple forms with different design<BR>
40
- - Style Template Slider on the Contact Form 7 form Settings page<BR>
41
- - px,em, % unit selector for all the specified style settings<BR>
42
- - possibility to change the syling for the HOVER state of each element<BR>
43
- - live preview on changing/adding the new style properties of each element<BR>
44
- - possibility to customize error messages, success messages and warning messages<BR>
45
- - setting page, where can re-import deleted default templates, deactivate collecting data and / or manipulate the appearance of the "edit style" button on the page where you have your contact form 7 form<BR>
46
-
47
- <strong>Support can be found [here](https://wordpress.org/support/plugin/contact-form-7-style).</strong>
48
-
49
- or you can check the [FAQ](http://cf7style.com/faq/) section.
50
-
51
-
52
- == Installation ==
53
-
54
- 1. Upload the entire `contact-form-7-style` folder to the `/wp-content/plugins/` directory
55
- 2. Make sure that Contact Form 7 is installed and activated ( an admin notice will check for this )
56
- 3. Activate the plugin through the 'Plugins' menu in WordPress
57
-
58
- You will find 'Contact Style' menu in your WordPress admin panel.
59
-
60
- == Screenshots ==
61
-
62
- 1. The Contact Style main settings page with predefined, responsive Style Templates
63
- 2. Custom new style Settings page with Google Font Selector, live preview and multiple element styling with the possibility to change the settings unit.
64
- 3. Template slider for quick setup of the form styling on the Contact Form 7 Settings Page.
65
- 4. Possibility to remove predefined templates only with 2 clicks.
66
- 5. Quick Edit on the Contact Style Settings Page, which allows Style Apply on various forms in a few seconds away.
67
- 6. Manual CSS Editor on the pages/posts which contains one or more Contact Form 7 forms.
68
- 7. Form Selector on the new Custom Style Setup Page.
69
- 8. Google Font Selector with all the Google Fonts included in one Dropdown with preview on the right side of the Dropdown.
70
- 9. Enable / disable forcing the CSS on the actual setup (it adds !important to every style property changed on the form)
71
- 10. Transparent background
72
-
73
- == Frequently Asked Questions ==
74
-
75
- Please check our FAQ page where you'll find answers to some of your questions on [cf7style.com/faq/](http://cf7style.com/faq/).
76
-
77
- == Changelog ==
78
-
79
- = 3.1.8 =
80
-
81
- Release Date: March 6th, 2018
82
-
83
- * Removed functionality for non sensitive data tracking (not using this feature anymore) and removed status report too
84
-
85
- = 3.1.7 =
86
-
87
- Release Date: March 6th, 2018
88
-
89
- * [Major Fix](https://wordpress.org/support/topic/increased-i-o/) Fixed I/O process with reducing the json requests from the servers
90
- * [Major Fix] Fixed the problem where the form was missing some settings when multiple form were selected in the custom style part
91
- * [Improvement](https://wordpress.org/support/topic/hide-contact-form-7-style-from-admin-bar/) Added settings to hide/show Contact Form 7 Style link
92
-
93
-
94
- = 3.1.6 =
95
-
96
- Release Date: November 7th, 2017
97
-
98
- * [Major Fix](https://wordpress.org/support/topic/u-have-a-problem-with-ure-update/) Fixed slash error and added extra condition to check for response
99
-
100
- = 3.1.5 =
101
-
102
- Release Date: November 6th, 2017
103
-
104
- * [Major Fix](https://wordpress.org/support/topic/error-on-updating-cf7-style/) Fallback for setups where json file can not be accesed by wp_remote_get
105
-
106
- = 3.1.4 =
107
-
108
- Release Date: November 4th, 2017
109
-
110
- * [Major Fix](https://wordpress.org/support/topic/dont-show-background-image/) Background image rendering fixed ( added "url()" )
111
-
112
- = 3.1.3 =
113
-
114
- Release Date: November 3rd, 2017
115
-
116
- * [New Feature] Placeholder elements styling and hover too + preview generate
117
- * [New Feature] Opacity settings for placeholders
118
- * [Improvement] Updated fonticons
119
- * [Improvement] Contact Form 7 "Go To CF7" button to edit form structure
120
- * [Improvement] Notifications handling modified
121
- * [Improvement] Removed transparent checkbox from font color
122
- * [Improvement] Updated plugin file structure for better code management
123
- * [Improvement] JSON files for plugin settings
124
- * [Major Fix] Works with PHP 7
125
- * [Major Fix] Compatible with WordPress Multisite
126
- * [Major Fix] Refactored style generator
127
- * General bugfixing
128
-
129
- = 3.1.2 =
130
- * [Small Fix](https://wordpress.org/support/topic/block-disappeared/) de-activated the possibility to drag boxes around
131
- * [Small Fix](https://wordpress.org/support/topic/transparentclear-input-background/) added possibility to add transparent background
132
- * [Small Fix](https://wordpress.org/support/topic/custom-submit-button-settings-not-working/) added new Force CSS settings possibility to plugin
133
- * [Small Fix](https://wordpress.org/support/topic/successfully-sent-message-styles-not-working-properly/) customized styling to remove this issue
134
- * [Small Fix](https://wordpress.org/support/topic/changing-default-padding-and-margins/) added possibility to add 0 padding / 0 margin
135
- * [Small Improvement] Possible to add negative margins on custom templates
136
- * [Small Improvement] Possible to add decimal values for "%" and "em" units
137
- * [Small Improvement] Added tooltip on settings page for better understanding
138
- * general bugfixing
139
- * user interface improvements
140
-
141
- = 3.1.1 =
142
- * [Major Fix](https://wordpress.org/support/topic/custom-styles-not-working/) for custom styles
143
- * [Small Fix] Styling issue on buttons
144
- * [Small Fix] CSS generator core upgraded
145
-
146
- = 3.1.0 =
147
- * [New Feature](https://wordpress.org/support/topic/error-confirmation-message-box-styling?replies=2) Error, confirmation, success message customization added
148
- * [New Feature](https://wordpress.org/support/topic/disabling-the-edit-custom-style-button?replies=2) Added settings field, where you can activate or deactivate the "edit custom style" button
149
- * [Major Improvement] modified settings page field generation, now it will remove every hidden field to improve page load
150
- * [New](https://wordpress.org/support/topic/could-we-have-few-more-ready-skins-pretty-please/) predefined templates available
151
- * [Improvements] for reliability and speed
152
- * User interface improvements
153
- * general bugfixing
154
-
155
- = 3.0.5 =
156
- * [Major Fix](https://wordpress.org/support/topic/headers-already-sent-35?replies=2) Headers already sent
157
- * [Major Fix](https://wordpress.org/support/topic/please-fix-a-googleapi-call-in-your-php?replies=2) SSL security fix for Google Fonts
158
- * [Major Fix] Parse error: syntax error, unexpected T_STATIC
159
- * general bugfixing
160
-
161
- = 3.0.4 =
162
- * [Major Fix](https://wordpress.org/support/topic/problem-with-css-editor?replies=2) Fixed CSS editor "\" multiplier removed
163
- * [Major Fix] Collection data functionality to prevent fatal error for various server setups
164
- * [Major Fix] Prevent existing style data loss based on a new versioning system functionality
165
- * [Improvement] Publish or Update Style button
166
- * New feature - System Status page with the possibility to ask for help from the Contact Form 7 Style team by email
167
- * New feature - Settings page - Install predefined templates or Allow collection data
168
- * General bugfixing
169
-
170
- = 3.0.3 =
171
- * [Major Fix](https://wordpress.org/support/topic/existing-styling-deleted?replies=3) JQuery conflict with Siteorigin Page Builder and Visual Composer
172
-
173
- = 3.0.2 =
174
- * [Major Fix](https://wordpress.org/support/topic/does-not-work-639?replies=7)
175
- * [Collection data settings page](https://wordpress.org/support/topic/how-to-disable-data-collection?replies=2)
176
- * New feature - generate cf7 form preview buttons added when creating new custom style
177
- * Improvements - preview generations on various user interactions
178
- * Improvements - general bugfixing
179
-
180
- = 3.0.1 =
181
- * New feature - width and height styling properties for radio elements
182
- * New feature - width and height styling properties for checkbox elements
183
- * Improvements - general bugfixing
184
-
185
- = 3.0.0 =
186
- * UI rework, update, redesign
187
- * New feature - Live Preview on all element changes with the actual Contact Form 7 form where the styling is applied
188
- * New feature - Hover state design for all elements
189
- * New feature - Style Selector Slider on Contact Form 7 Settings page, for quick style selection
190
- * New feature - Introduced new unit selector
191
- * New feature - Introduced new background-image add-on
192
- * New feature - Introduced new styling properties
193
- * New feature - Introduced fieldset, dropdowns, radio, checkbox
194
- * Improvements - Bugfixing, running process, code updates
195
- * Improvements - Modified Custom Styling logic and add it to new settings page
196
- * Improvements - Message boxes behaviour
197
- * Improvements - autocomplete styling where possible
198
-
199
- = 2.2.8 =
200
- * Optimize responsive view for predefined templates on mobile devices
201
- * Added Invitora WordPress Theme compatibility
202
- * Added support for special characters and fixed bugs
203
-
204
- = 2.2.7 =
205
- * Improvements for reliability and speed
206
- * Enhanced plugin stability and fixed bugs
207
- * Added Bretheon Premium WordPress Theme compatibility
208
-
209
- = 2.2.6 =
210
- * Added Avada Theme compatibility
211
- * Added Bridge - Creative Multi-Purpose WordPress Theme compatibility
212
- * Added Flatco - Multipurpose & Responsive WordPress Theme compatibility
213
- * Improve CSS Editor UI
214
-
215
- = 2.2.5 =
216
- * [Fixed](https://wordpress.org/support/topic/avada-theme-5) Avada Theme Fusion Page Builder incompatibility issue
217
- * [Fixed](https://wordpress.org/support/topic/good-morning-1) Contact form 7 shortcode detection for Flatco - Multipurpose & Responsive WordPress Theme
218
- * Improve plugin installer process
219
-
220
- = 2.2.4 =
221
- * New feature - ability to add your own custom css rules
222
- * [Fixed](https://wordpress.org/support/topic/textarea-height-and-submit-width) textarea and submit button on focus issue
223
-
224
- = 2.2.3 =
225
- * [Fixed](https://wordpress.org/support/topic/style-doesnt-apply-to-an-existing-form) simple template style issue
226
-
227
- = 2.2.2 =
228
- * Minor JQuery fixes for newer wordpress version
229
- * Fixed custom style for textarea selector
230
- * Admin panel minor adjustments
231
-
232
- = 2.2.1 =
233
- * New feature - textarea field additional options
234
- * [Fixed](https://wordpress.org/support/topic/field-style-issue?replies=6) textarea field style issue
235
-
236
- = 2.2 =
237
- * Fixed Chrome preview problem
238
- * Removed unnecessary elements from nav menus
239
- * Fixed custom style no title problem
240
- * [Fixed](https://wordpress.org/support/topic/custom-style-is-not-working?replies=6) css class generator
241
- * New feature - Added quick edit
242
- * New feature - Added new simple pattern style category with Twenty Fifteen Pattern
243
-
244
- = 2.1.1 =
245
- * Minor JQuery fixes for older wordpress version
246
-
247
- = 2.1 =
248
- * New feature - Google fonts preview when edit the style
249
- * New feature - List all styles thumbnail preview for predefined templates
250
-
251
- = 2.0.1 =
252
- * Admin panel minor adjustments
253
-
254
- = 2.0 =
255
- * New UI Admin settings options
256
- * Use custom post type for individual style set up
257
- * Multiple cf7 forms can have their own style
258
- * Style can be activated only for certain cf7 forms
259
- * All google fonts available for use
260
- * Styling improvement for theme twentyfifteen, twentyfourteen
261
- * New settings available
262
- * Possibility to change certain settings for the "custom style" styles
263
- * Style filtering by categories for easier use
264
- * Possibility to save your settings and import / export the generated "custom style"
265
- * Donate option for support the plugin's continued development and better user support
266
-
267
- = 1.1.1 =
268
- * Added plugin update notification in plugin template selection panel
269
-
270
- = 1.1.0 =
271
- * Added Valentine's Day templates for 2014.
272
- * Fixed Xmas Red header and footer position
273
- * Added Custom Style submenu for styling the templates
274
-
275
- = 1.0.1 =
276
- * Fixed x-mas classic display on 2014 wordpress theme.
277
-
278
- = 1.0 =
279
- * First plugin version.
280
-
281
- == Upgrade Notice ==
282
- = Contact Form 7 Style Version 3.1.7 =
283
-
284
- * [Major Fix](https://wordpress.org/support/topic/increased-i-o/) Fixed I/O process with reducing the json requests from the servers
285
- * [Major Fix] Fixed the problem where the form was missing some settings when multiple form were selected in the custom style part
286
- * [Improvement](https://wordpress.org/support/topic/hide-contact-form-7-style-from-admin-bar/) Added settings to hide/show Contact Form 7 Style link
 
 
 
 
 
 
 
 
1
+ === Contact Form 7 Style ===
2
+ Contributors: ionut.iclanzan, dorumarginean, mlehelsz, mircear
3
+ Donate link: http://cf7style.com/back-this-project/
4
+ Tags: contact form 7, contact form 7 style, contact form 7 templates, contact form 7 styling, CF7, CF7 style, styling contact form, styling contact form 7, multiple form styling, custom form styling, CF7 addon, customize, templates, valentine's day templates, Christmas templates, manual styling, live preview, hover state styling, CF7 form messages styling
5
+ Requires at least: 4.0.1
6
+ Tested up to: 5.5.1
7
+ Stable tag: 3.1.9
8
+ Requires PHP: 5.6.0
9
+ License: GPLv2 or later
10
+ License URI: http://www.gnu.org/licenses/gpl-2.0.html
11
+
12
+ Simple style customization and templating for Contact Form 7 forms. Requires Contact Form 7 plugin installed.
13
+
14
+ == Description ==
15
+
16
+ [Contact Form 7 Style](http://cf7style.com/) plugin is an addon for [Contact Form 7](http://wordpress.org/plugins/contact-form-7/) which needs to be installed on your WordPress website.
17
+ > This plugin requires the <a href="http://wordpress.org/extend/plugins/contact-form-7/" rel="nofollow">Contact Form 7 plugin</a><BR>
18
+ <BR>
19
+ > <a href="http://cf7style.com/downloads-history/" target="_blank">Downloads history</a> can be checked out on the cf7style.com website.<BR>
20
+
21
+ [youtube https://www.youtube.com/watch?v=dByaDeVlmAc]
22
+
23
+ Supports custom styling, which can be easily managed via admin dashboard. Also has predefined templates like Simple Pattern, Valentine's Day, Christmas that can be activated on your Contact Form 7. <BR>
24
+
25
+
26
+ **Custom style options: <BR>**
27
+ - color styling, <BR>
28
+ - custom fonts ( google fonts included ), <BR>
29
+ - styling for input fields, text, textarea, labels, submit button, messages, placeholders, <BR>
30
+ - border-color, <BR>
31
+ - form background-color, <BR>
32
+ - form transparent background-color, <BR>
33
+ - form background-image, <BR>
34
+ - form container styling, <BR>
35
+ - form container background-image styling, <BR>
36
+ - form placeholder opacity styling, <BR>
37
+ - customized style can be imported / exported <BR>
38
+ - quick edit option <BR>
39
+ - support multiple forms with different design<BR>
40
+ - Style Template Slider on the Contact Form 7 form Settings page<BR>
41
+ - px,em, % unit selector for all the specified style settings<BR>
42
+ - possibility to change the syling for the HOVER state of each element<BR>
43
+ - live preview on changing/adding the new style properties of each element<BR>
44
+ - possibility to customize error messages, success messages and warning messages<BR>
45
+ - setting page, where can re-import deleted default templates, deactivate collecting data and / or manipulate the appearance of the "edit style" button on the page where you have your contact form 7 form<BR>
46
+
47
+ <strong>Support can be found [here](https://wordpress.org/support/plugin/contact-form-7-style).</strong>
48
+
49
+ or you can check the [FAQ](http://cf7style.com/faq/) section.
50
+
51
+
52
+ == Installation ==
53
+
54
+ 1. Upload the entire `contact-form-7-style` folder to the `/wp-content/plugins/` directory
55
+ 2. Make sure that Contact Form 7 is installed and activated ( an admin notice will check for this )
56
+ 3. Activate the plugin through the 'Plugins' menu in WordPress
57
+
58
+ You will find 'Contact Style' menu in your WordPress admin panel.
59
+
60
+ == Screenshots ==
61
+
62
+ 1. The Contact Style main settings page with predefined, responsive Style Templates
63
+ 2. Custom new style Settings page with Google Font Selector, live preview and multiple element styling with the possibility to change the settings unit.
64
+ 3. Template slider for quick setup of the form styling on the Contact Form 7 Settings Page.
65
+ 4. Possibility to remove predefined templates only with 2 clicks.
66
+ 5. Quick Edit on the Contact Style Settings Page, which allows Style Apply on various forms in a few seconds away.
67
+ 6. Manual CSS Editor on the pages/posts which contains one or more Contact Form 7 forms.
68
+ 7. Form Selector on the new Custom Style Setup Page.
69
+ 8. Google Font Selector with all the Google Fonts included in one Dropdown with preview on the right side of the Dropdown.
70
+ 9. Enable / disable forcing the CSS on the actual setup (it adds !important to every style property changed on the form)
71
+ 10. Transparent background
72
+
73
+ == Frequently Asked Questions ==
74
+
75
+ Please check our FAQ page where you'll find answers to some of your questions on [cf7style.com/faq/](http://cf7style.com/faq/).
76
+
77
+ == Changelog ==
78
+
79
+ = 3.1.9 =
80
+
81
+ Release Date: October 21th, 2020
82
+
83
+ * [Security Fix] Added suggested santiziation on possible critical field
84
+ * [Minor Fix] Google Fonts List updated
85
+ * [Major Fix] Predefined templates loading issue
86
+
87
+ = 3.1.8 =
88
+
89
+ Release Date: February 12th, 2019
90
+
91
+ * Removed functionality for non sensitive data tracking (not using this feature anymore) and removed status report too
92
+
93
+ = 3.1.7 =
94
+
95
+ Release Date: March 6th, 2018
96
+
97
+ * [Major Fix](https://wordpress.org/support/topic/increased-i-o/) Fixed I/O process with reducing the json requests from the servers
98
+ * [Major Fix] Fixed the problem where the form was missing some settings when multiple form were selected in the custom style part
99
+ * [Improvement](https://wordpress.org/support/topic/hide-contact-form-7-style-from-admin-bar/) Added settings to hide/show Contact Form 7 Style link
100
+
101
+
102
+ = 3.1.6 =
103
+
104
+ Release Date: November 7th, 2017
105
+
106
+ * [Major Fix](https://wordpress.org/support/topic/u-have-a-problem-with-ure-update/) Fixed slash error and added extra condition to check for response
107
+
108
+ = 3.1.5 =
109
+
110
+ Release Date: November 6th, 2017
111
+
112
+ * [Major Fix](https://wordpress.org/support/topic/error-on-updating-cf7-style/) Fallback for setups where json file can not be accesed by wp_remote_get
113
+
114
+ = 3.1.4 =
115
+
116
+ Release Date: November 4th, 2017
117
+
118
+ * [Major Fix](https://wordpress.org/support/topic/dont-show-background-image/) Background image rendering fixed ( added "url()" )
119
+
120
+ = 3.1.3 =
121
+
122
+ Release Date: November 3rd, 2017
123
+
124
+ * [New Feature] Placeholder elements styling and hover too + preview generate
125
+ * [New Feature] Opacity settings for placeholders
126
+ * [Improvement] Updated fonticons
127
+ * [Improvement] Contact Form 7 "Go To CF7" button to edit form structure
128
+ * [Improvement] Notifications handling modified
129
+ * [Improvement] Removed transparent checkbox from font color
130
+ * [Improvement] Updated plugin file structure for better code management
131
+ * [Improvement] JSON files for plugin settings
132
+ * [Major Fix] Works with PHP 7
133
+ * [Major Fix] Compatible with WordPress Multisite
134
+ * [Major Fix] Refactored style generator
135
+ * General bugfixing
136
+
137
+ = 3.1.2 =
138
+ * [Small Fix](https://wordpress.org/support/topic/block-disappeared/) de-activated the possibility to drag boxes around
139
+ * [Small Fix](https://wordpress.org/support/topic/transparentclear-input-background/) added possibility to add transparent background
140
+ * [Small Fix](https://wordpress.org/support/topic/custom-submit-button-settings-not-working/) added new Force CSS settings possibility to plugin
141
+ * [Small Fix](https://wordpress.org/support/topic/successfully-sent-message-styles-not-working-properly/) customized styling to remove this issue
142
+ * [Small Fix](https://wordpress.org/support/topic/changing-default-padding-and-margins/) added possibility to add 0 padding / 0 margin
143
+ * [Small Improvement] Possible to add negative margins on custom templates
144
+ * [Small Improvement] Possible to add decimal values for "%" and "em" units
145
+ * [Small Improvement] Added tooltip on settings page for better understanding
146
+ * general bugfixing
147
+ * user interface improvements
148
+
149
+ = 3.1.1 =
150
+ * [Major Fix](https://wordpress.org/support/topic/custom-styles-not-working/) for custom styles
151
+ * [Small Fix] Styling issue on buttons
152
+ * [Small Fix] CSS generator core upgraded
153
+
154
+ = 3.1.0 =
155
+ * [New Feature](https://wordpress.org/support/topic/error-confirmation-message-box-styling?replies=2) Error, confirmation, success message customization added
156
+ * [New Feature](https://wordpress.org/support/topic/disabling-the-edit-custom-style-button?replies=2) Added settings field, where you can activate or deactivate the "edit custom style" button
157
+ * [Major Improvement] modified settings page field generation, now it will remove every hidden field to improve page load
158
+ * [New](https://wordpress.org/support/topic/could-we-have-few-more-ready-skins-pretty-please/) predefined templates available
159
+ * [Improvements] for reliability and speed
160
+ * User interface improvements
161
+ * general bugfixing
162
+
163
+ = 3.0.5 =
164
+ * [Major Fix](https://wordpress.org/support/topic/headers-already-sent-35?replies=2) Headers already sent
165
+ * [Major Fix](https://wordpress.org/support/topic/please-fix-a-googleapi-call-in-your-php?replies=2) SSL security fix for Google Fonts
166
+ * [Major Fix] Parse error: syntax error, unexpected T_STATIC
167
+ * general bugfixing
168
+
169
+ = 3.0.4 =
170
+ * [Major Fix](https://wordpress.org/support/topic/problem-with-css-editor?replies=2) Fixed CSS editor "\" multiplier removed
171
+ * [Major Fix] Collection data functionality to prevent fatal error for various server setups
172
+ * [Major Fix] Prevent existing style data loss based on a new versioning system functionality
173
+ * [Improvement] Publish or Update Style button
174
+ * New feature - System Status page with the possibility to ask for help from the Contact Form 7 Style team by email
175
+ * New feature - Settings page - Install predefined templates or Allow collection data
176
+ * General bugfixing
177
+
178
+ = 3.0.3 =
179
+ * [Major Fix](https://wordpress.org/support/topic/existing-styling-deleted?replies=3) JQuery conflict with Siteorigin Page Builder and Visual Composer
180
+
181
+ = 3.0.2 =
182
+ * [Major Fix](https://wordpress.org/support/topic/does-not-work-639?replies=7)
183
+ * [Collection data settings page](https://wordpress.org/support/topic/how-to-disable-data-collection?replies=2)
184
+ * New feature - generate cf7 form preview buttons added when creating new custom style
185
+ * Improvements - preview generations on various user interactions
186
+ * Improvements - general bugfixing
187
+
188
+ = 3.0.1 =
189
+ * New feature - width and height styling properties for radio elements
190
+ * New feature - width and height styling properties for checkbox elements
191
+ * Improvements - general bugfixing
192
+
193
+ = 3.0.0 =
194
+ * UI rework, update, redesign
195
+ * New feature - Live Preview on all element changes with the actual Contact Form 7 form where the styling is applied
196
+ * New feature - Hover state design for all elements
197
+ * New feature - Style Selector Slider on Contact Form 7 Settings page, for quick style selection
198
+ * New feature - Introduced new unit selector
199
+ * New feature - Introduced new background-image add-on
200
+ * New feature - Introduced new styling properties
201
+ * New feature - Introduced fieldset, dropdowns, radio, checkbox
202
+ * Improvements - Bugfixing, running process, code updates
203
+ * Improvements - Modified Custom Styling logic and add it to new settings page
204
+ * Improvements - Message boxes behaviour
205
+ * Improvements - autocomplete styling where possible
206
+
207
+ = 2.2.8 =
208
+ * Optimize responsive view for predefined templates on mobile devices
209
+ * Added Invitora WordPress Theme compatibility
210
+ * Added support for special characters and fixed bugs
211
+
212
+ = 2.2.7 =
213
+ * Improvements for reliability and speed
214
+ * Enhanced plugin stability and fixed bugs
215
+ * Added Bretheon Premium WordPress Theme compatibility
216
+
217
+ = 2.2.6 =
218
+ * Added Avada Theme compatibility
219
+ * Added Bridge - Creative Multi-Purpose WordPress Theme compatibility
220
+ * Added Flatco - Multipurpose & Responsive WordPress Theme compatibility
221
+ * Improve CSS Editor UI
222
+
223
+ = 2.2.5 =
224
+ * [Fixed](https://wordpress.org/support/topic/avada-theme-5) Avada Theme Fusion Page Builder incompatibility issue
225
+ * [Fixed](https://wordpress.org/support/topic/good-morning-1) Contact form 7 shortcode detection for Flatco - Multipurpose & Responsive WordPress Theme
226
+ * Improve plugin installer process
227
+
228
+ = 2.2.4 =
229
+ * New feature - ability to add your own custom css rules
230
+ * [Fixed](https://wordpress.org/support/topic/textarea-height-and-submit-width) textarea and submit button on focus issue
231
+
232
+ = 2.2.3 =
233
+ * [Fixed](https://wordpress.org/support/topic/style-doesnt-apply-to-an-existing-form) simple template style issue
234
+
235
+ = 2.2.2 =
236
+ * Minor JQuery fixes for newer wordpress version
237
+ * Fixed custom style for textarea selector
238
+ * Admin panel minor adjustments
239
+
240
+ = 2.2.1 =
241
+ * New feature - textarea field additional options
242
+ * [Fixed](https://wordpress.org/support/topic/field-style-issue?replies=6) textarea field style issue
243
+
244
+ = 2.2 =
245
+ * Fixed Chrome preview problem
246
+ * Removed unnecessary elements from nav menus
247
+ * Fixed custom style no title problem
248
+ * [Fixed](https://wordpress.org/support/topic/custom-style-is-not-working?replies=6) css class generator
249
+ * New feature - Added quick edit
250
+ * New feature - Added new simple pattern style category with Twenty Fifteen Pattern
251
+
252
+ = 2.1.1 =
253
+ * Minor JQuery fixes for older wordpress version
254
+
255
+ = 2.1 =
256
+ * New feature - Google fonts preview when edit the style
257
+ * New feature - List all styles thumbnail preview for predefined templates
258
+
259
+ = 2.0.1 =
260
+ * Admin panel minor adjustments
261
+
262
+ = 2.0 =
263
+ * New UI Admin settings options
264
+ * Use custom post type for individual style set up
265
+ * Multiple cf7 forms can have their own style
266
+ * Style can be activated only for certain cf7 forms
267
+ * All google fonts available for use
268
+ * Styling improvement for theme twentyfifteen, twentyfourteen
269
+ * New settings available
270
+ * Possibility to change certain settings for the "custom style" styles
271
+ * Style filtering by categories for easier use
272
+ * Possibility to save your settings and import / export the generated "custom style"
273
+ * Donate option for support the plugin's continued development and better user support
274
+
275
+ = 1.1.1 =
276
+ * Added plugin update notification in plugin template selection panel
277
+
278
+ = 1.1.0 =
279
+ * Added Valentine's Day templates for 2014.
280
+ * Fixed Xmas Red header and footer position
281
+ * Added Custom Style submenu for styling the templates
282
+
283
+ = 1.0.1 =
284
+ * Fixed x-mas classic display on 2014 wordpress theme.
285
+
286
+ = 1.0 =
287
+ * First plugin version.
288
+
289
+ == Upgrade Notice ==
290
+ = Contact Form 7 Style Version 3.1.9 =
291
+
292
+ * [Security Fix] Added suggested santiziation on possible critical field
293
+ * [Minor Fix] Google Fonts List updated
294
+ * [Major Fix] Predefined templates loading issue