///
///
///
Umbraco.Sys.registerNamespace("Umbraco.Controls");
(function($) {
Umbraco.Controls.HistoryManager = function() {
/// This is a wrapper for the bbq plugin history manager, but we could do alot with history mgmt in the future!
var obj = {
onNavigate: function(e) {
var l = $.param.fragment();
if (l != "") {
jQuery(window.top).trigger("navigating", [$.param.fragment()]); //raise event!
}
},
addHistory: function(name, forceRefresh) {
if ($.param.fragment() == name && forceRefresh) {
this.onNavigate();
}
else {
$.bbq.pushState(name, 2);
}
},
getCurrent: function() {
return ($.param.fragment().length > 0) ? $.param.fragment() : "";
},
addEventHandler: function(fnName, fn) {
/// Adds an event listener to the event name event
if (typeof (jQuery) != "undefined") jQuery(window.top).bind(fnName, fn); //if there's no jQuery, there is no events
},
removeEventHandler: function(fnName, fn) {
/// Removes an event listener to the event name event
if (typeof (jQuery) != "undefined") jQuery(window.top).unbind(fnName, fn); //if there's no jQuery, there is no events
}
};
//wire up the navigate events, wrap method to maintain scope
$(window).bind('hashchange', function(e) { obj.onNavigate.call(obj); });
return obj;
};
})(jQuery);