prevent的Adobe边缘preload.js加载文件的jQuery [英] prevent Adobe Edge preload.js file from loading jquery

查看:272
本文介绍了prevent的Adobe边缘preload.js加载文件的jQuery的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

首先,我必须说,我不是一个专业的程序员,但这样做的设计师学习。所以,恐怕我需要简单的解释如果可能的话。
我使用Edge Animate中与特定脚本(由安德鲁·特莱斯的帮助下,网站的部分地区,在这里看到:的 http://www.tricedesigns.com/2012/07/12/using-adobe-edge-animations-as-components/ )。我也成功地只存储1边沿preload.js文件在我的libs文件夹。在这里面我介绍了在最后一个变量,以便能够加载边缘的动画此起彼伏。 code:

First I have to say that I am not a professional programmer but designer learning by doing. So I am afraid I need simple explanations if possible. I am using Edge animate as parts of a website with the help of a particular script (by Andrew Trice, see here: http://www.tricedesigns.com/2012/07/12/using-adobe-edge-animations-as-components/ ). I also succeeded in storing only 1 Edge preload.js file in my libs folder. In it I introduced a variable at the end in order to be able to load Edge animations one after another. Code:

function setupAnimationView( template ) { 

var $workPage = $("#workPage")

$workPage.empty();
window.AdobeEdge = undefined;
AdobeEdge = undefined;

var viewModel = { workChart: workChart };

var html = Mustache.to_html(template, viewModel)
$workPage.append( html );

//detect if edge is loaded yet
var edgeDetectionFunction = function() {

    if ( AdobeEdge && AdobeEdge.compositions != undefined ) {
        //put a delay here
        var hasComposition = false;

        if ( AdobeEdge.compositions ) {
            //loop to see if the composition is actually loaded
            for ( var key in AdobeEdge.compositionDefns ) {
                hasComposition = true;
                break;
            }
        }

        if ( hasComposition ) {
            setTimeout( function() { 
                $(window).trigger( "animationReady" ); }, 100 );    
            return;

        }
    }
    else if ( AdobeEdge ) {
        window.onDocLoaded();
    }
    setTimeout( edgeDetectionFunction, 100 );
}
edgeDetectionFunction();

}

修改的Adobe边缘preload.js:

Modified Adobe Edge preload.js:

...

   requiresSVG=false;

doDelayLoad=false;
htFallbacks={
};

aLoader = [
{ load: "libs/jquery-1.10.2.min.js"},
{ load: "libs/jquery.easing.1.3.js"},
{ load: "libs/jquery.rotate.js"},
{ load: "libs/edge.1.0.0.min.js"},
    {test: !hasJSON, yep:"libs/json2_min.js"},
      { load: "templates/Chart_" + workChart + "/Page_work_edge.js"},
      { load: "templates/Chart_" + workChart + "/Page_work_edgeActions.js"}];

loadResources(aLoader, doDelayLoad);

preContent={dom:[
]}
;//simpleContent

dlContent={dom: [
]}
;//simpleContent

//updated paths for loader
//added this so it can be invoked later
window.onDocLoaded = onDocLoaded;

})( "animation_content");

到目前为止感谢Andrew一切工作很细,只是我在开发人员工具(Safari浏览器),我的code导致了一遍又一遍加载像jQuery-1.10.2.min.js基本js文件看到每一次一个新的动画开始运行这个文件总结到数之不尽......我的猜测是不是一件好事。
我甚至知道为什么(至少我认为),所以我删除了aLoader对象中的各条线在preLOAD的结束。 (当然他们的脚本标签内我的索引页加载)

So far thanks to Andrew everything works very fine except that I saw in my developer tool (Safari) that my code leads to loading the basic js files like jquery-1.10.2.min.js over and over again each time a new animation starts to run and this files are summing up to an endless number… which I guess isn’t a good thing. I even understand why (at least I believed) and so I deleted the respective lines in the aLoader object at the end of preload. (of course they are loaded within the script tag in my index page)

aLoader = [
{ load: "libs/jquery-1.10.2.min.js"}, // deleted this one
{ load: "libs/jquery.easing.1.3.js"}, // deleted this one
{ load: "libs/jquery.rotate.js"}, // deleted this one
{ load: "libs/edge.1.0.0.min.js"}, // deleted this one
    {test: !hasJSON, yep:"libs/json2_min.js"},
      { load: "templates/Chart_" + workChart + "/Page_work_edge.js"},
      { load: "templates/Chart_" + workChart + "/Page_work_edgeActions.js"}];

由于我不明白为什么有必要加载它们不止一次。然而,这样做只有第一个动画运行后,二不下去了。但为什么?我在浏览器中检查,看到的jQuery-1.10.2.min.js在页面为什么不能(或者看起来如此)边缘文件使用它的任何更长?同为其他的(旋转等)。
我也试过用晚餐preSS从上面的功能,这两条线:

because I can’t see why it would be necessary to load them more than once. Yet, after doing so only the first animation runs, the second does not any longer. But why? I checked in the browser and see that jquery-1.10.2.min.js is in the page so why can’t (or seems so) the Edge files use it any longer? The same for the other ones (rotate etc.). I also tried to suppress these two lines from the function above:

window.AdobeEdge = undefined;
AdobeEdge = undefined;

但没有任何结果。
哪里办法来避免重装这些基本需要.js文件?有任何想法吗?非常感谢你的意见
加拉瓦尼

without any result though. Where is the trick to avoid reloading those basic needed .js files? Any ideas? Thank you so much for advice Garavani

@Jamie

编辑:
所以,你好杰米!我很好奇你的解决方案,我放弃一切,试了一下。遗憾的是它并没有在我试图在此编辑上面的线条尽可能准确说明情况的工作。
为了避免任何误解我在这里的改变code以下的指令(顺便说一句很好的解释!):

So ,hello Jamie! I was so curious about your solution that I dropped everything else and tried it. Sadly it does not work in the situation I tried to explain as exactly as possible in the lines above this edit. To avoid any misunderstandings here my changed code following your instructions (very good explanation by the way!):

边缘preload.js(!在我的版本,它没有文件名添加和在于,由每个新的动画由安德鲁·法后访问我的lib目录的文件夹 - 见上文):

edgePreload.js (in my version it has no filename addition and lies in my „lib" folder that is accessed by each new animation after the method by Andrew - see above!) :

window.AdobeEdge = window.AdobeEdge || {};
window.AdobeEdge.$_ = $;
// Include yepnope
if(!AdobeEdge.yepnope) {…

再往上:

$(function() { // your insert opening function

(function(compId){

var htFallbacks; …

…
window.onDocLoaded = onDocLoaded;

})( "animation_content");

}); // your insert closure

我的index.html包含以下脚本(其中包括):

My index.html contains the following scripts (among others):

<script src="libs/jquery-1.11.0.min.js"></script>
<script src="libs/jquery.easing.1.3.js"></script>
<script src="libs/jquery.rotate.js"></script>
<script src="libs/edge.1.0.0.min.js"></script>
<script src="libs/mustache.js"></script>
<script src="libs/mustacheHelper.js"></script>

我想主办我的服务器上。 (避免各种麻烦来了版本的更新不是我的控制之下)

which I like to host on my server. (avoiding all kinds of trouble coming up with versions updates not under my control)

现在我敢,希望能够取消那些东西从我的aLoader箭头如下:

Now I dared and hoped to be able to cancel that stuff from my aLoader arrow as follows:

aLoader = [
// { load: "libs/jquery-1.11.0.min.js"},
// { load: "libs/jquery.easing.1.3.js"},
// { load: "libs/jquery.rotate.js"},
// { load: "libs/edge.1.0.0.min.js"},
    {test: !hasJSON, yep:"libs/json2_min.js"},
      { load: "templates/Chart_" + workChart + "/Page_work_edge.js"},
      { load: "templates/Chart_" + workChart + "/Page_work_edgeActions.js"}];     

但ID T不工作(投掷各种错误显然是基于缺乏边缘codeS)。
当我再次更换所有的aLoader至少它的工作原理,而不显示有关新插入的行的错误。但我有没有结果。然而,就soooooooooo酷!
我错过了什么?难道你真的仔细检查我做什么,我最初的线上面?

but id t doesn’t work (throwing all kinds of errors obviously based on lacking edge codes). When I replace all in the aLoader again at least it works without showing errors concerning the new inserted lines. But I have no result. Yet, would be soooooooooo cool!!! Did I miss something? Did you really check thoroughly what I did in my initial lines above?

我好奇地听到你的想法!
谢谢到目前为止您的兴趣,并愿意分享你的这个复杂的边料方面的知识(没有太大的讨论 - 有很好的理由我想 - 在这里堆栈溢出)。

I am curious to hear your ideas! Thank you so far for your interest and willing to share your knowledge of this complicated edge material (not much discussed - for good reasons I guess – here in stack overflow).

推荐答案

我一直有确切的问题,你现在可能已经解决了这个问题,但希望它会帮助别人。

I've been having the exact issue and you've probably solved it by now, but hopefully it'll help someone else.

1)确保您在您的发布设置,并发布到一个干净的文件夹选择HTML让你的文件。

1) Make sure you get your files by choosing 'HTML' in your publish settings, and publishing to a clean folder.

2)使用prettifier工具(如 http://jsbeautifier.org/ )以使 [文件名] _edge preload.js 文件的可读性。

2) Use a prettifier tool (e.g. http://jsbeautifier.org/) to make the [filename]_edgePreload.js file readable.

3)加入这一行 window.AdobeEdge $ _ = $; 刚下过顶行 window.AdobeEdge = window.AdobeEdge || {};

3) Add this line window.AdobeEdge.$_ = $; just under the top line window.AdobeEdge = window.AdobeEdge || {};

4)找到这一行(功能(compId){(这是load方法的开始),敷在此之间的整个法(一切,底部页)与 $(函数(){});

4) Find this line (function(compId) { (which is the start of the load method) and wrap that whole method (everything between here and the bottom of the page) with $(function() { and });

5)在 aLoader 阵列,删除指定如何加载的边缘和jQuery的前两个条目。

5) In the aLoader array, remove the first two entries that specify how to load edge and jquery.

6)加边库(目前 https://animate.adobe.com/runtime/4.0.1/edge.4.0.1.min.js )您的网站的负责人,和jQuery一起。

6) Add the edge library (currently https://animate.adobe.com/runtime/4.0.1/edge.4.0.1.min.js) to the head of your site, along with jQuery.

不要觉得太糟糕了,这是混乱的,土坯边缘输出code已被写入用腿白菜。每个人都与它斗争:)

Don't feel too bad that this was confusing, the Adobe Edge output code has been written by a cabbage with legs. Everyone struggles with it :)

这篇关于prevent的Adobe边缘preload.js加载文件的jQuery的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆