Changeset 26671 for extensions/stripped-galleria/galleria/plugins/history
- Timestamp:
- Jan 12, 2014, 10:03:35 PM (10 years ago)
- 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 1 1 /** 2 * @preserve Galleria History Plugin 2011-08-013 * http://galleria. aino.se2 * Galleria History Plugin 2012-04-04 3 * http://galleria.io 4 4 * 5 * Copyright 2011, Aino6 * Licensed under the MIT license.5 * Licensed under the MIT license 6 * https://raw.github.com/aino/galleria/master/LICENSE 7 7 * 8 8 */ 9 10 (function( $, window ) { 9 11 10 12 /*global jQuery, Galleria, window */ … … 12 14 Galleria.requires(1.25, 'The History Plugin requires Galleria version 1.2.5 or later.'); 13 15 14 (function( $, window) {16 Galleria.History = (function() { 15 17 16 Galleria.History = (function() {18 var onloads = [], 17 19 18 var onloads = [],20 init = false, 19 21 20 init = false,22 loc = window.location, 21 23 22 loc = window.location,24 doc = window.document, 23 25 24 doc = window.document,26 ie = Galleria.IE, 25 27 26 ie = Galleria.IE,28 support = 'onhashchange' in window && ( doc.mode === undefined || doc.mode > 7 ), 27 29 28 support = 'onhashchange' in window && ( doc.mode === undefined || doc.mode > 7 ),30 iframe, 29 31 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 }, 31 40 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 ), 40 42 41 saved = get( loc ),43 callbacks = [], 42 44 43 callbacks = [], 45 onchange = function() { 46 $.each( callbacks, function( i, fn ) { 47 fn.call( window, get() ); 48 }); 49 }, 44 50 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 }); 50 55 51 ready = function() { 52 $.each( onloads, function(i, fn) { 53 fn(); 54 }); 56 init = true; 57 }, 55 58 56 init = true; 57 }, 59 setHash = function( val ) { 60 return '/' + val; 61 }; 58 62 59 setHash = function( val ) { 60 return '/' + val; 61 }; 63 // always remove support if IE < 8 64 if ( support && ie < 8 ) { 65 support = false; 66 } 62 67 63 // always remove support if IE < 8 64 if ( support && ie < 8 ) { 65 support = false; 66 } 68 if ( !support ) { 67 69 68 if ( !support) {70 $(function() { 69 71 70 $(function() {72 var interval = window.setInterval(function() { 71 73 72 var interval = window.setInterval(function() {74 var hash = get(); 73 75 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(); 117 80 } 118 81 119 if ( !support && ie ) {82 }, 50); 120 83 121 this.ready(function() {84 if ( ie ) { 122 85 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() { 126 87 127 iframe.location.hash = setHash( val );88 iframe = this.contentWindow; 128 89 129 }); 130 } 90 ready(); 131 91 132 loc.hash = setHash( val ); 133 }, 92 }).insertAfter(doc.body); 134 93 135 ready: function(fn) { 136 if (!init) { 137 onloads.push(fn); 138 } else { 139 fn(); 140 } 94 } else { 95 ready(); 141 96 } 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 }()); 144 144 145 145 }( 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 21 21 22 22 <!-- 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> 24 24 25 25 <!-- load Galleria --> 26 <script src="../../galleria-1. 2.6.min.js"></script>26 <script src="../../galleria-1.3.3.min.js"></script> 27 27 28 28 <!-- load the History plugin, no need for further scripting --> … … 39 39 <div id="galleria"> 40 40 <a href="http://upload.wikimedia.org/wikipedia/commons/thumb/3/34/Locomotives-Roundhouse2.jpg/800px-Locomotives-Roundhouse2.jpg"> 41 42 43 44 41 <img title="Locomotives Roundhouse" 42 alt="Steam locomotives of the Chicago & North Western Railway." 43 src="http://upload.wikimedia.org/wikipedia/commons/thumb/3/34/Locomotives-Roundhouse2.jpg/100px-Locomotives-Roundhouse2.jpg"> 44 </a> 45 45 <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"> 46 46 <img title="Icebergs in the High Arctic" … … 91 91 92 92 // Load the classic theme 93 93 Galleria.loadTheme('../../themes/classic/galleria.classic.min.js'); 94 94 95 96 $('#galleria').galleria();95 // Initialize Galleria 96 Galleria.run('#galleria'); 97 97 98 98 </script>
Note: See TracChangeset
for help on using the changeset viewer.