~dylanmccall/ubiquity-slideshow-ubuntu/maverick-ubuntu-design

« back to all changes in this revision

Viewing changes to slideshows/link-core/fastinit.js

  • Committer: Dylan McCall
  • Date: 2010-09-13 03:57:39 UTC
  • Revision ID: dylanmccall@gmail.com-20100913035739-jbo2wvnvxmqzxyww
Replaced scripaculous / Crossfade with jQuery and Cycle plugin.
Automatic slide switching now pauses after reaching the end, but manual controls continue to function.
Important note: This needed a change to the CSS for all slideshows, setting 100% width and height for #slideshow > div

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/*
2
 
*
3
 
* Copyright (c) 2007 Andrew Tetlaw
4
 
5
 
* Permission is hereby granted, free of charge, to any person
6
 
* obtaining a copy of this software and associated documentation
7
 
* files (the "Software"), to deal in the Software without
8
 
* restriction, including without limitation the rights to use, copy,
9
 
* modify, merge, publish, distribute, sublicense, and/or sell copies
10
 
* of the Software, and to permit persons to whom the Software is
11
 
* furnished to do so, subject to the following conditions:
12
 
13
 
* The above copyright notice and this permission notice shall be
14
 
* included in all copies or substantial portions of the Software.
15
 
16
 
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
 
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
 
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
 
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
20
 
* BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
21
 
* ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
22
 
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
23
 
* SOFTWARE.
24
 
* * 
25
 
*
26
 
*
27
 
* FastInit
28
 
* http://tetlaw.id.au/view/javascript/fastinit
29
 
* Andrew Tetlaw
30
 
* Version 1.3 (2007-01-09)
31
 
* Based on:
32
 
* http://dean.edwards.name/weblog/2006/03/faster
33
 
* http://dean.edwards.name/weblog/2006/06/again/
34
 
* Help from:
35
 
* http://www.cherny.com/webdev/26/domloaded-object-literal-updated
36
 
37
 
*/
38
 
var FastInit = {
39
 
        onload : function() {
40
 
                if (FastInit.done) { return; }
41
 
                FastInit.done = true;
42
 
                for(var x = 0, al = FastInit.f.length; x < al; x++) {
43
 
                        FastInit.f[x]();
44
 
                }
45
 
        },
46
 
        addOnLoad : function() {
47
 
                var a = arguments;
48
 
                for(var x = 0, al = a.length; x < al; x++) {
49
 
                        if(typeof a[x] === 'function') { FastInit.f.push(a[x]); }
50
 
                }
51
 
        },
52
 
        listen : function() {
53
 
                if (/WebKit|khtml/i.test(navigator.userAgent)) {
54
 
                        FastInit.timer = setInterval(function() {
55
 
                                if (/loaded|complete/.test(document.readyState)) {
56
 
                                        clearInterval(FastInit.timer);
57
 
                                        delete FastInit.timer;
58
 
                                        FastInit.onload();
59
 
                                }}, 10);
60
 
                } else if (document.addEventListener) {
61
 
                        document.addEventListener('DOMContentLoaded', FastInit.onload, false);
62
 
                } else if(!FastInit.iew32) {
63
 
                        Event.observe(window, 'load', FastInit.onload);
64
 
                }
65
 
        },
66
 
        f:[],done:false,timer:null,iew32:false
67
 
};
68
 
/*@cc_on @*/
69
 
/*@if (@_win32)
70
 
FastInit.iew32 = true;
71
 
document.write('<script id="__ie_onload" defer src="' + ((location.protocol == 'https:') ? '//0' : 'javascript:void(0)') + '"><\/script>');
72
 
document.getElementById('__ie_onload').onreadystatechange = function(){if (this.readyState == 'complete') { FastInit.onload(); }};
73
 
/*@end @*/
74
 
FastInit.listen();