From 0672387994d3b79460a3a7531e01bbf8b3846785 Mon Sep 17 00:00:00 2001 From: "Alex A. Naanou" Date: Wed, 30 Dec 2015 04:47:11 +0300 Subject: [PATCH] added onhashchange handling... Signed-off-by: Alex A. Naanou --- ui (gen4)/features/ui.js | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/ui (gen4)/features/ui.js b/ui (gen4)/features/ui.js index 03ef5436..628d43af 100755 --- a/ui (gen4)/features/ui.js +++ b/ui (gen4)/features/ui.js @@ -2783,18 +2783,37 @@ module.DirectControlGSAP = core.ImageGridFeatures.Feature({ //--------------------------------------------------------------------- -// XXX make this browser specific... (???) +// XXX make this work for external links in a stable manner... var URLHash = module.URLHash = core.ImageGridFeatures.Feature({ - title: '', + title: 'Handle URL hash', doc: '', tag: 'ui-url-hash', depends: ['ui'], + //isApplicable: function(){ + // return typeof(location) != 'undefined' && location.hash != null }, isApplicable: function(){ return this.runtime == 'browser' }, handlers: [ + // hanlde window.onhashchange event... + ['start', + function(){ + var that = this + var handler = this.__hashchange_handler = function(){ + var h = location.hash + h = h.replace(/^#/, '') + that.current = h + } + $(window).on('hashchange', handler) + }], + ['stop', + function(){ + this.__hashchange_handler + && $(window).on('hashchange', this.__hashchange_handler) + }], + // store/restore hash when we focus images... ['focusImage', function(res, a){ if(this.current && this.current != ''){