diff --git a/js/guimanager.js b/js/guimanager.js new file mode 100644 index 0000000..bdfd9d2 --- /dev/null +++ b/js/guimanager.js @@ -0,0 +1,123 @@ +/** + * + */ + + + + $(document).ready(function(){ + grammarconditions=0 + var aggettivoJson=null + $.getJSON("aggettivo.json", function(aggettivo){ + //var keys = Object.values(aggettivo.filtri["Con oggetto indiretto"]); + //alert(keys); + aggettivoJson=aggettivo + }).fail(function(){ + console.log("An error has occurred."); + }); + + $('.tabs__menu-item').on('click', function() { + $(this).addClass('bg-white').addClass('red'); + $(this).siblings().removeClass('bg-white').removeClass('red'); + }); + + jQuery(document).delegate('a.add-record', 'click', function(e) { + e.preventDefault(); + var content = jQuery('#categoriagrammaticale div'), + size = jQuery('#condizioni >div').length + 1, + element = null, + element = content.clone(); + //alert(size); + element.attr('id', 'cg-'+size); + //element.attr('class', "stripe-dark") + //element.find('.delete-record').attr('data-id', size); + element.appendTo('#condizioni'); + element.find('.sn').html(size); + grammarconditions=grammarconditions+1 + + if (size==1) + jQuery('#grammarbutton').attr('style', "display:block;") + }); + + jQuery(document).delegate('a.add-record-sint', 'click', function(e) { + e.preventDefault(); + var content = jQuery('#tiposintattico div'), + size = jQuery('#condizioni >div').length + 1, + element = null, + element = content.clone(); + element.attr('id', 'ts-'+size); + //element.attr('class', "stripe-dark") + //element.find('.delete-record').attr('data-id', size); + element.appendTo('#condizioni'); + element.find('.sn').html(size); + if (size==1) + jQuery('#grammarbutton').attr('style', "display:block;") + }); + + + jQuery(document).delegate('select.catgram', 'change', function(e) { + e.preventDefault(); + //alert ($('#types').find(":selected").val()) + alert ($(this).closest('div').attr('id')) + + containerid='dettaglio_'+$(this).closest('div').attr('id') + //if ($('#types').find(":selected").val()=='verbovolgare'){ + if ($(this).val()=='verbovolgare'){ + //alert($('#types').find(":selected").val()); + var content = jQuery('#categoriaverbo >div'), + size = jQuery('#dettaglifiltri').length + 1, + element = null, + element = content.clone(); + + } + if ($(this).val()=='sostantivovolgare'){ + //alert($('#types').find(":selected").val()); + var content = jQuery('#categoriasostantivo >div'), + size = jQuery('#dettaglifiltri').length + 1, + element = null, + element = content.clone(); + } + if ($(this).val()=='aggettivovolgare'){ + var keys = Object.keys(aggettivoJson.filtri); + alert(keys) + } + element.attr('style',"display: block;") + //element.appendTo('#dettaglifiltri'); + + var test=jQuery('#'+containerid) + test.remove() + + + element.appendTo('#dettaglifiltri'); + var container = jQuery('#dettaglifiltri'); + container.attr('id', containerid); + var divdf = jQuery('#divdettaglifiltri >div'), + detelement = null, + detelement = divdf.clone(); + detelement.attr('id','dettaglifiltri') + detelement.appendTo("#query") + element.find('.sn').html(size); + + }); + + + jQuery(document).delegate('input.delete-record', 'click', function(e) { + e.preventDefault(); + var didConfirm = confirm("Sei sicuro di voler eliminare la condizione?"); + if (didConfirm == true) { + var id = jQuery(this).attr('data-id'); + var targetDiv = jQuery(this).attr('targetDiv'); + jQuery('#rec-' + id).remove(); + + if (jQuery('#condizioni >tbody >tr').length==0) + jQuery('#grammarbutton').attr('style', "display:none;") + //regnerate index number on table + $('#condizioni_body tr').each(function(index){ + $(this).find('span.sn').html(index+1); + + }); + return true; + } else { + return false; + } +}); + }); \ No newline at end of file