Ignore:
Timestamp:
Jan 12, 2014, 10:03:35 PM (10 years ago)
Author:
flop25
Message:

updated for 2.5 & 2.6

Location:
extensions/stripped-galleria/galleria/plugins/history
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • extensions/stripped-galleria/galleria/plugins/history/galleria.history.js

    r12975 r26671  
    11/**
    2  * @preserve Galleria History Plugin 2011-08-01
    3  * http://galleria.aino.se
     2 * Galleria History Plugin 2012-04-04
     3 * http://galleria.io
    44 *
    5  * Copyright 2011, Aino
    6  * Licensed under the MIT license.
     5 * Licensed under the MIT license
     6 * https://raw.github.com/aino/galleria/master/LICENSE
    77 *
    88 */
     9
     10(function( $, window ) {
    911
    1012/*global jQuery, Galleria, window */
     
    1214Galleria.requires(1.25, 'The History Plugin requires Galleria version 1.2.5 or later.');
    1315
    14 (function( $, window ) {
     16Galleria.History = (function() {
    1517
    16     Galleria.History = (function() {
     18    var onloads = [],
    1719
    18         var onloads = [],
     20        init = false,
    1921
    20             init = false,
     22        loc = window.location,
    2123
    22             loc = window.location,
     24        doc = window.document,
    2325
    24             doc = window.document,
     26        ie = Galleria.IE,
    2527
    26             ie = Galleria.IE,
     28        support = 'onhashchange' in window && ( doc.mode === undefined || doc.mode > 7 ),
    2729
    28             support = 'onhashchange' in window && ( doc.mode === undefined || doc.mode > 7 ),
     30        iframe,
    2931
    30             iframe,
     32        get = function( winloc ) {
     33            if( iframe && !support && Galleria.IE ) {
     34                winloc = winloc || iframe.location;
     35            }  else {
     36                winloc = loc;
     37            }
     38            return parseInt( winloc.hash.substr(2), 10 );
     39        },
    3140
    32             get = function( winloc ) {
    33                 if( iframe && !support && Galleria.IE ) {
    34                     winloc = winloc || iframe.location;
    35                 }  else {
    36                     winloc = loc;
    37                 }
    38                 return parseInt( winloc.hash.substr(2), 10 );
    39             },
     41        saved = get( loc ),
    4042
    41             saved = get( loc ),
     43        callbacks = [],
    4244
    43             callbacks = [],
     45        onchange = function() {
     46            $.each( callbacks, function( i, fn ) {
     47                fn.call( window, get() );
     48            });
     49        },
    4450
    45             onchange = function() {
    46                 $.each( callbacks, function( i, fn ) {
    47                     fn.call( window, get() );
    48                 });
    49             },
     51        ready = function() {
     52            $.each( onloads, function(i, fn) {
     53                fn();
     54            });
    5055
    51             ready = function() {
    52                 $.each( onloads, function(i, fn) {
    53                     fn();
    54                 });
     56            init = true;
     57        },
    5558
    56                 init = true;
    57             },
     59        setHash = function( val ) {
     60            return '/' + val;
     61        };
    5862
    59             setHash = function( val ) {
    60                 return '/' + val;
    61             };
     63    // always remove support if IE < 8
     64    if ( support && ie < 8 ) {
     65        support = false;
     66    }
    6267
    63         // always remove support if IE < 8
    64         if ( support && ie < 8 ) {
    65             support = false;
    66         }
     68    if ( !support ) {
    6769
    68         if ( !support ) {
     70        $(function() {
    6971
    70             $(function() {
     72            var interval = window.setInterval(function() {
    7173
    72                 var interval = window.setInterval(function() {
     74                var hash = get();
    7375
    74                     var hash = get();
    75 
    76                     if ( !isNaN( hash ) && hash != saved ) {
    77                         saved = hash;
    78                         loc.hash = setHash( hash );
    79                         onchange();
    80                     }
    81 
    82                 }, 50);
    83 
    84                 if ( ie ) {
    85 
    86                     $('<iframe tabindex="-1" title="empty">').hide().attr( 'src', 'about:blank' ).one('load', function() {
    87 
    88                         iframe = this.contentWindow;
    89 
    90                         ready();
    91 
    92                     }).insertAfter(doc.body);
    93 
    94                 } else {
    95                     ready();
    96                 }
    97             });
    98         } else {
    99             ready();
    100         }
    101 
    102         return {
    103 
    104             change: function( fn ) {
    105 
    106                 callbacks.push( fn );
    107 
    108                 if( support ) {
    109                     window.onhashchange = onchange;
    110                 }
    111             },
    112 
    113             set: function( val ) {
    114 
    115                 if ( isNaN( val ) ) {
    116                     return;
     76                if ( !isNaN( hash ) && hash != saved ) {
     77                    saved = hash;
     78                    loc.hash = setHash( hash );
     79                    onchange();
    11780                }
    11881
    119                 if ( !support && ie ) {
     82            }, 50);
    12083
    121                     this.ready(function() {
     84            if ( ie ) {
    12285
    123                         var idoc = iframe.document;
    124                         idoc.open();
    125                         idoc.close();
     86                $('<iframe tabindex="-1" title="empty">').hide().attr( 'src', 'about:blank' ).one('load', function() {
    12687
    127                         iframe.location.hash = setHash( val );
     88                    iframe = this.contentWindow;
    12889
    129                     });
    130                 }
     90                    ready();
    13191
    132                 loc.hash = setHash( val );
    133             },
     92                }).insertAfter(doc.body);
    13493
    135             ready: function(fn) {
    136                 if (!init) {
    137                     onloads.push(fn);
    138                 } else {
    139                     fn();
    140                 }
     94            } else {
     95                ready();
    14196            }
    142         };
    143     }());
     97        });
     98    } else {
     99        ready();
     100    }
     101
     102    return {
     103
     104        change: function( fn ) {
     105
     106            callbacks.push( fn );
     107
     108            if( support ) {
     109                window.onhashchange = onchange;
     110            }
     111        },
     112
     113        set: function( val ) {
     114
     115            if ( isNaN( val ) ) {
     116                return;
     117            }
     118
     119            if ( !support && ie ) {
     120
     121                this.ready(function() {
     122
     123                    var idoc = iframe.document;
     124                    idoc.open();
     125                    idoc.close();
     126
     127                    iframe.location.hash = setHash( val );
     128
     129                });
     130            }
     131
     132            loc.hash = setHash( val );
     133        },
     134
     135        ready: function(fn) {
     136            if (!init) {
     137                onloads.push(fn);
     138            } else {
     139                fn();
     140            }
     141        }
     142    };
     143}());
    144144
    145145}( jQuery, this ));
  • extensions/stripped-galleria/galleria/plugins/history/galleria.history.min.js

    r12975 r26671  
    1 /*
    2  Galleria History Plugin 2011-08-01
    3  http://galleria.aino.se
    4 
    5  Copyright 2011, Aino
    6  Licensed under the MIT license.
    7 
    8 */
    9 Galleria.requires(1.25,"The History Plugin requires Galleria version 1.2.5 or later.");
    10 (function(e,c){Galleria.History=function(){var k=[],l=!1,f=c.location,g=c.document,h=Galleria.IE,b="onhashchange"in c&&(g.mode===void 0||g.mode>7),d,i=function(a){a=d&&!b&&Galleria.IE?a||d.location:f;return parseInt(a.hash.substr(2),10)},m=i(f),n=[],o=function(){e.each(n,function(a,b){b.call(c,i())})},j=function(){e.each(k,function(a,b){b()});l=!0};b&&h<8&&(b=!1);b?j():e(function(){c.setInterval(function(){var a=i();if(!isNaN(a)&&a!=m)m=a,f.hash="/"+a,o()},50);h?e('<iframe tabindex="-1" title="empty">').hide().attr("src",
    11 "about:blank").one("load",function(){d=this.contentWindow;j()}).insertAfter(g.body):j()});return{change:function(a){n.push(a);if(b)c.onhashchange=o},set:function(a){if(!isNaN(a))!b&&h&&this.ready(function(){var b=d.document;b.open();b.close();d.location.hash="/"+a}),f.hash="/"+a},ready:function(a){l?a():k.push(a)}}}()})(jQuery,this);
     1!function(n,e){Galleria.requires(1.25,"The History Plugin requires Galleria version 1.2.5 or later.");Galleria.History=function(){var i=[],t=false,a=e.location,o=e.document,r=Galleria.IE,s="onhashchange"in e&&(o.mode===undefined||o.mode>7),u,c=function(n){if(u&&!s&&Galleria.IE){n=n||u.location}else{n=a}return parseInt(n.hash.substr(2),10)},f=c(a),l=[],h=function(){n.each(l,function(n,i){i.call(e,c())})},d=function(){n.each(i,function(n,e){e()});t=true},y=function(n){return"/"+n};if(s&&r<8){s=false}if(!s){n(function(){var i=e.setInterval(function(){var n=c();if(!isNaN(n)&&n!=f){f=n;a.hash=y(n);h()}},50);if(r){n('<iframe tabindex="-1" title="empty">').hide().attr("src","about:blank").one("load",function(){u=this.contentWindow;d()}).insertAfter(o.body)}else{d()}})}else{d()}return{change:function(n){l.push(n);if(s){e.onhashchange=h}},set:function(n){if(isNaN(n)){return}if(!s&&r){this.ready(function(){var e=u.document;e.open();e.close();u.location.hash=y(n)})}a.hash=y(n)},ready:function(n){if(!t){i.push(n)}else{n()}}}}()}(jQuery,this);
  • extensions/stripped-galleria/galleria/plugins/history/history-demo.html

    r12975 r26671  
    2121
    2222        <!-- load jQuery -->
    23         <script src="http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>
     23        <script src="http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.js"></script>
    2424
    2525        <!-- load Galleria -->
    26         <script src="../../galleria-1.2.6.min.js"></script>
     26        <script src="../../galleria-1.3.3.min.js"></script>
    2727
    2828        <!-- load the History plugin, no need for further scripting -->
     
    3939        <div id="galleria">
    4040            <a href="http://upload.wikimedia.org/wikipedia/commons/thumb/3/34/Locomotives-Roundhouse2.jpg/800px-Locomotives-Roundhouse2.jpg">
    41                 <img title="Locomotives Roundhouse"
    42                      alt="Steam locomotives of the Chicago &amp; North Western Railway."
    43                      src="http://upload.wikimedia.org/wikipedia/commons/thumb/3/34/Locomotives-Roundhouse2.jpg/100px-Locomotives-Roundhouse2.jpg">
    44                 </a>
     41                <img title="Locomotives Roundhouse"
     42                     alt="Steam locomotives of the Chicago &amp; North Western Railway."
     43                     src="http://upload.wikimedia.org/wikipedia/commons/thumb/3/34/Locomotives-Roundhouse2.jpg/100px-Locomotives-Roundhouse2.jpg">
     44            </a>
    4545            <a href="http://upload.wikimedia.org/wikipedia/commons/thumb/3/36/Icebergs_in_the_High_Arctic_-_20050907.jpg/1000px-Icebergs_in_the_High_Arctic_-_20050907.jpg">
    4646                <img title="Icebergs in the High Arctic"
     
    9191
    9292    // Load the classic theme
    93         Galleria.loadTheme('../../themes/classic/galleria.classic.min.js');
     93    Galleria.loadTheme('../../themes/classic/galleria.classic.min.js');
    9494
    95         // Initialize Galleria
    96         $('#galleria').galleria();
     95    // Initialize Galleria
     96    Galleria.run('#galleria');
    9797
    9898    </script>
Note: See TracChangeset for help on using the changeset viewer.