In this patch:

  • Wrapped autosave initialization procedure in a Drupal behavior.
  • Assigned new ids to DOM elements with too-generic ids "status", "view", "ignore" and "keep" to avoid conflicts. (Prepended "autosave-")
  • Removed unused global variable "autosaved_form"

Comments

aaronbauman’s picture

StatusFileSize
new4.3 KB
buzzman’s picture

Status: Active » Needs review
liquidcms’s picture

Category: bug » feature

not actually a "bug" is it? more of a what, theming suggestion? or i guess better adherence to standards?

i'll look at committing in a couple days. Can you point to any documentation on what a Drupal.behaviour is?

galaxor’s picture

StatusFileSize
new10.97 KB

Hi. I accidentally did this work as well, before I noticed this bug. That is, I made autosave use Drupal behaviors. My patch slightly different from this one: It only operates on form elements that don't have the 'autosave-processed' css class. Also, after attaching itself, this patch adds the 'autosave-processed' css class to the things it just attached to.

That's a pattern Drupalers use to make sure that if your Behavior gets called more than once on the same object, it won't cause wonkiness.

@liquidcms, here's a document that describes Drupal behaviors: The Drupal Javascript API.

@aaronbauman, I've incorporated your changes to the element ids.

Also, while I was at it, I made it use Drupal.t(). This addresses #669218: Use Drupal.t in autosave.js and #893894: use Drupal's translation mechanism for Javascript files.

Finally, this patch also contains the strongarm compatibility patch I submitted in #850934: Incompatibility with Strongarm module.

Tell me if you would like any of these patches split out, so they can be applied and critiqued separately.

galaxor’s picture

Version: 6.x-2.7 » 6.x-2.9

btw, my patch is against 6.x-2.9

liquidcms’s picture

anyone able to review this??

liquidcms’s picture

Version: 6.x-2.9 » 6.x-2.x-dev

i have committed the drupal.behaviours part and the better DOM ids part

not sure what unused var is about