[solved] minifier and input text form...

For developers using the Construct 2 Javascript SDK

Post » Sun Jan 29, 2012 2:36 pm

OK I've got the most annoying issue with the minifier option.
When it's checked, all input text form in my Iscroll plugins don't work correctly, you can't select the text inside.

I tried to export without and it works perfectly.
I've obviously read the manual part about minifier.

If you need to see the code, you can download the iscroll plugin.septeven2012-01-29 23:29:54
B
44
S
12
G
13
Posts: 628
Reputation: 10,471

Post » Sun Jan 29, 2012 8:35 pm

I had a quick look - I think the problem might be because you use a separate external script. The minifier does not parse or look at other scripts at all, so it does not know what 'iScroll' means and will rename it. So the line 'new iScroll(...' will turn to something like 'new mv(...' and break. To avoid this you must always reference anything from external scripts with string syntax, e.g.
new window["iScroll"](...)
because the minifier never changes anything using that syntax.
Scirra Founder
B
359
S
214
G
72
Posts: 22,952
Reputation: 178,600

Post » Sun Jan 29, 2012 8:46 pm

@Ashley
Thanks, I'll try this, but I wonder why it didn't break whole plugin because the 'new iscroll...' established all the functions of the plugin. It creates the scrolling system. Any ideas why it breaks only the input form?
B
44
S
12
G
13
Posts: 628
Reputation: 10,471

Post » Sun Jan 29, 2012 9:02 pm

I'm not sure, there was a lot of code in your plugin so I didn't have time to look all the way through it. You should just know that anything at all not defined in runtime.js will be renamed by the minifier, unless you use the ["property"] syntax. You should look through for any references at all to iScroll, other scripts, or anything not defined in the javascript itself, and make sure you switch them to ["property"] syntax.
Scirra Founder
B
359
S
214
G
72
Posts: 22,952
Reputation: 178,600

Post » Sun Jan 29, 2012 9:35 pm

OK I'll do that, hopefully it'll work.
Thanks
B
44
S
12
G
13
Posts: 628
Reputation: 10,471

Post » Sun Jan 29, 2012 10:23 pm

@Ashley I tried this and unfortunately it doesn't work... It's still impossible to select text when the minifier option is checked...
B
44
S
12
G
13
Posts: 628
Reputation: 10,471

Post » Sun Jan 29, 2012 10:37 pm

@Ashley
Damn, I just saw that's the same thing for my style Border-radius & shadow properties. It's broken when it is exported with the minifier.
So, how do I have to write the e.g. elem.style.borderRadius ?

[edit]
OK about style properties, I get it.
elem["style"]["borderRadius"]
But do I have to do this for ALL my style properties ??? I don't really understand why it breaks some style properties, some others not... ?

septeven2012-01-29 22:57:24
B
44
S
12
G
13
Posts: 628
Reputation: 10,471

Post » Sun Jan 29, 2012 11:34 pm

OK It was a known issue (that I was aware) from the original plugin.
In fact, I added this :
[code]new window["iScroll"] (...,
onBeforeScrollStart: function (e) {
var target = e.target;
while (target.nodeType != 1) target = target.parentNode;
if (target.tagName != 'SELECT' && target.tagName != 'INPUT' && target.tagName != 'TEXTAREA')
e.preventDefault();[/code]
but this is apparently broken with the minifier and I didn't figure out to write it correctly.
I've finally added an addEventListener directly to the input form which makes a stopPropagation.
septeven2012-01-30 08:29:33
B
44
S
12
G
13
Posts: 628
Reputation: 10,471


Return to Javascript SDK

Who is online

Users browsing this forum: No registered users and 0 guests