Ticket #823 (closed enhancement: fixed)

Opened 8 months ago

Last modified 7 months ago

extend invokeParamifier() to process "option paramifiers"

Reported by: EricShulman Owned by: MartinBudden
Priority: minor Milestone: 2.4.2
Component: core Version:
Severity: low Keywords:
Cc:

Description (last modified by EricShulman) (diff)

objective: use "option paramifiers" to override TiddlyWiki 'chk' and 'txt' option values on-the-fly, directly from a document URL.

If a paramifier begins with 'chk' (checkbox) or 'txt' (text field), it's value will be automatically stored in config.options.*, adding to or overriding any existing 'chk' or 'txt' option values that may have already been loaded from browser cookies and/or assigned by the TW core or plugin initialization functions using hard-coded default values.

Option values that have been overriden by paramifiers are only applied during the current document session, and are not automatically retained. However, if you edit an overridden option value during that session, then the modified value is, of course, saved in a browser cookie, as usual.

The following code has been successfully implemented at http://www.TiddlyTools.com/#CoreTweaks##823

function invokeParamifier(params,handler)
{
	if(!params || params.length == undefined || params.length <= 1)
		return;
	for(var t=1; t<params.length; t++) {
		var p = config.paramifiers[params[t].name];
		if(p && p[handler] instanceof Function)
			p[handler](params[t].value);
		else { // not a paramifier with handler()... check for an 'option' prefix
			var h=config.optionHandlers[params[t].name.substr(0,3)];
			if (h && h.set instanceof Function)
				h.set(params[t].name,params[t].value);
		}
	}
}

Note: This ticket is based on discussions from the "Developer's Conference Call" held on Nov 10, 2008, and provides a generalization of the hard-coded "#animate:..." paramifier suggested in http://trac.tiddlywiki.org/ticket/742 (which has now been closed).

Change History

Changed 8 months ago by EricShulman

  • description modified (diff)

Changed 8 months ago by EricShulman

  • description modified (diff)

Changed 8 months ago by EricShulman

  • milestone set to 2.5

Changed 7 months ago by FND

  • milestone changed from 2.5 to 2.4.2

Changed 7 months ago by MartinBudden

  • owner changed from JeremyRuston to MartinBudden

Changed 7 months ago by MartinBudden

  • status changed from new to closed
  • resolution set to fixed

Fixed in changeset:7988

Note: See TracTickets for help on using tickets.