Make WordPress Core

Opened 8 years ago

Closed 7 years ago

#28965 closed defect (bug) (fixed)

Media Grid JavaScript Clean-up

Reported by: ericlewis Owned by:
Milestone: 4.0 Priority: normal
Severity: normal Version: 4.0
Component: Media Keywords: has-patch
Focuses: javascript, docs Cc:

Description

Media Grid has been developed in a flurry.

Let's sweep through and fix up where urgency previously trumped cleanliness.

Attachments (3)

28965.diff (24.5 KB) - added by ericlewis 8 years ago.
28965.2.diff (29.7 KB) - added by ericlewis 8 years ago.
28965.3.diff (478 bytes) - added by ericlewis 7 years ago.

Download all attachments as: .zip

Change History (17)

@ericlewis
8 years ago

#1 @ericlewis
8 years ago

In attachment:28965.diff:

  • Instead of using an explicitly stated CSS class at the top-level frame of media grid,

use the mode-grid selector to apply styles.

  • Remove the edit mode, which is cruft from a different implementation of bulk edit.
  • Remove screen options CSS, which is unnecessary since the grid is not styled fixed.
  • Use more self-documenting function names, e.g. createViewForContentRegionInBrowseMode, which while verbose, is more useful than createBrowse
  • For media.controller.EditAttachmentMetadata state, remove unnecessary function overloading in lieu of setting region defaults to false in the options hash.
  • Move mode functionality from media.view.MediaFrame to media.view.Frame`.
  • Remove the custom events hash from media.view.Attachment.Details.TwoColumn. Closer method parity with its parent media.view.Attachment.Details.
  • Remove unnecessary methods: media.view.Attachment.Details.render
  • Fix up the image editor view loading business in media.view.MediaFrame.EditAttachments
Last edited 8 years ago by ericlewis (previous) (diff)

@ericlewis
8 years ago

#2 @ericlewis
8 years ago

In attachment:28965.2.diff:

  • More documentation.
  • Replace media.view.MediaFrame.EditAttachments.editMetadataContent with media.view.MediaFrame.EditAttachments.createViewForContentRegionInEditMetadataMode (self-documenting method naming), and clean up the implementation.

#3 @ericlewis
8 years ago

  • Keywords has-patch added

#4 @SergeyBiryukov
8 years ago

  • Milestone changed from Awaiting Review to 4.0

#5 @DrewAPicture
8 years ago

  • Focuses docs added

#6 follow-up: @wonderboymusic
8 years ago

In 29266:

Media Grid: general JS cleanup.

Props ericlewis.
See #28965.

#7 @wonderboymusic
8 years ago

I left out the iOS-style method name changes for now - I think better docs would alleviate the need for those.

#8 in reply to: ↑ 6 @afercia
8 years ago

Replying to wonderboymusic:

In 29266:
Media Grid: general JS cleanup.

hi,
after this I get a blank media grid, no grid items at all, no js errors in the console. I have to add back "router: false" to the default states in media-grid.js but I'm totally new to backbone.js sorry I can't help more.

#9 @wonderboymusic
8 years ago

  • Resolution set to fixed
  • Status changed from new to closed

a lot was tackled here

@ericlewis
7 years ago

#10 @ericlewis
7 years ago

  • Resolution fixed deleted
  • Status changed from closed to reopened

In attachment:28965.3.diff: per @koop, don't select body with jQuery.

#11 @wonderboymusic
7 years ago

In 29367:

Media Grid: don't select body with jQuery when instantiating media.view.UploaderWindow.

Props ericlewis.
See #28965.

#12 @koop
7 years ago

For clarity's sake: document.body is the body element itself, not a jQuery collection. In this case, it'll happen to work either way (which I dislike, I'd rather a more specific API).

Also, I think the container property might be vestigial at this point.

(Also, hey everyone.)

#13 @DrewAPicture
7 years ago

  • Summary changed from Media Grid Javascript Clean-up to Media Grid JavaScript Clean-up

#14 @wonderboymusic
7 years ago

  • Resolution set to fixed
  • Status changed from reopened to closed

This ticket, like #24716, is too broad at this point. We should open tickets for specific things we are doing, or just reference other tickets that we are expanding upon when committing.

Note: See TracTickets for help on using tickets.