Skip to content

Commit

Permalink
Merge pull request #159 from chinyihan/title_link
Browse files Browse the repository at this point in the history
Added title_link field in Text plugin
  • Loading branch information
nicolaisi authored Jun 19, 2024
2 parents a11554e + e590e7d commit c19012d
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 2 deletions.
18 changes: 16 additions & 2 deletions blueprint/designer.html
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@
{% end %}

{% if data['style'][key]['type'] == "text" %}
<div id='{{ key }}' class='varbox' style='position: absolute; top: {{ data['style'][key]['top'] }}; left:{{
<div id='{{ key }}' class='varbox' data-title-link="{{ data['style'][key]['div']['data-title-link'] }}" style='position: absolute; top: {{ data['style'][key]['top'] }}; left:{{
data['style'][key]['left'] }}; width:{{ data['style'][key]['width'] }}px;
height:{{ data['style'][key]['height'] }}px; font-size: {{ data['style'][key]['div']['font-size'] }}; font-weight: {{ data['style'][key]['div']['font-weight'] }};' data-type='text'>
<span class='text_name'>{{ data['style'][key]['div']['text-name'] }}</span>
Expand Down Expand Up @@ -126,7 +126,7 @@
{% end %}

{% if data['style'][key]['type'] == "virtual" %}
<div id='{{ key }}' class='varbox' data-type="{{ data['style'][key]['type'] }}" data-virtual-id="{{ data['style'][key]['div']['data-virtual-id'] }}" data-decimal-numbers="{{ data['style'][key]['div']['data-decimal-numbers'] }}" data-smaller-than="{{ data['style'][key]['div']['data-smaller-than'] }}" data-larger-than="{{ data['style'][key]['div']['data-larger-than'] }}" style='position: absolute; top: {{ data['style'][key]['top'] }};
<div id='{{ key }}' class='varbox' data-type="{{ data['style'][key]['type'] }}" data-virtual-id="{{ data['style'][key]['div']['data-virtual-id'] }}" data-decimal-numbers="{{ data['style'][key]['div']['data-decimal-numbers'] }}" data-smaller-than="{{ data['style'][key]['div']['data-smaller-than'] }}" data-larger-than="{{ data['style'][key]['div']['data-larger-than'] }}" data-exp="{{ data['style'][key]['div']['data-exp'] }}" data-link-adei="{{ data['style'][key]['div']['data-link-adei'] }}" data-trend="{{ data['style'][key]['div']['data-trend'] }}" style='position: absolute; top: {{ data['style'][key]['top'] }};
left:{{ data['style'][key]['left'] }}; width:{{ data['style'][key]['width'] }}px; height:{{ data['style'][key]['height'] }}px; font-size: {{ data['style'][key]['div']['font-size'] }}; font-weight: {{ data['style'][key]['div']['font-weight'] }};'>
<span class='text_name'>{{ data['style'][key]['div']['text-name'] }}</span> <span class='value'>XXX.XX</span> <span class='unit_name'>{{ data['style'][key]['div']['unit-name'] }}</span>
</div>
Expand Down Expand Up @@ -1479,6 +1479,11 @@
return params[item] = largerThan || "";
}

function getTitleLink(element_id, item) {
var titleLink = $("#" + element_id).attr("data-title-link");
return params[item] = titleLink || "";
}

// Helper function: changes the font_weight value from numeric to string
function interpretFontWeight(font_weight_value) {
switch (font_weight_value) {
Expand Down Expand Up @@ -1543,6 +1548,8 @@
params[item] = getIntegerToString(element_id, item);
} else if (item_array[2] == "icon_type") {
params[item] = getIconType(element_id, item);
} else if (item_array[2] == "title_link") {
params[item] = getTitleLink(element_id, item);
} else {
if (item_array[item_array.length - 1] == "nodata") {
params[item] = getElementStyle(element_id, item, item_array);
Expand Down Expand Up @@ -1624,6 +1631,10 @@
$("#" + element_id).attr('data-trend', params[item]);
}

function updateTitleLink(item, element_id) {
$("#" + element_id).attr('data-title-link', params[item]);
}

// Helper Function: updates the css style properties
function updateElementStyle(item, element_id, css_property) {
$("#" + element_id).css(css_property, params[item]);
Expand Down Expand Up @@ -1688,6 +1699,9 @@
case "trend":
updateTrend(item, element_id);
break;
case "title_link":
updateTitleLink(item, element_id);
break;
default:
updateElementStyle(item, element_id, css_property);
break;
Expand Down
5 changes: 5 additions & 0 deletions typedef/text.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@
"type": "string"
"optional": "No"
"data": "No"
"title_link":
"value": ""
"type": "string"
"optional": "Yes"
"data": "Yes"
"font_size":
"value": ""
"type": "string"
Expand Down

0 comments on commit c19012d

Please sign in to comment.