+++ /dev/null
-/*\r
- * jQuery UI History\r
- *\r
- * Copyright (c) 2008 Klaus Hartl (stilbuero.de)\r
- * Dual licensed under the MIT (MIT-LICENSE.txt)\r
- * and GPL (GPL-LICENSE.txt) licenses.\r
- *\r
- * http://docs.jquery.com/UI/History\r
- *\r
- * Depends:\r
- * ui.core.js\r
- */\r
-(function($) {\r
-\r
-// TODO lazy loading singleton\r
-$.ui.hmanager = new function() {\r
- var states = {}, def = function() {};\r
- \r
- var $window = $(window), hash = location.hash; \r
-\r
- function getState() {\r
- return hash.replace('#', '');\r
- } \r
- \r
- var iframe;\r
- // var keepHistoryIn = iframe || window;\r
- \r
- return {\r
-\r
- enable: function() {\r
- \r
- if ($.browser.msie && parseInt($.browser.version) < 8) {\r
- $(function() {\r
- // create hidden iframe for hash change tracking\r
- iframe = $('<iframe id="ui-history-iframe" style="display: none;"></iframe>').\r
- prependTo(document.body)[0];\r
- \r
- // create initial history entry\r
- iframe.contentWindow.document.open();\r
- iframe.contentWindow.document.close();\r
- \r
- if (getState())\r
- iframe.contentWindow.document.location.hash = getState();\r
- \r
- });\r
- }\r
- \r
- $window.bind('hashchange', function(e) {\r
- // Prevent IE 8 from fireing an event twice,\r
- // one from true event, one from trigger...\r
- if (!iframe && hash == location.hash || iframe && hash == iframe.contentWindow.document.location.hash)\r
- return false;\r
-\r
- if ($.browser.msie && parseInt($.browser.version) < 8) {\r
- hash = iframe.contentWindow.document.location.hash;\r
- }\r
- else\r
- hash = location.hash;\r
- \r
- if (getState())\r
- states[getState()]();\r
- else\r
- // TODO invoke default\r
- ;\r
- });\r
- \r
- if (!($.browser.msie && parseInt($.browser.version) >= 8)) {\r
- setInterval(\r
- ($.browser.msie ?\r
- function() {\r
- if (hash != iframe.contentWindow.document.location.hash)\r
- $window.trigger('hashchange');\r
- } : \r
- function() {\r
- if (hash != location.hash)\r
- $window.trigger('hashchange');\r
- else\r
- // Do the history.length check hack for Safari 2\r
- ;\r
- }\r
- )\r
- , 200\r
- );\r
- }\r
- },\r
-\r
- add: function(state, handler) {\r
- states[state] = handler;\r
- },\r
- \r
- go: function(state) {\r
- if (state) {\r
- if ($.browser.msie && parseInt($.browser.version) < 8) {\r
- iframe.contentWindow.document.open();\r
- iframe.contentWindow.document.close();\r
- iframe.contentWindow.document.location.hash = state; \r
- }\r
- location.hash = state;\r
- $window.trigger('hashchange');\r
- }\r
- else \r
- console.log('TODO do default state');\r
- }\r
- }\r
-};\r
-\r
-$.ui.history = function() { \r
- var args = Array.prototype.slice.call(arguments, 1);\r
- $.ui.hmanager[arguments[0]].apply($.ui.hmanager, args);\r
-};\r
-\r
-})(jQuery);\r