Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2012-07-19 08:44:19

gilest
New Member
Registered: 2012-07-19
Posts: 2

Newbie asking newbie questions

Hello everyone. My TP install (at gilest.org) is so fresh I can still see steam rising from it in the morning sunshine.

Thanks to @textpattern for support and encouragement on Twitter yesterday. I poked around, and kept poking until I starting understanding how it all fits together.

There’s still a few things I’m not grasped yet. First, what’s going on when I see this:

screenshot

It happens (sometimes, but not every time) when I hit “Save” or “Publish”. If I use the Back button in my browser, the changes I’ve just Saved aren’t actually saved. If I go up to the location bar and hack the URL back to /textpattern/, they are saved and everything continues to work as expected.

Is this is a bug (I’m using the latest nightly release – thanks to Phil Wareham for his advice on Twitter on that front), or have I done something stupid while installing/setting up/ messing about with Forms, etc?

Giles

Offline

#2 2012-07-19 10:13:29

Gocom
Developer Emeritus
From: Helsinki, Finland
Registered: 2006-07-14
Posts: 4,533
Website

Re: Newbie asking newbie questions

Hi gilest,

Yes it’s a bug. Likely caused by JavaScript initialization delay which isn’t taken into account. There are also potential issues with bubbling/re-initialization, process blocking (due to alerts and script responses) and freezing (due to not handling errors and script responses).

Robert, if you are reading, I would suggest either:

  • restoring non-async code paths and making sure they run based on client-side actions, not server-side configuration settings.
  • preventing form submissions until JavaScript has initialized. This means hiding any async form until JavaScript has loaded.

If the first option is chosen, it means that you will have drop all plans for removing non-async code paths. Both need to co-exists.

Will fill file a issue report for this now.

Last edited by Gocom (2012-07-19 10:35:43)

Offline

#3 2012-07-19 10:37:23

Gocom
Developer Emeritus
From: Helsinki, Finland
Registered: 2006-07-14
Posts: 4,533
Website

Offline

#4 2012-07-19 11:08:39

gilest
New Member
Registered: 2012-07-19
Posts: 2

Re: Newbie asking newbie questions

Excellent, thanks for clearing that up.

Offline

#5 2012-07-19 15:02:20

wet
Developer Emeritus
From: Schoerfling, Austria
Registered: 2005-06-06
Posts: 3,323
Website Mastodon

Re: Newbie asking newbie questions

Giles, thanks for the report.

This issue is probably fixed with r3980. This fix will be included in the next nightly build at 00:00 GMT. You can simply replace your current Textpattern files with those from the nightly archive file.

Please report back whether this fix works for you.

Offline

#6 2012-07-19 15:04:08

wet
Developer Emeritus
From: Schoerfling, Austria
Registered: 2005-06-06
Posts: 3,323
Website Mastodon

Re: Newbie asking newbie questions

Gocom wrote:

If the first option is chosen, it means that you will have drop all plans for removing non-async code paths

Not really a desirable option.

Offline

#7 2012-07-19 16:21:57

Gocom
Developer Emeritus
From: Helsinki, Finland
Registered: 2006-07-14
Posts: 4,533
Website

Re: Newbie asking newbie questions

Robert, how about plugins and other elements using Textpattern’s async API, but do not deploy the class due to needing their own hook and callbacks?

Could it be possible to add a general class (e.g. along the lines of wait-doc) that can be used to hide elements until the document is ready?

Last edited by Gocom (2012-07-19 16:22:40)

Offline

#8 2012-07-19 17:41:30

wet
Developer Emeritus
From: Schoerfling, Austria
Registered: 2005-06-06
Posts: 3,323
Website Mastodon

Re: Newbie asking newbie questions

You mean:

Index: textpattern/textpattern.js
--- textpattern/textpattern.js	(revision 3980)
+++ textpattern/textpattern.js	(revision )
@@ -898,4 +898,5 @@
 			error: function() {window.alert(textpattern.gTxt('form_submission_error'));}
 		}).addClass('armed');
 	}
+    $('body').removeClass('not-ready');
 });
Index: textpattern/lib/txplib_head.php
--- textpattern/lib/txplib_head.php	(revision 3980)
+++ textpattern/lib/txplib_head.php	(revision )
@@ -137,7 +137,7 @@
 	callback_event('admin_side', 'head_end');
 	?>
 	</head>
-	<body id="<?php echo $body_id; ?>" class="<?php echo $area; ?>">
+	<body id="<?php echo $body_id; ?>" class="not-ready <?php echo $area; ?>">
 	<div class="txp-header">
 	<?php callback_event('admin_side', 'pagetop');
 		$theme->set_state($area, $event, $bm, $message);

Offline

#9 2012-07-19 18:02:29

Gocom
Developer Emeritus
From: Helsinki, Finland
Registered: 2006-07-14
Posts: 4,533
Website

Re: Newbie asking newbie questions

Yeah, combined with something along the lines of:

.not-ready form.async input[type="submit"], .not-ready a.async, .not-ready .wait-doc {
	visibility: hidden;
}

So that plugins and core can deploy it without writing their own additional styles (hence .wait-doc selector). If a selector is added to the body itself, the .armed thing can be dropped. Both do the same thing, but the other can be used for more purposes.

Thinking about it, what if the whole body was hidden until the document is fully ready? Textpattern needs JavaScript everywhere now, so why not, right? I know, someone will chime in and say “no, that’s bad”, but what is anyone going to do with half-broken page.

Offline

#10 2012-07-19 18:11:05

maniqui
Member
From: Buenos Aires, Argentina
Registered: 2004-10-10
Posts: 3,070
Website

Re: Newbie asking newbie questions

Gocom wrote:

Thinking about it, what if the whole body was hidden until the document is fully ready? Textpattern needs JavaScript everywhere now, so why not, right? I know, someone will chime in and say “no, that’s bad”, but what is anyone going to do with half-broken page.

I used this (or a similar) trick in the past. And as you noted, the risk is: if JS breaks, page will render blank. I foresee a lot of complains here at forum if that would happen. I agree that a half-broken page is the same, in terms of not being able to accomplish something. But a blank page… that will bring panic & chaos.

While here, I will silently drop this link (have already done it in the past here at forum and in dev list, exposing some rationale & benefits of organizing JS code in TXP back-end).

Last edited by maniqui (2012-07-19 18:12:19)


La música ideas portará y siempre continuará

TXP Builders – finely-crafted code, design and txp

Offline

Board footer

Powered by FluxBB