Skip to content

Commit

Permalink
Creating a limited JS file, removing file upload
Browse files Browse the repository at this point in the history
  • Loading branch information
moflo committed Apr 30, 2014
1 parent 266f6a0 commit 807f1e4
Show file tree
Hide file tree
Showing 8 changed files with 276 additions and 147 deletions.
11 changes: 11 additions & 0 deletions Gruntfile.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,16 @@ module.exports = (grunt) ->
'bower_components/backbone/backbone.js'
'bower_components/backbone-deep-model/src/deep-model.js'
]
limited:
files:
'<%= distFolder %>/formbuilder.js': '<%= compiledFolder %>/*.js'
'<%= vendorFolder %>/js/vendor_limited.js': [
'bower_components/ie8-node-enum/index.js'
'bower_components/jquery.scrollWindowTo/index.js'
'bower_components/underscore.mixin.deepExtend/index.js'
'bower_components/rivets/dist/rivets.js'
'bower_components/backbone-deep-model/src/deep-model.js'
]

cssmin:
dist:
Expand Down Expand Up @@ -109,5 +119,6 @@ module.exports = (grunt) ->


grunt.registerTask 'default', ALL_TASKS
grunt.registerTask 'limited', ['jst:all', 'coffee:all', 'concat:limited', 'stylus:all', 'clean:compiled']
grunt.registerTask 'dist', ['cssmin:dist', 'uglify:dist']
grunt.registerTask 'test', ['dist', 'karma']
21 changes: 6 additions & 15 deletions dist/formbuilder.js
Original file line number Diff line number Diff line change
Expand Up @@ -720,12 +720,7 @@
}).call(this);

(function() {
Formbuilder.registerField('file', {
order: 55,
view: "<input type='file' />",
edit: "",
addButton: "<span class=\"symbol\"><span class=\"fa fa-cloud-upload\"></span></span> File"
});


}).call(this);

Expand Down Expand Up @@ -883,9 +878,9 @@ var __t, __p = '', __e = _.escape;
with (obj) {
__p += '<label>\n <input type=\'checkbox\' data-rv-checked=\'model.' +
((__t = ( Formbuilder.options.mappings.REQUIRED )) == null ? '' : __t) +
'\' />\n Required\n</label>\n<label>\n <input type=\'checkbox\' data-rv-checked=\'model.' +
'\' />\n Required\n</label>\n<!-- label>\n <input type=\'checkbox\' data-rv-checked=\'model.' +
((__t = ( Formbuilder.options.mappings.ADMIN_ONLY )) == null ? '' : __t) +
'\' />\n Admin only\n</label>';
'\' />\n Admin only\n</label -->';

}
return __p
Expand Down Expand Up @@ -1047,7 +1042,7 @@ __p += '\n <a data-field-type="' +
((__t = ( f.addButton )) == null ? '' : __t) +
'\n </a>\n ';
}); ;
__p += '\n </div>\n\n <div class=\'section\'>\n ';
__p += '\n </div>\n\n <!--div class=\'section\'>\n ';
_.each(_.sortBy(Formbuilder.nonInputFields, 'order'), function(f){ ;
__p += '\n <a data-field-type="' +
((__t = ( f.field_type )) == null ? '' : __t) +
Expand All @@ -1057,7 +1052,7 @@ __p += '\n <a data-field-type="' +
((__t = ( f.addButton )) == null ? '' : __t) +
'\n </a>\n ';
}); ;
__p += '\n </div>\n </div>\n</div>';
__p += '\n </div -->\n </div>\n</div>';

}
return __p
Expand Down Expand Up @@ -1131,11 +1126,7 @@ this["Formbuilder"]["templates"]["view/base_non_input"] = function(obj) {
obj || (obj = {});
var __t, __p = '', __e = _.escape;
with (obj) {
__p += '<div class=\'subtemplate-wrapper\'>\n <div class=\'cover\'></div>\n ' +
((__t = ( Formbuilder.fields[rf.get(Formbuilder.options.mappings.FIELD_TYPE)].view({rf: rf}) )) == null ? '' : __t) +
'\n ' +
((__t = ( Formbuilder.templates['view/duplicate_remove']({rf: rf}) )) == null ? '' : __t) +
'\n</div>\n';
__p += '';

}
return __p
Expand Down
97 changes: 97 additions & 0 deletions index_limited.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
<!doctype html>
<html>
<head>
<title>Form Builder</title>
<meta name="description" content="">
<link rel="stylesheet" href="vendor/css/vendor.css" />
<link rel="stylesheet" href="dist/formbuilder.css" />
<style>
* {
box-sizing: border-box;
}

body {
background-color: #444;
font-family: sans-serif;
}

.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;
}
</style>
</head>
<body>
<div class='fb-main'></div>

<script src="http://cdnjs.cloudflare.com/ajax/libs/jquery/2.0.3/jquery.min.js"></script>
<script src="http://cdnjs.cloudflare.com/ajax/libs/jqueryui/1.10.3/jquery-ui.min.js"></script>
<script src="http://cdnjs.cloudflare.com/ajax/libs/underscore.js/1.5.2/underscore-min.js"></script>
<script src="http://cdnjs.cloudflare.com/ajax/libs/backbone.js/1.1.0/backbone-min.js"></script>
<script src="vendor/js/vendor_limited.js"></script>
<script src="dist/formbuilder.js"></script>

<script>
$(function(){
fb = new Formbuilder({
selector: '.fb-main',
bootstrapData: [
{
"label": "Do you have a website?",
"field_type": "website",
"required": false,
"field_options": {},
"cid": "c1"
},
{
"label": "Please enter your clearance number",
"field_type": "text",
"required": true,
"field_options": {},
"cid": "c6"
},
{
"label": "Security personnel #82?",
"field_type": "radio",
"required": true,
"field_options": {
"options": [{
"label": "Yes",
"checked": false
}, {
"label": "No",
"checked": false
}],
"include_other_option": true
},
"cid": "c10"
},
{
"label": "Medical history",
"field_type": "file",
"required": true,
"field_options": {},
"cid": "c14"
}
]
});

fb.on('save', function(payload){
console.log(payload);
})
});
</script>

</body>
</html>
13 changes: 0 additions & 13 deletions src/scripts/fields/file.coffee
Original file line number Diff line number Diff line change
@@ -1,13 +0,0 @@
Formbuilder.registerField 'file',

order: 55

view: """
<input type='file' />
"""

edit: ""

addButton: """
<span class="symbol"><span class="fa fa-cloud-upload"></span></span> File
"""
4 changes: 2 additions & 2 deletions src/templates/edit/checkboxes.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<input type='checkbox' data-rv-checked='model.<%= Formbuilder.options.mappings.REQUIRED %>' />
Required
</label>
<label>
<!-- label>
<input type='checkbox' data-rv-checked='model.<%= Formbuilder.options.mappings.ADMIN_ONLY %>' />
Admin only
</label>
</label -->
4 changes: 2 additions & 2 deletions src/templates/partials/add_field.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@
<% }); %>
</div>

<div class='section'>
<!--div class='section'>
<% _.each(_.sortBy(Formbuilder.nonInputFields, 'order'), function(f){ %>
<a data-field-type="<%= f.field_type %>" class="<%= Formbuilder.options.BUTTON_CLASS %>">
<%= f.addButton %>
</a>
<% }); %>
</div>
</div -->
</div>
</div>
5 changes: 0 additions & 5 deletions src/templates/view/base_non_input.html
Original file line number Diff line number Diff line change
@@ -1,5 +0,0 @@
<div class='subtemplate-wrapper'>
<div class='cover'></div>
<%= Formbuilder.fields[rf.get(Formbuilder.options.mappings.FIELD_TYPE)].view({rf: rf}) %>
<%= Formbuilder.templates['view/duplicate_remove']({rf: rf}) %>
</div>
Loading

0 comments on commit 807f1e4

Please sign in to comment.