From ea95ba0ec758714006d1b85104e31ef3697a4164 Mon Sep 17 00:00:00 2001 From: Ezequiel Bergamaschi Date: Sun, 2 Feb 2014 23:34:40 -0300 Subject: [PATCH] extract method --- .../src/main/webapp/js/buttonActions.js | 40 +++---------------- .../src/main/webapp/js/labelActions.js | 24 +++++++++++ 2 files changed, 29 insertions(+), 35 deletions(-) diff --git a/wise-webapp/src/main/webapp/js/buttonActions.js b/wise-webapp/src/main/webapp/js/buttonActions.js index 559ce66a..bbb0ad8e 100644 --- a/wise-webapp/src/main/webapp/js/buttonActions.js +++ b/wise-webapp/src/main/webapp/js/buttonActions.js @@ -35,35 +35,15 @@ $(function () { }); if (labels) { - var labelList = $("#labelList"); - - var defaultValue = labelList.find("li[id=\"createLabelBtn\"]"); - //clear dropdown... - labelList.find('li').remove(); - //append items to dropdown - $.each(labels, function(index, value) { - labelList.append( - //aca jay codigo repetido - $('
  • ').attr('value', value.id).attr('color', value.color) - .append('' + - "
    " + - "
    " + value.title + "
    " + - - '
    ')); - }); - - //add the defaultValue - labelList.append('
  • ') - labelList.append(defaultValue); - - var mapIds = $('#mindmapListTable').dataTableExt.getSelectedMapsIds(); + prepareLabelList(labels); $(document).one('click', '.chooseLabel', function () { - var labelId = $(this).attr('value'); - var labelName = $(this).text(); - var labelColor = $(this).attr('color'); + var mapIds = $('#mindmapListTable').dataTableExt.getSelectedMapsIds(); if (mapIds.length > 0) { + var labelId = $(this).attr('value'); + var labelName = $(this).text(); + var labelColor = $(this).attr('color'); jQuery.ajax("c/restful/labels/maps?ids=" + jQuery.makeArray(mapIds).join(','), { type:'POST', //dataType: "json", @@ -215,16 +195,6 @@ $(function () { event.preventDefault(); }); - $("#parentLblCheckbox").click( - function () { - if ($(this).is(":checked")) { - $("#dropdownLabel").prop("disabled", false); - } else { - $("#dropdownLabel").prop("disabled", true); - } - } - ); - $(document).on('click', "#deleteLabelBtn", function() { var me = $(this); $("#delete-label-dialog-modal").dialogForm({ diff --git a/wise-webapp/src/main/webapp/js/labelActions.js b/wise-webapp/src/main/webapp/js/labelActions.js index 4d6b0b69..ec826923 100644 --- a/wise-webapp/src/main/webapp/js/labelActions.js +++ b/wise-webapp/src/main/webapp/js/labelActions.js @@ -65,3 +65,27 @@ function tagMindmaps(id, labelName, labelColor) { } } } + +function prepareLabelList(labels) { + var labelList = $("#labelList"); + var defaultValue = labelList.find("li[id=\"createLabelBtn\"]"); + + //clear dropdown... + labelList.find('li').remove(); + + //append items to dropdown + $.each(labels, function(index, value) { + labelList.append( + $('
  • ').attr('value', value.id).attr('color', value.color) + .append( + '' + + "
    " + + "
    " + value.title + "
    " + + '
    ') + ); + }); + + //add the defaultValue + labelList.append('
  • ') + labelList.append(defaultValue); +}