Skip to content
Mamadou Sy edited this page Mar 25, 2016 · 2 revisions

<functions>

Proposals for 2.2.0

Enumerates AskiaScript functions that could be use everywhere in the current ADX.

<functions><![CDATA[
''' Get value of the property as number
''' @param {String} id Id of the property
''' @return {Number} Value of the property as number
Function GetPropNum(id As String) As Number
   Return CurrentADC.PropValue(id).ToNumber()
End Function

''' Get value of the property as rbg
''' @param {String} id Id of the property
''' @return {String} Value of the property to RGB
Function GetPropRGB(id As String) As string
   Return CurrentADC.PropValue(id).ToRGB()
End Function

''' Format CSS background gradient with all vendor-prefix
''' @param {String} firstColorId Id of the property that hold the first color
''' @param {String} secondaryColorId Id of the property that hold the secondary color
Function BackgroundGradient(firstColorId As String, secondaryColorId As String) As String
   Dim c1  = CurrentADC.PropValue(firstColorId).ToHexa()
   Dim c2  = CurrentADC.PropValue(secondaryColorId).ToHexa()
   Dim str = "background: " + c1  + "; /* Old browsers */"
   str = str + "\r\nbackground: -moz-linear-gradient(-45deg," + c1 + " 100%," + c2 + " 100%); /* FF3.6+ */"
   str = str + "\r\nbackground: -webkit-gradient(linear, left top, right bottom, color-stop(100%," + c1 + "), color-stop(100%," + c2 + ")); /* Chrome,Safari4+ */"
   str = str + "\r\nbackground: -webkit-linear-gradient(-45deg," + c1 + " 100%," + c2 +" 100%); /* Chrome10+,Safari5.1+ */"
   str = str + "\r\nbackground: -o-linear-gradient(-45deg," + c1 + " 100%," + c2 + " 100%); /* Opera 11.10+ */"
   str = str + "\r\nbackground: -ms-linear-gradient(-45deg," + c1 + " 100%," + c2 + " 100%); /* IE10+ */"
   str = str + "\r\nbackground: linear-gradient(-45deg, " + c1 + " 100%," + c2 + " 100%); /* W3C */"
   str = str + "\r\nfilter: progid:DXImageTransform.Microsoft.gradient( startColorstr='" + c1 + "', endColorstr='" + c2 + "',GradientType=1 ); /* IE6-9 fallback on horizontal gradient */"

   Return str
End Function
]]></functions>

Example usage in dynamic CSS content

#adc_{%= CurrentADC.InstanceId%} .item {
   color : rgb({%:= GetPropRGB("font-color")%});
   {%:= BackgroundGradient("color1", "color2") %}
}
#adc_{%= CurrentADC.InstanceId%} .item.selected {
   color : rgb({%:= GetPropRGB("font-color-selected")%});
   {%:= BackgroundGradient("color1-selected", "color2-selected") %}
}

Produce:

#adc_1 .item {
   color : rgb(0,0,0);
   background: #ffffff; /* Old browsers */
   background: -moz-linear-gradient(-45deg,#ffffff 100%,#dddddd 100%); /* FF3.6+ */
   background: -webkit-gradient(linear, left top, right bottom, color-stop(100%,#ffffff), color-stop(100%,#dddddd)); /* Chrome,Safari4+ */
   background: -webkit-linear-gradient(-45deg,#ffffff 100%,#dddddd 100%); /* Chrome10+,Safari5.1+ */
   background: -o-linear-gradient(-45deg,#ffffff 100%,#dddddd 100%); /* Opera 11.10+ */
   background: -ms-linear-gradient(-45deg,#ffffff 100%,#dddddd 100%); /* IE10+ */
   background: linear-gradient(-45deg, #ffffff 100%,#dddddd 100%); /* W3C */
   filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#ffffff', endColorstr='#dddddd',GradientType=1 ); /* IE6-9 fallback on horizontal gradient */
}
#adc_1 .item.selected {
   color : rgb(255,255,255);
   background: #0000ff; /* Old browsers */
   background: -moz-linear-gradient(-45deg,#0000ff 100%,#dddddd 100%); /* FF3.6+ */
   background: -webkit-gradient(linear, left top, right bottom, color-stop(100%,#0000ff), color-stop(100%,#dddddd)); /* Chrome,Safari4+ */
   background: -webkit-linear-gradient(-45deg,#0000ff 100%,#dddddd 100%); /* Chrome10+,Safari5.1+ */
   background: -o-linear-gradient(-45deg,#0000ff 100%,#dddddd 100%); /* Opera 11.10+ */
   background: -ms-linear-gradient(-45deg,#0000ff 100%,#dddddd 100%); /* IE10+ */
   background: linear-gradient(-45deg, #0000ff 100%,#dddddd 100%); /* W3C */
   filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#0000ff', endColorstr='#dddddd',GradientType=1 ); /* IE6-9 fallback on horizontal gradient */
}

<< Config – Properties | Master Page >>