diff --git a/plugins/tobibeer/preview/plugin.info b/plugins/tobibeer/preview/plugin.info index f16500a..d1246f0 100644 --- a/plugins/tobibeer/preview/plugin.info +++ b/plugins/tobibeer/preview/plugin.info @@ -2,7 +2,7 @@ "title": "$:/plugins/tobibeer/preview", "description": "Shows a tiddler preview when hovering internal links", "author": "Tobias Beer", - "version": "0.5.1", + "version": "0.5.2", "core-version": ">=5.1.9", "source": "https://github.com/tobibeer/tw5-preview", "documentation": "https://tobibeer.github.io/tw5-preview", diff --git a/plugins/tobibeer/preview/startup.js b/plugins/tobibeer/preview/startup.js index b578fcd..b83bf85 100644 --- a/plugins/tobibeer/preview/startup.js +++ b/plugins/tobibeer/preview/startup.js @@ -7,4 +7,4 @@ Enhances the link widget for on-hover previews @preserve \*/ -(function(){"use strict";var e=require("$:/core/modules/widgets/link.js").link,t=e.prototype.render,p=e.prototype.handleClickEvent,i=require("$:/core/modules/utils/dom/popup.js").Popup,o=i.prototype.popupInfo;e.prototype.render=function(){t.apply(this,arguments);var e,p=this,i=this.wiki,o=this.domNodes[0],r=i.getTiddler(p.to),u="$:/plugins/tobibeer/preview/defaults/",n=$tw.utils.parseKeyDescriptor(i.getTextReference(u+"keys","").toUpperCase()),s=i.getTextReference(u+"delay","").toUpperCase(),l=function(){var t=$tw.popup.popupInfo(o).popupLevel;clearTimeout(e);$tw.popup.cancel(t-1);t++;i.setText("$:/temp/tobibeer/preview-"+t+"-tiddler","text",null,p.to);setTimeout(function(){$tw.popup.triggerPopup({domNode:o,title:"$:/temp/tobibeer/preview-"+t,wiki:i})},50)},a=function(){var e,t,r=1,n=i.getTextReference(u+"not","");if(n){$tw.utils.each(n.split(" "),function(e){var t=o;while(t&&r){if($tw.utils.hasClass(t,e)){r=0;return false}t=t.parentNode}})}t=i.getTextReference(u+"exclude","");e=t?i.filterTiddlers(t):[];if(e.indexOf(p.to)>=0){r=0}return r};s=s?parseInt(s):null;if(s!==null&&isNaN(s)){s=0}if(r){$tw.utils.addClass(o,"tc-popup-handle");$tw.utils.addClass(o,"tc-popup-absolute");["mouseover","mouseout"].forEach(function(t){o.addEventListener(t,function(p){var i=p||window.event;if(t==="mouseover"){if(a()){if(!i.keyCode){i.keyCode=0}if($tw.utils.checkKeyDescriptor(i,n)){l()}else if(s){e=setTimeout(l,s);o.delayTimeout=e}}}else{clearTimeout(e)}})})}};e.prototype.handleClickEvent=function(){p.apply(this,arguments);clearTimeout(this.delayTimeout);$tw.popup.cancel(Math.max(0,$tw.popup.popupInfo(this).popupLevel-1))};i.prototype.popupInfo=function(e){var t,p,i=e;while(i&&i.getAttribute){t=i.getAttribute("class")||"";p=t.indexOf("tc-preview-tiddler-");if(p>-1){t=t.substr(p).split(" ")[0];return{popupLevel:parseInt(t.charAt(t.length-1))}}i=i.parentNode}return o.apply(this,arguments)}})(); \ No newline at end of file +(function(){"use strict";var e=require("$:/core/modules/widgets/link.js").link,t=e.prototype.render,p=e.prototype.handleClickEvent,i=require("$:/core/modules/utils/dom/popup.js").Popup,o=i.prototype.popupInfo;e.prototype.render=function(){t.apply(this,arguments);var e,p=this,i=this.wiki,o=this.domNodes[0],r=i.getTiddler(p.to),u="$:/plugins/tobibeer/preview/defaults/",n=$tw.utils.parseKeyDescriptor(i.getTextReference(u+"keys","").toUpperCase()),s=i.getTextReference(u+"delay").toUpperCase(),l=function(){var t=$tw.popup.popupInfo(o).popupLevel;clearTimeout(e);$tw.popup.cancel(t-1);t++;i.setText("$:/temp/tobibeer/preview-"+t+"-tiddler","text",null,p.to);setTimeout(function(){$tw.popup.triggerPopup({domNode:o,title:"$:/temp/tobibeer/preview-"+t,wiki:i})},50)},a=function(){var e,t,r=1,n=i.getTextReference(u+"not","");if(n){$tw.utils.each(n.split(" "),function(e){var t=o;while(t&&r){if($tw.utils.hasClass(t,e)){r=0;return false}t=t.parentNode}})}t=i.getTextReference(u+"exclude","");e=t?i.filterTiddlers(t):[];if(e.indexOf(p.to)>=0){r=0}return r};s=s!==undefined?parseInt(s):null;if(s!==null&&isNaN(s)){s=0}if(r){$tw.utils.addClass(o,"tc-popup-handle");$tw.utils.addClass(o,"tc-popup-absolute");["mouseover","mouseout"].forEach(function(t){o.addEventListener(t,function(p){var i=p||window.event;if(t==="mouseover"){if(a()){if(!i.keyCode){i.keyCode=0}if($tw.utils.checkKeyDescriptor(i,n)){l()}else if(s!==null){e=setTimeout(l,s);o.delayTimeout=e}}}else{clearTimeout(e)}})})}};e.prototype.handleClickEvent=function(){p.apply(this,arguments);clearTimeout(this.delayTimeout);$tw.popup.cancel(Math.max(0,$tw.popup.popupInfo(this).popupLevel-1))};i.prototype.popupInfo=function(e){var t,p,i=e;while(i&&i.getAttribute){t=i.getAttribute("class")||"";p=t.indexOf("tc-preview-tiddler-");if(p>-1){t=t.substr(p).split(" ")[0];return{popupLevel:parseInt(t.charAt(t.length-1))}}i=i.parentNode}return o.apply(this,arguments)}})(); \ No newline at end of file diff --git a/src/plugin.info b/src/plugin.info index f16500a..d1246f0 100644 --- a/src/plugin.info +++ b/src/plugin.info @@ -2,7 +2,7 @@ "title": "$:/plugins/tobibeer/preview", "description": "Shows a tiddler preview when hovering internal links", "author": "Tobias Beer", - "version": "0.5.1", + "version": "0.5.2", "core-version": ">=5.1.9", "source": "https://github.com/tobibeer/tw5-preview", "documentation": "https://tobibeer.github.io/tw5-preview", diff --git a/src/startup.js b/src/startup.js index fce296a..f1f4e42 100644 --- a/src/startup.js +++ b/src/startup.js @@ -40,7 +40,7 @@ CoreLink.prototype.render = function() { // Modifier keys to quick-show the popup w/o delay keys = $tw.utils.parseKeyDescriptor(wiki.getTextReference(defaults+"keys","").toUpperCase()), // Delay for popup rendering - delay = wiki.getTextReference(defaults+"delay","").toUpperCase(), + delay = wiki.getTextReference(defaults+"delay").toUpperCase(), // Displays the preview popup showPopup = function() { // Get current popup level @@ -104,7 +104,7 @@ CoreLink.prototype.render = function() { return yes; }; // Turn delay to integer - delay = delay ? parseInt(delay) : null; + delay = delay !== undefined ? parseInt(delay) : null; // Not a number? if(delay !== null && isNaN(delay)) { // No delay @@ -136,7 +136,7 @@ CoreLink.prototype.render = function() { // Then show showPopup(); // Modifiers don't match but we got a delay? - } else if(delay) { + } else if(delay !== null) { // Set timeout and wait to show popup wait = setTimeout(showPopup,delay); // Remember timer at element