Commit 58d982d1 authored by jan.koester's avatar jan.koester
Browse files

llabel

parent fa5d8b52
Loading
Loading
Loading
Loading
+22 −0
Changes for editor/widgets/button/button.cpp: 22 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -418,6 +418,7 @@ extern "C" {
                element->SetAttribute("instance_id", getInstanceId().c_str());
                element->SetAttribute("type_id", getTypeId().c_str());
                element->SetAttribute("label", label.c_str());
                element->SetAttribute("hide_label", hideLabel ? "true" : "false");
                element->SetAttribute("link_url", linkUrl.c_str());
                element->SetAttribute("link_type", linkType.c_str());
                element->SetAttribute("section_id", sectionId.c_str());
@@ -475,6 +476,8 @@ extern "C" {
                const char* val = nullptr;

                val = xml_data->Attribute("label");            if (val) label = val;
                val = xml_data->Attribute("hide_label");
                if (val) hideLabel = (strcmp(val, "true") == 0);
                val = xml_data->Attribute("link_url");         if (val) linkUrl = val;
                val = xml_data->Attribute("link_type");        if (val) linkType = val;
                val = xml_data->Attribute("section_id");       if (val) sectionId = val;
@@ -553,6 +556,7 @@ extern "C" {
            std::string toPropertiesJson() {
                json_object *obj = json_object_new_object();
                json_object_object_add(obj, "label", json_object_new_string(label.c_str()));
                json_object_object_add(obj, "hide_label", json_object_new_boolean(hideLabel));
                json_object_object_add(obj, "link_url", json_object_new_string(linkUrl.c_str()));
                json_object_object_add(obj, "link_type", json_object_new_string(linkType.c_str()));
                json_object_object_add(obj, "section_id", json_object_new_string(sectionId.c_str()));
@@ -603,6 +607,14 @@ extern "C" {
                if (json_object_object_get_ex(obj, "label", &val_obj)) {
                    val = json_object_get_string(val_obj); if (val && val[0]) label = val;
                }
                if (json_object_object_get_ex(obj, "hide_label", &val_obj)) {
                    if (json_object_is_type(val_obj, json_type_string)) {
                        const char *s = json_object_get_string(val_obj);
                        hideLabel = (s && (strcmp(s, "true") == 0 || strcmp(s, "1") == 0));
                    } else {
                        hideLabel = json_object_get_boolean(val_obj);
                    }
                }
                if (json_object_object_get_ex(obj, "link_url", &val_obj)) {
                    val = json_object_get_string(val_obj); if (val && val[0]) linkUrl = val;
                }
@@ -823,7 +835,17 @@ extern "C" {

                a.setAttribute("style", style.c_str());
                a.setAttribute("class", responsiveClass.c_str());
                if (hideLabel) {
                    a.setAttribute("aria-label", label.c_str());
                    libhtmlpp::HtmlElement labelSpan("span");
                    labelSpan.setAttribute("style",
                        "position: absolute; width: 1px; height: 1px; overflow: hidden; "
                        "clip: rect(0,0,0,0); white-space: nowrap;");
                    labelSpan.appendChild(libhtmlpp::TextElement(label.c_str()));
                    a.appendChild(labelSpan);
                } else {
                    a.appendChild(libhtmlpp::TextElement(label.c_str()));
                }

                // Mobile responsive overrides via media query
                std::string mobileCSS;