aboutsummaryrefslogtreecommitdiffstats
path: root/ui/ui.history.js
diff options
context:
space:
mode:
authorScott González <scott.gonzalez@gmail.com>2008-07-10 02:50:51 +0000
committerScott González <scott.gonzalez@gmail.com>2008-07-10 02:50:51 +0000
commit12cdae02b136f7a542dfac7319d008cf9c3d5505 (patch)
tree5face07144b2c77f390a03e96d9bdd710e152255 /ui/ui.history.js
parent4f412c60ea8dbf11b9447e838b815214ab3ca1a2 (diff)
downloadjquery-ui-12cdae02b136f7a542dfac7319d008cf9c3d5505.tar.gz
jquery-ui-12cdae02b136f7a542dfac7319d008cf9c3d5505.zip
New plugins for 1.6: Fixed headers and indentation.
Diffstat (limited to 'ui/ui.history.js')
-rw-r--r--ui/ui.history.js179
1 files changed, 87 insertions, 92 deletions
diff --git a/ui/ui.history.js b/ui/ui.history.js
index 6378b75a0..40848ebe5 100644
--- a/ui/ui.history.js
+++ b/ui/ui.history.js
@@ -7,111 +7,106 @@
*
* http://docs.jquery.com/UI/History
*
- * Revision: $Id: ui.history.js 5218 2008-04-09 20:08:24Z rdworth $
+ * Depends:
+ * ui.core.js
*/
-;(function($) {
+(function($) {
- // if the UI scope is not availalable, add it
- $.ui = $.ui || {};
+// TODO lazy loading singleton
+$.ui.hmanager = new function() {
+ var states = {}, def = function() {};
- // TODO lazy loading singleton
- $.ui.hmanager = new function() {
- var states = {}, def = function() {};
-
- var $window = $(window), hash = location.hash;
-
- function getState() {
- return hash.replace('#', '');
- }
-
- var iframe;
- // var keepHistoryIn = iframe || window;
-
- return {
+ var $window = $(window), hash = location.hash;
- enable: function() {
-
- if ($.browser.msie && parseInt($.browser.version) < 8) {
- $(function() {
- // create hidden iframe for hash change tracking
- iframe = $('<iframe id="ui-history-iframe" style="display: none;"></iframe>').
- prependTo(document.body)[0];
-
- // create initial history entry
- iframe.contentWindow.document.open();
- iframe.contentWindow.document.close();
-
- if (getState())
- iframe.contentWindow.document.location.hash = getState();
-
- });
- }
-
- $window.bind('hashchange', function(e) {
- // Prevent IE 8 from fireing an event twice,
- // one from true event, one from trigger...
- if (!iframe && hash == location.hash || iframe && hash == iframe.contentWindow.document.location.hash)
- return false;
+ function getState() {
+ return hash.replace('#', '');
+ }
+
+ var iframe;
+ // var keepHistoryIn = iframe || window;
+
+ return {
- if ($.browser.msie && parseInt($.browser.version) < 8) {
- hash = iframe.contentWindow.document.location.hash;
- }
- else
- hash = location.hash;
+ enable: function() {
+
+ if ($.browser.msie && parseInt($.browser.version) < 8) {
+ $(function() {
+ // create hidden iframe for hash change tracking
+ iframe = $('<iframe id="ui-history-iframe" style="display: none;"></iframe>').
+ prependTo(document.body)[0];
+
+ // create initial history entry
+ iframe.contentWindow.document.open();
+ iframe.contentWindow.document.close();
if (getState())
- states[getState()]();
- else
- // TODO invoke default
- ;
+ iframe.contentWindow.document.location.hash = getState();
+
});
-
- if (!($.browser.msie && parseInt($.browser.version) >= 8)) {
- setInterval(
- ($.browser.msie ?
- function() {
- if (hash != iframe.contentWindow.document.location.hash)
- $window.trigger('hashchange');
- } :
- function() {
- if (hash != location.hash)
- $window.trigger('hashchange');
- else
- // Do the history.length check hack for Safari 2
- ;
- }
- )
- , 200
- );
+ }
+
+ $window.bind('hashchange', function(e) {
+ // Prevent IE 8 from fireing an event twice,
+ // one from true event, one from trigger...
+ if (!iframe && hash == location.hash || iframe && hash == iframe.contentWindow.document.location.hash)
+ return false;
+
+ if ($.browser.msie && parseInt($.browser.version) < 8) {
+ hash = iframe.contentWindow.document.location.hash;
}
+ else
+ hash = location.hash;
- },
-
- add: function(state, handler) {
- states[state] = handler;
- },
+ if (getState())
+ states[getState()]();
+ else
+ // TODO invoke default
+ ;
+ });
- go: function(state) {
- if (state) {
- if ($.browser.msie && parseInt($.browser.version) < 8) {
- iframe.contentWindow.document.open();
- iframe.contentWindow.document.close();
- iframe.contentWindow.document.location.hash = state;
- }
- location.hash = state;
- $window.trigger('hashchange');
- }
- else
- console.log('TODO do default state');
+ if (!($.browser.msie && parseInt($.browser.version) >= 8)) {
+ setInterval(
+ ($.browser.msie ?
+ function() {
+ if (hash != iframe.contentWindow.document.location.hash)
+ $window.trigger('hashchange');
+ } :
+ function() {
+ if (hash != location.hash)
+ $window.trigger('hashchange');
+ else
+ // Do the history.length check hack for Safari 2
+ ;
+ }
+ )
+ , 200
+ );
}
+ },
- }
+ add: function(state, handler) {
+ states[state] = handler;
+ },
- };
+ go: function(state) {
+ if (state) {
+ if ($.browser.msie && parseInt($.browser.version) < 8) {
+ iframe.contentWindow.document.open();
+ iframe.contentWindow.document.close();
+ iframe.contentWindow.document.location.hash = state;
+ }
+ location.hash = state;
+ $window.trigger('hashchange');
+ }
+ else
+ console.log('TODO do default state');
+ }
+ }
+};
+
+$.ui.history = function() {
+ var args = Array.prototype.slice.call(arguments, 1);
+ $.ui.hmanager[arguments[0]].apply($.ui.hmanager, args);
+};
- $.ui.history = function() {
- var args = Array.prototype.slice.call(arguments, 1);
- $.ui.hmanager[arguments[0]].apply($.ui.hmanager, args);
- };
-
})(jQuery);