diff --git a/.gitignore b/.gitignore
index 2785a6d1..f720e67c 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,4 +1,7 @@
node_modules
bower_components
.sass-cache
-compiled
\ No newline at end of file
+compiled
+npm-debug.log
+.DS_Store
+.idea
\ No newline at end of file
diff --git a/.nvmrc b/.nvmrc
new file mode 100644
index 00000000..d16c3a34
--- /dev/null
+++ b/.nvmrc
@@ -0,0 +1 @@
+10.15.3
\ No newline at end of file
diff --git a/Gruntfile.coffee b/Gruntfile.coffee
index abf78fb9..944205a2 100644
--- a/Gruntfile.coffee
+++ b/Gruntfile.coffee
@@ -1,4 +1,4 @@
-ALL_TASKS = ['jst:all', 'coffee:all', 'concat:all', 'stylus:all', 'clean:compiled']
+ALL_TASKS = ['jst:all', 'coffee:all', 'concat:all', 'stylus:all', 'clean:compiled', 'copy:all']
# formbuilder.js must be compiled in this order:
# 1. rivets-config
@@ -19,8 +19,10 @@ module.exports = (grunt) ->
grunt.loadNpmTasks('grunt-contrib-uglify')
grunt.loadNpmTasks('grunt-contrib-watch')
grunt.loadNpmTasks('grunt-contrib-clean')
+ grunt.loadNpmTasks('grunt-contrib-copy')
grunt.loadNpmTasks('grunt-release')
grunt.loadNpmTasks('grunt-karma')
+ grunt.loadNpmTasks('grunt-contrib-connect')
grunt.initConfig
@@ -58,7 +60,7 @@ module.exports = (grunt) ->
'<%= distFolder %>/formbuilder.js': '<%= compiledFolder %>/*.js'
'<%= vendorFolder %>/js/vendor.js': [
'bower_components/ie8-node-enum/index.js'
- 'bower_components/jquery/jquery.js'
+ 'bower_components/jquery/dist/jquery.js'
'bower_components/jquery-ui/ui/jquery.ui.core.js'
'bower_components/jquery-ui/ui/jquery.ui.widget.js'
'bower_components/jquery-ui/ui/jquery.ui.mouse.js'
@@ -66,18 +68,36 @@ module.exports = (grunt) ->
'bower_components/jquery-ui/ui/jquery.ui.droppable.js'
'bower_components/jquery-ui/ui/jquery.ui.sortable.js'
'bower_components/jquery.scrollWindowTo/index.js'
- 'bower_components/underscore/underscore-min.js'
+ 'bower_components/lodash/dist/lodash.min.js'
'bower_components/underscore.mixin.deepExtend/index.js'
'bower_components/rivets/dist/rivets.js'
'bower_components/backbone/backbone.js'
'bower_components/backbone-deep-model/src/deep-model.js'
+ 'bower_components/bootstrap/dist/js/bootstrap.js',
+ 'bower_components/bootstrap/js/tooltip.js',
+ 'bower_components/signature_pad/signature_pad.js'
+ 'bower_components/node-uuid/uuid.js'
+ 'bower_components/spectrum/spectrum.js'
]
+ '<%= vendorFolder %>/css/vendor.css': [
+ 'bower_components/font-awesome/css/font-awesome.css',
+ 'bower_components/bootstrap/dist/css/bootstrap.css',
+ 'bower_components/summernote/dist/summernote.css',
+ 'bower_components/spectrum/spectrum.css'
+ ]
+
+ copy:
+ all:
+ expand: true,
+ flatten: true,
+ src: 'bower_components/font-awesome/fonts/*',
+ dest: '<%= vendorFolder %>/fonts/'
cssmin:
dist:
files:
'<%= distFolder %>/formbuilder-min.css': '<%= distFolder %>/formbuilder.css'
- '<%= vendorFolder %>/css/vendor.css': 'bower_components/font-awesome/css/font-awesome.css'
+
stylus:
all:
@@ -99,6 +119,12 @@ module.exports = (grunt) ->
files: ['<%= srcFolder %>/**/*.{coffee,styl,html}']
tasks: ALL_TASKS
+ connect:
+ server:
+ options:
+ port: 9001
+ keepalive: true
+
# To test, run `grunt --no-write -v release`
release:
npm: false
diff --git a/README.md b/README.md
index a7c58bbe..099f1278 100644
--- a/README.md
+++ b/README.md
@@ -38,22 +38,22 @@ Because of its modular nature, Formbuilder is easy to customize. Most of the con
Keeping with the customizable nature of Formbuilder, you are also able to modify how Formbuilder structures its JSON output. The [default keypaths](https://github.com/dobtco/formbuilder/blob/master/coffee/main.coffee#L20) are:
```coffeescript
-SIZE: 'field_options.size'
-UNITS: 'field_options.units'
+SIZE: 'options.size'
+UNITS: 'options.units'
LABEL: 'label'
-FIELD_TYPE: 'field_type'
+type: 'type'
REQUIRED: 'required'
ADMIN_ONLY: 'admin_only'
-OPTIONS: 'field_options.options'
-DESCRIPTION: 'field_options.description'
-INCLUDE_OTHER: 'field_options.include_other_option'
-INCLUDE_BLANK: 'field_options.include_blank_option'
-INTEGER_ONLY: 'field_options.integer_only'
-MIN: 'field_options.min'
-MAX: 'field_options.max'
-MINLENGTH: 'field_options.minlength'
-MAXLENGTH: 'field_options.maxlength'
-LENGTH_UNITS: 'field_options.min_max_length_units'
+OPTIONS: 'options.options'
+DESCRIPTION: 'options.description'
+INCLUDE_OTHER: 'options.include_other_option'
+INCLUDE_BLANK: 'options.include_blank_option'
+INTEGER_ONLY: 'options.integer_only'
+MIN: 'options.min'
+MAX: 'options.max'
+MINLENGTH: 'options.minlength'
+MAXLENGTH: 'options.maxlength'
+LENGTH_UNITS: 'options.min_max_length_units'
```
Which outputs JSON that looks something like:
@@ -61,15 +61,15 @@ Which outputs JSON that looks something like:
```javascript
[{
"label": "Please enter your clearance number",
- "field_type": "text",
+ "type": "text",
"required": true,
- "field_options": {},
+ "options": {},
"cid": "c6"
}, {
"label": "Security personnel #82?",
- "field_type": "radio",
+ "type": "radio",
"required": true,
- "field_options": {
+ "options": {
"options": [{
"label": "Yes",
"checked": false
@@ -82,9 +82,9 @@ Which outputs JSON that looks something like:
"cid": "c10"
}, {
"label": "Medical history",
- "field_type": "file",
+ "type": "file",
"required": true,
- "field_options": {},
+ "options": {},
"cid": "c14"
}]
```
@@ -108,10 +108,12 @@ Have a question about Formbuilder? Feel free to [open a GitHub Issue](https://gi
## Developing
You'll need [node and npm](http://nodejs.org/) installed.
-1. `npm install`
-2. `bower install`
-3. `grunt watch`
-4. open `index.html` and you're all set!
+1. `nvm use`
+2. `npm install`
+3. `bower install`
+4. `grunt watch`
+5. Open a new terminal and run `grunt connect`
+6. open `http://localhost:9001/` and you're all set!
## License
MIT
diff --git a/bower.json b/bower.json
index e7deea0a..255fa4ee 100644
--- a/bower.json
+++ b/bower.json
@@ -16,15 +16,20 @@
"tests"
],
"dependencies": {
- "ie8-node-enum": "https://gist.github.com/adamjacobbecker/8902451/raw/b68459289526cb76c2e22416d98d0dbd0b722fa0/ie8_node_enum.js",
- "jquery": "~2.0.3",
+ "ie8-node-enum": "https://gist.github.com/ajb/8902451/raw/b68459289526cb76c2e22416d98d0dbd0b722fa0/ie8_node_enum.js",
+ "jquery.scrollWindowTo": "https://gist.github.com/ajb/6519570/raw/cd741057495d0fb19e545a0f9a098efba3bef9c8/jquery.scrollWindowTo.js",
+ "jquery": "~1.11.1",
"jquery-ui": "~1.10.3",
- "jquery.scrollWindowTo": "https://gist.github.com/adamjacobbecker/6519570/raw/cd741057495d0fb19e545a0f9a098efba3bef9c8/jquery.scrollWindowTo.js",
- "underscore": "~1.5.2",
- "underscore.mixin.deepExtend": "https://gist.github.com/adamjacobbecker/6519561/raw/63682037af9b10200b05c1a3d5890903397b2103/underscore.mixin.deepExtend.js",
"backbone": "~1.1.0",
"backbone-deep-model": "~0.10.4",
+ "underscore.mixin.deepExtend": "https://gist.github.com/ajb/6519561/raw/63682037af9b10200b05c1a3d5890903397b2103/underscore.mixin.deepExtend.js",
"rivets": "~0.5.13",
- "font-awesome": "~4.0.0"
+ "signature_pad": "~1.3.2",
+ "bootstrap": "~3.1.1",
+ "summernote": "~0.6.16",
+ "node-uuid": "~1.4.1",
+ "mathjs": "~1.1.1",
+ "lodash": "~2.4.1",
+ "spectrum": "~1.7.1"
}
-}
\ No newline at end of file
+}
diff --git a/dist/formbuilder-min.css b/dist/formbuilder-min.css
index 0247fb6d..1aae53c5 100644
--- a/dist/formbuilder-min.css
+++ b/dist/formbuilder-min.css
@@ -1 +1 @@
-.fb-button{display:inline-block;margin:0;padding:.563rem .844rem;border:0 none;background:#16a085;color:#fff;text-align:center;text-decoration:none;font-size:12px;line-height:1.5;cursor:pointer;border-radius:.125rem;border:thin solid #19b394;border-bottom:2px solid #16a085}.fb-button[disabled]{background:#ddd!important;border:thin solid #ccc;color:#777!important;text-shadow:none!important;-ms-filter:"alpha(Opacity=65)";opacity:.65;cursor:default}.fb-clear{clear:both}.fb-main{max-width:1000px;margin:0 auto;padding:0 20px 0 0;position:relative;font-family:'Source Sans Pro','Open Sans',Tahoma}.fb-save-wrapper{position:absolute;right:20px;top:10px}.fb-left{width:320px;float:left;padding-top:30px}.fb-right{padding-top:70px;margin-left:320px;border-left:1px solid #ddd;padding-left:20px;min-height:100%;overflow:hidden}.fb-no-response-fields{color:#999}.fb-tabs{list-style:none;margin:0 0 20px;padding:0 0 0 20px;border-bottom:1px solid #ccc}.fb-tabs li{display:inline-block}.fb-tabs li a{display:block;padding:10px;border-radius:5px 5px 0 0;font-size:13px;cursor:pointer;border-left:1px solid transparent;border-right:1px solid transparent}.fb-tabs li.active a{border:1px solid #ccc;margin-bottom:-1px;border-bottom-color:#fff}.fb-tab-content .fb-tab-pane{padding:0 20px;display:none}.fb-tab-content .fb-tab-pane.active{display:block}.fb-add-field-types .section{padding-bottom:5px;margin-bottom:20px}.fb-add-field-types{font-size:0}.fb-add-field-types a{font-size:13px;display:inline-block;width:48.5%;background-color:#1abc9c;margin-bottom:9px;box-sizing:border-box}.fb-add-field-types a:nth-child(odd){margin-right:3%}.fb-add-field-types a .symbol{opacity:.6;margin:0 .25em 0 -1em}.fb-response-fields{padding-bottom:150px}.fb-response-fields a.sortable-placeholder{display:block;border:1px dashed #ddd;min-height:80px;height:80px;width:100%}.fb-field-wrapper{cursor:pointer;position:relative;margin-bottom:20px}.fb-field-wrapper input{border-radius:3px;border:thin solid #ddd}.fb-field-wrapper:hover .actions-wrapper,.fb-field-wrapper.editing .actions-wrapper{display:block}.fb-field-wrapper:hover .subtemplate-wrapper{border-color:#ddd;border-radius:3px}.fb-field-wrapper.editing{background-color:#ecf0f1;border-radius:3px}.fb-field-wrapper.editing .subtemplate-wrapper{border-color:#d9e1e3;border-style:solid;margin:0;border-radius:3px}.fb-field-wrapper .actions-wrapper{display:none;position:absolute;bottom:-7px;right:5px;z-index:3}.fb-field-wrapper .actions-wrapper a{display:inline-block;background-color:#ccc;padding:2px 8px}.edit-response-field input,.edit-response-field textarea,.edit-response-field select{border:thin solid #ddd;border-radius:.25em;padding:.5em;display:inline-block;height:auto;vertical-align:middle}.edit-response-field input:focus,.edit-response-field textarea:focus,.edit-response-field select:focus{outline:0;border:thin solid #1abc9c}.edit-response-field select{font-size:14px}.fb-field-wrapper .actions-wrapper a.js-duplicate,.fb-edit-field-wrapper .js-add-option{background-color:#2ecc71;border:0}.fb-field-wrapper .actions-wrapper a.js-clear,.fb-edit-field-wrapper .js-remove-option{background-color:#e74c3c;border:0}.fb-field-wrapper .subtemplate-wrapper{border:1px dashed transparent;margin-bottom:10px;padding:10px;position:relative}.fb-field-wrapper .subtemplate-wrapper .cover{position:absolute;top:0;left:0;height:100%;width:100%;z-index:2}.fb-field-wrapper .subtemplate-wrapper>label{display:block;border-bottom:thin solid #eee;padding-bottom:3px;margin-bottom:7px}.fb-field-wrapper .subtemplate-wrapper abbr{color:red}.fb-field-wrapper .input-line{clear:both;margin-bottom:10px}.fb-field-wrapper .input-line .above-line{margin-top:7px}.fb-field-wrapper .input-line>span{display:inline-block;vertical-align:top}.fb-field-wrapper .input-line>span input{width:100%}.fb-field-wrapper .input-line>span>label{display:block;font-size:13px;margin-left:3px}.fb-field-wrapper .help-block{display:block;font-size:12px;margin-top:5px}.fb-edit-field-wrapper{font-size:13px}.fb-edit-field-wrapper .fb-field-label{font-weight:400;background:#eee;padding:.75em;color:#666;font-size:1.25em}.fb-edit-field-wrapper .fb-field-label .field-type{margin-top:.5em;display:block;font-family:'Source Sans Pro',sans-serif;font-size:1em}.fb-edit-field-wrapper .fb-field-label .field-type:before{content:'Type: ';color:#999}.fb-edit-field-wrapper .fb-field-label .fa.fa-arrow-right{display:none}.fb-edit-field-wrapper .fb-edit-section-header{border-bottom:1px solid #ddd;margin-top:25px;margin-bottom:10px;padding-bottom:5px;clear:both;font-weight:700}.fb-edit-field-wrapper .js-add-option,.fb-edit-field-wrapper .js-remove-option{padding:3px 6px}.fb-edit-field-wrapper .fb-bottom-add{margin-top:8px}.fb-common-wrapper .fb-label-description{margin-bottom:10px}.fb-common-wrapper .fb-label-description input,.fb-common-wrapper .fb-label-description textarea{width:100%}.fb-common-wrapper .fb-label-description textarea{min-height:5em}.response-field-draggable-helper{border:1px dashed #ddd;background:#eee}.response-field-text input.rf-size-small{width:130px}.response-field-text input.rf-size-medium{width:300px}.response-field-text input.rf-size-large{width:100%}.response-field-paragraph textarea.rf-size-small{width:200px;min-height:60px}.response-field-paragraph textarea.rf-size-medium{width:400px;min-height:100px}.response-field-paragraph textarea.rf-size-large{width:100%;min-height:200px}.response-field-address .street{width:400px}.response-field-address .city,.response-field-address .state,.response-field-address .zip,.response-field-address .country{width:198px}.response-field-date .month,.response-field-date .day,.response-field-date .year{width:50px}.response-field-time .hours,.response-field-time .minutes,.response-field-time .seconds{width:50px}.response-field-checkboxes .fb-option,.response-field-radio .fb-option{margin-bottom:5px;display:inline-block}
\ No newline at end of file
+[class^=fb-icon-]:before,[class*=" fb-icon-"]:before{font-family:fontello;font-style:normal;font-weight:400;speak:none;display:inline-block;text-decoration:inherit;width:1em;margin-right:.2em;text-align:center;font-variant:normal;text-transform:none;line-height:1em;margin-left:.2em}.fb-icon-date:before{content:'\e800'}.fb-icon-radio:before{content:'\e801'}.fb-icon-checkbox:before{content:'\e802'}.fb-icon-data-source:before{content:'\e803'}.fb-icon-dropdown:before{content:'\e804'}.fb-icon-signature:before{content:'\e805'}.fb-icon-info:before{content:'\e806'}.fb-icon-table:before{content:'\e807'}.fb-icon-textarea:before{content:'\e808'}.fb-icon-section:before{content:'\e809'}.fb-icon-text:before{content:'\e80a'}.fb-icon-number:before{content:'\e80b'}.fb-button{text-align:left}.fb-clear{clear:both}.fb-main{padding:0 20px 0 0;position:relative}.fb-save-wrapper{position:absolute;right:20px;top:10px}.fb-left{float:left;width:320px;padding-top:30px}.fb-right{padding-top:70px;margin-left:320px;border-left:1px solid #ddd;padding-left:20px;min-height:100%;overflow:hidden}.fb-no-response-fields{color:#999}.fb-tabs{list-style:none;margin:0 0 20px;padding:0 0 0 20px;border-bottom:1px solid #ccc}.fb-tabs li{display:inline-block}.fb-tabs li a{display:block;padding:10px;border-radius:5px 5px 0 0;font-size:13px;cursor:pointer;border-left:1px solid transparent;border-right:1px solid transparent}.fb-tabs li.active a{border:1px solid #ccc;margin-bottom:-1px;border-bottom-color:#fff}.fb-tab-content .fb-tab-pane{padding:0 20px;display:none}.fb-tab-content .fb-tab-pane.active{display:block}.fb-add-types .section{padding-bottom:5px;margin-bottom:20px}.fb-add-types{font-size:0}.fb-add-types a{font-size:13px;display:inline-block;width:48.5%;margin-bottom:9px;box-sizing:border-box}.fb-add-types a:nth-child(odd){margin-right:3%}.fb-add-types a .symbol{opacity:.6;margin:0 .25em 0 -1em}.fb-response-fields{padding-bottom:150px}.fb-response-fields a.sortable-placeholder{display:block;border:1px dashed #ddd;min-height:80px;height:80px;width:100%}.fb-field-wrapper{cursor:pointer;position:relative;margin-bottom:20px}.fb-field-wrapper input{border-radius:3px;border:thin solid #ddd}.fb-field-wrapper:hover .actions-wrapper,.fb-field-wrapper.editing .actions-wrapper{display:block}.fb-field-wrapper:hover .subtemplate-wrapper{border-color:#ddd;border-radius:3px}.fb-field-wrapper.editing{background-color:#ecf0f1;border-radius:3px}.fb-field-wrapper.editing .subtemplate-wrapper{border-color:#d9e1e3;border-style:solid;margin:0;border-radius:3px}.fb-field-wrapper .actions-wrapper{display:none;position:absolute;bottom:-7px;right:5px;z-index:3}.fb-field-wrapper .actions-wrapper a{display:inline-block;background-color:#ccc;padding:2px 8px}.edit-response-field input,.edit-response-field textarea,.edit-response-field select{border:thin solid #ddd;border-radius:.25em;padding:.5em;display:inline-block;height:auto;vertical-align:middle}.edit-response-field input:focus,.edit-response-field textarea:focus,.edit-response-field select:focus{outline:0}.edit-response-field select{font-size:14px}input[readonly]{cursor:not-allowed;background-color:#eee}.fb-field-wrapper .subtemplate-wrapper{border:1px dashed transparent;margin-bottom:10px;padding:10px;position:relative}.fb-field-wrapper .subtemplate-wrapper .cover{position:absolute;top:0;left:0;height:100%;width:100%;z-index:2}.fb-field-wrapper .subtemplate-wrapper>label{display:block;border-bottom:thin solid #eee;padding-bottom:3px;margin-bottom:7px}.fb-field-wrapper .subtemplate-wrapper abbr{color:red}.fb-field-wrapper .input-line{clear:both;margin-bottom:10px}.fb-field-wrapper .input-line .above-line{margin-top:7px}.fb-field-wrapper .input-line>span{display:inline-block;vertical-align:top}.fb-field-wrapper .input-line>span input{width:100%}.fb-field-wrapper .input-line>span>label{display:block;font-size:13px;margin-left:3px}.fb-field-wrapper .help-block{display:block;font-size:12px;margin-top:5px}.fb-edit-field-wrapper{font-size:13px}.fb-edit-field-wrapper .fb-field-label{font-weight:400;background:#eee;padding:.75em;color:#666;font-size:1.25em}.fb-edit-field-wrapper .fb-field-label .type{margin-top:.5em;display:block;font-family:'Source Sans Pro',sans-serif;font-size:1em}.fb-edit-field-wrapper .fb-field-label .type:before{content:'Type: ';color:#999}.fb-edit-field-wrapper .fb-field-label .fa.fa-arrow-right{display:none}.fb-edit-field-wrapper .fb-edit-section-header{border-bottom:1px solid #ddd;margin-top:25px;margin-bottom:10px;padding-bottom:5px;clear:both;font-weight:700}.fb-edit-field-wrapper .js-add-option,.fb-edit-field-wrapper .js-remove-option{padding:3px 6px}.fb-edit-field-wrapper .fb-bottom-add{margin-top:8px}.fb-common-wrapper .fb-label-description{margin-bottom:10px}.fb-common-wrapper .fb-label-description input,.fb-common-wrapper .fb-label-description textarea{width:100%}.fb-common-wrapper .fb-label-description textarea{min-height:5em}.option-score-input{width:50px}.option-label-input{width:170px}.response-field-draggable-helper{border:1px dashed #ddd;background:#eee}.response-field-text input.rf-size-medium{width:300px}.response-field-text input.rf-size-large{width:100%}.response-field-textarea textarea.rf-size-small{width:200px;min-height:60px}.response-field-textarea textarea.rf-size-medium{width:400px;min-height:100px}.response-field-textarea textarea.rf-size-large{width:100%;min-height:200px}.response-field-address .street{width:400px}.response-field-address .city,.response-field-address .state,.response-field-address .zip,.response-field-address .country{width:198px}.response-field-date .month,.response-field-date .day,.response-field-date .year{width:50px}.response-field-time .hours,.response-field-time .minutes,.response-field-time .seconds{width:50px}.response-field-checkboxes .fb-option,.response-field-radio .fb-option{margin-bottom:5px;display:inline-block}.response-field-website input{width:200px}.response-field-signature .fb-signature{width:300px;height:150px}.response-field-signature .fb-signature-placeholder{color:#aaa}.response-field-grid .cover{display:none}.response-field-table{width:100%}.response-field-table .cover{display:none}.response-field-table .section-name{display:inline-block}.response-field-table .element-selector{margin:0 5px;float:right;position:absolute;right:5px;top:5px}.response-field-table tr{vertical-align:top}.response-field-table table{margin-bottom:30px}.response-field-table table td{padding:10px 10px 0}.response-field-table table td label{border:0!important}.response-field-table table .calculated{font-style:italic;color:#ccc}.response-field-table table select,.response-field-table table input[type=text],.response-field-table table textarea,.response-field-table table .fb-signature{width:100%}.fb-options-per-row-1:before{content:" ";display:table}.fb-options-per-row-1:after{content:" ";display:table;clear:both}.fb-options-per-row-1{clear:both}.fb-options-per-row-1 .fb-option-wrapper{width:100%}.fb-options-per-row-2:before{content:" ";display:table}.fb-options-per-row-2:after{content:" ";display:table;clear:both}.fb-options-per-row-2{clear:both}.fb-options-per-row-2 .fb-option-wrapper{width:50%}.fb-options-per-row-3:before{content:" ";display:table}.fb-options-per-row-3:after{content:" ";display:table;clear:both}.fb-options-per-row-3{clear:both}.fb-options-per-row-3 .fb-option-wrapper{width:33.333333333333336%}.fb-options-per-row-4:before{content:" ";display:table}.fb-options-per-row-4:after{content:" ";display:table;clear:both}.fb-options-per-row-4{clear:both}.fb-options-per-row-4 .fb-option-wrapper{width:25%}.fb-options-per-row-5:before{content:" ";display:table}.fb-options-per-row-5:after{content:" ";display:table;clear:both}.fb-options-per-row-5{clear:both}.fb-options-per-row-5 .fb-option-wrapper{width:20%}.fb-options-per-row-6:before{content:" ";display:table}.fb-options-per-row-6:after{content:" ";display:table;clear:both}.fb-options-per-row-6{clear:both}.fb-options-per-row-6 .fb-option-wrapper{width:16.666666666666668%}.fb-options-per-row-7:before{content:" ";display:table}.fb-options-per-row-7:after{content:" ";display:table;clear:both}.fb-options-per-row-7{clear:both}.fb-options-per-row-7 .fb-option-wrapper{width:14.285714285714286%}.fb-options-per-row-8:before{content:" ";display:table}.fb-options-per-row-8:after{content:" ";display:table;clear:both}.fb-options-per-row-8{clear:both}.fb-options-per-row-8 .fb-option-wrapper{width:12.5%}.fb-options-per-row-9:before{content:" ";display:table}.fb-options-per-row-9:after{content:" ";display:table;clear:both}.fb-options-per-row-9{clear:both}.fb-options-per-row-9 .fb-option-wrapper{width:11.11111111111111%}.fb-options-per-row-10:before{content:" ";display:table}.fb-options-per-row-10:after{content:" ";display:table;clear:both}.fb-options-per-row-10{clear:both}.fb-options-per-row-10 .fb-option-wrapper{width:10%}.fb-options-per-row-11:before{content:" ";display:table}.fb-options-per-row-11:after{content:" ";display:table;clear:both}.fb-options-per-row-11{clear:both}.fb-options-per-row-11 .fb-option-wrapper{width:9.090909090909092%}.fb-options-per-row-12:before{content:" ";display:table}.fb-options-per-row-12:after{content:" ";display:table;clear:both}.fb-options-per-row-12{clear:both}.fb-options-per-row-12 .fb-option-wrapper{width:8.333333333333334%}.fb-options-per-row-13:before{content:" ";display:table}.fb-options-per-row-13:after{content:" ";display:table;clear:both}.fb-options-per-row-13{clear:both}.fb-options-per-row-13 .fb-option-wrapper{width:7.6923076923076925%}.fb-options-per-row-14:before{content:" ";display:table}.fb-options-per-row-14:after{content:" ";display:table;clear:both}.fb-options-per-row-14{clear:both}.fb-options-per-row-14 .fb-option-wrapper{width:7.142857142857143%}.fb-options-per-row-15:before{content:" ";display:table}.fb-options-per-row-15:after{content:" ";display:table;clear:both}.fb-options-per-row-15{clear:both}.fb-options-per-row-15 .fb-option-wrapper{width:6.666666666666667%}.response-field-grid-table{border-collapse:collapse;border-spacing:0;margin-bottom:5px;table-layout:fixed;width:100%}.response-field-grid-table .response-field-grid-row{height:100px;vertical-align:top}.response-field-grid-table td{padding:10px 10px 0}.response-field-grid-table .element-selector{width:100%}.response-field-grid-table .element-selector .dropdown-toggle{width:100%}.response-field-grid-table .element-selector .dropdown-toggle span{font-size:2em}.response-field-grid-table .response-field-grid-cell{padding:10px 10px 0;border:1px dashed #ddd;background-color:rgba(255,255,255,.8)}.response-field-grid-table .response-field-grid-cell .cover{display:block}.response-field-grid-table .response-field-grid-cell .response-field-selector{margin:.5em}.response-field-grid-table .response-field-grid-cell .subtemplate-wrapper>label{display:none}.response-field-grid-table .response-field-grid-cell .help-block{display:none}.response-field-grid-table .response-field-grid-cell select,.response-field-grid-table .response-field-grid-cell input[type=text],.response-field-grid-table .response-field-grid-cell textarea,.response-field-grid-table .response-field-grid-cell .fb-signature{width:100%}
\ No newline at end of file
diff --git a/dist/formbuilder-min.js b/dist/formbuilder-min.js
index cb44897a..7d12041e 100644
--- a/dist/formbuilder-min.js
+++ b/dist/formbuilder-min.js
@@ -1 +1,3 @@
-(function(){rivets.binders.input={publishes:!0,routine:rivets.binders.value.routine,bind:function(a){return a.addEventListener("input",this.publish)},unbind:function(a){return a.removeEventListener("input",this.publish)}},rivets.configure({prefix:"rv",adapter:{subscribe:function(a,b,c){return c.wrapped=function(a,b){return c(b)},a.on("change:"+b,c.wrapped)},unsubscribe:function(a,b,c){return a.off("change:"+b,c.wrapped)},read:function(a,b){return"cid"===b?a.cid:a.get(b)},publish:function(a,b,c){return a.cid?a.set(b,c):a[b]=c}}})}).call(this),function(){var a,b,c,d,e,f,g,h,i,j,k,l={}.hasOwnProperty,m=function(a,b){function c(){this.constructor=a}for(var d in b)l.call(b,d)&&(a[d]=b[d]);return c.prototype=b.prototype,a.prototype=new c,a.__super__=b.prototype,a};e=function(a){function b(){return g=b.__super__.constructor.apply(this,arguments)}return m(b,a),b.prototype.sync=function(){},b.prototype.indexInDOM=function(){var a,b=this;return a=$(".fb-field-wrapper").filter(function(a,c){return $(c).data("cid")===b.cid}),$(".fb-field-wrapper").index(a)},b.prototype.is_input=function(){return null!=c.inputFields[this.get(c.options.mappings.FIELD_TYPE)]},b}(Backbone.DeepModel),d=function(a){function b(){return h=b.__super__.constructor.apply(this,arguments)}return m(b,a),b.prototype.initialize=function(){return this.on("add",this.copyCidToModel)},b.prototype.model=e,b.prototype.comparator=function(a){return a.indexInDOM()},b.prototype.copyCidToModel=function(a){return a.attributes.cid=a.cid},b}(Backbone.Collection),f=function(a){function b(){return i=b.__super__.constructor.apply(this,arguments)}return m(b,a),b.prototype.className="fb-field-wrapper",b.prototype.events={"click .subtemplate-wrapper":"focusEditView","click .js-duplicate":"duplicate","click .js-clear":"clear"},b.prototype.initialize=function(a){return this.parentView=a.parentView,this.listenTo(this.model,"change",this.render),this.listenTo(this.model,"destroy",this.remove)},b.prototype.render=function(){return this.$el.addClass("response-field-"+this.model.get(c.options.mappings.FIELD_TYPE)).data("cid",this.model.cid).html(c.templates["view/base"+(this.model.is_input()?"":"_non_input")]({rf:this.model})),this},b.prototype.focusEditView=function(){return this.parentView.createAndShowEditView(this.model)},b.prototype.clear=function(){return this.parentView.handleFormUpdate(),this.model.destroy()},b.prototype.duplicate=function(){var a;return a=_.clone(this.model.attributes),delete a.id,a.label+=" Copy",this.parentView.createField(a,{position:this.model.indexInDOM()+1})},b}(Backbone.View),b=function(a){function b(){return j=b.__super__.constructor.apply(this,arguments)}return m(b,a),b.prototype.className="edit-response-field",b.prototype.events={"click .js-add-option":"addOption","click .js-remove-option":"removeOption","click .js-default-updated":"defaultUpdated","input .option-label-input":"forceRender"},b.prototype.initialize=function(a){return this.parentView=a.parentView,this.listenTo(this.model,"destroy",this.remove)},b.prototype.render=function(){return this.$el.html(c.templates["edit/base"+(this.model.is_input()?"":"_non_input")]({rf:this.model})),rivets.bind(this.$el,{model:this.model}),this},b.prototype.remove=function(){return this.parentView.editView=void 0,this.parentView.$el.find('[data-target="#addField"]').click(),b.__super__.remove.apply(this,arguments)},b.prototype.addOption=function(a){var b,d,e,f;return b=$(a.currentTarget),d=this.$el.find(".option").index(b.closest(".option")),f=this.model.get(c.options.mappings.OPTIONS)||[],e={label:"",checked:!1},d>-1?f.splice(d+1,0,e):f.push(e),this.model.set(c.options.mappings.OPTIONS,f),this.model.trigger("change:"+c.options.mappings.OPTIONS),this.forceRender()},b.prototype.removeOption=function(a){var b,d,e;return b=$(a.currentTarget),d=this.$el.find(".js-remove-option").index(b),e=this.model.get(c.options.mappings.OPTIONS),e.splice(d,1),this.model.set(c.options.mappings.OPTIONS,e),this.model.trigger("change:"+c.options.mappings.OPTIONS),this.forceRender()},b.prototype.defaultUpdated=function(a){var b;return b=$(a.currentTarget),"checkboxes"!==this.model.get(c.options.mappings.FIELD_TYPE)&&this.$el.find(".js-default-updated").not(b).attr("checked",!1).trigger("change"),this.forceRender()},b.prototype.forceRender=function(){return this.model.trigger("change")},b}(Backbone.View),a=function(a){function e(){return k=e.__super__.constructor.apply(this,arguments)}return m(e,a),e.prototype.SUBVIEWS=[],e.prototype.events={"click .js-save-form":"saveForm","click .fb-tabs a":"showTab","click .fb-add-field-types a":"addField"},e.prototype.initialize=function(a){var b;return b=a.selector,this.formBuilder=a.formBuilder,this.bootstrapData=a.bootstrapData,null!=b&&this.setElement($(b)),this.collection=new d,this.collection.bind("add",this.addOne,this),this.collection.bind("reset",this.reset,this),this.collection.bind("change",this.handleFormUpdate,this),this.collection.bind("destroy add reset",this.hideShowNoResponseFields,this),this.collection.bind("destroy",this.ensureEditViewScrolled,this),this.render(),this.collection.reset(this.bootstrapData),this.initAutosave()},e.prototype.initAutosave=function(){var a=this;return this.formSaved=!0,this.saveFormButton=this.$el.find(".js-save-form"),this.saveFormButton.attr("disabled",!0).text(c.options.dict.ALL_CHANGES_SAVED),setInterval(function(){return a.saveForm.call(a)},5e3),$(window).bind("beforeunload",function(){return a.formSaved?void 0:c.options.dict.UNSAVED_CHANGES})},e.prototype.reset=function(){return this.$responseFields.html(""),this.addAll()},e.prototype.render=function(){var a,b,d,e;for(this.$el.html(c.templates.page()),this.$fbLeft=this.$el.find(".fb-left"),this.$responseFields=this.$el.find(".fb-response-fields"),this.bindWindowScrollEvent(),this.hideShowNoResponseFields(),e=this.SUBVIEWS,b=0,d=e.length;d>b;b++)a=e[b],new a({parentView:this}).render();return this},e.prototype.bindWindowScrollEvent=function(){var a=this;return $(window).on("scroll",function(){var b,c;if(a.$fbLeft.data("locked")!==!0)return c=Math.max(0,$(window).scrollTop()),b=a.$responseFields.height(),a.$fbLeft.css({"margin-top":Math.min(b,c)})})},e.prototype.showTab=function(a){var b,c,d;return b=$(a.currentTarget),d=b.data("target"),b.closest("li").addClass("active").siblings("li").removeClass("active"),$(d).addClass("active").siblings(".fb-tab-pane").removeClass("active"),"#editField"!==d&&this.unlockLeftWrapper(),"#editField"===d&&!this.editView&&(c=this.collection.models[0])?this.createAndShowEditView(c):void 0},e.prototype.addOne=function(a,b,c){var d,e;return e=new f({model:a,parentView:this}),null!=c.$replaceEl?c.$replaceEl.replaceWith(e.render().el):null==c.position||-1===c.position?this.$responseFields.append(e.render().el):0===c.position?this.$responseFields.prepend(e.render().el):(d=this.$responseFields.find(".fb-field-wrapper").eq(c.position))[0]?d.before(e.render().el):this.$responseFields.append(e.render().el)},e.prototype.setSortable=function(){var a=this;return this.$responseFields.hasClass("ui-sortable")&&this.$responseFields.sortable("destroy"),this.$responseFields.sortable({forcePlaceholderSize:!0,placeholder:"sortable-placeholder",stop:function(b,d){var e;return d.item.data("field-type")&&(e=a.collection.create(c.helpers.defaultFieldAttrs(d.item.data("field-type")),{$replaceEl:d.item}),a.createAndShowEditView(e)),a.handleFormUpdate(),!0},update:function(b,c){return c.item.data("field-type")?void 0:a.ensureEditViewScrolled()}}),this.setDraggable()},e.prototype.setDraggable=function(){var a,b=this;return a=this.$el.find("[data-field-type]"),a.draggable({connectToSortable:this.$responseFields,helper:function(){var a;return a=$("
"),a.css({width:b.$responseFields.width(),height:"80px"}),a}})},e.prototype.addAll=function(){return this.collection.each(this.addOne,this),this.setSortable()},e.prototype.hideShowNoResponseFields=function(){return this.$el.find(".fb-no-response-fields")[this.collection.length>0?"hide":"show"]()},e.prototype.addField=function(a){var b;return b=$(a.currentTarget).data("field-type"),this.createField(c.helpers.defaultFieldAttrs(b))},e.prototype.createField=function(a,b){var c;return c=this.collection.create(a,b),this.createAndShowEditView(c),this.handleFormUpdate()},e.prototype.createAndShowEditView=function(a){var c,d,e;if(d=this.$el.find(".fb-field-wrapper").filter(function(){return $(this).data("cid")===a.cid}),d.addClass("editing").siblings(".fb-field-wrapper").removeClass("editing"),this.editView){if(this.editView.model.cid===a.cid)return this.$el.find('.fb-tabs a[data-target="#editField"]').click(),this.scrollLeftWrapper(d,"undefined"!=typeof e&&null!==e&&e),void 0;e=this.$fbLeft.css("padding-top"),this.editView.remove()}return this.editView=new b({model:a,parentView:this}),c=this.editView.render().$el,this.$el.find(".fb-edit-field-wrapper").html(c),this.$el.find('.fb-tabs a[data-target="#editField"]').click(),this.scrollLeftWrapper(d),this},e.prototype.ensureEditViewScrolled=function(){return this.editView?this.scrollLeftWrapper($(".fb-field-wrapper.editing")):void 0},e.prototype.scrollLeftWrapper=function(a){var b=this;return this.unlockLeftWrapper(),a[0]?$.scrollWindowTo(a.offset().top-this.$responseFields.offset().top,200,function(){return b.lockLeftWrapper()}):void 0},e.prototype.lockLeftWrapper=function(){return this.$fbLeft.data("locked",!0)},e.prototype.unlockLeftWrapper=function(){return this.$fbLeft.data("locked",!1)},e.prototype.handleFormUpdate=function(){return this.updatingBatch?void 0:(this.formSaved=!1,this.saveFormButton.removeAttr("disabled").text(c.options.dict.SAVE_FORM))},e.prototype.saveForm=function(){var a;if(!this.formSaved)return this.formSaved=!0,this.saveFormButton.attr("disabled",!0).text(c.options.dict.ALL_CHANGES_SAVED),this.collection.sort(),a=JSON.stringify({fields:this.collection.toJSON()}),c.options.HTTP_ENDPOINT&&this.doAjaxSave(a),this.formBuilder.trigger("save",a)},e.prototype.doAjaxSave=function(a){var b=this;return $.ajax({url:c.options.HTTP_ENDPOINT,type:c.options.HTTP_METHOD,data:a,contentType:"application/json",success:function(a){var c,d,e,f;for(b.updatingBatch=!0,d=0,e=a.length;e>d;d++)c=a[d],null!=(f=b.collection.get(c.cid))&&f.set({id:c.id}),b.collection.trigger("sync");return b.updatingBatch=void 0}})},e}(Backbone.View),c=function(){function b(b){var c;null==b&&(b={}),_.extend(this,Backbone.Events),c=_.extend(b,{formBuilder:this}),this.mainView=new a(c)}return b.helpers={defaultFieldAttrs:function(a){var c,d;return c={label:"Untitled",field_type:a,required:!0,field_options:{}},("function"==typeof(d=b.fields[a]).defaultAttributes?d.defaultAttributes(c):void 0)||c},simple_format:function(a){return null!=a?a.replace(/\n/g," "):void 0}},b.options={BUTTON_CLASS:"fb-button",HTTP_ENDPOINT:"",HTTP_METHOD:"POST",mappings:{SIZE:"field_options.size",UNITS:"field_options.units",LABEL:"label",FIELD_TYPE:"field_type",REQUIRED:"required",ADMIN_ONLY:"admin_only",OPTIONS:"field_options.options",DESCRIPTION:"field_options.description",INCLUDE_OTHER:"field_options.include_other_option",INCLUDE_BLANK:"field_options.include_blank_option",INTEGER_ONLY:"field_options.integer_only",MIN:"field_options.min",MAX:"field_options.max",MINLENGTH:"field_options.minlength",MAXLENGTH:"field_options.maxlength",LENGTH_UNITS:"field_options.min_max_length_units"},dict:{ALL_CHANGES_SAVED:"All changes saved",SAVE_FORM:"Save form",UNSAVED_CHANGES:"You have unsaved changes. If you leave this page, you will lose those changes!"}},b.fields={},b.inputFields={},b.nonInputFields={},b.registerField=function(a,c){var d,e,f,g;for(g=["view","edit"],e=0,f=g.length;f>e;e++)d=g[e],c[d]=_.template(c[d]);return c.field_type=a,b.fields[a]=c,"non_input"===c.type?b.nonInputFields[a]=c:b.inputFields[a]=c},b}(),window.Formbuilder=c,"undefined"!=typeof module&&null!==module?module.exports=c:window.Formbuilder=c}.call(this),function(){Formbuilder.registerField("address",{order:50,view:"\n \n \n Address \n \n
\n\n\n \n \n City \n \n\n \n \n State / Province / Region \n \n
\n\n\n \n \n Zipcode \n \n\n \n United States \n Country \n \n
",edit:"",addButton:' Address'})}.call(this),function(){Formbuilder.registerField("checkboxes",{order:10,view:"<% for (i in (rf.get(Formbuilder.options.mappings.OPTIONS) || [])) { %>\n \n \n onclick=\"javascript: return false;\" />\n <%= rf.get(Formbuilder.options.mappings.OPTIONS)[i].label %>\n \n
\n<% } %>\n\n<% if (rf.get(Formbuilder.options.mappings.INCLUDE_OTHER)) { %>\n \n \n \n Other\n \n\n \n
\n<% } %>",edit:"<%= Formbuilder.templates['edit/options']({ includeOther: true }) %>",addButton:' Checkboxes',defaultAttributes:function(a){return a.field_options.options=[{label:"",checked:!1},{label:"",checked:!1}],a}})}.call(this),function(){Formbuilder.registerField("date",{order:20,view:"\n \n \n MM \n \n\n / \n\n \n \n DD \n \n\n / \n\n \n \n YYYY \n \n
",edit:"",addButton:' Date'})}.call(this),function(){Formbuilder.registerField("dropdown",{order:24,view:"\n <% if (rf.get(Formbuilder.options.mappings.INCLUDE_BLANK)) { %>\n \n <% } %>\n\n <% for (i in (rf.get(Formbuilder.options.mappings.OPTIONS) || [])) { %>\n >\n <%= rf.get(Formbuilder.options.mappings.OPTIONS)[i].label %>\n \n <% } %>\n ",edit:"<%= Formbuilder.templates['edit/options']({ includeBlank: true }) %>",addButton:' Dropdown',defaultAttributes:function(a){return a.field_options.options=[{label:"",checked:!1},{label:"",checked:!1}],a.field_options.include_blank_option=!1,a}})}.call(this),function(){Formbuilder.registerField("email",{order:40,view:" ",edit:"",addButton:' Email'})}.call(this),function(){Formbuilder.registerField("file",{order:55,view:" ",edit:"",addButton:' File'})}.call(this),function(){Formbuilder.registerField("number",{order:30,view:" \n<% if (units = rf.get(Formbuilder.options.mappings.UNITS)) { %>\n <%= units %>\n<% } %>",edit:"<%= Formbuilder.templates['edit/min_max']() %>\n<%= Formbuilder.templates['edit/units']() %>\n<%= Formbuilder.templates['edit/integer_only']() %>",addButton:'123 Number'})}.call(this),function(){Formbuilder.registerField("paragraph",{order:5,view:"",edit:"<%= Formbuilder.templates['edit/size']() %>\n<%= Formbuilder.templates['edit/min_max_length']() %>",addButton:'¶ Paragraph',defaultAttributes:function(a){return a.field_options.size="small",a}})}.call(this),function(){Formbuilder.registerField("price",{order:45,view:"\n $ \n \n \n Dollars \n \n . \n \n \n Cents \n \n
",edit:"",addButton:' Price'})}.call(this),function(){Formbuilder.registerField("radio",{order:15,view:"<% for (i in (rf.get(Formbuilder.options.mappings.OPTIONS) || [])) { %>\n \n \n onclick=\"javascript: return false;\" />\n <%= rf.get(Formbuilder.options.mappings.OPTIONS)[i].label %>\n \n
\n<% } %>\n\n<% if (rf.get(Formbuilder.options.mappings.INCLUDE_OTHER)) { %>\n \n \n \n Other\n \n\n \n
\n<% } %>",edit:"<%= Formbuilder.templates['edit/options']({ includeOther: true }) %>",addButton:' Multiple Choice',defaultAttributes:function(a){return a.field_options.options=[{label:"",checked:!1},{label:"",checked:!1}],a}})}.call(this),function(){Formbuilder.registerField("section_break",{order:0,type:"non_input",view:"<%= rf.get(Formbuilder.options.mappings.LABEL) %> \n<%= rf.get(Formbuilder.options.mappings.DESCRIPTION) %>
",edit:"\n \n",addButton:" Section Break"})}.call(this),function(){Formbuilder.registerField("text",{order:0,view:" ",edit:"<%= Formbuilder.templates['edit/size']() %>\n<%= Formbuilder.templates['edit/min_max_length']() %>",addButton:" Text",defaultAttributes:function(a){return a.field_options.size="small",a}})}.call(this),function(){Formbuilder.registerField("time",{order:25,view:"\n \n \n HH \n \n\n : \n\n \n \n MM \n \n\n : \n\n \n \n SS \n \n\n \n \n AM \n PM \n \n \n
",edit:"",addButton:' Time'})}.call(this),function(){Formbuilder.registerField("website",{order:35,view:" ",edit:"<%= Formbuilder.templates['edit/size']() %>",addButton:' Website'})}.call(this),this.Formbuilder=this.Formbuilder||{},this.Formbuilder.templates=this.Formbuilder.templates||{},this.Formbuilder.templates["edit/base"]=function(obj){obj||(obj={});{var __t,__p="";_.escape}with(obj)__p+=(null==(__t=Formbuilder.templates["edit/base_header"]())?"":__t)+"\n"+(null==(__t=Formbuilder.templates["edit/common"]())?"":__t)+"\n"+(null==(__t=Formbuilder.fields[rf.get(Formbuilder.options.mappings.FIELD_TYPE)].edit({rf:rf}))?"":__t)+"\n";return __p},this.Formbuilder.templates["edit/base_header"]=function(obj){obj||(obj={});{var __t,__p="";_.escape}with(obj)__p+="\n \n
\n \n
";return __p},this.Formbuilder.templates["edit/base_non_input"]=function(obj){obj||(obj={});{var __t,__p="";_.escape}with(obj)__p+=(null==(__t=Formbuilder.templates["edit/base_header"]())?"":__t)+"\n"+(null==(__t=Formbuilder.fields[rf.get(Formbuilder.options.mappings.FIELD_TYPE)].edit({rf:rf}))?"":__t)+"\n";return __p},this.Formbuilder.templates["edit/checkboxes"]=function(obj){obj||(obj={});{var __t,__p="";_.escape}with(obj)__p+="\n \n Required\n \n\n \n Admin only\n ";return __p},this.Formbuilder.templates["edit/common"]=function(obj){obj||(obj={});{var __t,__p="";_.escape}with(obj)__p+="\n\n\n
\n "+(null==(__t=Formbuilder.templates["edit/label_description"]())?"":__t)+"\n
\n
\n "+(null==(__t=Formbuilder.templates["edit/checkboxes"]())?"":__t)+"\n
\n
\n
\n";return __p},this.Formbuilder.templates["edit/integer_only"]=function(obj){obj||(obj={});{var __t,__p="";_.escape}with(obj)__p+="\n\n \n Only accept integers\n \n";return __p},this.Formbuilder.templates["edit/label_description"]=function(obj){obj||(obj={});{var __t,__p="";_.escape}with(obj)__p+=" \n";return __p},this.Formbuilder.templates["edit/min_max"]=function(obj){obj||(obj={});{var __t,__p="";_.escape}with(obj)__p+='\n\nAbove\n \n\n \n\nBelow\n \n';return __p},this.Formbuilder.templates["edit/min_max_length"]=function(obj){obj||(obj={});{var __t,__p="";_.escape}with(obj)__p+='\n\nMin\n \n\n \n\nMax\n \n\n \n\n\n characters \n words \n \n';return __p},this.Formbuilder.templates["edit/options"]=function(obj){obj||(obj={});{var __t,__p="";_.escape,Array.prototype.join}with(obj)__p+="\n\n","undefined"!=typeof includeBlank&&(__p+="\n \n \n Include blank\n \n"),__p+="\n\n\n\n',"undefined"!=typeof includeOther&&(__p+="\n \n \n Include "other"\n \n'),__p+="\n\n\n';return __p},this.Formbuilder.templates["edit/size"]=function(obj){obj||(obj={});{var __t,__p="";_.escape}with(obj)__p+="\n\n Small \n Medium \n Large \n \n';return __p},this.Formbuilder.templates["edit/units"]=function(obj){obj||(obj={});{var __t,__p="";_.escape}with(obj)__p+='\n \n';return __p},this.Formbuilder.templates.page=function(obj){obj||(obj={});{var __t,__p="";_.escape}with(obj)__p+=(null==(__t=Formbuilder.templates["partials/save_button"]())?"":__t)+"\n"+(null==(__t=Formbuilder.templates["partials/left_side"]())?"":__t)+"\n"+(null==(__t=Formbuilder.templates["partials/right_side"]())?"":__t)+"\n
";return __p},this.Formbuilder.templates["partials/add_field"]=function(obj){obj||(obj={});{var __t,__p="";_.escape,Array.prototype.join}with(obj)__p+="";return __p},this.Formbuilder.templates["partials/edit_field"]=function(obj){obj||(obj={});{var __p="";_.escape}with(obj)__p+="\n";return __p},this.Formbuilder.templates["partials/left_side"]=function(obj){obj||(obj={});{var __t,__p="";_.escape}with(obj)__p+="\n
\n\n
\n "+(null==(__t=Formbuilder.templates["partials/add_field"]())?"":__t)+"\n "+(null==(__t=Formbuilder.templates["partials/edit_field"]())?"":__t)+"\n
\n
";return __p},this.Formbuilder.templates["partials/right_side"]=function(obj){obj||(obj={});{var __p="";_.escape}with(obj)__p+="\n
No response fields
\n
\n
\n";return __p},this.Formbuilder.templates["partials/save_button"]=function(obj){obj||(obj={});{var __t,__p="";_.escape}with(obj)__p+="\n \n
";return __p},this.Formbuilder.templates["view/base"]=function(obj){obj||(obj={});{var __t,__p="";_.escape}with(obj)__p+="\n
\n "+(null==(__t=Formbuilder.templates["view/label"]({rf:rf}))?"":__t)+"\n\n "+(null==(__t=Formbuilder.fields[rf.get(Formbuilder.options.mappings.FIELD_TYPE)].view({rf:rf}))?"":__t)+"\n\n "+(null==(__t=Formbuilder.templates["view/description"]({rf:rf}))?"":__t)+"\n "+(null==(__t=Formbuilder.templates["view/duplicate_remove"]({rf:rf}))?"":__t)+"\n
\n";return __p},this.Formbuilder.templates["view/base_non_input"]=function(obj){obj||(obj={});{var __t,__p="";_.escape}with(obj)__p+="\n
\n "+(null==(__t=Formbuilder.fields[rf.get(Formbuilder.options.mappings.FIELD_TYPE)].view({rf:rf}))?"":__t)+"\n "+(null==(__t=Formbuilder.templates["view/duplicate_remove"]({rf:rf}))?"":__t)+"\n
\n";return __p},this.Formbuilder.templates["view/description"]=function(obj){obj||(obj={});{var __t,__p="";_.escape}with(obj)__p+="\n "+(null==(__t=Formbuilder.helpers.simple_format(rf.get(Formbuilder.options.mappings.DESCRIPTION)))?"":__t)+"\n \n";return __p},this.Formbuilder.templates["view/duplicate_remove"]=function(obj){obj||(obj={});{var __t,__p="";_.escape}with(obj)__p+="';return __p},this.Formbuilder.templates["view/label"]=function(obj){obj||(obj={});{var __t,__p="";_.escape,Array.prototype.join}with(obj)__p+="\n "+(null==(__t=Formbuilder.helpers.simple_format(rf.get(Formbuilder.options.mappings.LABEL)))?"":__t)+"\n ",rf.get(Formbuilder.options.mappings.REQUIRED)&&(__p+="\n * \n "),__p+="\n \n";return __p};
\ No newline at end of file
+(function(){rivets.binders.append={routine:function(a,b){return a.checked=void 0!==_.find(b,function(b){return String(b)===String(a.value)})},bind:function(a){var b=this;return this.callback=function(){var c,d;return c=_.clone(b.model.get(b.keypath))||[],a.value&&_.contains(c,a.value)?(d=_.without(c,a.value),b.model.set(b.keypath,c)):(c.push(a.value),b.model.set(b.keypath,c))},$(a).on("change",this.callback)},unbind:function(a){return $(a).off("change",this.callback)}},rivets.formatters.length=function(a){return a?a.length:0},rivets.binders.input={publishes:!0,routine:rivets.binders.value.routine,bind:function(a){return $(a).bind("input.rivets",this.publish)},unbind:function(a){return $(a).unbind("input.rivets")}},rivets.configure({prefix:"rv",adapter:{subscribe:function(a,b,c){return c.wrapped=function(a,b){return c(b)},a.on("change:"+b,c.wrapped)},unsubscribe:function(a,b,c){return a.off("change:"+b,c.wrapped)},read:function(a,b){return"cid"===b?a.cid:a.get(b)},publish:function(a,b,c){return a.cid?a.set(b,c):a[b]=c}}})}).call(this),function(){var a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p={}.hasOwnProperty,q=function(a,b){function c(){this.constructor=a}for(var d in b)p.call(b,d)&&(a[d]=b[d]);return c.prototype=b.prototype,a.prototype=new c,a.__super__=b.prototype,a};e=function(a){function b(){return i=b.__super__.constructor.apply(this,arguments)}return q(b,a),b.prototype.sync=function(){},b.prototype.indexInDOM=function(){var a,b=this;return a=$(".fb-field-wrapper").filter(function(a,c){return $(c).data("cid")===b.cid}),a.index(".fb-field-wrapper")},b.prototype.is_input=function(){return null!=c.inputFields[this.get(c.options.mappings.TYPE)]},b.prototype.initialize=function(){return null==this.attributes.uuid&&(this.attributes.uuid=uuid.v4()),void 0===!this.attributes.parent_uuid&&(this.attributes.parent_uuid=null),this.attachMethods()},b.prototype.parentModel=function(){return this.collection.findWhereUuid(this.get("parent_uuid"))},b.prototype.hasParent=function(){return void 0!==this.parentModel},b.prototype.attachMethods=function(){return"function"==typeof this.attributes.initialize&&(this.attributes.initialize.call(this),delete this.attributes.initialize),"function"==typeof this.attributes.insertion&&(this.insertion=this.attributes.insertion,delete this.attributes.insertion),_.each(this.attributes,function(a,b){return"function"==typeof a&&void 0===this[b]?(this[b]=a,delete this.attributes[b]):void 0},this)},b}(Backbone.DeepModel),d=function(a){function b(){return j=b.__super__.constructor.apply(this,arguments)}return q(b,a),b.prototype.model=e,b.prototype.comparator=function(a){return a.indexInDOM()},b.prototype.add=function(a){var c;return c=a=b.__super__.add.call(this,a),_.isArray(a)||(c=[a]),_.each(c,function(a){return"function"==typeof a.insertion?a.insertion.call(a):void 0}),a},b.prototype.findWhereUuid=function(a){return this.findWhere({uuid:a})},b.prototype.findDataSourceFields=function(){return this.where({type:"datasource"})},b}(Backbone.Collection),h=function(a){function b(){return k=b.__super__.constructor.apply(this,arguments)}return q(b,a),b.insert=function(a,b,c,d,e){var f,g,h,i;return h=c.parentModel(),void 0===h||"grid"===h.get("type")||"table"===h.get("type")?(g=e.$appendEl||null,i=e.$replaceEl||null,null!=g?g.html(b.render().el):null!=i?i.replaceWith(b.render().el):null==e.position||-1===e.position?a.$responseFields.append(b.render().el):0===e.position?a.$responseFields.prepend(b.render().el):(f=a.$responseFields.find(".fb-field-wrapper").eq(e.position))[0]?f.before(b.render().el):a.$responseFields.append(b.render().el)):void 0},b.prototype.className="fb-field-wrapper",b.prototype.events={"click .subtemplate-wrapper":"focusEditView","click .js-duplicate":"duplicate","click .js-clear":"clear"},b.prototype.initialize=function(a){return this.parentView=a.parentView,this.listenTo(this.model,"change",this.render),this.listenTo(this.model,"destroy",this.remove)},b.prototype.render=function(){return this.$el.addClass("response-field-"+this.model.get(c.options.mappings.TYPE)).data("cid",this.model.cid).data("uuid",this.model.get("uuid")).html(c.templates["view/base"+(this.model.is_input()?"":"_non_input")]({rf:this.model})),this},b.prototype.focusEditView=function(){return this.parentView.createAndShowEditView(this.model)},b.prototype.clear=function(a){var b,d,e=this;switch(a.preventDefault(),a.stopPropagation(),b=function(){return e.parentView.handleFormUpdate(),e.model.destroy()},d=c.options.CLEAR_FIELD_CONFIRM,typeof d){case"string":if(confirm(d))return b();break;case"function":return d(b);default:return b()}},b.prototype.duplicate=function(a){var b;return a.preventDefault(),a.stopPropagation(),b=c.helpers.clone(this.model.attributes),delete b.id,delete b.cid,delete b.uuid,b.label+=" Copy",b.options.grid&&(b.options.grid.row=b.options.grid.row+1),this.parentView.createField(b,{position:this.model.indexInDOM()+1}),this.model.trigger("duplicate:viewfield")},b}(Backbone.View),g=function(a){function b(){return l=b.__super__.constructor.apply(this,arguments)}return q(b,a),b.prototype.className="fb-field-wrapper",b.prototype.initialize=function(a){return this.parentView=a.parentView,this.listenTo(this.model,"change",this.update),this.listenTo(this.model,"destroy",this.remove),_.each(this.model.get("options.elements"),function(a){var b;return b=this.model.collection.findWhereUuid(a.uuid),b?(this.listenTo(b,"change",this.update),this.listenTo(b,"destroy",function(a){return this.update(a)})):console.log(a.uuid)},this)},b.prototype.events={mouseenter:"showSelectors",mouseleave:"removeSelectors","click .drop-area li":"inlineAdd","click .subtemplate-wrapper":"focusEditView","click .response-field-table td.header":"focusSubelement","click .response-field-table td.element":"focusSubelement","click .js-clear":"clear","click .js-duplicate":"duplicate"},b.prototype.showSelectors=function(a){return this.$el.find(".drop-area").html(c.templates["view/element_selector"]())},b.prototype.removeSelectors=function(a){return this.$el.find(".drop-area").html("")},b.prototype.inlineAdd=function(a){var b,d,f;return a.preventDefault(),a.stopPropagation(),b=new e(c.helpers.defaultFieldAttrs($(a.currentTarget).data("type"))),b.set("parent_uuid",this.model.get("uuid")),b.set("options.in_sequence",!0),this.listenTo(b,"change",this.update),d=this.model.attributes.options.elements||[],f={uuid:b.get("uuid")},d.push(f),this.model.attributes.options.elements=d,this.parentView.collection.add(b),this.update(b)},b.prototype.update=function(a){return a?(this.render(),this.parentView.createAndShowEditView(a)):void 0},b.prototype.render=function(){return b.__super__.render.call(this),this.renderElements(),this},b.prototype.focusEditView=function(a){return this.parentView.createAndShowEditView(this.model)},b.prototype.focusSubelement=function(a){var b;return a.preventDefault(),a.stopPropagation(),b=$(a.currentTarget).data("uuid"),b?this.parentView.createAndShowEditView(this.parentView.modelByUuid(b)):void 0},b.prototype.renderElements=function(){return _.each(this.model.get("options.elements"),function(a){var b;return b=this.parentView.modelByUuid(a.uuid),this.$el.find(".header-"+a.uuid).html(c.templates["view/table_header"]({rf:b,element:a})).data("cid",b.cid),this.$el.find(".element-"+a.uuid).html(c.templates["view/table_element"]({rf:b,element:a})).data("cid",b.cid),this.$el.find(".total-"+a.uuid).html(c.templates["view/table_total"]({rf:b,element:a})).data("cid",b.cid)},this)},b.prototype.clear=function(a){var b,c;return a.preventDefault(),a.stopPropagation(),c=$(a.currentTarget).parents(".element").data("uuid"),void 0===c?(b=_.each(this.model.get("options.elements"),function(a){return this.parentView.modelByUuid(a.uuid).destroy(),!0},this),this.model.destroy(),this.$el.remove()):(this.parentView.modelByUuid(c).destroy(),this.model.set("options.elements",_.filter(this.model.get("options.elements"),function(a){return a.uuid!==c})),this.render())},b.prototype.duplicate=function(){var a,b,d,f,g=this;return a=c.helpers.clone(this.model.attributes),delete a.id,delete a.cid,a.uuid=uuid.v4(),a.label+=" Copy",f=a.options.elements,a.options.elements=[],a=_.extend({},c.helpers.defaultFieldAttrs("table"),a),this.parentView.createField(a,{position:-1}),d=this.parentView.viewByUuid(a.uuid),b=this.parentView.modelByUuid(a.uuid),_.each(f,function(f){var h,i,j,k;return h=g.parentView.modelByUuid(f.uuid),i=c.helpers.clone(h),delete i.id,delete i.cid,f.uuid=i.uuid=uuid.v4(),i.parent_uuid=a.uuid,i=_.extend({},c.helpers.defaultFieldAttrs(i.type),i),j=new e(i),f.totalColumn&&(k=b.createTotalColumnModel(i.uuid),f.totalColumnUuid=k.get("uuid")),g.parentView.collection.add(j),void 0!==j.expression&&j.get("options.calculation_type")&&j.expression(),d.listenTo(j,"change",d.update),a.options.elements.push(f)}),d.render()},b.insert=function(a,b,c,d,e){var f;return f=a.viewByUuid(c.get("parent_uuid")),null!=f?!0:!1},b}(h),f=function(a){function b(){return m=b.__super__.constructor.apply(this,arguments)}return q(b,a),b.prototype.className="fb-field-wrapper",b.prototype.events={"click .response-field-grid-cell li":"inlineAdd","click .response-field-grid-cell .js-clear":"subelementClear","click .js-duplicate":"duplicate","click .js-clear":"clear","click .subtemplate-wrapper":"focusEditView"},b.prototype.initialize=function(a){return this.parentView=a.parentView,this.listenTo(this.model,"change",this.redraw),this.listenTo(this.model,"destroy",this.remove),this.parentView.collection.bind("add",this.addSubelement,this),this.parentView.collection.bind("destroy",this.removeSubelement,this),this.render},b.prototype.render=function(){return b.__super__.render.call(this),this.redraw(),this.renderChildren(),this},b.prototype.redraw=function(){var a;return a=this.$el.find(".response-field-grid-table").detach(),this.$el.addClass("response-field-"+this.model.get(c.options.mappings.TYPE)).data("cid",this.model.cid).data("uuid",this.model.get("uuid")).html(c.templates["view/base"+(this.model.is_input()?"":"_non_input")]({rf:this.model})),1===a.length&&this.$el.find(".response-field-grid-table").replaceWith(a),this.renderTable()},b.prototype.renderTable=function(){var a,b,d,e,f,g,h,i,j,k=this;return e=this.model.get("options.num_rows")||1,d=this.model.get("options.num_cols")||1,h=this.$el.find("table"),b=h.find("tr").length,a=h.find("tr:nth-child(1) td").length,f=$.makeArray(h.find("tr")),e>b&&(f=f.concat(function(){j=[];for(var a=i=f.length;e>=i?e>a:a>e;e>=i?a++:a--)j.push(a);return j}.apply(this))),f=_.map(f,function(a){var b,e,f;return _.isNumber(a)&&(a=$(' ').appendTo(h)),b=$.makeArray($(a).find("td")),b.length=e?d>a:a>d;d>=e?a++:a--)f.push(a);return f}.apply(this))),b=_.map(b,function(b){return _.isNumber(b)?b=$(' ').appendTo(a).html(c.templates["view/element_selector"]()):void 0}),a}),b>e&&(g=this.subelements(),_.each(g,function(a){var b;return b=k.parentView.gridAttr(a),b.row>e-1?a.destroy():void 0}),h.find("tr").slice(e-b).remove()),a>d?(g=this.subelements(),_.each(g,function(a){var b;return b=k.parentView.gridAttr(a),b.col>d-1?a.destroy():void 0}),h.find("tr").find("td:gt("+(d-1)+")").remove()):void 0},b.prototype.renderChildren=function(){var a,b=this;return a=this.model.get("children")||[],_.each(a,function(a){var c;return c=a.options.grid,b.createField(a,b.getSubelement(c.row,c.col))})},b.prototype.focusEditView=function(a){return 0===$(a.target).parents("table").length?this.parentView.createAndShowEditView(this.model):void 0},b.prototype.clear=function(a){var b,d,e=this;switch(a.preventDefault(),a.stopPropagation(),b=function(){var a;return e.parentView.handleFormUpdate(),a=e.subelements(),_.each(e.subelements(),function(a){return a.destroy(),!0}),e.model.destroy()},d=c.options.CLEAR_FIELD_CONFIRM,typeof d){case"string":if(confirm(d))return b();break;case"function":return d(b);default:return b()}},b.prototype.duplicate=function(){var a,b,d=this;return a=c.helpers.clone(this.model.attributes),delete a.id,delete a.cid,a.uuid=uuid.v4(),a.label+=" Copy",b=this.subelements(),delete a.children,this.parentView.createField(a,{position:-1}),a.children=_.map(b,function(b){var e;return e=c.helpers.clone(b.attributes),delete e.id,delete e.cid,delete e.uuid,e.parent_uuid=a.uuid,d.parentView.createField(e,{position:-1})})},b.prototype.addSubelement=function(a){var b,c;return this.belongsToMe(a)&&a.get("label").match(/Copy/)?(b=this.parentView.gridAttr(a),c=a.get("label").match(/(.+) Copy/),null!==c?a.attributes.label=c[1]+" "+(b.row+1):a.attributes.label="Row: "+(b.row+1)+", Col: "+(b.col+1)):void 0},b.prototype.removeSubelement=function(a){var b,d;return d=this.parentView.gridAttr(a),b=this.belongsToMe(a),b&&""===this.getSubelement(d.row,d.col).html()?this.getSubelement(d.row,d.col).html(c.templates["view/element_selector"]({rf:this.model})):void 0},b.prototype.subelements=function(){var a=this;return this.parentView.collection.filter(function(b){return a.belongsToMe(b)})},b.prototype.belongsToMe=function(a){return this.parentView.inGrid(a)&&a.get("parent_uuid")===this.model.get("uuid")},b.prototype.inlineAdd=function(a){var b,c;return a.preventDefault(),a.stopPropagation(),c=$(a.currentTarget).data("type"),b=$(a.currentTarget).parents(".response-field-grid-cell"),this.createField(c,b)},b.prototype.getSubelement=function(a,b){return a++,b++,this.$el.find("tr:nth-child("+a+") td:nth-child("+b+")")},b.prototype.createField=function(a,b){return _.isString(a)&&(a=c.helpers.defaultFieldAttrs(a)),a.options.grid={col:b.prop("cellIndex"),row:b.parents("tr").prop("rowIndex")},a.parent_uuid=this.model.get("uuid"),this.parentView.createField(a,{$appendEl:b})},b.insert=function(a,b,c,d,e){var f,g,i;return e.$appendEl||(i=c.get("options.grid.row"),g=c.get("options.grid.col"),f=a.wrapperByUuid(c.get("parent_uuid")),f=f.find("tr:nth-child("+(i+1)+") td:nth-child("+(g+1)+")"),1===f.length&&(e.$appendEl=f)),h.insert(a,b,c,d,e)},b}(Backbone.View),b=function(a){function b(){return n=b.__super__.constructor.apply(this,arguments)}return q(b,a),b.prototype.className="edit-response-field",b.prototype.events={"click .js-add-option":"addOption","click .js-remove-option":"removeOption","click .js-default-updated":"defaultUpdated","input .option-label-input":"forceRender"},b.prototype.initialize=function(a){var b=this;return this.parentView=a.parentView,this.listenTo(this.model,"destroy",this.remove),_.each(c.options.change,function(a,d){var e;return e="change:"+_.nested(c.options.mappings,d),b.listenTo(b.model,e,a)})},b.prototype.render=function(){return this.$el.html(c.templates["edit/base"+(this.model.is_input()?"":"_non_input")]({rf:this.model})),rivets.bind(this.$el,{model:this.model}),this},b.prototype.reset=function(){return this.parentView.editView=void 0,this.parentView.createAndShowEditView(this.model)},b.prototype.remove=function(){return this.parentView.editView=void 0,this.parentView.$el.find('[data-target="#addField"]').click(),b.__super__.remove.apply(this,arguments)},b.prototype.addOption=function(a){var b,d,e,f;return b=$(a.currentTarget),d=this.$el.find(".option").index(b.closest(".option")),f=this.model.get(c.options.mappings.OPTIONS)||[],e={uuid:uuid.v4(),label:"",checked:!1},d>-1?f.splice(d+1,0,e):f.push(e),this.model.set(c.options.mappings.OPTIONS,f),this.model.trigger("change:"+c.options.mappings.OPTIONS),this.forceRender()},b.prototype.removeOption=function(a){var b,d,e;return b=$(a.currentTarget),d=this.$el.find(".js-remove-option").index(b),e=this.model.get(c.options.mappings.OPTIONS),e.splice(d,1),this.model.set(c.options.mappings.OPTIONS,e),this.model.trigger("change:"+c.options.mappings.OPTIONS),this.forceRender()},b.prototype.defaultUpdated=function(a){var b;return b=$(a.currentTarget),"checkboxes"!==this.model.get(c.options.mappings.TYPE)&&this.$el.find(".js-default-updated").not(b).attr("checked",!1).trigger("change"),this.forceRender()},b.prototype.forceRender=function(){return this.model.trigger("change",this.model)},b}(Backbone.View),a=function(a){function e(){return o=e.__super__.constructor.apply(this,arguments)}return q(e,a),e.prototype.SUBVIEWS=[],e.prototype.saveFormButton=$(),e.prototype.events={"click .fb-tabs a":"showTab","click .fb-add-types a":"addField","mouseover .fb-add-types":"lockLeftWrapper","mouseout .fb-add-types":"unlockLeftWrapper"},e.prototype.initialize=function(a){var b;return b=a.selector,this.formBuilder=a.formBuilder,this.bootstrapData=a.bootstrapData,null!=b&&this.setElement($(b)),this.collection=new d,this.collection.bind("add",this.addOne,this),this.collection.bind("reset",this.reset,this),this.collection.bind("change",this.handleFormUpdate,this),this.collection.bind("destroy add reset",this.hideShowNoResponseFields,this),this.collection.bind("destroy",this.ensureEditViewScrolled,this),this.render(),this.collection.reset(this.bootstrapData),this.bindSaveEvent()},e.prototype.bindSaveEvent=function(){var a=this;return this.formSaved=!0,this.saveFormButton.attr("disabled",!0).text(c.options.dict.ALL_CHANGES_SAVED),c.options.AUTOSAVE&&setInterval(function(){return a.saveForm.call(a)},5e3),$(window).bind("beforeunload",function(){return a.formSaved?void 0:c.options.dict.UNSAVED_CHANGES})},e.prototype.reset=function(){return this.$responseFields.html(""),this.addAll()},e.prototype.render=function(){var a,b,d,e;for(this.$el.html(c.templates.page()),this.$fbLeft=this.$el.find(".fb-left"),this.$responseFields=this.$el.find(".fb-response-fields"),this.bindWindowScrollEvent(),this.hideShowNoResponseFields(),e=this.SUBVIEWS,b=0,d=e.length;d>b;b++)a=e[b],new a({parentView:this}).render();return this},e.prototype.bindWindowScrollEvent=function(){var a=this;return $(window).on("scroll",function(){var b,c;if(a.$fbLeft.data("locked")!==!0)return c=Math.max(0,$(window).scrollTop()-a.$el.offset().top),b=a.$responseFields.height(),a.$fbLeft.css({"margin-top":Math.min(b,c)})})},e.prototype.showTab=function(a){var b,c,d;return b=$(a.currentTarget),d=b.data("target"),b.closest("li").addClass("active").siblings("li").removeClass("active"),$(d).addClass("active").siblings(".fb-tab-pane").removeClass("active"),"#editField"!==d&&this.unlockLeftWrapper(),"#editField"===d&&!this.editView&&(c=this.collection.models[0])?this.createAndShowEditView(c):void 0},e.prototype.createView=function(a){var b;return b="grid"===a.attributes.type?new f({model:a,parentView:this}):"table"===a.attributes.type?new g({model:a,parentView:this}):new h({model:a,parentView:this})},e.prototype.insert=function(a,b,c,d){var e,i,j,k;return e=!1,i=b.parentModel(),j=i?i.get("type"):void 0,k=j||b.get("type"),"grid"===k?e=f.insert(this,a,b,c,d):"table"===k&&(e=g.insert(this,a,b,c,d)),e||(e=h.insert(this,a,b,c,d)),e},e.prototype.addOne=function(a,b,c){var d;return d=this.createView(a),this.$responseFields.find("> .ui-draggable").remove(),a.get("model_only")!==!0&&this.insert(d,a,b,c),this.views[a.get("uuid")]=d},e.prototype.setSortable=function(){var a=this;return this.$responseFields.hasClass("ui-sortable")&&this.$responseFields.sortable("destroy"),this.$responseFields.sortable({forcePlaceholderSize:!0,placeholder:"sortable-placeholder",stop:function(b,d){var e;return d.item.data("type")&&(e=a.collection.create(c.helpers.defaultFieldAttrs(d.item.data("type")),{$replaceEl:d.item}),a.createAndShowEditView(e)),a.handleFormUpdate(),!0},update:function(b,c){return c.item.data("type")?void 0:a.ensureEditViewScrolled()}}),this.setDraggable()},e.prototype.setDraggable=function(){var a,b=this;return a=this.$el.find("[data-type]"),a.draggable({connectToSortable:this.$responseFields,helper:function(){var a;return a=$("
"),a.css({width:b.$responseFields.width(),height:"80px"}),a}})},e.prototype.addAll=function(){return this.collection.each(function(a,b,c){return this.addOne.call(this,a,b,{})},this),this.setSortable()},e.prototype.hideShowNoResponseFields=function(){return this.$el.find(".fb-no-response-fields")[this.collection.length>0?"hide":"show"]()},e.prototype.addField=function(a){var b;return b=$(a.currentTarget).data("type"),this.createField(c.helpers.defaultFieldAttrs(b,{}))},e.prototype.createField=function(a,b){var c;return c=this.collection.create(a,b),this.createAndShowEditView(c),this.handleFormUpdate()},e.prototype.createAndShowEditView=function(a){var d,e,f,g;if(e=this.$el.find(".fb-field-wrapper").filter(function(){return $(this).data("cid")===a.cid}),$(".fb-field-wrapper").removeClass("editing"),e.addClass("editing"),this.editView){if(this.editView.model.cid===a.cid)return this.$el.find('.fb-tabs a[data-target="#editField"]').click(),void this.scrollLeftWrapper(e);this.editView.remove()}return this.editView=new b({model:a,parentView:this}),d=this.editView.render().$el,g=this.$el.find(".fb-edit-field-wrapper"),g.html(d),this.inGrid(a)?g.addClass("fb-edit-field-grid"):g.removeClass("fb-edit-field-grid"),this.$el.find('.fb-tabs a[data-target="#editField"]').click(),this.scrollLeftWrapper(e),f=c.helpers.defaultFieldAttrs(a.get("type")),void 0!==f.definition.onEdit&&f.definition.onEdit(a),this.$el.find("input, textarea, [contenteditable=true]").filter(":visible").first().focus(),this},e.prototype.inGrid=function(a){return this.hasParent(a)&&a.get("options.grid")},e.prototype.hasParent=function(a){return a.get("parent_uuid")},e.prototype.modelByUuid=function(a){return this.collection.findWhere({uuid:a})},e.prototype.wrapperByUuid=function(a){return $(".fb-field-wrapper").filter(function(){return $(this).data("uuid")===a})},e.prototype.viewByUuid=function(a){return this.views[a]},e.prototype.views={},e.prototype.gridAttr=function(a){return this.inGrid(a)?a.get("options.grid"):null},e.prototype.ensureEditViewScrolled=function(){return this.editView?this.scrollLeftWrapper($(".fb-field-wrapper.editing")):void 0},e.prototype.scrollLeftWrapper=function(a){var b=this;return this.unlockLeftWrapper(),a[0]?$.scrollWindowTo(this.$el.offset().top+a.offset().top-this.$responseFields.offset().top,200,function(){return b.lockLeftWrapper()}):void 0},e.prototype.lockLeftWrapper=function(){return this.$fbLeft.data("locked",!0)},e.prototype.unlockLeftWrapper=function(){return this.$fbLeft.data("locked",!1)},e.prototype.handleFormUpdate=function(){return this.collection.sort(),this.updatingBatch?void 0:(this.formSaved=!1,this.saveFormButton.removeAttr("disabled").text(c.options.dict.SAVE_FORM))},e.prototype.getPayload=function(){return JSON.stringify({fields:this.collection.toJSON()})},e.prototype.saveForm=function(a){var b;if(!this.formSaved)return this.formSaved=!0,this.saveFormButton.attr("disabled",!0).text(c.options.dict.ALL_CHANGES_SAVED),this.collection.sort(),b=this.getPayload(),c.options.HTTP_ENDPOINT&&this.doAjaxSave(b),this.formBuilder.trigger("save",b)},e.prototype.doAjaxSave=function(a){var b=this;return $.ajax({url:c.options.HTTP_ENDPOINT,type:c.options.HTTP_METHOD,data:a,contentType:"application/json",success:function(a){var c,d,e,f;for(b.updatingBatch=!0,d=0,e=a.length;e>d;d++)c=a[d],null!=(f=b.collection.get(c.cid))&&f.set({id:c.id}),b.collection.trigger("sync");return b.updatingBatch=void 0}})},e}(Backbone.View),c=function(){function b(c){var d,e;null==c&&(c={}),_.extend(this,Backbone.Events),d=_.extend(c,{formBuilder:this}),this.attrs={},e=_(d.bootstrapData||[]).groupBy(function(a){return void 0===a.parent_uuid?0:1}).toArray().value(),e=_.reduce(e,function(a,b){return a.concat(b)}),d.bootstrapData=_.map(e,function(a){return _.extend({},b.helpers.defaultFieldAttrs(a.type),a)}),this.mainView=new a(d),this.mainView.collection,b.instances.push(this)}return b.attrs={},b.instances=[],b.attr=function(a,c){return void 0!==c&&(b.attrs[a]=c,_.each(this.instances,function(a){return a.mainView.reset()})),void 0!==b.attrs[a]?b.attrs[a]:void 0},b.helpers={defaultFieldAttrs:function(a){var c,d;return c={},c[b.options.mappings.LABEL]="Untitled",c[b.options.mappings.TYPE]=a,c[b.options.mappings.REQUIRED]=!1,c.definition=b.fields[a],c.options={},("function"==typeof(d=b.fields[a]).defaultAttributes?d.defaultAttributes(c,b):void 0)||c},simple_format:function(a){return null!=a?a.replace(/\n/g," "):void 0},clone:function(a){return JSON.parse(JSON.stringify(a))}},b.options={BUTTON_CLASS_SELECTOR:"fb-button btn btn-default",BUTTON_CLASS_ADD:"fb-button btn btn-xs btn-primary",BUTTON_CLASS_REMOVE:"fb-button btn btn-xs btn-danger",HTTP_ENDPOINT:"",HTTP_METHOD:"POST",AUTOSAVE:!1,CLEAR_FIELD_CONFIRM:!1,ENABLED_FIELDS:["text","checkbox","dropdown","textarea","radio","date","section","signature","info","grid","number","table","datasource"],mappings:{SIZE:"options.size",UNITS:"options.units",LABEL:"label",NAME:"definition.name",TYPE:"type",REQUIRED:"required",ADMIN_ONLY:"admin_only",POPULATE_FROM:"options.populate_from",POPULATE_UUID:"options.populate_uuid",OPTIONS:"answers",DESCRIPTION:"description",INCLUDE_OTHER:"options.include_other_option",INCLUDE_BLANK:"options.include_blank_option",INCLUDE_SCORING:"is_scored",INTEGER_ONLY:"options.integer_only",READ_ONLY:"options.read_only",COLUMN_WIDTH:"options.column_width",NUMERIC:{CALCULATION_TYPE:"options.calculation_type",CALCULATION_EXPRESSION:"options.calculation_expression",CALCULATION_DISPLAY:"options.calculation_display",TOTAL_SEQUENCE:"options.total_sequence"},GRID:{COLS:"options.cols",NUMCOLS:"options.num_cols",ROWS:"options.rows",NUMROWS:"options.num_rows",FULL_WIDTH:"options.full_width",FIRST_ROW_HEADINGS:"options.first_row_headings"},TABLE:{COLS:"options.cols",NUMCOLS:"options.num_cols",ROWS:"options.rows",INITIALROWS:"options.initial_rows",MAXROWS:"options.max_rows",FULL_WIDTH:"options.full_width",COLUMNTOTALS:"options.display_column_totals",ROWTOTALS:"options.display_row_totals"},DATA_SOURCE:{MULTIPLE:"options.multiple_selections",DATA_SOURCE:"options.data_source",VALUE_TEMPLATE:"options.value_template",REQUIRED_PROPERTIES:"options.required_properties",FILTER:"options.filter",FILTER_VALUES:"options.filter_values",IS_FILTERED:"options.is_filtered"},MIN:"options.min",MAX:"options.max",OPTIONS_PER_ROW:"options.options_per_row",MINLENGTH:"options.minlength",MAXLENGTH:"options.maxlength",LENGTH_UNITS:"options.min_max_length_units"},change:{INCLUDE_SCORING:function(){return this.reset()},POPULATE_UUID:function(){return this.reset()},"DATA_SOURCE.DATA_SOURCE":function(){return this.reset()},"DATA_SOURCE.IS_FILTERED":function(){return this.reset()},"DATA_SOURCE.FILTER":function(){return this.reset()}},dict:{ALL_CHANGES_SAVED:"All changes saved",SAVE_FORM:"Save form",UNSAVED_CHANGES:"You have unsaved changes. If you leave this page, you will lose those changes!"}},b.fields={},b.inputFields={},b.nonInputFields={},b.prototype.markSaved=function(){return this.mainView.formSaved=!0},b.prototype.getPayload=function(){return this.mainView.getPayload()},b.registerField=function(a,c){var d,e,f,g,h;for(d=!0,_.contains(b.options.ENABLED_FIELDS,a)||(d=!1),h=["view","edit"],f=0,g=h.length;g>f;f++)e=h[f],c[e]=d?_.template(c[e]):function(a){return""};return c.type=a,c.enabled=d,b.fields[a]=c,"non_input"===c.element_type?b.nonInputFields[a]=c:b.inputFields[a]=c},b}(),void 0===_.nested&&_.mixin({nested:function(a,b){return a&&b?a[b]||_.reduce(b.split("."),function(a,b){return a?a[b]:void 0},a):void 0}}),window.Formbuilder=c,window.FormbuilderModel=e,"undefined"!=typeof module&&null!==module?module.exports=c:window.Formbuilder=c}.call(this),function(){Formbuilder.registerField("address",{name:"Address",order:50,view:"\n \n \n Address \n \n
\n\n\n \n \n City \n \n\n \n \n State / Province / Region \n \n
\n\n\n \n \n Zipcode \n \n\n \n United States \n Country \n \n
",edit:"",addButton:' Address'})}.call(this),function(){Formbuilder.registerField("checkbox",{name:"Checkboxes",order:10,view:"",edit:"<%= Formbuilder.templates['edit/options']({ rf: rf }) %>\n<%= Formbuilder.templates['edit/options_per_row']({ rf: rf }) %>",addButton:' Checkboxes',defaultAttributes:function(a){return a.answers=[{uuid:uuid.v4(),label:"",checked:!1,score:!1},{uuid:uuid.v4(),label:"",checked:!1,score:!1}],a.options.options_per_row=1,a}})}.call(this),function(){Formbuilder.registerField("datasource",{name:"List",order:70,view:"\n \n <%= rf.source().title %>\n (<%= rf.sourceProperty(rf.get(Formbuilder.options.mappings.DATA_SOURCE.VALUE_TEMPLATE)) %>)\n \n ",edit:"<%= Formbuilder.templates['edit/data_source_options']({ rf: rf }) %>",addButton:' Data Source',defaultAttributes:function(a,b){return a.initialize=function(){return this.on("change",function(a){var b,c;return void 0!==_.nested(a,"changed.options.data_source")?(b=_.keys(a.sourceProperties()),a.set("options.required_properties",b),c=_.first(b),a.set("options.value_template",c)):void 0}),this.on("destroy",function(a){return this.collection.each(function(b){return b.get("options.populate_uuid")===a.get("uuid")?(b.set("options.populate_uuid",null),b.set("options.populate_from",null)):void 0})})},a.source=function(){var a,c;return a=this.options?this.options.data_source:this.get(Formbuilder.options.mappings.DATA_SOURCE.DATA_SOURCE),c=b.attr("sources"),_.nested(c,a)||null},a.sourceProperties=function(){var a;return a=this.source(),_.nested(a,"properties")||[]},a.filters=function(){var a;return a=this.source(),_.nested(a,"filters")||null},a.currentFilter=function(){var a;return a=this.source(),_.nested(a,"filters."+this.get("options.filter"))||{}},a.filterValues=function(){return this.currentFilter().values||{}},a.sourceProperty=function(a){return this.sourceProperties()[a]||null},a.options.multiple_selections=!1,a.options.is_filtered=!1,a.options.data_source=a.source()||_.keys(b.attr("sources")||{})[0],a.options.required_properties=_.keys(a.sourceProperties(a.options.data_source)),a.options.filter=a.filters(),a.options.filter_values=[],a.options.value_template=_.first(a.options.required_properties),a}})}.call(this),function(){Formbuilder.registerField("date",{name:"Date",order:20,view:'\n \n
',edit:"",addButton:' Date'})}.call(this),function(){Formbuilder.registerField("dropdown",{name:"Dropdown",order:24,view:"\n <% if (rf.get(Formbuilder.options.mappings.INCLUDE_BLANK)) { %>\n \n <% } %>\n\n <% for (i in (rf.get(Formbuilder.options.mappings.OPTIONS) || [])) { %>\n >\n <%= rf.get(Formbuilder.options.mappings.OPTIONS)[i].label %>\n \n <% } %>\n ",
+edit:"<%= Formbuilder.templates['edit/scoring']() %>\n<%= Formbuilder.templates['edit/options']({ rf: rf }) %>",addButton:' Dropdown',defaultAttributes:function(a){return a.answers=[{uuid:uuid.v4(),label:"",checked:!1,score:""},{uuid:uuid.v4(),label:"",checked:!1,score:""}],a.is_scored=!1,a.options.include_blank_option=!1,a}})}.call(this),function(){Formbuilder.registerField("email",{name:"Email",order:40,view:" ",edit:"",addButton:' Email'})}.call(this),function(){Formbuilder.registerField("file",{name:"File",order:55,view:" ",edit:"",addButton:' File'})}.call(this),function(){Formbuilder.registerField("grid",{name:"Layout Grid",order:30,element_type:"non_input",view:"<%= rf.get(Formbuilder.options.mappings.LABEL) %> \n\n<%= rf.get(Formbuilder.options.mappings.DESCRIPTION) %>
",edit:'\n\n',addButton:' Grid',defaultAttributes:function(a){return a.options.num_cols=1,a.options.num_rows=1,a.options.full_width=!1,a.options.first_row_headings=!1,a.children=[],a.childModels=function(){return this.collection.filter(function(a){return-1!==_.indexOf(this.get("options.elements"),a.get("uuid"))},this)},a}})}.call(this),function(){Formbuilder.registerField("info",{name:"Info",order:20,element_type:"non_input",view:"<%= rf.get(Formbuilder.options.mappings.LABEL) %> \n<%= rf.get(Formbuilder.options.mappings.DESCRIPTION) %>
",edit:'\n',addButton:' Info',onEdit:function(a){var b;return b=function(){return a.set(Formbuilder.options.mappings.DESCRIPTION,$(this).code()),a.trigger("change:"+Formbuilder.options.mappings.DESCRIPTION)},$(".fb-info-editor").summernote({onChange:function(){return b.call(this)},onKeyup:function(){return b.call(this)},toolbar:[["style",["bold","italic","underline"]],["fontsize",["fontsize"]],["color",["color"]],["insert",["link"]],["table",["table"]],["misc",["codeview"]]]})}})}.call(this),function(){Formbuilder.registerField("number",{name:"Number",order:30,view:" \" <%= rf.get(Formbuilder.options.mappings.NUMERIC.CALCULATION_DISPLAY) ? 'readonly=\"readonly\"' : '' %> />\n<% if (units = rf.get(Formbuilder.options.mappings.UNITS)) { %>\n <%= units %>\n<% } %>",edit:"<%= Formbuilder.templates['edit/integer_only']({rf:rf}) %>\n<%= Formbuilder.templates['edit/total']({rf:rf}) %>\n<%= Formbuilder.templates['edit/min_max']({rf:rf}) %>",addButton:' Number',defaultAttributes:function(a,b){return a.options.calculation_type="",a.options.calculation_expression="",a.options.calculation_display="",a.options.total_sequence=!1,a.insertion=function(){var a,b;return a=this.parentModel(),a&&"table"===a.get("type")?(b=a.totalColumn(this.get("uuid")),this.attributes.options.total_sequence=b):void 0},a.initialize=function(){return this.on("change",function(a){var b;return void 0!==_.nested(a,"changed.options.calculation_type")&&a.expression(),void 0!==_.nested(a,"changed.options.total_sequence")&&(b=_.nested(a,"changed.options.total_sequence"),this.parentModel().totalColumn(a.get("uuid"),b)),a})},a.numericSiblings=function(){var a;return a=this.parentModel(),a?_.filter(a.childModels(),function(a){return"number"===a.get("type")&&a.get("uuid")!==this.get("uuid")},this):[]},a.expression=function(){var a,b,c;return a=this.get("options.calculation_type"),""!==a?(c="SUM"===a?"+":"*",b=this.numericSiblings(),this.set("options.calculation_expression",_.map(b,function(a){return"uuid_"+a.get("uuid").replace(/-/g,"_")}).join(c)),this.set("options.calculation_display","= "+_.map(b,function(a){return a.get("label")}).join(c)),console.log(this.get("options.calculation_expression"))):(this.set("options.calculation_expression",""),this.set("options.calculation_display",""))},a.canTotalColumn=function(){var a;return a=this.parentModel(),a&&"table"===a.get("type")},a.canAcceptCalculatedTotal=function(){return this.numericSiblings().length>1},a}})}.call(this),function(){Formbuilder.registerField("price",{name:"Price",order:45,view:"\n $ \n \n \n Dollars \n \n . \n \n \n Cents \n \n
",edit:"",addButton:' Price'})}.call(this),function(){Formbuilder.registerField("radio",{name:"Radio Button",order:15,view:"",edit:"<%= Formbuilder.templates['edit/scoring']({ rf: rf }) %>\n<%= Formbuilder.templates['edit/options']({ rf: rf }) %>\n<%= Formbuilder.templates['edit/options_per_row']({ rf: rf }) %>",addButton:' Multiple Choice',defaultAttributes:function(a){return a.answers=[{uuid:uuid.v4(),label:"",checked:!1,score:""},{uuid:uuid.v4(),label:"",checked:!1,score:""}],a.is_scored=!1,a.options.options_per_row=1,a}})}.call(this),function(){Formbuilder.registerField("section",{name:"Section",order:10,element_type:"non_input",view:"<%= rf.get(Formbuilder.options.mappings.LABEL) %> \n<%= rf.get(Formbuilder.options.mappings.DESCRIPTION) %>
",edit:'\n',addButton:' Section Break'})}.call(this),function(){Formbuilder.registerField("signature",{name:"Signature",order:65,view:'\nClear ',edit:"",addButton:' Signature'})}.call(this),function(){Formbuilder.registerField("table",{name:"Table",order:0,element_type:"non_input",view:"<%= rf.get(Formbuilder.options.mappings.LABEL) %> \n<%= Formbuilder.templates[\"view/table_field\"]({rf: rf}) %>\n<%= rf.get(Formbuilder.options.mappings.DESCRIPTION) %>
",edit:"\n\n
\n <%= Formbuilder.templates['edit/label_description']({rf: rf}) %>\n
\n
\n
\n\n Display full width ?\n ",addButton:' Table',defaultAttributes:function(a){return a.options.full_width=!1,a.initialize=function(){var a;return a=this,_.each(this.childModels,function(b){return b.on("change",function(b){return void 0!==_.nested(b,"changed.options.column_width")&&a.columnWidth(b.get("uuid"),b.get("options.column_width")),b})})},a.childModels=function(){var a;return a=_.pluck(this.get("options.elements"),"uuid"),this.collection.filter(function(b){return-1!==_.indexOf(a,b.get("uuid"))},this)},a.elementOptions=function(a){return _.findWhere(this.get("options.elements"),{uuid:a})},a.createTotalColumnModel=function(a){var b;return b=new FormbuilderModel(Formbuilder.helpers.defaultFieldAttrs("number")),b.set("options.calculation_expression","sum(column_uuid_"+a.replace(/-/g,"_")+")"),b.set("model_only",!0),b.set("parent_uuid",a),this.collection.add(b),b},a.columnWidth=function(a,b){var c;return c=this.get("options.elements"),_.each(c,function(d,e){return d.uuid===a?c[e].columnWidth=b:void 0},this)},a.totalColumn=function(a,b){var c;return c=this.get("options.elements"),void 0!==b?(_.each(c,function(d,e){var f;return d.uuid===a?(void 0===d.totalColumnUuid&&(f=this.createTotalColumnModel(d.uuid),c[e].totalColumnUuid=f.get("uuid")),c[e].totalColumn=b):void 0},this),this.set("options.elements",c)):this.elementOptions(a)?this.elementOptions(a).totalColumn||!1:!1},a}})}.call(this),function(){Formbuilder.registerField("text",{name:"Text",order:0,view:" ",edit:"<%= Formbuilder.templates['edit/populate_from']({ rf: rf }) %>",addButton:' Text',defaultAttributes:function(a){return a.options.size="small",a}})}.call(this),function(){Formbuilder.registerField("textarea",{name:"Paragraph",order:5,view:"",edit:"<%= Formbuilder.templates['edit/populate_from']({ rf: rf }) %>",addButton:' Paragraph',defaultAttributes:function(a){return a.options.size="small",a}})}.call(this),function(){Formbuilder.registerField("time",{name:"Time",order:25,view:"\n \n \n HH \n \n\n : \n\n \n \n MM \n \n\n : \n\n \n \n SS \n \n\n \n \n AM \n PM \n \n \n
",edit:"",addButton:' Time'})}.call(this),function(){Formbuilder.registerField("website",{name:"Website",order:35,view:" ",edit:"",addButton:' Website'})}.call(this),this.Formbuilder=this.Formbuilder||{},this.Formbuilder.templates=this.Formbuilder.templates||{},this.Formbuilder.templates["edit/base"]=function(obj){obj||(obj={});var __t,__p="";_.escape;with(obj)__p+=(null==(__t=Formbuilder.templates["edit/base_header"]({rf:rf}))?"":__t)+"\n"+(null==(__t=Formbuilder.templates["edit/common"]({rf:rf}))?"":__t)+"\n"+(null==(__t=Formbuilder.fields[rf.get(Formbuilder.options.mappings.TYPE)].edit({rf:rf}))?"":__t)+"\n"+(null==(__t=Formbuilder.templates["edit/columnwidth"]({rf:rf}))?"":__t)+"\n";return __p},this.Formbuilder.templates["edit/base_header"]=function(obj){obj||(obj={});var __t,__p="";_.escape;with(obj)__p+="\n \n
\n \n
\n";return __p},this.Formbuilder.templates["edit/base_non_input"]=function(obj){obj||(obj={});var __t,__p="";_.escape;with(obj)__p+=(null==(__t=Formbuilder.templates["edit/base_header"]({rf:rf}))?"":__t)+"\n"+(null==(__t=Formbuilder.fields[rf.get(Formbuilder.options.mappings.TYPE)].edit({rf:rf}))?"":__t)+"\n";return __p},this.Formbuilder.templates["edit/checkboxes"]=function(obj){obj||(obj={});var __t,__p="";_.escape;with(obj)__p+="\n \n Required\n \n";return __p},this.Formbuilder.templates["edit/columnwidth"]=function(obj){obj||(obj={});var __t,__p="";_.escape;with(obj)__p+='';return __p},this.Formbuilder.templates["edit/common"]=function(obj){obj||(obj={});var __t,__p="";_.escape;with(obj)__p+="\n\n\n
\n "+(null==(__t=Formbuilder.templates["edit/label_description"]({rf:rf}))?"":__t)+"\n
\n
\n "+(null==(__t=Formbuilder.templates["edit/checkboxes"]())?"":__t)+"\n
\n
\n
";return __p},this.Formbuilder.templates["edit/data_source_options"]=function(obj){obj||(obj={});var __t,__p="";_.escape,Array.prototype.join;with(obj){__p+="\n \n Multiple selections\n \n\n\n\n';for(i in Formbuilder.attr("sources")||[])__p+='\n \n '+(null==(__t=Formbuilder.attr("sources")[i].title)?"":__t)+"\n \n";__p+="\n \n\n\n';for(i in rf.sourceProperties()||[])__p+='\n \n '+(null==(__t=rf.sourceProperties()[i])?"":__t)+"\n \n";if(__p+="\n \n",rf.filters()){if(__p+="\n \n \n \n Apply a filter?\n \n ",rf.get(Formbuilder.options.mappings.DATA_SOURCE.IS_FILTERED)){__p+='\n \n [ No Filter ] \n ';for(i in rf.filters()||[])__p+='\n \n '+(null==(__t=rf.filters()[i].name)?"":__t)+"\n \n ";__p+="\n \n ";for(i in rf.filterValues())__p+="\n \n \n '+(null==(__t=rf.filterValues()[i])?"":__t)+"\n \n ";__p+="\n"}__p+="\n"}}return __p},this.Formbuilder.templates["edit/integer_only"]=function(obj){obj||(obj={});var __t,__p="";_.escape;with(obj)__p+="\n \n Whole numbers only?\n \n";return __p},this.Formbuilder.templates["edit/label_description"]=function(obj){obj||(obj={});var __t,__p="";_.escape;with(obj)__p+=" \n";return __p},this.Formbuilder.templates["edit/min_max"]=function(obj){obj||(obj={});var __t,__p="";_.escape;with(obj)__p+='\n\nMin\n \n\n \n\nMax\n \n';return __p},this.Formbuilder.templates["edit/min_max_length"]=function(obj){obj||(obj={});var __t,__p="";_.escape;with(obj)__p+='\n\nMin\n \n\n \n\nMax\n \n\n \n\n\n characters \n words \n \n';return __p},this.Formbuilder.templates["edit/options"]=function(obj){obj||(obj={});var __t,__p="";_.escape,Array.prototype.join;with(obj)__p+="\n\n","undefined"!=typeof includeBlank&&(__p+="\n \n \n Include blank\n \n"),__p+="\n\n\n\n \n ',rf.get(Formbuilder.options.mappings.INCLUDE_SCORING)&&(__p+='\n \n '),__p+='\n\n \n
\n\n',"undefined"!=typeof includeOther&&(__p+="\n \n \n Include "other"\n \n'),__p+="\n\n\n Add option \n
\n';return __p},this.Formbuilder.templates["edit/options_per_row"]=function(obj){obj||(obj={});var __t,__p="";_.escape;with(obj)__p+="\n \n 1 \n 2 \n 3 \n 4 \n 5 \n 6 \n 7 \n 8 \n 9 \n 10 \n 11 \n 12 \n 13 \n 14 \n 15 \n \n';return __p},this.Formbuilder.templates["edit/populate_from"]=function(obj){obj||(obj={});var __t,__p="";_.escape,Array.prototype.join;with(obj){var list=rf.collection.findDataSourceFields();if(list.length){__p+="\n \n \n \n ';for(i in list||[])__p+='\n \n '+(null==(__t=list[i].get("label"))?"":__t)+"\n \n ";__p+='\n \n \n \n ';var populationUuid=rf.get("options.populate_uuid"),populationModel=rf.collection.findWhereUuid(populationUuid)||{};if(populationUuid&&populationModel){var dataSource=populationModel.get("options.data_source"),listProperties=Formbuilder.attr("sources")[dataSource].properties;for(i in listProperties)__p+='\n \n '+(null==(__t=listProperties[i])?"":__t)+"\n \n "}__p+="\n \n"}__p+="\n"}return __p},this.Formbuilder.templates["edit/scoring"]=function(obj){obj||(obj={});var __t,__p="";_.escape;with(obj)__p+='\n \n \n Include Scoring\n \n
\n\n";return __p},this.Formbuilder.templates["edit/size"]=function(obj){obj||(obj={});var __t,__p="";_.escape;with(obj)__p+="\n\n Small \n Medium \n Large \n \n';return __p},this.Formbuilder.templates["edit/table_layout"]=function(obj){obj||(obj={});var __t,__p="";_.escape;with(obj)__p+="\n \n Columns\n \n 1 \n 2 \n 3 \n 4 \n 5 \n 6 \n 7 \n 8 \n 9 \n 10 \n \n \n\n \n Max rows\n \n \n';return __p},this.Formbuilder.templates["edit/table_totals"]=function(obj){obj||(obj={});var __t,__p="";_.escape;with(obj)__p+="\n \n \n Display column totals?\n \n";return __p},this.Formbuilder.templates["edit/total"]=function(obj){obj||(obj={});var __t,__p="";_.escape,Array.prototype.join;with(obj)rf.canTotalColumn()&&(__p+='\n\n Display column total?\n \n \n"),__p+="\n",rf.canAcceptCalculatedTotal()&&(__p+="\n\n\n Calculated Value\n \n No Calculation \n Sum \n Product \n \n \n'),__p+="\n\n";return __p},this.Formbuilder.templates["edit/units"]=function(obj){obj||(obj={});var __t,__p="";_.escape;with(obj)__p+='\n \n';return __p},this.Formbuilder.templates.page=function(obj){obj||(obj={});var __t,__p="";_.escape;with(obj)__p+=(null==(__t=Formbuilder.templates["partials/left_side"]())?"":__t)+"\n"+(null==(__t=Formbuilder.templates["partials/right_side"]())?"":__t)+"\n
";return __p},this.Formbuilder.templates["partials/add_field"]=function(obj){obj||(obj={});var __t,__p="";_.escape,Array.prototype.join;with(obj)__p+="";return __p},this.Formbuilder.templates["partials/edit_field"]=function(obj){obj||(obj={});var __p="";_.escape;with(obj)__p+="\n";return __p},this.Formbuilder.templates["partials/left_side"]=function(obj){obj||(obj={});var __t,__p="";_.escape;with(obj)__p+="\n
\n\n
\n "+(null==(__t=Formbuilder.templates["partials/add_field"]())?"":__t)+"\n "+(null==(__t=Formbuilder.templates["partials/edit_field"]())?"":__t)+"\n
\n
";return __p},this.Formbuilder.templates["partials/right_side"]=function(obj){obj||(obj={});var __p="";_.escape;with(obj)__p+="\n
No response fields
\n
\n
\n";return __p},this.Formbuilder.templates["view/base"]=function(obj){obj||(obj={});var __t,__p="";_.escape;with(obj)__p+="\n
\n "+(null==(__t=Formbuilder.templates["view/label"]({rf:rf}))?"":__t)+"\n\n "+(null==(__t=Formbuilder.fields[rf.get(Formbuilder.options.mappings.TYPE)].view({rf:rf}))?"":__t)+"\n\n "+(null==(__t=Formbuilder.templates["view/description"]({rf:rf}))?"":__t)+"\n "+(null==(__t=Formbuilder.templates["view/duplicate_remove"]({rf:rf}))?"":__t)+"\n
\n";return __p},this.Formbuilder.templates["view/base_non_input"]=function(obj){obj||(obj={});var __t,__p="";_.escape;with(obj)__p+="\n
\n "+(null==(__t=Formbuilder.fields[rf.get(Formbuilder.options.mappings.TYPE)].view({rf:rf}))?"":__t)+"\n "+(null==(__t=Formbuilder.templates["view/duplicate_remove"]({rf:rf}))?"":__t)+"\n
\n";return __p},this.Formbuilder.templates["view/description"]=function(obj){obj||(obj={});var __t,__p="";_.escape;with(obj)__p+="\n "+(null==(__t=Formbuilder.helpers.simple_format(rf.get(Formbuilder.options.mappings.DESCRIPTION)))?"":__t)+"\n \n";return __p},this.Formbuilder.templates["view/duplicate_remove"]=function(obj){obj||(obj={});var __t,__p="";_.escape;with(obj)__p+="\n \n \n
';return __p},this.Formbuilder.templates["view/element_selector"]=function(obj){obj||(obj={});var __p="";_.escape;with(obj)__p+='\n\n \n \n\n
';
+return __p},this.Formbuilder.templates["view/label"]=function(obj){obj||(obj={});var __t,__p="";_.escape,Array.prototype.join;with(obj)__p+="\n "+(null==(__t=Formbuilder.helpers.simple_format(rf.get(Formbuilder.options.mappings.LABEL)))?"":__t)+"\n ",rf.get(Formbuilder.options.mappings.REQUIRED)&&(__p+="\n * \n "),__p+="\n \n";return __p},this.Formbuilder.templates["view/remove"]=function(obj){obj||(obj={});var __t,__p="";_.escape;with(obj)__p+="\n \n
';return __p},this.Formbuilder.templates["view/table_element"]=function(obj){obj||(obj={});var __t,__p="";_.escape;with(obj)__p+=(null==(__t=Formbuilder.fields[rf.get(Formbuilder.options.mappings.TYPE)].view({rf:rf}))?"":__t)+"\n"+(null==(__t=Formbuilder.templates["view/remove"]({rf:rf}))?"":__t);return __p},this.Formbuilder.templates["view/table_field"]=function(obj){obj||(obj={});var __t,__p="";_.escape,Array.prototype.join;with(obj){__p+='\n'+(null==(__t=Formbuilder.templates["view/element_selector"]())?"":__t)+'\n \n\n\n \n \n ';for(i in rf.get("options.elements")||[])__p+='\n \n ';__p+="\n \n \n ";for(i in rf.get("options.elements")||[])__p+='\n \n ';__p+="\n \n \n \n \n ";for(i in rf.get("options.elements")||[])__p+='\n \n ';__p+="\n \n \n
"}return __p},this.Formbuilder.templates["view/table_header"]=function(obj){obj||(obj={});var __t,__p="";_.escape;with(obj)__p+=(null==(__t=Formbuilder.templates["view/label"]({rf:rf}))?"":__t)+"\n"+(null==(__t=Formbuilder.templates["view/description"]({rf:rf}))?"":__t);return __p},this.Formbuilder.templates["view/table_total"]=function(obj){obj||(obj={});var __p="";_.escape,Array.prototype.join;with(obj)rf.get("options.total_sequence")&&(__p+='\n(Column Total) \n');return __p};
\ No newline at end of file
diff --git a/dist/formbuilder.css b/dist/formbuilder.css
index 331fbb8e..49c37c6b 100644
--- a/dist/formbuilder.css
+++ b/dist/formbuilder.css
@@ -1,10 +1,25 @@
-.fb-button{display:inline-block;margin:0;padding:.563rem .844rem;border:0 none;background:#16a085;color:#fff;text-align:center;text-decoration:none;font-size:12px;line-height:1.5;cursor:pointer;border-radius:.125rem;border:thin solid #19b394;border-bottom:2px solid #16a085}
-.fb-button[disabled]{background:#ddd !important;border:thin solid #ccc;color:#777 !important;text-shadow:none !important;-ms-filter:"progid:DXImageTransform.Microsoft.Alpha(Opacity=65)";opacity:.65;cursor:default}
+[class^="fb-icon-"]:before,[class*=" fb-icon-"]:before{font-family:"fontello";font-style:normal;font-weight:normal;speak:none;display:inline-block;text-decoration:inherit;width:1em;margin-right:.2em;text-align:center;font-variant:normal;text-transform:none;line-height:1em;margin-left:.2em}
+.fb-icon-date:before{content:'\e800'}
+.fb-icon-radio:before{content:'\e801'}
+.fb-icon-checkbox:before{content:'\e802'}
+.fb-icon-data-source:before{content:'\e803'}
+.fb-icon-dropdown:before{content:'\e804'}
+.fb-icon-signature:before{content:'\e805'}
+.fb-icon-info:before{content:'\e806'}
+.fb-icon-table:before{content:'\e807'}
+.fb-icon-textarea:before{content:'\e808'}
+.fb-icon-section:before{content:'\e809'}
+.fb-icon-text:before{content:'\e80a'}
+.fb-icon-number:before{content:'\e80b'}
+.fb-icon-time:before{content:'\e80c'}
+.fb-icon-conditional:before{content:'\E80D'}
+.fb-icon-geolocation:before{content:'\E80E'}
+.fb-button{text-align:left}
.fb-clear{clear:both}
-.fb-main{max-width:1000px;margin:0 auto;padding:0 20px 0 0;position:relative;font-family:'Source Sans Pro','Open Sans',Tahoma}
+.fb-main{padding:0 20px 0 0;position:relative}
.fb-save-wrapper{position:absolute;right:20px;top:10px}
.fb-left{float:left;width:320px;padding-top:30px}
-.fb-right{padding-top:70px;margin-left:320px;border-left:1px solid #ddd;padding-left:20px;min-height:100%;overflow:hidden}
+.fb-right{padding-top:70px;margin-left:320px;border-left:1px solid #ddd;padding-left:20px;padding-bottom:150px;min-height:100%;overflow:hidden}
.fb-no-response-fields{color:#999}
.fb-tabs{list-style:none;margin:0 0 20px 0;padding:0 0 0 20px;border-bottom:1px solid #ccc}
.fb-tabs li{display:inline-block}
@@ -12,26 +27,26 @@
.fb-tabs li.active a{border:1px solid #ccc;margin-bottom:-1px;border-bottom-color:#fff}
.fb-tab-content .fb-tab-pane{padding:0 20px;display:none}
.fb-tab-content .fb-tab-pane.active{display:block}
-.fb-add-field-types .section{padding-bottom:5px;margin-bottom:20px}
-.fb-add-field-types{font-size:0}
-.fb-add-field-types a{font-size:13px;display:inline-block;width:48.5%;background-color:#1abc9c;margin-bottom:9px;box-sizing:border-box}
-.fb-add-field-types a:nth-child(odd){margin-right:3%}
-.fb-add-field-types a .symbol{opacity:.6;margin:0 .25em 0 -1em}
+.fb-add-types .section{padding-bottom:5px;margin-bottom:20px}
+.fb-add-types{font-size:0}
+.fb-add-types a{font-size:13px;display:inline-block;width:48.5%;margin-bottom:9px;box-sizing:border-box}
+.fb-add-types a:nth-child(odd){margin-right:3%}
+.fb-add-types a .symbol{opacity:.6;margin:0 .25em 0 -1em}
.fb-response-fields{padding-bottom:150px}
.fb-response-fields a.sortable-placeholder{display:block;border:1px dashed #ddd;min-height:80px;height:80px;width:100%}
.fb-field-wrapper{cursor:pointer;position:relative;margin-bottom:20px}
.fb-field-wrapper input{border-radius:3px;border:thin solid #ddd}
.fb-field-wrapper:hover .actions-wrapper,.fb-field-wrapper.editing .actions-wrapper{display:block}
.fb-field-wrapper:hover .subtemplate-wrapper{border-color:#ddd;border-radius:3px}
-.fb-field-wrapper.editing{background-color:#ecf0f1;border-radius:3px}
+.fb-field-wrapper.editing{background-color:#ecf0f1;border-radius:3px;box-shadow:inset 0 0 7px 2px rgba(100,100,100,0.1);border:1px solid rgba(100,100,100,0.2)}
+.fb-field-wrapper.parent{box-shadow:rgba(0,0,0,0.3) 1px 1px 10px}
.fb-field-wrapper.editing .subtemplate-wrapper{border-color:#d9e1e3;border-style:solid;margin:0;border-radius:3px}
.fb-field-wrapper .actions-wrapper{display:none;position:absolute;bottom:-7px;right:5px;z-index:3}
.fb-field-wrapper .actions-wrapper a{display:inline-block;background-color:#ccc;padding:2px 8px}
.edit-response-field input,.edit-response-field textarea,.edit-response-field select{border:thin solid #ddd;border-radius:.25em;padding:.5em;display:inline-block;height:auto;vertical-align:middle}
-.edit-response-field input:focus,.edit-response-field textarea:focus,.edit-response-field select:focus{outline:none;border:thin solid #1abc9c}
-.edit-response-field select{font-size:14px}
-.fb-field-wrapper .actions-wrapper a.js-duplicate,.fb-edit-field-wrapper .js-add-option{background-color:#2ecc71;border:none}
-.fb-field-wrapper .actions-wrapper a.js-clear,.fb-edit-field-wrapper .js-remove-option{background-color:#e74c3c;border:none}
+.edit-response-field input:focus,.edit-response-field textarea:focus,.edit-response-field select:focus{outline:none}
+.edit-response-field select{font-size:14px;max-width:100%}
+input[readonly]{cursor:not-allowed;background-color:#eee}
.fb-field-wrapper .subtemplate-wrapper{border:1px dashed transparent;margin-bottom:10px;padding:10px;position:relative}
.fb-field-wrapper .subtemplate-wrapper .cover{position:absolute;top:0;left:0;height:100%;width:100%;z-index:2}
.fb-field-wrapper .subtemplate-wrapper > label{display:block;border-bottom:thin solid #eee;padding-bottom:3px;margin-bottom:7px}
@@ -44,8 +59,8 @@
.fb-field-wrapper .help-block{display:block;font-size:12px;margin-top:5px}
.fb-edit-field-wrapper{font-size:13px}
.fb-edit-field-wrapper .fb-field-label{font-weight:normal;background:#eee;padding:.75em;color:#666;font-size:1.25em}
-.fb-edit-field-wrapper .fb-field-label .field-type{margin-top:.5em;display:block;font-family:'Source Sans Pro',sans-serif;font-size:1em}
-.fb-edit-field-wrapper .fb-field-label .field-type:before{content:'Type: ';color:#999}
+.fb-edit-field-wrapper .fb-field-label .type{margin-top:.5em;display:block;font-family:'Source Sans Pro',sans-serif;font-size:1em}
+.fb-edit-field-wrapper .fb-field-label .type:before{content:'Type: ';color:#999}
.fb-edit-field-wrapper .fb-field-label .fa.fa-arrow-right{display:none}
.fb-edit-field-wrapper .fb-edit-section-header{border-bottom:1px solid #ddd;margin-top:25px;margin-bottom:10px;padding-bottom:5px;clear:both;font-weight:700}
.fb-edit-field-wrapper .js-add-option,.fb-edit-field-wrapper .js-remove-option{padding:3px 6px}
@@ -53,16 +68,108 @@
.fb-common-wrapper .fb-label-description{margin-bottom:10px}
.fb-common-wrapper .fb-label-description input,.fb-common-wrapper .fb-label-description textarea{width:100%}
.fb-common-wrapper .fb-label-description textarea{min-height:5em}
+.fb-conditional-question{float:right;font-size:.9em;max-width:50%;text-overflow:ellipsis;height:20px;white-space:nowrap;overflow:hidden}
+.fb-conditional-question-trigger > span{font-weight:bold}
+.option-score-input{width:50px}
+.option-label-input{width:170px}
.response-field-draggable-helper{border:1px dashed #ddd;background:#eee}
-.response-field-text input.rf-size-small{width:130px}
.response-field-text input.rf-size-medium{width:300px}
.response-field-text input.rf-size-large{width:100%}
-.response-field-paragraph textarea.rf-size-small{width:200px;min-height:60px}
-.response-field-paragraph textarea.rf-size-medium{width:400px;min-height:100px}
-.response-field-paragraph textarea.rf-size-large{width:100%;min-height:200px}
+.response-field-textarea textarea.rf-size-small{width:200px;min-height:60px}
+.response-field-textarea textarea.rf-size-medium{width:400px;min-height:100px}
+.response-field-textarea textarea.rf-size-large{width:100%;min-height:200px}
.response-field-address .street{width:400px}
.response-field-address .city,.response-field-address .state,.response-field-address .zip,.response-field-address .country{width:198px}
.response-field-date .month,.response-field-date .day,.response-field-date .year{width:50px}
-.response-field-time .hours,.response-field-time .minutes,.response-field-time .seconds{width:50px}
-.response-field-checkboxes .fb-option,.response-field-radio .fb-option{margin-bottom:5px;display:inline-block}
+.response-field-time .input-group{width:145px}
+.response-field-checkbox .fb-option,.response-field-radio .fb-option{margin-bottom:5px;padding:3px 8px;display:inline-block}
+.editing .trigger-option,.fb-option.trigger-option{background-color:#5cb85c;border-radius:.25em;color:#fff}
+.fb-conditional-question .trigger-option{padding:1px 4px}
.response-field-website input{width:200px}
+.response-field-signature .fb-signature{width:300px;height:150px}
+.response-field-signature .fb-signature-placeholder{color:#aaa}
+.response-field-grid .cover{display:none}
+.response-field-table{width:100%}
+.response-field-table .cover{display:none}
+.response-field-table .section-name{display:inline-block}
+.response-field-table .element-selector{margin:0 5px;float:right;position:absolute;right:5px;top:5px}
+.response-field-table tr{vertical-align:top}
+.response-field-table table{margin-bottom:30px}
+.response-field-table table td{padding:10px 10px 0 10px}
+.response-field-table table td label{border:none !important}
+.response-field-table table .calculated{font-style:italic;color:#ccc}
+.response-field-table table select,.response-field-table table input[type=text],.response-field-table table textarea,.response-field-table table .fb-signature{width:100%}
+.fb-options-per-row-1:before{content:" ";display:table}
+.fb-options-per-row-1:after{content:" ";display:table;clear:both}
+.fb-options-per-row-1{clear:both}
+.fb-options-per-row-1 .fb-option-wrapper{width:100%}
+.fb-options-per-row-2:before{content:" ";display:table}
+.fb-options-per-row-2:after{content:" ";display:table;clear:both}
+.fb-options-per-row-2{clear:both}
+.fb-options-per-row-2 .fb-option-wrapper{width:50%}
+.fb-options-per-row-3:before{content:" ";display:table}
+.fb-options-per-row-3:after{content:" ";display:table;clear:both}
+.fb-options-per-row-3{clear:both}
+.fb-options-per-row-3 .fb-option-wrapper{width:33.333333333333336%}
+.fb-options-per-row-4:before{content:" ";display:table}
+.fb-options-per-row-4:after{content:" ";display:table;clear:both}
+.fb-options-per-row-4{clear:both}
+.fb-options-per-row-4 .fb-option-wrapper{width:25%}
+.fb-options-per-row-5:before{content:" ";display:table}
+.fb-options-per-row-5:after{content:" ";display:table;clear:both}
+.fb-options-per-row-5{clear:both}
+.fb-options-per-row-5 .fb-option-wrapper{width:20%}
+.fb-options-per-row-6:before{content:" ";display:table}
+.fb-options-per-row-6:after{content:" ";display:table;clear:both}
+.fb-options-per-row-6{clear:both}
+.fb-options-per-row-6 .fb-option-wrapper{width:16.666666666666668%}
+.fb-options-per-row-7:before{content:" ";display:table}
+.fb-options-per-row-7:after{content:" ";display:table;clear:both}
+.fb-options-per-row-7{clear:both}
+.fb-options-per-row-7 .fb-option-wrapper{width:14.285714285714286%}
+.fb-options-per-row-8:before{content:" ";display:table}
+.fb-options-per-row-8:after{content:" ";display:table;clear:both}
+.fb-options-per-row-8{clear:both}
+.fb-options-per-row-8 .fb-option-wrapper{width:12.5%}
+.fb-options-per-row-9:before{content:" ";display:table}
+.fb-options-per-row-9:after{content:" ";display:table;clear:both}
+.fb-options-per-row-9{clear:both}
+.fb-options-per-row-9 .fb-option-wrapper{width:11.11111111111111%}
+.fb-options-per-row-10:before{content:" ";display:table}
+.fb-options-per-row-10:after{content:" ";display:table;clear:both}
+.fb-options-per-row-10{clear:both}
+.fb-options-per-row-10 .fb-option-wrapper{width:10%}
+.fb-options-per-row-11:before{content:" ";display:table}
+.fb-options-per-row-11:after{content:" ";display:table;clear:both}
+.fb-options-per-row-11{clear:both}
+.fb-options-per-row-11 .fb-option-wrapper{width:9.090909090909092%}
+.fb-options-per-row-12:before{content:" ";display:table}
+.fb-options-per-row-12:after{content:" ";display:table;clear:both}
+.fb-options-per-row-12{clear:both}
+.fb-options-per-row-12 .fb-option-wrapper{width:8.333333333333334%}
+.fb-options-per-row-13:before{content:" ";display:table}
+.fb-options-per-row-13:after{content:" ";display:table;clear:both}
+.fb-options-per-row-13{clear:both}
+.fb-options-per-row-13 .fb-option-wrapper{width:7.6923076923076925%}
+.fb-options-per-row-14:before{content:" ";display:table}
+.fb-options-per-row-14:after{content:" ";display:table;clear:both}
+.fb-options-per-row-14{clear:both}
+.fb-options-per-row-14 .fb-option-wrapper{width:7.142857142857143%}
+.fb-options-per-row-15:before{content:" ";display:table}
+.fb-options-per-row-15:after{content:" ";display:table;clear:both}
+.fb-options-per-row-15{clear:both}
+.fb-options-per-row-15 .fb-option-wrapper{width:6.666666666666667%}
+.response-field-grid-table{border-collapse:collapse;border-spacing:0;margin-bottom:5px;table-layout:fixed;width:100%}
+.response-field-grid-table .response-field-grid-row{height:100px;vertical-align:top}
+.response-field-grid-table td{padding:10px 10px 0 10px}
+.response-field-grid-table .element-selector{width:100%}
+.response-field-grid-table .element-selector .dropdown-toggle{width:100%}
+.response-field-grid-table .element-selector .dropdown-toggle span{font-size:2em}
+.response-field-grid-table .response-field-grid-cell{padding:10px 10px 0 10px;border:1px dashed #ddd;background-color:rgba(255,255,255,0.8)}
+.response-field-grid-table .response-field-grid-cell .cover{display:block}
+.response-field-grid-table .response-field-grid-cell .response-field-selector{margin:.5em}
+.response-field-grid-table .response-field-grid-cell .subtemplate-wrapper > label{display:none}
+.response-field-grid-table .response-field-grid-cell .help-block{display:none}
+.response-field-grid-table .response-field-grid-cell select,.response-field-grid-table .response-field-grid-cell input[type=text],.response-field-grid-table .response-field-grid-cell textarea,.response-field-grid-table .response-field-grid-cell .fb-signature{width:100%}
+.section-separator{border-top:1px solid #333}
+.fb-link-object-fields{padding:15px}
diff --git a/dist/formbuilder.js b/dist/formbuilder.js
index 47f8e09a..8d7d600d 100644
--- a/dist/formbuilder.js
+++ b/dist/formbuilder.js
@@ -1,4 +1,38 @@
(function() {
+ rivets.binders.append = {
+ routine: function(el, value) {
+ return el.checked = _.find(value, function(item) {
+ return String(item) === String(el.value);
+ }) !== void 0;
+ },
+ bind: function(el) {
+ var _this = this;
+ this.callback = function() {
+ var currentValue, newValue;
+ currentValue = _.clone(_this.model.get(_this.keypath)) || [];
+ if (_.contains(currentValue, el.value)) {
+ newValue = _.without(currentValue, el.value);
+ return _this.model.set(_this.keypath, newValue);
+ } else {
+ currentValue.push(el.value);
+ return _this.model.set(_this.keypath, currentValue);
+ }
+ };
+ return $(el).on('change', this.callback);
+ },
+ unbind: function(el) {
+ return $(el).off('change', this.callback);
+ }
+ };
+
+ rivets.formatters.length = function(value) {
+ if (value) {
+ return value.length;
+ } else {
+ return 0;
+ }
+ };
+
rivets.binders.input = {
publishes: true,
routine: rivets.binders.value.routine,
@@ -41,11 +75,14 @@
}).call(this);
(function() {
- var BuilderView, EditFieldView, Formbuilder, FormbuilderCollection, FormbuilderModel, ViewFieldView, _ref, _ref1, _ref2, _ref3, _ref4,
+ var BuilderView, EditFieldView, Formbuilder, FormbuilderCollection, FormbuilderModel, GridFieldView, TableFieldView, ViewFieldView, _ref, _ref1, _ref2, _ref3, _ref4, _ref5, _ref6,
__hasProp = {}.hasOwnProperty,
- __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; };
+ __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; },
+ __indexOf = [].indexOf || function(item) { for (var i = 0, l = this.length; i < l; i++) { if (i in this && this[i] === item) return i; } return -1; };
FormbuilderModel = (function(_super) {
+ var $wrappers;
+
__extends(FormbuilderModel, _super);
function FormbuilderModel() {
@@ -53,19 +90,147 @@
return _ref;
}
+ $wrappers = {};
+
FormbuilderModel.prototype.sync = function() {};
FormbuilderModel.prototype.indexInDOM = function() {
- var $wrapper,
- _this = this;
- $wrapper = $(".fb-field-wrapper").filter((function(_, el) {
- return $(el).data('cid') === _this.cid;
- }));
- return $(".fb-field-wrapper").index($wrapper);
+ if ($wrappers[this.cid] === void 0) {
+ $(".fb-field-wrapper").each((function(_, el) {
+ $wrappers[$(el).data('cid')] = $(el);
+ return true;
+ }));
+ }
+ return ($wrappers[this.cid] || {
+ index: function() {
+ return -1;
+ }
+ }).index(".fb-field-wrapper");
};
FormbuilderModel.prototype.is_input = function() {
- return Formbuilder.inputFields[this.get(Formbuilder.options.mappings.FIELD_TYPE)] != null;
+ return Formbuilder.inputFields[this.get(Formbuilder.options.mappings.TYPE)] != null;
+ };
+
+ FormbuilderModel.prototype.initialize = function() {
+ if (this.attributes.uuid == null) {
+ this.attributes.uuid = uuid.v4();
+ }
+ if (!this.attributes.parent_uuid === void 0) {
+ this.attributes.parent_uuid = null;
+ }
+ return this.attachMethods();
+ };
+
+ FormbuilderModel.prototype.parentModel = function() {
+ var collention;
+ collention = this.collection;
+ if (collention) {
+ return this.collection.findWhereUuid(this.get('parent_uuid'));
+ }
+ };
+
+ FormbuilderModel.prototype.hasParent = function() {
+ return this.parentModel() !== void 0;
+ };
+
+ FormbuilderModel.prototype.inTable = function() {
+ var parent;
+ parent = this.parentModel();
+ return parent && parent.get('type') === 'table';
+ };
+
+ FormbuilderModel.prototype.inGrid = function() {
+ var parent;
+ parent = this.parentModel();
+ return parent && parent.get('type') === 'grid';
+ };
+
+ FormbuilderModel.prototype.canBeConditionallyDisplayed = function() {
+ return !this.inTable() && !this.inGrid() && Formbuilder.conditionalFunctionality;
+ };
+
+ FormbuilderModel.prototype.canShowReferenceID = function() {
+ return Formbuilder.showReferenceIDFunctionality;
+ };
+
+ FormbuilderModel.prototype.conditionalParent = function() {
+ var parentUuid;
+ parentUuid = this.get(Formbuilder.options.mappings.CONDITIONAL_PARENT);
+ if (parentUuid) {
+ return this.collection.findWhereUuid(parentUuid);
+ }
+ return null;
+ };
+
+ FormbuilderModel.prototype.conditionalChildren = function() {
+ var uuid;
+ uuid = this.attributes.uuid;
+ return this.collection.filter(function(item) {
+ return uuid === item.get(Formbuilder.options.mappings.CONDITIONAL_PARENT);
+ });
+ };
+
+ FormbuilderModel.prototype.answers = function() {
+ return this.get('answers') || [];
+ };
+
+ FormbuilderModel.prototype.conditionalTriggerOptions = function(selected) {
+ var options, parent, triggerValues;
+ parent = this.conditionalParent();
+ options = [];
+ if (parent) {
+ options = _.clone(parent.answers());
+ options.unshift({
+ 'uuid': '',
+ 'label': '[No Selection]'
+ });
+ if (selected) {
+ triggerValues = this.get(Formbuilder.options.mappings.CONDITIONAL_VALUES) || [];
+ options = _.filter(options, function(trigger) {
+ var _ref1;
+ return _ref1 = trigger.uuid, __indexOf.call(triggerValues, _ref1) >= 0;
+ });
+ }
+ }
+ return options;
+ };
+
+ FormbuilderModel.prototype.isValid = function() {
+ var conditional, conditional_ele, conditional_parent, conditional_values, options;
+ conditional_ele = this.canBeConditionallyDisplayed();
+ if (!conditional_ele) {
+ return true;
+ } else {
+ options = this.attributes.options;
+ conditional = options.conditional;
+ if (conditional) {
+ conditional_values = conditional.values;
+ conditional_parent = conditional.parent;
+ }
+ }
+ if ((conditional_parent && (conditional_values && conditional_values.length !== 0)) || (typeof conditional_values === "undefined" && typeof conditional_parent === "undefined")) {
+ return true;
+ } else {
+ return false;
+ }
+ };
+
+ FormbuilderModel.prototype.attachMethods = function() {
+ if (typeof this.attributes.initialize === 'function') {
+ this.attributes.initialize.call(this);
+ delete this.attributes['initialize'];
+ }
+ if (typeof this.attributes.insertion === 'function') {
+ this['insertion'] = this.attributes['insertion'];
+ delete this.attributes['insertion'];
+ }
+ return _.each(this.attributes, function(method, name) {
+ if (typeof method === 'function' && this[name] === void 0) {
+ this[name] = method;
+ return delete this.attributes[name];
+ }
+ }, this);
};
return FormbuilderModel;
@@ -80,24 +245,60 @@
return _ref1;
}
- FormbuilderCollection.prototype.initialize = function() {
- return this.on('add', this.copyCidToModel);
- };
-
FormbuilderCollection.prototype.model = FormbuilderModel;
FormbuilderCollection.prototype.comparator = function(model) {
return model.indexInDOM();
};
- FormbuilderCollection.prototype.copyCidToModel = function(model) {
- return model.attributes.cid = model.cid;
+ FormbuilderCollection.prototype.add = function(model) {
+ var models;
+ models = model = FormbuilderCollection.__super__.add.call(this, model);
+ if (!_.isArray(model)) {
+ models = [model];
+ }
+ _.each(models, function(model) {
+ if (typeof model.insertion === 'function') {
+ return model.insertion.call(model);
+ }
+ });
+ return model;
+ };
+
+ FormbuilderCollection.prototype.findWhereUuid = function(uuid) {
+ return this.findWhere({
+ 'uuid': uuid
+ });
+ };
+
+ FormbuilderCollection.prototype.findDataSourceFields = function() {
+ return this.where({
+ 'type': 'datasource'
+ });
+ };
+
+ FormbuilderCollection.prototype.findConditionalTriggers = function(child) {
+ var items;
+ items = this.filter(function(model) {
+ var correctType, differentModel, hasNoParent, _ref2;
+ correctType = (_ref2 = model.get('type')) === 'dropdown' || _ref2 === 'checkbox' || _ref2 === 'radio';
+ differentModel = model !== child;
+ hasNoParent = !model.hasParent();
+ return correctType && differentModel && hasNoParent;
+ });
+ return items;
+ };
+
+ FormbuilderCollection.prototype.clearConditionEle = function(conditionalChild) {
+ return conditionalChild.unset(Formbuilder.options.mappings.CONDITIONAL);
};
return FormbuilderCollection;
})(Backbone.Collection);
+ 'Individual elements';
+
ViewFieldView = (function(_super) {
__extends(ViewFieldView, _super);
@@ -106,6 +307,28 @@
return _ref2;
}
+ ViewFieldView.insert = function(builder, view, responseField, _, options) {
+ var $replacePosition, appendEl, parentModel, replaceEl;
+ parentModel = responseField.parentModel();
+ if (parentModel === void 0 || parentModel.get('type') === 'grid' || parentModel.get('type') === 'table') {
+ appendEl = options.$appendEl || null;
+ replaceEl = options.$replaceEl || null;
+ if (appendEl != null) {
+ return appendEl.html(view.render().el);
+ } else if (replaceEl != null) {
+ return replaceEl.replaceWith(view.render().el);
+ } else if ((options.position == null) || options.position === -1) {
+ return builder.$responseFields.append(view.render().el);
+ } else if (options.position === 0) {
+ return builder.$responseFields.prepend(view.render().el);
+ } else if (($replacePosition = builder.$responseFields.find(".fb-field-wrapper").eq(options.position))[0]) {
+ return $replacePosition.before(view.render().el);
+ } else {
+ return builder.$responseFields.append(view.render().el);
+ }
+ }
+ };
+
ViewFieldView.prototype.className = "fb-field-wrapper";
ViewFieldView.prototype.events = {
@@ -121,7 +344,7 @@
};
ViewFieldView.prototype.render = function() {
- this.$el.addClass('response-field-' + this.model.get(Formbuilder.options.mappings.FIELD_TYPE)).data('cid', this.model.cid).html(Formbuilder.templates["view/base" + (!this.model.is_input() ? '_non_input' : '')]({
+ this.$el.addClass('response-field-' + this.model.get(Formbuilder.options.mappings.TYPE)).data('cid', this.model.cid).data('uuid', this.model.get('uuid')).html(Formbuilder.templates["view/base" + (!this.model.is_input() ? '_non_input' : '')]({
rf: this.model
}));
return this;
@@ -136,6 +359,10 @@
_this = this;
e.preventDefault();
e.stopPropagation();
+ _.each(this.model.conditionalChildren(), function(conditionalChild) {
+ conditionalChild.unset(Formbuilder.options.mappings.CONDITIONAL_PARENT);
+ return conditionalChild.unset(Formbuilder.options.mappings.CONDITIONAL_VALUES);
+ });
cb = function() {
_this.parentView.handleFormUpdate();
return _this.model.destroy();
@@ -154,26 +381,482 @@
}
};
- ViewFieldView.prototype.duplicate = function() {
+ ViewFieldView.prototype.duplicate = function(e) {
var attrs;
- attrs = _.clone(this.model.attributes);
+ e.preventDefault();
+ e.stopPropagation();
+ attrs = Formbuilder.helpers.clone(this.model.attributes);
delete attrs['id'];
+ delete attrs['cid'];
+ delete attrs['uuid'];
attrs['label'] += ' Copy';
- return this.parentView.createField(attrs, {
+ if (attrs.options.grid) {
+ attrs.options.grid.row = attrs.options.grid.row + 1;
+ }
+ this.parentView.createField(attrs, {
position: this.model.indexInDOM() + 1
});
+ return this.model.trigger("duplicate:viewfield");
};
return ViewFieldView;
})(Backbone.View);
+ TableFieldView = (function(_super) {
+ __extends(TableFieldView, _super);
+
+ function TableFieldView() {
+ _ref3 = TableFieldView.__super__.constructor.apply(this, arguments);
+ return _ref3;
+ }
+
+ TableFieldView.prototype.className = "fb-field-wrapper";
+
+ TableFieldView.prototype.initialize = function(options) {
+ this.parentView = options.parentView;
+ this.listenTo(this.model, "change", this.update);
+ this.listenTo(this.model, "destroy", this.remove);
+ return _.each(this.model.get('options.elements'), function(element) {
+ var childModel;
+ childModel = this.model.collection.findWhereUuid(element.uuid);
+ if (childModel) {
+ return this.listenTo(childModel, "change", this.update);
+ } else {
+ return console.log(element.uuid);
+ }
+ }, this);
+ };
+
+ TableFieldView.prototype.events = {
+ 'mouseenter': 'showSelectors',
+ 'mouseleave': 'removeSelectors',
+ 'click .drop-area li': 'inlineAdd',
+ 'click .subtemplate-wrapper': 'focusEditView',
+ 'click .response-field-table td.header': 'focusSubelement',
+ 'click .response-field-table td.element': 'focusSubelement',
+ 'click .js-clear': 'clear',
+ 'click .js-duplicate': 'duplicate'
+ };
+
+ TableFieldView.prototype.showSelectors = function(e) {
+ return this.$el.find('.drop-area').html(Formbuilder.templates['view/element_selector']());
+ };
+
+ TableFieldView.prototype.removeSelectors = function(e) {
+ return this.$el.find('.drop-area').html('');
+ };
+
+ TableFieldView.prototype.inlineAdd = function(e) {
+ var childModel, elements, newElement;
+ e.preventDefault();
+ e.stopPropagation();
+ childModel = new FormbuilderModel(Formbuilder.helpers.defaultFieldAttrs($(e.currentTarget).data('type')));
+ childModel.set('parent_uuid', this.model.get('uuid'));
+ childModel.set('options.in_sequence', true);
+ this.listenTo(childModel, "change", this.update);
+ elements = this.model.attributes.options.elements || [];
+ newElement = {
+ 'uuid': childModel.get('uuid')
+ };
+ elements.push(newElement);
+ this.model.attributes.options.elements = elements;
+ this.parentView.collection.add(childModel);
+ return this.update(childModel);
+ };
+
+ TableFieldView.prototype.update = function(model) {
+ if (model) {
+ this.render();
+ return this.parentView.createAndShowEditView(model);
+ }
+ };
+
+ TableFieldView.prototype.render = function() {
+ TableFieldView.__super__.render.call(this);
+ this.renderElements();
+ return this;
+ };
+
+ TableFieldView.prototype.focusEditView = function(e) {
+ if (!$(e.target).parents('.dropdown-toggle').length && !$(e.target).hasClass('dropdown-toggle')) {
+ return this.parentView.createAndShowEditView(this.model);
+ }
+ };
+
+ TableFieldView.prototype.focusSubelement = function(e) {
+ var childUuid;
+ e.preventDefault();
+ e.stopPropagation();
+ childUuid = $(e.currentTarget).data('uuid');
+ if (childUuid) {
+ return this.parentView.createAndShowEditView(this.parentView.modelByUuid(childUuid));
+ }
+ };
+
+ TableFieldView.prototype.renderElements = function() {
+ return _.each(this.model.get('options.elements'), function(element) {
+ var model;
+ model = this.parentView.modelByUuid(element.uuid);
+ this.$el.find('.header-' + element.uuid).html(Formbuilder.templates["view/table_header"]({
+ rf: model,
+ element: element
+ })).css('background-color', model.get(Formbuilder.options.mappings.LABEL_BACKGROUND_COLOR)).data('cid', model.cid);
+ this.$el.find('.element-' + element.uuid).html(Formbuilder.templates["view/table_element"]({
+ rf: model,
+ element: element
+ })).data('cid', model.cid);
+ return this.$el.find('.total-' + element.uuid).html(Formbuilder.templates["view/table_total"]({
+ rf: model,
+ element: element
+ })).data('cid', model.cid);
+ }, this);
+ };
+
+ TableFieldView.prototype.clear = function(e) {
+ var models, uuid;
+ e.preventDefault();
+ e.stopPropagation();
+ uuid = $(e.currentTarget).parents('.element').data('uuid');
+ if (uuid === void 0) {
+ models = _.each(this.model.get('options.elements'), function(element) {
+ this.parentView.modelByUuid(element.uuid).destroy();
+ return true;
+ }, this);
+ this.model.destroy();
+ return this.$el.remove();
+ } else {
+ this.parentView.modelByUuid(uuid).destroy();
+ this.model.set('options.elements', _.filter(this.model.get('options.elements'), function(destroyedElement) {
+ return destroyedElement.uuid !== uuid;
+ }));
+ return this.render();
+ }
+ };
+
+ TableFieldView.prototype.duplicate = function() {
+ var attrs, clonedTableModel, clonedView, elements,
+ _this = this;
+ attrs = Formbuilder.helpers.clone(this.model.attributes);
+ delete attrs['id'];
+ delete attrs['cid'];
+ attrs['uuid'] = uuid.v4();
+ attrs['label'] += ' Copy';
+ elements = attrs['options']['elements'];
+ attrs['options']['elements'] = [];
+ attrs = _.extend({}, Formbuilder.helpers.defaultFieldAttrs('table'), attrs);
+ this.parentView.createField(attrs, {
+ position: -1
+ });
+ clonedView = this.parentView.viewByUuid(attrs['uuid']);
+ clonedTableModel = this.parentView.modelByUuid(attrs['uuid']);
+ _.each(elements, function(child) {
+ var childModel, childattrs, clonedModel, totalColumnModel;
+ childModel = _this.parentView.modelByUuid(child.uuid);
+ childattrs = Formbuilder.helpers.clone(childModel);
+ delete childattrs['id'];
+ delete childattrs['cid'];
+ child.uuid = childattrs['uuid'] = uuid.v4();
+ childattrs['parent_uuid'] = attrs['uuid'];
+ childattrs = _.extend({}, Formbuilder.helpers.defaultFieldAttrs(childattrs['type']), childattrs);
+ clonedModel = new FormbuilderModel(childattrs);
+ if (child.totalColumn) {
+ totalColumnModel = clonedTableModel.createTotalColumnModel(childattrs['uuid']);
+ child.totalColumnUuid = totalColumnModel.get('uuid');
+ }
+ _this.parentView.collection.add(clonedModel);
+ if (clonedModel.expression !== void 0 && clonedModel.get('options.calculation_type')) {
+ clonedModel.expression();
+ }
+ clonedView.listenTo(clonedModel, "change", clonedView.update);
+ return attrs['options']['elements'].push(child);
+ });
+ return clonedView.render();
+ };
+
+ TableFieldView.insert = function(builder, view, responseField, _, options) {
+ var instanceView;
+ instanceView = builder.viewByUuid(responseField.get('parent_uuid'));
+ if (instanceView != null) {
+ return true;
+ } else {
+ return false;
+ }
+ };
+
+ return TableFieldView;
+
+ })(ViewFieldView);
+
+ GridFieldView = (function(_super) {
+ __extends(GridFieldView, _super);
+
+ function GridFieldView() {
+ _ref4 = GridFieldView.__super__.constructor.apply(this, arguments);
+ return _ref4;
+ }
+
+ GridFieldView.prototype.className = "fb-field-wrapper";
+
+ GridFieldView.prototype.events = {
+ 'click .response-field-grid-cell li': 'inlineAdd',
+ 'click .response-field-grid-cell .js-clear': 'subelementClear',
+ 'click .js-duplicate': 'duplicate',
+ 'click .js-clear': 'clear',
+ 'click .subtemplate-wrapper': 'focusEditView'
+ };
+
+ GridFieldView.prototype.initialize = function(options) {
+ this.parentView = options.parentView;
+ this.listenTo(this.model, "change", this.redraw);
+ this.listenTo(this.model, "destroy", this.remove);
+ this.parentView.collection.bind('add', this.addSubelement, this);
+ this.parentView.collection.bind('destroy', this.removeSubelement, this);
+ return this.render;
+ };
+
+ GridFieldView.prototype.render = function() {
+ GridFieldView.__super__.render.call(this);
+ this.redraw();
+ this.renderChildren();
+ return this;
+ };
+
+ GridFieldView.prototype.redraw = function() {
+ var table;
+ table = this.$el.find('.response-field-grid-table').detach();
+ this.$el.addClass('response-field-' + this.model.get(Formbuilder.options.mappings.TYPE)).data('cid', this.model.cid).data('uuid', this.model.get('uuid')).html(Formbuilder.templates["view/base" + (!this.model.is_input() ? '_non_input' : '')]({
+ rf: this.model
+ }));
+ if (table.length === 1) {
+ this.$el.find('.response-field-grid-table').replaceWith(table);
+ }
+ return this.renderTable();
+ };
+
+ GridFieldView.prototype.renderTable = function() {
+ var currentCols, currentRows, numCols, numRows, rows, subelements, table, _i, _ref5, _results,
+ _this = this;
+ numRows = this.model.get('options.num_rows') || 1;
+ numCols = this.model.get('options.num_cols') || 1;
+ table = this.$el.find('table');
+ currentRows = table.find('tr').length;
+ currentCols = table.find("tr:nth-child(1) td").length;
+ rows = $.makeArray(table.find('tr'));
+ if (currentRows < numRows) {
+ rows = rows.concat((function() {
+ _results = [];
+ for (var _i = _ref5 = rows.length; _ref5 <= numRows ? _i < numRows : _i > numRows; _ref5 <= numRows ? _i++ : _i--){ _results.push(_i); }
+ return _results;
+ }).apply(this));
+ }
+ rows = _.map(rows, function(row) {
+ var cols, _j, _ref6, _results1;
+ if (_.isNumber(row)) {
+ row = $(' ').appendTo(table);
+ }
+ cols = $.makeArray($(row).find('td'));
+ if (cols.length < numCols) {
+ cols = cols.concat((function() {
+ _results1 = [];
+ for (var _j = _ref6 = cols.length; _ref6 <= numCols ? _j < numCols : _j > numCols; _ref6 <= numCols ? _j++ : _j--){ _results1.push(_j); }
+ return _results1;
+ }).apply(this));
+ }
+ cols = _.map(cols, function(col) {
+ if (_.isNumber(col)) {
+ return col = $(' ').appendTo(row).html(Formbuilder.templates["view/element_selector"]());
+ }
+ });
+ return row;
+ });
+ if (currentRows > numRows) {
+ subelements = this.subelements();
+ _.each(subelements, function(subelement) {
+ var grid;
+ grid = _this.parentView.gridAttr(subelement);
+ if (grid.row > (numRows - 1)) {
+ return subelement.destroy();
+ }
+ });
+ table.find('tr').slice(numRows - currentRows).remove();
+ }
+ if (currentCols > numCols) {
+ subelements = this.subelements();
+ _.each(subelements, function(subelement) {
+ var grid;
+ grid = _this.parentView.gridAttr(subelement);
+ if (grid.col > (numCols - 1)) {
+ return subelement.destroy();
+ }
+ });
+ return table.find('tr').find('td:gt(' + (numCols - 1) + ')').remove();
+ }
+ };
+
+ GridFieldView.prototype.renderChildren = function() {
+ var children,
+ _this = this;
+ children = this.model.get('children') || [];
+ return _.each(children, function(child) {
+ var grid;
+ grid = child.options.grid;
+ return _this.createField(child, _this.getSubelement(grid.row, grid.col));
+ });
+ };
+
+ GridFieldView.prototype.focusEditView = function(e) {
+ if ($(e.target).parents('table').length === 0) {
+ return this.parentView.createAndShowEditView(this.model);
+ }
+ };
+
+ GridFieldView.prototype.clear = function(e) {
+ var cb, x,
+ _this = this;
+ e.preventDefault();
+ e.stopPropagation();
+ cb = function() {
+ var subelements;
+ _this.parentView.handleFormUpdate();
+ subelements = _this.subelements();
+ _.each(_this.subelements(), function(model) {
+ model.destroy();
+ return true;
+ });
+ return _this.model.destroy();
+ };
+ x = Formbuilder.options.CLEAR_FIELD_CONFIRM;
+ switch (typeof x) {
+ case 'string':
+ if (confirm(x)) {
+ return cb();
+ }
+ break;
+ case 'function':
+ return x(cb);
+ default:
+ return cb();
+ }
+ };
+
+ GridFieldView.prototype.duplicate = function() {
+ var attrs, children,
+ _this = this;
+ attrs = Formbuilder.helpers.clone(this.model.attributes);
+ delete attrs['id'];
+ delete attrs['cid'];
+ attrs['uuid'] = uuid.v4();
+ attrs['label'] += ' Copy';
+ children = this.subelements();
+ delete attrs['children'];
+ this.parentView.createField(attrs, {
+ position: -1
+ });
+ return attrs['children'] = _.map(children, function(child) {
+ var childattrs;
+ childattrs = Formbuilder.helpers.clone(child.attributes);
+ delete childattrs['id'];
+ delete childattrs['cid'];
+ delete childattrs['uuid'];
+ childattrs['parent_uuid'] = attrs['uuid'];
+ childattrs;
+ return _this.parentView.createField(childattrs, {
+ position: -1
+ });
+ });
+ };
+
+ GridFieldView.prototype.addSubelement = function(model) {
+ var grid, label;
+ if (this.belongsToMe(model) && model.get('label').match(/Copy/)) {
+ grid = this.parentView.gridAttr(model);
+ label = model.get('label').match(/(.+) Copy/);
+ if (label !== null) {
+ return model.attributes.label = label[1] + ' ' + (grid.row + 1);
+ } else {
+ return model.attributes.label = 'Row: ' + (grid.row + 1) + ', Col: ' + (grid.col + 1);
+ }
+ }
+ };
+
+ GridFieldView.prototype.removeSubelement = function(model) {
+ var belongsToMe, grid;
+ grid = this.parentView.gridAttr(model);
+ belongsToMe = this.belongsToMe(model);
+ if (belongsToMe && this.getSubelement(grid.row, grid.col).html() === '') {
+ return this.getSubelement(grid.row, grid.col).html(Formbuilder.templates["view/element_selector"]({
+ rf: this.model
+ }));
+ }
+ };
+
+ GridFieldView.prototype.subelements = function() {
+ var _this = this;
+ return this.parentView.collection.filter(function(item) {
+ return _this.belongsToMe(item);
+ });
+ };
+
+ GridFieldView.prototype.belongsToMe = function(model) {
+ return this.parentView.inGrid(model) && model.get('parent_uuid') === this.model.get('uuid');
+ };
+
+ GridFieldView.prototype.inlineAdd = function(e) {
+ var target, type;
+ e.preventDefault();
+ e.stopPropagation();
+ type = $(e.currentTarget).data('type');
+ target = $(e.currentTarget).parents('.response-field-grid-cell');
+ return this.createField(type, target);
+ };
+
+ GridFieldView.prototype.getSubelement = function(row, col) {
+ row++;
+ col++;
+ return this.$el.find('tr:nth-child(' + row + ') td:nth-child(' + col + ')');
+ };
+
+ GridFieldView.prototype.createField = function(attrs, target) {
+ if (_.isString(attrs)) {
+ attrs = Formbuilder.helpers.defaultFieldAttrs(attrs);
+ }
+ attrs.options.grid = {
+ col: target.prop('cellIndex'),
+ row: target.parents('tr').prop('rowIndex')
+ };
+ attrs.parent_uuid = this.model.get('uuid');
+ return this.parentView.createField(attrs, {
+ $appendEl: target
+ });
+ };
+
+ GridFieldView.insert = function(builder, view, responseField, _, options) {
+ var append, col, row;
+ if (!options.$appendEl) {
+ row = responseField.get('options.grid.row');
+ col = responseField.get('options.grid.col');
+ append = builder.wrapperByUuid(responseField.get('parent_uuid'));
+ append = append.find('tr:nth-child(' + (row + 1) + ') td:nth-child(' + (col + 1) + ')');
+ if (append.length === 1) {
+ options.$appendEl = append;
+ }
+ }
+ return ViewFieldView.insert(builder, view, responseField, _, options);
+ };
+
+ return GridFieldView;
+
+ })(Backbone.View);
+
+ '"Edit field" tab';
+
EditFieldView = (function(_super) {
__extends(EditFieldView, _super);
function EditFieldView() {
- _ref3 = EditFieldView.__super__.constructor.apply(this, arguments);
- return _ref3;
+ _ref5 = EditFieldView.__super__.constructor.apply(this, arguments);
+ return _ref5;
}
EditFieldView.prototype.className = "edit-response-field";
@@ -186,8 +869,14 @@
};
EditFieldView.prototype.initialize = function(options) {
+ var _this = this;
this.parentView = options.parentView;
- return this.listenTo(this.model, "destroy", this.remove);
+ this.listenTo(this.model, "destroy", this.remove);
+ return _.each(Formbuilder.options.change, function(callback, key) {
+ var eventName;
+ eventName = 'change:' + _.nested(Formbuilder.options.mappings, key);
+ return _this.listenTo(_this.model, eventName, callback);
+ });
};
EditFieldView.prototype.render = function() {
@@ -200,9 +889,16 @@
return this;
};
+ EditFieldView.prototype.reset = function() {
+ this.stopListening();
+ this.parentView.editView = void 0;
+ return this.parentView.createAndShowEditView(this.model);
+ };
+
EditFieldView.prototype.remove = function() {
this.parentView.editView = void 0;
this.parentView.$el.find("[data-target=\"#addField\"]").click();
+ this.stopListening();
return EditFieldView.__super__.remove.apply(this, arguments);
};
@@ -212,6 +908,7 @@
i = this.$el.find('.option').index($el.closest('.option'));
options = this.model.get(Formbuilder.options.mappings.OPTIONS) || [];
newOption = {
+ uuid: uuid.v4(),
label: "",
checked: false
};
@@ -239,36 +936,39 @@
EditFieldView.prototype.defaultUpdated = function(e) {
var $el;
$el = $(e.currentTarget);
- if (this.model.get(Formbuilder.options.mappings.FIELD_TYPE) !== 'checkboxes') {
+ if (this.model.get(Formbuilder.options.mappings.TYPE) !== 'checkboxes') {
this.$el.find(".js-default-updated").not($el).attr('checked', false).trigger('change');
}
return this.forceRender();
};
EditFieldView.prototype.forceRender = function() {
- return this.model.trigger('change');
+ return this.model.trigger('change', this.model);
};
return EditFieldView;
})(Backbone.View);
+ 'Main View for the editor';
+
BuilderView = (function(_super) {
__extends(BuilderView, _super);
function BuilderView() {
- _ref4 = BuilderView.__super__.constructor.apply(this, arguments);
- return _ref4;
+ _ref6 = BuilderView.__super__.constructor.apply(this, arguments);
+ return _ref6;
}
BuilderView.prototype.SUBVIEWS = [];
+ BuilderView.prototype.saveFormButton = $();
+
BuilderView.prototype.events = {
- 'click .js-save-form': 'saveForm',
'click .fb-tabs a': 'showTab',
- 'click .fb-add-field-types a': 'addField',
- 'mouseover .fb-add-field-types': 'lockLeftWrapper',
- 'mouseout .fb-add-field-types': 'unlockLeftWrapper'
+ 'click .fb-add-types a': 'addField',
+ 'mouseover .fb-add-types': 'lockLeftWrapper',
+ 'mouseout .fb-add-types': 'unlockLeftWrapper'
};
BuilderView.prototype.initialize = function(options) {
@@ -291,7 +991,6 @@
BuilderView.prototype.bindSaveEvent = function() {
var _this = this;
this.formSaved = true;
- this.saveFormButton = this.$el.find(".js-save-form");
this.saveFormButton.attr('disabled', true).text(Formbuilder.options.dict.ALL_CHANGES_SAVED);
if (!!Formbuilder.options.AUTOSAVE) {
setInterval(function() {
@@ -313,15 +1012,15 @@
};
BuilderView.prototype.render = function() {
- var subview, _i, _len, _ref5;
+ var subview, _i, _len, _ref7;
this.$el.html(Formbuilder.templates['page']());
this.$fbLeft = this.$el.find('.fb-left');
this.$responseFields = this.$el.find('.fb-response-fields');
this.bindWindowScrollEvent();
this.hideShowNoResponseFields();
- _ref5 = this.SUBVIEWS;
- for (_i = 0, _len = _ref5.length; _i < _len; _i++) {
- subview = _ref5[_i];
+ _ref7 = this.SUBVIEWS;
+ for (_i = 0, _len = _ref7.length; _i < _len; _i++) {
+ subview = _ref7[_i];
new subview({
parentView: this
}).render();
@@ -345,11 +1044,17 @@
};
BuilderView.prototype.showTab = function(e) {
- var $el, first_model, target;
+ var $el, first_model, go, target;
$el = $(e.currentTarget);
+ go = true;
target = $el.data('target');
- $el.closest('li').addClass('active').siblings('li').removeClass('active');
- $(target).addClass('active').siblings('.fb-tab-pane').removeClass('active');
+ if (this.editView && !this.editView.model.isValid()) {
+ go = false;
+ }
+ if (go || (!go && target === '#editField')) {
+ $el.closest('li').addClass('active').siblings('li').removeClass('active');
+ $(target).addClass('active').siblings('.fb-tab-pane').removeClass('active');
+ }
if (target !== '#editField') {
this.unlockLeftWrapper();
}
@@ -358,23 +1063,52 @@
}
};
- BuilderView.prototype.addOne = function(responseField, _, options) {
- var $replacePosition, view;
- view = new ViewFieldView({
- model: responseField,
- parentView: this
- });
- if (options.$replaceEl != null) {
- return options.$replaceEl.replaceWith(view.render().el);
- } else if ((options.position == null) || options.position === -1) {
- return this.$responseFields.append(view.render().el);
- } else if (options.position === 0) {
- return this.$responseFields.prepend(view.render().el);
- } else if (($replacePosition = this.$responseFields.find(".fb-field-wrapper").eq(options.position))[0]) {
- return $replacePosition.before(view.render().el);
+ BuilderView.prototype.createView = function(responseField) {
+ var view;
+ if (responseField.attributes.type === 'grid') {
+ view = new GridFieldView({
+ model: responseField,
+ parentView: this
+ });
+ } else if (responseField.attributes.type === 'table') {
+ view = new TableFieldView({
+ model: responseField,
+ parentView: this
+ });
} else {
- return this.$responseFields.append(view.render().el);
+ view = new ViewFieldView({
+ model: responseField,
+ parentView: this
+ });
+ }
+ return view;
+ };
+
+ BuilderView.prototype.insert = function(view, responseField, _, options) {
+ var inserted, parentModel, parentType, type;
+ inserted = false;
+ parentModel = responseField.parentModel();
+ parentType = parentModel ? parentModel.get('type') : void 0;
+ type = parentType || responseField.get('type');
+ if (type === 'grid') {
+ inserted = GridFieldView.insert(this, view, responseField, _, options);
+ } else if (type === 'table') {
+ inserted = TableFieldView.insert(this, view, responseField, _, options);
+ }
+ if (!inserted) {
+ inserted = ViewFieldView.insert(this, view, responseField, _, options);
+ }
+ return inserted;
+ };
+
+ BuilderView.prototype.addOne = function(responseField, _, options) {
+ var view;
+ view = this.createView(responseField);
+ this.$responseFields.find('> .ui-draggable').remove();
+ if (responseField.get('model_only') !== true) {
+ this.insert(view, responseField, _, options);
}
+ return this.views[responseField.get('uuid')] = view;
};
BuilderView.prototype.setSortable = function() {
@@ -387,8 +1121,8 @@
placeholder: 'sortable-placeholder',
stop: function(e, ui) {
var rf;
- if (ui.item.data('field-type')) {
- rf = _this.collection.create(Formbuilder.helpers.defaultFieldAttrs(ui.item.data('field-type')), {
+ if (ui.item.data('type')) {
+ rf = _this.collection.create(Formbuilder.helpers.defaultFieldAttrs(ui.item.data('type')), {
$replaceEl: ui.item
});
_this.createAndShowEditView(rf);
@@ -397,7 +1131,7 @@
return true;
},
update: function(e, ui) {
- if (!ui.item.data('field-type')) {
+ if (!ui.item.data('type')) {
return _this.ensureEditViewScrolled();
}
}
@@ -408,7 +1142,7 @@
BuilderView.prototype.setDraggable = function() {
var $addFieldButtons,
_this = this;
- $addFieldButtons = this.$el.find("[data-field-type]");
+ $addFieldButtons = this.$el.find("[data-type]");
return $addFieldButtons.draggable({
connectToSortable: this.$responseFields,
helper: function() {
@@ -424,7 +1158,9 @@
};
BuilderView.prototype.addAll = function() {
- this.collection.each(this.addOne, this);
+ this.collection.each(function(item, _, collection) {
+ return this.addOne.call(this, item, _, {});
+ }, this);
return this.setSortable();
};
@@ -433,9 +1169,9 @@
};
BuilderView.prototype.addField = function(e) {
- var field_type;
- field_type = $(e.currentTarget).data('field-type');
- return this.createField(Formbuilder.helpers.defaultFieldAttrs(field_type));
+ var type;
+ type = $(e.currentTarget).data('type');
+ return this.createField(Formbuilder.helpers.defaultFieldAttrs(type, {}));
};
BuilderView.prototype.createField = function(attrs, options) {
@@ -446,30 +1182,115 @@
};
BuilderView.prototype.createAndShowEditView = function(model) {
- var $newEditEl, $responseFieldEl;
+ var $newEditEl, $parentWrapper, $responseFieldEl, attrs, fieldWrapper, go, parent, selectedTriggers;
$responseFieldEl = this.$el.find(".fb-field-wrapper").filter(function() {
return $(this).data('cid') === model.cid;
});
- $responseFieldEl.addClass('editing').siblings('.fb-field-wrapper').removeClass('editing');
+ go = true;
if (this.editView) {
if (this.editView.model.cid === model.cid) {
this.$el.find(".fb-tabs a[data-target=\"#editField\"]").click();
this.scrollLeftWrapper($responseFieldEl);
return;
}
- this.editView.remove();
+ go = this.editView.model.isValid();
+ if (!go) {
+ $('.fb-edit-section-conditional-wrapper #warning-message').show();
+ } else {
+ this.editView.remove();
+ }
+ }
+ if (go) {
+ $('.fb-field-wrapper').removeClass('parent');
+ $('.fb-option').removeClass('trigger-option');
+ $('.fb-field-wrapper').removeClass('editing');
+ $responseFieldEl.addClass('editing');
+ }
+ parent = model.conditionalParent();
+ if (parent) {
+ selectedTriggers = model.get(Formbuilder.options.mappings.CONDITIONAL_VALUES) || [];
+ $parentWrapper = this.$el.find(".fb-field-wrapper").filter(function() {
+ return $(this).data('cid') === parent.cid;
+ });
+ $parentWrapper.addClass('parent');
+ $parentWrapper.find('.fb-option').filter(function() {
+ var uuid, _ref7;
+ uuid = $(this).data('uuid');
+ return _ref7 = $(this).data('uuid'), __indexOf.call(selectedTriggers, _ref7) >= 0;
+ }).each(function() {
+ return $(this).addClass('trigger-option');
+ });
+ }
+ if (go) {
+ this.editView = new EditFieldView({
+ model: model,
+ parentView: this
+ });
+ $newEditEl = this.editView.render().$el;
+ fieldWrapper = this.$el.find(".fb-edit-field-wrapper");
+ fieldWrapper.html($newEditEl);
+ if (this.inGrid(model)) {
+ fieldWrapper.addClass('fb-edit-field-grid');
+ } else {
+ fieldWrapper.removeClass('fb-edit-field-grid');
+ }
+ if (model.inTable()) {
+ $('.spectrum-colorpicker', ".fb-edit-field-wrapper").spectrum({
+ allowEmpty: true,
+ preferredFormat: 'hex',
+ showPalette: true,
+ showPaletteOnly: true,
+ palette: ['#000000', '#424242', '#636363', '#9C9C94', '#CEC6CE', '#EFEFEF', '#F7F7F7', '#FFFFFF', '#FF0000', '#FF9C00', '#FFFF00', '#00FF00', '#00FFFF', '#0000FF', '#9C00FF', '#FF00FF', '#F7C6CE', '#FFE7CE', '#FFEFC6', '#D6EFD6', '#CEDEE7', '#CEE7F7', '#D6D6E7', '#E7D6DE', '#E79C9C', '#FFC69C', '#FFE79C', '#B5D6A5', '#A5C6CE', '#9CC6EF', '#B5A5D6', '#D6A5BD', '#E76363', '#F7AD6B', '#FFD663', '#94BD7B', '#73A5AD', '#6BADDE', '#8C7BC6', '#C67BA5', '#CE0000', '#E79439', '#EFC631', '#6BA54A', '#4A7B8C', '#3984C6', '#634AA5', '#A54A7B', '#9C0000', '#B56308', '#BD9400', '#397B21', '#104A5A', '#085294', '#311873', '#731842', '#630000', '#7B3900', '#846300', '#295218', '#083139', '#003163', '#21104A', '#4A1031']
+ });
+ }
+ this.$el.find(".fb-tabs a[data-target=\"#editField\"]").click();
+ this.scrollLeftWrapper($responseFieldEl);
+ attrs = Formbuilder.helpers.defaultFieldAttrs(model.get('type'));
+ if (attrs.definition.onEdit !== void 0) {
+ attrs.definition.onEdit(model);
+ }
+ this.$el.find("input, textarea, [contenteditable=true]").filter(':visible').first().focus();
}
- this.editView = new EditFieldView({
- model: model,
- parentView: this
- });
- $newEditEl = this.editView.render().$el;
- this.$el.find(".fb-edit-field-wrapper").html($newEditEl);
- this.$el.find(".fb-tabs a[data-target=\"#editField\"]").click();
- this.scrollLeftWrapper($responseFieldEl);
return this;
};
+ BuilderView.prototype.inGrid = function(model) {
+ return this.hasParent(model) && model.get('options.grid');
+ };
+
+ BuilderView.prototype.inTable = function(model) {
+ return this.hasParent(model) && model.get('options.table');
+ };
+
+ BuilderView.prototype.hasParent = function(model) {
+ return model.get('parent_uuid');
+ };
+
+ BuilderView.prototype.modelByUuid = function(uuid) {
+ return this.collection.findWhere({
+ 'uuid': uuid
+ });
+ };
+
+ BuilderView.prototype.wrapperByUuid = function(uuid) {
+ return $('.fb-field-wrapper').filter(function() {
+ return $(this).data('uuid') === uuid;
+ });
+ };
+
+ BuilderView.prototype.viewByUuid = function(uuid) {
+ return this.views[uuid];
+ };
+
+ BuilderView.prototype.views = {};
+
+ BuilderView.prototype.gridAttr = function(model) {
+ if (this.inGrid(model)) {
+ return model.get('options.grid');
+ }
+ return null;
+ };
+
BuilderView.prototype.ensureEditViewScrolled = function() {
if (!this.editView) {
return;
@@ -497,6 +1318,7 @@
};
BuilderView.prototype.handleFormUpdate = function() {
+ this.collection.sort();
if (this.updatingBatch) {
return;
}
@@ -504,6 +1326,12 @@
return this.saveFormButton.removeAttr('disabled').text(Formbuilder.options.dict.SAVE_FORM);
};
+ BuilderView.prototype.getPayload = function() {
+ return JSON.stringify({
+ fields: this.collection.toJSON()
+ });
+ };
+
BuilderView.prototype.saveForm = function(e) {
var payload;
if (this.formSaved) {
@@ -512,9 +1340,7 @@
this.formSaved = true;
this.saveFormButton.attr('disabled', true).text(Formbuilder.options.dict.ALL_CHANGES_SAVED);
this.collection.sort();
- payload = JSON.stringify({
- fields: this.collection.toJSON()
- });
+ payload = this.getPayload();
if (Formbuilder.options.HTTP_ENDPOINT) {
this.doAjaxSave(payload);
}
@@ -529,12 +1355,12 @@
data: payload,
contentType: "application/json",
success: function(data) {
- var datum, _i, _len, _ref5;
+ var datum, _i, _len, _ref7;
_this.updatingBatch = true;
for (_i = 0, _len = data.length; _i < _len; _i++) {
datum = data[_i];
- if ((_ref5 = _this.collection.get(datum.cid)) != null) {
- _ref5.set({
+ if ((_ref7 = _this.collection.get(datum.cid)) != null) {
+ _ref7.set({
id: datum.id
});
}
@@ -550,44 +1376,168 @@
})(Backbone.View);
Formbuilder = (function() {
+ Formbuilder.attrs = {};
+
+ Formbuilder.instances = [];
+
+ Formbuilder.attr = function(name, value) {
+ if (value !== void 0) {
+ Formbuilder.attrs[name] = value;
+ _.each(this.instances, function(instance) {
+ return instance.mainView.reset();
+ });
+ }
+ if (Formbuilder.attrs[name] !== void 0) {
+ return Formbuilder.attrs[name];
+ } else {
+ return void 0;
+ }
+ };
+
+ Formbuilder.conditionalFunctionality = true;
+
+ Formbuilder.showReferenceIDFunctionality = false;
+
+ Formbuilder.geolocationFunctionality = true;
+
+ Formbuilder.linkAssetFunctionality = false;
+
+ Formbuilder.linkAssetDisplayFields = {};
+
+ Formbuilder.disableField = function(field) {
+ return this.fields[field].enabled = false;
+ };
+
Formbuilder.helpers = {
- defaultFieldAttrs: function(field_type) {
+ defaultFieldAttrs: function(type) {
var attrs, _base;
attrs = {};
attrs[Formbuilder.options.mappings.LABEL] = 'Untitled';
- attrs[Formbuilder.options.mappings.FIELD_TYPE] = field_type;
- attrs[Formbuilder.options.mappings.REQUIRED] = true;
- attrs['field_options'] = {};
- return (typeof (_base = Formbuilder.fields[field_type]).defaultAttributes === "function" ? _base.defaultAttributes(attrs) : void 0) || attrs;
+ attrs[Formbuilder.options.mappings.TYPE] = type;
+ attrs[Formbuilder.options.mappings.REQUIRED] = false;
+ attrs['definition'] = Formbuilder.fields[type];
+ attrs['options'] = {};
+ return (typeof (_base = Formbuilder.fields[type]).defaultAttributes === "function" ? _base.defaultAttributes(attrs, Formbuilder) : void 0) || attrs;
},
simple_format: function(x) {
- return x != null ? x.replace(/\n/g, ' ') : void 0;
+ var _ref7;
+ return (_ref7 = this.escape_html(x)) != null ? _ref7.replace(/\n/g, ' ') : void 0;
+ },
+ clone: function(obj) {
+ return JSON.parse(JSON.stringify(obj));
+ },
+ escape_html: function(text) {
+ var map;
+ map = {
+ '&': '&',
+ '<': '<',
+ '>': '>',
+ '"': '"',
+ "'": '''
+ };
+ return text != null ? text.replace(/[&<>"']/g, function(m) {
+ return map[m];
+ }) : void 0;
}
};
Formbuilder.options = {
- BUTTON_CLASS: 'fb-button',
+ BUTTON_CLASS_SELECTOR: 'fb-button btn btn-default',
+ BUTTON_CLASS_ADD: 'fb-button btn btn-xs btn-primary',
+ BUTTON_CLASS_REMOVE: 'fb-button btn btn-xs btn-danger',
HTTP_ENDPOINT: '',
HTTP_METHOD: 'POST',
- AUTOSAVE: true,
+ AUTOSAVE: false,
CLEAR_FIELD_CONFIRM: false,
+ ENABLED_FIELDS: ['text', 'checkbox', 'dropdown', 'textarea', 'radio', 'date', 'section', 'signature', 'info', 'grid', 'number', 'table', 'datasource', 'time', 'geolocation'],
mappings: {
- SIZE: 'field_options.size',
- UNITS: 'field_options.units',
+ SIZE: 'options.size',
+ UNITS: 'options.units',
LABEL: 'label',
- FIELD_TYPE: 'field_type',
+ NAME: 'definition.name',
+ TYPE: 'type',
REQUIRED: 'required',
ADMIN_ONLY: 'admin_only',
- OPTIONS: 'field_options.options',
- DESCRIPTION: 'field_options.description',
- INCLUDE_OTHER: 'field_options.include_other_option',
- INCLUDE_BLANK: 'field_options.include_blank_option',
- INTEGER_ONLY: 'field_options.integer_only',
- MIN: 'field_options.min',
- MAX: 'field_options.max',
- MINLENGTH: 'field_options.minlength',
- MAXLENGTH: 'field_options.maxlength',
- LENGTH_UNITS: 'field_options.min_max_length_units'
+ POPULATE_FROM: 'options.populate_from',
+ POPULATE_UUID: 'options.populate_uuid',
+ CONDITIONAL_PARENT: 'options.conditional.parent',
+ CONDITIONAL_VALUES: 'options.conditional.values',
+ CONDITIONAL: 'options.conditional',
+ OPTIONS: 'answers',
+ DESCRIPTION: 'description',
+ INCLUDE_OTHER: 'options.include_other_option',
+ INCLUDE_BLANK: 'options.include_blank_option',
+ INCLUDE_SCORING: 'is_scored',
+ INTEGER_ONLY: 'options.integer_only',
+ LABEL_COLOR: 'options.label_color',
+ LABEL_BACKGROUND_COLOR: 'options.label_background_color',
+ READ_ONLY: 'options.read_only',
+ COLUMN_WIDTH: 'options.column_width',
+ DEFAULT_TIME: 'options.default_time',
+ DEFAULT_DATE: 'options.default_date',
+ REFERENCE_ID: 'reference_id',
+ NUMERIC: {
+ CALCULATION_TYPE: 'options.calculation_type',
+ CALCULATION_EXPRESSION: 'options.calculation_expression',
+ CALCULATION_DISPLAY: 'options.calculation_display',
+ TOTAL_SEQUENCE: 'options.total_sequence'
+ },
+ GRID: {
+ COLS: 'options.cols',
+ NUMCOLS: 'options.num_cols',
+ ROWS: 'options.rows',
+ NUMROWS: 'options.num_rows',
+ FULL_WIDTH: 'options.full_width',
+ FIRST_ROW_HEADINGS: 'options.first_row_headings'
+ },
+ TABLE: {
+ COLS: 'options.cols',
+ NUMCOLS: 'options.num_cols',
+ ROWS: 'options.rows',
+ INITIALROWS: 'options.initial_rows',
+ MAXROWS: 'options.max_rows',
+ FULL_WIDTH: 'options.full_width',
+ COLUMNTOTALS: 'options.display_column_totals',
+ ROWTOTALS: 'options.display_row_totals'
+ },
+ DATA_SOURCE: {
+ MULTIPLE: 'options.multiple_selections',
+ DATA_SOURCE: 'options.data_source',
+ VALUE_TEMPLATE: 'options.value_template',
+ REQUIRED_PROPERTIES: 'options.required_properties',
+ FILTER: 'options.filter',
+ FILTER_VALUES: 'options.filter_values',
+ IS_FILTERED: 'options.is_filtered'
+ },
+ MIN: 'options.min',
+ MAX: 'options.max',
+ OPTIONS_PER_ROW: 'options.options_per_row',
+ MINLENGTH: 'options.minlength',
+ MAXLENGTH: 'options.maxlength',
+ LENGTH_UNITS: 'options.min_max_length_units'
+ },
+ change: {
+ INCLUDE_SCORING: function() {
+ return this.reset();
+ },
+ POPULATE_UUID: function() {
+ return this.reset();
+ },
+ CONDITIONAL_PARENT: function() {
+ return this.reset();
+ },
+ CONDITIONAL_VALUES: function() {
+ return this.reset();
+ },
+ 'DATA_SOURCE.DATA_SOURCE': function() {
+ return this.reset();
+ },
+ 'DATA_SOURCE.IS_FILTERED': function() {
+ return this.reset();
+ },
+ 'DATA_SOURCE.FILTER': function() {
+ return this.reset();
+ }
},
dict: {
ALL_CHANGES_SAVED: 'All changes saved',
@@ -602,16 +1552,41 @@
Formbuilder.nonInputFields = {};
+ Formbuilder.prototype.markSaved = function() {
+ return this.mainView.formSaved = true;
+ };
+
+ Formbuilder.prototype.isValid = function() {
+ var go;
+ go = true;
+ if (this.mainView.editView && !this.mainView.editView.model.isValid()) {
+ go = false;
+ }
+ return go;
+ };
+
+ Formbuilder.prototype.getPayload = function() {
+ return this.mainView.getPayload();
+ };
+
Formbuilder.registerField = function(name, opts) {
- var x, _i, _len, _ref5;
- _ref5 = ['view', 'edit'];
- for (_i = 0, _len = _ref5.length; _i < _len; _i++) {
- x = _ref5[_i];
- opts[x] = _.template(opts[x]);
+ var enabled, fields, x, _i, _len, _ref7;
+ enabled = true;
+ fields = Formbuilder.options.ENABLED_FIELDS;
+ if (!_.contains(fields, name)) {
+ enabled = false;
+ }
+ _ref7 = ['view', 'edit'];
+ for (_i = 0, _len = _ref7.length; _i < _len; _i++) {
+ x = _ref7[_i];
+ opts[x] = enabled ? _.template(opts[x]) : function(x) {
+ return '';
+ };
}
- opts.field_type = name;
+ opts.type = name;
+ opts.enabled = enabled;
Formbuilder.fields[name] = opts;
- if (opts.type === 'non_input') {
+ if (opts.element_type === 'non_input') {
return Formbuilder.nonInputFields[name] = opts;
} else {
return Formbuilder.inputFields[name] = opts;
@@ -619,7 +1594,7 @@
};
function Formbuilder(opts) {
- var args;
+ var args, partionedData;
if (opts == null) {
opts = {};
}
@@ -627,15 +1602,51 @@
args = _.extend(opts, {
formBuilder: this
});
+ this.attrs = {};
+ partionedData = _(args.bootstrapData || []).groupBy(function(i) {
+ if (i.parent_uuid === void 0) {
+ return 0;
+ } else {
+ return 1;
+ }
+ }).toArray().value();
+ partionedData = _.reduce(partionedData, function(a, i) {
+ return a.concat(i);
+ });
+ args.bootstrapData = _.map(partionedData, function(i) {
+ return _.extend({}, Formbuilder.helpers.defaultFieldAttrs(i.type), i);
+ });
this.mainView = new BuilderView(args);
+ this.mainView.collection;
+ Formbuilder.instances.push(this);
}
return Formbuilder;
})();
+ if (_.nested === void 0) {
+ _.mixin({
+ 'nested': function(obj, key) {
+ if (obj && key) {
+ return obj[key] || _.reduce(key.split('.'), function(obj, key) {
+ if (obj) {
+ return obj[key];
+ } else {
+ return void 0;
+ }
+ }, obj);
+ } else {
+ return void 0;
+ }
+ }
+ });
+ }
+
window.Formbuilder = Formbuilder;
+ window.FormbuilderModel = FormbuilderModel;
+
if (typeof module !== "undefined" && module !== null) {
module.exports = Formbuilder;
} else {
@@ -646,30 +1657,110 @@
(function() {
Formbuilder.registerField('address', {
+ name: 'Address',
order: 50,
view: "\n \n \n Address \n \n
\n\n\n \n \n City \n \n\n \n \n State / Province / Region \n \n
\n\n\n \n \n Zipcode \n \n\n \n United States \n Country \n \n
",
- edit: "",
- addButton: " Address"
+ edit: "<%= Formbuilder.templates['edit/conditional_options']({ rf: rf }) %>",
+ addButton: " Address"
});
}).call(this);
(function() {
- Formbuilder.registerField('checkboxes', {
+ Formbuilder.registerField('checkbox', {
+ name: 'Checkboxes',
order: 10,
- view: "<% for (i in (rf.get(Formbuilder.options.mappings.OPTIONS) || [])) { %>\n \n \n onclick=\"javascript: return false;\" />\n <%= rf.get(Formbuilder.options.mappings.OPTIONS)[i].label %>\n \n
\n<% } %>\n\n<% if (rf.get(Formbuilder.options.mappings.INCLUDE_OTHER)) { %>\n \n \n \n Other\n \n\n \n
\n<% } %>",
- edit: "<%= Formbuilder.templates['edit/options']({ includeOther: true }) %>",
- addButton: " Checkboxes",
+ view: "",
+ edit: "<%= Formbuilder.templates['edit/options']({ rf: rf }) %>\n<%= Formbuilder.templates['edit/options_per_row']({ rf: rf }) %>\n<%= Formbuilder.templates['edit/conditional_options']({ rf: rf }) %>",
+ addButton: " Checkboxes",
defaultAttributes: function(attrs) {
- attrs.field_options.options = [
+ attrs.answers = [
{
+ uuid: uuid.v4(),
label: "",
- checked: false
+ checked: false,
+ score: false
}, {
+ uuid: uuid.v4(),
label: "",
- checked: false
+ checked: false,
+ score: false
}
];
+ attrs.options.options_per_row = 1;
+ return attrs;
+ }
+ });
+
+}).call(this);
+
+(function() {
+ Formbuilder.registerField('datasource', {
+ name: 'List',
+ order: 70,
+ view: "\n \n <%- rf.source().title %>\n (<%- rf.sourceProperty(rf.get(Formbuilder.options.mappings.DATA_SOURCE.VALUE_TEMPLATE)) %>)\n \n ",
+ edit: "<%= Formbuilder.templates['edit/data_source_options']({ rf: rf }) %>\n<%= Formbuilder.templates['edit/conditional_options']({ rf: rf }) %>",
+ addButton: " Data Source",
+ defaultAttributes: function(attrs, formbuilder) {
+ var datasources;
+ attrs.initialize = function() {
+ this.on("change", function(model) {
+ var filters, sourceProperties, valueTemplate;
+ filters = model.filters();
+ if (_.nested(model, 'changed.options.data_source') !== void 0) {
+ sourceProperties = _.keys(model.sourceProperties());
+ model.set('options.required_properties', sourceProperties);
+ valueTemplate = _.first(sourceProperties);
+ model.set('options.value_template', valueTemplate);
+ }
+ if (filters) {
+ return model.set('options.filter', _.first(_.keys(filters)));
+ }
+ });
+ return this.on("destroy", function(model) {
+ return this.collection.each(function(collectionModel) {
+ if (collectionModel.get('options.populate_uuid') === model.get('uuid')) {
+ collectionModel.set('options.populate_uuid', null);
+ return collectionModel.set('options.populate_from', null);
+ }
+ });
+ });
+ };
+ attrs.source = function() {
+ var source, sources;
+ source = this.options ? this.options.data_source : this.get(Formbuilder.options.mappings.DATA_SOURCE.DATA_SOURCE);
+ sources = formbuilder.attr('sources');
+ return _.nested(sources, source) || {};
+ };
+ attrs.sourceProperties = function() {
+ var source;
+ source = this.source();
+ return _.nested(source, 'properties') || [];
+ };
+ attrs.filters = function() {
+ var source;
+ source = this.source();
+ return _.nested(source, 'filters') || null;
+ };
+ attrs.currentFilter = function() {
+ var source;
+ source = this.source();
+ return _.nested(source, 'filters.' + this.get('options.filter')) || {};
+ };
+ attrs.filterValues = function() {
+ return this.currentFilter().values || {};
+ };
+ attrs.sourceProperty = function(property) {
+ return this.sourceProperties()[property] || null;
+ };
+ attrs.options.multiple_selections = false;
+ attrs.options.is_filtered = false;
+ datasources = formbuilder.attr('sources') || {};
+ attrs.options.data_source = _.keys(datasources)[0];
+ attrs.options.required_properties = _.keys(attrs.sourceProperties(attrs.options.data_source));
+ attrs.options.filter = null;
+ attrs.options.filter_values = [];
+ attrs.options.value_template = _.first(attrs.options.required_properties);
return attrs;
}
});
@@ -678,31 +1769,42 @@
(function() {
Formbuilder.registerField('date', {
+ name: 'Date',
order: 20,
- view: "\n \n \n MM \n \n\n / \n\n \n \n DD \n \n\n / \n\n \n \n YYYY \n \n
",
- edit: "",
- addButton: " Date"
+ view: "\n \n
",
+ edit: "<%= Formbuilder.templates['edit/date']({ rf: rf }) %>\n<%= Formbuilder.templates['edit/conditional_options']({ rf: rf }) %>",
+ addButton: " Date",
+ defaultAttributes: function(attrs) {
+ attrs.options.default_date = false;
+ return attrs;
+ }
});
}).call(this);
(function() {
Formbuilder.registerField('dropdown', {
+ name: 'Dropdown',
order: 24,
- view: "\n <% if (rf.get(Formbuilder.options.mappings.INCLUDE_BLANK)) { %>\n \n <% } %>\n\n <% for (i in (rf.get(Formbuilder.options.mappings.OPTIONS) || [])) { %>\n >\n <%= rf.get(Formbuilder.options.mappings.OPTIONS)[i].label %>\n \n <% } %>\n ",
- edit: "<%= Formbuilder.templates['edit/options']({ includeBlank: true }) %>",
- addButton: " Dropdown",
+ view: "\n <% if (rf.get(Formbuilder.options.mappings.INCLUDE_BLANK)) { %>\n \n <% } %>\n\n <% for (i in (rf.get(Formbuilder.options.mappings.OPTIONS) || [])) { %>\n >\n <%- rf.get(Formbuilder.options.mappings.OPTIONS)[i].label %>\n \n <% } %>\n ",
+ edit: "<%= Formbuilder.templates['edit/scoring']() %>\n<%= Formbuilder.templates['edit/options']({ rf: rf }) %>\n<%= Formbuilder.templates['edit/conditional_options']({ rf: rf }) %>",
+ addButton: " Dropdown",
defaultAttributes: function(attrs) {
- attrs.field_options.options = [
+ attrs.answers = [
{
+ uuid: uuid.v4(),
label: "",
- checked: false
+ checked: false,
+ score: ""
}, {
+ uuid: uuid.v4(),
label: "",
- checked: false
+ checked: false,
+ score: ""
}
];
- attrs.field_options.include_blank_option = false;
+ attrs.is_scored = false;
+ attrs.options.include_blank_option = false;
return attrs;
}
});
@@ -711,42 +1813,161 @@
(function() {
Formbuilder.registerField('email', {
+ name: 'Email',
order: 40,
- view: " ",
- edit: "",
- addButton: " Email"
+ view: " ",
+ edit: "<%= Formbuilder.templates['edit/conditional_options']({ rf: rf }) %>",
+ addButton: " Email"
});
}).call(this);
(function() {
Formbuilder.registerField('file', {
+ name: 'File',
order: 55,
- view: " ",
- edit: "",
- addButton: " File"
+ view: " ",
+ edit: "<%= Formbuilder.templates['edit/conditional_options']({ rf: rf }) %>",
+ addButton: " File"
});
}).call(this);
(function() {
- Formbuilder.registerField('number', {
- order: 30,
- view: " \n<% if (units = rf.get(Formbuilder.options.mappings.UNITS)) { %>\n <%= units %>\n<% } %>",
- edit: "<%= Formbuilder.templates['edit/min_max']() %>\n<%= Formbuilder.templates['edit/units']() %>\n<%= Formbuilder.templates['edit/integer_only']() %>",
- addButton: "123 Number"
+ Formbuilder.registerField('geolocation', {
+ name: 'Geolocation',
+ order: 60,
+ element_type: 'non_input',
+ view: "<%- rf.get(Formbuilder.options.mappings.LABEL) %> \n\n Get GeoLocation \n
\n<%- rf.get(Formbuilder.options.mappings.DESCRIPTION) %>
\n\n<%=rf.geolocationFunctionality%> ",
+ edit: "\n\n<%= Formbuilder.templates['edit/conditional_options']({ rf: rf }) %>",
+ addButton: " GeoLocation"
});
}).call(this);
(function() {
- Formbuilder.registerField('paragraph', {
- order: 5,
- view: "",
- edit: "<%= Formbuilder.templates['edit/size']() %>\n<%= Formbuilder.templates['edit/min_max_length']() %>",
- addButton: "¶ Paragraph",
+ Formbuilder.registerField('grid', {
+ name: 'Layout Grid',
+ order: 30,
+ element_type: 'non_input',
+ view: "<%- rf.get(Formbuilder.options.mappings.LABEL) %> \n\n<%- rf.get(Formbuilder.options.mappings.DESCRIPTION) %>
",
+ edit: "\n\n",
+ addButton: " Grid",
defaultAttributes: function(attrs) {
- attrs.field_options.size = 'small';
+ attrs.options.num_cols = 1;
+ attrs.options.num_rows = 1;
+ attrs.options.full_width = false;
+ attrs.options.first_row_headings = false;
+ attrs.children = [];
+ attrs.childModels = function() {
+ return this.collection.filter(function(model) {
+ return _.indexOf(this.get('options.elements'), model.get('uuid')) !== -1;
+ }, this);
+ };
+ return attrs;
+ }
+ });
+
+}).call(this);
+
+(function() {
+ Formbuilder.registerField('info', {
+ name: 'Info',
+ order: 20,
+ element_type: 'non_input',
+ view: "<%- rf.get(Formbuilder.options.mappings.LABEL) %> \n<%= rf.get(Formbuilder.options.mappings.DESCRIPTION) %>
",
+ edit: "\n\n<%= Formbuilder.templates['edit/conditional_options']({ rf: rf }) %>",
+ addButton: " Info",
+ onEdit: function(model) {
+ var update;
+ update = function() {
+ model.set(Formbuilder.options.mappings.DESCRIPTION, $(this).code());
+ return model.trigger('change:' + Formbuilder.options.mappings.DESCRIPTION);
+ };
+ return $('.fb-info-editor').summernote({
+ onChange: function() {
+ return update.call(this);
+ },
+ onKeyup: function() {
+ return update.call(this);
+ },
+ toolbar: [['style', ['bold', 'italic', 'underline']], ['fontsize', ['fontsize']], ['color', ['color']], ['insert', ['link']], ['table', ['table']], ['misc', ['codeview']]]
+ });
+ }
+ });
+
+}).call(this);
+
+(function() {
+ Formbuilder.registerField('number', {
+ name: 'Number',
+ order: 30,
+ view: " \" <%- rf.get(Formbuilder.options.mappings.NUMERIC.CALCULATION_DISPLAY) ? 'readonly=\"readonly\"' : '' %> />\n<% if (units = rf.get(Formbuilder.options.mappings.UNITS)) { %>\n <%= units %>\n<% } %>",
+ edit: "<%= Formbuilder.templates['edit/integer_only']({rf:rf}) %>\n<%= Formbuilder.templates['edit/total']({rf:rf}) %>\n<%= Formbuilder.templates['edit/min_max']({rf:rf}) %>\n<%= Formbuilder.templates['edit/conditional_options']({ rf: rf }) %>",
+ addButton: " Number",
+ defaultAttributes: function(attrs, formbuilder) {
+ attrs.options.calculation_type = '';
+ attrs.options.calculation_expression = '';
+ attrs.options.calculation_display = '';
+ attrs.options.total_sequence = false;
+ attrs.insertion = function() {
+ var parentModel, totalColumn;
+ parentModel = this.parentModel();
+ if (parentModel && parentModel.get('type') === 'table') {
+ totalColumn = parentModel.totalColumn(this.get('uuid'));
+ return this.attributes.options.total_sequence = totalColumn;
+ }
+ };
+ attrs.initialize = function() {
+ return this.on("change", function(model) {
+ var totalSequence;
+ if (_.nested(model, 'changed.options.calculation_type') !== void 0) {
+ model.expression();
+ }
+ if (_.nested(model, 'changed.options.total_sequence') !== void 0) {
+ totalSequence = _.nested(model, 'changed.options.total_sequence');
+ this.parentModel().totalColumn(model.get('uuid'), totalSequence);
+ }
+ return model;
+ });
+ };
+ attrs.numericSiblings = function() {
+ var parentModel;
+ parentModel = this.parentModel();
+ if (parentModel) {
+ return _.filter(parentModel.childModels(), function(i) {
+ return i.get('type') === 'number' && i.get('uuid') !== this.get('uuid');
+ }, this);
+ } else {
+ return [];
+ }
+ };
+ attrs.expression = function() {
+ var calculation_type, numericSiblings, operator;
+ calculation_type = this.get('options.calculation_type');
+ if (calculation_type !== '') {
+ operator = calculation_type === 'SUM' ? '+' : '*';
+ numericSiblings = this.numericSiblings();
+ this.set('options.calculation_expression', _.map(numericSiblings, function(model) {
+ return 'uuid_' + model.get('uuid').replace(/-/g, '_');
+ }).join(operator));
+ this.set('options.calculation_display', '= ' + _.map(numericSiblings, function(model) {
+ return model.get('label');
+ }).join(operator));
+ return console.log(this.get('options.calculation_expression'));
+ } else {
+ this.set('options.calculation_expression', '');
+ return this.set('options.calculation_display', '');
+ }
+ };
+ attrs.canTotalColumn = function() {
+ var parent;
+ parent = this.parentModel();
+ return parent && parent.get('type') === 'table';
+ };
+ attrs.canAcceptCalculatedTotal = function() {
+ return this.numericSiblings().length > 1;
+ };
return attrs;
}
});
@@ -755,30 +1976,38 @@
(function() {
Formbuilder.registerField('price', {
+ name: 'Price',
order: 45,
view: "\n $ \n \n \n Dollars \n \n . \n \n \n Cents \n \n
",
- edit: "",
- addButton: " Price"
+ edit: "<%= Formbuilder.templates['edit/conditional_options']({ rf: rf }) %>",
+ addButton: " Price"
});
}).call(this);
(function() {
Formbuilder.registerField('radio', {
+ name: 'Radio Button',
order: 15,
- view: "<% for (i in (rf.get(Formbuilder.options.mappings.OPTIONS) || [])) { %>\n \n \n onclick=\"javascript: return false;\" />\n <%= rf.get(Formbuilder.options.mappings.OPTIONS)[i].label %>\n \n
\n<% } %>\n\n<% if (rf.get(Formbuilder.options.mappings.INCLUDE_OTHER)) { %>\n \n \n \n Other\n \n\n \n
\n<% } %>",
- edit: "<%= Formbuilder.templates['edit/options']({ includeOther: true }) %>",
- addButton: " Multiple Choice",
+ view: "",
+ edit: "<%= Formbuilder.templates['edit/scoring']({ rf: rf }) %>\n<%= Formbuilder.templates['edit/options']({ rf: rf }) %>\n<%= Formbuilder.templates['edit/options_per_row']({ rf: rf }) %>\n<%= Formbuilder.templates['edit/conditional_options']({ rf: rf }) %>",
+ addButton: " Radio Button",
defaultAttributes: function(attrs) {
- attrs.field_options.options = [
+ attrs.answers = [
{
+ uuid: uuid.v4(),
label: "",
- checked: false
+ checked: false,
+ score: ""
}, {
+ uuid: uuid.v4(),
label: "",
- checked: false
+ checked: false,
+ score: ""
}
];
+ attrs.is_scored = false;
+ attrs.options.options_per_row = 1;
return attrs;
}
});
@@ -786,24 +2015,133 @@
}).call(this);
(function() {
- Formbuilder.registerField('section_break', {
+ Formbuilder.registerField('section', {
+ name: 'Section',
+ order: 10,
+ element_type: 'non_input',
+ view: "<%- rf.get(Formbuilder.options.mappings.LABEL) %> \n<%- rf.get(Formbuilder.options.mappings.DESCRIPTION) %>
",
+ edit: "\n\n<%= Formbuilder.templates['edit/conditional_options']({ rf: rf }) %>",
+ addButton: " Section Break"
+ });
+
+}).call(this);
+
+(function() {
+ Formbuilder.registerField('signature', {
+ name: 'Signature',
+ order: 65,
+ view: "\nClear ",
+ edit: "<%= Formbuilder.templates['edit/conditional_options']({ rf: rf }) %>",
+ addButton: " Signature"
+ });
+
+}).call(this);
+
+(function() {
+ Formbuilder.registerField('table', {
+ name: 'Table',
order: 0,
- type: 'non_input',
- view: "<%= rf.get(Formbuilder.options.mappings.LABEL) %> \n<%= rf.get(Formbuilder.options.mappings.DESCRIPTION) %>
",
- edit: "\n \n",
- addButton: " Section Break"
+ element_type: 'non_input',
+ view: "<%- rf.get(Formbuilder.options.mappings.LABEL) %> \n<%= Formbuilder.templates[\"view/table_field\"]({rf: rf}) %>\n<%- rf.get(Formbuilder.options.mappings.DESCRIPTION) %>
",
+ edit: "\n\n
\n <%= Formbuilder.templates['edit/label_description']({rf: rf}) %>\n
\n
\n
\n\n Display full width ?\n ",
+ addButton: " Table",
+ defaultAttributes: function(attrs) {
+ attrs.options.full_width = false;
+ attrs.initialize = function() {
+ var parent;
+ parent = this;
+ return _.each(this.childModels, function(childModel) {
+ return childModel.on("change", function(model) {
+ if (_.nested(model, 'changed.options.column_width') !== void 0) {
+ parent.columnWidth(model.get('uuid'), model.get('options.column_width'));
+ }
+ return model;
+ });
+ });
+ };
+ attrs.childModels = function() {
+ var elementsUuids;
+ elementsUuids = _.pluck(this.get('options.elements'), 'uuid');
+ return this.collection.filter(function(model) {
+ return _.indexOf(elementsUuids, model.get('uuid')) !== -1;
+ }, this);
+ };
+ attrs.elementOptions = function(elementUuid) {
+ return _.findWhere(this.get('options.elements'), {
+ uuid: elementUuid
+ });
+ };
+ attrs.createTotalColumnModel = function(parentUuid) {
+ var totalColumnModel;
+ totalColumnModel = new FormbuilderModel(Formbuilder.helpers.defaultFieldAttrs('number'));
+ totalColumnModel.set('options.calculation_expression', 'sum(column_uuid_' + parentUuid.replace(/-/g, '_') + ')');
+ totalColumnModel.set('model_only', true);
+ totalColumnModel.set('parent_uuid', parentUuid);
+ this.collection.add(totalColumnModel);
+ return totalColumnModel;
+ };
+ attrs.columnWidth = function(elementUuid, width) {
+ var elements;
+ elements = this.get('options.elements');
+ return _.each(elements, function(element, index) {
+ if (element.uuid === elementUuid) {
+ return elements[index].columnWidth = width;
+ }
+ }, this);
+ };
+ attrs.totalColumn = function(elementUuid, value) {
+ var elements;
+ elements = this.get('options.elements');
+ if (value !== void 0) {
+ _.each(elements, function(element, index) {
+ var totalColumnModel;
+ if (element.uuid === elementUuid) {
+ if (element.totalColumnUuid === void 0) {
+ totalColumnModel = this.createTotalColumnModel(element.uuid);
+ elements[index].totalColumnUuid = totalColumnModel.get('uuid');
+ }
+ return elements[index].totalColumn = value;
+ }
+ }, this);
+ return this.set('options.elements', elements);
+ } else {
+ if (this.elementOptions(elementUuid)) {
+ return this.elementOptions(elementUuid).totalColumn || false;
+ } else {
+ return false;
+ }
+ }
+ };
+ return attrs;
+ }
+ });
+
+}).call(this);
+
+(function() {
+ Formbuilder.registerField('text', {
+ name: 'Text',
+ order: 0,
+ view: " ",
+ edit: "<%= Formbuilder.templates['edit/populate_from']({ rf: rf }) %>\n<%= Formbuilder.templates['edit/conditional_options']({ rf: rf }) %>",
+ addButton: " Text",
+ defaultAttributes: function(attrs) {
+ attrs.options.size = 'small';
+ return attrs;
+ }
});
}).call(this);
(function() {
- Formbuilder.registerField('text', {
- order: 0,
- view: " ",
- edit: "<%= Formbuilder.templates['edit/size']() %>\n<%= Formbuilder.templates['edit/min_max_length']() %>",
- addButton: " Text",
+ Formbuilder.registerField('textarea', {
+ name: 'Paragraph',
+ order: 5,
+ view: "",
+ edit: "<%= Formbuilder.templates['edit/populate_from']({ rf: rf }) %>\n<%= Formbuilder.templates['edit/conditional_options']({ rf: rf }) %>",
+ addButton: " Paragraph",
defaultAttributes: function(attrs) {
- attrs.field_options.size = 'small';
+ attrs.options.size = 'small';
return attrs;
}
});
@@ -812,20 +2150,26 @@
(function() {
Formbuilder.registerField('time', {
+ name: 'Time',
order: 25,
- view: "\n \n \n HH \n \n\n : \n\n \n \n MM \n \n\n : \n\n \n \n SS \n \n\n \n \n AM \n PM \n \n \n
",
- edit: "",
- addButton: " Time"
+ view: "",
+ edit: "<%= Formbuilder.templates['edit/time']({ rf: rf }) %>\n<%= Formbuilder.templates['edit/conditional_options']({ rf: rf }) %>",
+ addButton: " Time",
+ defaultAttributes: function(attrs) {
+ attrs.options.default_time = false;
+ return attrs;
+ }
});
}).call(this);
(function() {
Formbuilder.registerField('website', {
+ name: 'Website',
order: 35,
view: " ",
- edit: "",
- addButton: " Website"
+ edit: "<%= Formbuilder.templates['edit/conditional_options']({ rf: rf }) %>",
+ addButton: " Website"
});
}).call(this);
@@ -838,11 +2182,15 @@ obj || (obj = {});
var __t, __p = '', __e = _.escape;
with (obj) {
__p +=
-((__t = ( Formbuilder.templates['edit/base_header']() )) == null ? '' : __t) +
+((__t = ( Formbuilder.templates['edit/base_header']({rf: rf}) )) == null ? '' : __t) +
'\n' +
-((__t = ( Formbuilder.templates['edit/common']() )) == null ? '' : __t) +
+((__t = ( Formbuilder.templates['edit/common']({rf: rf}) )) == null ? '' : __t) +
'\n' +
-((__t = ( Formbuilder.fields[rf.get(Formbuilder.options.mappings.FIELD_TYPE)].edit({rf: rf}) )) == null ? '' : __t) +
+((__t = ( Formbuilder.fields[rf.get(Formbuilder.options.mappings.TYPE)].edit({rf: rf}) )) == null ? '' : __t) +
+'\n' +
+((__t = ( Formbuilder.templates['edit/columnwidth']({rf: rf}) )) == null ? '' : __t) +
+'\n' +
+((__t = ( Formbuilder.templates['edit/table_color']({rf: rf}) )) == null ? '' : __t) +
'\n';
}
@@ -855,9 +2203,9 @@ var __t, __p = '', __e = _.escape;
with (obj) {
__p += '\n \n
\n \n
';
+'">\n
\n \n\n';
}
return __p
@@ -868,9 +2216,9 @@ obj || (obj = {});
var __t, __p = '', __e = _.escape;
with (obj) {
__p +=
-((__t = ( Formbuilder.templates['edit/base_header']() )) == null ? '' : __t) +
+((__t = ( Formbuilder.templates['edit/base_header']({rf: rf}) )) == null ? '' : __t) +
'\n' +
-((__t = ( Formbuilder.fields[rf.get(Formbuilder.options.mappings.FIELD_TYPE)].edit({rf: rf}) )) == null ? '' : __t) +
+((__t = ( Formbuilder.fields[rf.get(Formbuilder.options.mappings.TYPE)].edit({rf: rf}) )) == null ? '' : __t) +
'\n';
}
@@ -881,25 +2229,175 @@ this["Formbuilder"]["templates"]["edit/checkboxes"] = function(obj) {
obj || (obj = {});
var __t, __p = '', __e = _.escape;
with (obj) {
-__p += '\n \n \n Required\n \n\n \n Admin only\n ';
+'\' />\n Required\n\n';
}
return __p
};
-this["Formbuilder"]["templates"]["edit/common"] = function(obj) {
+this["Formbuilder"]["templates"]["edit/columnwidth"] = function(obj) {
obj || (obj = {});
var __t, __p = '', __e = _.escape;
with (obj) {
-__p += '\n\n\n
\n ' +
-((__t = ( Formbuilder.templates['edit/label_description']() )) == null ? '' : __t) +
-'\n
\n
\n ' +
+__p += '';
+
+}
+return __p
+};
+
+this["Formbuilder"]["templates"]["edit/common"] = function(obj) {
+obj || (obj = {});
+var __t, __p = '', __e = _.escape, __j = Array.prototype.join;
+function print() { __p += __j.call(arguments, '') }
+with (obj) {
+
+ if (rf.canShowReferenceID()) { ;
+__p += '\n
\n \n ' +
+((__t = ( Formbuilder.templates['edit/reference_id']({rf: rf}) )) == null ? '' : __t) +
+'\n
\n';
+ } ;
+__p += '\n\n\n
\n
\n ' +
+((__t = ( Formbuilder.templates['edit/label_description']({rf: rf}) )) == null ? '' : __t) +
+'\n
\n
\n ' +
((__t = ( Formbuilder.templates['edit/checkboxes']() )) == null ? '' : __t) +
-'\n
\n
\n
\n';
+'\n
\n
\n
';
+
+}
+return __p
+};
+
+this["Formbuilder"]["templates"]["edit/conditional_options"] = function(obj) {
+obj || (obj = {});
+var __t, __p = '', __e = _.escape, __j = Array.prototype.join;
+function print() { __p += __j.call(arguments, '') }
+with (obj) {
+
+ if (rf.canBeConditionallyDisplayed()) { ;
+__p += '\n\n\n\n\n\n';
+ var list = rf.collection.findConditionalTriggers(rf);
+
+if (list.length) {
+;
+__p += '\n\n
\n \n ';
+
+ for (i in (list || [])) { ;
+__p += '\n \n ' +
+__e( list[i].get('label') ) +
+'\n ';
+ if( rf.canShowReferenceID() && list[i].get('reference_id')) { ;
+__p += '\n [' +
+((__t = ( list[i].get('reference_id') )) == null ? '' : __t) +
+']\n ';
+ } ;
+__p += '\n \n ';
+ } ;
+__p += '\n \n\n\n\n\n';
+
+
+var selectedList = rf.conditionalTriggerOptions();
+
+if (selectedList.length == 0)
+ rf.collection.clearConditionEle(rf);
+for (i in selectedList) { ;
+__p += '\n
\n \n ' +
+((__t = ( selectedList[i].label )) == null ? '' : __t) +
+'\n \n\n';
+ } ;
+__p += '\n';
+ } else { ;
+__p += '\nNo trigger elements\n';
+ } ;
+__p += '\n';
+ } ;
+__p += '\n
Please ensure that conditional values are selected
\n
\n';
+
+}
+return __p
+};
+
+this["Formbuilder"]["templates"]["edit/data_source_options"] = function(obj) {
+obj || (obj = {});
+var __t, __p = '', __e = _.escape, __j = Array.prototype.join;
+function print() { __p += __j.call(arguments, '') }
+with (obj) {
+__p += '\n\n';
+ for (i in (Formbuilder.attr('sources') || [])) { ;
+__p += '\n \n ' +
+__e( Formbuilder.attr('sources')[i].title ) +
+'\n \n';
+ } ;
+__p += '\n \n\n\n';
+
+ for (i in (rf.sourceProperties() || [])) { ;
+__p += '\n \n ' +
+__e( rf.sourceProperties()[i] ) +
+'\n \n';
+ } ;
+__p += '\n \n';
+ if (rf.filters()) { ;
+__p += '\n \n \n \n Apply a filter?\n \n ';
+ if (rf.get(Formbuilder.options.mappings.DATA_SOURCE.IS_FILTERED)) { ;
+__p += '\n \n ';
+
+ for (i in (rf.filters() || [])) { ;
+__p += '\n \n ' +
+__e( rf.filters()[i].name ) +
+'\n \n ';
+ } ;
+__p += '\n \n ';
+
+ for (i in rf.filterValues()) { ;
+__p += '\n \n \n ' +
+__e( rf.filterValues()[i] ) +
+'\n \n ';
+ } ;
+__p += '\n';
+ } ;
+__p += '\n';
+ } ;
+
+
+}
+return __p
+};
+
+this["Formbuilder"]["templates"]["edit/date"] = function(obj) {
+obj || (obj = {});
+var __t, __p = '', __e = _.escape;
+with (obj) {
+__p += '\n \n \n Default to current date\n \n
\n';
}
return __p
@@ -909,9 +2407,9 @@ this["Formbuilder"]["templates"]["edit/integer_only"] = function(obj) {
obj || (obj = {});
var __t, __p = '', __e = _.escape;
with (obj) {
-__p += '\n\n \n \n Only accept integers\n \n';
+'\' />\n Whole numbers only?\n\n';
}
return __p
@@ -921,9 +2419,9 @@ this["Formbuilder"]["templates"]["edit/label_description"] = function(obj) {
obj || (obj = {});
var __t, __p = '', __e = _.escape;
with (obj) {
-__p += ' \n\n';
@@ -935,9 +2433,9 @@ this["Formbuilder"]["templates"]["edit/min_max"] = function(obj) {
obj || (obj = {});
var __t, __p = '', __e = _.escape;
with (obj) {
-__p += '\n\nAbove\n \n\n \n\nBelow\n \n\n \n\nMax\n \n';
@@ -949,11 +2447,11 @@ this["Formbuilder"]["templates"]["edit/min_max_length"] = function(obj) {
obj || (obj = {});
var __t, __p = '', __e = _.escape;
with (obj) {
-__p += '\n\nMin\n \n\n \n\nMax\n \n\n \n\nMax\n \n\n \n\n \n\n \n\n\n characters \n words \n \n';
@@ -968,25 +2466,107 @@ function print() { __p += __j.call(arguments, '') }
with (obj) {
__p += '\n\n';
if (typeof includeBlank !== 'undefined'){ ;
-__p += '\n \n \n \n Include blank\n \n';
} ;
__p += '\n\n\n\n';
+'\'>\n\n \n ';
+ if (rf.get(Formbuilder.options.mappings.INCLUDE_SCORING)) { ;
+__p += '\n \n ';
+ } ;
+__p += '\n\n \n\n\n';
if (typeof includeOther !== 'undefined'){ ;
-__p += '\n \n \n \n Include "other"\n \n';
} ;
-__p += '\n\n\n';
+__p += '\n\n\n Add option \n
\n';
+
+}
+return __p
+};
+
+this["Formbuilder"]["templates"]["edit/options_per_row"] = function(obj) {
+obj || (obj = {});
+var __t, __p = '', __e = _.escape;
+with (obj) {
+__p += '\n \n 1 \n 2 \n 3 \n 4 \n 5 \n 6 \n 7 \n 8 \n 9 \n 10 \n 11 \n 12 \n 13 \n 14 \n 15 \n \n';
+
+}
+return __p
+};
+
+this["Formbuilder"]["templates"]["edit/populate_from"] = function(obj) {
+obj || (obj = {});
+var __t, __p = '', __e = _.escape, __j = Array.prototype.join;
+function print() { __p += __j.call(arguments, '') }
+with (obj) {
+
+ var list = rf.collection.findDataSourceFields();
+if (list.length) { ;
+__p += '\n \n \n \n ';
+
+ for (i in (list || [])) { ;
+__p += '\n \n ' +
+__e( list[i].get('label') ) +
+'\n \n ';
+ } ;
+__p += '\n \n \n \n ';
+
+ var populationUuid = rf.get('options.populate_uuid');
+ var populationModel = rf.collection.findWhereUuid(populationUuid) || {};
+ if (populationUuid && populationModel) {
+ var dataSource = populationModel.get('options.data_source');
+ var listProperties = Formbuilder.attr('sources')[dataSource].properties;
+ for (i in listProperties) { ;
+__p += '\n \n ' +
+__e( listProperties[i] ) +
+'\n \n ';
+ }
+ } ;
+__p += '\n \n';
+ } ;
+__p += '\n';
+
+}
+return __p
+};
+
+this["Formbuilder"]["templates"]["edit/reference_id"] = function(obj) {
+obj || (obj = {});
+var __t, __p = '', __e = _.escape;
+with (obj) {
+__p += ' ';
+
+}
+return __p
+};
+
+this["Formbuilder"]["templates"]["edit/scoring"] = function(obj) {
+obj || (obj = {});
+var __t, __p = '', __e = _.escape;
+with (obj) {
+__p += '\n \n \n Include Scoring\n \n
\n\n';
}
return __p
@@ -1004,6 +2584,86 @@ __p += '\n\n \n \n \n
\n \n \n \n
\n\n';
+ } ;
+
+
+}
+return __p
+};
+
+this["Formbuilder"]["templates"]["edit/table_layout"] = function(obj) {
+obj || (obj = {});
+var __t, __p = '', __e = _.escape;
+with (obj) {
+__p += '\n \n Columns\n \n 1 \n 2 \n 3 \n 4 \n 5 \n 6 \n 7 \n 8 \n 9 \n 10 \n \n \n\n \n Max rows\n \n \n';
+
+}
+return __p
+};
+
+this["Formbuilder"]["templates"]["edit/table_totals"] = function(obj) {
+obj || (obj = {});
+var __t, __p = '', __e = _.escape;
+with (obj) {
+__p += '\n \n \n Display column totals?\n \n';
+
+}
+return __p
+};
+
+this["Formbuilder"]["templates"]["edit/time"] = function(obj) {
+obj || (obj = {});
+var __t, __p = '', __e = _.escape;
+with (obj) {
+__p += '\n \n \n Default to current time\n \n
\n';
+
+}
+return __p
+};
+
+this["Formbuilder"]["templates"]["edit/total"] = function(obj) {
+obj || (obj = {});
+var __t, __p = '', __e = _.escape, __j = Array.prototype.join;
+function print() { __p += __j.call(arguments, '') }
+with (obj) {
+
+ if (rf.canTotalColumn()) { ;
+__p += '\n\n Display column total?\n \n \n';
+ } ;
+__p += '\n';
+ if (rf.canAcceptCalculatedTotal()) { ;
+__p += '\n\n\n Calculated Value\n \n No Calculation \n Sum \n Product \n \n \n';
+ } ;
+__p += '\n\n';
+
+}
+return __p
+};
+
this["Formbuilder"]["templates"]["edit/units"] = function(obj) {
obj || (obj = {});
var __t, __p = '', __e = _.escape;
@@ -1021,8 +2681,6 @@ obj || (obj = {});
var __t, __p = '', __e = _.escape;
with (obj) {
__p +=
-((__t = ( Formbuilder.templates['partials/save_button']() )) == null ? '' : __t) +
-'\n' +
((__t = ( Formbuilder.templates['partials/left_side']() )) == null ? '' : __t) +
'\n' +
((__t = ( Formbuilder.templates['partials/right_side']() )) == null ? '' : __t) +
@@ -1037,22 +2695,28 @@ obj || (obj = {});
var __t, __p = '', __e = _.escape, __j = Array.prototype.join;
function print() { __p += __j.call(arguments, '') }
with (obj) {
-__p += '\n
\n
\n\n
\n ';
- _.each(_.sortBy(Formbuilder.nonInputFields, 'order'), function(f){ ;
-__p += '\n
\n ' +
((__t = ( f.addButton )) == null ? '' : __t) +
'\n \n ';
@@ -1089,21 +2753,16 @@ return __p
this["Formbuilder"]["templates"]["partials/right_side"] = function(obj) {
obj || (obj = {});
-var __t, __p = '', __e = _.escape;
-with (obj) {
-__p += '
\n
No response fields
\n
\n
\n';
-
-}
-return __p
-};
-
-this["Formbuilder"]["templates"]["partials/save_button"] = function(obj) {
-obj || (obj = {});
-var __t, __p = '', __e = _.escape;
+var __t, __p = '', __e = _.escape, __j = Array.prototype.join;
+function print() { __p += __j.call(arguments, '') }
with (obj) {
-__p += '
\n \n
';
+__p += '
\n
No response fields
\n ';
+ if (Formbuilder.linkAssetFunctionality) { ;
+__p += '\n ' +
+((__t = ( Formbuilder.templates['view/link_object']({object: Formbuilder.linkAssetDisplayFields}) )) == null ? '' : __t) +
+'\n
\n ';
+ } ;
+__p += '\n
\n
\n';
}
return __p
@@ -1114,9 +2773,11 @@ obj || (obj = {});
var __t, __p = '', __e = _.escape;
with (obj) {
__p += '
\n
\n ' +
+((__t = ( Formbuilder.templates['view/conditional']({rf: rf}) )) == null ? '' : __t) +
+'\n ' +
((__t = ( Formbuilder.templates['view/label']({rf: rf}) )) == null ? '' : __t) +
'\n\n ' +
-((__t = ( Formbuilder.fields[rf.get(Formbuilder.options.mappings.FIELD_TYPE)].view({rf: rf}) )) == null ? '' : __t) +
+((__t = ( Formbuilder.fields[rf.get(Formbuilder.options.mappings.TYPE)].view({rf: rf}) )) == null ? '' : __t) +
'\n\n ' +
((__t = ( Formbuilder.templates['view/description']({rf: rf}) )) == null ? '' : __t) +
'\n ' +
@@ -1132,7 +2793,9 @@ obj || (obj = {});
var __t, __p = '', __e = _.escape;
with (obj) {
__p += '
\n
\n ' +
-((__t = ( Formbuilder.fields[rf.get(Formbuilder.options.mappings.FIELD_TYPE)].view({rf: rf}) )) == null ? '' : __t) +
+((__t = ( Formbuilder.templates['view/conditional']({rf: rf}) )) == null ? '' : __t) +
+'\n ' +
+((__t = ( Formbuilder.fields[rf.get(Formbuilder.options.mappings.TYPE)].view({rf: rf}) )) == null ? '' : __t) +
'\n ' +
((__t = ( Formbuilder.templates['view/duplicate_remove']({rf: rf}) )) == null ? '' : __t) +
'\n
\n';
@@ -1141,13 +2804,45 @@ __p += '
\n
\n '
return __p
};
+this["Formbuilder"]["templates"]["view/conditional"] = function(obj) {
+obj || (obj = {});
+var __t, __p = '', __e = _.escape, __j = Array.prototype.join;
+function print() { __p += __j.call(arguments, '') }
+with (obj) {
+
+
+var parent = rf.conditionalParent();
+var triggerValues = _.pluck(rf.conditionalTriggerOptions(true), 'label');
+if (parent && triggerValues.length) {
+;
+__p += '\n
\n \n display when ' +
+((__t = ( parent.get('label') )) == null ? '' : __t) +
+' is ' +
+((__t = ( triggerValues.join(' or') )) == null ? '' : __t) +
+' \n
\n';
+ } ;
+__p += '\n';
+
+}
+return __p
+};
+
this["Formbuilder"]["templates"]["view/description"] = function(obj) {
obj || (obj = {});
-var __t, __p = '', __e = _.escape;
+var __t, __p = '', __e = _.escape, __j = Array.prototype.join;
+function print() { __p += __j.call(arguments, '') }
with (obj) {
-__p += '
\n ' +
+__p += '\n ';
+ if (rf.get("type") == "info") { ;
+__p += '\n ' +
+((__t = ( rf.get(Formbuilder.options.mappings.DESCRIPTION) )) == null ? '' : __t) +
+'\n ';
+ } else { ;
+__p += '\n ' +
((__t = ( Formbuilder.helpers.simple_format(rf.get(Formbuilder.options.mappings.DESCRIPTION)) )) == null ? '' : __t) +
-'\n \n';
+'\n ';
+ } ;
+__p += '\n ';
}
return __p
@@ -1157,11 +2852,21 @@ this["Formbuilder"]["templates"]["view/duplicate_remove"] = function(obj) {
obj || (obj = {});
var __t, __p = '', __e = _.escape;
with (obj) {
-__p += '
';
+__p += '
\n \n \n
';
+
+}
+return __p
+};
+
+this["Formbuilder"]["templates"]["view/element_selector"] = function(obj) {
+obj || (obj = {});
+var __t, __p = '', __e = _.escape;
+with (obj) {
+__p += '
\n\n \n \n\n
\n';
}
return __p
@@ -1172,7 +2877,9 @@ obj || (obj = {});
var __t, __p = '', __e = _.escape, __j = Array.prototype.join;
function print() { __p += __j.call(arguments, '') }
with (obj) {
-__p += '
\n ' +
+__p += '\n ' +
((__t = ( Formbuilder.helpers.simple_format(rf.get(Formbuilder.options.mappings.LABEL)) )) == null ? '' : __t) +
'\n ';
if (rf.get(Formbuilder.options.mappings.REQUIRED)) { ;
@@ -1180,6 +2887,121 @@ __p += '\n * \n ';
} ;
__p += '\n \n';
+}
+return __p
+};
+
+this["Formbuilder"]["templates"]["view/link_object"] = function(obj) {
+obj || (obj = {});
+var __t, __p = '', __e = _.escape, __j = Array.prototype.join;
+function print() { __p += __j.call(arguments, '') }
+with (obj) {
+__p += '\n
\n ' +
+((__t = ( object.name )) == null ? '' : __t) +
+' \n
\n
\n Display Fields \n
\n
\n ';
+ for (field in object.fields) { ;
+__p += '\n ' +
+((__t = ( object.fields[field] )) == null ? '' : __t) +
+' \n ';
+ } ;
+__p += '\n \n
\n\n\n';
+
+}
+return __p
+};
+
+this["Formbuilder"]["templates"]["view/remove"] = function(obj) {
+obj || (obj = {});
+var __t, __p = '', __e = _.escape;
+with (obj) {
+__p += '\n \n
';
+
+}
+return __p
+};
+
+this["Formbuilder"]["templates"]["view/table_element"] = function(obj) {
+obj || (obj = {});
+var __t, __p = '', __e = _.escape;
+with (obj) {
+__p +=
+((__t = ( Formbuilder.fields[rf.get(Formbuilder.options.mappings.TYPE)].view({rf: rf}) )) == null ? '' : __t) +
+'\n' +
+((__t = ( Formbuilder.templates['view/remove']({rf: rf}) )) == null ? '' : __t);
+
+}
+return __p
+};
+
+this["Formbuilder"]["templates"]["view/table_field"] = function(obj) {
+obj || (obj = {});
+var __t, __p = '', __e = _.escape, __j = Array.prototype.join;
+function print() { __p += __j.call(arguments, '') }
+with (obj) {
+__p += '\n' +
+((__t = ( Formbuilder.templates['view/element_selector']() )) == null ? '' : __t) +
+'\n \n\n\n \n \n ';
+ for (i in (rf.get('options.elements') || [])) { ;
+__p += '\n \n ';
+ } ;
+__p += '\n \n \n ';
+ for (i in (rf.get('options.elements') || [])) { ;
+__p += '\n \n ';
+ } ;
+__p += '\n \n \n \n \n ';
+ for (i in (rf.get('options.elements') || [])) { ;
+__p += '\n \n ';
+ } ;
+__p += '\n \n \n
';
+
+}
+return __p
+};
+
+this["Formbuilder"]["templates"]["view/table_header"] = function(obj) {
+obj || (obj = {});
+var __t, __p = '', __e = _.escape;
+with (obj) {
+__p +=
+((__t = ( Formbuilder.templates['view/label']({rf: rf}) )) == null ? '' : __t) +
+'\n' +
+((__t = ( Formbuilder.templates['view/description']({rf: rf}) )) == null ? '' : __t);
+
+}
+return __p
+};
+
+this["Formbuilder"]["templates"]["view/table_total"] = function(obj) {
+obj || (obj = {});
+var __t, __p = '', __e = _.escape, __j = Array.prototype.join;
+function print() { __p += __j.call(arguments, '') }
+with (obj) {
+
+ if (rf.get('options.total_sequence')) { ;
+__p += '\n(Column Total) \n';
+ } ;
+
+
}
return __p
};
\ No newline at end of file
diff --git a/formbuilder.sublime-project b/formbuilder.sublime-project
deleted file mode 100644
index 8414ecbc..00000000
--- a/formbuilder.sublime-project
+++ /dev/null
@@ -1,20 +0,0 @@
-{
- "folders":
- [
- {
- "path": ".",
- "folder_exclude_patterns": ["bower_components", ".sass-cache", "css", "js", "node_modules"],
- "file_exclude_patterns": ["*.sublime-workspace", "formbuilder.js", "formbuilder.css", "formbuilder-min.js", "formbuilder-min.css", "templates/compiled.js"]
- }
- ],
-
- "settings":
- {
- // indentation
- "tab_size": 2,
- "translate_tabs_to_spaces": true,
- "trim_trailing_white_space_on_save": true,
- // ensure line endings is linux style (even when on Windows)
- "default_line_ending": "LF"
- }
-}
diff --git a/index.html b/index.html
index a65e6255..7f2ab6f0 100644
--- a/index.html
+++ b/index.html
@@ -1,93 +1,259 @@
- Form Builder
-
-
-
-
+
- .fb-main {
- background-color: #fff;
- border-radius: 5px;
- min-height: 600px;
- }
-
- input[type=text] {
- height: 26px;
- margin-bottom: 3px;
- }
-
- select {
- margin-bottom: 5px;
- font-size: 40px;
- }
-
-
-
-
+
+Log Payload
+
+
+
-
+
-
\ No newline at end of file
+