Custom Contact Forms - Version 6.1.4

Version Description

  • Decode html entities on model sync. Escape entities on output.
Download this release

Release Info

Developer tlovett1
Plugin Icon 128x128 Custom Contact Forms
Version 6.1.4
Comparing to
See all releases

Code changes from version 6.1.2 to 6.1.4

build/js/form-manager.js CHANGED
@@ -234,6 +234,34 @@
234
  return Backbone.Model.prototype.set.call( this, key, value, options );
235
  };
236
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
237
  wp.ccf.models.FieldChoice = wp.ccf.models.FieldChoice || Backbone.Model.extend(
238
  {
239
  defaults: {
@@ -242,6 +270,10 @@
242
  selected: false
243
  },
244
 
 
 
 
 
245
  set: _modelSet
246
  }
247
  );
@@ -253,6 +285,10 @@
253
 
254
  set: _modelSet,
255
 
 
 
 
 
256
  defaults: function() {
257
  var defaults = {
258
  fields: new wp.ccf.collections.Fields(),
@@ -273,6 +309,13 @@
273
  return defaults;
274
  },
275
 
 
 
 
 
 
 
 
276
  getFieldSlugs: function( mutableOnly ) {
277
  var fields = wp.ccf.currentForm.get( 'fields' ),
278
  columns = [];
@@ -310,7 +353,9 @@
310
 
311
  if ( choices && choices.length > 0 ) {
312
  for ( var z = 0; z < newField.choices; z++ ) {
313
- choices.at( z ).set( newField.choices[z] );
 
 
314
  }
315
  }
316
 
@@ -318,6 +363,7 @@
318
  }
319
 
320
  field.set( newField );
 
321
  }
322
  }
323
 
@@ -326,7 +372,10 @@
326
  var newFields = [];
327
 
328
  _.each( response.fields, function( field ) {
329
- newFields.push( new wp.ccf.models.Fields[field.type]( field ) );
 
 
 
330
  });
331
 
332
  response.fields = new wp.ccf.collections.Fields( newFields, { formId: response.ID } );
@@ -377,6 +426,10 @@
377
  return [ 'slug' ];
378
  },
379
 
 
 
 
 
380
  hasRequiredAttributes: function() {
381
  var SELF = this;
382
  var reqsMet = true;
@@ -583,7 +636,10 @@
583
  var choices = [];
584
 
585
  _.each( attributes.choices, function( choice ) {
586
- choices.push( new wp.ccf.models.FieldChoice( choice ) );
 
 
 
587
  });
588
 
589
  this.set( 'choices', new wp.ccf.collections.FieldChoices( choices ) );
234
  return Backbone.Model.prototype.set.call( this, key, value, options );
235
  };
236
 
237
+ /**
238
+ * We decode HTML entities after syncing then escape on output. The
239
+ * point of this is to prevent double escaping.
240
+ */
241
+ var _modelDecode = function( excludeKeys ) {
242
+ for ( var key in this.attributes ) {
243
+ if ( excludeKeys.indexOf( key ) === -1 ) {
244
+ var value = this.get( key );
245
+
246
+ if ( typeof value === 'string' && value !== '' ) {
247
+ value = String( value )
248
+ .replace( /&amp;/g, '&' )
249
+ .replace( /&lt;/g, '<' )
250
+ .replace( /&gt;/g, '>' )
251
+ .replace( /&quot;/g, '"' )
252
+ .replace( /&#8220;/g, '”' )
253
+ .replace( /&#8221;/g, '”' )
254
+ .replace( /&#8216;/g, "‘" )
255
+ .replace( /&#039;/g, "'" );
256
+
257
+ this.set( key, value );
258
+ }
259
+ }
260
+ }
261
+
262
+ return this;
263
+ };
264
+
265
  wp.ccf.models.FieldChoice = wp.ccf.models.FieldChoice || Backbone.Model.extend(
266
  {
267
  defaults: {
270
  selected: false
271
  },
272
 
273
+ decode: function() {
274
+ return _modelDecode.call( this, [] );
275
+ },
276
+
277
  set: _modelSet
278
  }
279
  );
285
 
286
  set: _modelSet,
287
 
288
+ initialize: function() {
289
+ this.on( 'sync', this.decode, this );
290
+ },
291
+
292
  defaults: function() {
293
  var defaults = {
294
  fields: new wp.ccf.collections.Fields(),
309
  return defaults;
310
  },
311
 
312
+ decode: function() {
313
+ var keys = _.keys( wp.api.models.Post.prototype.defaults );
314
+ keys = _.without( keys, 'title' );
315
+
316
+ return _modelDecode.call( this, keys );
317
+ },
318
+
319
  getFieldSlugs: function( mutableOnly ) {
320
  var fields = wp.ccf.currentForm.get( 'fields' ),
321
  columns = [];
353
 
354
  if ( choices && choices.length > 0 ) {
355
  for ( var z = 0; z < newField.choices; z++ ) {
356
+ var choice = choices.at( z );
357
+ choice.set( newField.choices[z] );
358
+ choice.decode();
359
  }
360
  }
361
 
363
  }
364
 
365
  field.set( newField );
366
+ field.decode();
367
  }
368
  }
369
 
372
  var newFields = [];
373
 
374
  _.each( response.fields, function( field ) {
375
+ var fieldModel = new wp.ccf.models.Fields[field.type]( field );
376
+ fieldModel.decode();
377
+
378
+ newFields.push( fieldModel );
379
  });
380
 
381
  response.fields = new wp.ccf.collections.Fields( newFields, { formId: response.ID } );
426
  return [ 'slug' ];
427
  },
428
 
429
+ decode: function() {
430
+ return _modelDecode.call( this, _.keys( wp.api.models.Post.prototype.defaults ) );
431
+ },
432
+
433
  hasRequiredAttributes: function() {
434
  var SELF = this;
435
  var reqsMet = true;
636
  var choices = [];
637
 
638
  _.each( attributes.choices, function( choice ) {
639
+ var choiceModel = new wp.ccf.models.FieldChoice( choice );
640
+ choiceModel.decode();
641
+
642
+ choices.push( choiceModel );
643
  });
644
 
645
  this.set( 'choices', new wp.ccf.collections.FieldChoices( choices ) );
build/js/form-manager.min.js CHANGED
@@ -1,2 +1,2 @@
1
- (function(e,t,i,l){"use strict";window.wp=window.wp||{},wp.ccf=wp.ccf||{},wp.ccf.utils=wp.ccf.utils||{},wp.ccf.utils.cleanDateFields=function(e){delete e.date,delete e.date_gmt,delete e.modified,delete e.modified_gmt,delete e.date_tz,delete e.modified_tz},wp.ccf.utils.insertFormShortcode=function(e){var t=wp.ccf.forms.findWhere({ID:e.get("ID")});t||wp.ccf.forms.add(e);var i=tinymce.get(wpActiveEditor),l='[ccf_form id="'+e.get("ID")+'"]';i&&!i.isHidden()?tinymce.activeEditor.execCommand("mceInsertContent",!1,l):document.getElementById(wpActiveEditor).value+=l},wp.ccf.utils.getPrettyPostDate=function(e){return e=moment(e),e.format("h:mm a M/D/YYYY")},wp.ccf.utils.wordChop=function(e,t){var i=e.substr(0,t);return i.substr(0,Math.min(i.length,i.lastIndexOf(" "))),i.length<e.length&&(i+="..."),i},wp.ccf.utils.isFieldDate=function(e){return e.date!==void 0||e.hour!==void 0&&e.minute!==void 0&&e["am-pm"]!==void 0?!0:!1},wp.ccf.utils.isFieldName=function(e){return e.name!==void 0||e.last!==void 0?!0:!1},wp.ccf.utils.isFieldAddress=function(e){return e.street!==void 0&&e.city!==void 0&&e.zipcode!==void 0&&e.line_two!==void 0?!0:!1},wp.ccf.utils.getPrettyFieldDate=function(e){var t="",i="";if(e.hour&&e.minute&&e["am-pm"]&&(t+=e.hour+":"+e.minute+" "+e["am-pm"]),e.date&&(t+=" "+e.date),!t)return"-";var s=moment(t);return s.isValid()?(e.hour&&e.minute&&e["am-pm"]&&(i+=s.format("h:mm a")),e.date&&(i&&(i+=" "),i+=s.format("M/D/YYYY")),i):l.invalidDate},wp.ccf.utils.getPrettyFieldName=function(e){var t=e.first;return t.length>0&&(t+=" "),e.last&&(t+=e.last),t||(t="-"),t},wp.ccf.utils.getPrettyFieldAddress=function(e){if(!e.street||!e.city)return"-";var t=e.street;return e.line_two&&(t+=" "+e.line_two),t+=", "+e.city,e.state&&(t+=", "+e.state),e.zipcode&&(t+=" "+e.zipcode),e.country&&(t+=" "+e.country),t}})(jQuery,Backbone,_,ccfSettings),function(e,t,i){"use strict";wp.ccf.mixins=wp.ccf.mixins||{},wp.ccf.mixins.subViewable=wp.ccf.mixins.subViewable||{subViews:{},initRenderSubViews:function(e,t,l){this.renderedSubViews||(this.renderedSubViews={});for(var s in this.subViews){var c={el:this.$el.find(".ccf-"+s),parent:this};l&&i.extend(c,l),this.renderedSubViews[s]&&this.renderedSubViews[s].destroy&&this.renderedSubViews[s].destroy(),(t||!this.renderedSubViews[s])&&(this.renderedSubViews[s]=new this.subViews[s](c)),this.renderedSubViews[s].render(),e&&(this.renderedSubViews[s].el.style.display="block")}return this},showView:function(e,t,i){if(this.renderedSubViews!==void 0&&this.renderedSubViews[e]!==void 0){var l=this.renderedSubViews[e];i||l.render(t),l.el.style.display="block",this.currentView=e;for(var s in this.subViews)s!==e&&(this.renderedSubViews[s].el.style.display="none")}}}}(jQuery,Backbone,_,ccfSettings),function(e,t,i,l,s){"use strict";wp.ccf.models=wp.ccf.models||{},wp.ccf.models.Fields=wp.ccf.models.Fields||{};var c=function(e,i,l){return"object"!=typeof i&&""===i&&(i=""),t.Model.prototype.set.call(this,e,i,l)};wp.ccf.models.FieldChoice=wp.ccf.models.FieldChoice||t.Model.extend({defaults:{label:"",value:"",selected:!1},set:c}),wp.ccf.models.Form=wp.ccf.models.Form||wp.api.models.Post.extend({urlRoot:s.root+"/ccf/forms",set:c,defaults:function(){var e={fields:new wp.ccf.collections.Fields,type:"ccf_form",status:"publish",description:"",buttonText:"Submit Form",completionActionType:"text",completionRedirectUrl:"",completionMessage:"",sendEmailNotifications:!1,emailNotificationAddresses:l.adminEmail};return e=i.defaults(e,this.constructor.__super__.defaults),wp.ccf.utils.cleanDateFields(e),e},getFieldSlugs:function(e){var t=wp.ccf.currentForm.get("fields"),i=[];return t.each(function(t){e&&t.isImmutable||i.push(t.get("slug"))}),i},parse:function(e){var t=this;if(e.fields){var l=t.get("fields");if(l&&l.length>0){for(var s=0;e.fields.length>s;s++){var c=e.fields[s],n=l.findWhere({slug:c.slug});if(n){if(c.choices!==void 0){var r=t.get("choices");if(r&&r.length>0)for(var o=0;c.choices>o;o++)r.at(o).set(c.choices[o]);delete e.fields[s].choices}n.set(c)}}delete e.fields}else{var a=[];i.each(e.fields,function(e){a.push(new wp.ccf.models.Fields[e.type](e))}),e.fields=new wp.ccf.collections.Fields(a,{formId:e.ID})}}return this.constructor.__super__.parse.call(this,e)},toJSON:function(){var e=this.constructor.__super__.toJSON.call(this);return e.fields&&(e.fields=e.fields.toJSON()),e.author&&(e.author=e.author.toJSON()),e}}),wp.ccf.models.Submission=wp.api.models.Submission||wp.api.models.Post.extend({idAttribute:"ID",defaults:{ID:null,data:{}}}),wp.ccf.models.Field=wp.api.models.Field||wp.api.models.Post.extend({idAttribute:"ID",defaults:{ID:null},set:c,required:function(){return["slug"]},hasRequiredAttributes:function(){var e=this,t=!0;return i.each(this.required(),function(i){(e.get(i)===void 0||""===e.get(i))&&(t=!1)}),t}}),wp.ccf.models.StandardField=wp.ccf.models.StandardField||wp.ccf.models.Field.extend({idAttribute:"ID",defaults:function(){var e={label:"Field Label",value:"",placeholder:"",slug:"",type:"",required:!1,className:""};return i.defaults(e,this.constructor.__super__.defaults)}}),wp.ccf.models.Fields["single-line-text"]=wp.ccf.models.Fields["single-line-text"]||wp.ccf.models.StandardField.extend({defaults:function(){var e={type:"single-line-text"};return i.defaults(e,this.constructor.__super__.defaults())}}),wp.ccf.models.Fields["paragraph-text"]=wp.ccf.models.Fields["paragraph-text"]||wp.ccf.models.StandardField.extend({defaults:function(){var e={type:"paragraph-text"};return i.defaults(e,this.constructor.__super__.defaults())}}),wp.ccf.models.Fields.hidden=wp.ccf.models.Fields.hidden||wp.ccf.models.StandardField.extend({defaults:function(){var e={type:"hidden"};return i.defaults(e,this.constructor.__super__.defaults())}}),wp.ccf.models.Fields.email=wp.ccf.models.Fields.email||wp.ccf.models.StandardField.extend({defaults:function(){var e={type:"email",emailConfirmation:!1};return i.defaults(e,this.constructor.__super__.defaults())}}),wp.ccf.models.Fields.website=wp.ccf.models.Fields.website||wp.ccf.models.StandardField.extend({defaults:function(){var e={type:"website"};return i.defaults(e,this.constructor.__super__.defaults())}}),wp.ccf.models.Fields.phone=wp.ccf.models.Fields.phone||wp.ccf.models.StandardField.extend({defaults:function(){var e={type:"phone",phoneFormat:"us"};return i.defaults(e,this.constructor.__super__.defaults())}}),wp.ccf.models.Fields.date=wp.ccf.models.Fields.date||wp.ccf.models.StandardField.extend({defaults:function(){var e={type:"date",showDate:!0,showTime:!0};return i.defaults(e,this.constructor.__super__.defaults())}}),wp.ccf.models.Fields.name=wp.ccf.models.Fields.name||wp.ccf.models.StandardField.extend({defaults:function(){var e={type:"name"};return i.defaults(e,this.constructor.__super__.defaults())}}),wp.ccf.models.Fields.address=wp.ccf.models.Fields.address||wp.ccf.models.StandardField.extend({defaults:function(){var e={type:"address",addressType:"us"};return i.defaults(e,this.constructor.__super__.defaults())}}),wp.ccf.models.Fields["section-header"]=wp.ccf.models.Fields["section-header"]||wp.ccf.models.Field.extend({defaults:function(){var e={type:"section-header",slug:"",heading:"",subheading:"",className:""};return i.defaults(e,this.constructor.__super__.defaults)},required:function(){return[]},isImmutable:!0}),wp.ccf.models.Fields.html=wp.ccf.models.Fields.html||wp.ccf.models.Field.extend({defaults:function(){var e={type:"html",slug:"",html:"",className:""};return i.defaults(e,this.constructor.__super__.defaults)},required:function(){return[]},isImmutable:!0}),wp.ccf.models.ChoiceableField=wp.ccf.models.ChoiceableField||wp.ccf.models.StandardField.extend({defaults:function(){var e={choices:new wp.ccf.collections.FieldChoices};return i.defaults(e,this.constructor.__super__.defaults())},initialize:function(e){if("object"==typeof e&&e.choices){var t=[];i.each(e.choices,function(e){t.push(new wp.ccf.models.FieldChoice(e))}),this.set("choices",new wp.ccf.collections.FieldChoices(t))}}}),wp.ccf.models.Fields.radio=wp.ccf.models.Fields.radio||wp.ccf.models.ChoiceableField.extend({defaults:function(){var e={type:"radio"};return i.defaults(e,this.constructor.__super__.defaults())},initialize:function(){return this.constructor.__super__.initialize.apply(this,arguments)}}),wp.ccf.models.Fields.checkboxes=wp.ccf.models.Fields.checkboxes||wp.ccf.models.ChoiceableField.extend({defaults:function(){var e={type:"checkboxes"};return i.defaults(e,this.constructor.__super__.defaults())},initialize:function(){return this.constructor.__super__.initialize.apply(this,arguments)}}),wp.ccf.models.Fields.dropdown=wp.ccf.models.Fields.dropdown||wp.ccf.models.ChoiceableField.extend({defaults:function(){var e={type:"dropdown"};return i.defaults(e,this.constructor.__super__.defaults())},initialize:function(){return this.constructor.__super__.initialize.apply(this,arguments)}})}(jQuery,Backbone,_,ccfSettings,WP_API_Settings),function(e,t,i){"use strict";wp.ccf.collections=wp.ccf.collections||{},wp.ccf.collections.Forms=wp.ccf.collections.Forms||wp.api.collections.Posts.extend({model:wp.ccf.models.Form,url:WP_API_Settings.root+"/ccf/forms",formsFetching:{},initialize:function(){this.constructor.__super__.initialize(),this.formsFetching={}},remove:function(e,t){t=t||{};var l=this.constructor.__super__.remove.call(this,e,t);return t.destroy&&(e instanceof Array?i.each(e,function(e){e.destroy()}):e.destroy()),l}}),wp.ccf.collections.Fields=wp.ccf.collections.Fields||wp.api.collections.Posts.extend({model:wp.ccf.models.Field,url:function(){return WP_API_Settings.root+"/ccf/forms/"+this.formId+"/fields"},initialize:function(e,t){t&&t.formId&&(this.formId=t.formId)}}),wp.ccf.collections.Submissions=wp.ccf.collections.Submissions||wp.api.collections.Posts.extend({model:wp.ccf.models.Submission,url:function(){return WP_API_Settings.root+"/ccf/forms/"+this.formId+"/submissions"},initialize:function(e,t){this.constructor.__super__.initialize.apply(this,arguments),t&&t.formId&&(this.formId=t.formId)}}),wp.ccf.collections.FieldChoices=wp.ccf.collections.FieldChoices||t.Collection.extend({model:wp.ccf.models.FieldChoice})}(jQuery,Backbone,_,ccfSettings),function(e,t,i,l){"use strict";wp.ccf.views=wp.ccf.views||{},wp.ccf.views.Fields=wp.ccf.views.Fields||{},wp.ccf.views.FieldChoice=t.View.extend({template:i.template(document.getElementById("ccf-field-choice-template").innerHTML),className:"choice",events:{"click .add":"triggerAdd","click .delete":"triggerDelete","blur input":"saveChoice",saveChoice:"saveChoice",sorted:"triggerUpdateSort"},initialize:function(e){this.field=e.field},destroy:function(){wp.ccf.dispatcher.off("mainViewChange",this.saveChoice),this.unbind()},triggerUpdateSort:function(e,t){this.field.get("choices").remove(this.model,{silent:!0}),this.field.get("choices").add(this.model,{at:t,silent:!0})},saveChoice:function(){if(""!==this.el.innerHTML){var e=this.el.querySelectorAll(".choice-label")[0].value,t=this.el.querySelectorAll(".choice-value")[0].value;this.model.set("label",e),this.model.set("value",t);var i=this.el.querySelectorAll(".choice-selected")[0],l=i.checked?!0:!1;return this.model.set("selected",l),this}},render:function(){var e={};return this.model&&(e.choice=this.model.toJSON()),this.el.innerHTML=this.template(e),wp.ccf.dispatcher.on("mainViewChange",this.saveChoice,this),this},triggerAdd:function(){this.field.get("choices").add(new wp.ccf.models.FieldChoice)},triggerDelete:function(){var e=this.field.get("choices");if(e.length>1)e.remove(this.model),this.destroy(),this.remove();else{for(var t=this.el.querySelectorAll(".choice-label, .choice-value"),i=this.el.querySelectorAll(".choice-selected"),l=0;t.length>l;l++)t[l].value="";i[0].checked=!1}}}),wp.ccf.views.FieldBase=wp.ccf.views.FieldBase||t.View.extend({events:{"blur input":"saveField","blur input.field-slug":"checkSlug","blur textarea":"saveField","change select":"saveField",'change input[type="checkbox"]':"saveField"},checkSlug:function(){var e=this.el.querySelectorAll(".field-slug");if(e.length>0){var t=e[0];t.parentNode.className=t.value&&!t.value.match(/^[a-zA-Z0-9\-_]+$/)?t.parentNode.className.replace(/ field-error/i,"")+" field-error":t.parentNode.className.replace(/ field-error/i,"")}},destroy:function(){this.unbind()},render:function(){return this.el.innerHTML=this.template({field:this.model.toJSON()}),this.checkSlug(),this}}),wp.ccf.views.Fields["single-line-text"]=wp.ccf.views.Fields["single-line-text"]||wp.ccf.views.FieldBase.extend({template:i.template(document.getElementById("ccf-single-line-text-template").innerHTML),initialize:function(){},saveField:function(){return this.model.set("slug",this.el.querySelectorAll(".field-slug")[0].value),this.model.set("label",this.el.querySelectorAll(".field-label")[0].value),this.model.set("value",this.el.querySelectorAll(".field-value")[0].value),this.model.set("placeholder",this.el.querySelectorAll(".field-placeholder")[0].value),this.model.set("className",this.el.querySelectorAll(".field-class-name")[0].value),this.model.set("required",1==this.el.querySelectorAll(".field-required")[0].value?!0:!1),this}}),wp.ccf.views.Fields["section-header"]=wp.ccf.views.Fields["section-header"]||wp.ccf.views.FieldBase.extend({template:i.template(document.getElementById("ccf-section-header-template").innerHTML),initialize:function(){},saveField:function(){return this.model.set("heading",this.el.querySelectorAll(".field-heading")[0].value),this.model.set("subheading",this.el.querySelectorAll(".field-subheading")[0].value),this.model.set("className",this.el.querySelectorAll(".field-class-name")[0].value),this}}),wp.ccf.views.Fields.html=wp.ccf.views.Fields.html||wp.ccf.views.FieldBase.extend({template:i.template(document.getElementById("ccf-html-template").innerHTML),initialize:function(){},saveField:function(){return this.model.set("html",this.el.querySelectorAll(".field-html")[0].value),this.model.set("className",this.el.querySelectorAll(".field-class-name")[0].value),this}}),wp.ccf.views.Fields["paragraph-text"]=wp.ccf.views.Fields["paragraph-text"]||wp.ccf.views.FieldBase.extend({template:i.template(document.getElementById("ccf-paragraph-text-template").innerHTML),saveField:function(){return this.model.set("slug",this.el.querySelectorAll(".field-slug")[0].value),this.model.set("label",this.el.querySelectorAll(".field-label")[0].value),this.model.set("value",this.el.querySelectorAll(".field-value")[0].value),this.model.set("placeholder",this.el.querySelectorAll(".field-placeholder")[0].value),this.model.set("className",this.el.querySelectorAll(".field-class-name")[0].value),this.model.set("required",1==this.el.querySelectorAll(".field-required")[0].value?!0:!1),this}}),wp.ccf.views.Fields.hidden=wp.ccf.views.Fields.hidden||wp.ccf.views.FieldBase.extend({template:i.template(document.getElementById("ccf-hidden-template").innerHTML),saveField:function(){return this.model.set("slug",this.el.querySelectorAll(".field-slug")[0].value),this.model.set("value",this.el.querySelectorAll(".field-value")[0].value),this.model.set("className",this.el.querySelectorAll(".field-class-name")[0].value),this}}),wp.ccf.views.Fields.date=wp.ccf.views.Fields.date||wp.ccf.views.FieldBase.extend({template:i.template(document.getElementById("ccf-date-template").innerHTML),saveField:function(){this.model.set("slug",this.el.querySelectorAll(".field-slug")[0].value),this.model.set("label",this.el.querySelectorAll(".field-label")[0].value);var e=this.el.querySelectorAll(".field-value");e.length>0&&this.model.set("value",e[0].value),this.model.set("className",this.el.querySelectorAll(".field-class-name")[0].value),this.model.set("showDate",this.el.querySelectorAll(".field-show-date")[0].checked?!0:!1);var t=this.model.get("showTime"),i=this.el.querySelectorAll(".field-show-time")[0].checked?!0:!1;return this.model.set("showTime",i),this.model.set("required",1==this.el.querySelectorAll(".field-required")[0].value?!0:!1),i!=t&&this.render(),this}}),wp.ccf.views.Fields.name=wp.ccf.views.Fields.name||wp.ccf.views.FieldBase.extend({template:i.template(document.getElementById("ccf-name-template").innerHTML),saveField:function(){return this.model.set("slug",this.el.querySelectorAll(".field-slug")[0].value),this.model.set("label",this.el.querySelectorAll(".field-label")[0].value),this.model.set("className",this.el.querySelectorAll(".field-class-name")[0].value),this.model.set("required",1==this.el.querySelectorAll(".field-required")[0].value?!0:!1),this}}),wp.ccf.views.Fields.website=wp.ccf.views.Fields.website||wp.ccf.views.FieldBase.extend({template:i.template(document.getElementById("ccf-website-template").innerHTML),saveField:function(){return this.model.set("slug",this.el.querySelectorAll(".field-slug")[0].value),this.model.set("label",this.el.querySelectorAll(".field-label")[0].value),this.model.set("value",this.el.querySelectorAll(".field-value")[0].value),this.model.set("placeholder",this.el.querySelectorAll(".field-placeholder")[0].value),this.model.set("className",this.el.querySelectorAll(".field-class-name")[0].value),this.model.set("required",1==this.el.querySelectorAll(".field-required")[0].value?!0:!1),this}}),wp.ccf.views.Fields.phone=wp.ccf.views.Fields.phone||wp.ccf.views.FieldBase.extend({template:i.template(document.getElementById("ccf-phone-template").innerHTML),saveField:function(){return this.model.set("slug",this.el.querySelectorAll(".field-slug")[0].value),this.model.set("label",this.el.querySelectorAll(".field-label")[0].value),this.model.set("value",this.el.querySelectorAll(".field-value")[0].value),this.model.set("placeholder",this.el.querySelectorAll(".field-placeholder")[0].value),this.model.set("phoneFormat",this.el.querySelectorAll(".field-phone-format")[0].value),this.model.set("className",this.el.querySelectorAll(".field-class-name")[0].value),this.model.set("required",1==this.el.querySelectorAll(".field-required")[0].value?!0:!1),this}}),wp.ccf.views.Fields.address=wp.ccf.views.Fields.address||wp.ccf.views.FieldBase.extend({template:i.template(document.getElementById("ccf-address-template").innerHTML),saveField:function(){return this.model.set("slug",this.el.querySelectorAll(".field-slug")[0].value),this.model.set("label",this.el.querySelectorAll(".field-label")[0].value),this.model.set("addressType",this.el.querySelectorAll(".field-address-type")[0].value),this.model.set("className",this.el.querySelectorAll(".field-class-name")[0].value),this.model.set("required",1==this.el.querySelectorAll(".field-required")[0].value?!0:!1),this}}),wp.ccf.views.Fields.email=wp.ccf.views.Fields.email||wp.ccf.views.FieldBase.extend({template:i.template(document.getElementById("ccf-email-template").innerHTML),saveField:function(){this.model.set("slug",this.el.querySelectorAll(".field-slug")[0].value),this.model.set("label",this.el.querySelectorAll(".field-label")[0].value);var e=this.el.querySelectorAll(".field-value");e.length&&this.model.set("value",e[0].value);var t=this.el.querySelectorAll(".field-placeholder");t.length&&this.model.set("placeholder",t[0].value),this.model.set("className",this.el.querySelectorAll(".field-class-name")[0].value),this.model.set("required",1==this.el.querySelectorAll(".field-required")[0].value?!0:!1);var i=1==this.el.querySelectorAll(".field-email-confirmation")[0].value?!0:!1,l=this.model.get("emailConfirmation");return this.model.set("emailConfirmation",i),l!=i&&this.render(),this}}),wp.ccf.views.ChoiceableField=wp.ccf.views.ChoiceableField||wp.ccf.views.FieldBase.extend({template:i.template(document.getElementById("ccf-dropdown-template").innerHTML),initialize:function(){var e=this.model.get("choices");this.listenTo(e,"add",this.addChoice)},addChoice:function(e){var t=new wp.ccf.views.FieldChoice({model:e,field:this.model}).render(),i=this.el.querySelectorAll(".repeatable-choices")[0];i.appendChild(t.el)},saveField:function(){this.model.set("slug",this.el.querySelectorAll(".field-slug")[0].value),this.model.set("label",this.el.querySelectorAll(".field-label")[0].value),this.model.set("className",this.el.querySelectorAll(".field-class-name")[0].value),this.model.set("required",1==this.el.querySelectorAll(".field-required")[0].value?!0:!1);var t=this.el.querySelectorAll(".repeatable-choices")[0].querySelectorAll(".choice");return i.each(t,function(t){e(t).trigger("saveChoice")}),this},render:function(){var t=this;t.el.innerHTML=t.template({field:t.model.toJSON()});var i=t.model.get("choices"),l=this.el.querySelectorAll(".repeatable-choices")[0];if(i.length>=1)i.each(function(e){var i=new wp.ccf.views.FieldChoice({model:e,field:t.model}).render();l.appendChild(i.el)});else{var s=new wp.ccf.models.FieldChoice;i.add(s)}return l=this.el.querySelectorAll(".repeatable-choices")[0],e(l).sortable({handle:".move",axis:"y",stop:function(e,t){t.item.trigger("sorted",t.item.index())}}),t}}),wp.ccf.views.Fields.dropdown=wp.ccf.views.Fields.dropdown||wp.ccf.views.ChoiceableField.extend({template:i.template(document.getElementById("ccf-dropdown-template").innerHTML),events:function(){return this.constructor.__super__.events}}),wp.ccf.views.Fields.radio=wp.ccf.views.Fields.radio||wp.ccf.views.ChoiceableField.extend({template:i.template(document.getElementById("ccf-radio-template").innerHTML),events:function(){return this.constructor.__super__.events}}),wp.ccf.views.Fields.checkboxes=wp.ccf.views.Fields.checkboxes||wp.ccf.views.ChoiceableField.extend({template:i.template(document.getElementById("ccf-checkboxes-template").innerHTML),events:function(){return this.constructor.__super__.events}}),wp.ccf.views.FieldSidebar=wp.ccf.views.FieldSidebar||t.View.extend({initialize:function(e){this.currentFieldView=null,this.form=e.form},save:function(e){this.currentFieldView&&""!==this.currentFieldView.el.innerHTML&&this.currentFieldView.saveField(),e&&e instanceof Object&&e.resolve()},fieldRemoved:function(){this.currentFieldView&&(this.form.get("fields").get(this.currentFieldView.model)||this.render())},destroy:function(){wp.ccf.dispatcher.off("saveField",this.save),wp.ccf.dispatcher.off("mainViewChange",this.save),this.unbind()},render:function(e){var t={};if(e){var l=e.get("type");this.currentFieldView&&(this.currentFieldView.saveField(),this.currentFieldView.destroy&&this.currentFieldView.destroy()),this.currentFieldView=new wp.ccf.views.Fields[l]({model:e}),this.currentFieldView.render(),this.el.innerHTML="",this.el.appendChild(this.currentFieldView.el);var s=this.form.get("fields");this.listenTo(s,"remove",this.fieldRemoved)}else{var c=i.template(document.getElementById("ccf-empty-field-template").innerHTML);this.el.innerHTML=c(t)}return wp.ccf.dispatcher.on("saveField",this.save,this),wp.ccf.dispatcher.on("mainViewChange",this.save,this),this}}),wp.ccf.views.FieldRowPlaceholder=wp.ccf.views.FieldRowPlaceholder||t.View.extend({template:i.template(document.getElementById("ccf-field-row-template").innerHTML),tagName:"div",className:"field",initialize:function(e){this.type=e.type},render:function(){return this.el.innerHTML=this.template({label:l.allLabels[this.type]}),this.el.setAttribute("data-field-type",this.type),this.el.className+=" "+this.type,this}}),wp.ccf.views.FieldRow=wp.ccf.views.FieldRow||t.View.extend({template:i.template(document.getElementById("ccf-field-row-template").innerHTML),tagName:"div",className:"field",events:{"click .delete":"triggerDelete","click h4":"triggerEdit",sorted:"triggerUpdateSort"},initialize:function(e){i.bindAll(this,"triggerDelete"),this.form=e.form,this.listenTo(this.model,"change",this.handleChange,this),this.listenTo(this.model,"requirementsNotMet",this.requirementsNotMet,this),this.listenTo(this.model,"requirementsMet",this.requirementsMet,this),this.listenTo(this.model,"duplicateSlug",this.duplicateSlug,this),this.model.attributes.choices&&this.listenTo(this.model.attributes.choices,"change",this.handleChange,this)},duplicateSlug:function(){this.requirementsMet(),this.el.className+=" field-duplicate-slug"},requirementsNotMet:function(){this.requirementsMet(),this.el.className+=" field-incomplete"},requirementsMet:function(){this.el.className=this.el.className.replace(/(field-incomplete|field-duplicate-slug)/i,"")},triggerUpdateSort:function(e,t){this.form.get("fields").remove(this.model),this.form.get("fields").add(this.model,{at:t})},handleChange:function(){this.render()},triggerDelete:function(e){e.stopPropagation(),this.form.get("fields").remove(this.model),this.undelegateEvents(),this.remove()},triggerEdit:function(){var e=this.el.parentNode.querySelectorAll(".ccf-editing");i.each(e,function(e){e.className=e.className.replace(/ccf-editing/i,"")}),this.el.className=this.el.className.replace(/ccf-editing/i,"")+" ccf-editing",wp.ccf.dispatcher.trigger("openEditField",this.model)},render:function(e){this.el.innerHTML=this.template({label:l.allLabels[this.model.get("type")]}),this.el.setAttribute("data-field-type",this.model.get("type"));var t=RegExp(" "+this.model.get("type"),"i");this.el.className=this.el.className.replace(t,"")+" "+this.model.get("type"),e&&(this.el.className=this.el.className.replace(/ instantiated/i,"")+" instantiated");var s=document.getElementById("ccf-"+this.model.get("type")+"-preview-template");if(s){var c=this.el.querySelectorAll(".preview")[0];c.style.display="block",c.innerHTML=i.template(s.innerHTML)({field:this.model.toJSON()})}return this}}),wp.ccf.views.FormSettings=wp.ccf.views.FormSettings||t.View.extend({template:i.template(document.getElementById("ccf-form-settings-template").innerHTML),events:{"blur input":"save","change select":"save","change select.form-completion-action-type":"toggleCompletionFields","change select.form-send-email-notifications":"toggleNotificationFields"},initialize:function(e){this.model=e.form},destroy:function(){wp.ccf.dispatcher.off("saveFormSettings",this.save),wp.ccf.dispatcher.off("mainViewChange",this.save)},toggleCompletionFields:function(){var e=this.el.querySelectorAll(".form-completion-action-type")[0].value,t=this.el.querySelectorAll(".completion-message")[0],i=this.el.querySelectorAll(".completion-redirect-url")[0];"text"===e?(t.style.display="block",i.style.display="none"):(t.style.display="none",i.style.display="block")},toggleNotificationFields:function(){var e=this.el.querySelectorAll(".form-send-email-notifications")[0].value,t=this.el.querySelectorAll(".email-notification-addresses")[0];t.style.display=parseInt(e)?"block":"none"},save:function(e){if(""!==this.el.innerHTML){var t=this.el.querySelectorAll(".form-title")[0].value;this.model.set("title",t);var i=this.el.querySelectorAll(".form-description")[0].value;this.model.set("description",i);var l=this.el.querySelectorAll(".form-button-text")[0].value;this.model.set("buttonText",l);var s=this.el.querySelectorAll(".form-completion-message")[0].value;this.model.set("completionMessage",s);var c=this.el.querySelectorAll(".form-completion-redirect-url")[0].value;this.model.set("completionRedirectUrl",c);var n=this.el.querySelectorAll(".form-completion-action-type")[0].value;this.model.set("completionActionType",n);var r=this.el.querySelectorAll(".form-send-email-notifications")[0].value;this.model.set("sendEmailNotifications",parseInt(r)?!0:!1);var o=this.el.querySelectorAll(".form-email-notification-addresses")[0].value;this.model.set("emailNotificationAddresses",o),e!==void 0&&e.promise!==void 0&&e.resolve()}},render:function(){var e={form:this.model.toJSON()};return this.el.innerHTML=this.template(e),this.toggleCompletionFields(),this.toggleNotificationFields(),wp.ccf.dispatcher.on("saveFormSettings",this.save,this),wp.ccf.dispatcher.on("mainViewChange",this.save,this),this}}),wp.ccf.views.FormPane=wp.ccf.views.FormPane||t.View.extend(i.defaults({template:i.template(document.getElementById("ccf-form-pane-template").innerHTML),subViews:{"field-sidebar":wp.ccf.views.FieldSidebar,"form-settings":wp.ccf.views.FormSettings},events:{"click .save-button":"sync","click h2":"accordionClick","click .insert-form-button":"insertForm"},initialize:function(){wp.ccf.dispatcher.on("openEditField",this.openEditField,this)},insertForm:function(){wp.ccf.utils.insertFormShortcode(this.model),wp.ccf.toggle()},accordionClick:function(t){var l=e(t.currentTarget).parents(".accordion-container")[0],s=l.querySelectorAll(".accordion-section");t.currentTarget.parentNode.className.match(/expanded/i)?t.currentTarget.parentNode.className=t.currentTarget.parentNode.className.replace(/expanded/i,""):t.currentTarget.parentNode.className+=" expanded",i.each(s,function(e){e!=t.currentTarget.parentNode&&e.className.match(/expanded/i)&&(e.className=e.className.replace(/expanded/i,""))})},openEditField:function(e){this.renderedSubViews["field-sidebar"].render(e).el.style.display="block"},disable:function(){this.el.querySelectorAll(".save-button")[0].setAttribute("disabled","disabled"),this.el.querySelectorAll(".disabled-overlay")[0].style.display="block"},enable:function(){this.el.querySelectorAll(".save-button")[0].removeAttribute("disabled"),this.el.querySelectorAll(".disabled-overlay")[0].style.display="none"},sync:function(){var t=this,i=e(this.el.querySelectorAll(".spinner")[0]);i.fadeIn(),t.disable();var s=e.Deferred(),c=e.Deferred();wp.ccf.dispatcher.trigger("saveFormSettings",s),wp.ccf.dispatcher.trigger("saveField",c),e.when(s,c).then(function(){var e=t.model.get("fields"),s=!0,c={};e.each(function(e){var t=e.get("slug");e.hasRequiredAttributes()?t&&!t.match(/^[a-zA-Z0-9\-_]+$/)?(s=!1,e.trigger("requirementsNotMet")):c[e.get("slug")]!==void 0?(s=!1,e.trigger("duplicateSlug"),c[e.get("slug")].trigger("duplicateSlug")):e.trigger("requirementsMet"):(s=!1,e.trigger("requirementsNotMet")),e.get("slug")&&(c[e.get("slug")]=e)}),s?t.model.save({},{context:"edit"}).done(function(){l.single&&!l.postId&&(window.location=l.adminUrl+"post.php?post="+t.model.get("ID")+"&action=edit#ccf-form/"+t.model.get("ID"))}).complete(function(){i.fadeOut(),t.enable(),wp.ccf.dispatcher.trigger("saveFormComplete",t.model)}):(t.enable(),i.fadeOut())})},enableDisableInsert:function(){var e=this.el.querySelectorAll(".insert-form-button")[0];this.model.get("ID")?e.removeAttribute("disabled"):e.setAttribute("disabled","disabled")},render:function(t){var s=this;s.model=t?t:new wp.ccf.models.Form,this.listenTo(s.model,"change",this.enableDisableInsert,this);var c={labels:l.fieldLabels,form:s.model.toJSON()};window.form=s.model,s.el.innerHTML=this.template(c);var n=s.el.querySelectorAll(".fields")[0];i.each(l.fieldLabels,function(e,t){n.appendChild(new wp.ccf.views.FieldRowPlaceholder({type:t}).render().el)});var r=s.el.querySelectorAll(".structure-fields")[0];i.each(l.structureFieldLabels,function(e,t){r.appendChild(new wp.ccf.views.FieldRowPlaceholder({type:t}).render().el)});var o=s.el.querySelectorAll(".special-fields")[0];i.each(l.specialFieldLabels,function(e,t){o.appendChild(new wp.ccf.views.FieldRowPlaceholder({type:t}).render().el)}),e(s.el.querySelectorAll(".left-sidebar")[0].querySelectorAll(".field")).draggable({cursor:"move",zIndex:160001,scroll:!1,containment:".ccf-form-pane",appendTo:".ccf-main-modal",snap:!0,connectToSortable:".form-content",helper:function(t){var i=e(t.currentTarget),l=e('<div class="field" data-field-type="'+i.attr("data-field-type")+'"><h4>'+i.find(".label").html()+"</h4></div>");return l.css({width:i.width(),height:i.height()})}});var a=s.model.get("fields"),d=s.el.querySelectorAll(".form-content")[0];return a.length>=1&&(d.innerHTML="",a.each(function(e){var t=new wp.ccf.views.FieldRow({model:e,form:s.model}).render(!0).el;d.appendChild(t)})),e(d).sortable({axis:"y",handle:"h4",stop:function(e,t){if(!t.item.hasClass("instantiated")){var i=t.item.attr("data-field-type"),l={};if(wp.ccf.models.Fields[i].prototype.defaults().slug!==void 0){var c=s.model.get("fields").where({type:i}).length+1;l.slug=i+"-"+c}var n=new wp.ccf.models.Fields[i](l),r=s.model.get("fields");r.add(n),new wp.ccf.views.FieldRow({model:n,el:t.item,form:s.model}).render(!0),t.item.attr("style","")}t.item.trigger("sorted",t.item.index())}}),s.initRenderSubViews(!0,!0,{form:s.model}),s.enableDisableInsert(),s
2
- }},wp.ccf.mixins.subViewable)),wp.ccf.views.ExistingFormTableRow=wp.ccf.views.ExistingFormTableRow||t.View.extend({tagName:"tr",template:i.template(document.getElementById("ccf-existing-form-table-row-template").innerHTML),events:{"click .edit":"triggerMainViewChange","click .delete":"triggerDelete","click .insert-form-button":"insertForm"},initialize:function(e){this.parent=e.parent},insertForm:function(){wp.ccf.utils.insertFormShortcode(this.model),wp.ccf.toggle()},triggerMainViewChange:function(){wp.ccf.switchToForm(this.model)},triggerDelete:function(){var e,t=this,i=t.parent.collection.state.currentPage;t.model.destroy().done(function(){e=i,e===t.parent.collection.state.totalPages&&e-1===(t.parent.collection.state.totalObjects-1)/l.postsPerPage&&e--,t.parent.showPage(e).done(function(){t.parent.renderPagination()})})},render:function(){return this.$el.html(this.template({form:this.model.toJSON(),utils:{getPrettyPostDate:wp.ccf.utils.getPrettyPostDate}})),this}}),wp.ccf.views.EmptyFormTableRow=wp.ccf.views.EmptyFormTableRow||t.View.extend({tagName:"tr",template:i.template(document.getElementById("ccf-empty-form-table-row-template").innerHTML),render:function(){return this.$el.html(this.template()),this}}),wp.ccf.views.ExistingFormTable=wp.ccf.views.ExistingFormTable||t.View.extend({template:i.template(document.getElementById("ccf-existing-form-table-template").innerHTML),initialize:function(){this.parent=arguments.parent,this.collection=new wp.ccf.collections.Forms,wp.ccf.dispatcher.on("changeFormTablePage",this.showPage,this),wp.ccf.dispatcher.on("saveFormComplete",this.render,this)},showPage:function(e){var t=this,i=this.collection.fetch({data:{page:e}});return i.done(function(){var e=t.el.querySelectorAll(".rows")[0],i=document.createElement("tbody");i.className="rows",t.collection.length>=1?t.collection.each(function(e){var l=new wp.ccf.views.ExistingFormTableRow({model:e,parent:t}).render();i.appendChild(l.el)},t):i.appendChild((new wp.ccf.views.EmptyFormTableRow).render().el),e.parentNode.replaceChild(i,e)}),i},renderPagination:function(){var e=this.el.querySelectorAll(".ccf-pagination")[0];e.innerHTML="",this.collection.state.totalPages>1&&e.appendChild(new wp.ccf.views.Pagination({parent:this}).render(this.collection.state.totalPages,this.collection.state.currentPage).el)},render:function(){var e=this;return this.el.innerHTML=this.template(),this.el.querySelectorAll(".ccf-pagination")[0],this.showPage(1).done(function(){e.renderPagination()}),this}}),wp.ccf.views.ExistingFormPane=wp.ccf.views.ExistingFormPane||t.View.extend(i.defaults({template:i.template(document.getElementById("ccf-existing-form-pane-template").innerHTML),subViews:{"existing-form-table":wp.ccf.views.ExistingFormTable},render:function(){return this.rendered?this:(this.rendered=!0,this.el.innerHTML=this.template(),this.initRenderSubViews(!0),this)}},wp.ccf.mixins.subViewable)),wp.ccf.views.MainModal=wp.ccf.views.MainModal||t.View.extend(i.defaults({tagName:"div",className:"ccf-main-modal",template:i.template(document.getElementById("ccf-main-modal-template").innerHTML),events:{"click .close-icon":"hide","click .main-menu a":"menuClick"},subViews:{"form-pane":wp.ccf.views.FormPane},initialize:function(){l.single||(this.subViews["existing-form-pane"]=wp.ccf.views.ExistingFormPane),wp.ccf.dispatcher.on("mainViewChange",this.toggleView,this)},toggleView:function(e){this.showView(e,wp.ccf.currentForm);var t=e;"form-pane"===e&&wp.ccf.currentForm&&(t="existing-form-pane");var l=this.el.querySelectorAll(".menu-item");i.each(l,function(e){var i=e.getAttribute("data-view");e.className=i===t?e.className.replace("selected","")+" selected":e.className.replace("selected","")})},menuClick:function(e){var t=e.target.getAttribute("data-view");"form-pane"===t&&(wp.ccf.currentForm=null),wp.ccf.dispatcher.trigger("mainViewChange",t),e.preventDefault()},render:function(e){return e=e||!1,this.overlay(),this.el.innerHTML=this.template({single:e}),this.initRenderSubViews(),this.showView("form-pane",wp.ccf.currentForm,!0),this},overlay:function(){return this.overlayEl===void 0&&(this.overlayEl=document.createElement("div"),this.overlayEl.className="ccf-main-modal-overlay",document.body.appendChild(this.overlayEl)),this.overlayEl},remove:function(){return document.body.removeChild(this.overlay()),this},show:function(){e(this.overlay()).show(),this.$el.show()},hide:function(){e(this.overlay()).hide(),this.$el.hide()}},wp.ccf.mixins.subViewable)),wp.ccf.views.SubmissionRow=wp.ccf.views.SubmissionRow||t.View.extend({tagName:"tr",template:i.template(document.getElementById("ccf-submission-row-template").innerHTML),events:{"click .view":"view","click .delete":"delete"},initialize:function(e){this.parent=e.parent},"delete":function(){var e,t=this,i=t.parent.collection.state.currentPage;t.model.destroy().done(function(){e=i,e===t.parent.collection.state.totalPages&&e-1===(t.parent.collection.state.totalObjects-1)/l.postsPerPage&&e--,t.parent.showPage(e).done(function(){t.parent.renderPagination()})})},view:function(e){var t=e.currentTarget.getAttribute("data-submission-id"),i=e.currentTarget.getAttribute("data-submission-date");tb_show(l.thickboxTitle+" - "+wp.ccf.utils.getPrettyPostDate(i),"#TB_inline?height=500&amp;width=700&amp;inlineId=ccf-submission-content-"+parseInt(t),null)},render:function(){return this.$el.html(this.template({submission:this.model.toJSON(),currentColumns:this.parent.columns,columns:wp.ccf.currentForm.getFieldSlugs(!0),utils:{getPrettyPostDate:wp.ccf.utils.getPrettyPostDate,wordChop:wp.ccf.utils.wordChop,isFieldDate:wp.ccf.utils.isFieldDate,isFieldName:wp.ccf.utils.isFieldName,isFieldAddress:wp.ccf.utils.isFieldAddress,getPrettyFieldDate:wp.ccf.utils.getPrettyFieldDate,getPrettyFieldAddress:wp.ccf.utils.getPrettyFieldAddress,getPrettyFieldName:wp.ccf.utils.getPrettyFieldName}})),this}}),wp.ccf.views.SubmissionsTable=wp.ccf.views.SubmissionsTable||t.View.extend({template:i.template(document.getElementById("ccf-submission-table-template").innerHTML),events:{"click .prev:not(.disabled)":"previousPage","click .next:not(.disabled)":"nextPage","click .first:not(.disabled)":"firstPage","click .last:not(.disabled)":"lastPage"},initialize:function(){this.collection=new wp.ccf.collections.Submissions({},{formId:l.postId}),wp.ccf.dispatcher.on("submissionTableRebuild",this.render,this)},showPage:function(e){var t=this,i=this.collection.fetch({data:{page:e}});return i.done(function(){var e=t.el.querySelectorAll(".submission-rows")[0],i=document.createElement("tbody");i.className="submission-rows",t.collection.length>=1?t.collection.each(function(e){var l=new wp.ccf.views.SubmissionRow({model:e,parent:t}).render();i.appendChild(l.el)},t):i.appendChild(new wp.ccf.views.EmptySubmissionTableRow({parent:t}).render(wp.ccf.currentForm.getFieldSlugs(!0).concat("date")).el),e.parentNode.replaceChild(i,e)}),i},renderPagination:function(){var e=this.el.querySelectorAll(".ccf-pagination")[0];e.innerHTML="",this.collection.state.totalPages>1&&e.appendChild(new wp.ccf.views.Pagination({parent:this}).render(this.collection.state.totalPages,this.collection.state.currentPage).el)},render:function(e){var t=this;return t.columns=e?e:wp.ccf.currentForm.getFieldSlugs(!0).slice(0,4).concat("date"),1>t.columns.length?t.el.innerHTML="":(t.el.innerHTML=t.template({columns:t.columns}),t.el.querySelectorAll(".ccf-pagination")[0],t.showPage(1).done(function(){t.renderPagination()})),t}}),wp.ccf.views.Pagination=wp.ccf.views.Pagination||t.View.extend({template:i.template(document.getElementById("ccf-pagination-template").innerHTML),events:{"click .prev:not(.disabled)":"previousPage","click .next:not(.disabled)":"nextPage","click .first:not(.disabled)":"firstPage","click .last:not(.disabled)":"lastPage"},initialize:function(e){this.parent=e.parent},previousPage:function(){var e=this;e.parent.showPage(e.parent.collection.state.currentPage-1).done(function(){e.render()})},nextPage:function(){var e=this;e.parent.showPage(e.parent.collection.state.currentPage+1).done(function(){e.render()})},firstPage:function(){var e=this;e.parent.showPage(1).done(function(){e.render()})},lastPage:function(){var e=this;e.parent.showPage(e.parent.collection.state.totalPages).done(function(){e.render()})},render:function(){return this.el.innerHTML=this.template({totalPages:this.parent.collection.state.totalPages,currentPage:this.parent.collection.state.currentPage,totalObjects:this.parent.collection.state.totalObjects}),this}}),wp.ccf.views.EmptySubmissionTableRow=wp.ccf.views.EmptySubmissionTableRow||t.View.extend({tagName:"tr",template:i.template(document.getElementById("ccf-no-submissions-row-template").innerHTML),initialize:function(e){this.parent=e.parent},render:function(){return this.el.innerHTML=this.template({columns:this.parent.columns}),this}}),wp.ccf.views.SubmissionColumnController=wp.ccf.views.SubmissionColumnController||t.View.extend({template:i.template(document.getElementById("ccf-submissions-controller-template").innerHTML),events:{"click input[type=checkbox]":"triggerTableRebuild"},render:function(){this.el.innerHTML=this.template({columns:wp.ccf.currentForm.getFieldSlugs(!0).concat("date")})},triggerTableRebuild:function(){var e=[],t=document.querySelectorAll(".submission-column-checkbox");if(t.length>=1)for(var i=0;t.length>i;i++)t[i].checked&&e.push(t[i].value);wp.ccf.dispatcher.trigger("submissionTableRebuild",e)}})}(jQuery,Backbone,_,ccfSettings),function(e,t){"use strict";wp.ccf.router=wp.ccf.router||t.Router.extend({routes:{"ccf-form":"open","ccf-form/:formId":"open"},open:function(e){wp.ccf.show(e)}})}(jQuery,Backbone,_,ccfSettings),function(e,t,i,l){"use strict";wp.ccf=i.defaults(wp.ccf,{forms:new wp.ccf.collections.Forms,currentForm:null,_currentFormDeferred:null,dispatcher:{},show:function(e){return this.switchToForm(e),this.instance.show(),this.instance},switchToForm:function(e){var t=this;if(+e===parseInt(e)){var i=parseInt(e);if(e=t.forms.findWhere({ID:parseInt(i)}),!e){var l;return t.forms.formsFetching[i]!==void 0?(l=t.forms.formsFetching[i],e=null):(e=new wp.ccf.models.Form({ID:i}),l=e.fetch(),t.forms.formsFetching[i]=l),l.done(function(){e?(delete t.forms.formsFetching[i],t.forms.add(e)):e=t.forms.findWhere({ID:i}),t.currentForm=e,wp.ccf.dispatcher.trigger("mainViewChange","form-pane")}),l}t.currentForm=e,wp.ccf.dispatcher.trigger("mainViewChange","form-pane")}else t.currentForm=e,wp.ccf.dispatcher.trigger("mainViewChange","form-pane");return!0},hide:function(){return this.instance.hide(),this.instance},toggle:function(e){return this.switchToForm(e),this.instance.$el.is(":visible")?this.instance.hide():this.instance.show(),this.instance},createSubmissionsTable:function(e){var t=document.querySelectorAll(".ccf-submission-column-controller"),i=new wp.ccf.views.SubmissionsTable({el:e});i.render(),t&&new wp.ccf.views.SubmissionColumnController({el:t}).render()},_setupMainModal:function(e){return this.instance=(new wp.ccf.views.MainModal).render(e),document.getElementsByTagName("body")[0].appendChild(this.instance.el),t.history.start(),this.instance},createManager:function(){var s=this;i.extend(this.dispatcher,t.Events),new wp.ccf.router;var c=!1,n=document.querySelectorAll(".ccf-open-form-manager")[0];if(l.single)if(c=!0,l.postId){var r=parseInt(l.postId);if(s.forms.formsFetching[r]===void 0){var o=new wp.ccf.models.Form({ID:r}),a=o.fetch();s.forms.formsFetching[r]=a,s._currentFormDeferred=a,a.done(function(){delete s.forms.formsFetching[r],s.forms.add(o),s.currentForm=o})}else s._currentFormDeferred=s.forms.formsFetching[r],s._currentFormDeferred.done(function(){s.currentForm=s.forms.findWhere({ID:r})});e.when(s._currentFormDeferred).then(function(){s._setupMainModal(!0),n.style.display="inline-block";var e=document.getElementById("ccf-submissions");if(e){var t=e.querySelectorAll(".inside")[0],i=document.createElement("div");i.className="ccf-submission-settings",i.setAttribute("data-icon","");var l=document.getElementById("show-settings-link");i.onclick=function(){l.click()},e.insertBefore(i,e.firstChild.nextSibling.nextSibling),wp.ccf.createSubmissionsTable(t)}})}else s._setupMainModal(!0),n.style.display="inline-block";else s._setupMainModal();var d=function(e){e=e||window.event;var t=e.currentTarget?e.currentTarget:e.srcElement,i=t.getAttribute("data-form-id");wp.ccf.toggle(i)};n.addEventListener?n.addEventListener("click",d,!1):n.attachEvent("onclick",d)}}),wp.ccf.createManager()}(jQuery,Backbone,_,ccfSettings);
1
+ (function(e,t,i,l){"use strict";window.wp=window.wp||{},wp.ccf=wp.ccf||{},wp.ccf.utils=wp.ccf.utils||{},wp.ccf.utils.cleanDateFields=function(e){delete e.date,delete e.date_gmt,delete e.modified,delete e.modified_gmt,delete e.date_tz,delete e.modified_tz},wp.ccf.utils.insertFormShortcode=function(e){var t=wp.ccf.forms.findWhere({ID:e.get("ID")});t||wp.ccf.forms.add(e);var i=tinymce.get(wpActiveEditor),l='[ccf_form id="'+e.get("ID")+'"]';i&&!i.isHidden()?tinymce.activeEditor.execCommand("mceInsertContent",!1,l):document.getElementById(wpActiveEditor).value+=l},wp.ccf.utils.getPrettyPostDate=function(e){return e=moment(e),e.format("h:mm a M/D/YYYY")},wp.ccf.utils.wordChop=function(e,t){var i=e.substr(0,t);return i.substr(0,Math.min(i.length,i.lastIndexOf(" "))),i.length<e.length&&(i+="..."),i},wp.ccf.utils.isFieldDate=function(e){return e.date!==void 0||e.hour!==void 0&&e.minute!==void 0&&e["am-pm"]!==void 0?!0:!1},wp.ccf.utils.isFieldName=function(e){return e.name!==void 0||e.last!==void 0?!0:!1},wp.ccf.utils.isFieldAddress=function(e){return e.street!==void 0&&e.city!==void 0&&e.zipcode!==void 0&&e.line_two!==void 0?!0:!1},wp.ccf.utils.getPrettyFieldDate=function(e){var t="",i="";if(e.hour&&e.minute&&e["am-pm"]&&(t+=e.hour+":"+e.minute+" "+e["am-pm"]),e.date&&(t+=" "+e.date),!t)return"-";var s=moment(t);return s.isValid()?(e.hour&&e.minute&&e["am-pm"]&&(i+=s.format("h:mm a")),e.date&&(i&&(i+=" "),i+=s.format("M/D/YYYY")),i):l.invalidDate},wp.ccf.utils.getPrettyFieldName=function(e){var t=e.first;return t.length>0&&(t+=" "),e.last&&(t+=e.last),t||(t="-"),t},wp.ccf.utils.getPrettyFieldAddress=function(e){if(!e.street||!e.city)return"-";var t=e.street;return e.line_two&&(t+=" "+e.line_two),t+=", "+e.city,e.state&&(t+=", "+e.state),e.zipcode&&(t+=" "+e.zipcode),e.country&&(t+=" "+e.country),t}})(jQuery,Backbone,_,ccfSettings),function(e,t,i){"use strict";wp.ccf.mixins=wp.ccf.mixins||{},wp.ccf.mixins.subViewable=wp.ccf.mixins.subViewable||{subViews:{},initRenderSubViews:function(e,t,l){this.renderedSubViews||(this.renderedSubViews={});for(var s in this.subViews){var c={el:this.$el.find(".ccf-"+s),parent:this};l&&i.extend(c,l),this.renderedSubViews[s]&&this.renderedSubViews[s].destroy&&this.renderedSubViews[s].destroy(),(t||!this.renderedSubViews[s])&&(this.renderedSubViews[s]=new this.subViews[s](c)),this.renderedSubViews[s].render(),e&&(this.renderedSubViews[s].el.style.display="block")}return this},showView:function(e,t,i){if(this.renderedSubViews!==void 0&&this.renderedSubViews[e]!==void 0){var l=this.renderedSubViews[e];i||l.render(t),l.el.style.display="block",this.currentView=e;for(var s in this.subViews)s!==e&&(this.renderedSubViews[s].el.style.display="none")}}}}(jQuery,Backbone,_,ccfSettings),function(e,t,i,l,s){"use strict";wp.ccf.models=wp.ccf.models||{},wp.ccf.models.Fields=wp.ccf.models.Fields||{};var c=function(e,i,l){return"object"!=typeof i&&""===i&&(i=""),t.Model.prototype.set.call(this,e,i,l)},n=function(e){for(var t in this.attributes)if(-1===e.indexOf(t)){var i=this.get(t);"string"==typeof i&&""!==i&&(i=(i+"").replace(/&amp;/g,"&").replace(/&lt;/g,"<").replace(/&gt;/g,">").replace(/&quot;/g,'"').replace(/&#8220;/g,"”").replace(/&#8221;/g,"”").replace(/&#8216;/g,"‘").replace(/&#039;/g,"'"),this.set(t,i))}return this};wp.ccf.models.FieldChoice=wp.ccf.models.FieldChoice||t.Model.extend({defaults:{label:"",value:"",selected:!1},decode:function(){return n.call(this,[])},set:c}),wp.ccf.models.Form=wp.ccf.models.Form||wp.api.models.Post.extend({urlRoot:s.root+"/ccf/forms",set:c,initialize:function(){this.on("sync",this.decode,this)},defaults:function(){var e={fields:new wp.ccf.collections.Fields,type:"ccf_form",status:"publish",description:"",buttonText:"Submit Form",completionActionType:"text",completionRedirectUrl:"",completionMessage:"",sendEmailNotifications:!1,emailNotificationAddresses:l.adminEmail};return e=i.defaults(e,this.constructor.__super__.defaults),wp.ccf.utils.cleanDateFields(e),e},decode:function(){var e=i.keys(wp.api.models.Post.prototype.defaults);return e=i.without(e,"title"),n.call(this,e)},getFieldSlugs:function(e){var t=wp.ccf.currentForm.get("fields"),i=[];return t.each(function(t){e&&t.isImmutable||i.push(t.get("slug"))}),i},parse:function(e){var t=this;if(e.fields){var l=t.get("fields");if(l&&l.length>0){for(var s=0;e.fields.length>s;s++){var c=e.fields[s],n=l.findWhere({slug:c.slug});if(n){if(c.choices!==void 0){var r=t.get("choices");if(r&&r.length>0)for(var o=0;c.choices>o;o++){var a=r.at(o);a.set(c.choices[o]),a.decode()}delete e.fields[s].choices}n.set(c),n.decode()}}delete e.fields}else{var d=[];i.each(e.fields,function(e){var t=new wp.ccf.models.Fields[e.type](e);t.decode(),d.push(t)}),e.fields=new wp.ccf.collections.Fields(d,{formId:e.ID})}}return this.constructor.__super__.parse.call(this,e)},toJSON:function(){var e=this.constructor.__super__.toJSON.call(this);return e.fields&&(e.fields=e.fields.toJSON()),e.author&&(e.author=e.author.toJSON()),e}}),wp.ccf.models.Submission=wp.api.models.Submission||wp.api.models.Post.extend({idAttribute:"ID",defaults:{ID:null,data:{}}}),wp.ccf.models.Field=wp.api.models.Field||wp.api.models.Post.extend({idAttribute:"ID",defaults:{ID:null},set:c,required:function(){return["slug"]},decode:function(){return n.call(this,i.keys(wp.api.models.Post.prototype.defaults))},hasRequiredAttributes:function(){var e=this,t=!0;return i.each(this.required(),function(i){(e.get(i)===void 0||""===e.get(i))&&(t=!1)}),t}}),wp.ccf.models.StandardField=wp.ccf.models.StandardField||wp.ccf.models.Field.extend({idAttribute:"ID",defaults:function(){var e={label:"Field Label",value:"",placeholder:"",slug:"",type:"",required:!1,className:""};return i.defaults(e,this.constructor.__super__.defaults)}}),wp.ccf.models.Fields["single-line-text"]=wp.ccf.models.Fields["single-line-text"]||wp.ccf.models.StandardField.extend({defaults:function(){var e={type:"single-line-text"};return i.defaults(e,this.constructor.__super__.defaults())}}),wp.ccf.models.Fields["paragraph-text"]=wp.ccf.models.Fields["paragraph-text"]||wp.ccf.models.StandardField.extend({defaults:function(){var e={type:"paragraph-text"};return i.defaults(e,this.constructor.__super__.defaults())}}),wp.ccf.models.Fields.hidden=wp.ccf.models.Fields.hidden||wp.ccf.models.StandardField.extend({defaults:function(){var e={type:"hidden"};return i.defaults(e,this.constructor.__super__.defaults())}}),wp.ccf.models.Fields.email=wp.ccf.models.Fields.email||wp.ccf.models.StandardField.extend({defaults:function(){var e={type:"email",emailConfirmation:!1};return i.defaults(e,this.constructor.__super__.defaults())}}),wp.ccf.models.Fields.website=wp.ccf.models.Fields.website||wp.ccf.models.StandardField.extend({defaults:function(){var e={type:"website"};return i.defaults(e,this.constructor.__super__.defaults())}}),wp.ccf.models.Fields.phone=wp.ccf.models.Fields.phone||wp.ccf.models.StandardField.extend({defaults:function(){var e={type:"phone",phoneFormat:"us"};return i.defaults(e,this.constructor.__super__.defaults())}}),wp.ccf.models.Fields.date=wp.ccf.models.Fields.date||wp.ccf.models.StandardField.extend({defaults:function(){var e={type:"date",showDate:!0,showTime:!0};return i.defaults(e,this.constructor.__super__.defaults())}}),wp.ccf.models.Fields.name=wp.ccf.models.Fields.name||wp.ccf.models.StandardField.extend({defaults:function(){var e={type:"name"};return i.defaults(e,this.constructor.__super__.defaults())}}),wp.ccf.models.Fields.address=wp.ccf.models.Fields.address||wp.ccf.models.StandardField.extend({defaults:function(){var e={type:"address",addressType:"us"};return i.defaults(e,this.constructor.__super__.defaults())}}),wp.ccf.models.Fields["section-header"]=wp.ccf.models.Fields["section-header"]||wp.ccf.models.Field.extend({defaults:function(){var e={type:"section-header",slug:"",heading:"",subheading:"",className:""};return i.defaults(e,this.constructor.__super__.defaults)},required:function(){return[]},isImmutable:!0}),wp.ccf.models.Fields.html=wp.ccf.models.Fields.html||wp.ccf.models.Field.extend({defaults:function(){var e={type:"html",slug:"",html:"",className:""};return i.defaults(e,this.constructor.__super__.defaults)},required:function(){return[]},isImmutable:!0}),wp.ccf.models.ChoiceableField=wp.ccf.models.ChoiceableField||wp.ccf.models.StandardField.extend({defaults:function(){var e={choices:new wp.ccf.collections.FieldChoices};return i.defaults(e,this.constructor.__super__.defaults())},initialize:function(e){if("object"==typeof e&&e.choices){var t=[];i.each(e.choices,function(e){var i=new wp.ccf.models.FieldChoice(e);i.decode(),t.push(i)}),this.set("choices",new wp.ccf.collections.FieldChoices(t))}}}),wp.ccf.models.Fields.radio=wp.ccf.models.Fields.radio||wp.ccf.models.ChoiceableField.extend({defaults:function(){var e={type:"radio"};return i.defaults(e,this.constructor.__super__.defaults())},initialize:function(){return this.constructor.__super__.initialize.apply(this,arguments)}}),wp.ccf.models.Fields.checkboxes=wp.ccf.models.Fields.checkboxes||wp.ccf.models.ChoiceableField.extend({defaults:function(){var e={type:"checkboxes"};return i.defaults(e,this.constructor.__super__.defaults())},initialize:function(){return this.constructor.__super__.initialize.apply(this,arguments)}}),wp.ccf.models.Fields.dropdown=wp.ccf.models.Fields.dropdown||wp.ccf.models.ChoiceableField.extend({defaults:function(){var e={type:"dropdown"};return i.defaults(e,this.constructor.__super__.defaults())},initialize:function(){return this.constructor.__super__.initialize.apply(this,arguments)}})}(jQuery,Backbone,_,ccfSettings,WP_API_Settings),function(e,t,i){"use strict";wp.ccf.collections=wp.ccf.collections||{},wp.ccf.collections.Forms=wp.ccf.collections.Forms||wp.api.collections.Posts.extend({model:wp.ccf.models.Form,url:WP_API_Settings.root+"/ccf/forms",formsFetching:{},initialize:function(){this.constructor.__super__.initialize(),this.formsFetching={}},remove:function(e,t){t=t||{};var l=this.constructor.__super__.remove.call(this,e,t);return t.destroy&&(e instanceof Array?i.each(e,function(e){e.destroy()}):e.destroy()),l}}),wp.ccf.collections.Fields=wp.ccf.collections.Fields||wp.api.collections.Posts.extend({model:wp.ccf.models.Field,url:function(){return WP_API_Settings.root+"/ccf/forms/"+this.formId+"/fields"},initialize:function(e,t){t&&t.formId&&(this.formId=t.formId)}}),wp.ccf.collections.Submissions=wp.ccf.collections.Submissions||wp.api.collections.Posts.extend({model:wp.ccf.models.Submission,url:function(){return WP_API_Settings.root+"/ccf/forms/"+this.formId+"/submissions"},initialize:function(e,t){this.constructor.__super__.initialize.apply(this,arguments),t&&t.formId&&(this.formId=t.formId)}}),wp.ccf.collections.FieldChoices=wp.ccf.collections.FieldChoices||t.Collection.extend({model:wp.ccf.models.FieldChoice})}(jQuery,Backbone,_,ccfSettings),function(e,t,i,l){"use strict";wp.ccf.views=wp.ccf.views||{},wp.ccf.views.Fields=wp.ccf.views.Fields||{},wp.ccf.views.FieldChoice=t.View.extend({template:i.template(document.getElementById("ccf-field-choice-template").innerHTML),className:"choice",events:{"click .add":"triggerAdd","click .delete":"triggerDelete","blur input":"saveChoice",saveChoice:"saveChoice",sorted:"triggerUpdateSort"},initialize:function(e){this.field=e.field},destroy:function(){wp.ccf.dispatcher.off("mainViewChange",this.saveChoice),this.unbind()},triggerUpdateSort:function(e,t){this.field.get("choices").remove(this.model,{silent:!0}),this.field.get("choices").add(this.model,{at:t,silent:!0})},saveChoice:function(){if(""!==this.el.innerHTML){var e=this.el.querySelectorAll(".choice-label")[0].value,t=this.el.querySelectorAll(".choice-value")[0].value;this.model.set("label",e),this.model.set("value",t);var i=this.el.querySelectorAll(".choice-selected")[0],l=i.checked?!0:!1;return this.model.set("selected",l),this}},render:function(){var e={};return this.model&&(e.choice=this.model.toJSON()),this.el.innerHTML=this.template(e),wp.ccf.dispatcher.on("mainViewChange",this.saveChoice,this),this},triggerAdd:function(){this.field.get("choices").add(new wp.ccf.models.FieldChoice)},triggerDelete:function(){var e=this.field.get("choices");if(e.length>1)e.remove(this.model),this.destroy(),this.remove();else{for(var t=this.el.querySelectorAll(".choice-label, .choice-value"),i=this.el.querySelectorAll(".choice-selected"),l=0;t.length>l;l++)t[l].value="";i[0].checked=!1}}}),wp.ccf.views.FieldBase=wp.ccf.views.FieldBase||t.View.extend({events:{"blur input":"saveField","blur input.field-slug":"checkSlug","blur textarea":"saveField","change select":"saveField",'change input[type="checkbox"]':"saveField"},checkSlug:function(){var e=this.el.querySelectorAll(".field-slug");if(e.length>0){var t=e[0];t.parentNode.className=t.value&&!t.value.match(/^[a-zA-Z0-9\-_]+$/)?t.parentNode.className.replace(/ field-error/i,"")+" field-error":t.parentNode.className.replace(/ field-error/i,"")}},destroy:function(){this.unbind()},render:function(){return this.el.innerHTML=this.template({field:this.model.toJSON()}),this.checkSlug(),this}}),wp.ccf.views.Fields["single-line-text"]=wp.ccf.views.Fields["single-line-text"]||wp.ccf.views.FieldBase.extend({template:i.template(document.getElementById("ccf-single-line-text-template").innerHTML),initialize:function(){},saveField:function(){return this.model.set("slug",this.el.querySelectorAll(".field-slug")[0].value),this.model.set("label",this.el.querySelectorAll(".field-label")[0].value),this.model.set("value",this.el.querySelectorAll(".field-value")[0].value),this.model.set("placeholder",this.el.querySelectorAll(".field-placeholder")[0].value),this.model.set("className",this.el.querySelectorAll(".field-class-name")[0].value),this.model.set("required",1==this.el.querySelectorAll(".field-required")[0].value?!0:!1),this}}),wp.ccf.views.Fields["section-header"]=wp.ccf.views.Fields["section-header"]||wp.ccf.views.FieldBase.extend({template:i.template(document.getElementById("ccf-section-header-template").innerHTML),initialize:function(){},saveField:function(){return this.model.set("heading",this.el.querySelectorAll(".field-heading")[0].value),this.model.set("subheading",this.el.querySelectorAll(".field-subheading")[0].value),this.model.set("className",this.el.querySelectorAll(".field-class-name")[0].value),this}}),wp.ccf.views.Fields.html=wp.ccf.views.Fields.html||wp.ccf.views.FieldBase.extend({template:i.template(document.getElementById("ccf-html-template").innerHTML),initialize:function(){},saveField:function(){return this.model.set("html",this.el.querySelectorAll(".field-html")[0].value),this.model.set("className",this.el.querySelectorAll(".field-class-name")[0].value),this}}),wp.ccf.views.Fields["paragraph-text"]=wp.ccf.views.Fields["paragraph-text"]||wp.ccf.views.FieldBase.extend({template:i.template(document.getElementById("ccf-paragraph-text-template").innerHTML),saveField:function(){return this.model.set("slug",this.el.querySelectorAll(".field-slug")[0].value),this.model.set("label",this.el.querySelectorAll(".field-label")[0].value),this.model.set("value",this.el.querySelectorAll(".field-value")[0].value),this.model.set("placeholder",this.el.querySelectorAll(".field-placeholder")[0].value),this.model.set("className",this.el.querySelectorAll(".field-class-name")[0].value),this.model.set("required",1==this.el.querySelectorAll(".field-required")[0].value?!0:!1),this}}),wp.ccf.views.Fields.hidden=wp.ccf.views.Fields.hidden||wp.ccf.views.FieldBase.extend({template:i.template(document.getElementById("ccf-hidden-template").innerHTML),saveField:function(){return this.model.set("slug",this.el.querySelectorAll(".field-slug")[0].value),this.model.set("value",this.el.querySelectorAll(".field-value")[0].value),this.model.set("className",this.el.querySelectorAll(".field-class-name")[0].value),this}}),wp.ccf.views.Fields.date=wp.ccf.views.Fields.date||wp.ccf.views.FieldBase.extend({template:i.template(document.getElementById("ccf-date-template").innerHTML),saveField:function(){this.model.set("slug",this.el.querySelectorAll(".field-slug")[0].value),this.model.set("label",this.el.querySelectorAll(".field-label")[0].value);var e=this.el.querySelectorAll(".field-value");e.length>0&&this.model.set("value",e[0].value),this.model.set("className",this.el.querySelectorAll(".field-class-name")[0].value),this.model.set("showDate",this.el.querySelectorAll(".field-show-date")[0].checked?!0:!1);var t=this.model.get("showTime"),i=this.el.querySelectorAll(".field-show-time")[0].checked?!0:!1;return this.model.set("showTime",i),this.model.set("required",1==this.el.querySelectorAll(".field-required")[0].value?!0:!1),i!=t&&this.render(),this}}),wp.ccf.views.Fields.name=wp.ccf.views.Fields.name||wp.ccf.views.FieldBase.extend({template:i.template(document.getElementById("ccf-name-template").innerHTML),saveField:function(){return this.model.set("slug",this.el.querySelectorAll(".field-slug")[0].value),this.model.set("label",this.el.querySelectorAll(".field-label")[0].value),this.model.set("className",this.el.querySelectorAll(".field-class-name")[0].value),this.model.set("required",1==this.el.querySelectorAll(".field-required")[0].value?!0:!1),this}}),wp.ccf.views.Fields.website=wp.ccf.views.Fields.website||wp.ccf.views.FieldBase.extend({template:i.template(document.getElementById("ccf-website-template").innerHTML),saveField:function(){return this.model.set("slug",this.el.querySelectorAll(".field-slug")[0].value),this.model.set("label",this.el.querySelectorAll(".field-label")[0].value),this.model.set("value",this.el.querySelectorAll(".field-value")[0].value),this.model.set("placeholder",this.el.querySelectorAll(".field-placeholder")[0].value),this.model.set("className",this.el.querySelectorAll(".field-class-name")[0].value),this.model.set("required",1==this.el.querySelectorAll(".field-required")[0].value?!0:!1),this}}),wp.ccf.views.Fields.phone=wp.ccf.views.Fields.phone||wp.ccf.views.FieldBase.extend({template:i.template(document.getElementById("ccf-phone-template").innerHTML),saveField:function(){return this.model.set("slug",this.el.querySelectorAll(".field-slug")[0].value),this.model.set("label",this.el.querySelectorAll(".field-label")[0].value),this.model.set("value",this.el.querySelectorAll(".field-value")[0].value),this.model.set("placeholder",this.el.querySelectorAll(".field-placeholder")[0].value),this.model.set("phoneFormat",this.el.querySelectorAll(".field-phone-format")[0].value),this.model.set("className",this.el.querySelectorAll(".field-class-name")[0].value),this.model.set("required",1==this.el.querySelectorAll(".field-required")[0].value?!0:!1),this}}),wp.ccf.views.Fields.address=wp.ccf.views.Fields.address||wp.ccf.views.FieldBase.extend({template:i.template(document.getElementById("ccf-address-template").innerHTML),saveField:function(){return this.model.set("slug",this.el.querySelectorAll(".field-slug")[0].value),this.model.set("label",this.el.querySelectorAll(".field-label")[0].value),this.model.set("addressType",this.el.querySelectorAll(".field-address-type")[0].value),this.model.set("className",this.el.querySelectorAll(".field-class-name")[0].value),this.model.set("required",1==this.el.querySelectorAll(".field-required")[0].value?!0:!1),this}}),wp.ccf.views.Fields.email=wp.ccf.views.Fields.email||wp.ccf.views.FieldBase.extend({template:i.template(document.getElementById("ccf-email-template").innerHTML),saveField:function(){this.model.set("slug",this.el.querySelectorAll(".field-slug")[0].value),this.model.set("label",this.el.querySelectorAll(".field-label")[0].value);var e=this.el.querySelectorAll(".field-value");e.length&&this.model.set("value",e[0].value);var t=this.el.querySelectorAll(".field-placeholder");t.length&&this.model.set("placeholder",t[0].value),this.model.set("className",this.el.querySelectorAll(".field-class-name")[0].value),this.model.set("required",1==this.el.querySelectorAll(".field-required")[0].value?!0:!1);var i=1==this.el.querySelectorAll(".field-email-confirmation")[0].value?!0:!1,l=this.model.get("emailConfirmation");return this.model.set("emailConfirmation",i),l!=i&&this.render(),this}}),wp.ccf.views.ChoiceableField=wp.ccf.views.ChoiceableField||wp.ccf.views.FieldBase.extend({template:i.template(document.getElementById("ccf-dropdown-template").innerHTML),initialize:function(){var e=this.model.get("choices");this.listenTo(e,"add",this.addChoice)},addChoice:function(e){var t=new wp.ccf.views.FieldChoice({model:e,field:this.model}).render(),i=this.el.querySelectorAll(".repeatable-choices")[0];i.appendChild(t.el)},saveField:function(){this.model.set("slug",this.el.querySelectorAll(".field-slug")[0].value),this.model.set("label",this.el.querySelectorAll(".field-label")[0].value),this.model.set("className",this.el.querySelectorAll(".field-class-name")[0].value),this.model.set("required",1==this.el.querySelectorAll(".field-required")[0].value?!0:!1);var t=this.el.querySelectorAll(".repeatable-choices")[0].querySelectorAll(".choice");return i.each(t,function(t){e(t).trigger("saveChoice")}),this},render:function(){var t=this;t.el.innerHTML=t.template({field:t.model.toJSON()});var i=t.model.get("choices"),l=this.el.querySelectorAll(".repeatable-choices")[0];if(i.length>=1)i.each(function(e){var i=new wp.ccf.views.FieldChoice({model:e,field:t.model}).render();l.appendChild(i.el)});else{var s=new wp.ccf.models.FieldChoice;i.add(s)}return l=this.el.querySelectorAll(".repeatable-choices")[0],e(l).sortable({handle:".move",axis:"y",stop:function(e,t){t.item.trigger("sorted",t.item.index())}}),t}}),wp.ccf.views.Fields.dropdown=wp.ccf.views.Fields.dropdown||wp.ccf.views.ChoiceableField.extend({template:i.template(document.getElementById("ccf-dropdown-template").innerHTML),events:function(){return this.constructor.__super__.events}}),wp.ccf.views.Fields.radio=wp.ccf.views.Fields.radio||wp.ccf.views.ChoiceableField.extend({template:i.template(document.getElementById("ccf-radio-template").innerHTML),events:function(){return this.constructor.__super__.events}}),wp.ccf.views.Fields.checkboxes=wp.ccf.views.Fields.checkboxes||wp.ccf.views.ChoiceableField.extend({template:i.template(document.getElementById("ccf-checkboxes-template").innerHTML),events:function(){return this.constructor.__super__.events}}),wp.ccf.views.FieldSidebar=wp.ccf.views.FieldSidebar||t.View.extend({initialize:function(e){this.currentFieldView=null,this.form=e.form},save:function(e){this.currentFieldView&&""!==this.currentFieldView.el.innerHTML&&this.currentFieldView.saveField(),e&&e instanceof Object&&e.resolve()},fieldRemoved:function(){this.currentFieldView&&(this.form.get("fields").get(this.currentFieldView.model)||this.render())},destroy:function(){wp.ccf.dispatcher.off("saveField",this.save),wp.ccf.dispatcher.off("mainViewChange",this.save),this.unbind()},render:function(e){var t={};if(e){var l=e.get("type");this.currentFieldView&&(this.currentFieldView.saveField(),this.currentFieldView.destroy&&this.currentFieldView.destroy()),this.currentFieldView=new wp.ccf.views.Fields[l]({model:e}),this.currentFieldView.render(),this.el.innerHTML="",this.el.appendChild(this.currentFieldView.el);var s=this.form.get("fields");this.listenTo(s,"remove",this.fieldRemoved)}else{var c=i.template(document.getElementById("ccf-empty-field-template").innerHTML);this.el.innerHTML=c(t)}return wp.ccf.dispatcher.on("saveField",this.save,this),wp.ccf.dispatcher.on("mainViewChange",this.save,this),this}}),wp.ccf.views.FieldRowPlaceholder=wp.ccf.views.FieldRowPlaceholder||t.View.extend({template:i.template(document.getElementById("ccf-field-row-template").innerHTML),tagName:"div",className:"field",initialize:function(e){this.type=e.type},render:function(){return this.el.innerHTML=this.template({label:l.allLabels[this.type]}),this.el.setAttribute("data-field-type",this.type),this.el.className+=" "+this.type,this}}),wp.ccf.views.FieldRow=wp.ccf.views.FieldRow||t.View.extend({template:i.template(document.getElementById("ccf-field-row-template").innerHTML),tagName:"div",className:"field",events:{"click .delete":"triggerDelete","click h4":"triggerEdit",sorted:"triggerUpdateSort"},initialize:function(e){i.bindAll(this,"triggerDelete"),this.form=e.form,this.listenTo(this.model,"change",this.handleChange,this),this.listenTo(this.model,"requirementsNotMet",this.requirementsNotMet,this),this.listenTo(this.model,"requirementsMet",this.requirementsMet,this),this.listenTo(this.model,"duplicateSlug",this.duplicateSlug,this),this.model.attributes.choices&&this.listenTo(this.model.attributes.choices,"change",this.handleChange,this)},duplicateSlug:function(){this.requirementsMet(),this.el.className+=" field-duplicate-slug"},requirementsNotMet:function(){this.requirementsMet(),this.el.className+=" field-incomplete"},requirementsMet:function(){this.el.className=this.el.className.replace(/(field-incomplete|field-duplicate-slug)/i,"")},triggerUpdateSort:function(e,t){this.form.get("fields").remove(this.model),this.form.get("fields").add(this.model,{at:t})},handleChange:function(){this.render()},triggerDelete:function(e){e.stopPropagation(),this.form.get("fields").remove(this.model),this.undelegateEvents(),this.remove()},triggerEdit:function(){var e=this.el.parentNode.querySelectorAll(".ccf-editing");i.each(e,function(e){e.className=e.className.replace(/ccf-editing/i,"")}),this.el.className=this.el.className.replace(/ccf-editing/i,"")+" ccf-editing",wp.ccf.dispatcher.trigger("openEditField",this.model)},render:function(e){this.el.innerHTML=this.template({label:l.allLabels[this.model.get("type")]}),this.el.setAttribute("data-field-type",this.model.get("type"));var t=RegExp(" "+this.model.get("type"),"i");this.el.className=this.el.className.replace(t,"")+" "+this.model.get("type"),e&&(this.el.className=this.el.className.replace(/ instantiated/i,"")+" instantiated");var s=document.getElementById("ccf-"+this.model.get("type")+"-preview-template");if(s){var c=this.el.querySelectorAll(".preview")[0];c.style.display="block",c.innerHTML=i.template(s.innerHTML)({field:this.model.toJSON()})}return this}}),wp.ccf.views.FormSettings=wp.ccf.views.FormSettings||t.View.extend({template:i.template(document.getElementById("ccf-form-settings-template").innerHTML),events:{"blur input":"save","change select":"save","change select.form-completion-action-type":"toggleCompletionFields","change select.form-send-email-notifications":"toggleNotificationFields"},initialize:function(e){this.model=e.form},destroy:function(){wp.ccf.dispatcher.off("saveFormSettings",this.save),wp.ccf.dispatcher.off("mainViewChange",this.save)},toggleCompletionFields:function(){var e=this.el.querySelectorAll(".form-completion-action-type")[0].value,t=this.el.querySelectorAll(".completion-message")[0],i=this.el.querySelectorAll(".completion-redirect-url")[0];"text"===e?(t.style.display="block",i.style.display="none"):(t.style.display="none",i.style.display="block")},toggleNotificationFields:function(){var e=this.el.querySelectorAll(".form-send-email-notifications")[0].value,t=this.el.querySelectorAll(".email-notification-addresses")[0];t.style.display=parseInt(e)?"block":"none"},save:function(e){if(""!==this.el.innerHTML){var t=this.el.querySelectorAll(".form-title")[0].value;this.model.set("title",t);var i=this.el.querySelectorAll(".form-description")[0].value;this.model.set("description",i);var l=this.el.querySelectorAll(".form-button-text")[0].value;this.model.set("buttonText",l);var s=this.el.querySelectorAll(".form-completion-message")[0].value;this.model.set("completionMessage",s);var c=this.el.querySelectorAll(".form-completion-redirect-url")[0].value;this.model.set("completionRedirectUrl",c);var n=this.el.querySelectorAll(".form-completion-action-type")[0].value;this.model.set("completionActionType",n);var r=this.el.querySelectorAll(".form-send-email-notifications")[0].value;this.model.set("sendEmailNotifications",parseInt(r)?!0:!1);var o=this.el.querySelectorAll(".form-email-notification-addresses")[0].value;this.model.set("emailNotificationAddresses",o),e!==void 0&&e.promise!==void 0&&e.resolve()}},render:function(){var e={form:this.model.toJSON()};return this.el.innerHTML=this.template(e),this.toggleCompletionFields(),this.toggleNotificationFields(),wp.ccf.dispatcher.on("saveFormSettings",this.save,this),wp.ccf.dispatcher.on("mainViewChange",this.save,this),this}}),wp.ccf.views.FormPane=wp.ccf.views.FormPane||t.View.extend(i.defaults({template:i.template(document.getElementById("ccf-form-pane-template").innerHTML),subViews:{"field-sidebar":wp.ccf.views.FieldSidebar,"form-settings":wp.ccf.views.FormSettings},events:{"click .save-button":"sync","click h2":"accordionClick","click .insert-form-button":"insertForm"},initialize:function(){wp.ccf.dispatcher.on("openEditField",this.openEditField,this)},insertForm:function(){wp.ccf.utils.insertFormShortcode(this.model),wp.ccf.toggle()},accordionClick:function(t){var l=e(t.currentTarget).parents(".accordion-container")[0],s=l.querySelectorAll(".accordion-section");t.currentTarget.parentNode.className.match(/expanded/i)?t.currentTarget.parentNode.className=t.currentTarget.parentNode.className.replace(/expanded/i,""):t.currentTarget.parentNode.className+=" expanded",i.each(s,function(e){e!=t.currentTarget.parentNode&&e.className.match(/expanded/i)&&(e.className=e.className.replace(/expanded/i,""))})},openEditField:function(e){this.renderedSubViews["field-sidebar"].render(e).el.style.display="block"},disable:function(){this.el.querySelectorAll(".save-button")[0].setAttribute("disabled","disabled"),this.el.querySelectorAll(".disabled-overlay")[0].style.display="block"},enable:function(){this.el.querySelectorAll(".save-button")[0].removeAttribute("disabled"),this.el.querySelectorAll(".disabled-overlay")[0].style.display="none"},sync:function(){var t=this,i=e(this.el.querySelectorAll(".spinner")[0]);i.fadeIn(),t.disable();var s=e.Deferred(),c=e.Deferred();wp.ccf.dispatcher.trigger("saveFormSettings",s),wp.ccf.dispatcher.trigger("saveField",c),e.when(s,c).then(function(){var e=t.model.get("fields"),s=!0,c={};e.each(function(e){var t=e.get("slug");e.hasRequiredAttributes()?t&&!t.match(/^[a-zA-Z0-9\-_]+$/)?(s=!1,e.trigger("requirementsNotMet")):c[e.get("slug")]!==void 0?(s=!1,e.trigger("duplicateSlug"),c[e.get("slug")].trigger("duplicateSlug")):e.trigger("requirementsMet"):(s=!1,e.trigger("requirementsNotMet")),e.get("slug")&&(c[e.get("slug")]=e)}),s?t.model.save({},{context:"edit"}).done(function(){l.single&&!l.postId&&(window.location=l.adminUrl+"post.php?post="+t.model.get("ID")+"&action=edit#ccf-form/"+t.model.get("ID"))}).complete(function(){i.fadeOut(),t.enable(),wp.ccf.dispatcher.trigger("saveFormComplete",t.model)}):(t.enable(),i.fadeOut())})},enableDisableInsert:function(){var e=this.el.querySelectorAll(".insert-form-button")[0];this.model.get("ID")?e.removeAttribute("disabled"):e.setAttribute("disabled","disabled")},render:function(t){var s=this;s.model=t?t:new wp.ccf.models.Form,this.listenTo(s.model,"change",this.enableDisableInsert,this);var c={labels:l.fieldLabels,form:s.model.toJSON()};window.form=s.model,s.el.innerHTML=this.template(c);var n=s.el.querySelectorAll(".fields")[0];i.each(l.fieldLabels,function(e,t){n.appendChild(new wp.ccf.views.FieldRowPlaceholder({type:t}).render().el)});var r=s.el.querySelectorAll(".structure-fields")[0];i.each(l.structureFieldLabels,function(e,t){r.appendChild(new wp.ccf.views.FieldRowPlaceholder({type:t}).render().el)});var o=s.el.querySelectorAll(".special-fields")[0];i.each(l.specialFieldLabels,function(e,t){o.appendChild(new wp.ccf.views.FieldRowPlaceholder({type:t}).render().el)}),e(s.el.querySelectorAll(".left-sidebar")[0].querySelectorAll(".field")).draggable({cursor:"move",zIndex:160001,scroll:!1,containment:".ccf-form-pane",appendTo:".ccf-main-modal",snap:!0,connectToSortable:".form-content",helper:function(t){var i=e(t.currentTarget),l=e('<div class="field" data-field-type="'+i.attr("data-field-type")+'"><h4>'+i.find(".label").html()+"</h4></div>");return l.css({width:i.width(),height:i.height()})}});var a=s.model.get("fields"),d=s.el.querySelectorAll(".form-content")[0];
2
+ return a.length>=1&&(d.innerHTML="",a.each(function(e){var t=new wp.ccf.views.FieldRow({model:e,form:s.model}).render(!0).el;d.appendChild(t)})),e(d).sortable({axis:"y",handle:"h4",stop:function(e,t){if(!t.item.hasClass("instantiated")){var i=t.item.attr("data-field-type"),l={};if(wp.ccf.models.Fields[i].prototype.defaults().slug!==void 0){var c=s.model.get("fields").where({type:i}).length+1;l.slug=i+"-"+c}var n=new wp.ccf.models.Fields[i](l),r=s.model.get("fields");r.add(n),new wp.ccf.views.FieldRow({model:n,el:t.item,form:s.model}).render(!0),t.item.attr("style","")}t.item.trigger("sorted",t.item.index())}}),s.initRenderSubViews(!0,!0,{form:s.model}),s.enableDisableInsert(),s}},wp.ccf.mixins.subViewable)),wp.ccf.views.ExistingFormTableRow=wp.ccf.views.ExistingFormTableRow||t.View.extend({tagName:"tr",template:i.template(document.getElementById("ccf-existing-form-table-row-template").innerHTML),events:{"click .edit":"triggerMainViewChange","click .delete":"triggerDelete","click .insert-form-button":"insertForm"},initialize:function(e){this.parent=e.parent},insertForm:function(){wp.ccf.utils.insertFormShortcode(this.model),wp.ccf.toggle()},triggerMainViewChange:function(){wp.ccf.switchToForm(this.model)},triggerDelete:function(){var e,t=this,i=t.parent.collection.state.currentPage;t.model.destroy().done(function(){e=i,e===t.parent.collection.state.totalPages&&e-1===(t.parent.collection.state.totalObjects-1)/l.postsPerPage&&e--,t.parent.showPage(e).done(function(){t.parent.renderPagination()})})},render:function(){return this.$el.html(this.template({form:this.model.toJSON(),utils:{getPrettyPostDate:wp.ccf.utils.getPrettyPostDate}})),this}}),wp.ccf.views.EmptyFormTableRow=wp.ccf.views.EmptyFormTableRow||t.View.extend({tagName:"tr",template:i.template(document.getElementById("ccf-empty-form-table-row-template").innerHTML),render:function(){return this.$el.html(this.template()),this}}),wp.ccf.views.ExistingFormTable=wp.ccf.views.ExistingFormTable||t.View.extend({template:i.template(document.getElementById("ccf-existing-form-table-template").innerHTML),initialize:function(){this.parent=arguments.parent,this.collection=new wp.ccf.collections.Forms,wp.ccf.dispatcher.on("changeFormTablePage",this.showPage,this),wp.ccf.dispatcher.on("saveFormComplete",this.render,this)},showPage:function(e){var t=this,i=this.collection.fetch({data:{page:e}});return i.done(function(){var e=t.el.querySelectorAll(".rows")[0],i=document.createElement("tbody");i.className="rows",t.collection.length>=1?t.collection.each(function(e){var l=new wp.ccf.views.ExistingFormTableRow({model:e,parent:t}).render();i.appendChild(l.el)},t):i.appendChild((new wp.ccf.views.EmptyFormTableRow).render().el),e.parentNode.replaceChild(i,e)}),i},renderPagination:function(){var e=this.el.querySelectorAll(".ccf-pagination")[0];e.innerHTML="",this.collection.state.totalPages>1&&e.appendChild(new wp.ccf.views.Pagination({parent:this}).render(this.collection.state.totalPages,this.collection.state.currentPage).el)},render:function(){var e=this;return this.el.innerHTML=this.template(),this.el.querySelectorAll(".ccf-pagination")[0],this.showPage(1).done(function(){e.renderPagination()}),this}}),wp.ccf.views.ExistingFormPane=wp.ccf.views.ExistingFormPane||t.View.extend(i.defaults({template:i.template(document.getElementById("ccf-existing-form-pane-template").innerHTML),subViews:{"existing-form-table":wp.ccf.views.ExistingFormTable},render:function(){return this.rendered?this:(this.rendered=!0,this.el.innerHTML=this.template(),this.initRenderSubViews(!0),this)}},wp.ccf.mixins.subViewable)),wp.ccf.views.MainModal=wp.ccf.views.MainModal||t.View.extend(i.defaults({tagName:"div",className:"ccf-main-modal",template:i.template(document.getElementById("ccf-main-modal-template").innerHTML),events:{"click .close-icon":"hide","click .main-menu a":"menuClick"},subViews:{"form-pane":wp.ccf.views.FormPane},initialize:function(){l.single||(this.subViews["existing-form-pane"]=wp.ccf.views.ExistingFormPane),wp.ccf.dispatcher.on("mainViewChange",this.toggleView,this)},toggleView:function(e){this.showView(e,wp.ccf.currentForm);var t=e;"form-pane"===e&&wp.ccf.currentForm&&(t="existing-form-pane");var l=this.el.querySelectorAll(".menu-item");i.each(l,function(e){var i=e.getAttribute("data-view");e.className=i===t?e.className.replace("selected","")+" selected":e.className.replace("selected","")})},menuClick:function(e){var t=e.target.getAttribute("data-view");"form-pane"===t&&(wp.ccf.currentForm=null),wp.ccf.dispatcher.trigger("mainViewChange",t),e.preventDefault()},render:function(e){return e=e||!1,this.overlay(),this.el.innerHTML=this.template({single:e}),this.initRenderSubViews(),this.showView("form-pane",wp.ccf.currentForm,!0),this},overlay:function(){return this.overlayEl===void 0&&(this.overlayEl=document.createElement("div"),this.overlayEl.className="ccf-main-modal-overlay",document.body.appendChild(this.overlayEl)),this.overlayEl},remove:function(){return document.body.removeChild(this.overlay()),this},show:function(){e(this.overlay()).show(),this.$el.show()},hide:function(){e(this.overlay()).hide(),this.$el.hide()}},wp.ccf.mixins.subViewable)),wp.ccf.views.SubmissionRow=wp.ccf.views.SubmissionRow||t.View.extend({tagName:"tr",template:i.template(document.getElementById("ccf-submission-row-template").innerHTML),events:{"click .view":"view","click .delete":"delete"},initialize:function(e){this.parent=e.parent},"delete":function(){var e,t=this,i=t.parent.collection.state.currentPage;t.model.destroy().done(function(){e=i,e===t.parent.collection.state.totalPages&&e-1===(t.parent.collection.state.totalObjects-1)/l.postsPerPage&&e--,t.parent.showPage(e).done(function(){t.parent.renderPagination()})})},view:function(e){var t=e.currentTarget.getAttribute("data-submission-id"),i=e.currentTarget.getAttribute("data-submission-date");tb_show(l.thickboxTitle+" - "+wp.ccf.utils.getPrettyPostDate(i),"#TB_inline?height=500&amp;width=700&amp;inlineId=ccf-submission-content-"+parseInt(t),null)},render:function(){return this.$el.html(this.template({submission:this.model.toJSON(),currentColumns:this.parent.columns,columns:wp.ccf.currentForm.getFieldSlugs(!0),utils:{getPrettyPostDate:wp.ccf.utils.getPrettyPostDate,wordChop:wp.ccf.utils.wordChop,isFieldDate:wp.ccf.utils.isFieldDate,isFieldName:wp.ccf.utils.isFieldName,isFieldAddress:wp.ccf.utils.isFieldAddress,getPrettyFieldDate:wp.ccf.utils.getPrettyFieldDate,getPrettyFieldAddress:wp.ccf.utils.getPrettyFieldAddress,getPrettyFieldName:wp.ccf.utils.getPrettyFieldName}})),this}}),wp.ccf.views.SubmissionsTable=wp.ccf.views.SubmissionsTable||t.View.extend({template:i.template(document.getElementById("ccf-submission-table-template").innerHTML),events:{"click .prev:not(.disabled)":"previousPage","click .next:not(.disabled)":"nextPage","click .first:not(.disabled)":"firstPage","click .last:not(.disabled)":"lastPage"},initialize:function(){this.collection=new wp.ccf.collections.Submissions({},{formId:l.postId}),wp.ccf.dispatcher.on("submissionTableRebuild",this.render,this)},showPage:function(e){var t=this,i=this.collection.fetch({data:{page:e}});return i.done(function(){var e=t.el.querySelectorAll(".submission-rows")[0],i=document.createElement("tbody");i.className="submission-rows",t.collection.length>=1?t.collection.each(function(e){var l=new wp.ccf.views.SubmissionRow({model:e,parent:t}).render();i.appendChild(l.el)},t):i.appendChild(new wp.ccf.views.EmptySubmissionTableRow({parent:t}).render(wp.ccf.currentForm.getFieldSlugs(!0).concat("date")).el),e.parentNode.replaceChild(i,e)}),i},renderPagination:function(){var e=this.el.querySelectorAll(".ccf-pagination")[0];e.innerHTML="",this.collection.state.totalPages>1&&e.appendChild(new wp.ccf.views.Pagination({parent:this}).render(this.collection.state.totalPages,this.collection.state.currentPage).el)},render:function(e){var t=this;return t.columns=e?e:wp.ccf.currentForm.getFieldSlugs(!0).slice(0,4).concat("date"),1>t.columns.length?t.el.innerHTML="":(t.el.innerHTML=t.template({columns:t.columns}),t.el.querySelectorAll(".ccf-pagination")[0],t.showPage(1).done(function(){t.renderPagination()})),t}}),wp.ccf.views.Pagination=wp.ccf.views.Pagination||t.View.extend({template:i.template(document.getElementById("ccf-pagination-template").innerHTML),events:{"click .prev:not(.disabled)":"previousPage","click .next:not(.disabled)":"nextPage","click .first:not(.disabled)":"firstPage","click .last:not(.disabled)":"lastPage"},initialize:function(e){this.parent=e.parent},previousPage:function(){var e=this;e.parent.showPage(e.parent.collection.state.currentPage-1).done(function(){e.render()})},nextPage:function(){var e=this;e.parent.showPage(e.parent.collection.state.currentPage+1).done(function(){e.render()})},firstPage:function(){var e=this;e.parent.showPage(1).done(function(){e.render()})},lastPage:function(){var e=this;e.parent.showPage(e.parent.collection.state.totalPages).done(function(){e.render()})},render:function(){return this.el.innerHTML=this.template({totalPages:this.parent.collection.state.totalPages,currentPage:this.parent.collection.state.currentPage,totalObjects:this.parent.collection.state.totalObjects}),this}}),wp.ccf.views.EmptySubmissionTableRow=wp.ccf.views.EmptySubmissionTableRow||t.View.extend({tagName:"tr",template:i.template(document.getElementById("ccf-no-submissions-row-template").innerHTML),initialize:function(e){this.parent=e.parent},render:function(){return this.el.innerHTML=this.template({columns:this.parent.columns}),this}}),wp.ccf.views.SubmissionColumnController=wp.ccf.views.SubmissionColumnController||t.View.extend({template:i.template(document.getElementById("ccf-submissions-controller-template").innerHTML),events:{"click input[type=checkbox]":"triggerTableRebuild"},render:function(){this.el.innerHTML=this.template({columns:wp.ccf.currentForm.getFieldSlugs(!0).concat("date")})},triggerTableRebuild:function(){var e=[],t=document.querySelectorAll(".submission-column-checkbox");if(t.length>=1)for(var i=0;t.length>i;i++)t[i].checked&&e.push(t[i].value);wp.ccf.dispatcher.trigger("submissionTableRebuild",e)}})}(jQuery,Backbone,_,ccfSettings),function(e,t){"use strict";wp.ccf.router=wp.ccf.router||t.Router.extend({routes:{"ccf-form":"open","ccf-form/:formId":"open"},open:function(e){wp.ccf.show(e)}})}(jQuery,Backbone,_,ccfSettings),function(e,t,i,l){"use strict";wp.ccf=i.defaults(wp.ccf,{forms:new wp.ccf.collections.Forms,currentForm:null,_currentFormDeferred:null,dispatcher:{},show:function(e){return this.switchToForm(e),this.instance.show(),this.instance},switchToForm:function(e){var t=this;if(+e===parseInt(e)){var i=parseInt(e);if(e=t.forms.findWhere({ID:parseInt(i)}),!e){var l;return t.forms.formsFetching[i]!==void 0?(l=t.forms.formsFetching[i],e=null):(e=new wp.ccf.models.Form({ID:i}),l=e.fetch(),t.forms.formsFetching[i]=l),l.done(function(){e?(delete t.forms.formsFetching[i],t.forms.add(e)):e=t.forms.findWhere({ID:i}),t.currentForm=e,wp.ccf.dispatcher.trigger("mainViewChange","form-pane")}),l}t.currentForm=e,wp.ccf.dispatcher.trigger("mainViewChange","form-pane")}else t.currentForm=e,wp.ccf.dispatcher.trigger("mainViewChange","form-pane");return!0},hide:function(){return this.instance.hide(),this.instance},toggle:function(e){return this.switchToForm(e),this.instance.$el.is(":visible")?this.instance.hide():this.instance.show(),this.instance},createSubmissionsTable:function(e){var t=document.querySelectorAll(".ccf-submission-column-controller"),i=new wp.ccf.views.SubmissionsTable({el:e});i.render(),t&&new wp.ccf.views.SubmissionColumnController({el:t}).render()},_setupMainModal:function(e){return this.instance=(new wp.ccf.views.MainModal).render(e),document.getElementsByTagName("body")[0].appendChild(this.instance.el),t.history.start(),this.instance},createManager:function(){var s=this;i.extend(this.dispatcher,t.Events),new wp.ccf.router;var c=!1,n=document.querySelectorAll(".ccf-open-form-manager")[0];if(l.single)if(c=!0,l.postId){var r=parseInt(l.postId);if(s.forms.formsFetching[r]===void 0){var o=new wp.ccf.models.Form({ID:r}),a=o.fetch();s.forms.formsFetching[r]=a,s._currentFormDeferred=a,a.done(function(){delete s.forms.formsFetching[r],s.forms.add(o),s.currentForm=o})}else s._currentFormDeferred=s.forms.formsFetching[r],s._currentFormDeferred.done(function(){s.currentForm=s.forms.findWhere({ID:r})});e.when(s._currentFormDeferred).then(function(){s._setupMainModal(!0),n.style.display="inline-block";var e=document.getElementById("ccf-submissions");if(e){var t=e.querySelectorAll(".inside")[0],i=document.createElement("div");i.className="ccf-submission-settings",i.setAttribute("data-icon","");var l=document.getElementById("show-settings-link");i.onclick=function(){l.click()},e.insertBefore(i,e.firstChild.nextSibling.nextSibling),wp.ccf.createSubmissionsTable(t)}})}else s._setupMainModal(!0),n.style.display="inline-block";else s._setupMainModal();var d=function(e){e=e||window.event;var t=e.currentTarget?e.currentTarget:e.srcElement,i=t.getAttribute("data-form-id");wp.ccf.toggle(i)};n.addEventListener?n.addEventListener("click",d,!1):n.attachEvent("onclick",d)}}),wp.ccf.createManager()}(jQuery,Backbone,_,ccfSettings);
classes/class-ccf-api.php CHANGED
@@ -326,6 +326,16 @@ class CCF_API extends WP_JSON_Posts {
326
  unset( $data['author'] );
327
  }
328
 
 
 
 
 
 
 
 
 
 
 
329
  $result = $this->insert_post( $data );
330
  if ( $result instanceof WP_Error ) {
331
  return $result;
@@ -582,6 +592,16 @@ class CCF_API extends WP_JSON_Posts {
582
  unset( $data['author'] );
583
  }
584
 
 
 
 
 
 
 
 
 
 
 
585
  $result = $this->insert_post( $data );
586
  if ( $result instanceof WP_Error ) {
587
  return $result;
326
  unset( $data['author'] );
327
  }
328
 
329
+ // @todo: remove hack. Needed for broken API
330
+ if ( isset( $data['date'] ) ) {
331
+ unset( $data['date'] );
332
+ }
333
+
334
+ // @todo: remove hack. Needed for broken API
335
+ if ( isset( $data['date_gmt'] ) ) {
336
+ unset( $data['date_gmt'] );
337
+ }
338
+
339
  $result = $this->insert_post( $data );
340
  if ( $result instanceof WP_Error ) {
341
  return $result;
592
  unset( $data['author'] );
593
  }
594
 
595
+ // @todo: remove hack. Needed for broken API
596
+ if ( isset( $data['date'] ) ) {
597
+ unset( $data['date'] );
598
+ }
599
+
600
+ // @todo: remove hack. Needed for broken API
601
+ if ( isset( $data['date_gmt'] ) ) {
602
+ unset( $data['date_gmt'] );
603
+ }
604
+
605
  $result = $this->insert_post( $data );
606
  if ( $result instanceof WP_Error ) {
607
  return $result;
classes/class-ccf-custom-contact-forms.php CHANGED
@@ -17,7 +17,7 @@ class CCF_Custom_Contact_Forms {
17
  public function setup() {
18
  add_action( 'plugins_loaded', array( $this, 'manually_load_api' ), 100 );
19
  add_action( 'plugins_loaded', array( $this, 'load_textdomain' ) );
20
- add_filter( 'plugin_row_meta', array( $this, 'filter_plugin_row_meta' ), 10, 4 );
21
  add_action( 'admin_notices', array( $this, 'permalink_warning' ) );
22
  add_action( 'admin_init', array( $this, 'flush_rewrites' ), 10000 );
23
  }
@@ -50,23 +50,21 @@ class CCF_Custom_Contact_Forms {
50
  }
51
 
52
  /**
53
- * Add forms and form submissions link to meta
54
  *
55
- * @param array $plugin_meta
56
  * @param string $plugin_file
57
- * @param string $plugin_data
58
- * @param string $status
59
- * @since 6.0
60
  * @return array
61
  */
62
- public function filter_plugin_row_meta( $plugin_meta, $plugin_file, $plugin_data, $status ) {
63
- $new_meta = array();
64
 
65
- if ( 'custom-contact-forms/custom-contact-forms.php' === $plugin_file ) {
66
- $new_meta['ccf_forms'] = sprintf( __( '<a href="%s">Forms and Submissions</a>', 'custom-contact-forms' ), esc_url( admin_url( 'edit.php?post_type=ccf_form' ) ) );
67
  }
68
 
69
- return array_merge( $new_meta, $plugin_meta );
70
  }
71
 
72
  /**
17
  public function setup() {
18
  add_action( 'plugins_loaded', array( $this, 'manually_load_api' ), 100 );
19
  add_action( 'plugins_loaded', array( $this, 'load_textdomain' ) );
20
+ add_filter( 'plugin_action_links', array( $this, 'filter_plugin_action_links' ), 10, 2 );
21
  add_action( 'admin_notices', array( $this, 'permalink_warning' ) );
22
  add_action( 'admin_init', array( $this, 'flush_rewrites' ), 10000 );
23
  }
50
  }
51
 
52
  /**
53
+ * Add forms and form submissions link to plugin actions
54
  *
55
+ * @param array $plugin_actions
56
  * @param string $plugin_file
57
+ * @since 6.1.4
 
 
58
  * @return array
59
  */
60
+ public function filter_plugin_action_links( $plugin_actions, $plugin_file ) {
61
+ $new_actions = array();
62
 
63
+ if ( basename( plugin_dir_path( dirname( __FILE__ ) ) ) . '/custom-contact-forms.php' === $plugin_file ) {
64
+ $new_actions['ccf_forms'] = sprintf( __( '<a href="%s">Forms and Submissions</a>', 'custom-contact-forms' ), esc_url( admin_url( 'edit.php?post_type=ccf_form' ) ) );
65
  }
66
 
67
+ return array_merge( $new_actions, $plugin_actions );
68
  }
69
 
70
  /**
classes/class-ccf-form-cpt.php CHANGED
@@ -242,7 +242,7 @@ class CCF_Form_CPT {
242
  <h1>
243
  <span class="ccf-form-cpt-title">
244
  <?php if ( ! empty( $title ) ) : ?>
245
- <?php echo $title; ?>
246
  <?php else: ?>
247
  <?php esc_html_e( '(No title)', 'custom-contact-forms' ); ?>
248
  <?php endif; ?>
242
  <h1>
243
  <span class="ccf-form-cpt-title">
244
  <?php if ( ! empty( $title ) ) : ?>
245
+ <?php echo esc_html( $title ); ?>
246
  <?php else: ?>
247
  <?php esc_html_e( '(No title)', 'custom-contact-forms' ); ?>
248
  <?php endif; ?>
classes/class-ccf-form-handler.php CHANGED
@@ -563,12 +563,14 @@ class CCF_Form_Handler {
563
  <?php
564
  }
565
 
566
- ?>
567
- <div>
568
- <?php esc_html_e( 'Form submitted from:', 'custom-contact-forms' ); ?>:
569
- <?php echo esc_url( untrailingslashit( site_url() ) . $_SERVER['REQUEST_URI'] ); ?>
570
- </div>
571
- <?php
 
 
572
 
573
  $message .= ob_get_clean();
574
 
563
  <?php
564
  }
565
 
566
+ if ( ! empty( $_POST['form_page'] ) ) {
567
+ ?>
568
+ <div>
569
+ <?php esc_html_e( 'Form submitted from', 'custom-contact-forms' ); ?>:
570
+ <?php echo esc_url( $_POST['form_page'] ); ?>
571
+ </div>
572
+ <?php
573
+ }
574
 
575
  $message .= ob_get_clean();
576
 
classes/class-ccf-form-manager.php CHANGED
@@ -68,7 +68,7 @@ class CCF_Form_Manager {
68
  <div class="right">
69
  <a aria-hidden="true" data-icon="&#xe602;" class="delete"></a>
70
  </div>
71
- <span class="label"><%= label %></span>
72
  </h4>
73
 
74
  <div class="preview"></div>
@@ -118,17 +118,17 @@ class CCF_Form_Manager {
118
  <div class="section-content">
119
  <p>
120
  <label for="ccf_form_title"><?php esc_html_e( 'Form Title:', 'custom-contact-forms' ); ?></label>
121
- <input class="widefat form-title" id="ccf_form_title" name="title" type="text" value="<%= form.title %>">
122
  </p>
123
 
124
  <p>
125
  <label for="ccf_form_description"><?php esc_html_e( 'Form Description:', 'custom-contact-forms' ); ?></label>
126
- <textarea class="widefat form-description" id="ccf_form_description" name="description"><%= form.description %></textarea>
127
  </p>
128
 
129
  <p>
130
  <label for="ccf_form_button_text"><?php esc_html_e( 'Button Text:', 'custom-contact-forms' ); ?></label>
131
- <input class="widefat form-button-text" id="ccf_form_button_text" name="text" type="text" value="<%= form.buttonText %>">
132
  </p>
133
 
134
  <p>
@@ -141,11 +141,11 @@ class CCF_Form_Manager {
141
  </p>
142
  <p class="completion-redirect-url">
143
  <label for="ccf_form_completion_redirect_url"><?php esc_html_e( 'Redirect URL:', 'custom-contact-forms' ); ?></label>
144
- <input class="widefat form-completion-redirect-url" id="ccf_form_completion_redirect_url" name="text" type="text" value="<%= form.completionRedirectUrl %>">
145
  </p>
146
  <p class="completion-message">
147
  <label for="ccf_form_completion_message"><?php esc_html_e( 'Completion Message:', 'custom-contact-forms' ); ?></label>
148
- <textarea class="widefat form-completion-message" id="ccf_form_completion_message" name="completion-message"><%= form.completionMessage %></textarea>
149
  </p>
150
 
151
  <p>
@@ -158,7 +158,7 @@ class CCF_Form_Manager {
158
  </p>
159
  <p class="email-notification-addresses">
160
  <label for="ccf_form_email_notification_addresses"><?php esc_html_e( 'Email Addresses (comma separated):', 'custom-contact-forms' ); ?></label>
161
- <input class="widefat form-email-notification-addresses" id="ccf_form_email_notification_addresses" name="email-notification-addresses" value="<%= form.emailNotificationAddresses %>">
162
  </p>
163
  </div>
164
  </script>
@@ -170,12 +170,12 @@ class CCF_Form_Manager {
170
  </script>
171
 
172
  <script type="text/html" id="ccf-pagination-template">
173
- <span class="num-items"><%= totalObjects %> <?php esc_html_e( 'items', 'custom-contact-forms' ); ?></span>
174
 
175
  <a class="first <% if ( currentPage <= 1 ) { %>disabled<% } %>">&laquo;</a>
176
  <a class="prev <% if ( currentPage <= 1 ) { %>disabled<% } %>">&lsaquo;</a>
177
 
178
- <span class="pages"><%= currentPage %> of <%= totalPages %></span>
179
 
180
  <a class="next <% if ( currentPage >= totalPages ) { %>disabled<% } %>">&rsaquo;</a>
181
  <a class="last <% if ( currentPage >= totalPages ) { %>disabled<% } %>">&raquo;</a>
@@ -223,15 +223,15 @@ class CCF_Form_Manager {
223
  <div class="section-content">
224
  <div>
225
  <label for="ccf-field-slug"><span class="required">*</span> <?php esc_html_e( 'Internal Slug', 'custom-contact-forms' ); ?> (a-z, 0-9, -, _):</label>
226
- <input id="ccf-field-slug" class="field-slug" type="text" value="<%= field.slug %>">
227
  </div>
228
  <div>
229
  <label for="ccf-field-label"><?php esc_html_e( 'Label:', 'custom-contact-forms' ); ?></label>
230
- <input id="ccf-field-label" class="field-label" type="text" value="<%= field.label %>">
231
  </div>
232
  <div>
233
  <label for="ccf-field-value"><?php esc_html_e( 'Initial Value:', 'custom-contact-forms' ); ?></label>
234
- <input id="ccf-field-value" class="field-value" type="text" value="<%= field.value %>">
235
  </div>
236
  <div>
237
  <label for="ccf-field-required"><?php esc_html_e( 'Required:', 'custom-contact-forms' ); ?></label>
@@ -247,11 +247,11 @@ class CCF_Form_Manager {
247
  <div class="section-content">
248
  <div>
249
  <label for="ccf-field-class-name"><?php esc_html_e( 'Class Name:', 'custom-contact-forms' ); ?></label>
250
- <input id="ccf-field-class-name" class="field-class-name" type="text" value="<%= field.className %>">
251
  </div>
252
  <div>
253
  <label for="ccf-field-placeholder"><?php esc_html_e( 'Placeholder Text:', 'custom-contact-forms' ); ?></label>
254
- <input id="ccf-field-placeholder" class="field-placeholder" type="text" value="<%= field.placeholder %>">
255
  </div>
256
  </div>
257
  </div>
@@ -263,15 +263,15 @@ class CCF_Form_Manager {
263
  <div class="section-content">
264
  <div>
265
  <label for="ccf-field-slug"><span class="required">*</span> <?php esc_html_e( 'Internal Slug', 'custom-contact-forms' ); ?> (a-z, 0-9, -, _):</label>
266
- <input id="ccf-field-slug" class="field-slug" type="text" value="<%= field.slug %>">
267
  </div>
268
  <div>
269
  <label for="ccf-field-label"><?php esc_html_e( 'Label:', 'custom-contact-forms' ); ?></label>
270
- <input id="ccf-field-label" class="field-label" type="text" value="<%= field.label %>">
271
  </div>
272
  <div>
273
  <label for="ccf-field-value"><?php esc_html_e( 'Initial Value:', 'custom-contact-forms' ); ?></label>
274
- <input id="ccf-field-value" class="field-value" type="text" value="<%= field.value %>">
275
  </div>
276
  <div>
277
  <label for="ccf-field-required"><?php esc_html_e( 'Required:', 'custom-contact-forms' ); ?></label>
@@ -287,11 +287,11 @@ class CCF_Form_Manager {
287
  <div class="section-content">
288
  <div>
289
  <label for="ccf-field-class-name"><?php esc_html_e( 'Class Name:', 'custom-contact-forms' ); ?></label>
290
- <input id="ccf-field-class-name" class="field-class-name" type="text" value="<%= field.className %>">
291
  </div>
292
  <div>
293
  <label for="ccf-field-placeholder"><?php esc_html_e( 'Placeholder Text:', 'custom-contact-forms' ); ?></label>
294
- <input id="ccf-field-placeholder" class="field-placeholder" type="text" value="<%= field.placeholder %>">
295
  </div>
296
  </div>
297
  </div>
@@ -303,7 +303,7 @@ class CCF_Form_Manager {
303
  <div class="section-content">
304
  <div>
305
  <label for="ccf-field-html"><?php esc_html_e( 'HTML Content:', 'custom-contact-forms' ); ?></label>
306
- <textarea id="ccf-field-html" class="field-html"><%= field.html %></textarea>
307
  </div>
308
  </div>
309
  </div>
@@ -312,7 +312,7 @@ class CCF_Form_Manager {
312
  <div class="section-content">
313
  <div>
314
  <label for="ccf-field-class-name"><?php esc_html_e( 'Class Name:', 'custom-contact-forms' ); ?></label>
315
- <input id="ccf-field-class-name" class="field-class-name" type="text" value="<%= field.className %>">
316
  </div>
317
  </div>
318
  </div>
@@ -324,11 +324,11 @@ class CCF_Form_Manager {
324
  <div class="section-content">
325
  <div>
326
  <label for="ccf-field-heading"><?php esc_html_e( 'Heading:', 'custom-contact-forms' ); ?></label>
327
- <input id="ccf-field-heading" class="field-heading" type="text" value="<%= field.heading %>">
328
  </div>
329
  <div>
330
  <label for="ccf-field-subheading"><?php esc_html_e( 'Sub Heading:', 'custom-contact-forms' ); ?></label>
331
- <textarea id="ccf-field-subheading" class="field-subheading" type="text"><%= field.subheading %></textarea>
332
  </div>
333
  </div>
334
  </div>
@@ -337,7 +337,7 @@ class CCF_Form_Manager {
337
  <div class="section-content">
338
  <div>
339
  <label for="ccf-field-class-name"><?php esc_html_e( 'Class Name:', 'custom-contact-forms' ); ?></label>
340
- <input id="ccf-field-class-name" class="field-class-name" type="text" value="<%= field.className %>">
341
  </div>
342
  </div>
343
  </div>
@@ -349,15 +349,15 @@ class CCF_Form_Manager {
349
  <div class="section-content">
350
  <div>
351
  <label for="ccf-field-slug"><span class="required">*</span> <?php esc_html_e( 'Internal Slug', 'custom-contact-forms' ); ?> (a-z, 0-9, -, _):</label>
352
- <input id="ccf-field-slug" class="field-slug" type="text" value="<%= field.slug %>">
353
  </div>
354
  <div>
355
  <label for="ccf-field-label"><?php esc_html_e( 'Label:', 'custom-contact-forms' ); ?></label>
356
- <input id="ccf-field-label" class="field-label" type="text" value="<%= field.label %>">
357
  </div>
358
  <div>
359
  <label for="ccf-field-value"><?php esc_html_e( 'Initial Value:', 'custom-contact-forms' ); ?></label>
360
- <input id="ccf-field-value" class="field-value" type="text" value="<%= field.value %>">
361
  </div>
362
  <div>
363
  <label for="ccf-field-required"><?php esc_html_e( 'Required:', 'custom-contact-forms' ); ?></label>
@@ -373,11 +373,11 @@ class CCF_Form_Manager {
373
  <div class="section-content">
374
  <div>
375
  <label for="ccf-field-class-name"><?php esc_html_e( 'Class Name:', 'custom-contact-forms' ); ?></label>
376
- <input id="ccf-field-class-name" class="field-class-name" type="text" value="<%= field.className %>">
377
  </div>
378
  <div>
379
  <label for="ccf-field-placeholder"><?php esc_html_e( 'Placeholder Text:', 'custom-contact-forms' ); ?></label>
380
- <input id="ccf-field-placeholder" class="field-placeholder" type="text" value="<%= field.placeholder %>">
381
  </div>
382
  </div>
383
  </div>
@@ -389,11 +389,11 @@ class CCF_Form_Manager {
389
  <div class="section-content">
390
  <div>
391
  <label for="ccf-field-slug"><span class="required">*</span> <?php esc_html_e( 'Internal Slug (a-z, 0-9, -, _):', 'custom-contact-forms' ); ?></label>
392
- <input id="ccf-field-slug" class="field-slug" type="text" value="<%= field.slug %>">
393
  </div>
394
  <div>
395
  <label for="ccf-field-value"><?php esc_html_e( 'Initial Value:', 'custom-contact-forms' ); ?></label>
396
- <input id="ccf-field-value" class="field-value" type="text" value="<%= field.value %>">
397
  </div>
398
  </div>
399
  </div>
@@ -402,7 +402,7 @@ class CCF_Form_Manager {
402
  <div class="section-content">
403
  <div>
404
  <label for="ccf-field-class-name"><?php esc_html_e( 'Class Name:', 'custom-contact-forms' ); ?></label>
405
- <input id="ccf-field-class-name" class="field-class-name" type="text" value="<%= field.className %>">
406
  </div>
407
  </div>
408
  </div>
@@ -414,11 +414,11 @@ class CCF_Form_Manager {
414
  <div class="section-content">
415
  <div>
416
  <label for="ccf-field-slug"><span class="required">*</span> <?php esc_html_e( 'Internal Slug (a-z, 0-9, -, _):', 'custom-contact-forms' ); ?></label>
417
- <input id="ccf-field-slug" class="field-slug" type="text" value="<%= field.slug %>">
418
  </div>
419
  <div>
420
  <label for="ccf-field-label"><?php esc_html_e( 'Label:', 'custom-contact-forms' ); ?></label>
421
- <input id="ccf-field-label" class="field-label" type="text" value="<%= field.label %>">
422
  </div>
423
  <div>
424
  <label for="ccf-field-required"><?php esc_html_e( 'Required:', 'custom-contact-forms' ); ?></label>
@@ -434,7 +434,7 @@ class CCF_Form_Manager {
434
  <div class="section-content">
435
  <div>
436
  <label for="ccf-field-class-name"><?php esc_html_e( 'Class Name:', 'custom-contact-forms' ); ?></label>
437
- <input id="ccf-field-class-name" class="field-class-name" type="text" value="<%= field.className %>">
438
  </div>
439
  </div>
440
  </div>
@@ -446,16 +446,16 @@ class CCF_Form_Manager {
446
  <div class="section-content">
447
  <div>
448
  <label for="ccf-field-slug"><span class="required">*</span> <?php esc_html_e( 'Internal Slug (a-z, 0-9, -, _):', 'custom-contact-forms' ); ?></label>
449
- <input id="ccf-field-slug" class="field-slug" type="text" value="<%= field.slug %>">
450
  </div>
451
  <div>
452
  <label for="ccf-field-label"><?php esc_html_e( 'Label:', 'custom-contact-forms' ); ?></label>
453
- <input id="ccf-field-label" class="field-label" type="text" value="<%= field.label %>">
454
  </div>
455
  <% if ( ! field.showTime ) { %>
456
  <div>
457
  <label for="ccf-field-value"><?php esc_html_e( 'Initial Value:', 'custom-contact-forms' ); ?></label>
458
- <input id="ccf-field-value" class="field-value" type="text" value="<%= field.value %>">
459
  </div>
460
  <% } %>
461
  <div>
@@ -480,12 +480,12 @@ class CCF_Form_Manager {
480
  <div class="section-content">
481
  <div>
482
  <label for="ccf-field-class-name"><?php esc_html_e( 'Class Name:', 'custom-contact-forms' ); ?></label>
483
- <input id="ccf-field-class-name" class="field-class-name" type="text" value="<%= field.className %>">
484
  </div>
485
  <% if ( ! ( field.showTime && field.showDate ) ) { %>
486
  <div>
487
  <label for="ccf-field-placeholder"><?php esc_html_e( 'Placeholder Text:', 'custom-contact-forms' ); ?></label>
488
- <input id="ccf-field-placeholder" class="field-placeholder" type="text" value="<%= field.placeholder %>">
489
  </div>
490
  <% } %>
491
  </div>
@@ -498,15 +498,15 @@ class CCF_Form_Manager {
498
  <div class="section-content">
499
  <div>
500
  <label for="ccf-field-slug"><span class="required">*</span> <?php esc_html_e( 'Internal Slug (a-z, 0-9, -, _):', 'custom-contact-forms' ); ?></label>
501
- <input id="ccf-field-slug" class="field-slug" type="text" value="<%= field.slug %>">
502
  </div>
503
  <div>
504
  <label for="ccf-field-label"><?php esc_html_e( 'Label:', 'custom-contact-forms' ); ?></label>
505
- <input id="ccf-field-label" class="field-label" type="text" value="<%= field.label %>">
506
  </div>
507
  <div>
508
  <label for="ccf-field-value"><?php esc_html_e( 'Initial Value:', 'custom-contact-forms' ); ?></label>
509
- <input id="ccf-field-value" class="field-value" type="text" value="<%= field.value %>">
510
  </div>
511
  <div>
512
  <label for="ccf-field-phone-format"><?php esc_html_e( 'Format:', 'custom-contact-forms' ); ?></label>
@@ -529,11 +529,11 @@ class CCF_Form_Manager {
529
  <div class="section-content">
530
  <div>
531
  <label for="ccf-field-class-name"><?php esc_html_e( 'Class Name:', 'custom-contact-forms' ); ?></label>
532
- <input id="ccf-field-class-name" class="field-class-name" type="text" value="<%= field.className %>">
533
  </div>
534
  <div>
535
  <label for="ccf-field-placeholder"><?php esc_html_e( 'Placeholder Text:', 'custom-contact-forms' ); ?></label>
536
- <input id="ccf-field-placeholder" class="field-placeholder" type="text" value="<%= field.placeholder %>">
537
  </div>
538
  </div>
539
  </div>
@@ -545,11 +545,11 @@ class CCF_Form_Manager {
545
  <div class="section-content">
546
  <div>
547
  <label for="ccf-field-slug"><span class="required">*</span> <?php esc_html_e( 'Internal Slug (a-z, 0-9, -, _):', 'custom-contact-forms' ); ?></label>
548
- <input id="ccf-field-slug" class="field-slug" type="text" value="<%= field.slug %>">
549
  </div>
550
  <div>
551
  <label for="ccf-field-label"><?php esc_html_e( 'Label:', 'custom-contact-forms' ); ?></label>
552
- <input id="ccf-field-label" class="field-label" type="text" value="<%= field.label %>">
553
  </div>
554
  <div>
555
  <label for="ccf-field-address-type"><?php esc_html_e( 'Type:', 'custom-contact-forms' ); ?></label>
@@ -572,7 +572,7 @@ class CCF_Form_Manager {
572
  <div class="section-content">
573
  <div>
574
  <label for="ccf-field-class-name"><?php esc_html_e( 'Class Name:', 'custom-contact-forms' ); ?></label>
575
- <input id="ccf-field-class-name" class="field-class-name" type="text" value="<%= field.className %>">
576
  </div>
577
  </div>
578
  </div>
@@ -584,16 +584,16 @@ class CCF_Form_Manager {
584
  <div class="section-content">
585
  <div>
586
  <label for="ccf-field-slug"><span class="required">*</span> <?php esc_html_e( 'Internal Slug (a-z, 0-9, -, _):', 'custom-contact-forms' ); ?></label>
587
- <input id="ccf-field-slug" class="field-slug" type="text" value="<%= field.slug %>">
588
  </div>
589
  <div>
590
  <label for="ccf-field-label"><?php esc_html_e( 'Label:', 'custom-contact-forms' ); ?></label>
591
- <input id="ccf-field-label" class="field-label" type="text" value="<%= field.label %>">
592
  </div>
593
  <% if ( ! field.emailConfirmation ) { %>
594
  <div>
595
  <label for="ccf-field-value"><?php esc_html_e( 'Initial Value:', 'custom-contact-forms' ); ?></label>
596
- <input id="ccf-field-value" class="field-value" type="text" value="<%= field.value %>">
597
  </div>
598
  <% } %>
599
  <div>
@@ -617,12 +617,12 @@ class CCF_Form_Manager {
617
  <div class="section-content">
618
  <div>
619
  <label for="ccf-field-class-name"><?php esc_html_e( 'Class Name:', 'custom-contact-forms' ); ?></label>
620
- <input id="ccf-field-class-name" class="field-class-name" type="text" value="<%= field.className %>">
621
  </div>
622
  <% if ( ! field.emailConfirmation ) { %>
623
  <div>
624
  <label for="ccf-field-placeholder"><?php esc_html_e( 'Placeholder Text:', 'custom-contact-forms' ); ?></label>
625
- <input id="ccf-field-placeholder" class="field-placeholder" type="text" value="<%= field.placeholder %>">
626
  </div>
627
  <% } %>
628
  </div>
@@ -632,8 +632,8 @@ class CCF_Form_Manager {
632
  <script type="text/html" id="ccf-field-choice-template">
633
  <a aria-hidden="true" data-icon="&#xe606;" class="move"></a>
634
  <input class="choice-selected" <% if ( choice.selected ) { %>checked<% } %> name="selected" type="checkbox" value="1">
635
- <input class="choice-label" type="text" placeholder="<?php esc_html_e( 'Label', 'custom-contact-forms' ); ?>" value="<%= choice.label %>">
636
- <input class="choice-value" type="text" placeholder="<?php esc_html_e( 'Value', 'custom-contact-forms' ); ?>" value="<%= choice.value %>">
637
  <a aria-hidden="true" data-icon="&#xe605;" class="add"></a>
638
  <a aria-hidden="true" data-icon="&#xe604;" class="delete"></a>
639
  </script>
@@ -644,11 +644,11 @@ class CCF_Form_Manager {
644
  <div class="section-content">
645
  <div>
646
  <label for="ccf-field-slug"><span class="required">*</span> <?php esc_html_e( 'Internal Slug (a-z, 0-9, -, _):', 'custom-contact-forms' ); ?></label>
647
- <input id="ccf-field-slug" class="field-slug" type="text" value="<%= field.slug %>">
648
  </div>
649
  <div>
650
  <label for="ccf-field-label"><?php esc_html_e( 'Label:', 'custom-contact-forms' ); ?></label>
651
- <input id="ccf-field-label" class="field-label" type="text" value="<%= field.label %>">
652
  </div>
653
  <div>
654
  <label for="ccf-field-required"><?php esc_html_e( 'Required:', 'custom-contact-forms' ); ?></label>
@@ -669,7 +669,7 @@ class CCF_Form_Manager {
669
  <div class="section-content">
670
  <div>
671
  <label for="ccf-field-class-name"><?php esc_html_e( 'Class Name:', 'custom-contact-forms' ); ?></label>
672
- <input id="ccf-field-class-name" class="field-class-name" type="text" value="<%= field.className %>">
673
  </div>
674
  </div>
675
  </div>
@@ -681,11 +681,11 @@ class CCF_Form_Manager {
681
  <div class="section-content">
682
  <div>
683
  <label for="ccf-field-slug"><span class="required">*</span> <?php esc_html_e( 'Internal Slug (a-z, 0-9, -, _):', 'custom-contact-forms' ); ?></label>
684
- <input id="ccf-field-slug" class="field-slug" type="text" value="<%= field.slug %>">
685
  </div>
686
  <div>
687
  <label for="ccf-field-label"><?php esc_html_e( 'Label:', 'custom-contact-forms' ); ?></label>
688
- <input id="ccf-field-label" class="field-label" type="text" value="<%= field.label %>">
689
  </div>
690
  <div>
691
  <label for="ccf-field-required"><?php esc_html_e( 'Required:', 'custom-contact-forms' ); ?></label>
@@ -706,7 +706,7 @@ class CCF_Form_Manager {
706
  <div class="section-content">
707
  <div>
708
  <label for="ccf-field-class-name"><?php esc_html_e( 'Class Name:', 'custom-contact-forms' ); ?></label>
709
- <input id="ccf-field-class-name" class="field-class-name" type="text" value="<%= field.className %>">
710
  </div>
711
  </div>
712
  </div>
@@ -718,11 +718,11 @@ class CCF_Form_Manager {
718
  <div class="section-content">
719
  <div>
720
  <label for="ccf-field-slug"><span class="required">*</span> <?php esc_html_e( 'Internal Slug (a-z, 0-9, -, _):', 'custom-contact-forms' ); ?></label>
721
- <input id="ccf-field-slug" class="field-slug" type="text" value="<%= field.slug %>">
722
  </div>
723
  <div>
724
  <label for="ccf-field-label"><?php esc_html_e( 'Label:', 'custom-contact-forms' ); ?></label>
725
- <input id="ccf-field-label" class="field-label" type="text" value="<%= field.label %>">
726
  </div>
727
  <div>
728
  <label for="ccf-field-required"><?php esc_html_e( 'Required:', 'custom-contact-forms' ); ?></label>
@@ -743,7 +743,7 @@ class CCF_Form_Manager {
743
  <div class="section-content">
744
  <div>
745
  <label for="ccf-field-class-name"><?php esc_html_e( 'Class Name:', 'custom-contact-forms' ); ?></label>
746
- <input id="ccf-field-class-name" class="field-class-name" type="text" value="<%= field.className %>">
747
  </div>
748
  </div>
749
  </div>
@@ -756,30 +756,30 @@ class CCF_Form_Manager {
756
  </script>
757
 
758
  <script type="text/html" id="ccf-single-line-text-preview-template">
759
- <label><%= field.label %> <% if ( field.required ) { %><span>*</span><% } %></label>
760
- <input disabled type="text" placeholder="<%= field.placeholder %>" value="<%= field.value %>">
761
  </script>
762
 
763
  <script type="text/html" id="ccf-paragraph-text-preview-template">
764
- <label><%= field.label %> <% if ( field.required ) { %><span>*</span><% } %></label>
765
- <textarea placeholder="<%= field.placeholder %>" disabled><%= field.value %></textarea>
766
  </script>
767
 
768
  <script type="text/html" id="ccf-dropdown-preview-template">
769
- <label><%= field.label %> <% if ( field.required ) { %><span>*</span><% } %></label>
770
  <select>
771
  <% if ( field.choices.length === 0 || ( field.choices.length === 1 && ! field.choices.at( 0 ).get( 'label' ) && ! field.choices.at( 0 ).get( 'value' ) ) ) { %>
772
  <option><?php esc_html_e( 'An example choice', 'custom-contact-forms' ); ?></option>
773
  <%} else { %>
774
  <% field.choices.each( function( choice ) { %>
775
- <option value="<%= choice.get( 'value' ) %>"><%= choice.get( 'label' ) %></option>
776
  <% }); %>
777
  <% } %>
778
  </select>
779
  </script>
780
 
781
  <script type="text/html" id="ccf-radio-preview-template">
782
- <label><%= field.label %> <% if ( field.required ) { %><span>*</span><% } %></label>
783
  <% if ( field.choices.length === 0 || ( field.choices.length === 1 && ! field.choices.at( 0 ).get( 'label' ) && ! field.choices.at( 0 ).get( 'value' ) ) ) { %>
784
  <div>
785
  <input type="radio" value="1" checked="checked"> <label><?php esc_html_e( 'An example choice', 'custom-contact-forms' ); ?></label>
@@ -787,14 +787,14 @@ class CCF_Form_Manager {
787
  <%} else { %>
788
  <% field.choices.each( function( choice ) { %>
789
  <div class="choice">
790
- <input type="radio" value="<%= choice.get( 'value' ) %>" <% if ( choice.get( 'selected' ) ) { %>checked="checked"<% } %>> <label><%= choice.get( 'label' ) %></label>
791
  </div>
792
  <% }); %>
793
  <% } %>
794
  </script>
795
 
796
  <script type="text/html" id="ccf-checkboxes-preview-template">
797
- <label><%= field.label %> <% if ( field.required ) { %><span>*</span><% } %></label>
798
  <% if ( field.choices.length === 0 || ( field.choices.length === 1 && ! field.choices.at( 0 ).get( 'label' ) && ! field.choices.at( 0 ).get( 'value' ) ) ) { %>
799
  <div>
800
  <input type="checkbox" value="1" checked="checked"> <label><?php esc_html_e( 'An example choice', 'custom-contact-forms' ); ?></label>
@@ -802,7 +802,7 @@ class CCF_Form_Manager {
802
  <%} else { %>
803
  <% field.choices.each( function( choice ) { %>
804
  <div class="choice">
805
- <input type="checkbox" value="<%= choice.get( 'value' ) %>" <% if ( choice.get( 'selected' ) ) { %>checked="checked"<% } %>> <label><%= choice.get( 'label' ) %></label>
806
  </div>
807
  <% }); %>
808
  <% } %>
@@ -818,13 +818,13 @@ class CCF_Form_Manager {
818
 
819
  <script type="text/html" id="ccf-section-header-preview-template">
820
  <div class="heading">
821
- <% if ( field.heading ) { %><%= field.heading %><% } else { %><?php esc_html_e( 'Section Heading', 'custom-contact-forms' ); ?><% } %>
822
  </div>
823
- <div class="subheading"><% if ( field.subheading ) { %><%= field.subheading %><% } else { %><?php esc_html_e( 'This is the sub-heading text.', 'custom-contact-forms' ); ?><% } %></div>
824
  </script>
825
 
826
  <script type="text/html" id="ccf-name-preview-template">
827
- <label><%= field.label %> <% if ( field.required ) { %><span>*</span><% } %></label>
828
  <div class="left">
829
  <input type="text">
830
  <label class="sub-label"><?php esc_html_e( 'First', 'custom-contact-forms' ); ?></label>
@@ -836,9 +836,9 @@ class CCF_Form_Manager {
836
  </script>
837
 
838
  <script type="text/html" id="ccf-date-preview-template">
839
- <label><%= field.label %> <% if ( field.required ) { %><span>*</span><% } %></label>
840
  <% if ( field.showDate && ! field.showTime ) { %>
841
- <input value="<%= field.value %>" class="ccf-datepicker" disabled type="text">
842
  <% } else if ( ! field.showDate && field.showTime ) { %>
843
  <div class="full">
844
  <div class="hour">
@@ -881,7 +881,7 @@ class CCF_Form_Manager {
881
  </script>
882
 
883
  <script type="text/html" id="ccf-address-preview-template">
884
- <label><%= field.label %> <% if ( field.required ) { %><span>*</span><% } %></label>
885
  <% if ( field.addressType === 'us' ) { %>
886
  <div class="full">
887
  <input type="text">
@@ -940,9 +940,9 @@ class CCF_Form_Manager {
940
  </script>
941
 
942
  <script type="text/html" id="ccf-email-preview-template">
943
- <label><%= field.label %> <% if ( field.required ) { %><span>*</span><% } %></label>
944
  <% if ( ! field.emailConfirmation ) { %>
945
- <input placeholder="<% if ( field.placeholder ) { %><%= field.placeholder %><% } else { %><?php esc_html_e( 'email@example.com', 'custom-contact-forms' ); ?><% } %>" disabled type="text" value="<%= field.value %>">
946
  <% } else { %>
947
  <div class="left">
948
  <input type="text">
@@ -956,34 +956,34 @@ class CCF_Form_Manager {
956
  </script>
957
 
958
  <script type="text/html" id="ccf-website-preview-template">
959
- <label><%= field.label %> <% if ( field.required ) { %><span>*</span><% } %></label>
960
- <input placeholder="<% if ( field.placeholder ) { %><%= field.placeholder %><% } else { %>http://<% } %>" disabled type="text" value="<%= field.value %>">
961
  </script>
962
 
963
  <script type="text/html" id="ccf-phone-preview-template">
964
- <label><%= field.label %> <% if ( field.required ) { %><span>*</span><% } %></label>
965
- <input placeholder="<% if ( field.placeholder ) { %><%= field.placeholder %><% } else { %>(301) 101-8976<% } %>" disabled type="text" value="<%= field.value %>">
966
  </script>
967
 
968
  <script type="text/html" id="ccf-existing-form-table-row-template">
969
 
970
- <td><%= form.ID %></td>
971
  <td>
972
- <a class="edit edit-form title" data-view="form-pane" data-form-id="<%= form.ID %>" href="#form-pane-<%= form.ID %>"><% if ( form.title ) { %><%= form.title %><% } else { %><%= '<?php esc_html_e( '(No title)', 'custom-contact-forms' ); ?>' %><% } %></a>
973
  <div class="actions">
974
- <a class="edit edit-form" data-view="form-pane" data-form-id="<%= form.ID %>" href="#form-pane-<%= form.ID %>"><?php esc_html_e( 'Edit', 'custom-contact-forms' ); ?></a> |
975
  <a class="insert-form-button"><?php esc_html_e( 'Insert into post', 'custom-contact-forms' ); ?></a> |
976
  <a class="delete"><?php esc_html_e( 'Trash', 'custom-contact-forms' ); ?></a>
977
  </div>
978
  </td>
979
  <td>
980
- <%= utils.getPrettyPostDate( form.date ) %>
981
  </td>
982
  <td>
983
- <%= form.author.username %>
984
  </td>
985
  <td>
986
- <%= form.fields.length %>
987
  </td>
988
  <td>
989
  0
@@ -991,25 +991,25 @@ class CCF_Form_Manager {
991
  </script>
992
 
993
  <script type="text/html" id="ccf-form-mce-preview">
994
- <div class="ccf-form-preview form-id-<%= form.ID %>">
995
  <% if ( form.title ) { %>
996
- <h2><%= form.title %></h2>
997
  <% } %>
998
 
999
  <% if ( form.description && form.description != '' ) { %>
1000
- <p><%= form.description %></p>
1001
  <% } %>
1002
 
1003
  <% if ( form.fields ) { %>
1004
  <% _.each( form.fields, function( field ) { %>
1005
- <div class="field <%= field.type %> field-<%= field.ID %>">
1006
  <%= field.preview %>
1007
  </div>
1008
  <% } ); %>
1009
  <% } %>
1010
 
1011
  <div class="field-submit">
1012
- <input type="button" value="<%= form.buttonText %>">
1013
  </div>
1014
  </div>
1015
  </script>
@@ -1025,11 +1025,11 @@ class CCF_Form_Manager {
1025
  <thead>
1026
  <tr>
1027
  <% _.each( columns, function( column ) { %>
1028
- <th scope="col" class="manage-column column-<%= column %>">
1029
  <% if ( 'date' === column ) { %>
1030
  <?php esc_html_e( 'Date', 'custom-contact-forms' ); ?>
1031
  <% } else { %>
1032
- <%= column %>
1033
  <% } %>
1034
  </th>
1035
  <% } ); %>
@@ -1039,11 +1039,11 @@ class CCF_Form_Manager {
1039
  <tfoot>
1040
  <tr>
1041
  <% _.each( columns, function( column ) { %>
1042
- <th scope="col" class="manage-column column-<%= column %>">
1043
  <% if ( 'date' === column ) { %>
1044
  <?php esc_html_e( 'Date', 'custom-contact-forms' ); ?>
1045
  <% } else { %>
1046
- <%= column %>
1047
  <% } %>
1048
  </th>
1049
  <% } ); %>
@@ -1053,7 +1053,7 @@ class CCF_Form_Manager {
1053
 
1054
  <tbody class="submission-rows">
1055
  <tr>
1056
- <td colspan="<%= columns.length + 1 %>">
1057
  <div class="spinner"></div>
1058
  </td>
1059
  </tr>
@@ -1065,17 +1065,17 @@ class CCF_Form_Manager {
1065
  <script type="text/html" id="ccf-submission-row-template">
1066
  <% _.each( currentColumns, function( column ) { %>
1067
  <% if ( 'date' === column ) { %>
1068
- <td colspan="1"><%= utils.getPrettyPostDate( submission.date ) %></td>
1069
  <% } else { %>
1070
  <td colspan="1">
1071
  <% if ( submission.data[column] ) { %>
1072
  <% if ( submission.data[column] instanceof Object ) { var output = '', i = 0; %>
1073
  <% if ( utils.isFieldDate( submission.data[column] ) ) { %>
1074
- <%= utils.getPrettyFieldDate( submission.data[column] ) %>
1075
  <% } else if ( utils.isFieldName( submission.data[column] ) ) { %>
1076
- <%= utils.getPrettyFieldName( submission.data[column] ) %>
1077
  <% } else if ( utils.isFieldAddress( submission.data[column] ) ) { %>
1078
- <%= utils.wordChop( utils.getPrettyFieldAddress( submission.data[column] ), 30 ) %>
1079
  <% } else { %>
1080
  <% for ( var key in submission.data[column] ) { if ( submission.data[column].hasOwnProperty( key ) ) {
1081
  if ( i > 0 ) {
@@ -1085,10 +1085,10 @@ class CCF_Form_Manager {
1085
 
1086
  i++;
1087
  } } %>
1088
- <%= utils.wordChop( output, 30 ) %>
1089
  <% } %>
1090
  <% } else { %>
1091
- <%= utils.wordChop( submission.data[column] ) %>
1092
  <% } %>
1093
  <% } else { %>
1094
  <span><?php esc_html_e( '-', 'custom-contact-forms' ); ?></span>
@@ -1097,31 +1097,31 @@ class CCF_Form_Manager {
1097
  <% } %>
1098
  <% } ); %>
1099
  <td class="actions">
1100
- <a href="#TB_inline?height=300&amp;width=400&amp;inlineId=submission-content" data-submission-date="<%= submission.date %>" data-submission-id="<%= submission.ID %>" class="view" data-icon="&#xe601;"></a>
1101
  <a class="delete" data-icon="&#xe602;"></a>
1102
 
1103
- <div class="submission-wrapper" id="ccf-submission-content-<%= submission.ID %>">
1104
  <div class="ccf-submission-content">
1105
  <% for ( column in submission.data ) { %>
1106
  <div class="field-slug">
1107
- <%= column %>
1108
  </div>
1109
  <div class="field-content">
1110
  <% if ( submission.data[column] ) { %>
1111
  <% if ( submission.data[column] instanceof Object ) { %>
1112
  <% if ( utils.isFieldDate( submission.data[column] ) ) { %>
1113
- <%= utils.getPrettyFieldDate( submission.data[column] ) %>
1114
  <% } else if ( utils.isFieldName( submission.data[column] ) ) { %>
1115
- <%= utils.getPrettyFieldName( submission.data[column] ) %>
1116
  <% } else if ( utils.isFieldAddress( submission.data[column] ) ) { %>
1117
- <%= utils.getPrettyFieldAddress( submission.data[column] ) %>
1118
  <% } else { %>
1119
  <% for ( var key in submission.data[column] ) { if ( submission.data[column].hasOwnProperty( key ) ) { %>
1120
- <% if ( isNaN( key ) ) { %><strong><%= key %>:</strong> <% } %><%= submission.data[column][key] %><br>
1121
  <% } } %>
1122
  <% } %>
1123
  <% } else { %>
1124
- <%= submission.data[column] %>
1125
  <% } %>
1126
  <% } else { %>
1127
  <span>-</span>
@@ -1135,18 +1135,18 @@ class CCF_Form_Manager {
1135
 
1136
 
1137
  <script type="text/html" id="ccf-no-submissions-row-template">
1138
- <td colspan="<%= columns.length + 1 %>" class="no-submissions"><?php esc_html_e( 'There are no submissions.', 'custom-contact-forms' ); ?></td>
1139
  </script>
1140
 
1141
  <script type="text/html" id="ccf-submissions-controller-template">
1142
  <% var i = 0; _.each( columns, function( column ) { %>
1143
 
1144
- <label for="ccf-column-<%= column %>">
1145
- <input class="submission-column-checkbox" type="checkbox" id="ccf-column-<%= column %>" <% if ( i < 4 || 'date' === column ) { %>checked<% } %> value="<%= column %>">
1146
  <% if ( 'date' === column ) { %>
1147
  <?php esc_html_e( 'Date', 'custom-contact-forms' ); ?>
1148
  <% } else { %>
1149
- <%= column %>
1150
  <% } %>
1151
  </label>
1152
 
68
  <div class="right">
69
  <a aria-hidden="true" data-icon="&#xe602;" class="delete"></a>
70
  </div>
71
+ <span class="label"><%- label %></span>
72
  </h4>
73
 
74
  <div class="preview"></div>
118
  <div class="section-content">
119
  <p>
120
  <label for="ccf_form_title"><?php esc_html_e( 'Form Title:', 'custom-contact-forms' ); ?></label>
121
+ <input class="widefat form-title" id="ccf_form_title" name="title" type="text" value="<%- form.title %>">
122
  </p>
123
 
124
  <p>
125
  <label for="ccf_form_description"><?php esc_html_e( 'Form Description:', 'custom-contact-forms' ); ?></label>
126
+ <textarea class="widefat form-description" id="ccf_form_description" name="description"><%- form.description %></textarea>
127
  </p>
128
 
129
  <p>
130
  <label for="ccf_form_button_text"><?php esc_html_e( 'Button Text:', 'custom-contact-forms' ); ?></label>
131
+ <input class="widefat form-button-text" id="ccf_form_button_text" name="text" type="text" value="<%- form.buttonText %>">
132
  </p>
133
 
134
  <p>
141
  </p>
142
  <p class="completion-redirect-url">
143
  <label for="ccf_form_completion_redirect_url"><?php esc_html_e( 'Redirect URL:', 'custom-contact-forms' ); ?></label>
144
+ <input class="widefat form-completion-redirect-url" id="ccf_form_completion_redirect_url" name="text" type="text" value="<%- form.completionRedirectUrl %>">
145
  </p>
146
  <p class="completion-message">
147
  <label for="ccf_form_completion_message"><?php esc_html_e( 'Completion Message:', 'custom-contact-forms' ); ?></label>
148
+ <textarea class="widefat form-completion-message" id="ccf_form_completion_message" name="completion-message"><%- form.completionMessage %></textarea>
149
  </p>
150
 
151
  <p>
158
  </p>
159
  <p class="email-notification-addresses">
160
  <label for="ccf_form_email_notification_addresses"><?php esc_html_e( 'Email Addresses (comma separated):', 'custom-contact-forms' ); ?></label>
161
+ <input class="widefat form-email-notification-addresses" id="ccf_form_email_notification_addresses" name="email-notification-addresses" value="<%- form.emailNotificationAddresses %>">
162
  </p>
163
  </div>
164
  </script>
170
  </script>
171
 
172
  <script type="text/html" id="ccf-pagination-template">
173
+ <span class="num-items"><%- totalObjects %> <?php esc_html_e( 'items', 'custom-contact-forms' ); ?></span>
174
 
175
  <a class="first <% if ( currentPage <= 1 ) { %>disabled<% } %>">&laquo;</a>
176
  <a class="prev <% if ( currentPage <= 1 ) { %>disabled<% } %>">&lsaquo;</a>
177
 
178
+ <span class="pages"><%- currentPage %> of <%- totalPages %></span>
179
 
180
  <a class="next <% if ( currentPage >= totalPages ) { %>disabled<% } %>">&rsaquo;</a>
181
  <a class="last <% if ( currentPage >= totalPages ) { %>disabled<% } %>">&raquo;</a>
223
  <div class="section-content">
224
  <div>
225
  <label for="ccf-field-slug"><span class="required">*</span> <?php esc_html_e( 'Internal Slug', 'custom-contact-forms' ); ?> (a-z, 0-9, -, _):</label>
226
+ <input id="ccf-field-slug" class="field-slug" type="text" value="<%- field.slug %>">
227
  </div>
228
  <div>
229
  <label for="ccf-field-label"><?php esc_html_e( 'Label:', 'custom-contact-forms' ); ?></label>
230
+ <input id="ccf-field-label" class="field-label" type="text" value="<%- field.label %>">
231
  </div>
232
  <div>
233
  <label for="ccf-field-value"><?php esc_html_e( 'Initial Value:', 'custom-contact-forms' ); ?></label>
234
+ <input id="ccf-field-value" class="field-value" type="text" value="<%- field.value %>">
235
  </div>
236
  <div>
237
  <label for="ccf-field-required"><?php esc_html_e( 'Required:', 'custom-contact-forms' ); ?></label>
247
  <div class="section-content">
248
  <div>
249
  <label for="ccf-field-class-name"><?php esc_html_e( 'Class Name:', 'custom-contact-forms' ); ?></label>
250
+ <input id="ccf-field-class-name" class="field-class-name" type="text" value="<%- field.className %>">
251
  </div>
252
  <div>
253
  <label for="ccf-field-placeholder"><?php esc_html_e( 'Placeholder Text:', 'custom-contact-forms' ); ?></label>
254
+ <input id="ccf-field-placeholder" class="field-placeholder" type="text" value="<%- field.placeholder %>">
255
  </div>
256
  </div>
257
  </div>
263
  <div class="section-content">
264
  <div>
265
  <label for="ccf-field-slug"><span class="required">*</span> <?php esc_html_e( 'Internal Slug', 'custom-contact-forms' ); ?> (a-z, 0-9, -, _):</label>
266
+ <input id="ccf-field-slug" class="field-slug" type="text" value="<%- field.slug %>">
267
  </div>
268
  <div>
269
  <label for="ccf-field-label"><?php esc_html_e( 'Label:', 'custom-contact-forms' ); ?></label>
270
+ <input id="ccf-field-label" class="field-label" type="text" value="<%- field.label %>">
271
  </div>
272
  <div>
273
  <label for="ccf-field-value"><?php esc_html_e( 'Initial Value:', 'custom-contact-forms' ); ?></label>
274
+ <input id="ccf-field-value" class="field-value" type="text" value="<%- field.value %>">
275
  </div>
276
  <div>
277
  <label for="ccf-field-required"><?php esc_html_e( 'Required:', 'custom-contact-forms' ); ?></label>
287
  <div class="section-content">
288
  <div>
289
  <label for="ccf-field-class-name"><?php esc_html_e( 'Class Name:', 'custom-contact-forms' ); ?></label>
290
+ <input id="ccf-field-class-name" class="field-class-name" type="text" value="<%- field.className %>">
291
  </div>
292
  <div>
293
  <label for="ccf-field-placeholder"><?php esc_html_e( 'Placeholder Text:', 'custom-contact-forms' ); ?></label>
294
+ <input id="ccf-field-placeholder" class="field-placeholder" type="text" value="<%- field.placeholder %>">
295
  </div>
296
  </div>
297
  </div>
303
  <div class="section-content">
304
  <div>
305
  <label for="ccf-field-html"><?php esc_html_e( 'HTML Content:', 'custom-contact-forms' ); ?></label>
306
+ <textarea id="ccf-field-html" class="field-html"><%- field.html %></textarea>
307
  </div>
308
  </div>
309
  </div>
312
  <div class="section-content">
313
  <div>
314
  <label for="ccf-field-class-name"><?php esc_html_e( 'Class Name:', 'custom-contact-forms' ); ?></label>
315
+ <input id="ccf-field-class-name" class="field-class-name" type="text" value="<%- field.className %>">
316
  </div>
317
  </div>
318
  </div>
324
  <div class="section-content">
325
  <div>
326
  <label for="ccf-field-heading"><?php esc_html_e( 'Heading:', 'custom-contact-forms' ); ?></label>
327
+ <input id="ccf-field-heading" class="field-heading" type="text" value="<%- field.heading %>">
328
  </div>
329
  <div>
330
  <label for="ccf-field-subheading"><?php esc_html_e( 'Sub Heading:', 'custom-contact-forms' ); ?></label>
331
+ <textarea id="ccf-field-subheading" class="field-subheading" type="text"><%- field.subheading %></textarea>
332
  </div>
333
  </div>
334
  </div>
337
  <div class="section-content">
338
  <div>
339
  <label for="ccf-field-class-name"><?php esc_html_e( 'Class Name:', 'custom-contact-forms' ); ?></label>
340
+ <input id="ccf-field-class-name" class="field-class-name" type="text" value="<%- field.className %>">
341
  </div>
342
  </div>
343
  </div>
349
  <div class="section-content">
350
  <div>
351
  <label for="ccf-field-slug"><span class="required">*</span> <?php esc_html_e( 'Internal Slug', 'custom-contact-forms' ); ?> (a-z, 0-9, -, _):</label>
352
+ <input id="ccf-field-slug" class="field-slug" type="text" value="<%- field.slug %>">
353
  </div>
354
  <div>
355
  <label for="ccf-field-label"><?php esc_html_e( 'Label:', 'custom-contact-forms' ); ?></label>
356
+ <input id="ccf-field-label" class="field-label" type="text" value="<%- field.label %>">
357
  </div>
358
  <div>
359
  <label for="ccf-field-value"><?php esc_html_e( 'Initial Value:', 'custom-contact-forms' ); ?></label>
360
+ <input id="ccf-field-value" class="field-value" type="text" value="<%- field.value %>">
361
  </div>
362
  <div>
363
  <label for="ccf-field-required"><?php esc_html_e( 'Required:', 'custom-contact-forms' ); ?></label>
373
  <div class="section-content">
374
  <div>
375
  <label for="ccf-field-class-name"><?php esc_html_e( 'Class Name:', 'custom-contact-forms' ); ?></label>
376
+ <input id="ccf-field-class-name" class="field-class-name" type="text" value="<%- field.className %>">
377
  </div>
378
  <div>
379
  <label for="ccf-field-placeholder"><?php esc_html_e( 'Placeholder Text:', 'custom-contact-forms' ); ?></label>
380
+ <input id="ccf-field-placeholder" class="field-placeholder" type="text" value="<%- field.placeholder %>">
381
  </div>
382
  </div>
383
  </div>
389
  <div class="section-content">
390
  <div>
391
  <label for="ccf-field-slug"><span class="required">*</span> <?php esc_html_e( 'Internal Slug (a-z, 0-9, -, _):', 'custom-contact-forms' ); ?></label>
392
+ <input id="ccf-field-slug" class="field-slug" type="text" value="<%- field.slug %>">
393
  </div>
394
  <div>
395
  <label for="ccf-field-value"><?php esc_html_e( 'Initial Value:', 'custom-contact-forms' ); ?></label>
396
+ <input id="ccf-field-value" class="field-value" type="text" value="<%- field.value %>">
397
  </div>
398
  </div>
399
  </div>
402
  <div class="section-content">
403
  <div>
404
  <label for="ccf-field-class-name"><?php esc_html_e( 'Class Name:', 'custom-contact-forms' ); ?></label>
405
+ <input id="ccf-field-class-name" class="field-class-name" type="text" value="<%- field.className %>">
406
  </div>
407
  </div>
408
  </div>
414
  <div class="section-content">
415
  <div>
416
  <label for="ccf-field-slug"><span class="required">*</span> <?php esc_html_e( 'Internal Slug (a-z, 0-9, -, _):', 'custom-contact-forms' ); ?></label>
417
+ <input id="ccf-field-slug" class="field-slug" type="text" value="<%- field.slug %>">
418
  </div>
419
  <div>
420
  <label for="ccf-field-label"><?php esc_html_e( 'Label:', 'custom-contact-forms' ); ?></label>
421
+ <input id="ccf-field-label" class="field-label" type="text" value="<%- field.label %>">
422
  </div>
423
  <div>
424
  <label for="ccf-field-required"><?php esc_html_e( 'Required:', 'custom-contact-forms' ); ?></label>
434
  <div class="section-content">
435
  <div>
436
  <label for="ccf-field-class-name"><?php esc_html_e( 'Class Name:', 'custom-contact-forms' ); ?></label>
437
+ <input id="ccf-field-class-name" class="field-class-name" type="text" value="<%- field.className %>">
438
  </div>
439
  </div>
440
  </div>
446
  <div class="section-content">
447
  <div>
448
  <label for="ccf-field-slug"><span class="required">*</span> <?php esc_html_e( 'Internal Slug (a-z, 0-9, -, _):', 'custom-contact-forms' ); ?></label>
449
+ <input id="ccf-field-slug" class="field-slug" type="text" value="<%- field.slug %>">
450
  </div>
451
  <div>
452
  <label for="ccf-field-label"><?php esc_html_e( 'Label:', 'custom-contact-forms' ); ?></label>
453
+ <input id="ccf-field-label" class="field-label" type="text" value="<%- field.label %>">
454
  </div>
455
  <% if ( ! field.showTime ) { %>
456
  <div>
457
  <label for="ccf-field-value"><?php esc_html_e( 'Initial Value:', 'custom-contact-forms' ); ?></label>
458
+ <input id="ccf-field-value" class="field-value" type="text" value="<%- field.value %>">
459
  </div>
460
  <% } %>
461
  <div>
480
  <div class="section-content">
481
  <div>
482
  <label for="ccf-field-class-name"><?php esc_html_e( 'Class Name:', 'custom-contact-forms' ); ?></label>
483
+ <input id="ccf-field-class-name" class="field-class-name" type="text" value="<%- field.className %>">
484
  </div>
485
  <% if ( ! ( field.showTime && field.showDate ) ) { %>
486
  <div>
487
  <label for="ccf-field-placeholder"><?php esc_html_e( 'Placeholder Text:', 'custom-contact-forms' ); ?></label>
488
+ <input id="ccf-field-placeholder" class="field-placeholder" type="text" value="<%- field.placeholder %>">
489
  </div>
490
  <% } %>
491
  </div>
498
  <div class="section-content">
499
  <div>
500
  <label for="ccf-field-slug"><span class="required">*</span> <?php esc_html_e( 'Internal Slug (a-z, 0-9, -, _):', 'custom-contact-forms' ); ?></label>
501
+ <input id="ccf-field-slug" class="field-slug" type="text" value="<%- field.slug %>">
502
  </div>
503
  <div>
504
  <label for="ccf-field-label"><?php esc_html_e( 'Label:', 'custom-contact-forms' ); ?></label>
505
+ <input id="ccf-field-label" class="field-label" type="text" value="<%- field.label %>">
506
  </div>
507
  <div>
508
  <label for="ccf-field-value"><?php esc_html_e( 'Initial Value:', 'custom-contact-forms' ); ?></label>
509
+ <input id="ccf-field-value" class="field-value" type="text" value="<%- field.value %>">
510
  </div>
511
  <div>
512
  <label for="ccf-field-phone-format"><?php esc_html_e( 'Format:', 'custom-contact-forms' ); ?></label>
529
  <div class="section-content">
530
  <div>
531
  <label for="ccf-field-class-name"><?php esc_html_e( 'Class Name:', 'custom-contact-forms' ); ?></label>
532
+ <input id="ccf-field-class-name" class="field-class-name" type="text" value="<%- field.className %>">
533
  </div>
534
  <div>
535
  <label for="ccf-field-placeholder"><?php esc_html_e( 'Placeholder Text:', 'custom-contact-forms' ); ?></label>
536
+ <input id="ccf-field-placeholder" class="field-placeholder" type="text" value="<%- field.placeholder %>">
537
  </div>
538
  </div>
539
  </div>
545
  <div class="section-content">
546
  <div>
547
  <label for="ccf-field-slug"><span class="required">*</span> <?php esc_html_e( 'Internal Slug (a-z, 0-9, -, _):', 'custom-contact-forms' ); ?></label>
548
+ <input id="ccf-field-slug" class="field-slug" type="text" value="<%- field.slug %>">
549
  </div>
550
  <div>
551
  <label for="ccf-field-label"><?php esc_html_e( 'Label:', 'custom-contact-forms' ); ?></label>
552
+ <input id="ccf-field-label" class="field-label" type="text" value="<%- field.label %>">
553
  </div>
554
  <div>
555
  <label for="ccf-field-address-type"><?php esc_html_e( 'Type:', 'custom-contact-forms' ); ?></label>
572
  <div class="section-content">
573
  <div>
574
  <label for="ccf-field-class-name"><?php esc_html_e( 'Class Name:', 'custom-contact-forms' ); ?></label>
575
+ <input id="ccf-field-class-name" class="field-class-name" type="text" value="<%- field.className %>">
576
  </div>
577
  </div>
578
  </div>
584
  <div class="section-content">
585
  <div>
586
  <label for="ccf-field-slug"><span class="required">*</span> <?php esc_html_e( 'Internal Slug (a-z, 0-9, -, _):', 'custom-contact-forms' ); ?></label>
587
+ <input id="ccf-field-slug" class="field-slug" type="text" value="<%- field.slug %>">
588
  </div>
589
  <div>
590
  <label for="ccf-field-label"><?php esc_html_e( 'Label:', 'custom-contact-forms' ); ?></label>
591
+ <input id="ccf-field-label" class="field-label" type="text" value="<%- field.label %>">
592
  </div>
593
  <% if ( ! field.emailConfirmation ) { %>
594
  <div>
595
  <label for="ccf-field-value"><?php esc_html_e( 'Initial Value:', 'custom-contact-forms' ); ?></label>
596
+ <input id="ccf-field-value" class="field-value" type="text" value="<%- field.value %>">
597
  </div>
598
  <% } %>
599
  <div>
617
  <div class="section-content">
618
  <div>
619
  <label for="ccf-field-class-name"><?php esc_html_e( 'Class Name:', 'custom-contact-forms' ); ?></label>
620
+ <input id="ccf-field-class-name" class="field-class-name" type="text" value="<%- field.className %>">
621
  </div>
622
  <% if ( ! field.emailConfirmation ) { %>
623
  <div>
624
  <label for="ccf-field-placeholder"><?php esc_html_e( 'Placeholder Text:', 'custom-contact-forms' ); ?></label>
625
+ <input id="ccf-field-placeholder" class="field-placeholder" type="text" value="<%- field.placeholder %>">
626
  </div>
627
  <% } %>
628
  </div>
632
  <script type="text/html" id="ccf-field-choice-template">
633
  <a aria-hidden="true" data-icon="&#xe606;" class="move"></a>
634
  <input class="choice-selected" <% if ( choice.selected ) { %>checked<% } %> name="selected" type="checkbox" value="1">
635
+ <input class="choice-label" type="text" placeholder="<?php esc_html_e( 'Label', 'custom-contact-forms' ); ?>" value="<%- choice.label %>">
636
+ <input class="choice-value" type="text" placeholder="<?php esc_html_e( 'Value', 'custom-contact-forms' ); ?>" value="<%- choice.value %>">
637
  <a aria-hidden="true" data-icon="&#xe605;" class="add"></a>
638
  <a aria-hidden="true" data-icon="&#xe604;" class="delete"></a>
639
  </script>
644
  <div class="section-content">
645
  <div>
646
  <label for="ccf-field-slug"><span class="required">*</span> <?php esc_html_e( 'Internal Slug (a-z, 0-9, -, _):', 'custom-contact-forms' ); ?></label>
647
+ <input id="ccf-field-slug" class="field-slug" type="text" value="<%- field.slug %>">
648
  </div>
649
  <div>
650
  <label for="ccf-field-label"><?php esc_html_e( 'Label:', 'custom-contact-forms' ); ?></label>
651
+ <input id="ccf-field-label" class="field-label" type="text" value="<%- field.label %>">
652
  </div>
653
  <div>
654
  <label for="ccf-field-required"><?php esc_html_e( 'Required:', 'custom-contact-forms' ); ?></label>
669
  <div class="section-content">
670
  <div>
671
  <label for="ccf-field-class-name"><?php esc_html_e( 'Class Name:', 'custom-contact-forms' ); ?></label>
672
+ <input id="ccf-field-class-name" class="field-class-name" type="text" value="<%- field.className %>">
673
  </div>
674
  </div>
675
  </div>
681
  <div class="section-content">
682
  <div>
683
  <label for="ccf-field-slug"><span class="required">*</span> <?php esc_html_e( 'Internal Slug (a-z, 0-9, -, _):', 'custom-contact-forms' ); ?></label>
684
+ <input id="ccf-field-slug" class="field-slug" type="text" value="<%- field.slug %>">
685
  </div>
686
  <div>
687
  <label for="ccf-field-label"><?php esc_html_e( 'Label:', 'custom-contact-forms' ); ?></label>
688
+ <input id="ccf-field-label" class="field-label" type="text" value="<%- field.label %>">
689
  </div>
690
  <div>
691
  <label for="ccf-field-required"><?php esc_html_e( 'Required:', 'custom-contact-forms' ); ?></label>
706
  <div class="section-content">
707
  <div>
708
  <label for="ccf-field-class-name"><?php esc_html_e( 'Class Name:', 'custom-contact-forms' ); ?></label>
709
+ <input id="ccf-field-class-name" class="field-class-name" type="text" value="<%- field.className %>">
710
  </div>
711
  </div>
712
  </div>
718
  <div class="section-content">
719
  <div>
720
  <label for="ccf-field-slug"><span class="required">*</span> <?php esc_html_e( 'Internal Slug (a-z, 0-9, -, _):', 'custom-contact-forms' ); ?></label>
721
+ <input id="ccf-field-slug" class="field-slug" type="text" value="<%- field.slug %>">
722
  </div>
723
  <div>
724
  <label for="ccf-field-label"><?php esc_html_e( 'Label:', 'custom-contact-forms' ); ?></label>
725
+ <input id="ccf-field-label" class="field-label" type="text" value="<%- field.label %>">
726
  </div>
727
  <div>
728
  <label for="ccf-field-required"><?php esc_html_e( 'Required:', 'custom-contact-forms' ); ?></label>
743
  <div class="section-content">
744
  <div>
745
  <label for="ccf-field-class-name"><?php esc_html_e( 'Class Name:', 'custom-contact-forms' ); ?></label>
746
+ <input id="ccf-field-class-name" class="field-class-name" type="text" value="<%- field.className %>">
747
  </div>
748
  </div>
749
  </div>
756
  </script>
757
 
758
  <script type="text/html" id="ccf-single-line-text-preview-template">
759
+ <label><%- field.label %> <% if ( field.required ) { %><span>*</span><% } %></label>
760
+ <input disabled type="text" placeholder="<%- field.placeholder %>" value="<%- field.value %>">
761
  </script>
762
 
763
  <script type="text/html" id="ccf-paragraph-text-preview-template">
764
+ <label><%- field.label %> <% if ( field.required ) { %><span>*</span><% } %></label>
765
+ <textarea placeholder="<%- field.placeholder %>" disabled><%- field.value %></textarea>
766
  </script>
767
 
768
  <script type="text/html" id="ccf-dropdown-preview-template">
769
+ <label><%- field.label %> <% if ( field.required ) { %><span>*</span><% } %></label>
770
  <select>
771
  <% if ( field.choices.length === 0 || ( field.choices.length === 1 && ! field.choices.at( 0 ).get( 'label' ) && ! field.choices.at( 0 ).get( 'value' ) ) ) { %>
772
  <option><?php esc_html_e( 'An example choice', 'custom-contact-forms' ); ?></option>
773
  <%} else { %>
774
  <% field.choices.each( function( choice ) { %>
775
+ <option value="<%- choice.get( 'value' ) %>"><%- choice.get( 'label' ) %></option>
776
  <% }); %>
777
  <% } %>
778
  </select>
779
  </script>
780
 
781
  <script type="text/html" id="ccf-radio-preview-template">
782
+ <label><%- field.label %> <% if ( field.required ) { %><span>*</span><% } %></label>
783
  <% if ( field.choices.length === 0 || ( field.choices.length === 1 && ! field.choices.at( 0 ).get( 'label' ) && ! field.choices.at( 0 ).get( 'value' ) ) ) { %>
784
  <div>
785
  <input type="radio" value="1" checked="checked"> <label><?php esc_html_e( 'An example choice', 'custom-contact-forms' ); ?></label>
787
  <%} else { %>
788
  <% field.choices.each( function( choice ) { %>
789
  <div class="choice">
790
+ <input type="radio" value="<%- choice.get( 'value' ) %>" <% if ( choice.get( 'selected' ) ) { %>checked="checked"<% } %>> <label><%- choice.get( 'label' ) %></label>
791
  </div>
792
  <% }); %>
793
  <% } %>
794
  </script>
795
 
796
  <script type="text/html" id="ccf-checkboxes-preview-template">
797
+ <label><%- field.label %> <% if ( field.required ) { %><span>*</span><% } %></label>
798
  <% if ( field.choices.length === 0 || ( field.choices.length === 1 && ! field.choices.at( 0 ).get( 'label' ) && ! field.choices.at( 0 ).get( 'value' ) ) ) { %>
799
  <div>
800
  <input type="checkbox" value="1" checked="checked"> <label><?php esc_html_e( 'An example choice', 'custom-contact-forms' ); ?></label>
802
  <%} else { %>
803
  <% field.choices.each( function( choice ) { %>
804
  <div class="choice">
805
+ <input type="checkbox" value="<%- choice.get( 'value' ) %>" <% if ( choice.get( 'selected' ) ) { %>checked="checked"<% } %>> <label><%- choice.get( 'label' ) %></label>
806
  </div>
807
  <% }); %>
808
  <% } %>
818
 
819
  <script type="text/html" id="ccf-section-header-preview-template">
820
  <div class="heading">
821
+ <% if ( field.heading ) { %><%- field.heading %><% } else { %><?php esc_html_e( 'Section Heading', 'custom-contact-forms' ); ?><% } %>
822
  </div>
823
+ <div class="subheading"><% if ( field.subheading ) { %><%- field.subheading %><% } else { %><?php esc_html_e( 'This is the sub-heading text.', 'custom-contact-forms' ); ?><% } %></div>
824
  </script>
825
 
826
  <script type="text/html" id="ccf-name-preview-template">
827
+ <label><%- field.label %> <% if ( field.required ) { %><span>*</span><% } %></label>
828
  <div class="left">
829
  <input type="text">
830
  <label class="sub-label"><?php esc_html_e( 'First', 'custom-contact-forms' ); ?></label>
836
  </script>
837
 
838
  <script type="text/html" id="ccf-date-preview-template">
839
+ <label><%- field.label %> <% if ( field.required ) { %><span>*</span><% } %></label>
840
  <% if ( field.showDate && ! field.showTime ) { %>
841
+ <input value="<%- field.value %>" class="ccf-datepicker" disabled type="text">
842
  <% } else if ( ! field.showDate && field.showTime ) { %>
843
  <div class="full">
844
  <div class="hour">
881
  </script>
882
 
883
  <script type="text/html" id="ccf-address-preview-template">
884
+ <label><%- field.label %> <% if ( field.required ) { %><span>*</span><% } %></label>
885
  <% if ( field.addressType === 'us' ) { %>
886
  <div class="full">
887
  <input type="text">
940
  </script>
941
 
942
  <script type="text/html" id="ccf-email-preview-template">
943
+ <label><%- field.label %> <% if ( field.required ) { %><span>*</span><% } %></label>
944
  <% if ( ! field.emailConfirmation ) { %>
945
+ <input placeholder="<% if ( field.placeholder ) { %><%- field.placeholder %><% } else { %><?php esc_html_e( 'email@example.com', 'custom-contact-forms' ); ?><% } %>" disabled type="text" value="<%- field.value %>">
946
  <% } else { %>
947
  <div class="left">
948
  <input type="text">
956
  </script>
957
 
958
  <script type="text/html" id="ccf-website-preview-template">
959
+ <label><%- field.label %> <% if ( field.required ) { %><span>*</span><% } %></label>
960
+ <input placeholder="<% if ( field.placeholder ) { %><%- field.placeholder %><% } else { %>http://<% } %>" disabled type="text" value="<%- field.value %>">
961
  </script>
962
 
963
  <script type="text/html" id="ccf-phone-preview-template">
964
+ <label><%- field.label %> <% if ( field.required ) { %><span>*</span><% } %></label>
965
+ <input placeholder="<% if ( field.placeholder ) { %><%- field.placeholder %><% } else { %>(301) 101-8976<% } %>" disabled type="text" value="<%- field.value %>">
966
  </script>
967
 
968
  <script type="text/html" id="ccf-existing-form-table-row-template">
969
 
970
+ <td><%- form.ID %></td>
971
  <td>
972
+ <a class="edit edit-form title" data-view="form-pane" data-form-id="<%- form.ID %>" href="#form-pane-<%- form.ID %>"><% if ( form.title ) { %><%- form.title %><% } else { %><%- '<?php esc_html_e( '(No title)', 'custom-contact-forms' ); ?>' %><% } %></a>
973
  <div class="actions">
974
+ <a class="edit edit-form" data-view="form-pane" data-form-id="<%- form.ID %>" href="#form-pane-<%- form.ID %>"><?php esc_html_e( 'Edit', 'custom-contact-forms' ); ?></a> |
975
  <a class="insert-form-button"><?php esc_html_e( 'Insert into post', 'custom-contact-forms' ); ?></a> |
976
  <a class="delete"><?php esc_html_e( 'Trash', 'custom-contact-forms' ); ?></a>
977
  </div>
978
  </td>
979
  <td>
980
+ <%- utils.getPrettyPostDate( form.date ) %>
981
  </td>
982
  <td>
983
+ <%- form.author.username %>
984
  </td>
985
  <td>
986
+ <%- form.fields.length %>
987
  </td>
988
  <td>
989
  0
991
  </script>
992
 
993
  <script type="text/html" id="ccf-form-mce-preview">
994
+ <div class="ccf-form-preview form-id-<%- form.ID %>">
995
  <% if ( form.title ) { %>
996
+ <h2><%- form.title %></h2>
997
  <% } %>
998
 
999
  <% if ( form.description && form.description != '' ) { %>
1000
+ <p><%- form.description %></p>
1001
  <% } %>
1002
 
1003
  <% if ( form.fields ) { %>
1004
  <% _.each( form.fields, function( field ) { %>
1005
+ <div class="field <%- field.type %> field-<%- field.ID %>">
1006
  <%= field.preview %>
1007
  </div>
1008
  <% } ); %>
1009
  <% } %>
1010
 
1011
  <div class="field-submit">
1012
+ <input type="button" value="<%- form.buttonText %>">
1013
  </div>
1014
  </div>
1015
  </script>
1025
  <thead>
1026
  <tr>
1027
  <% _.each( columns, function( column ) { %>
1028
+ <th scope="col" class="manage-column column-<%- column %>">
1029
  <% if ( 'date' === column ) { %>
1030
  <?php esc_html_e( 'Date', 'custom-contact-forms' ); ?>
1031
  <% } else { %>
1032
+ <%- column %>
1033
  <% } %>
1034
  </th>
1035
  <% } ); %>
1039
  <tfoot>
1040
  <tr>
1041
  <% _.each( columns, function( column ) { %>
1042
+ <th scope="col" class="manage-column column-<%- column %>">
1043
  <% if ( 'date' === column ) { %>
1044
  <?php esc_html_e( 'Date', 'custom-contact-forms' ); ?>
1045
  <% } else { %>
1046
+ <%- column %>
1047
  <% } %>
1048
  </th>
1049
  <% } ); %>
1053
 
1054
  <tbody class="submission-rows">
1055
  <tr>
1056
+ <td colspan="<%- columns.length + 1 %>">
1057
  <div class="spinner"></div>
1058
  </td>
1059
  </tr>
1065
  <script type="text/html" id="ccf-submission-row-template">
1066
  <% _.each( currentColumns, function( column ) { %>
1067
  <% if ( 'date' === column ) { %>
1068
+ <td colspan="1"><%- utils.getPrettyPostDate( submission.date ) %></td>
1069
  <% } else { %>
1070
  <td colspan="1">
1071
  <% if ( submission.data[column] ) { %>
1072
  <% if ( submission.data[column] instanceof Object ) { var output = '', i = 0; %>
1073
  <% if ( utils.isFieldDate( submission.data[column] ) ) { %>
1074
+ <%- utils.getPrettyFieldDate( submission.data[column] ) %>
1075
  <% } else if ( utils.isFieldName( submission.data[column] ) ) { %>
1076
+ <%- utils.getPrettyFieldName( submission.data[column] ) %>
1077
  <% } else if ( utils.isFieldAddress( submission.data[column] ) ) { %>
1078
+ <%- utils.wordChop( utils.getPrettyFieldAddress( submission.data[column] ), 30 ) %>
1079
  <% } else { %>
1080
  <% for ( var key in submission.data[column] ) { if ( submission.data[column].hasOwnProperty( key ) ) {
1081
  if ( i > 0 ) {
1085
 
1086
  i++;
1087
  } } %>
1088
+ <%- utils.wordChop( output, 30 ) %>
1089
  <% } %>
1090
  <% } else { %>
1091
+ <%- utils.wordChop( submission.data[column] ) %>
1092
  <% } %>
1093
  <% } else { %>
1094
  <span><?php esc_html_e( '-', 'custom-contact-forms' ); ?></span>
1097
  <% } %>
1098
  <% } ); %>
1099
  <td class="actions">
1100
+ <a href="#TB_inline?height=300&amp;width=400&amp;inlineId=submission-content" data-submission-date="<%- submission.date %>" data-submission-id="<%- submission.ID %>" class="view" data-icon="&#xe601;"></a>
1101
  <a class="delete" data-icon="&#xe602;"></a>
1102
 
1103
+ <div class="submission-wrapper" id="ccf-submission-content-<%- submission.ID %>">
1104
  <div class="ccf-submission-content">
1105
  <% for ( column in submission.data ) { %>
1106
  <div class="field-slug">
1107
+ <%- column %>
1108
  </div>
1109
  <div class="field-content">
1110
  <% if ( submission.data[column] ) { %>
1111
  <% if ( submission.data[column] instanceof Object ) { %>
1112
  <% if ( utils.isFieldDate( submission.data[column] ) ) { %>
1113
+ <%- utils.getPrettyFieldDate( submission.data[column] ) %>
1114
  <% } else if ( utils.isFieldName( submission.data[column] ) ) { %>
1115
+ <%- utils.getPrettyFieldName( submission.data[column] ) %>
1116
  <% } else if ( utils.isFieldAddress( submission.data[column] ) ) { %>
1117
+ <%- utils.getPrettyFieldAddress( submission.data[column] ) %>
1118
  <% } else { %>
1119
  <% for ( var key in submission.data[column] ) { if ( submission.data[column].hasOwnProperty( key ) ) { %>
1120
+ <% if ( isNaN( key ) ) { %><strong><%- key %>:</strong> <% } %><%- submission.data[column][key] %><br>
1121
  <% } } %>
1122
  <% } %>
1123
  <% } else { %>
1124
+ <%- submission.data[column] %>
1125
  <% } %>
1126
  <% } else { %>
1127
  <span>-</span>
1135
 
1136
 
1137
  <script type="text/html" id="ccf-no-submissions-row-template">
1138
+ <td colspan="<%- columns.length + 1 %>" class="no-submissions"><?php esc_html_e( 'There are no submissions.', 'custom-contact-forms' ); ?></td>
1139
  </script>
1140
 
1141
  <script type="text/html" id="ccf-submissions-controller-template">
1142
  <% var i = 0; _.each( columns, function( column ) { %>
1143
 
1144
+ <label for="ccf-column-<%- column %>">
1145
+ <input class="submission-column-checkbox" type="checkbox" id="ccf-column-<%- column %>" <% if ( i < 4 || 'date' === column ) { %>checked<% } %> value="<%- column %>">
1146
  <% if ( 'date' === column ) { %>
1147
  <?php esc_html_e( 'Date', 'custom-contact-forms' ); ?>
1148
  <% } else { %>
1149
+ <%- column %>
1150
  <% } %>
1151
  </label>
1152
 
classes/class-ccf-form-renderer.php CHANGED
@@ -158,6 +158,7 @@ class CCF_Form_Renderer {
158
  </div>
159
 
160
  <input type="hidden" name="form_id" value="<?php echo (int) $form_id; ?>">
 
161
  <input type="text" name="my_information" style="display: none;">
162
  <input type="hidden" name="ccf_form" value="1">
163
  <input type="hidden" name="form_nonce" value="<?php echo wp_create_nonce( 'ccf_form' ); ?>">
158
  </div>
159
 
160
  <input type="hidden" name="form_id" value="<?php echo (int) $form_id; ?>">
161
+ <input type="hidden" name="form_page" value="<?php echo esc_url( untrailingslashit( site_url() ) . $_SERVER['REQUEST_URI'] ); ?>">
162
  <input type="text" name="my_information" style="display: none;">
163
  <input type="hidden" name="ccf_form" value="1">
164
  <input type="hidden" name="form_nonce" value="<?php echo wp_create_nonce( 'ccf_form' ); ?>">
classes/class-ccf-upgrader.php CHANGED
@@ -34,7 +34,7 @@ class CCF_Upgrader {
34
  ?>
35
  <div class="update-nag">
36
  <p>
37
- <?php esc_html_e( 'Did you just upgrade to a post 6.0 version of Custom Contact Forms? If so, you might need to upgrade your database to use your old forms.', 'custom-contact-forms' ); ?>
38
  <a href="<?php echo esc_url( admin_url( '?ccf_upgrade=1&nonce=' . $nonce ) ); ?>" class="button"><?php esc_html_e( 'Upgrade', 'custom-contact-forms' ); ?></a>
39
  <a href="<?php echo esc_url( admin_url( '?ccf_upgrade=0&nonce=' . $nonce ) ); ?>" class="button"><?php esc_html_e( 'Dismiss', 'custom-contact-forms' ); ?></a>
40
  </p>
34
  ?>
35
  <div class="update-nag">
36
  <p>
37
+ <?php esc_html_e( 'Did you just upgrade to a post 6.0 version of Custom Contact Forms? If so, you might need to upgrade your database to use your old forms. Please backup your database before running the upgrade.', 'custom-contact-forms' ); ?>
38
  <a href="<?php echo esc_url( admin_url( '?ccf_upgrade=1&nonce=' . $nonce ) ); ?>" class="button"><?php esc_html_e( 'Upgrade', 'custom-contact-forms' ); ?></a>
39
  <a href="<?php echo esc_url( admin_url( '?ccf_upgrade=0&nonce=' . $nonce ) ); ?>" class="button"><?php esc_html_e( 'Dismiss', 'custom-contact-forms' ); ?></a>
40
  </p>
custom-contact-forms.php CHANGED
@@ -4,7 +4,7 @@
4
  * Plugin URI: http://www.taylorlovett.com
5
  * Description: Build beautiful custom forms the WordPress way. View live previews of your forms while you build them.
6
  * Author: Taylor Lovett
7
- * Version: 6.1.2
8
  * Author URI: http://www.taylorlovett.com
9
  */
10
 
4
  * Plugin URI: http://www.taylorlovett.com
5
  * Description: Build beautiful custom forms the WordPress way. View live previews of your forms while you build them.
6
  * Author: Taylor Lovett
7
+ * Version: 6.1.4
8
  * Author URI: http://www.taylorlovett.com
9
  */
10
 
js/manager/models.js CHANGED
@@ -17,6 +17,34 @@
17
  return Backbone.Model.prototype.set.call( this, key, value, options );
18
  };
19
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
20
  wp.ccf.models.FieldChoice = wp.ccf.models.FieldChoice || Backbone.Model.extend(
21
  {
22
  defaults: {
@@ -25,6 +53,10 @@
25
  selected: false
26
  },
27
 
 
 
 
 
28
  set: _modelSet
29
  }
30
  );
@@ -36,6 +68,10 @@
36
 
37
  set: _modelSet,
38
 
 
 
 
 
39
  defaults: function() {
40
  var defaults = {
41
  fields: new wp.ccf.collections.Fields(),
@@ -56,6 +92,13 @@
56
  return defaults;
57
  },
58
 
 
 
 
 
 
 
 
59
  getFieldSlugs: function( mutableOnly ) {
60
  var fields = wp.ccf.currentForm.get( 'fields' ),
61
  columns = [];
@@ -93,7 +136,9 @@
93
 
94
  if ( choices && choices.length > 0 ) {
95
  for ( var z = 0; z < newField.choices; z++ ) {
96
- choices.at( z ).set( newField.choices[z] );
 
 
97
  }
98
  }
99
 
@@ -101,6 +146,7 @@
101
  }
102
 
103
  field.set( newField );
 
104
  }
105
  }
106
 
@@ -109,7 +155,10 @@
109
  var newFields = [];
110
 
111
  _.each( response.fields, function( field ) {
112
- newFields.push( new wp.ccf.models.Fields[field.type]( field ) );
 
 
 
113
  });
114
 
115
  response.fields = new wp.ccf.collections.Fields( newFields, { formId: response.ID } );
@@ -160,6 +209,10 @@
160
  return [ 'slug' ];
161
  },
162
 
 
 
 
 
163
  hasRequiredAttributes: function() {
164
  var SELF = this;
165
  var reqsMet = true;
@@ -366,7 +419,10 @@
366
  var choices = [];
367
 
368
  _.each( attributes.choices, function( choice ) {
369
- choices.push( new wp.ccf.models.FieldChoice( choice ) );
 
 
 
370
  });
371
 
372
  this.set( 'choices', new wp.ccf.collections.FieldChoices( choices ) );
17
  return Backbone.Model.prototype.set.call( this, key, value, options );
18
  };
19
 
20
+ /**
21
+ * We decode HTML entities after syncing then escape on output. The
22
+ * point of this is to prevent double escaping.
23
+ */
24
+ var _modelDecode = function( excludeKeys ) {
25
+ for ( var key in this.attributes ) {
26
+ if ( excludeKeys.indexOf( key ) === -1 ) {
27
+ var value = this.get( key );
28
+
29
+ if ( typeof value === 'string' && value !== '' ) {
30
+ value = String( value )
31
+ .replace( /&amp;/g, '&' )
32
+ .replace( /&lt;/g, '<' )
33
+ .replace( /&gt;/g, '>' )
34
+ .replace( /&quot;/g, '"' )
35
+ .replace( /&#8220;/g, '”' )
36
+ .replace( /&#8221;/g, '”' )
37
+ .replace( /&#8216;/g, "‘" )
38
+ .replace( /&#039;/g, "'" );
39
+
40
+ this.set( key, value );
41
+ }
42
+ }
43
+ }
44
+
45
+ return this;
46
+ };
47
+
48
  wp.ccf.models.FieldChoice = wp.ccf.models.FieldChoice || Backbone.Model.extend(
49
  {
50
  defaults: {
53
  selected: false
54
  },
55
 
56
+ decode: function() {
57
+ return _modelDecode.call( this, [] );
58
+ },
59
+
60
  set: _modelSet
61
  }
62
  );
68
 
69
  set: _modelSet,
70
 
71
+ initialize: function() {
72
+ this.on( 'sync', this.decode, this );
73
+ },
74
+
75
  defaults: function() {
76
  var defaults = {
77
  fields: new wp.ccf.collections.Fields(),
92
  return defaults;
93
  },
94
 
95
+ decode: function() {
96
+ var keys = _.keys( wp.api.models.Post.prototype.defaults );
97
+ keys = _.without( keys, 'title' );
98
+
99
+ return _modelDecode.call( this, keys );
100
+ },
101
+
102
  getFieldSlugs: function( mutableOnly ) {
103
  var fields = wp.ccf.currentForm.get( 'fields' ),
104
  columns = [];
136
 
137
  if ( choices && choices.length > 0 ) {
138
  for ( var z = 0; z < newField.choices; z++ ) {
139
+ var choice = choices.at( z );
140
+ choice.set( newField.choices[z] );
141
+ choice.decode();
142
  }
143
  }
144
 
146
  }
147
 
148
  field.set( newField );
149
+ field.decode();
150
  }
151
  }
152
 
155
  var newFields = [];
156
 
157
  _.each( response.fields, function( field ) {
158
+ var fieldModel = new wp.ccf.models.Fields[field.type]( field );
159
+ fieldModel.decode();
160
+
161
+ newFields.push( fieldModel );
162
  });
163
 
164
  response.fields = new wp.ccf.collections.Fields( newFields, { formId: response.ID } );
209
  return [ 'slug' ];
210
  },
211
 
212
+ decode: function() {
213
+ return _modelDecode.call( this, _.keys( wp.api.models.Post.prototype.defaults ) );
214
+ },
215
+
216
  hasRequiredAttributes: function() {
217
  var SELF = this;
218
  var reqsMet = true;
419
  var choices = [];
420
 
421
  _.each( attributes.choices, function( choice ) {
422
+ var choiceModel = new wp.ccf.models.FieldChoice( choice );
423
+ choiceModel.decode();
424
+
425
+ choices.push( choiceModel );
426
  });
427
 
428
  this.set( 'choices', new wp.ccf.collections.FieldChoices( choices ) );
readme.txt CHANGED
@@ -4,7 +4,7 @@ Donate link: http://www.taylorlovett.com
4
  Tags: contact form, web form, custom contact form, custom forms, captcha form, contact fields, form mailers, forms
5
  Requires at least: 3.9
6
  Tested up to: 4.1
7
- Stable tag: 6.1.2
8
 
9
  Build beautiful custom forms the WordPress way. View live previews of your forms while you build them.
10
 
@@ -33,6 +33,12 @@ For questions, feature requests, and support concerning the Custom Contact Forms
33
 
34
  = Changelog ==
35
 
 
 
 
 
 
 
36
  = 6.1.2 =
37
  * Force JSON url to obey current protocol
38
  * Enqueue scripts earlier
4
  Tags: contact form, web form, custom contact form, custom forms, captcha form, contact fields, form mailers, forms
5
  Requires at least: 3.9
6
  Tested up to: 4.1
7
+ Stable tag: 6.1.4
8
 
9
  Build beautiful custom forms the WordPress way. View live previews of your forms while you build them.
10
 
33
 
34
  = Changelog ==
35
 
36
+ = 6.1.4 =
37
+ * Decode html entities on model sync. Escape entities on output.
38
+
39
+ = 6.1.3 =
40
+ * Fix form page bug
41
+
42
  = 6.1.2 =
43
  * Force JSON url to obey current protocol
44
  * Enqueue scripts earlier