JavaScript DHTML/Scriptaculous/Effect

Материал из Web эксперт
Перейти к: навигация, поиск

Effect.Queue limit

 
<!--
Copyright (c) 2005-2008 Thomas Fuchs (http://script.aculo.us, http://mir.aculo.us)
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-->
<!-- revised from scriptaculous-js-1.8.2 demo code  -->
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
  <title>script.aculo.us Effects functional test file</title>
  <meta http-equiv="content-type" content="text/html; charset=utf-8" />
  <script src="scriptaculous-js-1.8.2/lib/prototype.js" type="text/javascript"></script>
  <script src="scriptaculous-js-1.8.2/src/scriptaculous.js" type="text/javascript"></script>
  <script src="scriptaculous-js-1.8.2/src/unittest.js" type="text/javascript"></script>
  <style type="text/css" media="screen">
  
    #d1 { background-color: #fcb; width: 200px; height: 200px; float:left; }
    #d2 { background-color: #cfb; font-size: 2em; width: 200px; height: 200px; float:left; }
    #d3 { background-color: #bcf; font-size: 2em; width: 200px; height: 200px; float:left; }
  
  </style>
 
</head>
<body>
<h1>script.aculo.us Effects functional test file</h1>
<h2>Effect.Queue limit</h2>
<a href="#" onclick="Effect.SlideUp("slidingtwice",{queue:{scope:"myscope", position:"end", limit: 1}});">up</a>
<a href="#" onclick="Effect.SlideDown("slidingtwice",{queue:{scope:"myscope", position:"end", limit: 1}});">down</a>
<div id="slidingtwice"><div style="background-color:#000;color:white;font-size:20px;height:300px;width:150px;">
    Do a bit sliding in parallel, with a scoped queue, but I am limited to one : ) so don"t try over and over again...
</div></div>
</body>
</html>



Random effects demo

 
<!--
Copyright (c) 2005-2008 Thomas Fuchs (http://script.aculo.us, http://mir.aculo.us)
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-->
<!-- revised from scriptaculous-js-1.8.2 demo code  -->
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
        "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
  <title>script.aculo.us Effects functional test file</title>
  <meta http-equiv="content-type" content="text/html; charset=utf-8" />
  <script src="scriptaculous-js-1.8.2/lib/prototype.js" type="text/javascript"></script>
  <script src="scriptaculous-js-1.8.2/src/scriptaculous.js" type="text/javascript"></script>
  <style type="text/css" media="screen">
  
    div.demo { font-size: 70pt; float: left }
    div#info { font: 10px/11px Tahoma, Arial, sans-serif; }
  
  </style>
  <script type="text/javascript" language="javascript" charset="utf-8">
  
  function startDemo() {
    $$("div.demo").each( function(d) {
      d.visualEffect(
      ["fade","appear","blind_up","blind_down","puff","switch_off","drop_out","shake",
       "slide_up","slide_down","pulsate","squish","fold","grow","shrink"][Math.round(Math.random()*14)],
       { duration:0.5+Math.random()*5, delay: Math.random()*3 });
    });
    $("info").update(
      Effect.Queues.get("global").collect( function(e) {
        return e.inspect().escapeHTML()
      }).join("<br/>"));
  }
  
  </script>
</head>
<body>
<h1>Random effects demo</h1>
<a href="#" onclick="startDemo(); return false;">Start...</a> | 
<a href="#" onclick="$("info").toggle(); return false">Show/hide log</a>
<div class="demo" style="background-color:#f00"><div> 
DIV1
</div></div>
<div class="demo" style="background-color:#ff0"><div> 
DIV2
</div></div>
<div class="demo" style="background-color:#0f0"><div> 
DIV3
</div></div>
<div class="demo" style="background-color:#0ff"><div> 
DIV4
</div></div>
<div class="demo" style="background-color:#f00"><div> 
DIV5
</div></div>
<div class="demo" style="background-color:#ff0"><div> 
DIV6
</div></div>
<div class="demo" style="background-color:#f00"><div> 
DIV7
</div></div>
<div class="demo" style="background-color:#ff0"><div> 
DIV8
</div></div>
<div class="demo" style="background-color:#0f0"><div> 
DIV9
</div></div>
<div id="info" style="clear:both; display:none"> </div>
</body>
</html>



Start queued effects in global queue

 
<!--
Copyright (c) 2005-2008 Thomas Fuchs (http://script.aculo.us, http://mir.aculo.us)
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-->
<!-- revised from scriptaculous-js-1.8.2 demo code  -->
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
        "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
  <title>script.aculo.us Effects functional test file</title>
  <meta http-equiv="content-type" content="text/html; charset=utf-8" />
  <script src="scriptaculous-js-1.8.2/lib/prototype.js" type="text/javascript"></script>
  <script src="scriptaculous-js-1.8.2/src/scriptaculous.js" type="text/javascript"></script>
  <script src="scriptaculous-js-1.8.2/src/unittest.js" type="text/javascript"></script>
  <style type="text/css" media="screen">
  
    #d1 { background-color: #fcb; width: 200px; height: 200px; float:left; }
    #d2 { background-color: #cfb; font-size: 2em; width: 200px; height: 200px; float:left; }
    #d3 { background-color: #bcf; font-size: 2em; width: 200px; height: 200px; float:left; }
  
  </style>
  
</head>
<body>
<h1>script.aculo.us Effects functional test file</h1>
<h2>Effect.Queue</h2>
<div id="d1" style="font-size: 2em;">
  <p style="font-size:1em;">Lorem ipsum dolor sit amet</p>
</div>
<div id="d2">
  <p>Lorem ipsum dolor sit amet</p>
</div>
<div id="d3">
  <p>Lorem ipsum dolor sit amet</p>
</div>
<div style="clear: both">
  <a href="#" onclick="startTimeline(); return false;">Start queued effects</a> (in "global" queue)
</div>
<div id="sliding"><div style="background-color:#ccc;font-size:20px;height:300px;width:150px;">
  <a href="#" onclick="Effect.SlideUp("sliding",{queue:{scope:"myscope", position:"end"}}); Effect.SlideDown("sliding",{queue:{scope:"myscope", position:"end"}}); return false;">
    Do a bit sliding in parallel, with a scoped queue
  </a>
</div></div>
<script type="text/javascript" language="javascript" charset="utf-8">
  function startTimeline() {
    // 3x highlight in front
    for(var i=0; i<3; i++)
      new Effect.Highlight("d3", { duration: 1.0, queue: "front" });
    
    // insert scale at very beginning
    new Effect.Scale("d1", 75, { scaleContent: true, duration: 1.0, queue: "front" });
    
    // parallel implied, delay 0.5 sec
    new Effect.Highlight("d1", { delay: 0.5 }); 
    
    // puff at end
    new Effect.Puff("d2", { duration: 4.0, queue: "end" });
  }
</script>

</body>
</html>



Synchronized parallel execution of effects

 
<html>
<head>
<title>Untitled Document</title>
<script src="scriptaculous-js-1.8.2/lib/prototype.js" type="text/javascript"></script>
<script src="scriptaculous-js-1.8.2/src/scriptaculous.js" type="text/javascript"></script>
<script src="scriptaculous-js-1.8.2/src/unittest.js" type="text/javascript"></script>
<script type="text/javascript">
Event.observe(window, "load", function() {
  $("demo").observe("click", function() {
    new Effect.Parallel([
      new Effect.Opacity("demo", { sync: true, from: 1, to: 0.33 }),
      new Effect.Scale("demo", 400, { sync: true, scaleFromCenter: true })
    ], { duration: 20 });
  });
});
</script>
</head>
<body>
<p id="demo">Click on this paragraph to have a demonstration of it.</p>
</body>
</html>