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
if(cancel) {
$tw.popupper.cancel();
$tw.popup.cancel();
} else {
// Get the current popup state tiddler
var value = this.wiki.getTextReference(textRef,"",this.tiddlerTitle);
// 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]+)\)$/;
if(popupLocationRegExp.test(value)) {
$tw.popupper.cancel();
$tw.popup.cancel();
} else {
// Set the position if we're opening it
this.wiki.setTextReference(textRef,
"(" + this.child.domNode.offsetLeft + "," + this.child.domNode.offsetTop + "," +
this.child.domNode.offsetWidth + "," + this.child.domNode.offsetHeight + ")",
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
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(){
@ -13,38 +13,38 @@ Plugin that creates a $tw.utils.Popupper object prototype that manages popups in
"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
rootElement: the DOM element to which the popup zapper should be attached
*/
var Popupper = function(options) {
var Popup = function(options) {
options = options || {};
this.wiki = options.wiki;
this.rootElement = options.rootElement || document.body;
this.popupTextRef = null;
};
Popupper.prototype.popup = function(stateTextRef) {
Popup.prototype.popup = function(stateTextRef) {
var popupState;
this.cancel();
this.popupTextRef = stateTextRef;
this.rootElement.addEventListener("click",this,true);
};
Popupper.prototype.handleEvent = function(event) {
Popup.prototype.handleEvent = function(event) {
if(event.type === "click") {
this.rootElement.removeEventListener("click",this,true);
this.cancel();
}
};
Popupper.prototype.cancel = function() {
Popup.prototype.cancel = function() {
if(this.popupTextRef) {
this.wiki.deleteTextReference(this.popupTextRef);
this.popupTextRef = null;
}
};
exports.Popupper = Popupper;
exports.Popup = Popup;
})();

View File

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