tset, button change color with parent element

This commit is contained in:
Tim Krehan 2019-05-26 18:49:12 +02:00
parent 6416e8011e
commit 0ac5bffcd9
2 changed files with 9 additions and 3 deletions

View file

@ -34,14 +34,14 @@
} }
print_r("<div class='list-row $div_item_row_classes $div_item_row_color_classes'>"); print_r("<div class='list-row $div_item_row_classes $div_item_row_color_classes'>");
print_r("<div class='$div_item_checkbox_classes'><input type='checkbox' class='$input_item_checkbox_classes' data-color='$color_theme' data-id='$item->ID' $checked></div>"); print_r("<div class='$div_item_checkbox_classes'><input type='checkbox' class='$input_item_checkbox_classes' data-buttoncolor='$button_theme' data-color='$color_theme' data-id='$item->ID' $checked></div>");
print_r("<div class='$div_item_quantity_classes'>$item->Anzahl $item->Einheit</div>"); print_r("<div class='$div_item_quantity_classes'>$item->Anzahl $item->Einheit</div>");
print_r("<div class='$div_item_name_classes'>$item->Name</div>"); print_r("<div class='$div_item_name_classes'>$item->Name</div>");
print_r("<div class='$div_item_menu dropdown'>"); print_r("<div class='$div_item_menu dropdown'>");
print_r("<button type='button' class='btn $button_theme pt-0 pb-0' id='dropdownMenuButtonDataID-" . $item->ID . "' data-toggle='dropdown' aria-haspopup='true' aria-expanded='false'>"); print_r("<button type='button' class='dropdown-menu-button btn $button_theme pt-0 pb-0' id='dropdown-menu-button-dataID-" . $item->ID . "' data-toggle='dropdown' aria-haspopup='true' aria-expanded='false'>");
print_r("<i class='fas fa-angle-down'></i>"); print_r("<i class='fas fa-angle-down'></i>");
print_r("</button>"); print_r("</button>");
print_r("<div class='dropdown-menu' aria-labelledby='dropdownMenuButtonDataID-" . $item->ID . "'>"); print_r("<div class='dropdown-menu' aria-labelledby='dropdown-menu-button-dataID-" . $item->ID . "'>");
print_r("<button type='button' class='dropdown-item'><i class='fas fa-edit'></i> Bearbeiten</button>"); print_r("<button type='button' class='dropdown-item'><i class='fas fa-edit'></i> Bearbeiten</button>");
print_r("<button type='button' class='dropdown-item'><i class='fas fa-trash-alt'></i> Löschen</button>"); print_r("<button type='button' class='dropdown-item'><i class='fas fa-trash-alt'></i> Löschen</button>");
print_r("</div>"); print_r("</div>");

View file

@ -49,15 +49,21 @@ function checkItem() {
success: function () { success: function () {
var dataIdSelector = (`[data-id='${dataId}']`); var dataIdSelector = (`[data-id='${dataId}']`);
var color = $(dataIdSelector).data("color"); var color = $(dataIdSelector).data("color");
var buttoncolor = $(dataIdSelector).data("buttoncolor");
$(dataIdSelector).parent().parent().removeClass("bg-danger"); $(dataIdSelector).parent().parent().removeClass("bg-danger");
$(dataIdSelector).parent().parent().find(".dropdown-menu-button").removeClass("btn-danger");
if($(dataIdSelector).prop("checked")){ if($(dataIdSelector).prop("checked")){
$(dataIdSelector).parent().parent().removeClass(color); $(dataIdSelector).parent().parent().removeClass(color);
$(dataIdSelector).parent().parent().addClass("bg-success"); $(dataIdSelector).parent().parent().addClass("bg-success");
$(dataIdSelector).parent().parent().find(".dropdown-menu-button").removeClass(buttoncolor);
$(dataIdSelector).parent().parent().find(".dropdown-menu-button").addClass("btn-success");
} }
else{ else{
$(dataIdSelector).parent().parent().removeClass("bg-success"); $(dataIdSelector).parent().parent().removeClass("bg-success");
$(dataIdSelector).parent().parent().addClass(color); $(dataIdSelector).parent().parent().addClass(color);
$(dataIdSelector).parent().parent().find(".dropdown-menu-button").addClass(buttoncolor);
$(dataIdSelector).parent().parent().find(".dropdown-menu-button").removeClass("btn-success");
} }
}, },
error: function () { error: function () {