mirror of
https://bitbucket.org/wisemapping/wisemapping-open-source.git
synced 2024-09-12 07:10:07 +02:00
extract method
This commit is contained in:
parent
3cf726f928
commit
ea95ba0ec7
@ -35,35 +35,15 @@ $(function () {
|
|||||||
});
|
});
|
||||||
|
|
||||||
if (labels) {
|
if (labels) {
|
||||||
var labelList = $("#labelList");
|
prepareLabelList(labels);
|
||||||
|
|
||||||
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();
|
|
||||||
|
|
||||||
$(document).one('click', '.chooseLabel',
|
$(document).one('click', '.chooseLabel',
|
||||||
function () {
|
function () {
|
||||||
var labelId = $(this).attr('value');
|
var mapIds = $('#mindmapListTable').dataTableExt.getSelectedMapsIds();
|
||||||
var labelName = $(this).text();
|
|
||||||
var labelColor = $(this).attr('color');
|
|
||||||
if (mapIds.length > 0) {
|
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(','), {
|
jQuery.ajax("c/restful/labels/maps?ids=" + jQuery.makeArray(mapIds).join(','), {
|
||||||
type:'POST',
|
type:'POST',
|
||||||
//dataType: "json",
|
//dataType: "json",
|
||||||
@ -215,16 +195,6 @@ $(function () {
|
|||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
});
|
});
|
||||||
|
|
||||||
$("#parentLblCheckbox").click(
|
|
||||||
function () {
|
|
||||||
if ($(this).is(":checked")) {
|
|
||||||
$("#dropdownLabel").prop("disabled", false);
|
|
||||||
} else {
|
|
||||||
$("#dropdownLabel").prop("disabled", true);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
);
|
|
||||||
|
|
||||||
$(document).on('click', "#deleteLabelBtn", function() {
|
$(document).on('click', "#deleteLabelBtn", function() {
|
||||||
var me = $(this);
|
var me = $(this);
|
||||||
$("#delete-label-dialog-modal").dialogForm({
|
$("#delete-label-dialog-modal").dialogForm({
|
||||||
|
@ -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);
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user