Page MenuHomePhabricator

Some of the toolbar-API-functions don't work in a $( document ).ready-function
Closed, ResolvedPublic

Description

Some of the booklet related toolbar-API-functions don't work in a $j( document ).ready-function: Inserting an empty booklet (if you want to build things up step by step), adding pages to the two existing booklets (adding pages to an own booklet works), removing pages and removing characters.

To test it, put this into your personal vector.js:

function atT_booklet() {
$j( '#wpTextbox1' ).wikiEditor( 'addToToolbar', {
	'sections': {
		'emoticons': {
			'type': 'booklet',
			'label': 'Emoticons'
		}
	}
} );
}

function atT_chars() {
$j( '#wpTextbox1' ).wikiEditor( 'addToToolbar', {
	'section': 'characters',
	'pages': {
		'emoticons': {
			'layout': 'characters',
			'label': 'Emoticons',
			'characters': [ ':)', ':))', ':(', '<3', ';)' ]
		}
	}
} );
}

function atT_table() {
$j( '#wpTextbox1' ).wikiEditor( 'addToToolbar', {
	'section': 'help',
	'pages': {
		'colors': {
			'layout': 'table',
			'label': 'Colors',
			'headings': [
				{ text: 'Name' }, // or use textMsg for localization, see also above
				{ text: 'Temperature' },
				{ text: 'Swatch' }
			],
			'rows': [
				{
					'name': { text: 'Red' },
					'temp': { text: 'Warm' },
					'swatch': { html: '<div style="width:10px;height:10px;background-color:red;">' }
				},
				{
					'name': { text: 'Blue' },
					'temp': { text: 'Cold' },
					'swatch': { html: '<div style="width:10px;height:10px;background-color:blue;">' }
				},
				{
					'name': { text: 'Silver' },
					'temp': { text: 'Neutral' },
					'swatch': { html: '<div style="width:10px;height:10px;background-color:silver;">' }
				}
			]
		}
	}
} );
}

function rfT_page() {
$j( '#wpTextbox1' ).wikiEditor( 'removeFromToolbar', {
	'section': 'help',
	'page': 'format'
} );
}

function rfT_char() {
$j( '#wpTextbox1' ).wikiEditor( 'removeFromToolbar', {
	'section': 'characters',
	'page': 'latin',
	'character': 'Á'
} );
}

if ( typeof $j != 'undefined' && typeof $j.fn.wikiEditor != 'undefined' ) {
	// Execute on load
	$j( document ).ready( function() {
atT_booklet();
//atT_chars();
//atT_table();
//rfT_page();
//rfT_char();

});}

Expectet behaviour: The thing not commented out should appear/disappear.

Actual behaviour: Nothing happens, atT_booklet fails with "page is not defined", the others fail silently.

The interesting thing: All functions work via javascript:atT_booklet(); in the browser's navigation bar or if you put them in some onclick-thing or in a window.setTimeout.


Version: unspecified
Severity: normal

Details

Reference
bz23479
Related Gerrit Patches:
mediawiki/extensions/WikiEditor : masterWikieditor: Rework deferred building of toolbar

Event Timeline

bzimport raised the priority of this task from to Medium.Nov 21 2014, 10:58 PM
bzimport added a project: WikiEditor.
bzimport set Reference to bz23479.
bzimport added a subscriber: Unknown Object (MLST).
Schnark created this task.May 12 2010, 7:25 AM

We need a queue for toolbar API calls that come in when the toolbar isn't set up yet.

He7d3r added a comment.Nov 7 2010, 1:51 PM

A similar problem happens when changing addOnloadHook to $j(document).ready in a script which add a new section in the sidebar:
http://pt.wikibooks.org/w/index.php?title=MediaWiki:Common.js&diff=prev&oldid=197700
If I use addOnloadHook the section is collapsible, if $j(document).ready is used, the section is permanently hidden.

That's another bug, which was reported in bug 25726.

mxn added a subscriber: mxn.Nov 24 2014, 8:56 PM
GOIII added a subscriber: GOIII.Jul 17 2015, 8:40 AM
Restricted Application added a subscriber: Aklapper. · View Herald TranscriptJul 17 2015, 8:40 AM
GOIII updated the task description. (Show Details)Jul 17 2015, 8:44 AM
GOIII set Security to None.

Change 226676 had a related patch set uploaded (by Gerrit Patch Uploader):
Wikieditor: Rework deferred building of toolbar

https://gerrit.wikimedia.org/r/226676

Change 226676 merged by jenkins-bot:
Wikieditor: Rework deferred building of toolbar

https://gerrit.wikimedia.org/r/226676

TheDJ closed this task as Resolved.Oct 31 2015, 3:10 PM
TheDJ assigned this task to Schnark.
TheDJ removed a project: Patch-For-Review.
TheDJ removed a subscriber: wikibugs-l-list.
GOIII moved this task from Backlog to Closed on the WikiEditor board.Apr 3 2016, 9:42 AM