Caldera Forms – More Than Contact Forms - Version 1.3.0

Version Description

( August 23, 2015 ) = * Improved: Adding rows in form layout. * Added: Conditional groups. * Added: New helper classes for form processors. * Fixed: Issue where forms with a file field, without a file uploaded, would break mailer validation. * Added: Date range settings for date picker fields. * Improved: Colors in form editor. * Improved: Inline docs in Caldera_Forms class. * Added: 2 new form templates. * Fixed: Issue with field scripts being double loaded. * Fixed: Issue affecting color pickers as conditional fields. * Update Translations: German (de_DE), Spanish (es_ES), French (fr_FR), Japanese (ja), Portuguese (pt_PT), Turkish (tr_TR).

Download this release

Release Info

Developer Shelob9
Plugin Icon 128x128 Caldera Forms – More Than Contact Forms
Version 1.3.0
Comparing to
See all releases

Code changes from version 1.2.2 to 1.3.0

Files changed (71) hide show
  1. LICENSE +339 -0
  2. README.md +12 -0
  3. assets/css/admin.css +45 -6
  4. assets/css/editor-grid.css +31 -4
  5. assets/css/processors-edit.css +44 -3
  6. assets/js/conditionals.js +2 -2
  7. assets/js/conditionals.min.js +1 -1
  8. assets/js/edit.js +39 -19
  9. assets/js/edit.min.js +2 -2
  10. assets/js/frontend-script-init.js +12 -2
  11. assets/js/frontend-script-init.min.js +1 -1
  12. assets/js/wp-baldrick-full.js +43 -38
  13. caldera-core.php +7 -2
  14. classes/Caldera_Forms_Save_Final.php +391 -0
  15. classes/admin.php +170 -55
  16. classes/core.php +527 -388
  17. composer.json +15 -0
  18. fields/button/field.php +7 -1
  19. fields/calculation/field.php +11 -2
  20. fields/date_picker/datepicker.php +15 -3
  21. fields/date_picker/setup.php +18 -4
  22. fields/file/config_template.php +7 -0
  23. fields/file/field.php +9 -2
  24. fields/gravatar/field.php +5 -0
  25. fields/html/field.php +14 -2
  26. fields/range_slider/field.php +23 -16
  27. fields/recaptcha/field.php +9 -1
  28. fields/select2/css/ccselect2-spinner.gif +0 -0
  29. fields/select2/css/ccselect2.png +0 -0
  30. fields/select2/css/ccselect2x2.png +0 -0
  31. fields/select2/css/select2.css +706 -0
  32. fields/select2/field/config.php +55 -0
  33. fields/select2/field/field.php +139 -0
  34. fields/select2/field/preview.php +12 -0
  35. fields/select2/js/select2.min.js +24 -0
  36. fields/select2/select2.php +27 -0
  37. fields/star-rate/field.php +5 -1
  38. fields/states/field.php +1 -1
  39. fields/toggle_switch/field.php +7 -2
  40. includes/field_processors.php +47 -11
  41. includes/templates/registration-form-example.php +308 -0
  42. includes/templates/starter-contact-form.php +219 -0
  43. includes/templates/variable-price-example.php +311 -0
  44. languages/caldera-forms-de_DE.mo +0 -0
  45. languages/caldera-forms-de_DE.po +350 -241
  46. languages/caldera-forms-es_ES.mo +0 -0
  47. languages/caldera-forms-es_ES.po +349 -240
  48. languages/caldera-forms-fr_FR.mo +0 -0
  49. languages/caldera-forms-fr_FR.po +629 -507
  50. languages/caldera-forms-ja.mo +0 -0
  51. languages/caldera-forms-ja.po +346 -243
  52. languages/caldera-forms-pt_PT.mo +0 -0
  53. languages/caldera-forms-pt_PT.po +1761 -0
  54. languages/caldera-forms-tr_TR.mo +0 -0
  55. languages/caldera-forms-tr_TR.po +1753 -0
  56. languages/caldera-forms.pot +334 -237
  57. processors/classes/get_data.php +231 -0
  58. processors/classes/load.php +209 -0
  59. processors/classes/ui.php +275 -0
  60. readme.txt +51 -5
  61. ui/admin.php +30 -0
  62. ui/admin_templates.php +1 -1
  63. ui/community.php +1 -1
  64. ui/edit.php +65 -26
  65. ui/extend.php +8 -2
  66. ui/news_templates.php +2 -2
  67. ui/panels/conditions.php +366 -0
  68. ui/panels/emailer.php +7 -2
  69. ui/panels/layout.php +1 -0
  70. ui/panels/layout_toolbar.php +62 -0
  71. ui/panels/processors.php +2 -2
LICENSE ADDED
@@ -0,0 +1,339 @@
1
+ GNU GENERAL PUBLIC LICENSE
2
+ Version 2, June 1991
3
+
4
+ Copyright (C) 1989, 1991 Free Software Foundation, Inc., <http://fsf.org/>
5
+ 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
6
+ Everyone is permitted to copy and distribute verbatim copies
7
+ of this license document, but changing it is not allowed.
8
+
9
+ Preamble
10
+
11
+ The licenses for most software are designed to take away your
12
+ freedom to share and change it. By contrast, the GNU General Public
13
+ License is intended to guarantee your freedom to share and change free
14
+ software--to make sure the software is free for all its users. This
15
+ General Public License applies to most of the Free Software
16
+ Foundation's software and to any other program whose authors commit to
17
+ using it. (Some other Free Software Foundation software is covered by
18
+ the GNU Lesser General Public License instead.) You can apply it to
19
+ your programs, too.
20
+
21
+ When we speak of free software, we are referring to freedom, not
22
+ price. Our General Public Licenses are designed to make sure that you
23
+ have the freedom to distribute copies of free software (and charge for
24
+ this service if you wish), that you receive source code or can get it
25
+ if you want it, that you can change the software or use pieces of it
26
+ in new free programs; and that you know you can do these things.
27
+
28
+ To protect your rights, we need to make restrictions that forbid
29
+ anyone to deny you these rights or to ask you to surrender the rights.
30
+ These restrictions translate to certain responsibilities for you if you
31
+ distribute copies of the software, or if you modify it.
32
+
33
+ For example, if you distribute copies of such a program, whether
34
+ gratis or for a fee, you must give the recipients all the rights that
35
+ you have. You must make sure that they, too, receive or can get the
36
+ source code. And you must show them these terms so they know their
37
+ rights.
38
+
39
+ We protect your rights with two steps: (1) copyright the software, and
40
+ (2) offer you this license which gives you legal permission to copy,
41
+ distribute and/or modify the software.
42
+
43
+ Also, for each author's protection and ours, we want to make certain
44
+ that everyone understands that there is no warranty for this free
45
+ software. If the software is modified by someone else and passed on, we
46
+ want its recipients to know that what they have is not the original, so
47
+ that any problems introduced by others will not reflect on the original
48
+ authors' reputations.
49
+
50
+ Finally, any free program is threatened constantly by software
51
+ patents. We wish to avoid the danger that redistributors of a free
52
+ program will individually obtain patent licenses, in effect making the
53
+ program proprietary. To prevent this, we have made it clear that any
54
+ patent must be licensed for everyone's free use or not licensed at all.
55
+
56
+ The precise terms and conditions for copying, distribution and
57
+ modification follow.
58
+
59
+ GNU GENERAL PUBLIC LICENSE
60
+ TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
61
+
62
+ 0. This License applies to any program or other work which contains
63
+ a notice placed by the copyright holder saying it may be distributed
64
+ under the terms of this General Public License. The "Program", below,
65
+ refers to any such program or work, and a "work based on the Program"
66
+ means either the Program or any derivative work under copyright law:
67
+ that is to say, a work containing the Program or a portion of it,
68
+ either verbatim or with modifications and/or translated into another
69
+ language. (Hereinafter, translation is included without limitation in
70
+ the term "modification".) Each licensee is addressed as "you".
71
+
72
+ Activities other than copying, distribution and modification are not
73
+ covered by this License; they are outside its scope. The act of
74
+ running the Program is not restricted, and the output from the Program
75
+ is covered only if its contents constitute a work based on the
76
+ Program (independent of having been made by running the Program).
77
+ Whether that is true depends on what the Program does.
78
+
79
+ 1. You may copy and distribute verbatim copies of the Program's
80
+ source code as you receive it, in any medium, provided that you
81
+ conspicuously and appropriately publish on each copy an appropriate
82
+ copyright notice and disclaimer of warranty; keep intact all the
83
+ notices that refer to this License and to the absence of any warranty;
84
+ and give any other recipients of the Program a copy of this License
85
+ along with the Program.
86
+
87
+ You may charge a fee for the physical act of transferring a copy, and
88
+ you may at your option offer warranty protection in exchange for a fee.
89
+
90
+ 2. You may modify your copy or copies of the Program or any portion
91
+ of it, thus forming a work based on the Program, and copy and
92
+ distribute such modifications or work under the terms of Section 1
93
+ above, provided that you also meet all of these conditions:
94
+
95
+ a) You must cause the modified files to carry prominent notices
96
+ stating that you changed the files and the date of any change.
97
+
98
+ b) You must cause any work that you distribute or publish, that in
99
+ whole or in part contains or is derived from the Program or any
100
+ part thereof, to be licensed as a whole at no charge to all third
101
+ parties under the terms of this License.
102
+
103
+ c) If the modified program normally reads commands interactively
104
+ when run, you must cause it, when started running for such
105
+ interactive use in the most ordinary way, to print or display an
106
+ announcement including an appropriate copyright notice and a
107
+ notice that there is no warranty (or else, saying that you provide
108
+ a warranty) and that users may redistribute the program under
109
+ these conditions, and telling the user how to view a copy of this
110
+ License. (Exception: if the Program itself is interactive but
111
+ does not normally print such an announcement, your work based on
112
+ the Program is not required to print an announcement.)
113
+
114
+ These requirements apply to the modified work as a whole. If
115
+ identifiable sections of that work are not derived from the Program,
116
+ and can be reasonably considered independent and separate works in
117
+ themselves, then this License, and its terms, do not apply to those
118
+ sections when you distribute them as separate works. But when you
119
+ distribute the same sections as part of a whole which is a work based
120
+ on the Program, the distribution of the whole must be on the terms of
121
+ this License, whose permissions for other licensees extend to the
122
+ entire whole, and thus to each and every part regardless of who wrote it.
123
+
124
+ Thus, it is not the intent of this section to claim rights or contest
125
+ your rights to work written entirely by you; rather, the intent is to
126
+ exercise the right to control the distribution of derivative or
127
+ collective works based on the Program.
128
+
129
+ In addition, mere aggregation of another work not based on the Program
130
+ with the Program (or with a work based on the Program) on a volume of
131
+ a storage or distribution medium does not bring the other work under
132
+ the scope of this License.
133
+
134
+ 3. You may copy and distribute the Program (or a work based on it,
135
+ under Section 2) in object code or executable form under the terms of
136
+ Sections 1 and 2 above provided that you also do one of the following:
137
+
138
+ a) Accompany it with the complete corresponding machine-readable
139
+ source code, which must be distributed under the terms of Sections
140
+ 1 and 2 above on a medium customarily used for software interchange; or,
141
+
142
+ b) Accompany it with a written offer, valid for at least three
143
+ years, to give any third party, for a charge no more than your
144
+ cost of physically performing source distribution, a complete
145
+ machine-readable copy of the corresponding source code, to be
146
+ distributed under the terms of Sections 1 and 2 above on a medium
147
+ customarily used for software interchange; or,
148
+
149
+ c) Accompany it with the information you received as to the offer
150
+ to distribute corresponding source code. (This alternative is
151
+ allowed only for noncommercial distribution and only if you
152
+ received the program in object code or executable form with such
153
+ an offer, in accord with Subsection b above.)
154
+
155
+ The source code for a work means the preferred form of the work for
156
+ making modifications to it. For an executable work, complete source
157
+ code means all the source code for all modules it contains, plus any
158
+ associated interface definition files, plus the scripts used to
159
+ control compilation and installation of the executable. However, as a
160
+ special exception, the source code distributed need not include
161
+ anything that is normally distributed (in either source or binary
162
+ form) with the major components (compiler, kernel, and so on) of the
163
+ operating system on which the executable runs, unless that component
164
+ itself accompanies the executable.
165
+
166
+ If distribution of executable or object code is made by offering
167
+ access to copy from a designated place, then offering equivalent
168
+ access to copy the source code from the same place counts as
169
+ distribution of the source code, even though third parties are not
170
+ compelled to copy the source along with the object code.
171
+
172
+ 4. You may not copy, modify, sublicense, or distribute the Program
173
+ except as expressly provided under this License. Any attempt
174
+ otherwise to copy, modify, sublicense or distribute the Program is
175
+ void, and will automatically terminate your rights under this License.
176
+ However, parties who have received copies, or rights, from you under
177
+ this License will not have their licenses terminated so long as such
178
+ parties remain in full compliance.
179
+
180
+ 5. You are not required to accept this License, since you have not
181
+ signed it. However, nothing else grants you permission to modify or
182
+ distribute the Program or its derivative works. These actions are
183
+ prohibited by law if you do not accept this License. Therefore, by
184
+ modifying or distributing the Program (or any work based on the
185
+ Program), you indicate your acceptance of this License to do so, and
186
+ all its terms and conditions for copying, distributing or modifying
187
+ the Program or works based on it.
188
+
189
+ 6. Each time you redistribute the Program (or any work based on the
190
+ Program), the recipient automatically receives a license from the
191
+ original licensor to copy, distribute or modify the Program subject to
192
+ these terms and conditions. You may not impose any further
193
+ restrictions on the recipients' exercise of the rights granted herein.
194
+ You are not responsible for enforcing compliance by third parties to
195
+ this License.
196
+
197
+ 7. If, as a consequence of a court judgment or allegation of patent
198
+ infringement or for any other reason (not limited to patent issues),
199
+ conditions are imposed on you (whether by court order, agreement or
200
+ otherwise) that contradict the conditions of this License, they do not
201
+ excuse you from the conditions of this License. If you cannot
202
+ distribute so as to satisfy simultaneously your obligations under this
203
+ License and any other pertinent obligations, then as a consequence you
204
+ may not distribute the Program at all. For example, if a patent
205
+ license would not permit royalty-free redistribution of the Program by
206
+ all those who receive copies directly or indirectly through you, then
207
+ the only way you could satisfy both it and this License would be to
208
+ refrain entirely from distribution of the Program.
209
+
210
+ If any portion of this section is held invalid or unenforceable under
211
+ any particular circumstance, the balance of the section is intended to
212
+ apply and the section as a whole is intended to apply in other
213
+ circumstances.
214
+
215
+ It is not the purpose of this section to induce you to infringe any
216
+ patents or other property right claims or to contest validity of any
217
+ such claims; this section has the sole purpose of protecting the
218
+ integrity of the free software distribution system, which is
219
+ implemented by public license practices. Many people have made
220
+ generous contributions to the wide range of software distributed
221
+ through that system in reliance on consistent application of that
222
+ system; it is up to the author/donor to decide if he or she is willing
223
+ to distribute software through any other system and a licensee cannot
224
+ impose that choice.
225
+
226
+ This section is intended to make thoroughly clear what is believed to
227
+ be a consequence of the rest of this License.
228
+
229
+ 8. If the distribution and/or use of the Program is restricted in
230
+ certain countries either by patents or by copyrighted interfaces, the
231
+ original copyright holder who places the Program under this License
232
+ may add an explicit geographical distribution limitation excluding
233
+ those countries, so that distribution is permitted only in or among
234
+ countries not thus excluded. In such case, this License incorporates
235
+ the limitation as if written in the body of this License.
236
+
237
+ 9. The Free Software Foundation may publish revised and/or new versions
238
+ of the General Public License from time to time. Such new versions will
239
+ be similar in spirit to the present version, but may differ in detail to
240
+ address new problems or concerns.
241
+
242
+ Each version is given a distinguishing version number. If the Program
243
+ specifies a version number of this License which applies to it and "any
244
+ later version", you have the option of following the terms and conditions
245
+ either of that version or of any later version published by the Free
246
+ Software Foundation. If the Program does not specify a version number of
247
+ this License, you may choose any version ever published by the Free Software
248
+ Foundation.
249
+
250
+ 10. If you wish to incorporate parts of the Program into other free
251
+ programs whose distribution conditions are different, write to the author
252
+ to ask for permission. For software which is copyrighted by the Free
253
+ Software Foundation, write to the Free Software Foundation; we sometimes
254
+ make exceptions for this. Our decision will be guided by the two goals
255
+ of preserving the free status of all derivatives of our free software and
256
+ of promoting the sharing and reuse of software generally.
257
+
258
+ NO WARRANTY
259
+
260
+ 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
261
+ FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
262
+ OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
263
+ PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
264
+ OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
265
+ MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
266
+ TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
267
+ PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
268
+ REPAIR OR CORRECTION.
269
+
270
+ 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
271
+ WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
272
+ REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
273
+ INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
274
+ OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
275
+ TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
276
+ YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
277
+ PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
278
+ POSSIBILITY OF SUCH DAMAGES.
279
+
280
+ END OF TERMS AND CONDITIONS
281
+
282
+ How to Apply These Terms to Your New Programs
283
+
284
+ If you develop a new program, and you want it to be of the greatest
285
+ possible use to the public, the best way to achieve this is to make it
286
+ free software which everyone can redistribute and change under these terms.
287
+
288
+ To do so, attach the following notices to the program. It is safest
289
+ to attach them to the start of each source file to most effectively
290
+ convey the exclusion of warranty; and each file should have at least
291
+ the "copyright" line and a pointer to where the full notice is found.
292
+
293
+ {description}
294
+ Copyright (C) {year} {fullname}
295
+
296
+ This program is free software; you can redistribute it and/or modify
297
+ it under the terms of the GNU General Public License as published by
298
+ the Free Software Foundation; either version 2 of the License, or
299
+ (at your option) any later version.
300
+
301
+ This program is distributed in the hope that it will be useful,
302
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
303
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
304
+ GNU General Public License for more details.
305
+
306
+ You should have received a copy of the GNU General Public License along
307
+ with this program; if not, write to the Free Software Foundation, Inc.,
308
+ 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
309
+
310
+ Also add information on how to contact you by electronic and paper mail.
311
+
312
+ If the program is interactive, make it output a short notice like this
313
+ when it starts in an interactive mode:
314
+
315
+ Gnomovision version 69, Copyright (C) year name of author
316
+ Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
317
+ This is free software, and you are welcome to redistribute it
318
+ under certain conditions; type `show c' for details.
319
+
320
+ The hypothetical commands `show w' and `show c' should show the appropriate
321
+ parts of the General Public License. Of course, the commands you use may
322
+ be called something other than `show w' and `show c'; they could even be
323
+ mouse-clicks or menu items--whatever suits your program.
324
+
325
+ You should also get your employer (if you work as a programmer) or your
326
+ school, if any, to sign a "copyright disclaimer" for the program, if
327
+ necessary. Here is a sample; alter the names:
328
+
329
+ Yoyodyne, Inc., hereby disclaims all copyright interest in the program
330
+ `Gnomovision' (which makes passes at compilers) written by James Hacker.
331
+
332
+ {signature of Ty Coon}, 1 April 1989
333
+ Ty Coon, President of Vice
334
+
335
+ This General Public License does not permit incorporating your program into
336
+ proprietary programs. If your program is a subroutine library, you may
337
+ consider it more useful to permit linking proprietary applications with the
338
+ library. If this is what you want to do, use the GNU Lesser General
339
+ Public License instead of this License.
README.md ADDED
@@ -0,0 +1,12 @@
1
+ Caldera-Forms
2
+ =============
3
+ <img src="https://calderawp.com/wp-content/uploads/2015/02/CalderaWP_Logo_SQ-150x150.png" >
4
+
5
+ # Drag & Drop Responsive Form Builder
6
+
7
+ #### By <a href="https://CalderaWP.com" title="CalderaWP: Transform Your WordPress Experience">CalderaWP</a>
8
+
9
+ ### Docs, Add-ons & More Information:
10
+ * [Premium Add-ons](https://calderawp.com/caldera-forms-add-ons/)
11
+ * [More Information](https://calderawp.com/free-plugin/caldera-forms/)
12
+ * [Documentation](http://docs.calderaforms.com/)
assets/css/admin.css CHANGED
@@ -277,8 +277,8 @@ select.caldera-type-selector {
277
z-index: 100;
278
}
279
.caldera-editor-header.caldera-editor-subnav {
280
- background-color: #F8F8F8;
281
- top: 85px;
282
}
283
.caldera-editor-header .button.caldera-header-save-button,
284
.caldera-editor-header .button.caldera-header-preview-button {
@@ -317,9 +317,11 @@ li.caldera-editor-logo {
317
display: inline-block;
318
padding: 12px 12px;
319
text-decoration: none;
320
}
321
.caldera-editor-header-nav > li.active a {
322
- background: none repeat scroll 0 0 #efefef;
323
}
324
.caldera-editor-header-nav > li.caldera-forms-toolbar-item {
325
padding: 6px 6px 6px 12px;
@@ -697,6 +699,7 @@ a span.error-tag {
697
float: left;
698
margin-left: -430px;
699
width: 430px;
700
}
701
.form-entries-wrap {
702
padding: 0 30px;
@@ -825,8 +828,8 @@ a span.error-tag {
825
top: 0;
826
width: 150px;
827
}
828
- .modal-side-bar .user-avatar,
829
- .modal-side-bar .user-avatar img {
830
float: left;
831
}
832
.modal-side-bar .modal-side-tabs {
@@ -1628,4 +1631,40 @@ tr.form_entry_row.loading {
1628
.caldera-table-nav .tablenav-pages .current-page{
1629
width: 45px;
1630
}
1631
-
277
z-index: 100;
278
}
279
.caldera-editor-header.caldera-editor-subnav {
280
+ background-color: #f0f0f0;
281
+ top: 84px;
282
}
283
.caldera-editor-header .button.caldera-header-save-button,
284
.caldera-editor-header .button.caldera-header-preview-button {
317
display: inline-block;
318
padding: 12px 12px;
319
text-decoration: none;
320
+ color: #839e3f;
321
}
322
.caldera-editor-header-nav > li.active a {
323
+ background: none repeat scroll 0 0 #a3be5f;
324
+ color: #fff;
325
}
326
.caldera-editor-header-nav > li.caldera-forms-toolbar-item {
327
padding: 6px 6px 6px 12px;
699
float: left;
700
margin-left: -430px;
701
width: 430px;
702
+ position: relative;
703
}
704
.form-entries-wrap {
705
padding: 0 30px;
828
top: 0;
829
width: 150px;
830
}
831
+ .user-avatar,
832
+ .user-avatar img {
833
float: left;
834
}
835
.modal-side-bar .modal-side-tabs {
1631
.caldera-table-nav .tablenav-pages .current-page{
1632
width: 45px;
1633
}
1634
+ .cf-notification-external {
1635
+ left: 0;
1636
+ padding: 0 1px 0 0;
1637
+ position: absolute;
1638
+ right: 0;
1639
+ top: -45px;
1640
+ }
1641
+ .cf-notification {
1642
+ background: #fff none repeat scroll 0 0;
1643
+ border: 1px solid #dfdfdf;
1644
+ border-radius: 1px;
1645
+ box-shadow: 0 2px 4px rgba(0, 0, 0, 0.08);
1646
+ left: 0;
1647
+ padding: 0;
1648
+ position: absolute;
1649
+ right: 0;
1650
+ top: -45px;
1651
+ }
1652
+ .cf-notification-notice {
1653
+ height: 20px;
1654
+ overflow: hidden;
1655
+ padding: 8px;
1656
+ text-overflow: ellipsis;
1657
+ white-space: nowrap;
1658
+ }
1659
+ .cf-notification div.error {
1660
+ margin: 1px 0 0 !important;
1661
+ }
1662
+ .cf-notification .dashicons.dashicons-warning{
1663
+ color: #dd3d36;
1664
+ }
1665
+ .cf-notification .dashicons.dashicons-arrow-up,
1666
+ .cf-notification .dashicons.dashicons-arrow-down {
1667
+ cursor: pointer;
1668
+ float: right;
1669
+ padding: 8px;
1670
+ }
assets/css/editor-grid.css CHANGED
@@ -57,6 +57,25 @@
57
content: "\e601";
58
}
59
60
61
62
.column-tools i {
@@ -80,9 +99,20 @@
80
text-align: center;
81
}
82
.column-sort.column-tools {
83
- width: 45px;
84
right: 0;
85
}
86
.column-sort .icon-edit {
87
margin-right: 15px;
88
}
@@ -389,9 +419,6 @@ textarea.magic-tag-enabled {
389
z-index: 101;
390
}
391
392
- .layout-grid-panel{
393
- min-height: 100px;
394
- }
395
396
.template-element.ui-draggable-dragging{
397
z-index: 1000;
57
content: "\e601";
58
}
59
60
+ .add-new-item {
61
+ cursor: pointer;
62
+ text-align: center;
63
+ border: 3px dashed #cfcfcf;
64
+ height: 50px;
65
+ margin: 20px 4px;
66
+ }
67
+ .add-new-item:hover {
68
+ background-color: #e7e7e7;
69
+ border: 3px dashed #a3a3a3;
70
+ }
71
+ .add-new-item .dashicons.dashicons-plus {
72
+ color: #cfcfcf;
73
+ font-size: 28px;
74
+ line-height: 54px;
75
+ }
76
+ .add-new-item:hover .dashicons.dashicons-plus {
77
+ color: #a3a3a3;
78
+ }
79
80
81
.column-tools i {
99
text-align: center;
100
}
101
.column-sort.column-tools {
102
+ width: 25px;
103
right: 0;
104
}
105
+ .column-config.column-tools {
106
+ left: -20px;
107
+ position: absolute;
108
+ top: 29%;
109
+ }
110
+ .column-config.column-tools i {
111
+ border: 2px solid #CFCFCF;
112
+ height: 23px;
113
+ padding: 3px;
114
+ width: 23px;
115
+ }
116
.column-sort .icon-edit {
117
margin-right: 15px;
118
}
419
z-index: 101;
420
}
421
422
423
.template-element.ui-draggable-dragging{
424
z-index: 1000;
assets/css/processors-edit.css CHANGED
@@ -4,8 +4,10 @@
4
width: 250px;
5
}
6
.caldera-editor-processors-panel li{
7
- border-bottom: 1px solid #DFDFDF;
8
- margin: 0;
9
}
10
.caldera-editor-processors-panel a{
11
color: #6F6F6F;
@@ -15,7 +17,7 @@
15
}
16
.caldera-editor-processors-panel li.active a,
17
.caldera-editor-processors-panel a:hover{
18
- background: none repeat scroll 0 0 #E8E8E8;
19
}
20
.caldera-editor-processor-config {
21
float: left;
@@ -57,3 +59,42 @@ button.button.info-button {
57
margin-right: 9px;
58
width: 45px;
59
}
4
width: 250px;
5
}
6
.caldera-editor-processors-panel li{
7
+ border: 1px solid #dfdfdf;
8
+ border-radius: 3px;
9
+ box-shadow: 0 1px 2px rgba(0, 0, 0, 0.06);
10
+ margin: 0 0 6px;
11
}
12
.caldera-editor-processors-panel a{
13
color: #6F6F6F;
17
}
18
.caldera-editor-processors-panel li.active a,
19
.caldera-editor-processors-panel a:hover{
20
+ background: none repeat scroll 0 0 #FFF;
21
}
22
.caldera-editor-processor-config {
23
float: left;
59
margin-right: 9px;
60
width: 45px;
61
}
62
+
63
+
64
+ .caldera-editor-conditions-panel {
65
+ float: left;
66
+ margin-right: 20px;
67
+ width: 250px;
68
+ }
69
+ .caldera-editor-conditions-panel li {
70
+ border: 1px solid #dfdfdf;
71
+ border-radius: 3px;
72
+ box-shadow: 0 1px 2px rgba(0, 0, 0, 0.06);
73
+ margin: 0 0 6px;
74
+ }
75
+ .caldera-editor-conditions-panel a{
76
+ color: #6F6F6F;
77
+ display: block;
78
+ padding: 6px;
79
+ text-decoration: none;
80
+ }
81
+ .caldera-editor-conditions-panel li.active a,
82
+ .caldera-editor-conditions-panel a:hover{
83
+ background: none repeat scroll 0 0 #FFF;
84
+ }
85
+ .caldera-editor-condition-config {
86
+ float: left;
87
+ width: auto;
88
+ }
89
+ .caldera-editor-condition-config-wrapper {
90
+ width: 550px;
91
+ }
92
+ h3.caldera-editor-condition-title {
93
+ border-bottom: 1px solid #CFCFCF;
94
+ color: #3F3F3F;
95
+ font-size: 18px;
96
+ font-weight: 400;
97
+ margin: 0 0 6px;
98
+ padding: 5px 0 12px;
99
+ }
100
+
assets/js/conditionals.js CHANGED
@@ -170,15 +170,15 @@
170
}else{
171
target_field.prop('disabled', false);
172
}
173
}else if (action === 'disable'){
174
if(!target.html().length){
175
target.html(template).trigger('cf.add');
176
- jQuery(document).trigger('cf.add');
177
jQuery('[data-field="' + field + '"]').prop('disabled', 'disabled');
178
}else{
179
target_field.prop('disabled', 'disabled');
180
- jQuery(document).trigger('cf.disable');
181
}
182
}
183
184
}
170
}else{
171
target_field.prop('disabled', false);
172
}
173
+ jQuery(document).trigger('cf.enable');
174
}else if (action === 'disable'){
175
if(!target.html().length){
176
target.html(template).trigger('cf.add');
177
jQuery('[data-field="' + field + '"]').prop('disabled', 'disabled');
178
}else{
179
target_field.prop('disabled', 'disabled');
180
}
181
+ jQuery(document).trigger('cf.disable');
182
}
183
184
}
assets/js/conditionals.min.js CHANGED
@@ -1 +1 @@
1
- !function(a){function b(a){if("undefined"!=typeof caldera_conditionals[a])for(var b in caldera_conditionals[a]){var c=jQuery("#conditional_"+b);if(c.length){var d=caldera_conditionals[a][b].type,e=caldera_conditionals[a][b].group,f=[];for(var g in e){var h={},i=e[g];for(var j in i){var k=jQuery('[data-field="'+i[j].field+"_"+i[j].instance+'"]'),l=[],m="function"==typeof i[j].value?i[j].value():i[j].value;if(h[j]=!1,k.is(":radio,:checkbox")?k=k.filter(":checked"):k.is("div")&&(k=jQuery("<input>").val(k.html())),k.length)for(var n=0;n<k.length;n++)l.push(k[n].value);else l.push(i[j].field);switch(i[j].compare){case"is":l.length&&l.indexOf(m.toString())>=0&&(h[j]=!0);break;case"isnot":l.length&&l.indexOf(m)<0&&(h[j]=!0);break;case">":parseFloat(l.reduce(function(a,b){return a+b}))>parseFloat(m)&&(h[j]=!0);break;case"<":parseFloat(l.reduce(function(a,b){return a+b}))<parseFloat(m)&&(h[j]=!0);break;case"startswith":for(var n=0;n<l.length;n++)l[n].toLowerCase().substr(0,m.toLowerCase().length)===m.toLowerCase()&&(h[j]=!0);break;case"endswith":for(var n=0;n<l.length;n++)l[n].toLowerCase().substr(l[n].toLowerCase().length-m.toLowerCase().length)===m.toLowerCase()&&(h[j]=!0);break;case"contains":for(var n=0;n<l.length;n++)l[n].toLowerCase().indexOf(m)>=0&&(h[j]=!0)}}istrue=!0;for(var o in h)if(h[o]===!1){istrue=!1;break}f.push(istrue)}var s,p=jQuery("#conditional-"+b+"-tmpl").html(),q=jQuery("#conditional_"+b),r=jQuery('[data-field="'+b+'"]');f.length&&f.indexOf(!0)>=0?"show"===d?s="show":"hide"===d?s="hide":"disable"===d&&(s="disable"):s="show"===d?"hide":"disable"===d?"enable":"show","show"===s?q.html().length||(q.html(p).trigger("cf.add"),jQuery(document).trigger("cf.add")):"hide"===s?q.html().length&&(r.val("").empty().prop("checked",!1),q.empty().trigger("cf.remove"),jQuery(document).trigger("cf.remove")):"enable"===s?q.html().length?r.prop("disabled",!1):(q.html(p).trigger("cf.add"),jQuery(document).trigger("cf.add")):"disable"===s&&(q.html().length?(r.prop("disabled","disabled"),jQuery(document).trigger("cf.disable")):(q.html(p).trigger("cf.add"),jQuery(document).trigger("cf.add"),jQuery('[data-field="'+b+'"]').prop("disabled","disabled")))}}}Array.prototype.indexOf||(Array.prototype.indexOf=function(a){var b=this.length>>>0,c=Number(arguments[1])||0;for(c=0>c?Math.ceil(c):Math.floor(c),0>c&&(c+=b);b>c;c++)if(c in this&&this[c]===a)return c;return-1}),"undefined"!=typeof caldera_conditionals&&(jQuery(".caldera_forms_form").on("change keyup","[data-field]",function(){var d=a(this).closest(".caldera_forms_form").prop("id");b(d)}),a(".caldera_forms_form").each(function(){b(a(this).closest(".caldera_forms_form").prop("id"))}))}(jQuery);
1
+ !function(a){function b(a){if("undefined"!=typeof caldera_conditionals[a])for(var b in caldera_conditionals[a]){var c=jQuery("#conditional_"+b);if(c.length){var d=caldera_conditionals[a][b].type,e=caldera_conditionals[a][b].group,f=[];for(var g in e){var h={},i=e[g];for(var j in i){var k=jQuery('[data-field="'+i[j].field+"_"+i[j].instance+'"]'),l=[],m="function"==typeof i[j].value?i[j].value():i[j].value;if(h[j]=!1,k.is(":radio,:checkbox")?k=k.filter(":checked"):k.is("div")&&(k=jQuery("<input>").val(k.html())),k.length)for(var n=0;n<k.length;n++)l.push(k[n].value);else l.push(i[j].field);switch(i[j].compare){case"is":l.length&&l.indexOf(m.toString())>=0&&(h[j]=!0);break;case"isnot":l.length&&l.indexOf(m)<0&&(h[j]=!0);break;case">":parseFloat(l.reduce(function(a,b){return a+b}))>parseFloat(m)&&(h[j]=!0);break;case"<":parseFloat(l.reduce(function(a,b){return a+b}))<parseFloat(m)&&(h[j]=!0);break;case"startswith":for(var n=0;n<l.length;n++)l[n].toLowerCase().substr(0,m.toLowerCase().length)===m.toLowerCase()&&(h[j]=!0);break;case"endswith":for(var n=0;n<l.length;n++)l[n].toLowerCase().substr(l[n].toLowerCase().length-m.toLowerCase().length)===m.toLowerCase()&&(h[j]=!0);break;case"contains":for(var n=0;n<l.length;n++)l[n].toLowerCase().indexOf(m)>=0&&(h[j]=!0)}}istrue=!0;for(var o in h)if(h[o]===!1){istrue=!1;break}f.push(istrue)}var s,p=jQuery("#conditional-"+b+"-tmpl").html(),q=jQuery("#conditional_"+b),r=jQuery('[data-field="'+b+'"]');f.length&&f.indexOf(!0)>=0?"show"===d?s="show":"hide"===d?s="hide":"disable"===d&&(s="disable"):s="show"===d?"hide":"disable"===d?"enable":"show","show"===s?q.html().length||(q.html(p).trigger("cf.add"),jQuery(document).trigger("cf.add")):"hide"===s?q.html().length&&(r.val("").empty().prop("checked",!1),q.empty().trigger("cf.remove"),jQuery(document).trigger("cf.remove")):"enable"===s?(q.html().length?r.prop("disabled",!1):(q.html(p).trigger("cf.add"),jQuery(document).trigger("cf.add")),jQuery(document).trigger("cf.enable")):"disable"===s&&(q.html().length?r.prop("disabled","disabled"):(q.html(p).trigger("cf.add"),jQuery('[data-field="'+b+'"]').prop("disabled","disabled")),jQuery(document).trigger("cf.disable"))}}}Array.prototype.indexOf||(Array.prototype.indexOf=function(a){var b=this.length>>>0,c=Number(arguments[1])||0;for(c=0>c?Math.ceil(c):Math.floor(c),0>c&&(c+=b);b>c;c++)if(c in this&&this[c]===a)return c;return-1}),"undefined"!=typeof caldera_conditionals&&(jQuery(".caldera_forms_form").on("change keyup","[data-field]",function(){var d=a(this).closest(".caldera_forms_form").prop("id");b(d)}),a(".caldera_forms_form").each(function(){b(a(this).closest(".caldera_forms_form").prop("id"))}))}(jQuery);
assets/js/edit.js CHANGED
@@ -853,7 +853,7 @@ jQuery(document).ready(function($){
853
854
var select = $(this);
855
856
- if(this.value !== ''){
857
$('#' + select.data('id') + '_condition_group_add').show();
858
$('#' + select.data('id') + '_conditional_wrap').show();
859
}else{
@@ -1184,25 +1184,26 @@ init_magic_tags = function(){
1184
currentwrapper.show();
1185
}
1186
return;
1187
- }
1188
- var magictag = jQuery('<span class="icn-code magic-tag-init"></span>'),
1189
- wrapper = jQuery('<span style="position:relative;display:inline-block; width:100%;"></span>');
1190
1191
- if(input.is('input')){
1192
- magictag.css('borderBottom', 'none');
1193
- }
1194
1195
- if(input.hasClass('caldera-conditional-value-field')){
1196
- wrapper.width('auto');
1197
- }
1198
1199
- input.wrap(wrapper);
1200
- magictag.insertAfter(input);
1201
- input.addClass('magic-tag-init-bound');
1202
- if(!input.is(':visible')){
1203
- magictag.hide();
1204
- }else{
1205
- magictag.show();
1206
}
1207
});
1208
@@ -1837,7 +1838,10 @@ jQuery(document).ready(function($) {
1837
$('.caldera-add-page').trigger('click');
1838
return;
1839
}
1840
- $('.page-active').append('<div class="first-row-level row"><div class="col-xs-12"><div class="layout-column column-container"></div></div></div>');
1841
buildSortables();
1842
buildLayoutString();
1843
});
@@ -1981,7 +1985,8 @@ jQuery(document).ready(function($) {
1981
}
1982
1983
$(document).trigger('show.' + panel.data('config'));
1984
-
1985
if( type === 'radio' || type === 'checkbox' || type === 'dropdown' || type === 'toggle_switch' ){
1986
$('#' + panel.data('config') + '_auto').trigger('change');
1987
}
@@ -2373,6 +2378,21 @@ jQuery(document).ready(function($){
2373
2374
rebuild_field_binding();
2375
baldrickTriggers();
2376
}
2377
2378
// build configs on load:
853
854
var select = $(this);
855
856
+ if( this.value === 'show' || this.value === 'hide' || this.value === 'disable' || this.value === 'use' || this.value === 'not' ){
857
$('#' + select.data('id') + '_condition_group_add').show();
858
$('#' + select.data('id') + '_conditional_wrap').show();
859
}else{
1184
currentwrapper.show();
1185
}
1186
return;
1187
+ }else{
1188
+ var magictag = jQuery('<span class="icn-code magic-tag-init"></span>'),
1189
+ wrapper = jQuery('<span style="position:relative;display:inline-block; width:100%;"></span>');
1190
1191
+ if(input.is('input')){
1192
+ magictag.css('borderBottom', 'none');
1193
+ }
1194
1195
+ if(input.hasClass('caldera-conditional-value-field')){
1196
+ wrapper.width('auto');
1197
+ }
1198
1199
+ input.wrap(wrapper);
1200
+ magictag.insertAfter(input);
1201
+ input.addClass('magic-tag-init-bound');
1202
+ if(!input.is(':visible')){
1203
+ magictag.hide();
1204
+ }else{
1205
+ magictag.show();
1206
+ }
1207
}
1208
});
1209
1838
$('.caldera-add-page').trigger('click');
1839
return;
1840
}
1841
+ var new_row = $( '<div style="display:none;" class="first-row-level row"><div class="col-xs-12"><div class="layout-column column-container"></div></div></div>' );
1842
+
1843
+ $('.page-active').append( new_row );
1844
+ new_row.slideDown( 200 );
1845
buildSortables();
1846
buildLayoutString();
1847
});
1985
}
1986
1987
$(document).trigger('show.' + panel.data('config'));
1988
+ $(document).trigger('show.fieldedit');
1989
+
1990
if( type === 'radio' || type === 'checkbox' || type === 'dropdown' || type === 'toggle_switch' ){
1991
$('#' + panel.data('config') + '_auto').trigger('change');
1992
}
2378
2379
rebuild_field_binding();
2380
baldrickTriggers();
2381
+
2382
+ // initialise baldrick triggers
2383
+ $('.wp-baldrick').baldrick({
2384
+ request : ajaxurl,
2385
+ method : 'POST',
2386
+ before : function(el){
2387
+
2388
+ var tr = $(el);
2389
+
2390
+ if( tr.data('addNode') && !tr.data('request') ){
2391
+ tr.data('request', 'cf_get_default_setting');
2392
+ }
2393
+ }
2394
+ });
2395
+
2396
}
2397
2398
// build configs on load:
assets/js/edit.min.js CHANGED
@@ -1,2 +1,2 @@
1
- function new_conditional_group(a){var b=a.trigger.data("id"),c="cl"+Math.round(18746582734*Math.random()),d="rw"+Math.round(98347598345*Math.random()),e=[{id:d,type:a.trigger.data("type"),lines:[{id:c}]}];return{group:e,id:b}}function new_conditional_line(a){var b=a.trigger.data("id"),c=a.trigger.data("group"),d=a.trigger.data("type"),e="cl"+Math.round(18746582734*Math.random()),f={id:b,type:d,lineid:e,rowid:c,name:"config["+d+"]["+b+"][conditions][group]["+c+"]["+e+"]"};return f}function build_conditions_config(a){var b=JSON.parse(a.trigger.val());return b.id=a.trigger.data("id"),b}function setup_field_type(a){return{id:a.trigger.prop("id")}}function check_required_bindings(a){var b,d=(jQuery(".caldera-header-save-button"),jQuery(".layout-form-field")),e=jQuery(".caldera-processor-nav"),f=!0;b=a?jQuery(a):jQuery(".caldera-config-field .required"),b.removeClass("has-error"),d.removeClass("has-error"),e.removeClass("has-error"),jQuery(".error-tag").remove(),required_errors={},b.each(function(a,b){var c=jQuery(b),d=c.closest(".caldera-config-editor-panel");if(b.value.length){if(c.hasClass("field-slug"))for(var h=jQuery(".field-slug").not(c),i=0;i<h.length;i++)if(h[i].value===b.value){var c=jQuery(h[i]);required_errors[d.prop("id")]||(required_errors[d.prop("id")]=0);var e=c.closest(".caldera-editor-field-config-wrapper"),g=c.closest(".caldera-editor-processor-config-wrapper");e.length&&jQuery('.layout-form-field[data-config="'+e.prop("id")+'"]').addClass("has-error"),g.length&&jQuery("."+g.prop("id")).addClass("has-error"),required_errors[d.prop("id")]+=1,c.addClass("has-error");break}}else{required_errors[d.prop("id")]||(required_errors[d.prop("id")]=0);var e=c.closest(".caldera-editor-field-config-wrapper"),g=c.closest(".caldera-editor-processor-config-wrapper");e.length&&jQuery('.layout-form-field[data-config="'+e.prop("id")+'"]').addClass("has-error"),g.length&&jQuery("."+g.prop("id")).addClass("has-error"),required_errors[d.prop("id")]+=1,c.addClass("has-error"),f=!1}});for(var g in required_errors)jQuery(".caldera-forms-options-form").find('a[href="#'+g+'"]').append('<span class="error-tag">'+required_errors[g]+"</span>");return jQuery(".preview-caldera-config-group button:submit").length?(jQuery(".mailer-errors").hide(),jQuery(".mailer-control-panel").show()):(jQuery(".mailer-errors").show(),jQuery(".mailer-control-panel").hide()),jQuery(".caldera-conditional-field-set").trigger("change"),f}jQuery(document).ready(function(a){function b(b){var d=a(b),e=d.closest(".caldera-editor-field-config-wrapper"),f=e.find(".caldera-config-field-setup"),g=compiled_templates[d.val()+"_tmpl"]?compiled_templates[d.val()+"_tmpl"]:compiled_templates.noconfig_field_templ,h=e.find(".field_config_string").val(),i=d.data("type");if(e.find(".caldera-config-group").show(),d.addClass("field-initialized"),h=h.length&&i===d.val()?JSON.parse(h):fieldtype_defaults[d.val()+"_cfg"],h||(h={}),h._id=d.data("field"),h._name="config[fields]["+d.data("field")+"][config]",g=a("<div>").html(g(h)),f.html(g.html()),"function"==typeof window[d.val()+"_init"]&&window[d.val()+"_init"](d.data("field"),f),fieldtype_defaults[d.val()+"_nosupport"]&&(fieldtype_defaults[d.val()+"_nosupport"].indexOf("hide_label")>=0&&e.find(".hide-label-field").hide().find(".field-config").prop("checked",!1),fieldtype_defaults[d.val()+"_nosupport"].indexOf("caption")>=0&&e.find(".caption-field").hide().find(".field-config").val(""),fieldtype_defaults[d.val()+"_nosupport"].indexOf("required")>=0&&e.find(".required-field").hide().find(".field-config").prop("checked",!1),fieldtype_defaults[d.val()+"_nosupport"].indexOf("custom_class")>=0&&e.find(".customclass-field").hide().find(".field-config").val(""),fieldtype_defaults[d.val()+"_nosupport"].indexOf("entry_list")>=0&&e.find(".entrylist-field").hide().find(".field-config").prop("checked",!1)),e.find(".toggle_show_values").trigger("change"),!a(".caldera-select-field-type").not(".field-initialized").length){if(core_form.hasClass("builder-loaded"))c(d.data("field"));else{for(var j=a(".caldera-select-field-type.field-initialized"),k=0;k<j.length;k++)c(a(j[k]).data("field"));core_form.addClass("builder-loaded")}rebuild_field_binding(),baldrickTriggers()}}function c(b){var c=a("#"+b),d=c.find(".caldera-select-field-type"),e=a('.layout-form-field[data-config="'+b+'"]'),f=e.find(".field_preview"),h=(a("#preview-"+d.val()+"_tmpl").html(),compiled_templates["preview-"+d.val()+"_tmpl"]),i={id:b},j=c.find(".field-config");j.each(function(c,d){for(var e=a(d),f=e.prop("name").split("["+b+"]")[1].substr(1),g=f.substr(0,f.length-1).split("]["),h=e.is(":checkbox,:radio")?e.filter(":checked").val():e.val(),j={},k=g.length-1;k>=0;k--)if(k===g.length-1)j[g[k]]=h;else{var l=j;j={},j[g[k]]=l}a.extend(!0,i,j)}),f.html(h(i)),e.removeClass("button"),a(".preview-field-config").prop("disabled",!0)}function d(b){var t,c=a(".caldera-editor-fields-panel"),e=(a(".caldera-editor-groups-panel"),a(".caldera-group-nav")),f=a('[data-group="'+b+'"]'),g=f.find(".caldera-config-group-name"),h=f.find(".caldera-config-group-slug"),i=f.find(".caldera-config-group-desc"),j=f.find(".caldera-config-group-admin"),k=a(".active-group-name"),l=a(".active-group-slug"),m=a(".active-group-desc"),n=a(".active-group-admin"),o=a(".caldera-editor-fields-list ul"),p=f.find(".caldera-config-group-repeat"),q=a(".repeat-config-button"),s=(a(".caldera-editor-group-settings"),a(".caldera-config-group-remove"));a(".new-group-input").remove(),a(".new-field-input").remove(),e.removeClass("active"),c.show(),o.hide(),o.removeClass("active").find("li.active").removeClass("active"),o.hide(),f.addClass("active"),t=a(".caldera-editor-fields-list ul.active li"),t.length?s.hide():s.show(),a(".caldera-editor-field-config-wrapper").hide(),f.show(),k.val(g.val()),l.val(h.val()),m.val(i.val()),"1"===j.val()?n.prop("checked",!0):n.prop("checked",!1),"1"===p.val()?q.addClass("field-edit-open"):q.removeClass("field-edit-open")}a(".caldera-header-save-button").baldrick({method:"POST",request:"admin.php?page=caldera-forms",before:function(b,c){if(c.preventDefault(),!check_required_bindings())return!1;a("#save_indicator").addClass("loading"),"undefined"!=typeof tinyMCE&&tinyMCE.triggerSave();var d=a(".caldera-forms-options-form").formJSON();return a(b).data("cf_edit_nonce",d.cf_edit_nonce),a(b).data("_wp_http_referer",d._wp_http_referer),a(b).data("sender","ajax"),a(b).data("config",JSON.stringify(d.config)),!0},callback:function(b){if(!1===b.data){var c=a(".updated_notice_box");c.stop().animate({top:0},200,function(){setTimeout(function(){c.stop().animate({top:-75},200)},2e3)})}},complete:function(){a(".wrapper-instance-pane .field-config").prop("disabled",!1)}}),a("body").on("click",".toggle_option_tab > a",function(b){b.preventDefault();var c=a(this),d=a(c.attr("href")),e=c.parent().find("a"),f=c.closest(".caldera-editor-config-wrapper").find(".wrapper-instance-pane");e.removeClass("button-primary"),f.hide(),d.show(),c.addClass("button-primary"),a(".caldera-conditionals-usetype").trigger("change")}),a(".caldera-editor-body").on("change",".caldera-select-field-type",function(){b(this)}),a(".caldera-editor-body").on("click",".caldera-group-nav a",function(b){b.preventDefault(),d(a(this).attr("href").substr(1))}),a(".caldera-editor-body").on("click",".caldera-editor-fields-list a",function(b){b.preventDefault();var c=a(this),d=a(c.attr("href"));a(".new-group-input").remove(),a(".new-field-input").remove(),a(".caldera-editor-fields-list li.active").removeClass("active"),c.parent().addClass("active"),a(".caldera-editor-field-config-wrapper").hide(),d.show()}),a(".caldera-editor-body").on("click",".group-config-button",function(){var c=a(this),d=a(".caldera-editor-group-settings"),e=c.closest(".caldera-editor-fields-panel"),f=a(".caldera-config-group-remove");e.find(".caldera-field-line").length?f.hide():f.show(),c.hasClass("field-edit-open")?(d.slideUp(100),c.removeClass("field-edit-open")):(d.slideDown(100),c.addClass("field-edit-open"))}),a(".caldera-editor-body").on("keydown",".field-config",function(b){a(this).is("textarea")||13===b.which&&b.preventDefault()}),a(".caldera-editor-body").on("change",".field-label",function(b){var c=a(this).closest(".caldera-editor-field-config-wrapper").prop("id");field_line=a('[data-field="'+c+'"]'),field_title=a("#"+c+" .caldera-editor-field-title, .layout-form-field.field-edit-open .layout_field_name"),slug=a("#"+c+" .field-slug"),field_line.find("a").html('<i class="icn-field"></i> '+this.value),field_title.text(this.value),"change"===b.type&&slug.trigger("change"),rebuild_field_binding()}),a(".caldera-editor-body").on("change",".active-group-name",function(b){b.preventDefault();var c=a(".caldera-group-nav.active"),e=(c.data("group"),c.find(".caldera-config-group-name")),f=c.find("span");"focusout"!==b.type||this.value.length||(this.value="Group "+(parseInt(c.index())+1)),e.val(this.value),f.text(this.value)}),a(".caldera-editor-body").on("change",".active-group-slug",function(b){b.preventDefault();var c=a(".caldera-group-nav.active"),e=(c.data("group"),c.find(".caldera-config-group-name").val()),f=c.find(".caldera-config-group-slug"),h=(c.find("span"),this.value.split(" ").join("_").split("-").join("_").replace(/[^a-z0-9_]/gi,"").toLowerCase());"focusout"!==b.type||this.value.length||(h=e.split(" ").join("_").split("-").join("_").replace(/[^a-z0-9_]/gi,"").toLowerCase()),f.val(h),this.value=h}),a(".caldera-editor-body").on("change",".active-group-desc",function(b){b.preventDefault();var c=a(".caldera-group-nav.active"),e=(c.data("group"),c.find(".caldera-config-group-desc"));e.val(this.value)}),a(".caldera-editor-body").on("change",".active-group-admin",function(b){b.preventDefault();var c=a(".caldera-group-nav.active"),f=(c.data("group"),c.find(".caldera-config-group-name").val(),c.find(".caldera-config-group-admin"));c.find("span"),this.value.split(" ").join("_").split("-").join("_").replace(/[^a-z0-9_]/gi,"").toLowerCase(),a(this).prop("checked")?(f.val(1),c.addClass("is-admin")):(f.val(0),c.removeClass("is-admin"))}),a(".caldera-editor-body").on("click",".repeat-config-button",function(b){b.preventDefault();var c=a(".caldera-group-nav.active"),e=(c.data("group"),c.find("a .group-type")),f=c.find(".caldera-config-group-repeat"),g=a(this);g.hasClass("field-edit-open")?(f.val("0"),e.removeClass("icn-repeat").addClass("icn-folder"),g.removeClass("field-edit-open")):(f.val("1"),e.addClass("icn-repeat").removeClass("icn-folder"),g.addClass("field-edit-open"))}),a(".caldera-editor-body").on("click",".delete-field",function(){var b=a(this),c=b.closest(".caldera-editor-field-config-wrapper").prop("id");confirm(b.data("confirm"))&&(a("#"+c).remove(),a('option[value="'+c+'"]').remove(),a('[data-bind="'+c+'"]').remove(),delete current_form_fields[c],a('[data-config="'+c+'"]').slideUp(200,function(){var b=a(this);b.remove(),rebuild_field_binding(),a(document).trigger("field.removed")}))}),a(".caldera-editor-body").on("click",".add-new-group,.add-field",function(){var b=a(this);if(a(".new-group-input").remove(),a(".new-field-input").remove(),b.hasClass("add-field")){var c=a('<input type="text" class="new-field-input block-input">');c.appendTo(a(".caldera-editor-fields-list ul.active")).focus()}else{var d=a('<input type="text" class="new-group-input block-input">');d.appendTo(a(".caldera-editor-groups-panel")).focus()}}),a(".caldera-editor-body").on("change keypress",".new-group-input",function(b){if("keypress"===b.type){if(13!==b.which)return;b.preventDefault()}var h,i,c=this.value,e=a(this),f=a(".caldera-editor-groups-panel ul"),g=a(".caldera-editor-fields-list");if(c.length){h=Handlebars.compile(a("#caldera_group_line_templ").html()),i={id:c.split(" ").join("_").split("-").join("_").replace(/[^a-z0-9_]/gi,"").toLowerCase(),name:c},f.append(h(i));var j=a('<ul data-group="'+i.id+'">').hide();j.appendTo(g),e.remove(),d(i.id)}else e.remove()}),a(".caldera-editor-body").on("change keypress",".new-field-input",function(b){if("keypress"===b.type){if(13!==b.which)return;b.preventDefault()}var g,h,i,c=this.value,d=a(this),e=d.parent(),f=a(".caldera-editor-field-config"),j=a(".caldera-config-group-remove");if(c.length){j.hide(),g=Handlebars.compile(a("#caldera_field_line_templ").html()),h=Handlebars.compile(a("#caldera_field_config_wrapper_templ").html()),i={id:c.split(" ").join("_").split("-").join("_").replace(/[^a-z0-9_]/gi,"").toLowerCase(),label:c,slug:c.split(" ").join("_").split("-").join("_").replace(/[^a-z0-9_]/gi,"").toLowerCase(),group:a(".caldera-group-nav.active").data("group")};var k=a(g(i));k.appendTo(e),f.append(h(i)),k.find("a").trigger("click"),d.remove()}else d.remove()}),a(".caldera-editor-body").on("change",".field-slug",function(b){this.value.length?this.value=this.value.split(" ").join("_").split("-").join("_").replace(/[^a-z0-9_]/gi,"").toLowerCase():"change"===b.type&&(this.value=a(this).closest(".caldera-editor-field-config-wrapper").find(".field-label").val().split(" ").join("_").split("-").join("_").replace(/[^a-z0-9_]/gi,"").toLowerCase())}),a(".caldera-editor-body").on("click",".caldera-add-group",function(){var c=a(this),d=c.data("group"),e=a("#"+d+"_panel_tmpl").html();c.parent().parent().append(e)}),a(".caldera-editor-body").on("click",".caldera-config-group-remove",function(){var c=a(".active-group-slug").val();a('[data-group="'+c+'"]').hide(0,function(){a(this).remove();var b=a(".caldera-group-nav");b.length?b.first().find("a").trigger("click"):a(".caldera-editor-fields-panel").hide()})}),a("body").on("click",".set-current-field",function(b){b.preventDefault();var c=a(this);a("#"+c.data("field")+"_type").val(c.data("type")).trigger("change"),a("#"+c.data("field")+"_lable").focus(),a("#field_setup_baldrickModalCloser").trigger("click")}),a(".caldera-editor-body").on("change",".field-config",function(){var d=a(this),e=d.closest(".caldera-editor-field-config-wrapper");current_form_fields&&(d.prop("id")===e.prop("id")+"_lable"&&(current_form_fields[e.prop("id")].label=this.value),d.prop("id")===e.prop("id")+"_slug"&&(current_form_fields[e.prop("id")].slug=this.value),d.prop("id")===e.prop("id")+"_type"&&(current_form_fields[e.prop("id")].type=this.value),e.length&&c(e.prop("id")))}),a(".caldera-editor-body").on("focus",".caldera-field-bind",function(b){var c=a(this),d=this.value;return console.log(b.type),b.type&&"focusin"===b.type?(c.removeClass("bound_field").addClass("reload-binding"),rebind_field_bindings(),this.value=d,void 0):void 0}),a(".caldera-editor-body").on("change",".caldera-conditional-field-set",function(){var k,l,c=a(this),d=c.parent().find(".compare-type"),e=c.data("condition"),f=c.data("id"),g="config["+e+"]["+f+"][conditions][group]["+c.data("row")+"]["+c.data("line")+"]",h=c.data("line"),i=a("#"+h+"_value"),j=i.find(".caldera-conditional-value-field").first(),m=[],n=this.value;if("{"!==n.substr(0,1)&&(k=a("#"+n),l=k.find(".field-button-type"),m=k.find(".caldera-config-group-toggle-options")),c.hasClass(".bind_init")&&c.addClass("bound_triggered"),j.length&&j.val().length&&i.data("value",j.val()),d.show(),m.length){var o=m.find(".toggle_option_row"),p='<select name="'+g+'[value]" class="caldera-processor-value-bind caldera-conditional-value-field" data-field="'+n+'" style="max-width: 220px; width: 220px;">';p+='<option value=""></option>',o.each(function(b,c){var d=a(c).find(".toggle_label_field"),e=d.data("option"),f="";i.data("value")&&(i.data("value").toString()===e||i.data("value").toString()===a(c).find(".toggle_value_field").val())&&(f=' selected="selected"'),p+='<option value="'+e+'"'+f+">"+d.val()+"</option>"}),p+="</select>"}else l&&"button"==l.val()?(d.val("is").hide(),p='<select name="'+g+'[value]" class="caldera-processor-value-bind caldera-conditional-value-field" data-field="'+n+'" style="max-width: 220px; width: 220px;">',p+='<option value="click" '+("click"===i.data("value")?'selected="selected"':"")+">Click</option>",p+='<option value="dblclick" '+("dblclick"===i.data("value")?'selected="selected"':"")+">Double Click</option>",p+="</select>"):p='<input name="'+g+'[value]" type="text" class="caldera-conditional-value-field magic-tag-enabled" value="'+(i.data("value")?i.data("value"):"")+'" style="max-width: 205px;">';i.html(p),init_magic_tags()}),a(".caldera-editor-body").on("change",".caldera-conditionals-usetype",function(){var c=a(this);""!==this.value?(a("#"+c.data("id")+"_condition_group_add").show(),a("#"+c.data("id")+"_conditional_wrap").show()):(a("#"+c.data("id")+"_condition_group_add").hide(),a("#"+c.data("id")+"_conditional_wrap").hide())}),a(".caldera-editor-body").on("click",".remove-conditional-line",function(b){b.preventDefault();var c=a(this),d=c.closest(".caldera-condition-line"),e=c.closest(".caldera-condition-group");d.remove(),e.find(".caldera-condition-line").length||e.remove()}),a(".caldera-group-nav").first().find("a").trigger("click"),a(".caldera-editor-body").on("change",".toggle_show_values",function(){var c=a(this),d=c.closest(".caldera-config-group-toggle-options");values=d.find(".toggle_value_field"),lables=d.find(".toggle_label_field"),field_lables=d.find(".caldera-config-group-option-labels"),c.prop("checked")?(values.show().parent().show(),values.show().parent().parent().show(),lables.css("width",""),field_lables.show()):(values.hide().parent().hide(),lables.css("width",245),field_lables.hide()),lables.trigger("toggle.values"),init_magic_tags()}),a(".caldera-editor-body").on("change",".auto-populate-type",function(){a(this).closest(".wrapper-instance-pane").find(".auto-populate-options").trigger("change")}),a(".caldera-editor-body").on("change",".auto-populate-options",function(){var b=a(this),c=b.closest(".wrapper-instance-pane"),d=c.find(".caldera-config-group-toggle-options"),e=c.find(".caldera-config-group-auto-options"),f=e.find(".auto-populate-type");e.find(".auto-populate-type-panel").hide(),b.prop("checked")?(d.hide(),e.show()):(d.show(),e.hide()),e.find(".caldera-config-group-auto-"+f.val()).show()}),a("body").on("change",".pin-toggle-roles",function(){var b=a(this),c=a("#caldera-pin-rules");"1"===b.val()?c.show():c.hide()}),a("body").on("click",".magic-tag-init",function(){var c=a(this),d=c.prev();d.focus().trigger("init.magic")}),a("body").on("keyup blur focus select click init.magic",".magic-tag-enabled",function(b){init_magic_tags();var c=a(this),d=c.parent(),e=d.closest(".wrapper-instance-pane").find(".caldera-select-field-type").val()?d.closest(".wrapper-instance-pane").find(".caldera-select-field-type").val():"hidden",f=d.find(".magic-tags-autocomplete"),g=f.find("ul"),h=this.value,j=[],k="",l=this.selectionStart,m=this.selectionEnd;if(f.length&&f.data("focus"))return b.preventDefault(),void 0;if(c.data("tag",""),this.selectionEnd>this.selectionStart)k=this.value.substr(this.selectionStart,this.selectionEnd-this.selectionStart);else if(("select"===b.type||"keyup"===b.type)&&40!==b.which&&38!==b.which&&39!==b.which&&37!==b.which){for(l=this.selectionStart;l>0;l--){var n=h.substr(l-1,1);if(" "===n||"\n"===n||("%"===n||"}"===n)&&this.selectionStart===l)break}for(m=this.selectionStart;m<h.length;m++){var n=h.substr(m,1);if(" "===n||"\n"===n||("%"===n||"{"===n)&&this.selectionStart===m)break}k=h.substr(l,m-l)}if("focusout"!==b.type){if("init"!==b.type&&k.length<3)return f.length&&f.remove(),void 0;f.length||(f=a('<div class="magic-tags-autocomplete"></div>'),g=a("<ul></ul>"),g.appendTo(f),f.insertAfter(c),f.on("mouseenter",function(){a(this).data("focus",!0)}),f.on("mouseleave",function(){a(this).data("focus",!1),c.is(":focus")||c.trigger("focusout")})),g.empty();var o="system",p=!1;"hidden"===e||"dropdown"===e||"radio"===e||"toggle_switch"===e||"checkbox"===e?(p=!0,e="text",o="all"):("paragraph"===e||"html"===e)&&(e="text"),c.data("type")&&(e=c.data("type")),e=e.split(","),e.push("vars");for(var q=0;q<e.length;q++)for(var r in system_values)if("undefined"!=typeof system_values[r].tags[e[q]]){if(j=[r],"system"!==r&&"variable"!==r&&"field"!==r){var s=jQuery(".processor-"+r),t=c.closest(".caldera-editor-processor-config-wrapper"),u=t.prop("id");j=[];for(var v=0;v<s.length;v++)if(t.length||p!==!0){if(u===s[v].id)continue;jQuery("li."+s[v].id).index()<jQuery("li."+u).index()&&j.push(s[v].id)}else j.push(s[v].id)}for(var w=0;w<j.length;w++)if("all"===o||o===r||"variable"===r){var x=a('<li class="header">'+system_values[r].type+(w>0?" ["+(w+1)+"]":"")+"</li>"),y=0;x.appendTo(g);for(var z=0;z<system_values[r].tags[e[q]].length;z++)if(!c.data("parent")||"variable:"+c.data("parent")!==system_values[r].tags[e[q]][z]){var A=system_values[r].wrap[0]+system_values[r].tags[e[q]][z]+system_values[r].wrap[1];if(j[w]!==r&&j.length>1&&(A=system_values[r].wrap[0]+system_values[r].tags[e[q]][z]+":"+j[w]+system_values[r].wrap[1]),A.indexOf(k)>=0||"init"===b.type){y+=1;var B=A.replace(k,"<strong>"+k+"</strong>"),C=a('<li class="tag" data-tag="'+A+'">'+B+"</li>");C.on("click",function(){var b=a(this).data("tag");c.val(h.substr(0,l)+b+h.substr(m)).trigger("change").focus(),c[0].selectionStart=l+b.length-(b.indexOf("*")>0?2:0),c[0].selectionEnd=l+b.length-(b.indexOf("*")>0?1:0)}),C.appendTo(g)}}0===y&&x.remove()}}}g.children().length||f.remove(),"focusout"===b.type&&setTimeout(function(){f.remove()},200)});for(var e=a(".cf-editor-template"),f=0;f<e.length;f++)compiled_templates[e[f].id]=Handlebars.compile(e[f].innerHTML);a(".caldera-select-field-type").not(".field-initialized").each(function(a,c){b(c)})});var rebuild_field_binding,rebind_field_bindings,current_form_fields={},required_errors={},add_new_grid_page,add_page_grid,init_magic_tags,core_form,compiled_templates={};init_magic_tags=function(){var a=jQuery(".magic-tag-enabled");a.each(function(a,b){var c=jQuery(b);if(c.hasClass("magic-tag-init-bound")){var d=c.parent().find(".magic-tag-init");return c.is(":visible")?d.show():d.hide(),void 0}var e=jQuery('<span class="icn-code magic-tag-init"></span>'),f=jQuery('<span style="position:relative;display:inline-block; width:100%;"></span>');c.is("input")&&e.css("borderBottom","none"),c.hasClass("caldera-conditional-value-field")&&f.width("auto"),c.wrap(f),e.insertAfter(c),c.addClass("magic-tag-init-bound"),c.is(":visible")?e.show():e.hide()})},rebuild_field_binding=function(){if(core_form||(core_form=jQuery(".caldera-forms-options-form")),core_form.hasClass("builder-loaded")){var a=jQuery(".caldera-editor-field-config-wrapper");system_values.field={tags:{text:[]},type:"Fields",wrap:["%","%"]};for(var b=0;b<a.length;b++){var c=a[b].id,d=jQuery("#"+c+"_lable").val(),e=jQuery("#"+c+"_slug").val(),f=jQuery("#"+c+"_type").val();"undefined"==typeof system_values.field.tags[f]&&(system_values.field.tags[f]=[]),system_values.field.tags[f].push(e),"text"!==f&&system_values.field.tags.text.push(e),current_form_fields[c]={label:d,slug:e,type:f},jQuery("option.bound-field").trigger("change").each(function(a,b){var c=jQuery(b);0!==c.prop("value").indexOf("{")?c.text(jQuery("#"+c.prop("value")+"_lable").val()+" ["+jQuery("#"+c.prop("value")+"_lable").val()+"]"):c.text(c.prop("value").replace("{","").replace("}",""))}).removeClass("bound-field")}}},rebind_field_bindings=function(){var b,c,a=jQuery(".caldera-field-bind").not(".bound_field");if(a.length){a.addClass("bound_field");for(var d=0;d<a.length;d++){var e=jQuery(a[d]),f=e.val(),g=e.data("default"),h=e.data("exclude"),i=0,j=e.closest(".caldera-editor-processor-config-wrapper"),k=j.prop("id"),l="";if(g&&!e.hasClass("reload-binding")&&(f=g),e.is("select")){e.empty();var m=jQuery('<optgroup label="Fields">');for(var n in current_form_fields)e.data("type")&&e.data("type").split(",").indexOf(current_form_fields[n].type)<0||(e.data("id")!==n&&m.append('<option value="'+n+'"'+(f===n?'selected="selected"':"")+">"+current_form_fields[n].label+" ["+current_form_fields[n].slug+"]</option>"),i+=1);m.appendTo(e),0===i&&e.empty();for(var o in system_values)if(b=[],!(h&&h.split(",").indexOf(o)>=0)){if("system"!==o&&"variable"!==o)for(var p=jQuery(".processor-"+o),q=0;q<p.length;q++)k!==p[q].id&&(b.push(p[q].id),p.length>1&&(c=jQuery("li."+p[q].id+" .processor-line-number"))&&c.html("["+(q+1)+"]"));else b.push("__system__");var r=[];e.data("type")?(r=e.data("type").split(","),r.push("vars")):r=["text","vars"];for(var s=0;s<r.length;s++)if(system_values[o].tags[r[s]])for(var t=0;t<b.length;t++){jQuery("li."+b[t]).index()>jQuery("li."+k).index()&&"__system__"!==b[t]?e.closest(".caldera-editor-processors-panel-wrap").length&&(l=' disabled="disabled"'):l="";for(var m=jQuery('<optgroup label="'+system_values[o].type+("__system__"!==b[t]?" "+jQuery("li."+b[t]).find(".processor-line-number").html():"")+'"'+l+">"),u=0;u<system_values[o].tags[r[s]].length;u++){var v=system_values[o].tags[r[s]][u];"__system__"!==b[t]&&(v=v.replace(o,b[t])),m.append('<option value="{'+v+'}"'+(f==="{"+v+"}"?'selected="selected"':"")+l+">"+system_values[o].tags[r[s]][u]+"</option>"),i+=1}m.children().length&&m.appendTo(e)}}if(0===i){if(e.empty(),e.data("type")){e.append('<option value="">No '+e.data("type").split(",").join(" or ")+" in form</option>");var w=!0}}else e.prop("disabled",!1);e.hasClass("required")||"undefined"!=typeof w||e.prepend('<option value=""></option>'),e.val(f)}}init_magic_tags(),jQuery(document).trigger("bound.fields"),jQuery(".caldera-header-save-button").prop("disabled",!1)}},jQuery(document).ready(function(a){function b(){var b=a(".layout-grid-panel"),c=0;b.each(function(b,d){var e=a(d),f=e.find(".layout-structure"),g=e.find(".row"),h=[];g.each(function(b,d){var e=a(d),f=e.children().not(".column-merge"),g=[];c+=1,f.each(function(b,d){span=a(d).attr("class").split("-"),g.push(span[2]);var e=a(d).find(".field-location");e.length&&e.each(function(d,e){var f=a(e);f.val(c+":"+(b+1)).removeAttr("disabled")})}),h.push(g.join(":"))}),f.val(h.join("|"))})}function c(b,c,e){var i,j,f="fld_"+Math.round(1e7*Math.random()),g=f,h=a("#field_config_panels");if(e){var k=a("#"+e).clone().wrap("<div>").parent().html().replace(new RegExp(e,"g"),"{{id}}");i=Handlebars.compile(k)}else i=Handlebars.compile(a("#caldera_field_config_wrapper_templ").html());j={id:g,label:"",slug:""},h.append(i(j)),b.removeClass("button-small").removeClass("button").removeClass("button-primary").removeClass("ui-draggable").removeClass("layout-new-form-field").addClass("layout-form-field").attr("data-config",f),b.find(".layout_field_name").remove(),b.find(".field-location").prop("name","config[layout_grid][fields]["+f+"]"),b.find(".settings-panel").show(),b.appendTo(c),d(),b.find(".icon-edit").trigger("click"),a("#"+f+"_lable").focus().select(),e&&(h.find(".field_config_string").val(""),h.find(".field-label").trigger("change")),rebuild_field_binding(),baldrickTriggers(),a("#"+f).trigger("field.drop"),a(document).trigger("field.added")}function d(){a(".toggle-options").sortable({handle:".dashicons-sort"}),a("#grid-pages-panel").sortable({placeholder:"row-drop-helper",handle:".sort-handle",items:".first-row-level",axis:"y",stop:function(){b()}}),a(".layout-column").sortable({connectWith:".layout-column",appendTo:"#grid-pages-panel",helper:"clone",items:".layout-form-field",handle:".drag-handle",cursor:"move",opacity:.7,cursorAt:{left:100,top:15},start:function(a,b){b.helper.css({width:"200px",height:"35px",paddingTop:"20px"})},stop:function(a,c){c.item.removeAttr("style"),b()}}),a("h3 .layout-new-form-field").draggable({helper:"clone",appendTo:"body"}),a(".page-toggle.button").droppable({accept:".layout-form-field",over:function(){a(this).trigger("click"),a(".layout-column").sortable("refresh")}}),a(".layout-column").droppable({greedy:!0,activeClass:"ui-state-dropper",hoverClass:"ui-state-hoverable",accept:".layout-new-form-field",drop:function(b,d){var e=d.draggable.clone(),f=a(this);c(e,f)}}),b()}add_new_grid_page=function(){return{page_no:"pg_"+Math.round(1e7*Math.random())}},add_page_grid=function(b){var c=a(".page-toggle").length+1,e=a('<button type="button" data-name="Page '+c+'" data-page="'+b.rawData.page_no+'" class="page-toggle button">'+b.params.trigger.data("addtitle")+" "+c+"</button> "),f=a("#page-toggles");e.appendTo(f),f.show(),d(),e.trigger("click"),1===c&&f.hide(),a(document).trigger("add.page")},a(document).on("remove.page add.page load.page",function(){var c=a(".page-toggle").length,d=a("#tab_pages");1>=c?d.hide():d.show()}),d(),a("#grid-pages-panel").on("click",".column-fieldinsert .dashicons-plus-alt",function(){var d=a(this).closest(".column-container"),e=a("#newfield-tool").clone();c(e,d)}),a("#grid-pages-panel").on("click",".column-fieldinsert .dashicons-admin-generic",function(){}),a("#grid-pages-panel").on("click",".column-split",function(){var c=a(this).parent().parent(),e=c.attr("class").split("-"),f=a("<div>").insertAfter(c),g=Math.ceil(e[2]/2),h=Math.floor(e[2]/2);e[2]=g,c.attr("class",e.join("-")),e[2]=h,f.addClass(e.join("-")).append('<div class="layout-column column-container">'),a(this).remove(),d(),jQuery(".column-tools").remove(),jQuery(".column-merge").remove()}),a("#grid-pages-panel").on("click",".column-remove",function(){var d=a(this).closest(".row"),e=d.find(".layout-form-field"),f=d.closest(".layout-grid-panel");if(e.length){if(!confirm(a("#row-remove-fields-message").text()))return;e.each(function(b,c){var d=a(c).data("config");a("#"+d).remove(),a('option[value="'+d+'"]').remove(),a('[data-bind="'+d+'"]').remove(),delete current_form_fields[d]})}d.slideUp(200,function(){if(a(this).remove(),b(),rebuild_field_binding(),!f.find(".row").length){f.remove();var c=a("#page-toggles .button-primary"),d=c.prev(),e=c.next();c.remove(),d.length?d.trigger("click"):e.trigger("click")}a(document).trigger("remove.page")}),jQuery(".column-tools").remove(),jQuery(".column-merge").remove()}),a(".caldera-config-editor-main-panel").on("click",".caldera-add-row",function(c){c.preventDefault();var e=a(".page-active");return e.length?(a(".page-active").append('<div class="first-row-level row"><div class="col-xs-12"><div class="layout-column column-container"></div></div></div>'),d(),b(),void 0):(a(".caldera-add-page").trigger("click"),void 0)}),a("#grid-pages-panel").on("click",".column-join",function(){var d=a(this).parent().parent().parent(),e=d.prev(),f=e.attr("class").split("-"),g=d.attr("class").split("-");f[2]=parseFloat(f[2])+parseFloat(g[2]),d.find(".layout-column").contents().appendTo(e.find(".layout-column")),e.attr("class",f.join("-")),d.remove(),b(),jQuery(".column-tools").remove(),jQuery(".column-merge").remove()}),a("#grid-pages-panel").on("mouseenter",".row",function(){var d=jQuery(this);jQuery(".column-tools,.column-merge").remove(),d.children().children().first().append('<div class="column-remove column-tools"><i class="icon-remove"></i></div>'),d.children().children().last().append('<div class="column-sort column-tools" style="text-align:right;"><i class="dashicons dashicons-menu drag-handle sort-handle"></i></div>'),d.children().children().not(":first").prepend('<div class="column-merge"><div class="column-join column-tools"><i class="icon-join"></i></div></div>');var e=d.parent().parent().parent().width()/12-1;d.children().children().each(function(b,c){var d=a(c),e=d.width()/2-5;d.prepend('<div class="column-fieldinsert column-tools"><i class="dashicons dashicons-plus-alt"></i></div>'),d.parent().hasClass("col-xs-1")||(d.prepend('<div class="column-split column-tools"><i class="dashicons dashicons-leftright"></i></div>'),d.find(".column-split").css("left",e))}),jQuery(".column-merge").draggable({axis:"x",helper:"clone",appendTo:d,grid:[e,0],drag:function(c,d){a(this).addClass("dragging"),a(".column-tools").remove(),a(".column-split").remove();var e=a(this).parent().parent(),f=d.helper,g=d.originalPosition.left>f.position().left?"left":"right",i=e.prev(),j=Math.round(e.parent().width()/12-10),k=Math.abs(d.originalPosition.left-f.position().left);if(e.parent().addClass("sizing"),k>=j){var l=i.attr("class").split("-"),m=e.attr("class").split("-");l[2]=parseFloat(l[2]),m[2]=parseFloat(m[2]),"left"===g?(l[2]--,m[2]++,l[2]>0&&l[2]<l[2]+m[2]?(i.attr("class",l.join("-")),e.attr("class",m.join("-")),d.originalPosition.left=f.position().left):a(this).draggable("option","disabled",!0)):(l[2]++,m[2]--,m[2]>0&&m[2]<m[2]+m[2]?(i.attr("class",l.join("-")),e.attr("class",m.join("-")),d.originalPosition.left=f.position().left):a(this).draggable("option","disabled",!0)),b()
2
- }},stop:function(){a(this).removeClass("dragging").parent().parent().parent().removeClass("sizing")}})}),a("#grid-pages-panel").on("mouseleave",".row",function(){jQuery(".column-tools").remove(),jQuery(".column-merge").remove()}),a("#grid-pages-panel").on("click",".layout-form-field .icon-remove",function(){var b=a(this),c=b.parent(),d=a("#"+c.data("config"));c.slideUp(100,function(){a(this).remove()}),d.slideUp(100,function(){a(this).remove()})}),a("#grid-pages-panel").on("click",".layout-form-field .icon-edit",function(){var b=a(this),c=b.parent(),d=a("#"+c.data("config")+"_type").val();a(".caldera-editor-field-config-wrapper").hide(),c.hasClass("field-edit-open")?c.removeClass("field-edit-open"):(a(".layout-form-field").removeClass("field-edit-open"),c.addClass("field-edit-open"),a("#"+c.data("config")).show()),a(document).trigger("show."+c.data("config")),("radio"===d||"checkbox"===d||"dropdown"===d||"toggle_switch"===d)&&a("#"+c.data("config")+"_auto").trigger("change")}),a("body").on("click",".layout-modal-edit-closer,.layout-modal-save-action",function(b){b.preventDefault();var c=a(this),d=a(".layout-form-field.edit-open"),e=c.closest(".layout-modal-container");settings=e.find(".settings-panel").first(),a(".edit-open").removeClass("edit-open"),settings.appendTo(d.find(".settings-wrapper")).hide(),e.hide()}),a(".layout-editor-body").on("change",".layout-core-pod-query",function(){a(this).parent().find(".settings-panel-row").remove(),a(".edit-open").find(".drag-handle .set-pod").html(" - "+a(this).val())}),a(".layout-editor-body").on("click",".remove-where",function(){a(this).closest(".settings-panel-row").remove()}),a(".layout-editor-body").on("click",".use-pod-container",function(){var b=a(this),c=b.prev(),d=c.val();if(d.length){a(".edit-open").find(".drag-handle .set-pod").html(" - "+c.val()),b.parent().parent().find(".spinner").css("display","inline-block");var f={action:"pq_loadpod",pod_reference:{pod:d}};a.post(ajaxurl,f,function(c){b.parent().find(".spinner").css("display","none");var d=a("#where-line-tmpl").html(),e="",f=b.closest(".settings-panel").data("container");for(var g in c)e+='<option value="'+c[g]+'">'+c[g]+"</option>";d=d.replace(/{{fields}}/g,e).replace(/{{container_id}}/g,f),b.parent().append(d)})}}),a(".caldera-editor-header").on("click",".column-sort .icon-edit",function(){}),a(".layout-editor-body").on("tray_loaded",".layout-template-tray",function(){d()}),a(".caldera-editor-header").on("click",".caldera-editor-header-nav a",function(b){b.preventDefault();var c=a(this);a(".caldera-editor-header-nav li").removeClass("active"),a(".caldera-editor-body").hide(),a(c.attr("href")).show(),c.parent().addClass("active"),rebind_field_bindings()}),a("body").on("change",".required",function(){check_required_bindings(this)}),a("body").on("submit",".caldera-forms-options-form",function(b){var c=a(".required.has-error");c.length&&b.preventDefault()}),a(".caldera-editor-body").on("click",".add-toggle-option",function(){var c=a(this);if(c.data("bulk"))return a(c.data("bulk")).toggle(),a(c.data("bulk")).find("textarea").focus(),void 0;var d=c.closest(".caldera-editor-field-config-wrapper"),e=d.find(".toggle-options"),f=a("#field-option-row-tmpl").html(),g=Handlebars.compile(f),h="opt"+parseInt(1048576*(Math.random()+1)),i={_name:"config[fields]["+d.prop("id")+"][config]",option:{}};if(c.data("options")){for(var j=a(c.data("options")),k=j.val().split("\n"),l=0;l<k.length;l++)i.option["opt"+parseInt(1048576*(Math.random()+l))]={value:k[l],label:k[l],"default":!1};a(c.data("options")).parent().hide(),j.val(""),e.empty()}else i.option[h]={value:"",label:"","default":!1};e.append(g(i)),d.find(".toggle_show_values").trigger("change"),a(".toggle-options").sortable({handle:".dashicons-sort"}),k||e.find(".toggle_label_field").last().focus()}),a(".caldera-editor-body").on("click",".toggle-remove-option",function(){var c=a(this).closest(".caldera-editor-field-config-wrapper").find(".field-config").first();a(this).parent().remove(),c.trigger("change")}),a(".caldera-editor-body").on("click",".page-toggle",function(){var c=a(this),d=c.parent(),e=d.find(".button");e.removeClass("button-primary"),a(".layout-grid-panel").hide().removeClass("page-active"),a("#"+c.data("page")).show().addClass("page-active"),c.addClass("button-primary"),e.each(function(b,c){a(c).html(d.data("title")+" "+(b+1))}),1===e.length&&d.hide()}),a(".caldera-editor-body").on("blur toggle.values",".toggle_label_field",function(){var c=a(this),d=c.prev();d.val().length||d.val(c.val())}),rebuild_field_binding(),a(document).trigger("load.page")}),Handlebars.registerHelper("_options_config",function(){}),jQuery(document).ready(function(a){function b(){a(".caldera-editor-processors-panel ul").sortable({update:function(){rebuild_field_binding()}})}function c(b){var c=a(b),d=a("#"+c.val()+"-tmpl").length?a("#"+c.val()+"-tmpl").html():"",e=c.closest(".caldera-editor-processor-config-wrapper"),f=e.find(".caldera-config-processor-setup"),g=Handlebars.compile(d),h=e.find(".processor_config_string").val(),i=c.data("type");h=h.length&&i===c.val()?JSON.parse(h):processor_defaults[c.val()+"_cfg"],h||(h={}),h._id=e.prop("id"),h._name="config[processors]["+e.prop("id")+"][config]",g=a("<div>").html(g(h)),f.html(g.html()),"function"==typeof window[c.val()+"_init"]&&window[c.val()+"_init"](e.prop("id"),f),e.find(".no-conditions").length&&e.find(".toggle_option_tab").remove(),rebuild_field_binding(),baldrickTriggers()}a("body").on("click",".caldera-processor-nav a",function(b){b.preventDefault();var c=a(this);a(".caldera-processor-nav").removeClass("active"),a(".caldera-editor-processor-config-wrapper").hide(),a(c.attr("href")).show(),c.parent().addClass("active")}),a("body").on("click",".add-new-processor",function(){var d=a(this),e=Handlebars.compile(a("#processor-wrapper-tmpl").html());wrap=a(".active-processors-list"),process_conf=a(".caldera-editor-processor-config"),processid=Math.round(1e8*Math.random()),new_templ=Handlebars.compile(a("#processor-line-tmpl").html()),new_proc={id:"fp_"+processid,type:d.data("type")},wrap.append(new_templ(new_proc)),process_conf.append(e(new_proc)),a("#form_processor_baldrickModalCloser").trigger("click"),a(".caldera-processor-nav a").last().trigger("click"),a("#fp_"+processid+"_type").val(d.data("type")).trigger("change"),b(),baldrickTriggers()}),a("body").on("click",".delete-processor",function(){var c=a(this),d=c.closest(".caldera-editor-processor-config-wrapper");d.data("type"),confirm(c.data("confirm"))&&(a("."+d.prop("id")).remove(),d.remove(),a(".caldera-processor-nav a").first().trigger("click"),rebuild_field_binding())}),a("body").on("change",".caldera-select-processor-type",function(){var d=a(this),e=d.closest(".caldera-editor-processor-config-wrapper"),f=d.find('option[value="'+d.val()+'"]').text(),g=e.find(".caldera-editor-processor-title"),h=a(".caldera-processor-nav.active a");""===f&&(f=g.data("title")),g.html(f),h.html(f+' <span class="processor-line-number"></span>').parent().addClass("processor_type_"+d.val()),c(this),rebuild_field_binding()}),rebuild_field_binding(),a(".caldera-select-processor-type").each(function(a,b){c(b)}),b()}),Handlebars.registerHelper("_field",function(a){var b=this,c="",d="",e="",f=this[a.hash.slug]?' data-default="'+this[a.hash.slug]+'"':"";a.hash.required&&(c=" required"),a.hash.exclude&&(e='data-exclude="'+a.hash.exclude+'"'),a.hash.array&&(d="[]","true"!==a.hash.array&&(f='value="'+a.hash.array+'"')),out="<select "+(a.hash.type?'data-type="'+a.hash.type+'"':"")+f+" "+e+' name="'+this._name+"["+a.hash.slug+"]"+d+'" id="'+this._id+"_"+a.hash.slug+'" class="block-input field-config caldera-field-bind'+c+'">',this[a.hash.slug]?out+='<option class="bound-field" value="'+this[a.hash.slug]+'" class="bound-field"></option>':a.hash.required||(out+='<option value=""></option>');for(var g in current_form_fields){var h="";a.hash.type&&current_form_fields[g].type!==a.hash.type||(b[a.hash.slug]&&b[a.hash.slug]===g&&(h=' selected="selected"'),out+='<option value="'+g+'"'+h+">"+current_form_fields[g].label+" ["+current_form_fields[g].slug+"]</option>")}return out+="</select>",a.hash.required&&(out+='<input class="field-config" name="'+this._name+'[_required_bounds][]" type="hidden" value="'+a.hash.slug+'">'),out}),Handlebars.registerHelper("console",function(){console.log(this)});
1
+ function new_conditional_group(e){var a=e.trigger.data("id"),i="cl"+Math.round(18746582734*Math.random()),t="rw"+Math.round(98347598345*Math.random()),r=[{id:t,type:e.trigger.data("type"),lines:[{id:i}]}];return{group:r,id:a}}function new_conditional_line(e){var a=e.trigger.data("id"),i=e.trigger.data("group"),t=e.trigger.data("type"),r="cl"+Math.round(18746582734*Math.random()),o={id:a,type:t,lineid:r,rowid:i,name:"config["+t+"]["+a+"][conditions][group]["+i+"]["+r+"]"};return o}function build_conditions_config(e){var a=JSON.parse(e.trigger.val());return a.id=e.trigger.data("id"),a}function setup_field_type(e){return{id:e.trigger.prop("id")}}function check_required_bindings(e){var a,i=(jQuery(".caldera-header-save-button"),jQuery(".layout-form-field")),t=jQuery(".caldera-processor-nav"),r=!0;a=e?jQuery(e):jQuery(".caldera-config-field .required"),a.removeClass("has-error"),i.removeClass("has-error"),t.removeClass("has-error"),jQuery(".error-tag").remove(),required_errors={},a.each(function(e,a){var i=jQuery(a),t=i.closest(".caldera-config-editor-panel");if(a.value.length){if(i.hasClass("field-slug"))for(var o=jQuery(".field-slug").not(i),l=0;l<o.length;l++)if(o[l].value===a.value){var i=jQuery(o[l]);required_errors[t.prop("id")]||(required_errors[t.prop("id")]=0);var n=i.closest(".caldera-editor-field-config-wrapper"),d=i.closest(".caldera-editor-processor-config-wrapper");n.length&&jQuery('.layout-form-field[data-config="'+n.prop("id")+'"]').addClass("has-error"),d.length&&jQuery("."+d.prop("id")).addClass("has-error"),required_errors[t.prop("id")]+=1,i.addClass("has-error");break}}else{required_errors[t.prop("id")]||(required_errors[t.prop("id")]=0);var n=i.closest(".caldera-editor-field-config-wrapper"),d=i.closest(".caldera-editor-processor-config-wrapper");n.length&&jQuery('.layout-form-field[data-config="'+n.prop("id")+'"]').addClass("has-error"),d.length&&jQuery("."+d.prop("id")).addClass("has-error"),required_errors[t.prop("id")]+=1,i.addClass("has-error"),r=!1}});for(var o in required_errors)jQuery(".caldera-forms-options-form").find('a[href="#'+o+'"]').append('<span class="error-tag">'+required_errors[o]+"</span>");return jQuery(".preview-caldera-config-group button:submit").length?(jQuery(".mailer-errors").hide(),jQuery(".mailer-control-panel").show()):(jQuery(".mailer-errors").show(),jQuery(".mailer-control-panel").hide()),jQuery(".caldera-conditional-field-set").trigger("change"),r}jQuery(document).ready(function(e){function a(a){var t=e(a),r=t.closest(".caldera-editor-field-config-wrapper"),o=r.find(".caldera-config-field-setup"),l=compiled_templates[t.val()+"_tmpl"]?compiled_templates[t.val()+"_tmpl"]:compiled_templates.noconfig_field_templ,n=r.find(".field_config_string").val(),d=t.data("type");if(r.find(".caldera-config-group").show(),t.addClass("field-initialized"),n=n.length&&d===t.val()?JSON.parse(n):fieldtype_defaults[t.val()+"_cfg"],n||(n={}),n._id=t.data("field"),n._name="config[fields]["+t.data("field")+"][config]",l=e("<div>").html(l(n)),o.html(l.html()),"function"==typeof window[t.val()+"_init"]&&window[t.val()+"_init"](t.data("field"),o),fieldtype_defaults[t.val()+"_nosupport"]&&(fieldtype_defaults[t.val()+"_nosupport"].indexOf("hide_label")>=0&&r.find(".hide-label-field").hide().find(".field-config").prop("checked",!1),fieldtype_defaults[t.val()+"_nosupport"].indexOf("caption")>=0&&r.find(".caption-field").hide().find(".field-config").val(""),fieldtype_defaults[t.val()+"_nosupport"].indexOf("required")>=0&&r.find(".required-field").hide().find(".field-config").prop("checked",!1),fieldtype_defaults[t.val()+"_nosupport"].indexOf("custom_class")>=0&&r.find(".customclass-field").hide().find(".field-config").val(""),fieldtype_defaults[t.val()+"_nosupport"].indexOf("entry_list")>=0&&r.find(".entrylist-field").hide().find(".field-config").prop("checked",!1)),r.find(".toggle_show_values").trigger("change"),!e(".caldera-select-field-type").not(".field-initialized").length){if(core_form.hasClass("builder-loaded"))i(t.data("field"));else{for(var s=e(".caldera-select-field-type.field-initialized"),c=0;c<s.length;c++)i(e(s[c]).data("field"));core_form.addClass("builder-loaded")}rebuild_field_binding(),baldrickTriggers()}}function i(a){var i=e("#"+a),t=i.find(".caldera-select-field-type"),r=e('.layout-form-field[data-config="'+a+'"]'),o=r.find(".field_preview"),l=(e("#preview-"+t.val()+"_tmpl").html(),compiled_templates["preview-"+t.val()+"_tmpl"]),n={id:a},d=i.find(".field-config");d.each(function(i,t){for(var r=e(t),o=r.prop("name").split("["+a+"]")[1].substr(1),l=o.substr(0,o.length-1).split("]["),d=r.is(":checkbox,:radio")?r.filter(":checked").val():r.val(),s={},c=l.length-1;c>=0;c--)if(c===l.length-1)s[l[c]]=d;else{var p=s;s={},s[l[c]]=p}e.extend(!0,n,s)}),o.html(l(n)),r.removeClass("button"),e(".preview-field-config").prop("disabled",!0)}function t(a){var i,t=e(".caldera-editor-fields-panel"),r=(e(".caldera-editor-groups-panel"),e(".caldera-group-nav")),o=e('[data-group="'+a+'"]'),l=o.find(".caldera-config-group-name"),n=o.find(".caldera-config-group-slug"),d=o.find(".caldera-config-group-desc"),s=o.find(".caldera-config-group-admin"),c=e(".active-group-name"),p=e(".active-group-slug"),u=e(".active-group-desc"),f=e(".active-group-admin"),g=e(".caldera-editor-fields-list ul"),v=o.find(".caldera-config-group-repeat"),h=e(".repeat-config-button"),m=(e(".caldera-editor-group-settings"),e(".caldera-config-group-remove"));e(".new-group-input").remove(),e(".new-field-input").remove(),r.removeClass("active"),t.show(),g.hide(),g.removeClass("active").find("li.active").removeClass("active"),g.hide(),o.addClass("active"),i=e(".caldera-editor-fields-list ul.active li"),i.length?m.hide():m.show(),e(".caldera-editor-field-config-wrapper").hide(),o.show(),c.val(l.val()),p.val(n.val()),u.val(d.val()),"1"===s.val()?f.prop("checked",!0):f.prop("checked",!1),"1"===v.val()?h.addClass("field-edit-open"):h.removeClass("field-edit-open")}e(".caldera-header-save-button").baldrick({method:"POST",request:"admin.php?page=caldera-forms",before:function(a,i){if(i.preventDefault(),!check_required_bindings())return!1;e("#save_indicator").addClass("loading"),"undefined"!=typeof tinyMCE&&tinyMCE.triggerSave();var t=e(".caldera-forms-options-form").formJSON();return e(a).data("cf_edit_nonce",t.cf_edit_nonce),e(a).data("_wp_http_referer",t._wp_http_referer),e(a).data("sender","ajax"),e(a).data("config",JSON.stringify(t.config)),!0},callback:function(a){if(!1===a.data){var i=e(".updated_notice_box");i.stop().animate({top:0},200,function(){setTimeout(function(){i.stop().animate({top:-75},200)},2e3)})}},complete:function(a){e(".wrapper-instance-pane .field-config").prop("disabled",!1)}}),e("body").on("click",".toggle_option_tab > a",function(a){a.preventDefault();var i=e(this),t=e(i.attr("href")),r=i.parent().find("a"),o=i.closest(".caldera-editor-config-wrapper").find(".wrapper-instance-pane");r.removeClass("button-primary"),o.hide(),t.show(),i.addClass("button-primary"),e(".caldera-conditionals-usetype").trigger("change")}),e(".caldera-editor-body").on("change",".caldera-select-field-type",function(e){a(this)}),e(".caldera-editor-body").on("click",".caldera-group-nav a",function(a){a.preventDefault(),t(e(this).attr("href").substr(1))}),e(".caldera-editor-body").on("click",".caldera-editor-fields-list a",function(a){a.preventDefault();var i=e(this),t=e(i.attr("href"));e(".new-group-input").remove(),e(".new-field-input").remove(),e(".caldera-editor-fields-list li.active").removeClass("active"),i.parent().addClass("active"),e(".caldera-editor-field-config-wrapper").hide(),t.show()}),e(".caldera-editor-body").on("click",".group-config-button",function(a){var i=e(this),t=e(".caldera-editor-group-settings"),r=i.closest(".caldera-editor-fields-panel"),o=e(".caldera-config-group-remove");r.find(".caldera-field-line").length?o.hide():o.show(),i.hasClass("field-edit-open")?(t.slideUp(100),i.removeClass("field-edit-open")):(t.slideDown(100),i.addClass("field-edit-open"))}),e(".caldera-editor-body").on("keydown",".field-config",function(a){e(this).is("textarea")||13===a.which&&a.preventDefault()}),e(".caldera-editor-body").on("change",".field-label",function(a){var i=e(this).closest(".caldera-editor-field-config-wrapper").prop("id");field_line=e('[data-field="'+i+'"]'),field_title=e("#"+i+" .caldera-editor-field-title, .layout-form-field.field-edit-open .layout_field_name"),slug=e("#"+i+" .field-slug"),field_line.find("a").html('<i class="icn-field"></i> '+this.value),field_title.text(this.value),"change"===a.type&&slug.trigger("change"),rebuild_field_binding()}),e(".caldera-editor-body").on("change",".active-group-name",function(a){a.preventDefault();var i=e(".caldera-group-nav.active"),t=(i.data("group"),i.find(".caldera-config-group-name")),r=i.find("span");"focusout"!==a.type||this.value.length||(this.value="Group "+(parseInt(i.index())+1)),t.val(this.value),r.text(this.value)}),e(".caldera-editor-body").on("change",".active-group-slug",function(a){a.preventDefault();var i=e(".caldera-group-nav.active"),t=(i.data("group"),i.find(".caldera-config-group-name").val()),r=i.find(".caldera-config-group-slug"),o=(i.find("span"),this.value.split(" ").join("_").split("-").join("_").replace(/[^a-z0-9_]/gi,"").toLowerCase());"focusout"!==a.type||this.value.length||(o=t.split(" ").join("_").split("-").join("_").replace(/[^a-z0-9_]/gi,"").toLowerCase()),r.val(o),this.value=o}),e(".caldera-editor-body").on("change",".active-group-desc",function(a){a.preventDefault();var i=e(".caldera-group-nav.active"),t=(i.data("group"),i.find(".caldera-config-group-desc"));t.val(this.value)}),e(".caldera-editor-body").on("change",".active-group-admin",function(a){a.preventDefault();var i=e(".caldera-group-nav.active"),t=(i.data("group"),i.find(".caldera-config-group-name").val(),i.find(".caldera-config-group-admin"));i.find("span"),this.value.split(" ").join("_").split("-").join("_").replace(/[^a-z0-9_]/gi,"").toLowerCase();e(this).prop("checked")?(t.val(1),i.addClass("is-admin")):(t.val(0),i.removeClass("is-admin"))}),e(".caldera-editor-body").on("click",".repeat-config-button",function(a){a.preventDefault();var i=e(".caldera-group-nav.active"),t=(i.data("group"),i.find("a .group-type")),r=i.find(".caldera-config-group-repeat"),o=e(this);o.hasClass("field-edit-open")?(r.val("0"),t.removeClass("icn-repeat").addClass("icn-folder"),o.removeClass("field-edit-open")):(r.val("1"),t.addClass("icn-repeat").removeClass("icn-folder"),o.addClass("field-edit-open"))}),e(".caldera-editor-body").on("click",".delete-field",function(){var a=e(this),i=a.closest(".caldera-editor-field-config-wrapper").prop("id");confirm(a.data("confirm"))&&(e("#"+i).remove(),e('option[value="'+i+'"]').remove(),e('[data-bind="'+i+'"]').remove(),delete current_form_fields[i],e('[data-config="'+i+'"]').slideUp(200,function(){var a=e(this);a.remove(),rebuild_field_binding(),e(document).trigger("field.removed")}))}),e(".caldera-editor-body").on("click",".add-new-group,.add-field",function(){var a=e(this);if(e(".new-group-input").remove(),e(".new-field-input").remove(),a.hasClass("add-field")){var i=e('<input type="text" class="new-field-input block-input">');i.appendTo(e(".caldera-editor-fields-list ul.active")).focus()}else{var t=e('<input type="text" class="new-group-input block-input">');t.appendTo(e(".caldera-editor-groups-panel")).focus()}}),e(".caldera-editor-body").on("change keypress",".new-group-input",function(a){if("keypress"===a.type){if(13!==a.which)return;a.preventDefault()}var i,r,o=this.value,l=e(this),n=e(".caldera-editor-groups-panel ul"),d=e(".caldera-editor-fields-list");if(o.length){i=Handlebars.compile(e("#caldera_group_line_templ").html()),r={id:o.split(" ").join("_").split("-").join("_").replace(/[^a-z0-9_]/gi,"").toLowerCase(),name:o},n.append(i(r));var s=e('<ul data-group="'+r.id+'">').hide();s.appendTo(d),l.remove(),t(r.id)}else l.remove()}),e(".caldera-editor-body").on("change keypress",".new-field-input",function(a){if("keypress"===a.type){if(13!==a.which)return;a.preventDefault()}var i,t,r,o=this.value,l=e(this),n=l.parent(),d=e(".caldera-editor-field-config"),s=e(".caldera-config-group-remove");if(o.length){s.hide(),i=Handlebars.compile(e("#caldera_field_line_templ").html()),t=Handlebars.compile(e("#caldera_field_config_wrapper_templ").html()),r={id:o.split(" ").join("_").split("-").join("_").replace(/[^a-z0-9_]/gi,"").toLowerCase(),label:o,slug:o.split(" ").join("_").split("-").join("_").replace(/[^a-z0-9_]/gi,"").toLowerCase(),group:e(".caldera-group-nav.active").data("group")};var c=e(i(r));c.appendTo(n),d.append(t(r)),c.find("a").trigger("click"),l.remove()}else l.remove()}),e(".caldera-editor-body").on("change",".field-slug",function(a){this.value.length?this.value=this.value.split(" ").join("_").split("-").join("_").replace(/[^a-z0-9_]/gi,"").toLowerCase():"change"===a.type&&(this.value=e(this).closest(".caldera-editor-field-config-wrapper").find(".field-label").val().split(" ").join("_").split("-").join("_").replace(/[^a-z0-9_]/gi,"").toLowerCase())}),e(".caldera-editor-body").on("click",".caldera-add-group",function(a){var i=e(this),t=i.data("group"),r=e("#"+t+"_panel_tmpl").html();i.parent().parent().append(r)}),e(".caldera-editor-body").on("click",".caldera-config-group-remove",function(a){var i=e(".active-group-slug").val();e('[data-group="'+i+'"]').hide(0,function(){e(this).remove();var a=e(".caldera-group-nav");a.length?a.first().find("a").trigger("click"):e(".caldera-editor-fields-panel").hide()})}),e("body").on("click",".set-current-field",function(a){a.preventDefault();var i=e(this);e("#"+i.data("field")+"_type").val(i.data("type")).trigger("change"),e("#"+i.data("field")+"_lable").focus(),e("#field_setup_baldrickModalCloser").trigger("click")}),e(".caldera-editor-body").on("change",".field-config",function(a){var t=e(this),r=t.closest(".caldera-editor-field-config-wrapper");current_form_fields&&(t.prop("id")===r.prop("id")+"_lable"&&(current_form_fields[r.prop("id")].label=this.value),t.prop("id")===r.prop("id")+"_slug"&&(current_form_fields[r.prop("id")].slug=this.value),t.prop("id")===r.prop("id")+"_type"&&(current_form_fields[r.prop("id")].type=this.value),r.length&&i(r.prop("id")))}),e(".caldera-editor-body").on("focus",".caldera-field-bind",function(a){var i=e(this),t=this.value;return console.log(a.type),a.type&&"focusin"===a.type?(i.removeClass("bound_field").addClass("reload-binding"),rebind_field_bindings(),void(this.value=t)):void 0}),e(".caldera-editor-body").on("change",".caldera-conditional-field-set",function(a){var i,t,r=e(this),o=r.parent().find(".compare-type"),l=r.data("condition"),n=r.data("id"),d="config["+l+"]["+n+"][conditions][group]["+r.data("row")+"]["+r.data("line")+"]",s=r.data("line"),c=e("#"+s+"_value"),p=c.find(".caldera-conditional-value-field").first(),u=[],f=this.value;if("{"!==f.substr(0,1)&&(i=e("#"+f),t=i.find(".field-button-type"),u=i.find(".caldera-config-group-toggle-options")),r.hasClass(".bind_init")&&r.addClass("bound_triggered"),p.length&&p.val().length&&c.data("value",p.val()),o.show(),u.length){var g=u.find(".toggle_option_row"),v='<select name="'+d+'[value]" class="caldera-processor-value-bind caldera-conditional-value-field" data-field="'+f+'" style="max-width: 220px; width: 220px;">';v+='<option value=""></option>',g.each(function(a,i){var t=e(i).find(".toggle_label_field"),r=t.data("option"),o="";c.data("value")&&(c.data("value").toString()===r||c.data("value").toString()===e(i).find(".toggle_value_field").val())&&(o=' selected="selected"'),v+='<option value="'+r+'"'+o+">"+t.val()+"</option>"}),v+="</select>"}else t&&"button"==t.val()?(o.val("is").hide(),v='<select name="'+d+'[value]" class="caldera-processor-value-bind caldera-conditional-value-field" data-field="'+f+'" style="max-width: 220px; width: 220px;">',v+='<option value="click" '+("click"===c.data("value")?'selected="selected"':"")+">Click</option>",v+='<option value="dblclick" '+("dblclick"===c.data("value")?'selected="selected"':"")+">Double Click</option>",v+="</select>"):v='<input name="'+d+'[value]" type="text" class="caldera-conditional-value-field magic-tag-enabled" value="'+(c.data("value")?c.data("value"):"")+'" style="max-width: 205px;">';c.html(v),init_magic_tags()}),e(".caldera-editor-body").on("change",".caldera-conditionals-usetype",function(a){var i=e(this);"show"===this.value||"hide"===this.value||"disable"===this.value||"use"===this.value||"not"===this.value?(e("#"+i.data("id")+"_condition_group_add").show(),e("#"+i.data("id")+"_conditional_wrap").show()):(e("#"+i.data("id")+"_condition_group_add").hide(),e("#"+i.data("id")+"_conditional_wrap").hide())}),e(".caldera-editor-body").on("click",".remove-conditional-line",function(a){a.preventDefault();var i=e(this),t=i.closest(".caldera-condition-line"),r=i.closest(".caldera-condition-group");t.remove(),r.find(".caldera-condition-line").length||r.remove()}),e(".caldera-group-nav").first().find("a").trigger("click"),e(".caldera-editor-body").on("change",".toggle_show_values",function(a){var i=e(this),t=i.closest(".caldera-config-group-toggle-options");values=t.find(".toggle_value_field"),lables=t.find(".toggle_label_field"),field_lables=t.find(".caldera-config-group-option-labels"),i.prop("checked")?(values.show().parent().show(),values.show().parent().parent().show(),lables.css("width",""),field_lables.show()):(values.hide().parent().hide(),lables.css("width",245),field_lables.hide()),lables.trigger("toggle.values"),init_magic_tags()}),e(".caldera-editor-body").on("change",".auto-populate-type",function(){e(this).closest(".wrapper-instance-pane").find(".auto-populate-options").trigger("change")}),e(".caldera-editor-body").on("change",".auto-populate-options",function(){var a=e(this),i=a.closest(".wrapper-instance-pane"),t=i.find(".caldera-config-group-toggle-options"),r=i.find(".caldera-config-group-auto-options"),o=r.find(".auto-populate-type");r.find(".auto-populate-type-panel").hide(),a.prop("checked")?(t.hide(),r.show()):(t.show(),r.hide()),r.find(".caldera-config-group-auto-"+o.val()).show()}),e("body").on("change",".pin-toggle-roles",function(){var a=e(this),i=e("#caldera-pin-rules");"1"===a.val()?i.show():i.hide()}),e("body").on("click",".magic-tag-init",function(a){var i=e(this),t=i.prev();t.focus().trigger("init.magic")}),e("body").on("keyup blur focus select click init.magic",".magic-tag-enabled",function(a){init_magic_tags();var i=e(this),t=i.parent(),r=t.closest(".wrapper-instance-pane").find(".caldera-select-field-type").val()?t.closest(".wrapper-instance-pane").find(".caldera-select-field-type").val():"hidden",o=t.find(".magic-tags-autocomplete"),l=o.find("ul"),n=this.value,d=[],s="",c=this.selectionStart,p=this.selectionEnd;if(o.length&&o.data("focus"))return void a.preventDefault();if(i.data("tag",""),this.selectionEnd>this.selectionStart)s=this.value.substr(this.selectionStart,this.selectionEnd-this.selectionStart);else if(("select"===a.type||"keyup"===a.type)&&40!==a.which&&38!==a.which&&39!==a.which&&37!==a.which){for(c=this.selectionStart;c>0;c--){var u=n.substr(c-1,1);if(" "===u||"\n"===u||("%"===u||"}"===u)&&this.selectionStart===c)break}for(p=this.selectionStart;p<n.length;p++){var u=n.substr(p,1);if(" "===u||"\n"===u||("%"===u||"{"===u)&&this.selectionStart===p)break}s=n.substr(c,p-c)}if("focusout"!==a.type){if("init"!==a.type&&s.length<3)return void(o.length&&o.remove());o.length||(o=e('<div class="magic-tags-autocomplete"></div>'),l=e("<ul></ul>"),l.appendTo(o),o.insertAfter(i),o.on("mouseenter",function(){e(this).data("focus",!0)}),o.on("mouseleave",function(){e(this).data("focus",!1),i.is(":focus")||i.trigger("focusout")})),l.empty();var f="system",g=!1;"hidden"===r||"dropdown"===r||"radio"===r||"toggle_switch"===r||"checkbox"===r?(g=!0,r="text",f="all"):("paragraph"===r||"html"===r)&&(r="text"),i.data("type")&&(r=i.data("type")),r=r.split(","),r.push("vars");for(var v=0;v<r.length;v++)for(var h in system_values)if("undefined"!=typeof system_values[h].tags[r[v]]){if(d=[h],"system"!==h&&"variable"!==h&&"field"!==h){var m=jQuery(".processor-"+h),_=i.closest(".caldera-editor-processor-config-wrapper"),y=_.prop("id");d=[];for(var b=0;b<m.length;b++)if(_.length||g!==!0){if(y===m[b].id)continue;jQuery("li."+m[b].id).index()<jQuery("li."+y).index()&&d.push(m[b].id)}else d.push(m[b].id)}for(var w=0;w<d.length;w++)if("all"===f||f===h||"variable"===h){var k=e('<li class="header">'+system_values[h].type+(w>0?" ["+(w+1)+"]":"")+"</li>"),j=0;k.appendTo(l);for(var C=0;C<system_values[h].tags[r[v]].length;C++)if(!i.data("parent")||"variable:"+i.data("parent")!==system_values[h].tags[r[v]][C]){var x=system_values[h].wrap[0]+system_values[h].tags[r[v]][C]+system_values[h].wrap[1];if(d[w]!==h&&d.length>1&&(x=system_values[h].wrap[0]+system_values[h].tags[r[v]][C]+":"+d[w]+system_values[h].wrap[1]),x.indexOf(s)>=0||"init"===a.type){j+=1;var Q=x.replace(s,"<strong>"+s+"</strong>"),q=e('<li class="tag" data-tag="'+x+'">'+Q+"</li>");q.on("click",function(){var a=e(this).data("tag");i.val(n.substr(0,c)+a+n.substr(p)).trigger("change").focus(),i[0].selectionStart=c+a.length-(a.indexOf("*")>0?2:0),i[0].selectionEnd=c+a.length-(a.indexOf("*")>0?1:0)}),q.appendTo(l)}}0===j&&k.remove()}}}l.children().length||o.remove(),"focusout"===a.type&&setTimeout(function(){o.remove()},200)});for(var r=e(".cf-editor-template"),o=0;o<r.length;o++)compiled_templates[r[o].id]=Handlebars.compile(r[o].innerHTML);e(".caldera-select-field-type").not(".field-initialized").each(function(e,i){a(i)})});var rebuild_field_binding,rebind_field_bindings,current_form_fields={},required_errors={},add_new_grid_page,add_page_grid,init_magic_tags,core_form,compiled_templates={};init_magic_tags=function(){var e=jQuery(".magic-tag-enabled");e.each(function(e,a){var i=jQuery(a);if(i.hasClass("magic-tag-init-bound")){var t=i.parent().find(".magic-tag-init");return void(i.is(":visible")?t.show():t.hide())}var r=jQuery('<span class="icn-code magic-tag-init"></span>'),o=jQuery('<span style="position:relative;display:inline-block; width:100%;"></span>');i.is("input")&&r.css("borderBottom","none"),i.hasClass("caldera-conditional-value-field")&&o.width("auto"),i.wrap(o),r.insertAfter(i),i.addClass("magic-tag-init-bound"),i.is(":visible")?r.show():r.hide()})},rebuild_field_binding=function(){if(core_form||(core_form=jQuery(".caldera-forms-options-form")),core_form.hasClass("builder-loaded")){var e=jQuery(".caldera-editor-field-config-wrapper");system_values.field={tags:{text:[]},type:"Fields",wrap:["%","%"]};for(var a=0;a<e.length;a++){var i=e[a].id,t=jQuery("#"+i+"_lable").val(),r=jQuery("#"+i+"_slug").val(),o=jQuery("#"+i+"_type").val();"undefined"==typeof system_values.field.tags[o]&&(system_values.field.tags[o]=[]),system_values.field.tags[o].push(r),"text"!==o&&system_values.field.tags.text.push(r),current_form_fields[i]={label:t,slug:r,type:o},jQuery("option.bound-field").trigger("change").each(function(e,a){var i=jQuery(a);0!==i.prop("value").indexOf("{")?i.text(jQuery("#"+i.prop("value")+"_lable").val()+" ["+jQuery("#"+i.prop("value")+"_lable").val()+"]"):i.text(i.prop("value").replace("{","").replace("}",""))}).removeClass("bound-field")}}},rebind_field_bindings=function(){var e,a,i=jQuery(".caldera-field-bind").not(".bound_field");if(i.length){i.addClass("bound_field");for(var t=0;t<i.length;t++){var r=jQuery(i[t]),o=r.val(),l=r.data("default"),n=r.data("exclude"),d=0,s=r.closest(".caldera-editor-processor-config-wrapper"),c=s.prop("id"),p="";if(l&&!r.hasClass("reload-binding")&&(o=l),r.is("select")){r.empty();var u=jQuery('<optgroup label="Fields">');for(var f in current_form_fields)r.data("type")&&r.data("type").split(",").indexOf(current_form_fields[f].type)<0||(r.data("id")!==f&&u.append('<option value="'+f+'"'+(o===f?'selected="selected"':"")+">"+current_form_fields[f].label+" ["+current_form_fields[f].slug+"]</option>"),d+=1);u.appendTo(r),0===d&&r.empty();for(var g in system_values)if(e=[],!(n&&n.split(",").indexOf(g)>=0)){if("system"!==g&&"variable"!==g)for(var v=jQuery(".processor-"+g),h=0;h<v.length;h++)c!==v[h].id&&(e.push(v[h].id),v.length>1&&(a=jQuery("li."+v[h].id+" .processor-line-number"))&&a.html("["+(h+1)+"]"));else e.push("__system__");var m=[];r.data("type")?(m=r.data("type").split(","),m.push("vars")):m=["text","vars"];for(var _=0;_<m.length;_++)if(system_values[g].tags[m[_]])for(var y=0;y<e.length;y++){jQuery("li."+e[y]).index()>jQuery("li."+c).index()&&"__system__"!==e[y]?r.closest(".caldera-editor-processors-panel-wrap").length&&(p=' disabled="disabled"'):p="";for(var u=jQuery('<optgroup label="'+system_values[g].type+("__system__"!==e[y]?" "+jQuery("li."+e[y]).find(".processor-line-number").html():"")+'"'+p+">"),b=0;b<system_values[g].tags[m[_]].length;b++){var w=system_values[g].tags[m[_]][b];"__system__"!==e[y]&&(w=w.replace(g,e[y])),u.append('<option value="{'+w+'}"'+(o==="{"+w+"}"?'selected="selected"':"")+p+">"+system_values[g].tags[m[_]][b]+"</option>"),d+=1}u.children().length&&u.appendTo(r)}}if(0===d){if(r.empty(),r.data("type")){r.append('<option value="">No '+r.data("type").split(",").join(" or ")+" in form</option>");var k=!0}}else r.prop("disabled",!1);r.hasClass("required")||"undefined"!=typeof k||r.prepend('<option value=""></option>'),r.val(o)}}init_magic_tags(),jQuery(document).trigger("bound.fields"),jQuery(".caldera-header-save-button").prop("disabled",!1)}},jQuery(document).ready(function(e){function a(){var a=e(".layout-grid-panel"),i=0;a.each(function(a,t){var r=e(t),o=r.find(".layout-structure"),l=r.find(".row"),n=[];l.each(function(a,t){var r=e(t),o=r.children().not(".column-merge"),l=[];i+=1,o.each(function(a,t){span=e(t).attr("class").split("-"),l.push(span[2]);var r=e(t).find(".field-location");r.length&&r.each(function(t,r){var o=e(r);o.val(i+":"+(a+1)).removeAttr("disabled")})}),n.push(l.join(":"))}),o.val(n.join("|"))})}function i(a,i,r){var o,l,n="fld_"+Math.round(1e7*Math.random()),d=n,s=e("#field_config_panels");if(r){var c=e("#"+r).clone().wrap("<div>").parent().html().replace(new RegExp(r,"g"),"{{id}}");o=Handlebars.compile(c)}else o=Handlebars.compile(e("#caldera_field_config_wrapper_templ").html());l={id:d,label:"",slug:""},s.append(o(l)),a.removeClass("button-small").removeClass("button").removeClass("button-primary").removeClass("ui-draggable").removeClass("layout-new-form-field").addClass("layout-form-field").attr("data-config",n),a.find(".layout_field_name").remove(),a.find(".field-location").prop("name","config[layout_grid][fields]["+n+"]"),a.find(".settings-panel").show(),a.appendTo(i),t(),a.find(".icon-edit").trigger("click"),e("#"+n+"_lable").focus().select(),r&&(s.find(".field_config_string").val(""),s.find(".field-label").trigger("change")),rebuild_field_binding(),baldrickTriggers(),e("#"+n).trigger("field.drop"),e(document).trigger("field.added")}function t(){e(".toggle-options").sortable({handle:".dashicons-sort"}),e("#grid-pages-panel").sortable({placeholder:"row-drop-helper",handle:".sort-handle",items:".first-row-level",axis:"y",stop:function(){a()}}),e(".layout-column").sortable({connectWith:".layout-column",appendTo:"#grid-pages-panel",helper:"clone",items:".layout-form-field",handle:".drag-handle",cursor:"move",opacity:.7,cursorAt:{left:100,top:15},start:function(e,a){a.helper.css({width:"200px",height:"35px",paddingTop:"20px"})},stop:function(e,i){i.item.removeAttr("style"),a()}}),e("h3 .layout-new-form-field").draggable({helper:"clone",appendTo:"body"}),e(".page-toggle.button").droppable({accept:".layout-form-field",over:function(a,i){e(this).trigger("click"),e(".layout-column").sortable("refresh")}}),e(".layout-column").droppable({greedy:!0,activeClass:"ui-state-dropper",hoverClass:"ui-state-hoverable",accept:".layout-new-form-field",drop:function(a,t){var r=t.draggable.clone(),o=e(this);i(r,o)}}),a()}add_new_grid_page=function(e){return{page_no:"pg_"+Math.round(1e7*Math.random())}},add_page_grid=function(a){var i=e(".page-toggle").length+1,r=e('<button type="button" data-name="Page '+i+'" data-page="'+a.rawData.page_no+'" class="page-toggle button">'+a.params.trigger.data("addtitle")+" "+i+"</button> "),o=e("#page-toggles");r.appendTo(o),o.show(),t(),r.trigger("click"),1===i&&o.hide(),e(document).trigger("add.page")},e(document).on("remove.page add.page load.page",function(a){var i=e(".page-toggle").length,t=e("#tab_pages");1>=i?t.hide():t.show()}),t(),e("#grid-pages-panel").on("click",".column-fieldinsert .dashicons-plus-alt",function(a){var t=e(this).closest(".column-container"),r=e("#newfield-tool").clone();i(r,t)}),e("#grid-pages-panel").on("click",".column-fieldinsert .dashicons-admin-generic",function(e){}),e("#grid-pages-panel").on("click",".column-split",function(a){var i=e(this).parent().parent(),r=i.attr("class").split("-"),o=e("<div>").insertAfter(i),l=Math.ceil(r[2]/2),n=Math.floor(r[2]/2);r[2]=l,i.attr("class",r.join("-")),r[2]=n,o.addClass(r.join("-")).append('<div class="layout-column column-container">'),e(this).remove(),t(),jQuery(".column-tools").remove(),jQuery(".column-merge").remove()}),e("#grid-pages-panel").on("click",".column-remove",function(i){var t=e(this).closest(".row"),r=t.find(".layout-form-field"),o=t.closest(".layout-grid-panel");if(r.length){if(!confirm(e("#row-remove-fields-message").text()))return;r.each(function(a,i){var t=e(i).data("config");e("#"+t).remove(),e('option[value="'+t+'"]').remove(),e('[data-bind="'+t+'"]').remove(),delete current_form_fields[t]})}t.slideUp(200,function(){if(e(this).remove(),a(),rebuild_field_binding(),!o.find(".row").length){o.remove();var i=e("#page-toggles .button-primary"),t=i.prev(),r=i.next();i.remove(),t.length?t.trigger("click"):r.trigger("click")}e(document).trigger("remove.page")}),jQuery(".column-tools").remove(),jQuery(".column-merge").remove()}),e(".caldera-config-editor-main-panel").on("click",".caldera-add-row",function(i){i.preventDefault();var r=e(".page-active");if(!r.length)return void e(".caldera-add-page").trigger("click");var o=e('<div style="display:none;" class="first-row-level row"><div class="col-xs-12"><div class="layout-column column-container"></div></div></div>');e(".page-active").append(o),o.slideDown(200),t(),a()}),e("#grid-pages-panel").on("click",".column-join",function(i){var t=e(this).parent().parent().parent(),r=t.prev(),o=r.attr("class").split("-"),l=t.attr("class").split("-");o[2]=parseFloat(o[2])+parseFloat(l[2]),t.find(".layout-column").contents().appendTo(r.find(".layout-column")),r.attr("class",o.join("-")),t.remove(),a(),jQuery(".column-tools").remove(),jQuery(".column-merge").remove()}),e("#grid-pages-panel").on("mouseenter",".row",function(i){var t=jQuery(this);jQuery(".column-tools,.column-merge").remove(),t.children().children().first().append('<div class="column-remove column-tools"><i class="icon-remove"></i></div>'),t.children().children().last().append('<div class="column-sort column-tools" style="text-align:right;"><i class="dashicons dashicons-menu drag-handle sort-handle"></i></div>'),t.children().children().not(":first").prepend('<div class="column-merge"><div class="column-join column-tools"><i class="icon-join"></i></div></div>');var r=t.parent().parent().parent().width()/12-1;t.children().children().each(function(a,i){var t=e(i),r=t.width()/2-5;t.prepend('<div class="column-fieldinsert column-tools"><i class="dashicons dashicons-plus-alt"></i></div>'),t.parent().hasClass("col-xs-1")||(t.prepend('<div class="column-split column-tools"><i class="dashicons dashicons-leftright"></i></div>'),t.find(".column-split").css("left",r))}),jQuery(".column-merge").draggable({axis:"x",helper:"clone",appendTo:t,grid:[r,0],drag:function(i,t){e(this).addClass("dragging"),e(".column-tools").remove(),e(".column-split").remove();var r=e(this).parent().parent(),o=t.helper,l=t.originalPosition.left>o.position().left?"left":"right",n=r.prev(),d=Math.round(r.parent().width()/12-10),s=Math.abs(t.originalPosition.left-o.position().left);if(r.parent().addClass("sizing"),s>=d){var c=n.attr("class").split("-"),p=r.attr("class").split("-");
2
+ c[2]=parseFloat(c[2]),p[2]=parseFloat(p[2]),"left"===l?(c[2]--,p[2]++,c[2]>0&&c[2]<c[2]+p[2]?(n.attr("class",c.join("-")),r.attr("class",p.join("-")),t.originalPosition.left=o.position().left):e(this).draggable("option","disabled",!0)):(c[2]++,p[2]--,p[2]>0&&p[2]<p[2]+p[2]?(n.attr("class",c.join("-")),r.attr("class",p.join("-")),t.originalPosition.left=o.position().left):e(this).draggable("option","disabled",!0)),a()}},stop:function(){e(this).removeClass("dragging").parent().parent().parent().removeClass("sizing")}})}),e("#grid-pages-panel").on("mouseleave",".row",function(e){jQuery(".column-tools").remove(),jQuery(".column-merge").remove()}),e("#grid-pages-panel").on("click",".layout-form-field .icon-remove",function(){var a=e(this),i=a.parent(),t=e("#"+i.data("config"));i.slideUp(100,function(){e(this).remove()}),t.slideUp(100,function(){e(this).remove()})}),e("#grid-pages-panel").on("click",".layout-form-field .icon-edit",function(){var a=e(this),i=a.parent(),t=e("#"+i.data("config")+"_type").val();e(".caldera-editor-field-config-wrapper").hide(),i.hasClass("field-edit-open")?i.removeClass("field-edit-open"):(e(".layout-form-field").removeClass("field-edit-open"),i.addClass("field-edit-open"),e("#"+i.data("config")).show()),e(document).trigger("show."+i.data("config")),e(document).trigger("show.fieldedit"),("radio"===t||"checkbox"===t||"dropdown"===t||"toggle_switch"===t)&&e("#"+i.data("config")+"_auto").trigger("change")}),e("body").on("click",".layout-modal-edit-closer,.layout-modal-save-action",function(a){a.preventDefault();var i=e(this),t=e(".layout-form-field.edit-open"),r=i.closest(".layout-modal-container");settings=r.find(".settings-panel").first(),e(".edit-open").removeClass("edit-open"),settings.appendTo(t.find(".settings-wrapper")).hide(),r.hide()}),e(".layout-editor-body").on("change",".layout-core-pod-query",function(){e(this).parent().find(".settings-panel-row").remove(),e(".edit-open").find(".drag-handle .set-pod").html(" - "+e(this).val())}),e(".layout-editor-body").on("click",".remove-where",function(){e(this).closest(".settings-panel-row").remove()}),e(".layout-editor-body").on("click",".use-pod-container",function(){var a=e(this),i=a.prev(),t=i.val();if(t.length){e(".edit-open").find(".drag-handle .set-pod").html(" - "+i.val()),a.parent().parent().find(".spinner").css("display","inline-block");var r={action:"pq_loadpod",pod_reference:{pod:t}};e.post(ajaxurl,r,function(i){a.parent().find(".spinner").css("display","none");var t=e("#where-line-tmpl").html(),r="",o=a.closest(".settings-panel").data("container");for(var l in i)r+='<option value="'+i[l]+'">'+i[l]+"</option>";t=t.replace(/{{fields}}/g,r).replace(/{{container_id}}/g,o),a.parent().append(t)})}}),e(".caldera-editor-header").on("click",".column-sort .icon-edit",function(e){}),e(".layout-editor-body").on("tray_loaded",".layout-template-tray",function(){t()}),e(".caldera-editor-header").on("click",".caldera-editor-header-nav a",function(a){a.preventDefault();var i=e(this);e(".caldera-editor-header-nav li").removeClass("active"),e(".caldera-editor-body").hide(),e(i.attr("href")).show(),i.parent().addClass("active"),rebind_field_bindings()}),e("body").on("change",".required",function(){check_required_bindings(this)}),e("body").on("submit",".caldera-forms-options-form",function(a){var i=e(".required.has-error");i.length&&a.preventDefault()}),e(".caldera-editor-body").on("click",".add-toggle-option",function(a){var i=e(this);if(i.data("bulk"))return e(i.data("bulk")).toggle(),void e(i.data("bulk")).find("textarea").focus();var t=i.closest(".caldera-editor-field-config-wrapper"),r=t.find(".toggle-options"),o=e("#field-option-row-tmpl").html(),l=Handlebars.compile(o),n="opt"+parseInt(1048576*(Math.random()+1)),d={_name:"config[fields]["+t.prop("id")+"][config]",option:{}};if(i.data("options")){for(var s=e(i.data("options")),c=s.val().split("\n"),p=0;p<c.length;p++)d.option["opt"+parseInt(1048576*(Math.random()+p))]={value:c[p],label:c[p],"default":!1};e(i.data("options")).parent().hide(),s.val(""),r.empty()}else d.option[n]={value:"",label:"","default":!1};r.append(l(d)),t.find(".toggle_show_values").trigger("change"),e(".toggle-options").sortable({handle:".dashicons-sort"}),c||r.find(".toggle_label_field").last().focus()}),e(".caldera-editor-body").on("click",".toggle-remove-option",function(a){var i=e(this).closest(".caldera-editor-field-config-wrapper").find(".field-config").first();e(this).parent().remove(),i.trigger("change")}),e(".caldera-editor-body").on("click",".page-toggle",function(a){var i=e(this),t=i.parent(),r=t.find(".button");r.removeClass("button-primary"),e(".layout-grid-panel").hide().removeClass("page-active"),e("#"+i.data("page")).show().addClass("page-active"),i.addClass("button-primary"),r.each(function(a,i){e(i).html(t.data("title")+" "+(a+1))}),1===r.length&&t.hide()}),e(".caldera-editor-body").on("blur toggle.values",".toggle_label_field",function(a){var i=e(this),t=i.prev();t.val().length||t.val(i.val())}),rebuild_field_binding(),e(document).trigger("load.page")}),Handlebars.registerHelper("_options_config",function(){}),jQuery(document).ready(function(e){function a(){e(".caldera-editor-processors-panel ul").sortable({update:function(){rebuild_field_binding()}})}function i(a){var i=e(a),t=e("#"+i.val()+"-tmpl").length?e("#"+i.val()+"-tmpl").html():"",r=i.closest(".caldera-editor-processor-config-wrapper"),o=r.find(".caldera-config-processor-setup"),l=Handlebars.compile(t),n=r.find(".processor_config_string").val(),d=i.data("type");n=n.length&&d===i.val()?JSON.parse(n):processor_defaults[i.val()+"_cfg"],n||(n={}),n._id=r.prop("id"),n._name="config[processors]["+r.prop("id")+"][config]",l=e("<div>").html(l(n)),o.html(l.html()),"function"==typeof window[i.val()+"_init"]&&window[i.val()+"_init"](r.prop("id"),o),r.find(".no-conditions").length&&r.find(".toggle_option_tab").remove(),rebuild_field_binding(),baldrickTriggers(),e(".wp-baldrick").baldrick({request:ajaxurl,method:"POST",before:function(a){var i=e(a);i.data("addNode")&&!i.data("request")&&i.data("request","cf_get_default_setting")}})}e("body").on("click",".caldera-processor-nav a",function(a){a.preventDefault();var i=e(this);e(".caldera-processor-nav").removeClass("active"),e(".caldera-editor-processor-config-wrapper").hide(),e(i.attr("href")).show(),i.parent().addClass("active")}),e("body").on("click",".add-new-processor",function(i){var t=e(this),r=Handlebars.compile(e("#processor-wrapper-tmpl").html());wrap=e(".active-processors-list"),process_conf=e(".caldera-editor-processor-config"),processid=Math.round(1e8*Math.random()),new_templ=Handlebars.compile(e("#processor-line-tmpl").html()),new_proc={id:"fp_"+processid,type:t.data("type")},wrap.append(new_templ(new_proc)),process_conf.append(r(new_proc)),e("#form_processor_baldrickModalCloser").trigger("click"),e(".caldera-processor-nav a").last().trigger("click"),e("#fp_"+processid+"_type").val(t.data("type")).trigger("change"),a(),baldrickTriggers()}),e("body").on("click",".delete-processor",function(a){var i=e(this),t=i.closest(".caldera-editor-processor-config-wrapper");t.data("type");confirm(i.data("confirm"))&&(e("."+t.prop("id")).remove(),t.remove(),e(".caldera-processor-nav a").first().trigger("click"),rebuild_field_binding())}),e("body").on("change",".caldera-select-processor-type",function(a){var t=e(this),r=t.closest(".caldera-editor-processor-config-wrapper"),o=t.find('option[value="'+t.val()+'"]').text(),l=r.find(".caldera-editor-processor-title"),n=e(".caldera-processor-nav.active a");""===o&&(o=l.data("title")),l.html(o),n.html(o+' <span class="processor-line-number"></span>').parent().addClass("processor_type_"+t.val()),i(this),rebuild_field_binding()}),rebuild_field_binding(),e(".caldera-select-processor-type").each(function(e,a){i(a)}),a()}),Handlebars.registerHelper("_field",function(e){var a=this,i="",t="",r="",o=this[e.hash.slug]?' data-default="'+this[e.hash.slug]+'"':"";e.hash.required&&(i=" required"),e.hash.exclude&&(r='data-exclude="'+e.hash.exclude+'"'),e.hash.array&&(t="[]","true"!==e.hash.array&&(o='value="'+e.hash.array+'"')),out="<select "+(e.hash.type?'data-type="'+e.hash.type+'"':"")+o+" "+r+' name="'+this._name+"["+e.hash.slug+"]"+t+'" id="'+this._id+"_"+e.hash.slug+'" class="block-input field-config caldera-field-bind'+i+'">',this[e.hash.slug]?out+='<option class="bound-field" value="'+this[e.hash.slug]+'" class="bound-field"></option>':e.hash.required||(out+='<option value=""></option>');for(var l in current_form_fields){var n="";e.hash.type&&current_form_fields[l].type!==e.hash.type||(a[e.hash.slug]&&a[e.hash.slug]===l&&(n=' selected="selected"'),out+='<option value="'+l+'"'+n+">"+current_form_fields[l].label+" ["+current_form_fields[l].slug+"]</option>")}return out+="</select>",e.hash.required&&(out+='<input class="field-config" name="'+this._name+'[_required_bounds][]" type="hidden" value="'+e.hash.slug+'">'),out}),Handlebars.registerHelper("console",function(e,a){console.log(this)});
assets/js/frontend-script-init.js CHANGED
@@ -1,12 +1,19 @@
1
(function($){
2
- jQuery('document').ready(function(){
3
- // check for init function
4
jQuery('.init_field_type[data-type]').each(function(k,v){
5
var ftype = jQuery(v);
6
if( typeof window[ftype.data('type') + '_init'] === 'function' ){
7
window[ftype.data('type') + '_init'](ftype.prop('id'), ftype[0]);
8
}
9
});
10
});
11
// modals activation
12
jQuery(document).on('click', '.cf_modal_button', function(e){
@@ -19,6 +26,9 @@
19
var clicked = jQuery(this);
20
clicked.closest('.caldera-front-modal-container').hide();
21
});
22
// Page navigation
23
jQuery(document).on('click', '[data-page]', function(e){
24
1
+ var cf_jsfields_init;
2
(function($){
3
+
4
+ // make init function
5
+ cf_jsfields_init = function(){
6
jQuery('.init_field_type[data-type]').each(function(k,v){
7
var ftype = jQuery(v);
8
if( typeof window[ftype.data('type') + '_init'] === 'function' ){
9
window[ftype.data('type') + '_init'](ftype.prop('id'), ftype[0]);
10
}
11
});
12
+ };
13
+
14
+ jQuery('document').ready(function(){
15
+ // check for init function
16
+ cf_jsfields_init();
17
});
18
// modals activation
19
jQuery(document).on('click', '.cf_modal_button', function(e){
26
var clicked = jQuery(this);
27
clicked.closest('.caldera-front-modal-container').hide();
28
});
29
+ // stuff trigger
30
+ jQuery(document).on('cf.add cf.enable cf.disable cf.pagenav', cf_jsfields_init );
31
+
32
// Page navigation
33
jQuery(document).on('click', '[data-page]', function(e){
34
assets/js/frontend-script-init.min.js CHANGED
@@ -1 +1 @@
1
- !function(a){jQuery("document").ready(function(){jQuery(".init_field_type[data-type]").each(function(a,b){var c=jQuery(b);"function"==typeof window[c.data("type")+"_init"]&&window[c.data("type")+"_init"](c.prop("id"),c[0])})}),jQuery(document).on("click",".cf_modal_button",function(a){a.preventDefault();var b=jQuery(this);jQuery(b.attr("href")).show()}),jQuery(document).on("click",".caldera-front-modal-closer",function(a){a.preventDefault();var b=jQuery(this);b.closest(".caldera-front-modal-container").hide()}),jQuery(document).on("click","[data-page]",function(b){var h,i,j,c=jQuery(this),d=c.closest(".caldera-form-page"),e=c.closest(".caldera-grid"),f=d.data("formpage"),g=jQuery('.breadcrumb[data-form="'+e.prop("id")+'"]'),k={};if(e.length){c.data("pagenav")?(j=jQuery("#"+c.data("pagenav")+" .caldera-form-page").find("[data-field]"),e=c.closest(".caldera_forms_form")):j=e.find(".caldera-form-page:visible").find("[data-field]");for(var l=0;l<j.length;l++)if(jQuery(j[l]).is(":radio,:checkbox")){if(!a(j[l]).hasClass("option-required"))continue;k[a(j[l]).data("field")]||(k[a(j[l]).data("field")]=[]),k[a(j[l]).data("field")].push(a(j[l]).prop("checked"))}else if(jQuery(j[l]).prop("required")){if(!j[l].value.length)return b.preventDefault(),e.find('[type="submit"]').trigger("click"),void 0;if("email"===j[l].type&&(j[l].value.indexOf("@")<0||j[l].value.length<=j[l].value.indexOf("@")+1))return b.preventDefault(),e.find('[type="submit"]').trigger("click"),void 0}for(var m in k){if(k[m].indexOf(!0)<0)return a('[for="'+m+'"]').parent().addClass("has-error"),!1;a('[for="'+m+'"]').parent().removeClass("has-error")}"next"===c.data("page")?(g&&g.find("li.active").removeClass("active"),h=e.find('.caldera-form-page[data-formpage="'+(f+1)+'"]'),h.length&&(d.hide(),h.show(),g&&g.find('a[data-page="'+(f+1)+'"]').parent().addClass("active"))):"prev"===c.data("page")?(g&&g.find("li.active").removeClass("active"),i=e.find('.caldera-form-page[data-formpage="'+(f-1)+'"]'),i.length&&(d.hide(),i.show(),g&&g.find('a[data-page="'+(f-1)+'"]').parent().addClass("active"))):c.data("pagenav")&&(b.preventDefault(),c.closest(".breadcrumb").find("li.active").removeClass("active"),jQuery("#"+c.data("pagenav")+" .caldera-form-page").hide(),jQuery("#"+c.data("pagenav")+' .caldera-form-page[data-formpage="'+c.data("page")+'"]').show(),c.parent().addClass("active")),jQuery("html, body").animate({scrollTop:e.offset().top-100},200),jQuery(document).trigger("cf.pagenav")}});var b;jQuery(".caldera-grid .breadcrumb").each(function(a,c){jQuery(c).find("a[data-pagenav]").each(function(a,c){var d=jQuery(c),e=d.data("pagenav"),f=jQuery("#"+e+' .caldera-form-page[data-formpage="'+d.data("page")+'"]');f.find(".has-error").length&&(d.parent().addClass("error"),"undefined"==typeof b&&(d.trigger("click"),b=!0))})})}(jQuery);
1
+ var cf_jsfields_init;!function(a){cf_jsfields_init=function(){jQuery(".init_field_type[data-type]").each(function(a,e){var r=jQuery(e);"function"==typeof window[r.data("type")+"_init"]&&window[r.data("type")+"_init"](r.prop("id"),r[0])})},jQuery("document").ready(function(){cf_jsfields_init()}),jQuery(document).on("click",".cf_modal_button",function(a){a.preventDefault();var e=jQuery(this);jQuery(e.attr("href")).show()}),jQuery(document).on("click",".caldera-front-modal-closer",function(a){a.preventDefault();var e=jQuery(this);e.closest(".caldera-front-modal-container").hide()}),jQuery(document).on("cf.add cf.enable cf.disable cf.pagenav",cf_jsfields_init),jQuery(document).on("click","[data-page]",function(e){var r,t,d,i=jQuery(this),n=i.closest(".caldera-form-page"),f=i.closest(".caldera-grid"),o=n.data("formpage"),c=jQuery('.breadcrumb[data-form="'+f.prop("id")+'"]'),l={};if(f.length){i.data("pagenav")?(d=jQuery("#"+i.data("pagenav")+" .caldera-form-page").find("[data-field]"),f=i.closest(".caldera_forms_form")):d=f.find(".caldera-form-page:visible").find("[data-field]");for(var u=0;u<d.length;u++)if(jQuery(d[u]).is(":radio,:checkbox")){if(!a(d[u]).hasClass("option-required"))continue;l[a(d[u]).data("field")]||(l[a(d[u]).data("field")]=[]),l[a(d[u]).data("field")].push(a(d[u]).prop("checked"))}else if(jQuery(d[u]).prop("required")){if(!d[u].value.length)return e.preventDefault(),void f.find('[type="submit"]').trigger("click");if("email"===d[u].type&&(d[u].value.indexOf("@")<0||d[u].value.length<=d[u].value.indexOf("@")+1))return e.preventDefault(),void f.find('[type="submit"]').trigger("click")}for(var p in l){if(l[p].indexOf(!0)<0)return a('[for="'+p+'"]').parent().addClass("has-error"),!1;a('[for="'+p+'"]').parent().removeClass("has-error")}"next"===i.data("page")?(c&&c.find("li.active").removeClass("active"),r=f.find('.caldera-form-page[data-formpage="'+(o+1)+'"]'),r.length&&(n.hide(),r.show(),c&&c.find('a[data-page="'+(o+1)+'"]').parent().addClass("active"))):"prev"===i.data("page")?(c&&c.find("li.active").removeClass("active"),t=f.find('.caldera-form-page[data-formpage="'+(o-1)+'"]'),t.length&&(n.hide(),t.show(),c&&c.find('a[data-page="'+(o-1)+'"]').parent().addClass("active"))):i.data("pagenav")&&(e.preventDefault(),i.closest(".breadcrumb").find("li.active").removeClass("active"),jQuery("#"+i.data("pagenav")+" .caldera-form-page").hide(),jQuery("#"+i.data("pagenav")+' .caldera-form-page[data-formpage="'+i.data("page")+'"]').show(),i.parent().addClass("active")),jQuery("html, body").animate({scrollTop:f.offset().top-100},200),jQuery(document).trigger("cf.pagenav")}});var e;jQuery(".caldera-grid .breadcrumb").each(function(a,r){jQuery(r).find("a[data-pagenav]").each(function(a,r){var t=jQuery(r),d=t.data("pagenav"),i=jQuery("#"+d+' .caldera-form-page[data-formpage="'+t.data("page")+'"]');i.find(".has-error").length&&(t.parent().addClass("error"),"undefined"==typeof e&&(t.trigger("click"),e=!0))})})}(jQuery);
assets/js/wp-baldrick-full.js CHANGED
@@ -3830,32 +3830,23 @@ var __module0__ = (function(__dependency1__, __dependency2__, __dependency3__, _
3830
}
3831
3832
$.fn.formJSON = function(){
3833
-
3834
var form = $(this);
3835
- if( !form.is('form') ){
3836
- form = $('<form>').append( form.clone() );
3837
- }
3838
3839
- var fields = form.serializeArray(),
3840
json = {},
3841
arraynames = {};
3842
for( var v = 0; v < fields.length; v++){
3843
- var field = fields[v],
3844
- field_el = form.find('[name="' + field.name + '"]'),
3845
- name = field.name.replace(/\]/gi,'').split('['),
3846
- value = field.value,
3847
lineconf = {};
3848
3849
- /*if( field_el.prop('required') && field_el.is(':visible') ){
3850
- if( field_el[0].checkValidity ){
3851
- if( field_el[0].checkValidity() ){
3852
- field_el.removeClass('invalid');
3853
- }else{
3854
- field_el.focus().addClass('invalid');
3855
- return false;
3856
}
3857
- }
3858
- }*/
3859
for(var i = name.length-1; i >= 0; i--){
3860
var nestname = name[i];
3861
if(nestname.length === 0){
@@ -3868,18 +3859,20 @@ var __module0__ = (function(__dependency1__, __dependency2__, __dependency3__, _
3868
nestname = arraynames[name[i-1]];
3869
}
3870
if(i === name.length-1){
3871
- if( value === 'true' ){
3872
- value = true;
3873
- }else if( value === 'false' ){
3874
- value = false;
3875
- }else if( !isNaN( parseFloat( value ) ) && parseFloat( value ).toString() === value ){
3876
- value = parseFloat( value );
3877
- }else if( value.substr(0,1) === '{' || value.substr(0,1) === '[' ){
3878
- try {
3879
- value = JSON.parse( value );
3880
-
3881
- } catch (e) {
3882
- //console.log( e );
3883
}
3884
}
3885
lineconf[nestname] = value;
@@ -4638,6 +4631,15 @@ var handlebarsVariables = {};
4638
title = modal.find('.baldrick-modal-title'),
4639
current_size = '';
4640
4641
if( windowWidth <= 700 && windowWidth > 600 ){
4642
modalHeight = windowHeight - 30;
4643
modalWidth = windowWidth - 30;
@@ -4666,11 +4668,11 @@ var handlebarsVariables = {};
4666
// inject tabs
4667
var navtabs = obj.params.target.find('[data-tab]'),
4668
avatar = obj.params.target.find('.user-avatar');
4669
-
4670
if( navtabs.length ){
4671
var tabs = $('<ul>', { "class" : "navtabs" } ),
4672
hasSelection = false;
4673
-
4674
navtabs.each( function(k,v){
4675
var tab = $(this),
4676
element = $('<li>'),
@@ -4703,18 +4705,22 @@ var handlebarsVariables = {};
4703
}
4704
4705
tabs.css('top', obj.params.target.parent().find('.baldrick-modal-title').outerHeight() );
4706
- tabs.css('bottom', obj.params.target.parent().find('.baldrick-modal-footer').outerHeight() );
4707
4708
obj.params.target.before( tabs ).addClass('has-tabs');
4709
-
4710
if( avatar.length ){
4711
tabs.before( avatar );
4712
tabs.css('top', obj.params.target.parent().find('.baldrick-modal-title').outerHeight() + 149 );
4713
tabs.css('padding-top', 0 );
4714
}
4715
4716
- }
4717
-
4718
},
4719
event : function(el, obj){
4720
var trigger = $(el), modal_id = 'wm';
@@ -4726,8 +4732,7 @@ var handlebarsVariables = {};
4726
$('.baldrick-modal-wrap').css('zIndex' , '100099');
4727
//wm_hasModal = true;
4728
// write out a template wrapper.
4729
- var modal_element = trigger.data('modalElement') ? trigger.data('modalElement') : 'form',
4730
- modal = $('<' + modal_element + '>', {
4731
id : modal_id + '_baldrickModal',
4732
tabIndex : -1,
4733
"ariaLabelled-by" : modal_id + '_baldrickModalLable',
3830
}
3831
3832
$.fn.formJSON = function(){
3833
var form = $(this);
3834
3835
+ var fields = form.find('[name]'),
3836
json = {},
3837
arraynames = {};
3838
for( var v = 0; v < fields.length; v++){
3839
+ var field = $( fields[v] ),
3840
+ name = field.prop('name').replace(/\]/gi,'').split('['),
3841
+ value = field.val(),
3842
lineconf = {};
3843
3844
+ if( field.is(':radio') || field.is(':checkbox') ){
3845
+ if( !field.is(':checked') ){
3846
+ continue;
3847
}
3848
+ }
3849
+
3850
for(var i = name.length-1; i >= 0; i--){
3851
var nestname = name[i];
3852
if(nestname.length === 0){
3859
nestname = arraynames[name[i-1]];
3860
}
3861
if(i === name.length-1){
3862
+ if( value ){
3863
+ if( value === 'true' ){
3864
+ value = true;
3865
+ }else if( value === 'false' ){
3866
+ value = false;
3867
+ }else if( !isNaN( parseFloat( value ) ) && parseFloat( value ).toString() === value ){
3868
+ value = parseFloat( value );
3869
+ }else if( value.substr(0,1) === '{' || value.substr(0,1) === '[' ){
3870
+ try {
3871
+ value = JSON.parse( value );
3872
+
3873
+ } catch (e) {
3874
+ //console.log( e );
3875
+ }
3876
}
3877
}
3878
lineconf[nestname] = value;
4631
title = modal.find('.baldrick-modal-title'),
4632
current_size = '';
4633
4634
+ if( modalHeight === 'auto' ){
4635
+ body.css( 'position', 'initial' );
4636
+ modalHeight = body.outerHeight() + footer.outerHeight() + title.outerHeight();
4637
+ body.css( 'position', '' );
4638
+ }
4639
+ if( modalWidth === 'auto' ){
4640
+ modalWidth = 450;
4641
+ }
4642
+
4643
if( windowWidth <= 700 && windowWidth > 600 ){
4644
modalHeight = windowHeight - 30;
4645
modalWidth = windowWidth - 30;
4668
// inject tabs
4669
var navtabs = obj.params.target.find('[data-tab]'),
4670
avatar = obj.params.target.find('.user-avatar');
4671
+
4672
if( navtabs.length ){
4673
var tabs = $('<ul>', { "class" : "navtabs" } ),
4674
hasSelection = false;
4675
+
4676
navtabs.each( function(k,v){
4677
var tab = $(this),
4678
element = $('<li>'),
4705
}
4706
4707
tabs.css('top', obj.params.target.parent().find('.baldrick-modal-title').outerHeight() );
4708
+ if( obj.params.trigger.data('modalButtons' ) ){
4709
+ tabs.css('bottom', obj.params.target.parent().find('.baldrick-modal-footer').outerHeight() );
4710
+ }else{
4711
+ tabs.css('bottom', 0 );
4712
+ }
4713
+
4714
4715
obj.params.target.before( tabs ).addClass('has-tabs');
4716
+
4717
if( avatar.length ){
4718
tabs.before( avatar );
4719
tabs.css('top', obj.params.target.parent().find('.baldrick-modal-title').outerHeight() + 149 );
4720
tabs.css('padding-top', 0 );
4721
}
4722
4723
+ }
4724
},
4725
event : function(el, obj){
4726
var trigger = $(el), modal_id = 'wm';
4732
$('.baldrick-modal-wrap').css('zIndex' , '100099');
4733
//wm_hasModal = true;
4734
// write out a template wrapper.
4735
+ var modal = $('<' + ( trigger.data('modalElement') ? trigger.data('modalElement') : 'form' ) + '>', {
4736
id : modal_id + '_baldrickModal',
4737
tabIndex : -1,
4738
"ariaLabelled-by" : modal_id + '_baldrickModalLable',
caldera-core.php CHANGED
@@ -4,7 +4,7 @@
4
Plugin URI: http://digilab.co.za
5
Description: Easy to use, grid based responsive form builder for creating simple to complex forms.
6
Author: David Cramer
7
- Version: 1.2.2
8
Author URI: http://digilab.co.za
9
*/
10
@@ -17,7 +17,7 @@ if ( ! defined( 'WPINC' ) ) {
17
18
define('CFCORE_PATH', plugin_dir_path(__FILE__));
19
define('CFCORE_URL', plugin_dir_url(__FILE__));
20
- define('CFCORE_VER', '1.2.2');
21
define('CFCORE_EXTEND_URL', 'https://api.calderaforms.com/1.0/');
22
23
include_once CFCORE_PATH . 'classes/core.php';
@@ -29,6 +29,8 @@ include_once CFCORE_PATH . 'includes/cf-ajax/plugin.php';
29
include_once CFCORE_PATH . 'includes/field_processors.php';
30
include_once CFCORE_PATH . 'includes/custom_field_class.php';
31
include_once CFCORE_PATH . 'includes/filter_addon_plugins.php';
32
33
// table builder
34
register_activation_hook( __FILE__, array( 'Caldera_Forms', 'activate_caldera_forms' ) );
@@ -43,3 +45,6 @@ if ( is_admin() || defined( 'DOING_AJAX' ) ) {
43
44
}
45
4
Plugin URI: http://digilab.co.za
5
Description: Easy to use, grid based responsive form builder for creating simple to complex forms.
6
Author: David Cramer
7
+ Version: 1.3.0
8
Author URI: http://digilab.co.za
9
*/
10
17
18
define('CFCORE_PATH', plugin_dir_path(__FILE__));
19
define('CFCORE_URL', plugin_dir_url(__FILE__));
20
+ define('CFCORE_VER', '1.3.0');
21
define('CFCORE_EXTEND_URL', 'https://api.calderaforms.com/1.0/');
22
23
include_once CFCORE_PATH . 'classes/core.php';
29
include_once CFCORE_PATH . 'includes/field_processors.php';
30
include_once CFCORE_PATH . 'includes/custom_field_class.php';
31
include_once CFCORE_PATH . 'includes/filter_addon_plugins.php';
32
+ include_once CFCORE_PATH . 'processors/classes/load.php';
33
+ include_once CFCORE_PATH . 'processors/classes/get_data.php';
34
35
// table builder
36
register_activation_hook( __FILE__, array( 'Caldera_Forms', 'activate_caldera_forms' ) );
45
46
}
47
48
+ if ( is_admin() ) {
49
+ require_once( CFCORE_PATH . 'processors/classes/ui.php' );
50
+ }
classes/Caldera_Forms_Save_Final.php ADDED
@@ -0,0 +1,391 @@
1
+ <?php
2
+ /**
3
+ * Handles final saving of the form.
4
+ *
5
+ * @package Caldera_Forms
6
+ * @author Josh Pollock <Josh@CalderaWP.com>
7
+ * @license GPL-2.0+
8
+ * @link
9
+ * @copyright 2015 CalderaWP LLC
10
+ */
11
+ class Caldera_Forms_Save_Final {
12
+
13
+ public static function determine_type( $form, $_cf_frm_edt ) {
14
+
15
+ }
16
+
17
+ /**
18
+ * Save form in database
19
+ *
20
+ * @since 1.2.3
21
+ *
22
+ * @param array $form Form config
23
+ * @param int|null $entryid Optional. ID of entry to send. If not provided, will be determined from current POST data '_entry_id' key.
24
+ */
25
+ public static function save_in_db( $form, $entryid = null ) {
26
+ global $wpdb, $processed_meta;
27
+ if(!empty($form['db_support'])){
28
+
29
+ // new entry or update
30
+ if(empty($entryid)){
31
+
32
+ $entryid = Caldera_Forms::get_field_data( '_entry_id', $form );
33
+
34
+ foreach($form['fields'] as $field_id=>$field){
35
+ // add new and update
36
+ Caldera_Forms::save_field_data($field, $entryid, $form);
37
+
38
+ }
39
+
40
+ // save form meta if any
41
+ if(isset($processed_meta[$form['ID']])){
42
+ foreach($processed_meta[$form['ID']] as $process_id=>$meta_data){
43
+
44
+ foreach($meta_data as $meta_key=>$meta_value){
45
+ if(is_array($meta_value)){
46
+ foreach ($meta_value as &$check_value) {
47
+ if(is_array($check_value)){
48
+ foreach($check_value as &$sub_check_value){
49
+ if(!is_array($sub_check_value)){
50
+ $sub_check_value = Caldera_Forms::do_magic_tags( $sub_check_value );
51
+ }
52
+ }
53
+ }else{
54
+ $check_value = Caldera_Forms::do_magic_tags( $check_value );
55
+ }
56
+ }
57
+ }else{
58
+ $meta_value = Caldera_Forms::do_magic_tags( $meta_value );
59
+ }
60
+
61
+
62
+ if(count($meta_value) > 1){
63
+ $meta_value = json_encode($meta_value);
64
+ }else{
65
+ $meta_value = $meta_value[0];
66
+ if(is_array($meta_value) || is_object($meta_value)){
67
+ $meta_value = json_encode($meta_value);
68
+ }
69
+ }
70
+
71
+ $meta_entry = array(
72
+ 'entry_id' => $entryid,
73
+ 'process_id' => $process_id,
74
+ 'meta_key' => $meta_key,
75
+ 'meta_value' => $meta_value
76
+ );
77
+
78
+ $wpdb->insert($wpdb->prefix . 'cf_form_entry_meta', $meta_entry);
79
+
80
+ }
81
+
82
+ }
83
+ }
84
+
85
+ // update status
86
+ $wpdb->update($wpdb->prefix . 'cf_form_entries', array('status' => 'active'), array( 'id' => $entryid ) );
87
+
88
+ }else{
89
+
90
+ // do update
91
+ foreach($form['fields'] as $field_id=>$field){
92
+ // add new and update
93
+ Caldera_Forms::update_field_data($field, $entryid, $form);
94
+
95
+ }
96
+
97
+ if(isset($processed_meta[$form['ID']])){
98
+ foreach($processed_meta[$form['ID']] as $process_id=>$meta_data){
99
+
100
+ foreach($meta_data as $meta_key=>$meta_value){
101
+
102
+ if(count($meta_value) > 1){
103
+ $meta_value = json_encode($meta_value);
104
+ }else{
105
+ $meta_value = $meta_value[0];
106
+ }
107
+
108
+ $meta_entry = array(
109
+ 'entry_id' => $entryid,
110
+ 'process_id' => $process_id,
111
+ 'meta_key' => $meta_key,
112
+ 'meta_value' => $meta_value
113
+ );
114
+ $wpdb->insert($wpdb->prefix . 'cf_form_entry_meta', $meta_entry);
115
+
116
+ }
117
+
118
+ }
119
+ }
120
+
121
+ // return
122
+ return;
123
+ }
124
+
125
+ }
126
+
127
+ }
128
+
129
+ /**
130
+ * Process mailer
131
+ *
132
+ * @since 1.2.3
133
+ *
134
+ * @param array $form Form config
135
+ * @param int|null $entryid Optional. ID of entry to send. If not provided, will be deteremined based on global $transdata
136
+ * @param array|null $data Optional. Data to use for sending. If not provided, will be retrieved by form ID.
137
+ */
138
+ public static function do_mailer( $form, $entryid = null, $data = null ) {
139
+ global $transdata;
140
+
141
+ if ( ! $data ) {
142
+ $data = Caldera_Forms::get_submission_data($form);
143
+ }
144
+
145
+ // add entry ID to transient data
146
+ if( ! isset( $entryid ) ){
147
+ $entryid = null;
148
+ }
149
+ $transdata['entry_id'] = $entryid;
150
+
151
+ // do mailer!
152
+ $sendername = __('Caldera Forms Notification', 'caldera-forms');
153
+ if(!empty($form['mailer']['sender_name'])){
154
+ $sendername = $form['mailer']['sender_name'];
155
+ if( false !== strpos($sendername, '%')){
156
+ $isname = Caldera_Forms::get_slug_data( trim($sendername, '%'), $form);
157
+ if(!empty( $isname )){
158
+ $sendername = $isname;
159
+ }
160
+ }
161
+ }
162
+ if(empty($form['mailer']['sender_email'])){
163
+ $sendermail = get_option( 'admin_email' );
164
+ }else{
165
+ $sendermail = $form['mailer']['sender_email'];
166
+ if( false !== strpos($sendermail, '%')){
167
+ $ismail = Caldera_Forms::get_slug_data( trim($sendermail, '%'), $form);
168
+ if(is_email( $ismail )){
169
+ $sendermail = $ismail;
170
+ }
171
+ }
172
+ }
173
+ // use summary
174
+ if(empty($form['mailer']['email_message'])){
175
+ $form['mailer']['email_message'] = "{summary}";
176
+ }
177
+
178
+ $mail = array(
179
+ 'recipients' => array(),
180
+ 'subject' => Caldera_Forms::do_magic_tags($form['mailer']['email_subject']),
181
+ 'message' => stripslashes( $form['mailer']['email_message'] ) ."\r\n",
182
+ 'headers' => array(
183
+ Caldera_Forms::do_magic_tags( 'From: ' . $sendername . ' <' . $sendermail . '>' ),
184
+ ),
185
+ 'attachments' => array()
186
+ );
187
+
188
+ // if added a bcc
189
+ $bcc_to = trim( $form['mailer']['bcc_to'] );
190
+ if( !empty( $bcc_to ) ){
191
+ $mail['headers'][] = Caldera_Forms::do_magic_tags( 'Bcc: ' . $bcc_to );
192
+ }
193
+
194
+ // if added a replyto
195
+ $reply_to = trim( $form['mailer']['reply_to'] );
196
+ if( !empty( $reply_to ) ){
197
+ $mail['headers'][] = Caldera_Forms::do_magic_tags( 'Reply-To: <' . $reply_to . '>' );
198
+ }
199
+
200
+ // Filter Mailer first as not to have user input be filtered
201
+ $mail['message'] = Caldera_Forms::do_magic_tags($mail['message']);
202
+
203
+ if($form['mailer']['email_type'] == 'html'){
204
+ $mail['headers'][] = "Content-type: text/html";
205
+ $mail['message'] = wpautop( $mail['message'] );
206
+ }
207
+
208
+ // get tags
209
+ preg_match_all("/%(.+?)%/", $mail['message'], $hastags);
210
+ if(!empty($hastags[1])){
211
+ foreach($hastags[1] as $tag_key=>$tag){
212
+ $tagval = Caldera_Forms::get_slug_data($tag, $form);
213
+ if(is_array($tagval)){
214
+ $tagval = implode(', ', $tagval);
215
+ }
216
+ $mail['message'] = str_replace($hastags[0][$tag_key], $tagval, $mail['message']);
217
+ }
218
+ }
219
+
220
+ //$mail['message']
221
+
222
+ // ifs
223
+ preg_match_all("/\[if (.+?)?\](?:(.+?)?\[\/if\])?/", $mail['message'], $hasifs);
224
+ if(!empty($hasifs[1])){
225
+ // process ifs
226
+ foreach($hasifs[0] as $if_key=>$if_tag){
227
+
228
+ $content = explode('[else]', $hasifs[2][$if_key]);
229
+ if(empty($content[1])){
230
+ $content[1] = '';
231
+ }
232
+ $vars = shortcode_parse_atts( $hasifs[1][$if_key]);
233
+ foreach($vars as $varkey=>$varval){
234
+ if(is_string($varkey)){
235
+ $var = Caldera_Forms::get_slug_data($varkey, $form);
236
+ if( in_array($varval, (array) $var) ){
237
+ // yes show code
238
+ $mail['message'] = str_replace( $hasifs[0][$if_key], $content[0], $mail['message']);
239
+ }else{
240
+ // nope- no code
241
+ $mail['message'] = str_replace( $hasifs[0][$if_key], $content[1], $mail['message']);
242
+ }
243
+ }else{
244
+ $var = Caldera_Forms::get_slug_data($varval, $form);
245
+ if(!empty($var)){
246
+ // show code
247
+ $mail['message'] = str_replace( $hasifs[0][$if_key], $content[0], $mail['message']);
248
+ }else{
249
+ // no code
250
+ $mail['message'] = str_replace( $hasifs[0][$if_key], $content[1], $mail['message']);
251
+ }
252
+ }
253
+ }
254
+ }
255
+
256
+ }
257
+
258
+
259
+ if(!empty($form['mailer']['recipients'])){
260
+ $mail['recipients'] = explode(',', Caldera_Forms::do_magic_tags( $form['mailer']['recipients']) );
261
+ }else{
262
+ $mail['recipients'][] = get_option( 'admin_email' );
263
+ }
264
+
265
+ $submission = array();
266
+ foreach ($data as $field_id=>$row) {
267
+ if($row === null || !isset($form['fields'][$field_id]) ){
268
+ continue;
269
+ }
270
+
271
+ $key = $form['fields'][$field_id]['slug'];
272
+ if(is_array($row)){
273
+ if(!empty($row)){
274
+ $keys = array_keys($row);
275
+ if(is_int($keys[0])){
276
+ $row = implode(', ', $row);
277
+ }else{
278
+ $tmp = array();
279
+ foreach($row as $linekey=>$item){
280
+ if(is_array($item)){
281
+ $item = '( ' . implode(', ', $item).' )';
282
+ }
283
+ $tmp[] = $linekey.': '.$item;
284
+ }
285
+ $row = implode(', ', $tmp);
286
+ }
287
+ }else{
288
+ $row = null;
289
+ }
290
+ }
291
+ $mail['message'] = str_replace('%'.$key.'%', $row, $mail['message']);
292
+ $mail['subject'] = str_replace('%'.$key.'%', $row, $mail['subject']);
293
+
294
+ $submission[] = $row;
295
+ $labels[] = $form['fields'][$field_id]['label'];
296
+ }
297
+
298
+ // final magic
299
+ $mail['message'] = Caldera_Forms::do_magic_tags( $mail['message'] );
300
+ $mail['subject'] = Caldera_Forms::do_magic_tags( $mail['subject'] );
301
+
302
+ // CSV
303
+ if(!empty($form['mailer']['csv_data'])){
304
+ ob_start();
305
+ $df = fopen("php://output", 'w');
306
+ fputcsv($df, $labels);
307
+ fputcsv($df, $submission);
308
+ fclose($df);
309
+ $csv = ob_get_clean();
310
+ $csvfile = wp_upload_bits( uniqid().'.csv', null, $csv );
311
+ if( isset( $csvfile['file'] ) && false == $csvfile['error'] && file_exists( $csvfile['file'] ) ){
312
+ $mail['attachments'][] = $csvfile['file'];
313
+ }
314
+ }
315
+
316
+ if(empty($mail)){
317
+ return;
318
+ }
319
+
320
+ /**
321
+ * Filter email data before sending
322
+ *
323
+ * @since 1.2.3 in this location.
324
+ * @since unknown in original location (Caldera_Forms::save_final_form)
325
+ *
326
+ * @param array $mail Email data
327
+ * @param array $data Form entry data
328
+ * @param array $form The form config
329
+ */
330
+ $mail = apply_filters( 'caldera_forms_mailer', $mail, $data, $form);
331
+
332
+
333
+ $headers = implode("\r\n", $mail['headers']);
334
+
335
+ /**
336
+ * Runs before mail is sent, but after data is prepared
337
+ *
338
+ * @since 1.2.3 in this location.
339
+ * @since unknown in original location (Caldera_Forms::save_final_form)
340
+ *
341
+ * @param array $mail Email data
342
+ * @param array $data Form entry data
343
+ * @param array $form The form config
344
+ */
345
+ do_action( 'caldera_forms_do_mailer', $mail, $data, $form);
346
+
347
+ // force message to string.
348
+ if( is_array( $mail['message'] ) ){
349
+ $mail['message'] = implode( "\n", $mail['message'] );
350
+ }
351
+
352
+ if( ! empty( $mail ) ){
353
+
354
+ // is send debug enabled?
355
+ if( !empty( $form['debug_mailer'] ) ){
356
+ add_action( 'phpmailer_init', array( 'Caldera_Forms', 'debug_mail_send' ), 1000 );
357
+ }
358
+
359
+ if( wp_mail( (array) $mail['recipients'], $mail['subject'], stripslashes( $mail['message'] ), $headers, $mail['attachments'] )){
360
+
361
+ // kill attachment.
362
+ if(!empty($csvfile['file'])){
363
+ if(file_exists($csvfile['file'])){
364
+ unlink($csvfile['file']);
365
+ }
366
+ }
367
+ }else{
368
+ /**
369
+ * Fires main mailer fails
370
+ *
371
+ * @since 1.2.3
372
+ *
373
+ * @param array $mail Email data
374
+ * @param array $data Form entry data
375
+ * @param array $form The form config
376
+ */
377
+ do_action( 'caldera_forms_mailer_failed', $mail, $data, $form );
378
+
379
+ }
380
+ }else{
381
+ if(!empty($csvfile['file'])){
382
+ if(file_exists($csvfile['file'])){
383
+ unlink($csvfile['file']);
384
+ }
385
+ }
386
+
387
+ }
388
+
389
+ }
390
+
391
+ }
classes/admin.php CHANGED
@@ -26,22 +26,36 @@ class Caldera_Forms_Admin {
26
* @var string
27
*/
28
protected $plugin_slug = 'caldera-forms';
29
/**
30
* @var string
31
*/
32
protected $screen_prefix = array();
33
/**
34
* @var string
35
*/
36
protected $sub_prefix = null;
37
/**
38
* @var string
39
*/
40
protected $addons = array();
41
/**
42
* @var object
43
*/
44
protected static $instance = null;
45
/**
46
* Initialize the plugin by setting localization, filters, and administration functions.
47
*
@@ -96,6 +110,8 @@ class Caldera_Forms_Admin {
96
add_action('admin_footer-post.php', array( $this, 'render_editor_template')); // Fired on post edit page
97
add_action('admin_footer-post-new.php', array( $this, 'render_editor_template')); // Fired on add new post page
98
99
}
100
101
public function render_editor_template(){
@@ -112,7 +128,67 @@ class Caldera_Forms_Admin {
112
<?php
113
114
}
115
116
117
public function get_form_preview(){
118
global $post;
@@ -167,8 +243,10 @@ class Caldera_Forms_Admin {
167
if(empty($_POST['do'])){
168
die;
169
}
170
171
- switch ($_POST['do']) {
172
case 'active':
173
case 'trash':
174
case 'delete':
@@ -182,7 +260,7 @@ class Caldera_Forms_Admin {
182
$selectors[] = '#entry_row_' . (int) $item_id;
183
}
184
185
- switch ($_POST['do']) {
186
case 'delete':
187
if( current_user_can( 'delete_others_posts' ) ){
188
$result = $wpdb->query( "DELETE FROM `" . $wpdb->prefix . "cf_form_entries` WHERE `id` IN (".implode(',', $items).");" );
@@ -195,16 +273,16 @@ class Caldera_Forms_Admin {
195
196
default:
197
if( current_user_can( 'edit_others_posts' ) ){
198
- $result = $wpdb->query( $wpdb->prepare( "UPDATE `" . $wpdb->prefix . "cf_form_entries` SET `status` = %s WHERE `id` IN (".implode(',', $items).");", $_POST['do'] ) );
199
}
200
break;
201
}
202
203
if( $result ){
204
205
- $out['status'] = $_POST['do'];
206
- $out['undo'] = ( $_POST['do'] === 'trash' ? 'active' : __('Trash') );
207
- $out['undo_text'] = ( $_POST['do'] === 'trash' ? __('Restore', 'caldera-forms') : __('Trash') );
208
209
$out['entries'] = implode(',',$selectors);
210
$out['total'] = $wpdb->get_var($wpdb->prepare("SELECT COUNT(`id`) AS `total` FROM `" . $wpdb->prefix . "cf_form_entries` WHERE `form_id` = %s && `status` = 'active';", $_POST['form']));
@@ -263,7 +341,7 @@ class Caldera_Forms_Admin {
263
}
264
public static function get_admin_meta_templates(){
265
266
- $processors = apply_filters( 'caldera_forms_get_form_processors', array() );
267
if(!empty($processors)){
268
foreach($processors as $processor_type=>$processor_config){
269
if( isset( $processor_config['meta_template'] ) && file_exists( $processor_config['meta_template'] ) ){
@@ -430,7 +508,7 @@ class Caldera_Forms_Admin {
430
/**
431
* Get entries from a form
432
*
433
- * @since 1.3.0
434
*
435
* @param string|array $form Form ID or form config.
436
* @param int $page Optional. Page of entries to get per page. Default is 1.
@@ -489,17 +567,11 @@ class Caldera_Forms_Admin {
489
490
$filter = null;
491
492
- // status
493
- if(!empty($status)){
494
- $status = $wpdb->prepare("%s", $status );
495
- }
496
-
497
$data['trash'] = (int) $wpdb->get_var($wpdb->prepare("SELECT COUNT(`id`) AS `total` FROM `" . $wpdb->prefix . "cf_form_entries` WHERE `form_id` = %s AND `status` = 'trash';", $form_id ) );
498
$data['active'] = (int) $wpdb->get_var($wpdb->prepare("SELECT COUNT(`id`) AS `total` FROM `" . $wpdb->prefix . "cf_form_entries` WHERE `form_id` = %s AND `status` = 'active';", $form_id ) );
499
500
-
501
// set current total
502
- if(!empty( $status ) && isset($data[ $status ])){
503
$data['total'] = $data[ $status ];
504
}else{
505
$data['total'] = $data['active'];
@@ -533,7 +605,7 @@ class Caldera_Forms_Admin {
533
`form_id`
534
FROM `" . $wpdb->prefix ."cf_form_entries`
535
536
- WHERE `form_id` = %s AND `status` = ".$status." ORDER BY `datestamp` DESC LIMIT " . $limit . ";", $form_id));
537
538
if(!empty($rawdata)){
539
@@ -816,7 +888,7 @@ class Caldera_Forms_Admin {
816
$panel_extensions = apply_filters( 'caldera_forms_get_panel_extensions', array() );
817
818
// load processors
819
- $form_processors = apply_filters( 'caldera_forms_get_form_processors', array() );
820
821
// merge a list
822
$merged_types = array_merge($field_types, $panel_extensions, $form_processors);
@@ -1184,40 +1256,7 @@ class Caldera_Forms_Admin {
1184
}
1185
//dump($data);
1186
}
1187
- /*dump($data);
1188
- foreach( $rawdata as $entry){
1189
- // build structure
1190
- if(!isset($data[$entry->_entryid])){
1191
- $data[$entry->_entryid] = $structure;
1192
- }
1193
- // check for json
1194
- if(substr($entry->value, 0,2) === '{"' && substr($entry->value, strlen($entry->value)-2 ) === '"}'){
1195
- $row = json_decode($entry->value, true);
1196
- if(!empty($row)){
1197
- $keys = array_keys($row);
1198
- if(is_int($keys[0])){
1199
- $row = implode(', ', $row);
1200
- }else{
1201
- $tmp = array();
1202
- foreach($row as $key=>$item){
1203
- if(is_array($item)){
1204
- $item = '( ' . implode(', ', $item).' )';
1205
- }
1206
- $tmp[] = $key.': '.$item;
1207
- }
1208
- $row = implode(', ', $tmp);
1209
- }
1210
- $entry->value = $row;
1211
- }
1212
- }
1213
- $data[$entry->_entryid][$entry->slug] = $entry->value;
1214
- $label = $entry->slug;
1215
- if(isset($labels[$entry->slug])){
1216
- $label = $labels[$entry->slug];
1217
- }
1218
- $headers[$entry->slug] = $label;
1219
- }*/
1220
-
1221
header("Pragma: public");
1222
header("Expires: 0");
1223
header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
@@ -1299,6 +1338,9 @@ class Caldera_Forms_Admin {
1299
if(isset($forms[$data['ID']]['settings'])){
1300
unset($forms[$data['ID']]['settings']);
1301
}
1302
1303
foreach($forms as $form_id=>$form_config){
1304
if(empty($form_config)){
@@ -1307,7 +1349,14 @@ class Caldera_Forms_Admin {
1307
}
1308
// combine structure pages
1309
$data['layout_grid']['structure'] = implode('#', $data['layout_grid']['structure']);
1310
-
1311
// add from to list
1312
update_option($data['ID'], $data);
1313
do_action('caldera_forms_save_form', $data);
@@ -1331,6 +1380,9 @@ class Caldera_Forms_Admin {
1331
1332
parse_str( $_POST['data'], $newform );
1333
1334
// get form registry
1335
$forms = Caldera_Forms::get_forms( true );
1336
if(empty($forms)){
@@ -1339,15 +1391,25 @@ class Caldera_Forms_Admin {
1339
if(!empty($newform['clone'])){
1340
$clone = $newform['clone'];
1341
}
1342
$newform = array(
1343
"ID" => uniqid('CF'),
1344
"name" => $newform['name'],
1345
"description" => $newform['description'],
1346
"success" => __('Form has been successfully submitted. Thank you.', 'caldera-forms'),
1347
"form_ajax" => 1,
1348
- "hide_form" => 1
1349
);
1350
-
1351
// add from to list
1352
$newform = apply_filters( 'caldera_forms_create_form', $newform);
1353
@@ -1360,6 +1422,8 @@ class Caldera_Forms_Admin {
1360
$newform = array_merge($clone_form, $newform);
1361
}
1362
}
1363
1364
// add form to db
1365
update_option($newform['ID'], $newform);
@@ -1401,7 +1465,7 @@ class Caldera_Forms_Admin {
1401
"label" => __("Layout Builder", 'caldera-forms'),
1402
"active" => true,
1403
"actions" => array(
1404
- $path . "layout_add_row.php"
1405
),
1406
"repeat" => 0,
1407
"canvas" => $path . "layout.php",
@@ -1413,6 +1477,12 @@ class Caldera_Forms_Admin {
1413
"label" => __("Form Pages", 'caldera-forms'),
1414
"canvas" => $path . "pages.php",
1415
),
1416
"processors" => array(
1417
"name" => __("Processors", 'caldera-forms'),
1418
"location" => "lower",
@@ -1543,6 +1613,51 @@ class Caldera_Forms_Admin {
1543
1544
}
1545
1546
}
1547
1548
26
* @var string
27
*/
28
protected $plugin_slug = 'caldera-forms';
29
+
30
/**
31
* @var string
32
*/
33
protected $screen_prefix = array();
34
+
35
/**
36
* @var string
37
*/
38
protected $sub_prefix = null;
39
+
40
/**
41
* @var string
42
*/
43
protected $addons = array();
44
+
45
/**
46
* @var object
47
*/
48
protected static $instance = null;
49
+
50
+ /**
51
+ * Holds admin notices
52
+ *
53
+ * @since 1.3.0
54
+ *
55
+ * @var array
56
+ */
57
+ private static $admin_notices;
58
+
59
/**
60
* Initialize the plugin by setting localization, filters, and administration functions.
61
*
110
add_action('admin_footer-post.php', array( $this, 'render_editor_template')); // Fired on post edit page
111
add_action('admin_footer-post-new.php', array( $this, 'render_editor_template')); // Fired on add new post page
112
113
+ add_action( 'caldera_forms_new_form_template_end', array( $this, 'load_new_form_templates') );
114
+
115
}
116
117
public function render_editor_template(){
128
<?php
129
130
}
131
+
132
+ /**
133
+ * Returns the array of form templates.
134
+ *
135
+ * @since 1.2.3
136
+ *
137
+ * @return array The form templates
138
+ */
139
+ public static function internal_form_templates(){
140
+
141
+ $internal_templates = array(
142
+ 'starter_contact_form' => array(
143
+ 'name' => __( 'Starter Contact Form', 'caldera-forms' ),
144
+ 'template' => include CFCORE_PATH . 'includes/templates/starter-contact-form.php'
145
+ ),
146
+ 'variable_price_example' => array(
147
+ 'name' => __( 'Variable Pricing Form, with add-on products.', 'caldera-forms' ),
148
+ 'template' => include CFCORE_PATH . 'includes/templates/variable-price-example.php'
149
+ ),
150
+ 'registration' => array(
151
+ 'name' => __( 'Registration Form, with optional additional participants.', 'caldera-forms' ),
152
+ 'template' => include CFCORE_PATH . 'includes/templates/registration-form-example.php'
153
+ ),
154
+
155
+ );
156
+
157
+ /**
158
+ * Filter form templates
159
+ *
160
+ * @since 1.2.3
161
+ *
162
+ * @param array $internal_templates Form templates
163
+ */
164
+ return apply_filters( 'caldera_forms_get_form_templates', $internal_templates );
165
+
166
+ }
167
168
+ public function load_new_form_templates(){
169
+
170
+ $form_templates = self::internal_form_templates();
171
+
172
+ ?>
173
+ <div class="caldera-config-group">
174
+ <label for=""><?php echo __('Form Template', 'caldera-forms'); ?></label>
175
+ <div class="caldera-config-field">
176
+ <select class="new-form-template block-input field-config" name="template" value="">
177
+ <option value="0"><?php echo __('no template - blank form', 'caldera-forms'); ?></option>
178
+ <?php
179
+
180
+ foreach( $form_templates as $template_slug => $template ){
181
+ if( !empty( $template['template'] ) && !empty( $template['name'] ) ){
182
+ echo '<option value="' . $template_slug . '">' . $template['name'] . '</option>';
183
+ }
184
+ }
185
+
186
+ ?>
187
+ </select>
188
+ </div>
189
+ </div>
190
+ <?php
191
+ }
192
193
public function get_form_preview(){
194
global $post;
243
if(empty($_POST['do'])){
244
die;
245
}
246
+
247
+ $do_action = strtolower( $_POST['do'] );
248
249
+ switch ( $do_action ) {
250
case 'active':
251
case 'trash':
252
case 'delete':
260
$selectors[] = '#entry_row_' . (int) $item_id;
261
}
262
263
+ switch ($do_action) {
264
case 'delete':
265
if( current_user_can( 'delete_others_posts' ) ){
266
$result = $wpdb->query( "DELETE FROM `" . $wpdb->prefix . "cf_form_entries` WHERE `id` IN (".implode(',', $items).");" );
273
274
default:
275
if( current_user_can( 'edit_others_posts' ) ){
276
+ $result = $wpdb->query( $wpdb->prepare( "UPDATE `" . $wpdb->prefix . "cf_form_entries` SET `status` = %s WHERE `id` IN (".implode(',', $items).");", $do_action ) );
277
}
278
break;
279
}
280
281
if( $result ){
282
283
+ $out['status'] = $do_action;
284
+ $out['undo'] = ( $do_action === 'trash' ? 'active' : __('Trash') );
285
+ $out['undo_text'] = ( $do_action === 'trash' ? __('Restore', 'caldera-forms') : __('Trash') );
286
287
$out['entries'] = implode(',',$selectors);
288
$out['total'] = $wpdb->get_var($wpdb->prepare("SELECT COUNT(`id`) AS `total` FROM `" . $wpdb->prefix . "cf_form_entries` WHERE `form_id` = %s && `status` = 'active';", $_POST['form']));
341
}
342
public static function get_admin_meta_templates(){
343
344
+ $processors = $processors = Caldera_Forms_Processor_Load::get_instance()->get_processors();
345
if(!empty($processors)){
346
foreach($processors as $processor_type=>$processor_config){
347
if( isset( $processor_config['meta_template'] ) && file_exists( $processor_config['meta_template'] ) ){
508
/**
509
* Get entries from a form
510
*
511
+ * @since 1.2.1
512
*
513
* @param string|array $form Form ID or form config.
514
* @param int $page Optional. Page of entries to get per page. Default is 1.
567
568
$filter = null;
569
570
$data['trash'] = (int) $wpdb->get_var($wpdb->prepare("SELECT COUNT(`id`) AS `total` FROM `" . $wpdb->prefix . "cf_form_entries` WHERE `form_id` = %s AND `status` = 'trash';", $form_id ) );
571
$data['active'] = (int) $wpdb->get_var($wpdb->prepare("SELECT COUNT(`id`) AS `total` FROM `" . $wpdb->prefix . "cf_form_entries` WHERE `form_id` = %s AND `status` = 'active';", $form_id ) );
572
573
// set current total
574
+ if(!empty( $status ) && isset( $data[ $status ] ) ){
575
$data['total'] = $data[ $status ];
576
}else{
577
$data['total'] = $data['active'];
605
`form_id`
606
FROM `" . $wpdb->prefix ."cf_form_entries`
607
608
+ WHERE `form_id` = %s AND `status` = %s ORDER BY `datestamp` DESC LIMIT " . $limit . ";", $form_id, $status ) );
609
610
if(!empty($rawdata)){
611
888
$panel_extensions = apply_filters( 'caldera_forms_get_panel_extensions', array() );
889
890
// load processors
891
+ $form_processors = $processors = Caldera_Forms_Processor_Load::get_instance()->get_processors();
892
893
// merge a list
894
$merged_types = array_merge($field_types, $panel_extensions, $form_processors);
1256
}
1257
//dump($data);
1258
}
1259
+
1260
header("Pragma: public");
1261
header("Expires: 0");
1262
header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
1338
if(isset($forms[$data['ID']]['settings'])){
1339
unset($forms[$data['ID']]['settings']);
1340
}
1341
+ if(isset($forms[$data['ID']]['conditional_groups'])){
1342
+ unset($forms[$data['ID']]['conditional_groups']);
1343
+ }
1344
1345
foreach($forms as $form_id=>$form_config){
1346
if(empty($form_config)){
1349
}
1350
// combine structure pages
1351
$data['layout_grid']['structure'] = implode('#', $data['layout_grid']['structure']);
1352
+ // remove fields from conditions
1353
+ if( !empty( $data['conditional_groups']['fields'] ) ){
1354
+ unset( $data['conditional_groups']['fields'] );
1355
+ }
1356
+ // remove magics ( yes, not used yet.)
1357
+ if( !empty( $data['conditional_groups']['magic'] ) ){
1358
+ unset( $data['conditional_groups']['magic'] );
1359
+ }
1360
// add from to list
1361
update_option($data['ID'], $data);
1362
do_action('caldera_forms_save_form', $data);
1380
1381
parse_str( $_POST['data'], $newform );
1382
1383
+ // get form templates
1384
+ $form_templates = self::internal_form_templates();
1385
+
1386
// get form registry
1387
$forms = Caldera_Forms::get_forms( true );
1388
if(empty($forms)){
1391
if(!empty($newform['clone'])){
1392
$clone = $newform['clone'];
1393
}
1394
+ // load template if any
1395
+ if( !empty( $newform['template'] ) ){
1396
+ if( isset( $form_templates[ $newform['template'] ] ) && !empty( $form_templates[ $newform['template'] ]['template'] ) ){
1397
+ $form_template = $form_templates[ $newform['template'] ]['template'];
1398
+ }
1399
+ }
1400
$newform = array(
1401
"ID" => uniqid('CF'),
1402
"name" => $newform['name'],
1403
"description" => $newform['description'],
1404
"success" => __('Form has been successfully submitted. Thank you.', 'caldera-forms'),
1405
"form_ajax" => 1,
1406
+ "hide_form" => 1,
1407
+ "check_honey" => 1,
1408
);
1409
+ // is template?
1410
+ if( !empty( $form_template ) && is_array( $form_template ) ){
1411
+ $newform = array_merge( $form_template, $newform );
1412
+ }
1413
// add from to list
1414
$newform = apply_filters( 'caldera_forms_create_form', $newform);
1415
1422
$newform = array_merge($clone_form, $newform);
1423
}
1424
}
1425
+
1426
+
1427
1428
// add form to db
1429
update_option($newform['ID'], $newform);
1465
"label" => __("Layout Builder", 'caldera-forms'),
1466
"active" => true,
1467
"actions" => array(