Did concentrate to IconMobile now.
Obviously this would be the simplest option (the Spiderbasic way) but it do not work:
Code: Select all
; Create the icon and store its ID
IconMobile(1, "fa-fighter-jet", #PB_Mobile_Left)
SetMobileAttribute(1, "size", "35px") ; Set the size attribute
Anyway when we use different icons we can use this approach:
Code: Select all
IconMobile(1, "fa-fighter-jet", #PB_Mobile_Left)
; Find the icon by its icon attribute and set size
! var icon = document.querySelector('ons-icon[icon="fa-fighter-jet"]');
! if (icon) icon.setAttribute('size', '35px');
! if (icon) icon.setAttribute('spin','');
! if (icon) icon.setAttribute('style', "color:red;");
If you have multiple the same name then just the last one:
Code: Select all
IconMobile(1, "fa-fighter-jet", #PB_Mobile_Left)
; Get all md-face icons and modify the last one added (index -1 means last)
! var icons = document.querySelectorAll('ons-icon[icon="fa-fighter-jet"]');
! if (icons.length > 0) icons[icons.length - 1].setAttribute('size', '35px');
Or if you want cleaner code using event handler
Code: Select all
Procedure InitUI()
! var icon = document.querySelector('ons-icon[icon="fa-fighter-jet"]');
! if (icon) icon.setAttribute('size', '35px');
EndProcedure
If ContainerMobile(#PB_Any, #PB_Mobile_Page)
ListMobile(0)
If AddListMobileItem(0, "", #PB_Mobile_Container)
IconMobile(1, "fa-fighter-jet", #PB_Mobile_Left)
If ContainerMobile(#PB_Any, #PB_Mobile_Section, "", "")
TextMobile(#PB_Any, "Nice fighterjet", #PB_Mobile_Left)
HtmlMobile("<span style='font-size:0.9em; color:#999;'>On the Internet</span>")
CloseMobileContainer()
EndIf
CloseMobileContainer()
EndIf
CloseMobileContainer()
EndIf
; Call after UI creation
InitUI()
And if you have timing requirements:
Code: Select all
If ContainerMobile(#PB_Any, #PB_Mobile_Page)
ListMobile(0)
If AddListMobileItem(0, "", #PB_Mobile_Container)
IconMobile(1, "fa-fighter-jet", #PB_Mobile_Left)
; Use JavaScript setTimeout to delay execution
! setTimeout(function() {
! var icon = document.querySelector('ons-icon[icon="fa-fighter-jet"]');
! if (icon) icon.setAttribute('size', '35px');
! }, 2000);
If ContainerMobile(#PB_Any, #PB_Mobile_Section, "", "")
TextMobile(#PB_Any, "Nice fighterjet", #PB_Mobile_Left)
HtmlMobile("<span style='font-size:0.9em; color:#999;'>On the Internet</span>")
CloseMobileContainer()
EndIf
CloseMobileContainer()
EndIf
CloseMobileContainer()
EndIf
And if you need click event and some animation:
Code: Select all
Enumeration
#MyList
EndEnumeration
If ContainerMobile(#PB_Any, #PB_Mobile_Page)
ListMobile(#MyList)
If AddListMobileItem(#MyList, "", #PB_Mobile_Container | #PB_Mobile_Tappable)
IconMobile(1, "md-thumb-up", #PB_Mobile_Left)
! setTimeout(function() {
! var icon = document.querySelector('ons-icon[icon="md-thumb-up"]');
! if (icon) icon.setAttribute('size', '35px');
! }, 100);
; Add CSS for click animation
! var style = document.createElement('style');
! style.textContent = '@keyframes clickBounce { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.5); } }';
! document.head.appendChild(style);
If ContainerMobile(#PB_Any, #PB_Mobile_Section, "", "")
TextMobile(#PB_Any, "I like Spiderbasic", #PB_Mobile_Left)
HtmlMobile("<span style='font-size:0.9em; color:#999;'>Tap to like</span>")
CloseMobileContainer()
EndIf
CloseMobileContainer()
EndIf
CloseMobileContainer()
EndIf
Procedure MobileEvents()
Select EventMobile()
Case #MyList
; Animate icon on click
! var icon = document.querySelector('ons-icon[icon="md-thumb-up"]');
! if (icon) {
! icon.style.animation = 'none';
! setTimeout(function() {
! icon.style.animation = 'clickBounce 0.5s ease';
! }, 10);
! }
EndSelect
EndProcedure
BindEvent(#PB_Event_Mobile, @MobileEvents())