Logic Machine Forum
Auto opening widget, Changing camera view in 1 small widget - Printable Version

+- Logic Machine Forum (https://forum.logicmachine.net)
+-- Forum: LogicMachine eco-system (https://forum.logicmachine.net/forumdisplay.php?fid=1)
+--- Forum: Visualization (https://forum.logicmachine.net/forumdisplay.php?fid=9)
+--- Thread: Auto opening widget, Changing camera view in 1 small widget (/showthread.php?tid=195)

Pages: 1 2


RE: Auto opening widget, Changing camera view in 1 small widget - buuuudzik - 24.01.2017

(12.09.2016, 15:32)Erwin van der Zwart Wrote: Hi Buuuudzik,

Try this:


Code:
$(function(){
 
 var openwidget = false;
 
 function openWidget(){  
 if (currentPlanId == 4){
     if (openwidget == false){
         openwidget = true;  
        // Open widget
     $("#widget-5").removeClass("hide");
         // Position widget (absolute positioned)
     document.getElementById("widget-5").style.top = "150px";
     document.getElementById("widget-5").style.left = "150px";
     document.getElementById("widget-5").style.width = "1024px";
     document.getElementById("widget-5").style.height = "600px";
     }
 } else {
     // Condition to hide widget
     $("#widget-5").addClass("hide");
     openwidget = false;
   }
 }

 // Initial execution if needed
 openWidget();

 // Add event listener to control elements only for checking on each user input
 $('.item-control').on( "click", function() {
     openWidget();
 });
 
});

BR,

Erwin van der Zwart


I found a solution for an opening a widget via js which works as manually opened:
Code:
$("#widget-58").css('display', 'block')

And this is for closing:
Code:
$("#widget-58").css('display', "none")
But maybe somebody knows how can I prepare the event of changing currentPlanId for triggering the function? I think this event could be very useful for everyoneWink


RE: Auto opening widget, Changing camera view in 1 small widget - Erwin van der Zwart - 24.01.2017

Hi Buuuudzik,

It is as far as i know not possible to add a event handler to the plan ID, but you could solve it like this:

Code:
var planID = currentPlanId;
var PlanIDCheck = setInterval(
function(){
 if (planID != currentPlanId){
   planID = currentPlanId;
     alert("Plan Changed");
   // Put here your additional actions
 }
}, 1000);

BR,

Erwin


RE: Auto opening widget, Changing camera view in 1 small widget - buuuudzik - 24.01.2017

Thanks Erwin I thinked about similar solution but this works perfect with interval 500msWink

And if it is about auto opening widgets on first opening script must remove class '.hide' and change display to 'block' and after that it only must change this second attribute.

But I see a problem with this first opening widget, because when I use this two functions (it is not important which is first) the first opening is a bug(widget is very big and not in a right position on a screen). But I will check this tommorrowWink


RE: Auto opening widget, Changing camera view in 1 small widget - buuuudzik - 26.01.2017

I found the solution for autoopening widgets.

For properly open widget:

1) If this is before using any widget you should give proper style to class 'widgets' e.g.:
Code:
$('.widgets').css({'width': '720px', 'height': '1280px', 'margin-left': '-360px', 'margin-top': '-640px', 'transform': 'matrix(0.37109, 0, 0, 0.37109, 0, 0)'})

2) Before opening widget it should be appended to div with class ('.widgets'):
Code:
$('#widget-176').appendTo('.widgets')

3) Now widget can be opened(remove class 'hide' and set attribute 'display' to 'block'):
Code:
$('#widget-176').removeClass('hide').css("display", "block"); }


It works almost fine but there is a problem when I change the screen resolution(e.g. change a client from PC to iPhone). I see that attribute 'transform' from 1) step should be variable and should be calculated for current resolution not constant like I've prepared.

Maybe you admin or Erwin could advice some solution?


RE: Auto opening widget, Changing camera view in 1 small widget - Erwin van der Zwart - 26.01.2017

Hi Buuuuudzik,

Use this to get client resolution or calculate your widget by using ...% instead of ...px.

Code:
$(window).height();   // returns height of browser viewport
$(document).height(); // returns height of HTML document
$(window).width();    // returns width of browser viewport
$(document).width();  // returns width of HTML document

BR,

Erwin


RE: Auto opening widget, Changing camera view in 1 small widget - buuuudzik - 26.01.2017

Thanks Erwin but unfortunately these functions gives everytime my screen resolution but I must know what is real resolution of visualisation. I see that 100% solution is:
Code:
$('#layout-178').css('transform')

This gives exactly value which I am looking for:
Code:
"matrix(0.40937, 0, 0, 0.40937, 0, 0)"

but maybe there is some more universal object than '#layout-178' but I am checking this nowWink

The best solution is:
Code:
$('.plan-background').css('transform')



RE: Auto opening widget, Changing camera view in 1 small widget - josep - 19.06.2017

Hi Erwin,
I try to use the jump to page script but doesn't work. I make a resident script with 0/0/33 adress and I run it once, but when I send a 2 byte unsigned value with page ID number nothing happens, what am I doing wrong? THX