Author: kishore
Date: Thu Mar 23 05:37:25 2017
New Revision: 1788174
URL: http://svn.apache.org/viewvc?rev=1788174&view=rev
Log:
Remove dependency on jquery.history.js, using HTML5 History API.
Removed:
manifoldcf/branches/CONNECTORS-1196-2/framework/crawler-ui/src/main/webapp/javascript/jquery.history.js
Modified:
manifoldcf/branches/CONNECTORS-1196-2/framework/crawler-ui/src/main/webapp/index.jsp
manifoldcf/branches/CONNECTORS-1196-2/framework/crawler-ui/src/main/webapp/javascript/app.js
Modified:
manifoldcf/branches/CONNECTORS-1196-2/framework/crawler-ui/src/main/webapp/index.jsp
URL:
http://svn.apache.org/viewvc/manifoldcf/branches/CONNECTORS-1196-2/framework/crawler-ui/src/main/webapp/index.jsp?rev=1788174&r1=1788173&r2=1788174&view=diff
==============================================================================
---
manifoldcf/branches/CONNECTORS-1196-2/framework/crawler-ui/src/main/webapp/index.jsp
(original)
+++
manifoldcf/branches/CONNECTORS-1196-2/framework/crawler-ui/src/main/webapp/index.jsp
Thu Mar 23 05:37:25 2017
@@ -87,7 +87,6 @@
<!-- Bootstrap Select -->
<script src="bootstrap-select/js/bootstrap-select.min.js"
type="text/javascript"></script>
<script src="javascript/jquery.slimscroll.min.js"
type="text/javascript"></script>
- <script src="javascript/jquery.history.js" type="text/javascript"></script>
<!-- ManifoldCF -->
<script src="javascript/app.js" type="text/javascript"></script>
<%
Modified:
manifoldcf/branches/CONNECTORS-1196-2/framework/crawler-ui/src/main/webapp/javascript/app.js
URL:
http://svn.apache.org/viewvc/manifoldcf/branches/CONNECTORS-1196-2/framework/crawler-ui/src/main/webapp/javascript/app.js?rev=1788174&r1=1788173&r2=1788174&view=diff
==============================================================================
---
manifoldcf/branches/CONNECTORS-1196-2/framework/crawler-ui/src/main/webapp/javascript/app.js
(original)
+++
manifoldcf/branches/CONNECTORS-1196-2/framework/crawler-ui/src/main/webapp/javascript/app.js
Thu Mar 23 05:37:25 2017
@@ -395,7 +395,7 @@ function _preLoadContent()
function _postLoadContent()
{
- console.log('_postLoadContent')
+ console.log('_postLoadContent');
//Activate Bootstrap tooltip
$($.ManifoldCF.options.BSTooltipSelector).tooltip({
trigger: 'hover',
@@ -423,11 +423,10 @@ $.ManifoldCF.submit=function (form)
{
$('.overlay,#loader').show();
var $form=$(form);
- var action=$form.attr('action')
+ var action=$form.attr('action');
console.log("Ajax URL: " + action);
console.log($form.serialize());
_preLoadContent();
- //History.replaceState({urlPath: encodeURI(action)}, null,
'#execute_'+form.name);
$.ajax({
type: $form.attr('method'),
url: action,
@@ -438,10 +437,11 @@ $.ManifoldCF.submit=function (form)
console.log("page: " + page)
if (typeof page != 'undefined')
{
- History.replaceState({urlPath: encodeURI(page)},null,'?p=' + page +
'#execute');
- } else
+ window.history.replaceState({urlPath: encodeURI(page)},null,'?p=' + page
+ '#execute');
+ }
+ else
{
- History.replaceState({urlPath: encodeURI(action)},null,'#execute_' +
form.name);
+ window.history.replaceState({urlPath:
encodeURI(action)},null,'#execute_' + form.name);
}
console.log("textStatus: " + textStatus);
$('#content').html(data);
@@ -455,43 +455,36 @@ $.ManifoldCF.submit=function (form)
});
}
-$(function ()
-{
- var
- History=window.History,
- State;
-
- if (History.enabled)
- {
- State=History.getState();
- // set initial state to first page that was loaded
- History.pushState({urlPath: window.location.pathname},null,State.urlPath);
- }
- else
- {
- return false;
- }
-
- // Content update and back/forward button handler
- History.Adapter.bind(window,'statechange',function ()
- {
- var state=History.getState();
- console.log(state);
- if (typeof state != 'undefined' && typeof state.data != 'undefined')
+window.onpopstate = function (event) {
+ console.log('historyEvent:',event);
+ if (event.state) {
+ // history changed because of pushState/replaceState
+ var state=window.history.state;
+ if (typeof state != 'undefined')
{
- if (!state.data.urlPath.startsWith('execute'))
+ if (!state.urlPath.startsWith('execute'))
{
- $.ManifoldCF.loadContent(state.data.urlPath);
+ $.ManifoldCF.loadContent(state.urlPath);
}
}
- });
+ }
+ else
+ {
+ console.log('history changed because of a page load');
+ }
+}
+$(function(){
// navigation link handler
$(document.body).on("click",'.link',function (e)
{
e.preventDefault();
var urlPath=$(this).attr('href');
var title=$(this).text();
- History.pushState({urlPath: encodeURI(urlPath)},title,'?p=' +
encodeURI(urlPath) + '&_' + new Date().getTime());
+
+ $.ManifoldCF.loadContent(urlPath);
+
+ var data = {urlPath: encodeURIComponent(urlPath)};
+ window.history.pushState(data,title,'?p=' + encodeURIComponent(urlPath) +
'&_' + new Date().getTime());
});
});