Plugin Directory

Changeset 2818074


Ignore:
Timestamp:
11/15/2022 07:48:25 AM (3 years ago)
Author:
majick
Message:

1.0.5 trunk commit

Location:
teleporter/trunk
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • teleporter/trunk/js/teleporter.dev.js

    r2817374 r2818074  
    533533    if (!teleporter.dynamic.length) {return;}
    534534    var dynamic_classes = '';
    535     for (i = 0; i < dynamic.length; i++) {
     535    for (i = 0; i < teleporter.dynamic.length; i++) {
    536536        if (dynamic_classes != '') {dynamic_classes += ', ';}
    537         dynamic_classes += '.'+dynamic[i];
    538     }   
     537        dynamic_classes += '.'+teleporter.dynamic[i];
     538    }
     539    if (teleporter.debug) {console.log('Dynamic Classes: '+dynamic_classes);}
    539540    jQuery('a').on('click', dynamic_classes, function(e) {
     541        e.stopImmediatePropagation();
     542        e.preventDefault();
    540543        target = jQuery(e.target);
    541544        if (target.prop('tagName') != 'a') {target = target.closest('a');}
     
    544547        skip = teleporter_skip_link(element);
    545548        if (!skip) {
    546             e.stopImmediatePropagation();
    547             e.preventDefault();
     549            if (teleporter.debug) {console.log(target);}
    548550            return teleporter_transition_page(element);
    549551        }
     
    566568        teleporter_custom_event('teleporter-check-links', false);
    567569        teleporter_add_link_events();
     570        /* 1.0.5: load dynamic link clicks automatically */
     571        teleporter_dynamic_link_clicks();
    568572        teleporter_custom_event('teleporter-links-checked', false);
    569573        teleporter_transition_check(false, window);
  • teleporter/trunk/js/teleporter.js

    r2817374 r2818074  
    365365    if (!teleporter.dynamic.length) {return;}
    366366    var dynamic_classes = '';
    367     for (i = 0; i < dynamic.length; i++) {
     367    for (i = 0; i < teleporter.dynamic.length; i++) {
    368368        if (dynamic_classes != '') {dynamic_classes += ', ';}
    369         dynamic_classes += '.'+dynamic[i];
    370     }   
     369        dynamic_classes += '.'+teleporter.dynamic[i];
     370    }
     371    if (teleporter.debug) {console.log('Dynamic Classes: '+dynamic_classes);}
    371372    jQuery('a').on('click', dynamic_classes, function(e) {
     373        e.stopImmediatePropagation();
     374        e.preventDefault();
    372375        target = jQuery(e.target);
    373376        if (target.prop('tagName') != 'a') {target = target.closest('a');}
     
    376379        skip = teleporter_skip_link(element);
    377380        if (!skip) {
    378             e.stopImmediatePropagation();
    379             e.preventDefault();
     381            if (teleporter.debug) {console.log(target);}
    380382            return teleporter_transition_page(element);
    381383        }
     
    388390        teleporter_custom_event('teleporter-check-links', false);
    389391        teleporter_add_link_events();
     392        teleporter_dynamic_link_clicks();
    390393        teleporter_custom_event('teleporter-links-checked', false);
    391394        teleporter_transition_check(false, window);
  • teleporter/trunk/js/teleporter.min.js

    r2817374 r2818074  
    1 var teleporter = {debug: false, fadetime: 2000, timeout: 10000, ignore: ['no-transition','no-teleporter'], dynamic: [], iframe: 'teleporter-iframe', loading: 'teleporter-loading', 'siteurl': ''};  var t_topwin; t_topwin = teleporter_top_window();  if (typeof t_topwin.t_loading == 'undefined') {t_topwin.t_loading = false;}  if (typeof t_topwin.t_loaded == 'undefined') {t_topwin.t_loaded = false;}  if (typeof t_topwin.t_pushing == 'undefined') {t_topwin.t_pushing = false;}  if (typeof t_topwin.t_initialurl == 'undefined') {t_topwin.t_initialurl = window.location.href;}  if (typeof t_topwin.t_poppedstate == 'undefined') {  if  (typeof t_topwin.History == 'function') {t_topwin.t_poppedstate = t_topwin.History.getState();}  else {t_topwin.t_poppedstate = ('state' in t_topwin.history && t_topwin.history.state !== null);}  }  function teleporter_transition_page(link) {  if ((typeof History != 'function') && !window.history) {return true;}  if (typeof t_topwin.stateurls !== 'undefined') {  stateurls = t_topwin.stateurls;  for (i in stateurls) {  if (stateurls[i] == link.href) {  if (i == t_topwin.currentstate) {return false;}  teleporter_switch_state(i);  title = t_topwin.statetitles[i];  var obj = {id: i, title: title, url: link.href};  t_topwin.t_pushing = true;  if (typeof t_topwin.History == 'function') {t_topwin.History.replaceState(obj, title, link.href);}  else if (t_topwin.history) {t_topwin.history.replaceState(obj, title, link.href);}  t_topwin.t_pushing = false;  t_topwin.currentstate = i;  return false;  }  }  }  iframe = teleporter_add_iframe(link.href);  teleporter_show_loading(link.href);  return false;  }  function teleporter_transition_check(url, win) {  href = null; iframe = null; topdoc = t_topwin.document;  if (t_topwin != win.self) {  iframes = topdoc.getElementsByClassName(teleporter.iframe);  if (!url) {url = win.location.href;}  for (i = 0; i < iframes.length; i++) {  if (url == iframes[i].src) {iframe = iframes[i];}  }  if (!iframe) {  return;  }  if (iframe.src != t_topwin.location.href) {  teleporter_hide_loading();      body = topdoc.getElementsByTagName('body')[0];      if (!t_topwin.bodymargin) {t_topwin.bodymargin = body.style.margin;}      if (!t_topwin.bodypadding) {t_topwin.bodypadding = body.style.padding;}      body.style.margin = '0'; body.style.padding = '0'; body.style.overflow = 'hidden';  if (iframe.style.display != 'block') {  if ((typeof t_topwin.jQuery == 'function') && teleporter.fadetime) {  t_topwin.jQuery(iframe).fadeIn(teleporter.fadetime);  } else {iframe.style.display = 'block';}  }  href = iframe.src;      }  } else {href = win.location.href;}  if (href) {  stateid = teleporter_push_state(href, win);  if (iframe) {iframe.setAttribute('id', teleporter.iframe+'-'+stateid);}  }  }  function teleporter_push_state(href, win) {  titletag = win.document.getElementsByTagName('title');  if (titletag.length) {title = titletag[0].innerHTML;} else {title = '';}  if (typeof t_topwin.statecount === 'undefined') {  t_topwin.statecount = 0; t_topwin.windowstateid = 0; stateid = 0;  stateurls = []; stateurls[0] = href; t_topwin.stateurls = stateurls;  statetitles = []; statetitles[0] = title; t_topwin.statetitles = statetitles;  } else {  t_topwin.statecount++; stateid = t_topwin.statecount;  if ((t_topwin != win.self) && (typeof win.windowstateid == 'undefined') ) {  win.windowstateid = stateid;  t_topwin.stateurls[stateid] = href;  t_topwin.statetitles[stateid] = title;  }  }  var obj = {id: stateid, title: title, url: href};  t_topwin.t_pushing = true;  if (typeof t_topwin.History == 'function') {t_topwin.History.pushState(obj, title, href);}  else if (t_topwin.history) {t_topwin.history.pushState(obj, title, href);}  t_topwin.t_pushing = false;  teleporter_custom_event('teleporter-state-pushed', obj);  t_topwin.currentstate = stateid;  t_topwin.t_loaded = t_topwin.t_loading; t_topwin.t_loading = false;  return stateid;  }  function teleporter_show_loading(href) {  t_topwin.t_loading = href;  setTimeout(function() {  if (!t_topwin.t_loading) {return;}  href = t_topwin.t_loading;  console.log('Page load timeout reached. Displaying URL: '+href);  iframes = t_topwin.document.getElementsByClassName(teleporter.iframe);   for (i = 0; i < iframes.length; i++) {   if (href == iframes[i].src) {iframe = iframes[i];}  }  if (!iframe) {return;}  win = iframe.contentWindow;  teleporter_transition_check(href, win);  }, teleporter.timeout);  if (!teleporter.loading) {return;}  topdoc = t_topwin.document;  topdoc.getElementsByTagName('body')[0].classList.add('teleporter-loading');  topdoc.getElementById(teleporter.loading).className = 'reset';  setTimeout(function() {topdoc.getElementById(teleporter.loading).className = 'loading';}, 250);  iframes = topdoc.getElementsByClassName(teleporter.iframe);  for (i = 0; i < iframes.length; i++) {  doc = iframes[i].contentDocument || iframes[i].contentWindow.document;  if (doc.getElementById(teleporter.loading)) {doc.getElementById(teleporter.loading).className = 'reset';}  }  setTimeout(function() {  for (i = 0; i < iframes.length; i++) {  doc = iframes[i].contentDocument || iframes[i].contentWindow.document;  body = doc.getElementsByTagName('body')[0];  if (body) {body.classList.add('teleporter-loading');}  if (doc.getElementById(teleporter.loading)) {doc.getElementById(teleporter.loading).className = 'loading';}  }  }, 250);  }  function teleporter_hide_loading() {  if (!teleporter.loading) {return;}  topdoc = t_topwin.document;  topdoc.getElementById(teleporter.loading).className = '';  topdoc.getElementsByTagName('body')[0].classList.remove('teleporter-loading');  iframes = topdoc.getElementsByClassName(teleporter.iframe);  for (i = 0; i < iframes.length; i++) {  doc = iframes[i].contentDocument || iframes[i].contentWindow.document;  body = doc.getElementsByTagName('body')[0];  if (body) {body.classList.remove('teleporter-loading');}  if (doc.getElementById(teleporter.loading)) {doc.getElementById(teleporter.loading).className = '';}  }  }  function teleporter_add_popstate_checker() {  if (typeof window.History == 'function') {  (function(window,undefined) {  History.Adapter.bind(window, 'statechange', function (event) {  teleporter_custom_event('teleporter-popstate-event', {event: event});  teleporter_popstate_checker(event);  });  })(window);  } else {  window.addEventListener('popstate', function(event) {  teleporter_custom_event('teleporter-popstate-event', {event: event});  teleporter_popstate_checker(event);  }, false );  }  }  function teleporter_popstate_checker(event) {  t_topwin.initialpop = !t_topwin.t_poppedstate && (window.location.href == t_topwin.t_initialurl);  t_topwin.t_poppedstate = true; if (t_topwin.initialpop) {return;}  if (t_topwin.t_pushing) {return;}  if ((typeof t_topwin.backclicked != 'undefined') && t_topwin.backclicked) {  t_topwin.backclicked = false; return;  }  stateid = null;  if (event.state) {console.log('Event State'); console.log(event);}  if  (typeof t_topwin.History != 'undefined') {  state = t_topwin.History.getState();  if (state.data.id) {stateid = state.data.id;}  else {  for (i = 0; i < t_topwin.stateurls.length; i++) {  if (stateurls[i] == state.url) {stateid = i;}  }  }  } else if (t_topwin.history) {  if (event.state) {state = event.state; stateid = state.id;}  else if (t_topwin.history.state) {state = t_topwin.history.state; stateid = state.id;}  else {return true;}  } else {return true;}  if ((stateid === null) || (t_topwin.stateurls == 'undefined') || (state.url != t_topwin.stateurls[stateid])) {  if (state.url == t_topwin.t_initialurl) {  t_topwin.backclicked = true;  if (typeof t_topwin.History == 'function') {t_topwin.History.back();}  else if (t_topwin.history) {history.back();}  } else {  teleporter_transition_page({href: state.url});  }  return;  }  if (event.preventDefault) {event.preventDefault();}  if (event.stopImmediatePropagation) {event.stopImmediatePropagation();}  teleporter_switch_state(stateid);  }  function teleporter_switch_state(stateid) {  if (typeof t_topwin.windowstateid == 'undefined') {return;}  if (typeof t_topwin.currentstate != 'undefined') {currentstate = t_topwin.currentstate;}  else {currentstate = 0; t_topwin.currentstate = 0;}  if (stateid == currentstate) {return;}  teleporter_custom_event('teleporter-switch-state', {stateid: stateid});  iframes = t_topwin.document.getElementsByClassName(teleporter.iframe);  iframe = false;  for (i = 0; i < iframes.length; i++) {  if (iframes[i].id == teleporter.iframe+'-'+stateid) {  iframe = iframes[i]; j = i;  }  }  if (t_topwin.windowstateid == stateid) {  body = t_topwin.document.getElementsByTagName('body')[0];  body.style.margin = t_topwin.bodymargin;  body.style.padding = t_topwin.bodypadding;  body.style.overflow = 'scroll';  for (i = 0; i < iframes.length; i++) {  if (iframes[i].style.display != 'none') {  if ((typeof jQuery == 'function') && teleporter.fadetime) {  jQuery(iframes[i]).fadeOut(teleporter.fadetime);  } else {iframes[i].style.display = 'none';}  }  }  t_topwin.currentstate = 0;  } else if (iframe) {  body = t_topwin.document.getElementsByTagName('body')[0];  body.style.margin = '0'; body.style.padding = '0'; body.style.overflow = 'hidden';  for (i = 0; i < iframes.length; i++) {  if ((i != j) && (iframes[i].style.display != 'none')) {  if ((typeof jQuery == 'function') && teleporter.fadetime) {  jQuery(iframes[i]).fadeOut(teleporter.fadetime);  } else {iframes[i].style.display = 'none';}  }  }  if ((typeof jQuery == 'function') && teleporter.fadetime) {  jQuery(iframe).fadeIn(teleporter.fadetime);  } else {iframe.style.display = 'block';}  }  t_topwin.document.title = t_topwin.statetitles[stateid];  t_topwin.currentstate = stateid;  teleporter_custom_event('teleporter-transitioned', {stateid: stateid});  }  function teleporter_add_iframe(src) {  iframe = document.createElement('iframe');  iframe.setAttribute('class', teleporter.iframe);  iframe.setAttribute('name', teleporter.iframe);  iframe.setAttribute('src', src);  iframe.setAttribute('width', '100%');  iframe.setAttribute('height', '100%');  iframe.setAttribute('frameborder', '0');  iframe.setAttribute('scrolling', 'auto');  iframe.setAttribute('allowfullscreen', 'true');  iframe.setAttribute('style', 'display:none;');  t_topwin.document.getElementsByTagName('body')[0].appendChild(iframe);  return iframe;  }  function teleporter_skip_link(el) {  if (el.getAttribute('teleporter') == '1') {return true;}  if ((typeof el.href == 'undefined') || (el.href == '')) {return true;}  if ((typeof el.target != 'undefined') && (el.target != null) && (el.target != '_self') && (el.target != '')) {return true;}  if ((typeof el.onclick != 'undefined') && (el.onclick != null) && (el.onclick != '')) {return true;}  u = el.href; skip = true;  if ((u.indexOf('javascript') === 0) || (u.indexOf('mailto') === 0) || (u.indexOf('tel') === 0)) {return true;}  if ((u.indexOf('#') === 0) || (u.indexOf('?') === 0)) {skip = false;}  if ((teleporter.siteurl != '') && (u.indexOf(teleporter.siteurl) === 0)) {skip = false;}  if (el.host == t_topwin.location.host) {  a = t_topwin.location.protocol+'//'+t_topwin.location.host;  b = '//'+t_topwin.location.host;  if ((u.indexOf(a) === 0) || (u.indexOf(b) === 0)) {skip = false;}  }  if (!skip && teleporter.ignore.length && (typeof el.classList != 'undefined') && el.classList.length) {  for (i in teleporter.ignore) {  if (el.classList.contains(teleporter.ignore[i])) {skip = true;}  }  }  if (teleporter.debug) {if (!skip) {console.log('Found internal URL: '+u);} }  return skip;  }  addEventListener('unload', function(event) {  t_topwin.windowstateid = 'undefined';  }, false);  function teleporter_top_window() {  try {test = window.top.location; return window.top;} catch(e) {  return teleporter_get_window_parent(window.self);  }  }  function teleporter_get_window_parent(win) {  parentwindow = false;  try {test = win.parent.location; parentwindow = win.parent;} catch(e) {return false;}  if (parentwindow) {  if (parentwindow == win) {return win;}  maybe = teleporter_get_window_parent(parentwindow);  if (maybe) {return maybe;}  return parentwindow;  }  return win;  }  function teleporter_add_link_events() {  jQuery('a').each(function() {  el = jQuery(this)[0];  skip = teleporter_skip_link(el);  if (!skip) {  ev = jQuery._data(el, 'events');  if (ev && ev.click && teleporter.debug) {console.log(ev.click);}  el.setAttribute('teleporter', '1');  teleporter_add_link_event(el);  }  });  }  function teleporter_add_link_event(el) {  el.addEventListener('click', function(e) {  e.stopImmediatePropagation();  e.preventDefault();  target = jQuery(e.target);  if (target.prop('tagName') != 'a') {target = target.closest('a');}  element = target[0];  return teleporter_transition_page(element);  });  }  function teleporter_add_link_onclicks() {  alinks = document.getElementsByTagName('a');  for (var i = 0; i < alinks.length; i++) {  skip = teleporter_skip_link(alinks[i]);  if (!skip) {  alinks[i].setAttribute('teleporter', '1');  teleporter_add_link_onclick(alinks[i]);  }  }  }  function teleporter_add_link_onclick(el) {  el.setAttribute('onclick', 'return teleporter_transition_page(this);');  }  function teleporter_dynamic_link_clicks() {  if (!teleporter.dynamic.length) {return;}  var dynamic_classes = '';  for (i = 0; i < dynamic.length; i++) {  if (dynamic_classes != '') {dynamic_classes += ', ';}  dynamic_classes += '.'+dynamic[i];  }  jQuery('a').on('click', dynamic_classes, function(e) {  target = jQuery(e.target);  if (target.prop('tagName') != 'a') {target = target.closest('a');}  if (target.getAttribute('teleporter') == '1') {return;}  element = target[0];  skip = teleporter_skip_link(element);  if (!skip) {  e.stopImmediatePropagation();  e.preventDefault();  return teleporter_transition_page(element);  }  });  }  if (typeof window.jQuery !== 'undefined') {  jQuery(document).ready(function() {  if (!teleporter.iframe) {return;}  if (parent.document) {document.getElementsByTagName('body')[0].style.overflow = 'scroll';}  teleporter_custom_event('teleporter-check-links', false);  teleporter_add_link_events();  teleporter_custom_event('teleporter-links-checked', false);  teleporter_transition_check(false, window);  teleporter_add_popstate_checker();  setTimeout(function() {teleporter_add_link_events();;}, 5000);  });  } else {  (function(funcName, baseObj) {  "use strict"; funcName = funcName || 'documentReady'; baseObj = baseObj || window;  var readyList = []; var readyFired = false; var readyEventHandlersInstalled = false;  function ready() {  if (!readyFired) {  readyFired = true;  for (var i = 0; i < readyList.length; i++) {  readyList[i].fn.call(window, readyList[i].ctx);  }  readyList = [];  }  }  function readyStateChange() {if (document.readyState === "complete") {ready();} }  baseObj[funcName] = function(callback, context) {  if (readyFired) {setTimeout(function() {callback(context);}, 1); return;}  else {readyList.push({fn: callback, ctx: context});}  if (document.readyState === 'complete' || (!document.attachEvent && document.readyState === 'interactive')) {  setTimeout(ready, 1);  } else if (!readyEventHandlersInstalled) {  if (document.addEventListener) {  document.addEventListener('DOMContentLoaded', ready, false);  window.addEventListener('load', ready, false);  } else {  document.attachEvent('onreadystatechange', readyStateChange);  window.attachEvent('onload', ready);  }  readyEventHandlersInstalled = true;  }  }  })('documentReady', window);  window.documentReady(function() {  if (!teleporter.iframe) {return;}  if (parent.document) {document.getElementsByTagName('body')[0].style.overflow = 'scroll';}  teleporter_custom_event('teleporter-check-links', false);  teleporter_add_link_onclicks();  teleporter_custom_event('teleporter-links-checked', false);  teleporter_transition_check(false, window);  teleporter_add_popstate_checker();  setTimeout(function() {teleporter_add_link_onclicks();}, 5000);  });  }  function teleporter_custom_event(name, detail) {  params = {bubbles: false, cancelable: false, detail: detail};  var event = new CustomEvent(name, params); document.dispatchEvent(event);  }  (function () {  if (typeof window.CustomEvent === 'function') {return false;}  function CustomEvent(event, params) {  params = params || {bubbles: false, cancelable: false, detail: undefined};  var evt = document.createEvent('CustomEvent');  evt.initCustomEvent(event, params.bubbles, params.cancelable, params.detail);  return evt;  }  CustomEvent.prototype = window.Event.prototype;  window.CustomEvent = CustomEvent;  })();
     1var teleporter = {debug: false, fadetime: 2000, timeout: 10000, ignore: ['no-transition','no-teleporter'], dynamic: [], iframe: 'teleporter-iframe', loading: 'teleporter-loading', 'siteurl': ''};  var t_topwin; t_topwin = teleporter_top_window();  if (typeof t_topwin.t_loading == 'undefined') {t_topwin.t_loading = false;}  if (typeof t_topwin.t_loaded == 'undefined') {t_topwin.t_loaded = false;}  if (typeof t_topwin.t_pushing == 'undefined') {t_topwin.t_pushing = false;}  if (typeof t_topwin.t_initialurl == 'undefined') {t_topwin.t_initialurl = window.location.href;}  if (typeof t_topwin.t_poppedstate == 'undefined') {  if  (typeof t_topwin.History == 'function') {t_topwin.t_poppedstate = t_topwin.History.getState();}  else {t_topwin.t_poppedstate = ('state' in t_topwin.history && t_topwin.history.state !== null);}  }  function teleporter_transition_page(link) {  if ((typeof History != 'function') && !window.history) {return true;}  if (typeof t_topwin.stateurls !== 'undefined') {  stateurls = t_topwin.stateurls;  for (i in stateurls) {  if (stateurls[i] == link.href) {  if (i == t_topwin.currentstate) {return false;}  teleporter_switch_state(i);  title = t_topwin.statetitles[i];  var obj = {id: i, title: title, url: link.href};  t_topwin.t_pushing = true;  if (typeof t_topwin.History == 'function') {t_topwin.History.replaceState(obj, title, link.href);}  else if (t_topwin.history) {t_topwin.history.replaceState(obj, title, link.href);}  t_topwin.t_pushing = false;  t_topwin.currentstate = i;  return false;  }  }  }  iframe = teleporter_add_iframe(link.href);  teleporter_show_loading(link.href);  return false;  }  function teleporter_transition_check(url, win) {  href = null; iframe = null; topdoc = t_topwin.document;  if (t_topwin != win.self) {  iframes = topdoc.getElementsByClassName(teleporter.iframe);  if (!url) {url = win.location.href;}  for (i = 0; i < iframes.length; i++) {  if (url == iframes[i].src) {iframe = iframes[i];}  }  if (!iframe) {  return;  }  if (iframe.src != t_topwin.location.href) {  teleporter_hide_loading();      body = topdoc.getElementsByTagName('body')[0];      if (!t_topwin.bodymargin) {t_topwin.bodymargin = body.style.margin;}      if (!t_topwin.bodypadding) {t_topwin.bodypadding = body.style.padding;}      body.style.margin = '0'; body.style.padding = '0'; body.style.overflow = 'hidden';  if (iframe.style.display != 'block') {  if ((typeof t_topwin.jQuery == 'function') && teleporter.fadetime) {  t_topwin.jQuery(iframe).fadeIn(teleporter.fadetime);  } else {iframe.style.display = 'block';}  }  href = iframe.src;      }  } else {href = win.location.href;}  if (href) {  stateid = teleporter_push_state(href, win);  if (iframe) {iframe.setAttribute('id', teleporter.iframe+'-'+stateid);}  }  }  function teleporter_push_state(href, win) {  titletag = win.document.getElementsByTagName('title');  if (titletag.length) {title = titletag[0].innerHTML;} else {title = '';}  if (typeof t_topwin.statecount === 'undefined') {  t_topwin.statecount = 0; t_topwin.windowstateid = 0; stateid = 0;  stateurls = []; stateurls[0] = href; t_topwin.stateurls = stateurls;  statetitles = []; statetitles[0] = title; t_topwin.statetitles = statetitles;  } else {  t_topwin.statecount++; stateid = t_topwin.statecount;  if ((t_topwin != win.self) && (typeof win.windowstateid == 'undefined') ) {  win.windowstateid = stateid;  t_topwin.stateurls[stateid] = href;  t_topwin.statetitles[stateid] = title;  }  }  var obj = {id: stateid, title: title, url: href};  t_topwin.t_pushing = true;  if (typeof t_topwin.History == 'function') {t_topwin.History.pushState(obj, title, href);}  else if (t_topwin.history) {t_topwin.history.pushState(obj, title, href);}  t_topwin.t_pushing = false;  teleporter_custom_event('teleporter-state-pushed', obj);  t_topwin.currentstate = stateid;  t_topwin.t_loaded = t_topwin.t_loading; t_topwin.t_loading = false;  return stateid;  }  function teleporter_show_loading(href) {  t_topwin.t_loading = href;  setTimeout(function() {  if (!t_topwin.t_loading) {return;}  href = t_topwin.t_loading;  console.log('Page load timeout reached. Displaying URL: '+href);  iframes = t_topwin.document.getElementsByClassName(teleporter.iframe);   for (i = 0; i < iframes.length; i++) {   if (href == iframes[i].src) {iframe = iframes[i];}  }  if (!iframe) {return;}  win = iframe.contentWindow;  teleporter_transition_check(href, win);  }, teleporter.timeout);  if (!teleporter.loading) {return;}  topdoc = t_topwin.document;  topdoc.getElementsByTagName('body')[0].classList.add('teleporter-loading');  topdoc.getElementById(teleporter.loading).className = 'reset';  setTimeout(function() {topdoc.getElementById(teleporter.loading).className = 'loading';}, 250);  iframes = topdoc.getElementsByClassName(teleporter.iframe);  for (i = 0; i < iframes.length; i++) {  doc = iframes[i].contentDocument || iframes[i].contentWindow.document;  if (doc.getElementById(teleporter.loading)) {doc.getElementById(teleporter.loading).className = 'reset';}  }  setTimeout(function() {  for (i = 0; i < iframes.length; i++) {  doc = iframes[i].contentDocument || iframes[i].contentWindow.document;  body = doc.getElementsByTagName('body')[0];  if (body) {body.classList.add('teleporter-loading');}  if (doc.getElementById(teleporter.loading)) {doc.getElementById(teleporter.loading).className = 'loading';}  }  }, 250);  }  function teleporter_hide_loading() {  if (!teleporter.loading) {return;}  topdoc = t_topwin.document;  topdoc.getElementById(teleporter.loading).className = '';  topdoc.getElementsByTagName('body')[0].classList.remove('teleporter-loading');  iframes = topdoc.getElementsByClassName(teleporter.iframe);  for (i = 0; i < iframes.length; i++) {  doc = iframes[i].contentDocument || iframes[i].contentWindow.document;  body = doc.getElementsByTagName('body')[0];  if (body) {body.classList.remove('teleporter-loading');}  if (doc.getElementById(teleporter.loading)) {doc.getElementById(teleporter.loading).className = '';}  }  }  function teleporter_add_popstate_checker() {  if (typeof window.History == 'function') {  (function(window,undefined) {  History.Adapter.bind(window, 'statechange', function (event) {  teleporter_custom_event('teleporter-popstate-event', {event: event});  teleporter_popstate_checker(event);  });  })(window);  } else {  window.addEventListener('popstate', function(event) {  teleporter_custom_event('teleporter-popstate-event', {event: event});  teleporter_popstate_checker(event);  }, false );  }  }  function teleporter_popstate_checker(event) {  t_topwin.initialpop = !t_topwin.t_poppedstate && (window.location.href == t_topwin.t_initialurl);  t_topwin.t_poppedstate = true; if (t_topwin.initialpop) {return;}  if (t_topwin.t_pushing) {return;}  if ((typeof t_topwin.backclicked != 'undefined') && t_topwin.backclicked) {  t_topwin.backclicked = false; return;  }  stateid = null;  if (event.state) {console.log('Event State'); console.log(event);}  if  (typeof t_topwin.History != 'undefined') {  state = t_topwin.History.getState();  if (state.data.id) {stateid = state.data.id;}  else {  for (i = 0; i < t_topwin.stateurls.length; i++) {  if (stateurls[i] == state.url) {stateid = i;}  }  }  } else if (t_topwin.history) {  if (event.state) {state = event.state; stateid = state.id;}  else if (t_topwin.history.state) {state = t_topwin.history.state; stateid = state.id;}  else {return true;}  } else {return true;}  if ((stateid === null) || (t_topwin.stateurls == 'undefined') || (state.url != t_topwin.stateurls[stateid])) {  if (state.url == t_topwin.t_initialurl) {  t_topwin.backclicked = true;  if (typeof t_topwin.History == 'function') {t_topwin.History.back();}  else if (t_topwin.history) {history.back();}  } else {  teleporter_transition_page({href: state.url});  }  return;  }  if (event.preventDefault) {event.preventDefault();}  if (event.stopImmediatePropagation) {event.stopImmediatePropagation();}  teleporter_switch_state(stateid);  }  function teleporter_switch_state(stateid) {  if (typeof t_topwin.windowstateid == 'undefined') {return;}  if (typeof t_topwin.currentstate != 'undefined') {currentstate = t_topwin.currentstate;}  else {currentstate = 0; t_topwin.currentstate = 0;}  if (stateid == currentstate) {return;}  teleporter_custom_event('teleporter-switch-state', {stateid: stateid});  iframes = t_topwin.document.getElementsByClassName(teleporter.iframe);  iframe = false;  for (i = 0; i < iframes.length; i++) {  if (iframes[i].id == teleporter.iframe+'-'+stateid) {  iframe = iframes[i]; j = i;  }  }  if (t_topwin.windowstateid == stateid) {  body = t_topwin.document.getElementsByTagName('body')[0];  body.style.margin = t_topwin.bodymargin;  body.style.padding = t_topwin.bodypadding;  body.style.overflow = 'scroll';  for (i = 0; i < iframes.length; i++) {  if (iframes[i].style.display != 'none') {  if ((typeof jQuery == 'function') && teleporter.fadetime) {  jQuery(iframes[i]).fadeOut(teleporter.fadetime);  } else {iframes[i].style.display = 'none';}  }  }  t_topwin.currentstate = 0;  } else if (iframe) {  body = t_topwin.document.getElementsByTagName('body')[0];  body.style.margin = '0'; body.style.padding = '0'; body.style.overflow = 'hidden';  for (i = 0; i < iframes.length; i++) {  if ((i != j) && (iframes[i].style.display != 'none')) {  if ((typeof jQuery == 'function') && teleporter.fadetime) {  jQuery(iframes[i]).fadeOut(teleporter.fadetime);  } else {iframes[i].style.display = 'none';}  }  }  if ((typeof jQuery == 'function') && teleporter.fadetime) {  jQuery(iframe).fadeIn(teleporter.fadetime);  } else {iframe.style.display = 'block';}  }  t_topwin.document.title = t_topwin.statetitles[stateid];  t_topwin.currentstate = stateid;  teleporter_custom_event('teleporter-transitioned', {stateid: stateid});  }  function teleporter_add_iframe(src) {  iframe = document.createElement('iframe');  iframe.setAttribute('class', teleporter.iframe);  iframe.setAttribute('name', teleporter.iframe);  iframe.setAttribute('src', src);  iframe.setAttribute('width', '100%');  iframe.setAttribute('height', '100%');  iframe.setAttribute('frameborder', '0');  iframe.setAttribute('scrolling', 'auto');  iframe.setAttribute('allowfullscreen', 'true');  iframe.setAttribute('style', 'display:none;');  t_topwin.document.getElementsByTagName('body')[0].appendChild(iframe);  return iframe;  }  function teleporter_skip_link(el) {  if (el.getAttribute('teleporter') == '1') {return true;}  if ((typeof el.href == 'undefined') || (el.href == '')) {return true;}  if ((typeof el.target != 'undefined') && (el.target != null) && (el.target != '_self') && (el.target != '')) {return true;}  if ((typeof el.onclick != 'undefined') && (el.onclick != null) && (el.onclick != '')) {return true;}  u = el.href; skip = true;  if ((u.indexOf('javascript') === 0) || (u.indexOf('mailto') === 0) || (u.indexOf('tel') === 0)) {return true;}  if ((u.indexOf('#') === 0) || (u.indexOf('?') === 0)) {skip = false;}  if ((teleporter.siteurl != '') && (u.indexOf(teleporter.siteurl) === 0)) {skip = false;}  if (el.host == t_topwin.location.host) {  a = t_topwin.location.protocol+'//'+t_topwin.location.host;  b = '//'+t_topwin.location.host;  if ((u.indexOf(a) === 0) || (u.indexOf(b) === 0)) {skip = false;}  }  if (!skip && teleporter.ignore.length && (typeof el.classList != 'undefined') && el.classList.length) {  for (i in teleporter.ignore) {  if (el.classList.contains(teleporter.ignore[i])) {skip = true;}  }  }  if (teleporter.debug) {if (!skip) {console.log('Found internal URL: '+u);} }  return skip;  }  addEventListener('unload', function(event) {  t_topwin.windowstateid = 'undefined';  }, false);  function teleporter_top_window() {  try {test = window.top.location; return window.top;} catch(e) {  return teleporter_get_window_parent(window.self);  }  }  function teleporter_get_window_parent(win) {  parentwindow = false;  try {test = win.parent.location; parentwindow = win.parent;} catch(e) {return false;}  if (parentwindow) {  if (parentwindow == win) {return win;}  maybe = teleporter_get_window_parent(parentwindow);  if (maybe) {return maybe;}  return parentwindow;  }  return win;  }  function teleporter_add_link_events() {  jQuery('a').each(function() {  el = jQuery(this)[0];  skip = teleporter_skip_link(el);  if (!skip) {  ev = jQuery._data(el, 'events');  if (ev && ev.click && teleporter.debug) {console.log(ev.click);}  el.setAttribute('teleporter', '1');  teleporter_add_link_event(el);  }  });  }  function teleporter_add_link_event(el) {  el.addEventListener('click', function(e) {  e.stopImmediatePropagation();  e.preventDefault();  target = jQuery(e.target);  if (target.prop('tagName') != 'a') {target = target.closest('a');}  element = target[0];  return teleporter_transition_page(element);  });  }  function teleporter_add_link_onclicks() {  alinks = document.getElementsByTagName('a');  for (var i = 0; i < alinks.length; i++) {  skip = teleporter_skip_link(alinks[i]);  if (!skip) {  alinks[i].setAttribute('teleporter', '1');  teleporter_add_link_onclick(alinks[i]);  }  }  }  function teleporter_add_link_onclick(el) {  el.setAttribute('onclick', 'return teleporter_transition_page(this);');  }  function teleporter_dynamic_link_clicks() {  if (!teleporter.dynamic.length) {return;}  var dynamic_classes = '';  for (i = 0; i < teleporter.dynamic.length; i++) {  if (dynamic_classes != '') {dynamic_classes += ', ';}  dynamic_classes += '.'+teleporter.dynamic[i];  }  if (teleporter.debug) {console.log('Dynamic Classes: '+dynamic_classes);}  jQuery('a').on('click', dynamic_classes, function(e) {  e.stopImmediatePropagation();  e.preventDefault();  target = jQuery(e.target);  if (target.prop('tagName') != 'a') {target = target.closest('a');}  if (target.getAttribute('teleporter') == '1') {return;}  element = target[0];  skip = teleporter_skip_link(element);  if (!skip) {  if (teleporter.debug) {console.log(target);}  return teleporter_transition_page(element);  }  });  }  if (typeof window.jQuery !== 'undefined') {  jQuery(document).ready(function() {  if (!teleporter.iframe) {return;}  if (parent.document) {document.getElementsByTagName('body')[0].style.overflow = 'scroll';}  teleporter_custom_event('teleporter-check-links', false);  teleporter_add_link_events();  teleporter_dynamic_link_clicks();  teleporter_custom_event('teleporter-links-checked', false);  teleporter_transition_check(false, window);  teleporter_add_popstate_checker();  setTimeout(function() {teleporter_add_link_events();;}, 5000);  });  } else {  (function(funcName, baseObj) {  "use strict"; funcName = funcName || 'documentReady'; baseObj = baseObj || window;  var readyList = []; var readyFired = false; var readyEventHandlersInstalled = false;  function ready() {  if (!readyFired) {  readyFired = true;  for (var i = 0; i < readyList.length; i++) {  readyList[i].fn.call(window, readyList[i].ctx);  }  readyList = [];  }  }  function readyStateChange() {if (document.readyState === "complete") {ready();} }  baseObj[funcName] = function(callback, context) {  if (readyFired) {setTimeout(function() {callback(context);}, 1); return;}  else {readyList.push({fn: callback, ctx: context});}  if (document.readyState === 'complete' || (!document.attachEvent && document.readyState === 'interactive')) {  setTimeout(ready, 1);  } else if (!readyEventHandlersInstalled) {  if (document.addEventListener) {  document.addEventListener('DOMContentLoaded', ready, false);  window.addEventListener('load', ready, false);  } else {  document.attachEvent('onreadystatechange', readyStateChange);  window.attachEvent('onload', ready);  }  readyEventHandlersInstalled = true;  }  }  })('documentReady', window);  window.documentReady(function() {  if (!teleporter.iframe) {return;}  if (parent.document) {document.getElementsByTagName('body')[0].style.overflow = 'scroll';}  teleporter_custom_event('teleporter-check-links', false);  teleporter_add_link_onclicks();  teleporter_custom_event('teleporter-links-checked', false);  teleporter_transition_check(false, window);  teleporter_add_popstate_checker();  setTimeout(function() {teleporter_add_link_onclicks();}, 5000);  });  }  function teleporter_custom_event(name, detail) {  params = {bubbles: false, cancelable: false, detail: detail};  var event = new CustomEvent(name, params); document.dispatchEvent(event);  }  (function () {  if (typeof window.CustomEvent === 'function') {return false;}  function CustomEvent(event, params) {  params = params || {bubbles: false, cancelable: false, detail: undefined};  var evt = document.createEvent('CustomEvent');  evt.initCustomEvent(event, params.bubbles, params.cancelable, params.detail);  return evt;  }  CustomEvent.prototype = window.Event.prototype;  window.CustomEvent = CustomEvent;  })();
  • teleporter/trunk/readme.txt

    r2817374 r2818074  
    55Requires at least: 4.0.0
    66Tested up to: 6.1
    7 Stable tag: 1.0.4
     7Stable tag: 1.0.5
    88License: GPLv2 or later
    99License URI: http://www.gnu.org/licenses/gpl-2.0.html
     
    6969== Changelog ==
    7070
     71= 1.0.5 =
     72* Hotfix: automatically load dynamic link check
     73
    7174= 1.0.4 =
    7275* Updated: Plugin Panel (1.2.8)
  • teleporter/trunk/teleporter.php

    r2817374 r2818074  
    66Author: Tony Hayes
    77Description: Seamless fading Page Transitions via the Browser History API
    8 Version: 1.0.4
     8Version: 1.0.5
    99Author URI: http://wordquest.org
    1010GitHub Plugin URI: majick777/teleporter
     
    251251    ),
    252252
     253    // --- Script Debug Mode ---
     254    // 1.0.5: added for script debugging
     255    'script_debug' => array(
     256        'type'    => 'checkbox',
     257        'label'   => __( 'Debug Mode', 'teleporter' ),
     258        'value'    => 'yes',
     259        'default' => '',
     260        'helper'  => __( 'Use unminified script and output console debug messages.', 'teleporter' ),
     261        'section' => 'advanced',
     262    ),
     263
    253264    // --- Section Titles ---
    254265    'sections' => array(
     
    359370    // 0.9.7: fix to debug mode via querystring
    360371    // 1.0.4: allow for .dev script extension debugging via querystring
     372    $teleporter_debug = teleporter_get_setting( 'script_debug' );
    361373    if ( defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ) {
     374        $suffix = '';
     375    } elseif ( 'yes' == $teleporter_debug ) {
    362376        $suffix = '';
    363377    } elseif ( isset( $_REQUEST['teleporter-debug'] ) ) {
     
    390404
    391405    // --- set debug mode ---
    392     $debug = 'false';
    393     if ( isset( $_REQUEST['teleporter-debug'] ) && ( '1' == $_REQUEST['teleporter-debug'] ) ) {
     406    $debug = ( 'yes' == teleporter_get_setting( 'script_debug' ) ) ? 'true' : 'false';
     407    if ( isset( $_REQUEST['teleporter-debug'] ) ) {
    394408        $debug = 'true';
    395409    }
Note: See TracChangeset for help on using the changeset viewer.