? Success

User tests: Successful: Unsuccessful:

avatar dgt41
dgt41
18 Jan 2015

This is a redo of #4773

Why?

When editing an article, menu, category (anything singular), and press the back button, the refresh or the close button on the browser, user most probably will loose any data without warning. This PR throws a standard browser window with custom message to inform him/her. Of course we are not forcing anything, so he/she can go ahead and close the window, but at least we did informed them!
There is a check for debug and language debug, so this functionality is enabled only when none of these is enabled!

Preview:

Safari
screen shot 2015-01-19 at 1 37 39

Chrome
screen shot 2015-01-19 at 1 37 16

Firefox (NOTE: FF doesn’t support custom messages in the alert called onbeforeunload!)
screen shot 2015-01-19 at 1 38 23

Opera
screen shot 2015-01-19 at 1 37 59

And IE 8 (YES it even works on IE

avatar dgt41 dgt41 - open - 18 Jan 2015
avatar jissues-bot jissues-bot - change - 18 Jan 2015
The description was changed
Labels Added: ?
avatar Fedik
Fedik - comment - 19 Jan 2015

you approach a bit confuse,
the function will display alert even nothing edited, can be annoying.
what about something like:

jQuery(document).ready(function() {
  var changed;
  jQuery('[name]').on('change input', function(){
    changed = true;
  });
  jQuery(window).on('beforeunload', function (event) {
   if(changed){
      return 'alert';
    }
  });
});

or around :smile:

avatar brianteeman
brianteeman - comment - 19 Jan 2015

I really appreciate the detailed work that has gone into this and for testing on multiple browsers. However personally I dont like this. IF it was only happening when some data was changed I might think differently but for it to happen all the time is just a pain

avatar dgt41
dgt41 - comment - 19 Jan 2015

@Fedir @brianteeman Let’s say you try to edit an article. You click on the title in the list view and once you have the form you realize that this is NOT the one you want and you click the back button. Without throwing an alert (actually joomla is politely asking you to use save or cancel button) you will end up with a lock icon in the article, which means that you have to checkin that article (if you are allowed to do so!).
I hope this explains that this is not only for end users but also a way to keep Joomla admins out of the check in button!

avatar brianteeman
brianteeman - comment - 19 Jan 2015

You still get the lock icon with this popup if you click leave this page

avatar dgt41
dgt41 - comment - 19 Jan 2015

@brianteeman Sadly thats true

avatar dgt41 dgt41 - change - 19 Jan 2015
The description was changed
avatar dgt41 dgt41 - change - 19 Jan 2015
The description was changed
avatar dgt41
dgt41 - comment - 19 Jan 2015

@Fedik @brianteeman Implemented the check for changes! So the alert will NOT trigger if no changes made!

avatar brianteeman
brianteeman - comment - 19 Jan 2015

Just retested on a clean site and it didnt matter what I did I never got the popup

avatar brianteeman brianteeman - alter_testresult - 19 Jan 2015 - brianteeman: Tested unsuccessfully
avatar dgt41 dgt41 - change - 19 Jan 2015
The description was changed
avatar dgt41 dgt41 - change - 19 Jan 2015
The description was changed
avatar Fedik
Fedik - comment - 19 Jan 2015

test
works good for me, now

but question about whether we need it,
maybe need some vote? :smile:

avatar brianteeman
brianteeman - comment - 19 Jan 2015

I still cant get it to work (but even if I did I would not be in favour of
this)

On 19 January 2015 at 13:38, Fedir Zinchuk notifications@github.com wrote:

test
works good for me, now

but question about whether we need it,
maybe need some vote? [image: :smile:]


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

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

avatar zero-24 zero-24 - change - 19 Jan 2015
Category JavaScript UI/UX
avatar zero-24 zero-24 - change - 19 Jan 2015
Easy No Yes
avatar zero-24 zero-24 - alter_testresult - 19 Jan 2015 - Fedik: Tested successfully
avatar dgt41
dgt41 - comment - 19 Jan 2015

@brianteeman Due to the way .change is defined in jQuery, this might not work in cases where the edited element hasn’t lost its focus (you have to click somewhere else in the page)

The change event is sent to an element when its value changes. This event is limited to elements, boxes and elements. For select boxes, checkboxes, and radio buttons, the event is fired immediately when the user makes a selection with the mouse, but for the other element types the event is deferred until the element loses focus.

From jQuery API

avatar Fedik
Fedik - comment - 19 Jan 2015

@dgt41 another suggestion use jQuery('form :input').on('changed input', function() { instead of .changed()
this will mark changes on input modification, not only when input lost focus

other thing I would use local variable instead of bother with form element, but like now also can be....

and for which reason you disable this feature if debug enabled ?

@brianteeman maybe you have debug enabled :wink:

avatar dgt41
dgt41 - comment - 19 Jan 2015

@Fedik Disabled on debug was an old request from many PLT members, you can see the comments at #4773

avatar Fedik
Fedik - comment - 19 Jan 2015

@dgt41 so you know why it not very welcome feature? :smile:

avatar dgt41
dgt41 - comment - 19 Jan 2015

@Fedik I think this is a welcome feature for average users. Advanced users, and devs dislike anything that gets in their way, I guess

avatar brianteeman brianteeman - change - 19 Jan 2015
Status Pending Needs Review
avatar brianteeman
brianteeman - comment - 19 Jan 2015

I am setting this to needs review so that the CMS maintainers and PLT can decide if this concept is worth pursuing


This comment was created with the J!Tracker Application at issues.joomla.org/joomla-cms/5815.
avatar wilsonge
wilsonge - comment - 20 Jan 2015

Personally I like the concept (this isn't a formal PLT opinion :wink: ). However I'd make it much simpler. Just check if someone has altered the text in the textarea. I don't think changing other elements of the form is as annoying/time consuming to replace as the article itself.

avatar anibalsanchez
anibalsanchez - comment - 21 Jan 2015

I think that's a wonderful idea....however it does not work if you change text in the editor, category select (Chosen), or Publishing Dates (Calendars).


This comment was created with the J!Tracker Application at issues.joomla.org/joomla-cms/5815.
avatar anibalsanchez anibalsanchez - test_item - 21 Jan 2015 - Tested unsuccessfully
avatar dgt41
dgt41 - comment - 21 Jan 2015

@anibalsanchez reading others people approach in the net, most of them serialize the form data on the page load and then compare the changes (if any). Also this will prevent another erratic behavior e.g. add a word and the delete it, right now this will count as changed form, although it isn’t. Maybe the best approach is to utilize some jquery plugin for this

avatar anibalsanchez
anibalsanchez - comment - 21 Jan 2015

#dgt41 From my humble experience, I have created this https://github.com/anibalsanchez/jquery.saveform.js/blob/master/jquery.xtsaveform.js, based on jquery.saveform.js. It can be tweaked to include hidden fields (.xtd-save-this class).

avatar dgt41
dgt41 - comment - 6 Feb 2015

I am going to close this one, as there is little interest on improving UX.

avatar dgt41 dgt41 - close - 6 Feb 2015
avatar dgt41 dgt41 - close - 6 Feb 2015
avatar dgt41 dgt41 - change - 6 Feb 2015
Status Needs Review Closed
Closed_Date 0000-00-00 00:00:00 2015-02-06 12:00:25
avatar JoshuaLewis
JoshuaLewis - comment - 27 Mar 2015

As stated above, if it is activated with altered text I'm in favor of this.

avatar dgt41 dgt41 - head_ref_deleted - 14 Aug 2015

Add a Comment

Login with GitHub to post a comment