added onhashchange handling...

Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
Alex A. Naanou 2015-12-30 04:47:11 +03:00
parent 6b16845856
commit 0672387994

View File

@ -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 = var URLHash =
module.URLHash = core.ImageGridFeatures.Feature({ module.URLHash = core.ImageGridFeatures.Feature({
title: '', title: 'Handle URL hash',
doc: '', doc: '',
tag: 'ui-url-hash', tag: 'ui-url-hash',
depends: ['ui'], depends: ['ui'],
//isApplicable: function(){
// return typeof(location) != 'undefined' && location.hash != null },
isApplicable: function(){ return this.runtime == 'browser' }, isApplicable: function(){ return this.runtime == 'browser' },
handlers: [ 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', ['focusImage',
function(res, a){ function(res, a){
if(this.current && this.current != ''){ if(this.current && this.current != ''){