Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

REGRESSION: date of article and module manager broken in persian language #6207

Closed
farhadst opened this issue Feb 27, 2015 · 66 comments
Closed

Comments

@farhadst
Copy link

install joomla 3.4
install persian language
set administrator panel (backend) to persian language

  1. create a article, date is ok but when edit article date is broken!
    (when backend language set to En, everything is ok)
    article-edit

  1. in module manager and edit module, tabs of "Menu Assignment" "Module Permissions" and "Advanced" is hidden. (but when backend language set to En everything is ok)
    module-edit
@infograf768
Copy link
Member

I can't reproduce your jalali date error here with the registered Persian language pack.
screen shot 2015-02-27 at 08 54 59

@farhadst
Copy link
Author

Please set backend language to persian and logout joomla, then again login with persian language!
edit article and save it.

@infograf768
Copy link
Member

Same. no issue for the date.

BUT I confirm the issue for the modules tabs and this is a big regression!

@brianteeman
Copy link
Contributor

I can confirm that there is an issue with the persian date.
See how it is displayed within the article view and the article list
I think I saw a similar report with users of the Thai calendar in the forum

screen shot 2015-02-27 at 02 25 25

screen shot 2015-02-27 at 02 26 00


This comment was created with the J!Tracker Application at issues.joomla.org/joomla-cms/6207.

@infograf768
Copy link
Member

date has to be tested with debug OFF as there is no uncompressed jalali calendar_setup

Can't find why modules tabs don't show

@brianteeman
Copy link
Contributor

My tests were with debug OFF


This comment was created with the J!Tracker Application at issues.joomla.org/joomla-cms/6207.

@brianteeman
Copy link
Contributor

The thai language issue was a JS error and unrelated see http://forum.joomla.org/viewtopic.php?f=706&t=874697&p=3272023#p3272023


This comment was created with the J!Tracker Application at issues.joomla.org/joomla-cms/6207.

@infograf768
Copy link
Member

I found out that the specifc calendar js file for Persian is the reason why module tabs are broken
Although dates did show OK here, I find this js error in that file.

Timestamp: 27/02/15 10:02:16
Error: TypeError: C.inputField.form.addEvent is not a function
Source File: http://localhost:8888/trunkgitnew/media/fa-IR/js/calendar-setup.js
Line: 11

@infograf768
Copy link
Member

Issue is this chnage

-JHtml::_('behavior.formvalidation');
+JHtml::_('behavior.formvalidator');

I.e. mootools is no more loaded

The fa-IR js file has to be modified

@infograf768 infograf768 changed the title date of article and module manager broken in persian language REGRESSION: date of article and module manager broken in persian language Feb 28, 2015
@brianteeman
Copy link
Contributor

As the fix is beyond the control of the core of joomla and is something for the Persian Translation Team can this be closed here?


This comment was created with the J!Tracker Application at issues.joomla.org/joomla-cms/6207.

@Bakual
Copy link
Contributor

Bakual commented Feb 28, 2015

I would like to leave that open simply because I doubt the the translators will be able to fix it themself.
At least till we got the attention of someone willing and capable of fixing it. Shouldn't be that hard if you're a bit familiar with MooTools / jQuery.

@dgt41 or @Fedik maybe?

@brianteeman
Copy link
Contributor

Maybe check with the Thai translation team as it looks like they fixed an
identical issue with their non-gregorian calendar

On 28 February 2015 at 14:13, Thomas Hunziker notifications@github.com
wrote:

I would like to leave that open simply because I doubt the the translators
will be able to fix it themself.
At least till we got the attention of someone willing and capable of
fixing it. Shouldn't be that hard if you're a bit familiar with MooTools /
jQuery.

@dgt41 https://github.com/dgt41 or @Fedik https://github.com/fedik
maybe?


Reply to this email directly or view it on GitHub
#6207 (comment).

Brian Teeman
Co-founder Joomla! and OpenSourceMatters Inc.
http://brian.teeman.net/

@Bakual
Copy link
Contributor

Bakual commented Feb 28, 2015

Thanks for that info. I've sent them an email to ask what they did.

@Fedik
Copy link
Member

Fedik commented Feb 28, 2015

I can confirm error on Module edit, but in content all looks good .

But it very tricky to fix/debug, as they do not provide uncompressed version of calendar.js
and lack of knowledge for Persian language 😄

@Bakual
Copy link
Contributor

Bakual commented Feb 28, 2015

and lack of knowledge for Persian language

Aww, comon. It's sure simpler to learn than JavaScript 😃

@dgrammatiko
Copy link
Contributor

https://gist.github.com/dgt41/cfcbe426029726ef63e0
This might be a possible solution. Can somebody test it by replacing the calendar-setup.js with the code of the gist?

@infograf768
Copy link
Member

@test
https://gist.github.com/dgt41/cfcbe426029726ef63e0
Does not solve the issue here.

It's even worse compared to the original one.

@infograf768
Copy link
Member

@dgt41

If I change ONLY in the original file
C.inputField.form.addEvent('submit', function() {
to
C.inputField.form.addEventListener('submit', function() {

It looks like working here.

@farhadst
Copy link
Author

farhadst commented Mar 2, 2015

@infograf768
i have change this code in original file (calendar-setup.js)
But does not solve the issue!

in date article problem, when save article after 4time, date is ok:

first
1

second
2

Third
3

Fourth
4

@Fedik
Copy link
Member

Fedik commented Mar 2, 2015

@farhadst what browser you use?

@infograf768 it could not work in IE,
this should be more safe, in theory:

var method, event;
if(document.addEventListener){
 method = 'addEventListener';
 event = 'submit';
} else {
 method = 'attachEvent';
 event = 'onsubmit';
}

C.inputField.form[method](event, function() {

@farhadst
Copy link
Author

farhadst commented Mar 2, 2015

@Fedik
i have replace this code in original file (calendar-setup.js)
and problem with module tab fix. thanks for this solution.

But does not solve article date!
i check this problem in firefox 35.0.1 & google chrome 40.0.2214.115 m (64-bit) & IE 11 and cache is disabled!

@dgrammatiko
Copy link
Contributor

@infograf768 I thought that I changed only that part on that file :)
@Fedik Thanks for the full proof solution!
@farhadst The file calendar.js also got some extra code for jalali, which is quite hard to go through because this file is compressed. What I did in calendar-setup.js was to compare it with the normal of joomla (both compressed and normal), and maybe this is the way to debug this error as well

@Fedik
Copy link
Member

Fedik commented Mar 2, 2015

something tells me that it based on https://github.com/farhadi/JalaliJSCalendar 😄

@dgrammatiko
Copy link
Contributor

@Fedik I will bet that the problem here is the code to support multiple instances...

@Fedik
Copy link
Member

Fedik commented Mar 2, 2015

@dgt41 this simple to check, just leave the calendar only for one field, other set to text, example

@dgrammatiko
Copy link
Contributor

This is the line that produces the error:

C.inputField.value = date.print(C.ifFormat, 'jalali', C.langNumbers);

@dgrammatiko
Copy link
Contributor

I updated the gist: https://gist.github.com/dgt41/cfcbe426029726ef63e0
Please mind that line 36 needs to be either true or false, true means local numbers, names and false means local names but "english" numbers
@farhadst please try it, and see if it works for you with either settings

Correction Line 36: F("langNumbers", true); // Needs to be true

@infograf768
Copy link
Member

@dgt41
I confirm that, here, on Firefox, your js does not quite work.
screen shot 2015-03-02 at 18 54 01

If I change ONLY in the original file
C.inputField.form.addEvent('submit', function() {
to
C.inputField.form.addEventListener('submit', function()
I get
screen shot 2015-03-02 at 18 57 16

Then, If I use 'true" for langNumbers, I get:
screen shot 2015-03-02 at 19 01 11

@farhadst
Copy link
Author

farhadst commented Mar 9, 2015

@dgt41 i test this code https://gist.github.com/dgt41/cfcbe426029726ef63e0
and it work
Thank's :)

@infograf768
Copy link
Member

Works here too!

@mhem
I suggest you modify the fa-IR pack to add 2 js files.
these would be the exact copy of this calendar-setup.js proposed here + a copy of the existing fa-IR calendar.js (no need to really compress the originals).
Change the names of these copies to, respectively:
calendar-setup-uncompressed.js
and
calendar-uncompressed.js

Therefore jalali date will also work when Debug is on.
Add the copied files in the pack js folder.
your site install.xml would be

<media destination="fa-IR">
        <filename>index.html</filename>
        <filename>js/index.html</filename>
        <filename>js/calendar-setup.js</filename>
        <filename>js/calendar.js</filename>
        <filename>js/calendar-setup-uncompressed.js</filename>
        <filename>js/calendar-uncompressed.js</filename>
    </media>

@infograf768
Copy link
Member

@dgt41
Thanks a lot! I was frightened we would lose fa-IR for Joomla!

@minijoomla
Copy link
Contributor

@infograf768
I created language package file with this fix and emailed to you.

@infograf768
Copy link
Member

This can now be closed

@roland-d
Copy link
Contributor

roland-d commented Mar 9, 2015

Closed as requested.

@minijoomla
Copy link
Contributor

Hi, one more issue.
if on page mootools not load, below error appear:
TypeError: C.inputField.form.addEvent is not a function

@dgrammatiko
Copy link
Contributor

@MHEHM have you tried to clean your browser’s cache?

@infograf768
Copy link
Member

Also, on which page does it fails exactly?

@minijoomla
Copy link
Contributor

@dgt41 yes, i cleaned my browser cache.
@infograf768 i see this issue on one of my component. but you can see it on joomla user manager.
edit an user, and see firebug console. for user's created date field.
it is readonly but if you save user, date will get wrong value.The error is for addEvent function that is one of mootools function and because of that joomla is in converting mootools to jquery, in forms that not more load mootools and have a date field, this error appear.

@dgrammatiko
Copy link
Contributor

@MHEHM @infograf768
Since 3.4.1 PR #3484 is part of joomla so the code for jalali calendar can be simplified a little bit. (hopefully this will also eliminate this addEvent error)
I will provide a gist

@infograf768
Copy link
Member

I confirm the error:
Timestamp: 25/03/15 10:43:45
Error: TypeError: C.inputField.form.addEvent is not a function
Source File: http://localhost:8888/trunkgitnew/media/fa-IR/js/calendar-setup.js
Line: 14

@dgrammatiko
Copy link
Contributor

@MHEHM @infograf768 Here we go then:
on calendar-setup replace the function after line 55 with:

    jQuery(document).ready(function() {

        var form_id = "#"+C.inputField.form.id;

        jQuery(form_id).on("submit", function() {
            var dateEl = C.inputField || C.displayArea;
            var dateFmt = C.inputField ? C.ifFormat : C.daFormat;
            if (dateEl && parseInt(dateEl.value) != 0 && dateEl.value != '') {
                var date = Date.parseDate(dateEl.value || dateEl.innerHTML, dateFmt, 'jalali');
                C.inputField.value = date.print(C.ifFormat, 'gregorian', C.langNumbers);
            }
        });
    });

This will NOT work as there is a BUG on core-uncompressed.js at line 33:

        jQuery(form).submit();

NEEDS to be:

        jQuery(form).trigger("submit");

Once you verify that this also works on your setups I will make a PR for core.js

@dgrammatiko
Copy link
Contributor

Please also test #6580, to get this bug corrected once for good!

@minijoomla
Copy link
Contributor

@dgt41 I tested your last code with #6580 fix, and it worked for me.
Thanks.

@infograf768
Copy link
Member

Works great here too.
Now commenting in #6580

@balvard
Copy link

balvard commented Apr 9, 2015

Salam
I solved this issue.
in your own component just use this code at beginning of file :
JHtml::_('behavior.framework');
and new language package for persian in joomla 3.4.1 is updated
good luck

@infograf768
Copy link
Member

@dgt41
What is the last iteration for the fa-IR js files

@dgrammatiko
Copy link
Contributor

    jQuery(document).ready(function() {

        var form_id = "#"+C.inputField.form.id;

        jQuery(form_id).on("submit", function() {
            var dateEl = C.inputField || C.displayArea;
            var dateFmt = C.inputField ? C.ifFormat : C.daFormat;
            if (dateEl && parseInt(dateEl.value) != 0 && dateEl.value != '') {
                var date = Date.parseDate(dateEl.value || dateEl.innerHTML, dateFmt, 'jalali');
                C.inputField.value = date.print(C.ifFormat, 'gregorian', C.langNumbers);
            }
        });
    });

But will need 3.4.2 for the proper submit binding

@Fedik
Copy link
Member

Fedik commented Apr 11, 2015

@dgt41 jQuery(C.inputField.form) could save one line, in theory 😉

@dgrammatiko
Copy link
Contributor

@infograf768 To elaborate a little more (previous comment was from my mobile):
The last iteration #6207 (comment) as you already tested and it works for every possible condition. The problem here was that forms didn’t trigger the submit event and although that PR was actually merged in 3.4.1 there is still a bug as the compressed core.js somehow doesn’t have this code. That is the reason I stated that 3.4.2 will be needed, since @Fedik ’s PR is merged and this code is tested against that!

@Fedik Yes you are right here! I guess trying to figure out why this code didn’t execute in conjunction with #6580 I tried all the possible variations I could think, and this just left hanging there 😃

@infograf768
Copy link
Member

@dgt41
I was not asking for me but for the Persian (fa-IR) Translation Team Coordinator.
Can you send him the full file and reference this?
Here are his coordinates:
http://community.joomla.org/translations/joomla-3-translations.html#fa-ir

Thanks

@mamool
Copy link

mamool commented Jul 1, 2015

Hi
I upgrade my joomla to 3.4.2
after update jalali date has problem same first post


This comment was created with the J!Tracker Application at issues.joomla.org/joomla-cms/6207.

@farhadst
Copy link
Author

farhadst commented Jul 1, 2015

Hi @mamool
i have create a new issue for this problem on joomla 3.4.2
Please follow this #7298

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests