aboutsummaryrefslogtreecommitdiffstats
path: root/assets/jquery-history.js
diff options
context:
space:
mode:
authorJoey <joey@lineageos.org>2018-03-12 13:55:27 +0100
committerJoey <joey@lineageos.org>2018-03-12 16:00:00 +0100
commitb6d895cd9faec16a2f2020cc447a2aa1c698392e (patch)
tree9c80bdebcdd7abef35deeff38554593459e257c0 /assets/jquery-history.js
parent55ccdc3002a2adaee63231b59b6580cca7437869 (diff)
downloadlineage-sdk-b6d895cd9faec16a2f2020cc447a2aa1c698392e.tar.gz
lineage-sdk-b6d895cd9faec16a2f2020cc447a2aa1c698392e.tar.bz2
lineage-sdk-b6d895cd9faec16a2f2020cc447a2aa1c698392e.zip
Initial javadoc pushgh-pages
Change-Id: Ic4f9f576d0676dc696631b49d7e65e72b0ccde85 Signed-off-by: Joey <joey@lineageos.org>
Diffstat (limited to 'assets/jquery-history.js')
-rw-r--r--assets/jquery-history.js78
1 files changed, 78 insertions, 0 deletions
diff --git a/assets/jquery-history.js b/assets/jquery-history.js
new file mode 100644
index 00000000..ef96ec39
--- /dev/null
+++ b/assets/jquery-history.js
@@ -0,0 +1,78 @@
+/**
+ * jQuery history event v0.1
+ * Copyright (c) 2008 Tom Rodenberg <tarodenberg gmail com>
+ * Licensed under the GPL (http://www.gnu.org/licenses/gpl.html) license.
+ */
+(function($) {
+ var currentHash, previousNav, timer, hashTrim = /^.*#/;
+
+ var msie = {
+ iframe: null,
+ getDoc: function() {
+ return msie.iframe.contentWindow.document;
+ },
+ getHash: function() {
+ return msie.getDoc().location.hash;
+ },
+ setHash: function(hash) {
+ var d = msie.getDoc();
+ d.open();
+ d.close();
+ d.location.hash = hash;
+ }
+ };
+
+ var historycheck = function() {
+ var hash = msie.iframe ? msie.getHash() : location.hash;
+ if (hash != currentHash) {
+ currentHash = hash;
+ if (msie.iframe) {
+ location.hash = currentHash;
+ }
+ var current = $.history.getCurrent();
+ $.event.trigger('history', [current, previousNav]);
+ previousNav = current;
+ }
+ };
+
+ $.history = {
+ add: function(hash) {
+ hash = '#' + hash.replace(hashTrim, '');
+ if (currentHash != hash) {
+ var previous = $.history.getCurrent();
+ location.hash = currentHash = hash;
+ if (msie.iframe) {
+ msie.setHash(currentHash);
+ }
+ $.event.trigger('historyadd', [$.history.getCurrent(), previous]);
+ }
+ if (!timer) {
+ timer = setInterval(historycheck, 100);
+ }
+ },
+ getCurrent: function() {
+ if (currentHash) {
+ return currentHash.replace(hashTrim, '');
+ } else {
+ return "";
+ }
+ }
+ };
+
+ $.fn.history = function(fn) {
+ $(this).bind('history', fn);
+ };
+
+ $.fn.historyadd = function(fn) {
+ $(this).bind('historyadd', fn);
+ };
+
+ $(function() {
+ currentHash = location.hash;
+ if ($.browser.msie) {
+ msie.iframe = $('<iframe style="display:none" src="javascript:false;"></iframe>').prependTo('body')[0];
+ msie.setHash(currentHash);
+ currentHash = msie.getHash();
+ }
+ });
+})(jQuery);