diff options
Diffstat (limited to 'webapp/polls/templates/tags/structure.html')
-rw-r--r-- | webapp/polls/templates/tags/structure.html | 71 |
1 files changed, 71 insertions, 0 deletions
diff --git a/webapp/polls/templates/tags/structure.html b/webapp/polls/templates/tags/structure.html new file mode 100644 index 0000000..9b525b8 --- /dev/null +++ b/webapp/polls/templates/tags/structure.html @@ -0,0 +1,71 @@ +{% load i18n poll_tags %} + +<!-- Containers --> +<button id="WGroup_add" class="btn btn-primary"> + <i class="icon-plus-sign icon-white"></i> {% trans 'Agregar grupo' %} +</button> + +<div id="WGroupContainer"></div> + + +<!-- Mustache templates --> +{% include "mustache/group.html" %} + +{% include "mustache/field.html" %} + +{% include "mustache/option.html" %} + +{% include "mustache/option_default.html" %} + +{% include "mustache/option_image_upload.html" %} + +{% include "mustache/option_image_thumbnail.html" %} + +<!-- Global variables for dynamic_structure.js --> +<script type="text/javascript"> + + var groups = {{ groups|json }}, + WIDGET_TYPES = {{ WIDGET_TYPES|json }}, + WITH_OPTIONS = {{ WITH_OPTIONS|json }}, + WITH_IMAGES = {{ WITH_IMAGES|json }}, + OFFSET_OPTION_ID = {{ OFFSET_OPTION_ID|json }}, + IMAGE_OPTIONS_TMP_MEDIA_URL = {{ IMAGE_OPTIONS_TMP_MEDIA_URL|json }}, + POLL_ID = {{ POLL_ID|json }}; + +</script> + + +<!-- Dynamic structure methods --> +<script src="{{ STATIC_URL }}js/dynamic_structure.js"></script> + + +<!-- Dynamic structure initialization --> +<script type="text/javascript"> + (function($){ + + $(document).ready(function() { + + // Preparing TEMPLATES + $('script[type="text/x-mustache-template"]').each(function(i, obj){ + TEMPLATES[$(obj).attr('name')] = $(obj).text(); + }); + + // Get group container widget + container = $('#WGroupContainer'); + + // Render of groups + $.each(groups, factoryGroup); + + // Bind group add event + $("#WGroup_add").on('click', function(event){ + event.preventDefault(); + + // TODO: Que la estructura de grupo vacio la de un metodo. + var next_group_order = $('.group').length; + factoryGroup(next_group_order, {"name": '', "fields": []}) + }); + + }); + + })(jQuery); +</script>
\ No newline at end of file |