/*\ title: $:/core/modules/utils/dom/popup.js type: application/javascript module-type: utils Module that creates a $tw.utils.Popup object prototype that manages popups in the browser \*/ (function(){ /*jslint node: true, browser: true */ /*global $tw: false */ "use strict"; /* Creates a Popup object with these options: rootElement: the DOM element to which the popup zapper should be attached */ var Popup = function(options) { options = options || {}; this.rootElement = options.rootElement || document.documentElement; this.popups = []; // Array of {title:,wiki:,domNode:} objects }; /* Trigger a popup open or closed. Parameters are in a hashmap: title: title of the tiddler where the popup details are stored domNode: dom node to which the popup will be positioned wiki: wiki force: if specified, forces the popup state to true or false (instead of toggling it) */ Popup.prototype.triggerPopup = function(options) { console.log("triggerPopup",options) // Check if this popup is already active var index = -1; for(var t=0; t 0) { console.log("Adding click handler") this.rootElement.addEventListener("click",this,true); } }; /* Cancel all popups at or above a specified level or DOM node level: popup level to cancel (0 cancels all popups) */ Popup.prototype.cancel = function(level) { console.log("cancel",level) var numPopups = this.popups.length; level = Math.max(0,Math.min(level,numPopups)); for(var t=level; t