extract method

This commit is contained in:
Ezequiel Bergamaschi 2014-02-02 23:34:40 -03:00 committed by Ezequiel Bergamaschi
parent 3cf726f928
commit ea95ba0ec7
2 changed files with 29 additions and 35 deletions

View File

@ -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
$('<li class="chooseLabel"></li>').attr('value', value.id).attr('color', value.color)
.append('<a href="#" onclick="return false">' +
"<div class='labelColor' style='background: " + value.color + "'></div>" +
"<div class='labelName'>" + value.title + "</div>" +
'</a>'));
});
//add the defaultValue
labelList.append('<li><div class="listSeparator"></div></li>')
labelList.append(defaultValue);
var mapIds = $('#mindmapListTable').dataTableExt.getSelectedMapsIds();
prepareLabelList(labels);
$(document).one('click', '.chooseLabel',
function () {
var mapIds = $('#mindmapListTable').dataTableExt.getSelectedMapsIds();
if (mapIds.length > 0) {
var labelId = $(this).attr('value');
var labelName = $(this).text();
var labelColor = $(this).attr('color');
if (mapIds.length > 0) {
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({

View File

@ -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(
$('<li class="chooseLabel"></li>').attr('value', value.id).attr('color', value.color)
.append(
'<a href="#" onclick="return false">' +
"<div class='labelColor' style='background: " + value.color + "'></div>" +
"<div class='labelName'>" + value.title + "</div>" +
'</a>')
);
});
//add the defaultValue
labelList.append('<li><div class="listSeparator"></div></li>')
labelList.append(defaultValue);
}