为什么设置然后停靠/取消停靠会破坏此 Win 7 桌面小工具?

发布于 2024-12-09 15:22:59 字数 2189 浏览 0 评论 0原文

我已将范围缩小到点击设置,然后取消或确定(尚未处理设置事件的代码),然后尝试点击停靠按钮,可预见地杀死小工具控件。到目前为止,我已经尝试了评论中的所有建议,包括设置我感觉会完全破坏事情的课程。

真正困扰我的是,无论输入 endTransition 方法的参数如何,或者 end 和 beginTrans 方法是否存在,它的行为方式都是相同的。转换绝对不需要整整 5 秒。之前设置为1。还是没有区别。我在文档中找不到关于这些过渡类型的任何内容。

HTML 文件:

<!doctype html>

<html xmlns="http://www.w3.org/1999/xhtml">

<head>
    <meta http-equiv="Content-Type" content="text/html; charset=Unicode" />
    <title>Time Tracker Gadget</title>
    <link type="text/css" rel="stylesheet" media="screen" href="css/main.css" />
</head>

<body id="gadget">

<!-- pure HTML here, no linked scripts, inline JS, or styles -->

<script type="text/jscript" src="js/main.js"></script>

</body>

</html>

JS 文件:

System.Gadget.settingsUI = "settings.html";

var docked = {width:"161px", height:"110px"},
undocked = {width:"295px", height:"390px"},
gadgetEl = document.getElementById('gadget'),

addStyles = function(el,newStyles){
    var elStyle = el.style;
    for(var x in newStyles){ elStyle[x] = newStyles[x]; }
},

swapDockStates = function(){

    System.Gadget.beginTransition();

    if(System.Gadget.docked){
        addStyles(gadgetEl,undocked);
    }
    else {
        addStyles(gadgetEl,docked);
    }

    System.Gadget.endTransition(System.Gadget.TransitionType.morph, 5);

};

System.Gadget.onDock = swapDockStates;
System.Gadget.onUndock = swapDockStates;

XML 文件:

<?xml version="1.0" encoding="utf-8" ?>
<gadget>
  <name>BigTime Gadget</name>
  <version>1.0.0.0</version>
  <author name="BigTime Software">
    <info url="www.bigtime.net" />
  </author>
  <copyright>&#169; BigTime Software Inc.</copyright>
  <description>Time tracking gadget</description>
  <hosts>
    <host name="sidebar">
      <base type="HTML" apiVersion="1.0.0" src="bigtime.html" />
      <permissions>Full</permissions>
      <platform minPlatformVersion="1.0" />
    </host>
  </hosts>
</gadget>

I've narrowed it down to hitting settings, then cancel or okay (no code handling settings events yet) and then attempting to hit the dock button predictably killing the gadget controls. I've tried all suggestions in comments so far including setting the class which I had a feeling was going to break the thing altogether.

What's really bugging me is that it behaves the same way way regardless of arguments fed into the endTransition method or whether the end and beginTrans methods are even there. It's definitely not taking 5 full seconds to transition. That was set at 1 before. Still no difference. Nothing in docs about these transitionTypes that I can find.

HTML file:

<!doctype html>

<html xmlns="http://www.w3.org/1999/xhtml">

<head>
    <meta http-equiv="Content-Type" content="text/html; charset=Unicode" />
    <title>Time Tracker Gadget</title>
    <link type="text/css" rel="stylesheet" media="screen" href="css/main.css" />
</head>

<body id="gadget">

<!-- pure HTML here, no linked scripts, inline JS, or styles -->

<script type="text/jscript" src="js/main.js"></script>

</body>

</html>

JS file:

System.Gadget.settingsUI = "settings.html";

var docked = {width:"161px", height:"110px"},
undocked = {width:"295px", height:"390px"},
gadgetEl = document.getElementById('gadget'),

addStyles = function(el,newStyles){
    var elStyle = el.style;
    for(var x in newStyles){ elStyle[x] = newStyles[x]; }
},

swapDockStates = function(){

    System.Gadget.beginTransition();

    if(System.Gadget.docked){
        addStyles(gadgetEl,undocked);
    }
    else {
        addStyles(gadgetEl,docked);
    }

    System.Gadget.endTransition(System.Gadget.TransitionType.morph, 5);

};

System.Gadget.onDock = swapDockStates;
System.Gadget.onUndock = swapDockStates;

XML file:

<?xml version="1.0" encoding="utf-8" ?>
<gadget>
  <name>BigTime Gadget</name>
  <version>1.0.0.0</version>
  <author name="BigTime Software">
    <info url="www.bigtime.net" />
  </author>
  <copyright>© BigTime Software Inc.</copyright>
  <description>Time tracking gadget</description>
  <hosts>
    <host name="sidebar">
      <base type="HTML" apiVersion="1.0.0" src="bigtime.html" />
      <permissions>Full</permissions>
      <platform minPlatformVersion="1.0" />
    </host>
  </hosts>
</gadget>

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

山色无中 2024-12-16 15:22:59

呃……好尴尬啊。不要将同一个 JS 文件与设置文件和小工具文件中的事件处理程序和设置位置链接。这可以解释一些与存在或移除无关的事物的明显行为。我确实希望对全球范围内正在发生的事情有更深入的解释。

Ugh... how embarrassing. Don't link the same JS file with the event handlers and settings location in both your settings file and your gadget file. That would explain some of the apparent behavior of things not mattering whether present or removed. I do wish there was a more in-depth explanation of what's going on in terms of the global scope though.

对不⑦ 2024-12-16 15:22:59

你必须改变身体的高度来避免这个问题:

swapDockStates = function(){

    System.Gadget.beginTransition();

    if(System.Gadget.docked){
        document.body.style.height = '110px';
        addStyles(gadgetEl,undocked);
    }
    else {
        document.body.style.height = '390px';
        addStyles(gadgetEl,docked);
    }
    System.Gadget.endTransition(System.Gadget.TransitionType.morph, 5);
};

You have to change the height of the body to avoid this problem:

swapDockStates = function(){

    System.Gadget.beginTransition();

    if(System.Gadget.docked){
        document.body.style.height = '110px';
        addStyles(gadgetEl,undocked);
    }
    else {
        document.body.style.height = '390px';
        addStyles(gadgetEl,docked);
    }
    System.Gadget.endTransition(System.Gadget.TransitionType.morph, 5);
};
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文