mirror of
https://github.com/Jermolene/TiddlyWiki5
synced 2025-10-25 12:47:40 +00:00
Remove obsolete modules
ArgParser was used by the old tw2 parser, and the Sprite animator was never actually used
This commit is contained in:
@@ -72,8 +72,6 @@ exports.startup = function() {
|
|||||||
// Install the scroller
|
// Install the scroller
|
||||||
$tw.pageScroller = new $tw.utils.PageScroller();
|
$tw.pageScroller = new $tw.utils.PageScroller();
|
||||||
document.addEventListener("tw-scroll",$tw.pageScroller,false);
|
document.addEventListener("tw-scroll",$tw.pageScroller,false);
|
||||||
// Install the sprite factory
|
|
||||||
$tw.sprite = new $tw.utils.Sprite();
|
|
||||||
// Install the save action handler
|
// Install the save action handler
|
||||||
$tw.wiki.initSavers();
|
$tw.wiki.initSavers();
|
||||||
document.addEventListener("tw-save-wiki",function(event) {
|
document.addEventListener("tw-save-wiki",function(event) {
|
||||||
|
|||||||
@@ -1,117 +0,0 @@
|
|||||||
/*\
|
|
||||||
title: $:/core/modules/utils/argparser.js
|
|
||||||
type: application/javascript
|
|
||||||
module-type: utils
|
|
||||||
|
|
||||||
Parse a space-separated string of name:value parameters. Values can be quoted with single quotes, double quotes, double square brackets, or double curly braces.
|
|
||||||
|
|
||||||
The parameters are returned in a structure that can be referenced like this:
|
|
||||||
|
|
||||||
(return).byName["name"][0] - First occurance of parameter with a given name
|
|
||||||
(return).byPos[0].n - Name of parameter in first position
|
|
||||||
(return).byPos[0].v.string - Value of parameter in first position
|
|
||||||
(return).byPos[0].v.evaluated - True if the parameter is to be evaluated
|
|
||||||
|
|
||||||
Options and their defaults are:
|
|
||||||
|
|
||||||
defaultName: null,
|
|
||||||
defaultValue: null,
|
|
||||||
noNames: false,
|
|
||||||
cascadeDefaults: false,
|
|
||||||
allowEval: true
|
|
||||||
|
|
||||||
\*/
|
|
||||||
(function(){
|
|
||||||
|
|
||||||
/*jslint node: true, browser: true */
|
|
||||||
/*global $tw: false */
|
|
||||||
"use strict";
|
|
||||||
|
|
||||||
var ArgParser = function(argString,options) {
|
|
||||||
options = options || {};
|
|
||||||
var defaultName = options.defaultName,
|
|
||||||
defaultValue = options.defaultValue;
|
|
||||||
var parseToken = function(match,p) {
|
|
||||||
var n;
|
|
||||||
if(match[p]) { // Double quoted
|
|
||||||
n = {string: match[p]};
|
|
||||||
} else if(match[p+1]) { // Single quoted
|
|
||||||
n = {string: match[p+1]};
|
|
||||||
} else if(match[p+2]) { // Double-square-bracket quoted
|
|
||||||
n = {string: match[p+2]};
|
|
||||||
} else if(match[p+3]) { // Double-brace quoted
|
|
||||||
n = {string: match[p+3], evaluated: true};
|
|
||||||
} else if(match[p+4]) { // Unquoted
|
|
||||||
n = {string: match[p+4]};
|
|
||||||
} else if(match[p+5]) { // empty quote
|
|
||||||
n = {string: ""};
|
|
||||||
}
|
|
||||||
return n;
|
|
||||||
};
|
|
||||||
this.byPos = [];
|
|
||||||
var dblQuote = "(?:\"((?:(?:\\\\\")|[^\"])+)\")",
|
|
||||||
sngQuote = "(?:'((?:(?:\\\\\')|[^'])+)')",
|
|
||||||
dblSquare = "(?:\\[\\[((?:\\s|\\S)*?)\\]\\])",
|
|
||||||
dblBrace = "(?:\\{\\{((?:\\s|\\S)*?)\\}\\})",
|
|
||||||
unQuoted = options.noNames ? "([^\"'\\s]\\S*)" : "([^\"':\\s][^\\s:]*)",
|
|
||||||
emptyQuote = "((?:\"\")|(?:''))",
|
|
||||||
skipSpace = "(?:\\s*)",
|
|
||||||
token = "(?:" + dblQuote + "|" + sngQuote + "|" + dblSquare + "|" + dblBrace + "|" + unQuoted + "|" + emptyQuote + ")",
|
|
||||||
re = options.noNames ? new RegExp(token,"mg") : new RegExp(skipSpace + token + skipSpace + "(?:(\\:)" + skipSpace + token + ")?","mg"),
|
|
||||||
match,n,v;
|
|
||||||
do {
|
|
||||||
match = re.exec(argString);
|
|
||||||
if(match) {
|
|
||||||
n = parseToken(match,1);
|
|
||||||
if(options.noNames) {
|
|
||||||
this.byPos.push({n:"", v:n});
|
|
||||||
} else {
|
|
||||||
v = parseToken(match,8);
|
|
||||||
if(v === undefined && defaultName) {
|
|
||||||
v = n;
|
|
||||||
n = defaultName;
|
|
||||||
} else if(v === undefined && defaultValue) {
|
|
||||||
v = defaultValue;
|
|
||||||
}
|
|
||||||
if(n.evaluated === true) {
|
|
||||||
n = "{{" + n.string + "}}";
|
|
||||||
} else if (typeof n === "object" && $tw.utils.hop(n,"string")) {
|
|
||||||
n = n.string;
|
|
||||||
}
|
|
||||||
this.byPos.push({n:n, v:v});
|
|
||||||
if(options.cascadeDefaults) {
|
|
||||||
defaultName = n;
|
|
||||||
defaultValue = v;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} while(match);
|
|
||||||
this.byName = {};
|
|
||||||
for(var t=0; t<this.byPos.length; t++) {
|
|
||||||
n = this.byPos[t].n;
|
|
||||||
v = this.byPos[t].v;
|
|
||||||
if($tw.utils.hop(this.byName,n))
|
|
||||||
this.byName[n].push(v);
|
|
||||||
else
|
|
||||||
this.byName[n] = [v];
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
// Retrieve the first occurance of a named parameter, or the default if missing
|
|
||||||
ArgParser.prototype.getValueByName = function(n) {
|
|
||||||
var v = this.byName[n];
|
|
||||||
return v && v.length > 0 ? v[0] : null;
|
|
||||||
};
|
|
||||||
|
|
||||||
// Retrieve all the string values as an array
|
|
||||||
ArgParser.prototype.getStringValues = function() {
|
|
||||||
var result = [];
|
|
||||||
for(var t=0; t<this.byPos.length; t++) {
|
|
||||||
result.push(this.byPos[t].v.string);
|
|
||||||
}
|
|
||||||
return result;
|
|
||||||
};
|
|
||||||
|
|
||||||
exports.ArgParser = ArgParser;
|
|
||||||
|
|
||||||
})();
|
|
||||||
@@ -1,68 +0,0 @@
|
|||||||
/*\
|
|
||||||
title: $:/core/modules/utils/dom/sprite.js
|
|
||||||
type: application/javascript
|
|
||||||
module-type: utils
|
|
||||||
|
|
||||||
Animated sprites
|
|
||||||
|
|
||||||
\*/
|
|
||||||
(function(){
|
|
||||||
|
|
||||||
/*jslint node: true, browser: true */
|
|
||||||
/*global $tw: false */
|
|
||||||
"use strict";
|
|
||||||
|
|
||||||
/*
|
|
||||||
Create a sprite factory object
|
|
||||||
*/
|
|
||||||
var Sprite = function() {
|
|
||||||
};
|
|
||||||
|
|
||||||
/*
|
|
||||||
Animates a sprite that moves from the source location to the destination.
|
|
||||||
source: DOM element or {left:,top:,width:,height:} rectangle in viewport coordinates
|
|
||||||
dest: DOM element or {left:,top:,width:,height:} rectangle in viewport coordinates
|
|
||||||
content: content to be displayed in the sprite {text:,style:,class:}
|
|
||||||
*/
|
|
||||||
Sprite.prototype.fly = function(source,dest,content) {
|
|
||||||
// Create the element
|
|
||||||
var sprite = document.createElement("div");
|
|
||||||
if(content.text) {
|
|
||||||
sprite.appendChild(document.createTextNode(content.text));
|
|
||||||
}
|
|
||||||
if(content.style) {
|
|
||||||
sprite.setAttribute("style",content.style);
|
|
||||||
}
|
|
||||||
if(content["class"]) {
|
|
||||||
sprite["class"] = content["class"];
|
|
||||||
}
|
|
||||||
document.body.appendChild(sprite);
|
|
||||||
// Set the initial position of the sprite
|
|
||||||
var currWidth = sprite.offsetWidth,
|
|
||||||
scale = source.width/currWidth;
|
|
||||||
$tw.utils.setStyle(sprite,[
|
|
||||||
{position: "fixed"},
|
|
||||||
{top: "0px"},
|
|
||||||
{left: "0px"},
|
|
||||||
{transition: "none"},
|
|
||||||
{transformOrigin: "0% 0%"},
|
|
||||||
{transform: "translateX(" + source.left + "px) translateY(" + source.top + "px) scale(" + scale + ")"}
|
|
||||||
]);
|
|
||||||
// Set up a transition event handler to delete the sprite
|
|
||||||
sprite.addEventListener($tw.utils.convertEventName("transitionEnd"),function(event) {
|
|
||||||
sprite.parentNode.removeChild(sprite);
|
|
||||||
},false);
|
|
||||||
// Transition to its new position
|
|
||||||
$tw.utils.forceLayout(sprite);
|
|
||||||
scale = dest.width/currWidth;
|
|
||||||
$tw.utils.setStyle(sprite,[
|
|
||||||
{transition: $tw.utils.roundTripPropertyName("transform") + " " + $tw.config.preferences.animationDurationMs + " ease-in-out, "+
|
|
||||||
"opacity " + $tw.config.preferences.animationDurationMs + " ease-out"},
|
|
||||||
{transformOrigin: "0% 0%"},
|
|
||||||
{transform: "translateX(" + dest.left + "px) translateY(" + dest.top + "px) scale(" + scale + ")"}
|
|
||||||
]);
|
|
||||||
};
|
|
||||||
|
|
||||||
exports.Sprite = Sprite;
|
|
||||||
|
|
||||||
})();
|
|
||||||
Reference in New Issue
Block a user