1
0
mirror of https://github.com/Jermolene/TiddlyWiki5 synced 2024-12-25 09:30:28 +00:00

Complete renaming popupper component to popup

This commit is contained in:
Jeremy Ruston 2012-07-14 15:52:35 +01:00
parent 10b7075c7a
commit 761ffa403d
3 changed files with 13 additions and 13 deletions

View File

@ -39,21 +39,21 @@ exports.triggerPopup = function(event,cancel) {
} }
// Check for cancelling // Check for cancelling
if(cancel) { if(cancel) {
$tw.popupper.cancel(); $tw.popup.cancel();
} else { } else {
// Get the current popup state tiddler // Get the current popup state tiddler
var value = this.wiki.getTextReference(textRef,"",this.tiddlerTitle); var value = this.wiki.getTextReference(textRef,"",this.tiddlerTitle);
// Check if the popup is open by checking whether it matches "(<x>,<y>)" // Check if the popup is open by checking whether it matches "(<x>,<y>)"
var popupLocationRegExp = /^\((-?[0-9\.E]+),(-?[0-9\.E]+),(-?[0-9\.E]+),(-?[0-9\.E]+)\)$/; var popupLocationRegExp = /^\((-?[0-9\.E]+),(-?[0-9\.E]+),(-?[0-9\.E]+),(-?[0-9\.E]+)\)$/;
if(popupLocationRegExp.test(value)) { if(popupLocationRegExp.test(value)) {
$tw.popupper.cancel(); $tw.popup.cancel();
} else { } else {
// Set the position if we're opening it // Set the position if we're opening it
this.wiki.setTextReference(textRef, this.wiki.setTextReference(textRef,
"(" + this.child.domNode.offsetLeft + "," + this.child.domNode.offsetTop + "," + "(" + this.child.domNode.offsetLeft + "," + this.child.domNode.offsetTop + "," +
this.child.domNode.offsetWidth + "," + this.child.domNode.offsetHeight + ")", this.child.domNode.offsetWidth + "," + this.child.domNode.offsetHeight + ")",
this.tiddlerTitle,true); this.tiddlerTitle,true);
$tw.popupper.popup(textRef); $tw.popup.popup(textRef);
} }
} }
}; };

View File

@ -1,9 +1,9 @@
/*\ /*\
title: $:/core/modules/popupper.js title: $:/core/modules/popup.js
type: application/javascript type: application/javascript
module-type: utils module-type: utils
Plugin that creates a $tw.utils.Popupper object prototype that manages popups in the browser Plugin that creates a $tw.utils.Popup object prototype that manages popups in the browser
\*/ \*/
(function(){ (function(){
@ -13,38 +13,38 @@ Plugin that creates a $tw.utils.Popupper object prototype that manages popups in
"use strict"; "use strict";
/* /*
Creates a Popupper object with these options: Creates a Popup object with these options:
wiki: the wiki to use for resolving tiddler titles wiki: the wiki to use for resolving tiddler titles
rootElement: the DOM element to which the popup zapper should be attached rootElement: the DOM element to which the popup zapper should be attached
*/ */
var Popupper = function(options) { var Popup = function(options) {
options = options || {}; options = options || {};
this.wiki = options.wiki; this.wiki = options.wiki;
this.rootElement = options.rootElement || document.body; this.rootElement = options.rootElement || document.body;
this.popupTextRef = null; this.popupTextRef = null;
}; };
Popupper.prototype.popup = function(stateTextRef) { Popup.prototype.popup = function(stateTextRef) {
var popupState; var popupState;
this.cancel(); this.cancel();
this.popupTextRef = stateTextRef; this.popupTextRef = stateTextRef;
this.rootElement.addEventListener("click",this,true); this.rootElement.addEventListener("click",this,true);
}; };
Popupper.prototype.handleEvent = function(event) { Popup.prototype.handleEvent = function(event) {
if(event.type === "click") { if(event.type === "click") {
this.rootElement.removeEventListener("click",this,true); this.rootElement.removeEventListener("click",this,true);
this.cancel(); this.cancel();
} }
}; };
Popupper.prototype.cancel = function() { Popup.prototype.cancel = function() {
if(this.popupTextRef) { if(this.popupTextRef) {
this.wiki.deleteTextReference(this.popupTextRef); this.wiki.deleteTextReference(this.popupTextRef);
this.popupTextRef = null; this.popupTextRef = null;
} }
}; };
exports.Popupper = Popupper; exports.Popup = Popup;
})(); })();

View File

@ -56,8 +56,8 @@ exports.startup = function() {
$tw.Commander.initCommands(); $tw.Commander.initCommands();
// Host-specific startup // Host-specific startup
if($tw.browser) { if($tw.browser) {
// Install the popupper // Install the popup manage
$tw.popupper = new $tw.utils.Popupper({ $tw.popup = new $tw.utils.Popup({
wiki: $tw.wiki, wiki: $tw.wiki,
rootElement: document.body rootElement: document.body
}); });