Issue Summary
Problem/Motivation
While previewing layouts at various screen and device dimension sizes is familiar to most front end developers and themers, the mechanics of this efforts may still be unknown or cumbersome to content creators and editors. For many of them, the goal of their efforts is to create great content. Anything that helps them quickly determine what this content might look like across the media that will deliver it to consumers is an improvement.
CMS Competition
Many content management and creation tools are stepping up to aid content creators in this process.
Instant preview by Magnolia CMS: http://www.magnolia-cms.com/magnolia-cms/features/mobile-cms.html
Mobile optimization by Sitecore: http://www.sitecore.net/Products/Web-Content-Management/Mobile-Web/Mobil...
Adobe CQ5 optimization: http://www.adobe.com/it/special/eseminar-enterprise/pdf/CQ5_Mobile.pdf
CQ5 Mobile provides an easy-to-use, browser-based, in-context content authoring environment that eliminates the need for custom client software or separate sites for device types.
Drupal needs to assist in improving the content creation workflow from data model up to the point of end-user consumption.
Proposed resolution
The responsive preview module proposed here is a light-weight tool for content creators to quickly determine how their pages will appear on smaller devices.
It provides preview options for several popular devices. This device list will be kept current through periodic minor releases of Drupal.
Remaining tasks
Follow up issues are tagged responsive preview. Once this is in, they'll be moved to the responsive_preview.module component.
User interface changes
A toolbar tab that launched the preview is added.
API changes
None.
Comments
#1
Tagging.
#2
This patch is not quite a Minimally Viable Product (MVP). But the basic interaction is present. I'll be iterating on it and posting progress patches.
#3
This update adds the ability to change the size of the preview through the input box at the top-center of the container. The input is limited to digits through a validation function.
The interdiff shows changes from #2 to #3.
#4
Work is moved to #1880606: Introduce a configuration UI for theme-based breakpoints within the Breakpoint module queue.
#5
Opening this back up.
I postponed #1880606: Introduce a configuration UI for theme-based breakpoints.
This issue will be an minimally viable product (MVP) implementation of the display portion of a theme-based breakpoint configuration tool.
#6
...
#7
This update styles the toolbar tab to look more like the designs. The tab is rendered as a dropbutton.
This feature can be demoed (after 15 minutes of posting this patch) by navigating to http://simplytest.me/project/spark/8.x-1.x and launching a new sandbox.
#8
#9
Just wondering is this still a WIP? Because evaluating it even a little, I am confused:
The "Show responsive ruler" does nothing?
Desktop shows a smaller window, than my actual desktop
The ruler, does not have the affordance you can drag, that tiny <> part.
The purpose of the ruler, is not clear to me, do we want people to look at specific pixel values? I imagined the 80% case was just switching between breakpoints in your theme.
What if my theme has a black bg? Shouldn't we use some kind of background pattern?
#10
This is still a work in progress. I think Wim just got a little zealous.
I wish we had a tag for "needs progress review" and "needs final review".
#11
This update puts the mobile preview feature behind a checkbox that can be set on a per-theme basis, at the following path /admin/appearance/settings.
The wording of the option is really rough; I just threw it together.
On install of the layout module, the bartik theme is set to have the preview tab displayed -- the tab will not be displayed for Seven or Stark by default. The proper
hook_uninstallvariable cleanup is in place for the theme setting as well.#12
This patch is a major upgrade from #11. It brings the UI closer to the designs by tkoleary.
Those designs can be explored at https://projects.invisionapp.com/share/U4BPGASQ#/screens
I spent the day just getting the UI changes in place and cut some corners with code cleanliness. My next step is to go back and clean up and put in docs. I wanted to get to a point where folks can test the working UI even if it means the code underneath is a bit prototypy.
The latest changes can (always) be tested at simplytest.me with the 8.x-1.x branch.
#13
#12 works great! :) Major step forward indeed!
I found only one bug: "Show developer ruler" didn't work right away. I had to close the mobile preview, open it up again, and then it worked. Note that *something* was happening, because things were shifting around a bit (I think shifting downwards), but nothing visibly appeared. Maybe it appeared underneath the black layer that sits on top of the content?
Afterwards, I looked at the JS console and saw this error five times:
Uncaught TypeError: Cannot call method 'toggleClass' of undefined layout.preview.js:64#14
It turns out the controls don't exist until you've previewed a device. I need to take that case into account. Thanks for the report.
#15
This patch cleans up the CSS and JS. The entirety of the JS file has been commented up. I also fixed the JS error that Wim pointed out in #13.
#16
This patch moves the preview code out of the Layout module and into a new module called Responsive Preview.
I started a project for this module here: http://drupal.org/project/responsive_preview
This patch greatly reduces the functionality of the preview. The developer ruler and size input have been removed. It is now only possible to preview a page at the pre-defined device dimensions. The developer features may be reintroduced at a later time.
Next steps
#17
Changes
Feedback
Testing revealed the following bugs (unfixed in this reroll):
jQuery('html').attr('dir').+++ b/core/modules/responsive_preview/config/responsive-preview.devices.ymlundefined@@ -0,0 +1,21 @@
+ desktop:
+ label: desktop
+ dimensions:
+ width: 1366
+ height: 768
I think this one can be removed? After all, you're going to be looking at this from "a desktop" anyway. Because previewing this device on an iPad is never going to work anyway.
+++ b/core/modules/responsive_preview/css/responsive-preview.base.cssundefined@@ -0,0 +1,85 @@
+/* At narrow screen widths, float the tab to the left so it falls in line with
+ * the rest of the toolbar tabs. */
+.js .toolbar .bar .responsive-preview-toolbar-tab.tab {
+ display: block;
+ float: left; /* LTR */
+}
+/* At wide widths, float the tab to the right. */
+@media only screen and (min-width: 36em) {
+ .js .toolbar .bar .responsive-preview-toolbar-tab.tab {
+ float: right; /* LTR */
+ }
Do we even *want* this to appear on narrow screen widths?
36em seems to imply "smartphoneish" (because on an iPad, it still displays on the right).
Only on tablets and higher it makes sense to show this, IMO.
+++ b/core/modules/responsive_preview/css/responsive-preview.theme.cssundefined@@ -0,0 +1,109 @@
+ left: 0; /* LTR */
I removed this because AFAICT it was not useful at all. The offset was being set by the JS anyway.
+++ b/core/modules/responsive_preview/js/responsive-preview.jsundefined@@ -0,0 +1,380 @@
+ Drupal.behaviors.responsivePreview = {
Docblock for the behavior is missing — AFAIK it's an unwritten rule that each behavior must have some explanation attached to what it does.
+++ b/core/modules/responsive_preview/js/responsive-preview.jsundefined@@ -0,0 +1,380 @@
+ var $body = $(window.top.document.body).once('responsive-preview');
This will actually happily attach multiple times AFAICT.
You should put the rest of the
attach()function's body in an anonymous callback passed in as the second parameter to.once().If I'm wrong, then you need to document this better :)
+++ b/core/modules/responsive_preview/js/responsive-preview.jsundefined@@ -0,0 +1,380 @@
+ // Register a handler on window resize to reposition the tab dropdown.
+ $(window.top)
Why
window.topand not justwindow?+++ b/core/modules/responsive_preview/js/responsive-preview.jsundefined@@ -0,0 +1,380 @@
+ // The list of options will most likely render outside the window. Correct
+ // this.
+ .drupalLayout('correctEdgeCollisions');
Can you clarify this? I don't understand *why* this will "most likely" render outside the window.
+++ b/core/modules/responsive_preview/js/responsive-preview.jsundefined@@ -0,0 +1,380 @@
+ // Size is the width of the iframe.
+ updateDimensions({width: (size || window.top.document.documentElement.clientWidth)});
Why is this call necessary?
loadDevicePreview()is already callingupdateDimensions()with the exact same parameters.Removing this line didn't make any difference and causes the number of calls to
updateDimensions()to drop from 3 to 2 upon initial drawing.+++ b/core/modules/responsive_preview/js/responsive-preview.jsundefined@@ -0,0 +1,380 @@
+ // Trigger a resize to kick off some initial placements.
+ $(window.top)
+ .on('resize.responsivePreview', updateDimensions)
+ .trigger('resize.responsivePreview');
Why is this
.trigger()necessary?loadDevicePreview()is already callingupdateDimensions()with the exact same parameters.Removing this line didn't make any difference and causes the number of calls to
updateDimensions()to drop further from 2 to 1 upon initial drawing.+++ b/core/modules/responsive_preview/js/responsive-preview.jsundefined@@ -0,0 +1,380 @@
+ // @todo, are there any security implications to loading a page like this?
I don't think so, but I think as long as we do the same as overlay.module here, that we'd be good.
So: let's check whether overlay.module does the same.
+++ b/core/modules/responsive_preview/js/responsive-preview.jsundefined@@ -0,0 +1,380 @@
+ /**
+ * A jQuery plugin that contains element manipulation utilities.
+ *
+ * @return {Function}
+ * - The method to invoke this plugin.
+ */
+ $.fn.drupalLayout = (function () {
I think it's generally weird to see
$someElement.drupalLayout('correctEdgeCollisions')and$someElement.drupalLayout('prunePreviewChoices')."drupalLayout" implies a certain degree of generalism, which can be considered true of "correctEdgeCollisions", but most definitely not of "prunePreviewChoices".
If you want to keep the structure the same, then
drupalLayoutshould be renamed todrupalResponsivePreview.#18
Replaced with
.element-hiddenspans.Fixed by taking RTL/LTR into account when setting the edge distances for left or right.
The "standard desktop" is 1366px wide. On a large monitor, it's possible to preview this. If you're monitor isn't large enough, it won't appear as an option.
The only options you get are the ones your device is wide enough to preview. If the result is no devices, then the tab disappears.
oncereturns a jQuery set. You can either pass that set to a callback or store it in a variable.$body.lengthwill be 1 on the first attach and zero on all subsequent attaches. It just saves writing another function and indenting everything another 2 spaces.There are a couple
windowobjects in play here because of the iframe. The behaviors get attached to the page inside the iframe as well, so I'm just being really explicit about which window I want in all cases to avoid any silly mistakes.The CSS should prevent this from happening, so I changed the wording to "might". Whenever elements are absolute positioned like this, I worry that some part of the element will render off screen.
Totally right. Good catch. I removed it.
Good catch again. The control flow didn't always go through
loadDevicePreview. I removed a lot of code and these are some of the vestiges. Although something tells me they could have been redundant before too.I went though drupal.js and found
Drupal.encodePath. So now the code is:// Load the current page URI into the preview iframe.iframeDocument.location.href = Drupal.encodePath(Drupal.settings.currentPath);
Good point about the name, I missed that one during the refactor. I would like to keep this structure because these functions act on jQuery objects and it's just so easy to chain them. But it's polluting the jQuery fn namespace just for convenience. Blech, I need to rewrite them as functions. They still iterate over a set of jQuery objects...just not as a jQuery plugin on the $.fn object.
#19
Thank you for the extensive review, Wim!
#20
Blarg, it posted a file in #18 that I mark not to be listed.
This is the correct patch file: http://drupal.org/files/mobile-preview-1741498-18_0.patch
#21
Hrm, if that makes more sense, okay, but using
text-indent: -9999px;is fine too!You're right, I was making too many assumptions.
So the reason I described it the way I did is because anybody reading core JavaScript will be expecting it to look that way. So could you please add this tidbit of documentation to the code to clarify it? :)
Again, please add to the code docs.
The last two things were just a matter of "calling out code that looks unlike other JS of the Drupal code base and documenting it". This helps other people understand the code. Hence my request to document them.
Reviewed interdiff
+++ b/core/modules/responsive_preview/config/responsive-preview.devices.ymlundefined@@ -15,7 +15,7 @@ devices:
+ label: Standard desktop
Maybe "Typical" instead of "Standard"? Because there is no such thing as a "standard desktop resolution".
+++ b/core/modules/responsive_preview/css/responsive-preview.base-rtl.cssundefined@@ -3,20 +3,35 @@
+/* At narrow screen widths, float the tab to the left so it falls in line with
+ * the rest of the toolbar tabs. */
.js .toolbar .bar .responsive-preview-toolbar-tab.tab {
- float: right;
+ float: right; /* LTR */
}
-
+/* At wide widths, float the tab to the left. */
Both comments say "float left" :) You may want to fix the comments here.
+++ b/core/modules/responsive_preview/js/responsive-preview.jsundefined@@ -57,13 +59,12 @@
+ // The list of options will might render outside the window.
"will might" :)
+++ b/core/modules/responsive_preview/js/responsive-preview.jsundefined@@ -208,17 +204,19 @@
+ var dir = document.getElementsByTagName('html')[0].getAttribute('dir');
I get the need for speed, but having *everything* using jQuery except for this just looks silly?
+++ b/core/modules/responsive_preview/js/responsive-preview.jsundefined@@ -208,17 +204,19 @@
+ var options = {
+ width: size
+ }
Missing trailing semi-colon.
+++ b/core/modules/responsive_preview/js/responsive-preview.jsundefined@@ -208,17 +204,19 @@
+ .css(edge, (offset + size));
Too many spaces, unnecessary wrapping in parentheses
+++ b/core/modules/responsive_preview/js/responsive-preview.jsundefined@@ -240,120 +238,106 @@
+ * - The distance from the edge of the window that a device cannot exceed
+ * or it will be pruned from the list.
Remove the leading dash; it's against doc standards.
#22
--- /dev/null+++ b/core/modules/responsive_preview/config/responsive-preview.devices.yml
Please change hyphen to underscore (responsive_preview.devices.yml).
+++ b/core/modules/responsive_preview/responsive_preview.module@@ -0,0 +1,114 @@
+/**
+ * Page callback: Returns the breakpoints of the current active theme.
+ *
+ * @see responsive_preview_menu().
+ */
+function responsive_preview_get_devices_list() {
There's no responsive_preview_menu() in the patch, and this function isn't a page callback.
+++ b/core/modules/responsive_preview/responsive_preview.module@@ -0,0 +1,114 @@
+function responsive_preview_access() {
Needs a docblock.
#23
This patch addresses comments in #21 and #22.
#24
Tested the patch. Some suggestions:
1. "Android" is an Operating System, not a device. Some Android devices to consider: "Kindle Fire", "Nook", "Surface", "Nexus 7".
2. When your browser window is smaller than the "Typical desktop" size, the preview is too small. That option only works reliably when you have a big enough screen and browser window.
3. I'd add "iPad Mini", to differentiate from a normal "iPad".
Suggestions for follow-up patches:
1. Visualize the height of these devices. Maybe we can render a line or something to denote the bottom of the screen.
2. Ability to flip between portrait and landscape mode.
#25
I dont fully understand, why this is a core patch? It sounds like a great contrib module, but not very useful for core? I understand this isn't ready for review, but Dries reviewing gives the impression this is a serious consideration - and I haven't seen much of a larger product discussion, given that this will really be right in the face of any new user. I often fail to see, the larger idea - with patches like this, the end-goal was to make Drupal a better tool for mobile site building it seems like we worked on some of the fundamentals, and than stopped to end up at the far end - which is a preview mode. With no tools, to impact that preview mode - we seem to missing many of the tools that exist in that middle.
There is little people can do with this module - after all we cut all responsive parts from our blocks/responsive site builder concepts? We dont know if there is a demand for this? Its very prominent tool, even more so than common site building tasks - is the expectations people will do use this often? Wouldn't this fare better, as contrib and or optional core module? Is the strategy to define devices, I imagined that is a wrong strategy?
#26
I filled out the device listing.
Only the options that will fit in your current browser window, the gutters taken into account, will be shown as options to preview. It's true, most folks won't see the typical desktop option. On a Cinema Display, it will probably be available.
We'll just need to discussion the design of the controls. The data to do this is all there.
The collision detection I had in the patch before just wasn't working with long lists, so I replaced it with
jQuery.ui.position, removed a bunch of custom code, and everything is working well now.#27
Bojhan: The target user of this module is content creators, not site builders. It is an important feature available in many other CMSes (although usually much more advanced). That is why it slated for inclusion in core.
#28
Tagging for mobile. Also raising to major, given #27. I agree that achieving the goal of D8 being mobile-friendly is not just about good responsive design, but also making it easy for content creators to preview their pages in common device widths.
Well, after previewing for a particular device and seeing that the page doesn't look good, the content creator could edit the text in the node to be less wordy, or replace images with smaller ones (or configure better image styles for the
<picture>element once we have that working), or if the content creator is a single blogger, perhaps browse the web for a theme that better suits their content, or if the content creator is part of a team, ask the site builder for help on how to improve the way the page looks on different devices.I agree that the original design with the ruler, integrated breakpoint configuration, and responsive layout builder, would have made this better, but sadly, it didn't make it. I still think what's here is useful though.
That wasn't the case with #23, but is fixed in #26: thanks.
#26 looks great to me, but it's 90% front-end code, so I'm not the right person to RTBC it. Hopefully a front-end developer can come along and do that :)
#29
@Dries Right, because we are cutting many of the useful sitebuilders parts from this patch - I am concerned we are leaving its usefulness to only a small target audience, after all site builders is still a real part of our audience too. I don't want this feature to turn into a sales gimmick, it should have a clear actual use amongst both content creators and site builders.
@effulgentsia Thanks for elaborating, it would be useful for us to sum up some of these use cases - because frankly, except for making it less wordy many of the usecases you summarised are site builder related. I don't really for see this being super useful for content creators, given that they have little influence on the layout, font and many of the other crucial aspects that make up a responsive site. Since we are trowing this in the toolbar, right in people's faces it should have an 80% purpose; which means that we are expecting that people use this tool all the time. If thats not the case, and its more likely its a sales gimmick and useful in 30/40% of the usecases - I think its better left as a optional core module (it is now, so I definitely recommend keeping it that way - I think this might flourish better in contrib, but thats my personal pov).
I know calling RTBC, make issues go faster. But this definitely should get more reviews and argumentation (there are 13 followers, and only Acquian reviewers + me - we need to be proactive in reaching out to others when this occurs) if we could have learned anything from the past Spark issues - is that moving too fast will kill more usefull reviews, and end up in dozens of significant followups. Given that this was introduced in feature completion phase it is only normal this needs proactive reach out to to others.
Having used this patch on simplytest.me, immediately a few things jump to mind:
1) Why are we introducing device specific options, the list is already quite long and I imagine will only get longer. I though the options should be like "mobile", "tablet", "desktop". For example, having a kindle fire option in the netherlands is utterly useless, because its not a common device at all - with the ever changing landscape, do we really want to commit to a 80% device list?
2) The lack of a background (pattern) is disturbing, and completely caters to white Bartik like themes. After all, when you have a dark theme, it will blend in with the background and seeing where responsive starts and ends will be very difficult.
3) The [x] seems awkwardly placed, and uses a style that is alien to Drupal. We should consider using a "mode" like trigger (pencil mode) instead of close button.
4) We are introducing a 4th kind of button on the top tray, from mode switching (pencil), tray (menu), link (home) to now mobile preview. Beginners will have no clue what will happen when they click a button. The > dropdown indicator does something, but its also a complete one-off. It's really sad that the toolbar design cannot accomodate more requirements with a single pattern. I feel like the whole tray concept is more and more neglected over one-off features. Why can't this for example, trigger a tray, or a mode - with a toolbox (that way going out of the mobile preview mode, will be the same as going out of pencil mode).
5) With the vertical toolbar button/mode close to it, it starts to feel more and more like that area is a blob of functionality. We should decrease the importance of the vertical toolbar icon or do something else, but as it looks now is a bit too many different buttons close to each other.
6) How does this look on mobile? Where do we draw the line, when this isn't displayed anymore?
7) This breaks when I am in admin - it trows me out of the overlay.
8) This breaks with the vertical menu (jesse, are you not using that mode :D?) You lose the vertical menu, once you click that button? If its a preview mode fine, but that means you cant quickly go to a specific admin option to fix something you see - which I imagine will be annoying. Being in the vertical menu mode should not be a disadvantage, because we have less space.
9) How do we handle things that are triggered upon detection of touch?
#30
Something that hardcode a list of stuff is definitely not worthy for core inclusion in my opinion:
+ ipad2:+ label: iPad 2
+ dimensions:
+ width: 768
+ height: 1024
+ kindlefire:
+ label: Kindle Fire
+ dimensions:
+ width: 600
+ height: 1024
+ kindlefirehd:
+ label: Kindle Fire HD
+ dimensions:
+ width: 800
+ height: 1280
Also, all those device names are trademarked. So I assume we need a place to recognize the trademark somewhere.
This would be a great contrib module, thanks for all your hard work. But in core? Really, no.
#31
#29: This patch — AFAIK — is about the Minimum Viable Product. It's still possible to introduce the more advanced stuff (the "Developer ruler") in a follow-up patch.
Exactly, it's optional, and AFAIK it would remain that way.
RE: 1. I think Jesse just added everything she could think of in response to Dries' remark about "Android" being a non-existing device. Now it's up to us to prune the list.
Points 2 & 3 are styling. Easily fixable.
This is a great point I think. Why not just list all the available devices to do preview of in the tray? It'd also mean less JS :) Would also address your 3rd point.
However, I think this would conflict with toolbar.module's automatic responsive behavior. I.e. on small device widths, it will automatically switch the tray to vertical mode. That vertical tray then doesn't leave enough width to be able to do the preview.
This also answers your 8th point.
RE: 5. You only see the vertical/horizontal tray toggle if you actually have the tray open. So I'm not sure it's really a problem. In any case, that's not something we should address in this issue; that's purely about toolbar.module.
Answered before, and you could've found this yourself: only if one or more of the device previews has a smaller resolution than the current browser width, it will be available. Hence, nothing will be available on smartphones, but smartphones *will* be available on tablets.
RE: 7. No, it doesn't break overlay, it displays the preview on top of the overlay. As soon as you close the mobile preview, it'll show you the overlay again. Also, if that's what you were getting at: it doesn't make sense to do a mobile preview of the overlay, because those are always admin pages.
I don't understand this.
I'm working on a reroll of this patch that addresses the biggest remaining gaps: messy device list, no height preview, etc.
Most of the points raised in #29 are somewhat moot, I believe.
#32
Re: #30: Trademark should not be an issue as, to the best of my knowledge, this falls under nominative fair use.
#33
Re: #29: "@Dries Right, because we are cutting many of the useful sitebuilders parts from this patch - I am concerned we are leaving its usefulness to only a small target audience, after all site builders is still a real part of our audience too. I don't want this feature to turn into a sales gimmick, it should have a clear actual use amongst both content creators and site builders."
Three quick links, but I can find more: http://www.magnolia-cms.com/magnolia-cms/features/mobile-cms.html and http://www.sitecore.net/Products/Web-Content-Management/Mobile-Web/Mobil... and http://www.adobe.com/it/special/eseminar-enterprise/pdf/CQ5_Mobile.pdf. Long story short, mobile preview functionality is common and expected. Open Source systems are lacking behind in this area.
I don't understand why we must target both content creators and site builders in one patch. It's perfectly fine to target content creators with this patch. They are our biggest audience (certainly not a "small target audience"), and the primary reason why Drupal struggles. I'm concerned you don't truly understand Drupal's competitive landscape, or our different target audiences. In any event, we have a vision for adding site builders feature to this.
The list of devices can be updates between minor releases of Drupal. People can submit patches for it. We can maintain it like anything else in Drupal.
#34
The current patch confuses physical pixels and device-independent pixels, which seems to show a deep misunderstanding of how modern mobile devices actually work.
Let's give this time to mature in contrib, as it should. We have enough half-broken things in Drupal 8 already.
#35
@Dries I think its fine to add functionality for sitebuilders in later patches, but I do not see that vision posted as to what features that would contain and or any analysis as to why it should contain that. If there is a vision please share. The reason I think its a small audience, is because even out of the content creators that I am in contact with at small/large scale sites the majority currently doesn't seem to focus on optimising their content for mobile (they put that role with the sitebuilders), and in Drupal's case for those that do - we offer very limited tools to actually optimise it. I am gladly wrong on this count, but I just feel like we are offering a preview option with actually very few useful tools to positively influence that preview. The examples you linked all seem to have more functionality than just, preview which seems to validate my concern that the MVP is larger than just preview?
I don't think its fair to accuse, me or really anyone of not understanding Drupal's competitive landscape - that for a large part in the eye of the beholder. Acquia positions Drupal in a very different way, than it is positioned by the freelancers here in the Netherlands. I'm a little sad that you trow this accusation around, I feel like over the past years my role has often been to defend the content creator. Not understanding a particular need, is very different than not understanding the audience, competitive landscape, and with that Drupal's purpose(s) - if you do feel thats the case, I think me but more importantly the larger community could benefit from a lengthy blog post on this.
The guidance that has been provided to the core community, has been flaky and not been one of competitor analysis - that would bring out much more significant content creator flaws than a mobile preview toolbar, and it has definitely not been how we prioritised the to be developed features. Just pointing to features other CMS's have, and we don't is not a vision - we can really build on.
#36
re: #34
Wim Leers bent his brain around this problem most of the day yesterday. I'd struggled with it to for some hours, but this clever lad figured out a way to incorporate pixel density into the sizing. Truly inspired code! He also culled the list of devices considerably from #26 so there isn't so much overlap in sizing and device.
The current trend of core JS is moving towards Backbone for managing model-like state and the views of those models, so I switched the code here from closured-class-like structure to one a Backbone structure. It ends up being much cleaner and easier to follow.
I added a black-and-white set of borders to distinguish the previewed site from the modal background to address Bojhan's critique of the lack of contrast for darker background colored sites in #29-2.
The mobile preview button now glows blue when the preview is active.
The preview is now constrained by the device height as well.
#37
The last submitted patch, mobile-preview-1741498-36.patch, failed testing.
#38
#36: mobile-preview-1741498-36.patch queued for re-testing.
#39
Woo. Thanks for your reactivity on this! Very impressive.
This is definitely getting somewhere, but there is still some way to go...
+ iphone:+ label: iPhone 5
+ dimensions:
+ width: 640
+ height: 1136
+ dppx: 2
Browsing through the code, I do not think that getting into the pixel density business is a good idea. We are most likely not going to be able to emulate media-queries for
device-pixel-ratioso that they work properly in the simulator.If we want something that is useful for people while not pretending to be an exact simulation of a specific device, I think we should avoid naming devices all together. Really, only two things matter for the 80%:
Here is the list of devices I would like to see:
That maps relatively well with the Android screen size distribution, which defines the following four sizes:
(we probably don't want to pick exactly those values, but more the exact device independent size of the most typical device in the size... for example for "normal" it's the iPhone3/4 with 480dp x 320dp)
For all the non-desktop sizes, we also need to be able to preview portrait and lanscape orientation.
#40
#39:
Emulating those media queries is indeed impossible. But that's not why this information is in there.
It's there because it makes it easier to deal with devices that have "odd" dppx values, such as the Nexus 7. That device's width is 800 pixels, but it reports 603 pixels, in other words, it has a dppx ratio of about 1.3 (that's what pieroxy indicated and the value that I used, but obviously it's wrong, because 800/603=1.3266998342 — turns out Wikipedia pegs it at 1.325, which yields 800/1.325=603.77535. I've updated it accordingly).
So, in order to not have to list the Nexus 7 as a 603x966 pixels device, which looks extremely weird, I figured it'd be better to have slightly more metadata, to keep it sane & clean.
When I look at this in a logical, puristic manner, I completely agree with you. However… reality is that most people would expect to see familiar names. "Small phone" doesn't ring any bells.
If you want to simplify it further — which I think is a good idea again from a logical POV — then I'd suggest to remove the Android devices and only retain the Apple devices. Pretty much everybody knows what the dimensions of an iPhone and iPad are. Their brand names have been around for years. There's so many different Android brand names, device names, resolutions, pixel densities and so on that even including the flagship (i.e. best known) devices is going to cause users of this functionality to wonder what these devices are.
(I've never seen a Nexus 4 or 7, for example. They're far from common in Belgium.)
For now, I've kept this the same, because I expect some bikeshedding here :P So, I propose that we defer from discussing the specific device list to use to a follow-up issue. That's a matter of choice, it's not a technical problem.
Agreed, but I was hoping that could be a follow-up as well.
#36:
TabStateModelremains largely unchanged, but I moved the unrelated attributes out of there, intoPreviewStateModel</a> and <code>EnvironmentModel(for the text direction and viewport width — I got rid of the parent window reference). This allows for much more clarity and better separation.EnvironmentModel'sviewportWidth). This allows for better decoupling and as dumb-as-possible Backbone Views: they should simply respond to model changes as much as possible, and do as little else as possible.#41
I forgot to attach screenshots. These are pre-#36 screenshots, from the work I passed on to Jesse and that she molded into #36. As of #36, things look prettier :)
(Screenshots of my site because it's not yet responsive, plus it has both large and small text, and a big image, that make the difference very clear.)
#42
Reviewed the PHP / module code. Only found one minor typo in the .info. Also a doc suggestion for extensibility.
+++ b/core/modules/responsive_preview/responsive_preview.infoundefined@@ -0,0 +1,5 @@
+description = Provides a component that previews the a page in various device dimensions.
"the a page"
+++ b/core/modules/responsive_preview/responsive_preview.moduleundefined@@ -0,0 +1,130 @@
+/**
+ * Returns a list of devices and their properties from configuration.
+ */
+function responsive_preview_get_devices_list() {
+ $devices = config('responsive_preview.devices')->get('devices');
+
If the suggested process to change devices or add more devices is that this single yml is changed, then it would be great to document. That is how the code currently "allows" device changes. I guess contrib can have a module to allow device list editing based on this yml key.
#43
This patch address the two issues raised by Gábor in #42
Damien, I've added a follow-up and assigned it to myself for the orientation change improvement you suggested in #39.
#1920454: Add an orientation toggle to the responsive preview feature so that a page may be previewed in portrait and landscape modes
#44
I don't know why bot is so slow on #43, but clearly, nothing in the interdiff could have caused that or broken anything, and #40 is both green, and the review log shows that it took the normal amount of time.
Jesse and I updated the issue summary and filed all follow up issues that have been raised here (I think, though please add more if that's not the case).
Although I'm not a front-end developer, I looked over the code, and while I don't deeply understand every bit of it, it does look well structured and scoped, so I'm confident that whatever problems surface can be resolved.
I also manually tested this again, and did not find any problems other than what we already have follow ups for.
What does / doesn't belong in core is often contentious, but ultimately is for Dries to decide. Assuming Dries commits this, if someone still feels it should be removed from core, please open a follow up to make that case. Dries often listens to solid arguments, and has several times removed things from core that he originally wanted.
We'll need to determine what other tools are in scope in #1920564: Decide what else is in scope for responsive preview and ensure contrib can extend what isn't, but even if the answer is nothing, I still think a preview is useful. As I said in #28, for sites where the content creator is also the site builder, seeing the preview could lead the person to any number of decisions from configuring image styles and text formatters to selecting a different theme. For sites where the content creator isn't the site builder, even if all the preview accomplishes is letting the content creator discover that there's a problem, and then all the content creator can do is inform the site builder to fix it, that's still a useful outcome.
Given all this, RTBC.
#45
I'd like to commit this to 8.x. We can decide to remove it later if it is poorly received. We have a good track record of doing so.
#46
I am definitely concerned this is a bit of a skewed review process, there have been two non-spark reviews that both identified serious issues that are largely bumped to followups. Although I appreciate the work that has gone into this, it has been very late and left little room for involvement of the larger community.
I am not sure if committing this now is a good idea, we have received little to no feedback of the people involved in mobile besides jesse, this had no a11y review, it adds a optional module that has no clear use cases as pointed out (@effulgentsia you didn't seem to cover use cases that content creators can influence?), and a lack of useful site builder functionality. It would be useful if we have a plan for this, but this proposal is just not mature - like other proposals of Spark have been.
Anyways,- you can commit it, but its exactly situations like this that people have been afraid of - because even though valid points have been raised they are not really discussed before commit. I'm fine if this is the process for Favorites-of-Dries, but its not one that encourages larger community involvement.
#47
I think Bojhan's correct when he says that concerns about mobile presentation is, currently at least, predominantly a site builder concern. He's also correct when he says that there aren't many tools we offer people to actually do something about it if their preview looks messed up.
OTOH, I think that this concern logically belongs on the content creator side, and after playing with it for a good 15-20 mins, wearing my "content creator/site builder combo" hat, I really want this on not only my own blog, and Drupal.org handbook pages and the like as well. Even though I have at least half of those devices laying around my house somewhere (something that's definitely not true for most content creators, especially of low-end/freelance type sites), It's so flipping easy to just run through each of the previews one-by-one that I'll probably just use this 98% of the time. And while mobile testing isn't part of my content creation workflow now, it certainly probably should be by 2014 when most serious Drupal 8 sites will start coming out. A simple and useful tool like this out of the box allows Drupal 8 to stand out from the crowd when it comes to mobile support.
With this being a separate, optional module, and with the device listing stored in the configuration system, I think the risk in committing it to core is low. If it ends up like Dashboard, poor and neglected and largely unused in favour of superior contrib alternatives, we can easily remove it in D9. If it ends up like Contextual/Seven/Toolbar, mostly ubiquitous on standard Drupal sites, and continuing to evolve over time, then great. In Drupal 9 maybe it can preview responsive turkeys. ;)
I agree with Damien that a "switch orientation" button of some kind is a pretty important component of this. OTOH, I think it's fine to handle as a follow-up, and the issue's already been created.
So, long story short, I concur with RTBC on this, and would love to see it in D8. :)
#48
@webchick I agree that's its a good idea, but I am just not sure about the current state - I know we are all before feature freeze and all but we did not have enough reviews to evaluate whether we are anywhere near MVP. Anyways just warning for Dashboard like situations, where we rush features in because Dries likes it - and then no one is interested to improve it, although Spark has committed to working in the cleanup phase - their list of things to solve has become incredibly long with quite some majors and lose-ends in both the edit-in-line, toolbar and now this module.
I imagine good improvements/followups would be:
1) Although content creators are advertised as the primary target audience, for them this will primarily be a "escalation" tool, to see that their article sucks in a certain device resolution. Perhaps for this purpose, we should add some "text" that is useful for the content creator to relay to the site builder (e.g. Iphone, Landscape mode).
2) We advertise that Drupal is thinking "mobile-first", but we currently in the UI offer little to no useful sitebulder tools around mobile. I think that means that we should try to bubble up some of those tools into this UI, like initially proposed with the theme break points, that is useful information for site builders. However clearly that cannot be shown to content creators, so we will need a way to disclose that more nicely.
3) I know the follow up to this will be to enable it by default. I would be against that until we figure out our toolbar strategy, we can't just keep pushing stuff to the top level. We will now have 3 icons on the right, all with different behaviors (dropdown, activate buttons all over, and tour). We are now near clean-up, we should not treat the toolbar like something we can endlessly stuff things in.
I guess I just like features to be more mature, when they get into core - in terms of review process, that hasn't happened here. I hope you understand, that will always be a concern of mine. Because in the end, if features are not actually useful (like Dashboard) to our larger audience, it is a negative bump in our UX for a full version (affecting in D7's case, at least 500.000 people) - even though the idea itself is really good (like this idea is really good). Its my role to avoid that from happening, a thorough review process is a significant way to do that. Up until 14 February, I did not take this serious - after all, we had many immature features rallying towards feature freeze. I imagine many other contributors felt like that.
#49
At a minimum, there's the case of writing a node, saving it as unpublished, and wanting to preview on different sizes before deciding whether to publish. Then, maybe deciding to be less wordy (something I often struggle with, and nothing quite like seeing that someone will have to scroll 5 pages worth to see something to motivate getting to the point faster). Or else, deciding to escalate the problem to the site builder. Even though escalating a problem to the site builder is not something done via Drupal's UI, it is still something that content creators can "influence".
But I also think the content creator / site builder blended role (like a single blogger) is an important one to consider, and here again, being able to quickly preview while in content creator mode, and then upon seeing a problem, putting on the site builder hat and figuring out a solution is equally useful.
I think the "viable" part of "minimum viable product" means different things to different people. My standard of evaluation is whether the patch as-is is better or worse than not having the feature at all in core. To me, there's no question that it's better, but I understand that others could see it differently.
#50
I think with this hat on you want more information, like the theme its break points. I understand why we initially removed that, after all core is no theme debugger. But it seems like the biggest site builder part? Can't we have like a tiny "information" area - where we display the selection in text, and its meta information (breakpoints)? Especially on the mobile display there would be the space for this, possibly we can hide it behind an icon or something a like.
I agree, largely core features are evaluated by "does it make it worse", I always evaluate by "is its current form desirable, if Drupal was released tomorrow". That comes from previous experience, of many things that didn't get improved after they got it - but perhaps my judgement is clouded by Drupal 7 period which was incredibly hard on contributors who had to fix all of the stuff we pushed in.
#51
Follow-up issues if it gets committed: #1920698: [meta] Responsive Preview follow-ups.
#52
#50
Bojhan, yes, enriching the UI with more information is definitely possibe. This code existed in previous patches and Kevin has preliminary designs to that effect. It was removed to simplify this issue and bring this closer to a feature MVP, to be improved in subsequent patches. As you note, we'd want to hide that rich info behind a toggle or a button so the initial experience is just one of a quick preview with the possibility to experiment and manipulate right beneath the surface.
Here's the prototype link:
https://projects.invisionapp.com/share/JVBPENHP#/screens/4867869
#53
Assigning to Dries for the final call on this, and marking it as something that was RTBC at time of feature freeze.
#54
Hey, everyone!
Just want to be sure you know about the modules we have developed some time ago:
http://drupal.org/project/mobileadaptivetest
http://drupal.org/project/adaptive_layout_tester
It has similar idea and maybe it can be useful to you. We will be happy to help you anyway!
#55
Given that there are bookmarklets like http://lab.maltewassermann.com/viewport-resizer/ I wonder why this needs to be a module?
create mode 100644 core/modules/responsive_preview/images/close.pngI wonder how many more different close icons we want to introduce in Drupal core?
+++ b/core/modules/responsive_preview/config/responsive_preview.devices.yml@@ -0,0 +1,45 @@
+devices:
A configuration object whose name contains "devices" does not need a "devices" key.
+++ b/core/modules/responsive_preview/css/responsive-preview.base-rtl.css
@@ -0,0 +1,38 @@
+ * Toolbar tab.
+++ b/core/modules/responsive_preview/css/responsive-preview.base.css
@@ -0,0 +1,110 @@
+ * Toolbar tab.
+++ b/core/modules/responsive_preview/css/responsive-preview.theme-rtl.css
@@ -0,0 +1,36 @@
+ * Toolbar tab.
+++ b/core/modules/responsive_preview/css/responsive-preview.theme.css
@@ -0,0 +1,141 @@
+ * Toolbar tab.
That's an awful lot of custom styling, for a toolbar widget type (a dropdown list) that should be supported natively by Toolbar.
+++ b/core/modules/responsive_preview/js/responsive-preview.js@@ -0,0 +1,581 @@
+/**
+ * Registers theme templates with Drupal.theme().
+ */
+$.extend(Drupal.theme, {
...
+ layoutContainer: function () {
...
+ layoutClose: function () {
...
+ layoutFrame: function (url) {
These are not within the module namespace.
+++ b/core/modules/responsive_preview/responsive_preview.module@@ -0,0 +1,130 @@
+ 'href' => '',
+ 'options' => array(
+ 'fragment' => '!',
+ 'external' => TRUE,
+ ),
...
+ '#theme' => 'links',
+ '#links' => responsive_preview_get_devices_list(),
Why don't you use an item list instead of links, if you don't want to output links?
+++ b/core/modules/responsive_preview/responsive_preview.module@@ -0,0 +1,130 @@
+/**
+ * Prevents the preview tab from rendering on administration pages.
+ */
+function responsive_preview_access() {
+ return !path_is_admin(current_path());
+}
I don't understand why this condition exists.
#56
Wooow, this makes me a sad panda...
I didn't knew about this issue untill I read Dries his blogpost.
1) The patch is rushed in a couple of weeks
2) Like Sun said, there are tools for that in the browser that work a lot better.
3) It doesn't fix any bugs and it's a completly seperate module. It could be contrib.
4) It doesn't mean it's marked as spark that it should be in core.
5) It doesn't help content editors. It will give the impression those are the only screensizes. And seriously is someone going to check every state when adding content
6) It doesn't help the sitebuilder because yeah they use the more performant and flexible browser tools anyway.
Maybe some decent independent usability tests could tell us some more.
Please reconsider adding this to core... (at least give the impression that it's not yet decided)
This will frustrate some people (including me) if this get in without a good reason.
I still wonder why I ever would use this module?
Well in this case Dries his spark agenda always will say *add this to core*.
So I believe we must give others the opportunity to react to this issue and convince him that it's not a good idea after all.
(with good and valid arguments)
*spark profile material*
ps: I'm not sure how "hard" my post sound (for native english speakers). But it's not ment to be hard so please don't think I'm being an evil guy here.
#57
From what I gather for the original proposal is that this is a feature that is aimed aimed at clients working within the content approval workflow. It's common, in my experience, for clients to request this kind of feature. When they do, all they are interested in is ticking 'mobile friendly' off the checklist, the same way they would preview the page in a desktop browser before signing this off.
This isn't a feature for developers, or site builders, or even themers. This is a feature to sell Drupal to clients, which I think it would do pretty well. Arguments of "I won't use this" aren't really relevant to the decision unless you spend a lot of time approving content.
Whether this should go into core or contrib, based on the context above:
If the answer is yes then I see that as a justified reason to add it to core. Being able to compete with other platforms is key to Drupal's growth, that obviously benefits all of us.
#58
@LewisNyman: when is the last time you used Drupal core as a demo in your sales meeting? Being in core or not is totally irrelevant to the sales question.
On the other hand, putting something half-baked in core is a really good way to increase our technical debt. We have enough of that, we should focus on cleaning-up the existing debt, not add more.
#59
Your point on adding technical debt to core for no benefit is completely true and no one is disagreeing with that. Whether it does have a benefit being in core is still a question not discussed in depth. I think it's naïve to think that one demo meeting makes for 100% of a potential client's contact with Drupal.
#60
Response to review
#55-1
I brought this up with Kevin and he's given me a new image.
#55-2
Good to know. Updated.
#55-3
A fair point. At the moment, there's only one example of this type of dropdown -- a dropdown that isn't quite a dropbutton because it doesn't have a primary action. It's more like a select box, but select box would take even more styling to undo the native form element appearance, so I just went with a button followed by a list. If we see more instances of this type of element, I agree it should be made a type of display element that the toolbar offers. At the moment, it's custom code here or custom code there and it seems keeping the changes isolated to this module is just as well for the moment.
#55-4
Right, holdovers from a module name refactor. Updated.
#55-5
Great suggestion. Updated.
#55-6
One of our assumptions is that this feature is useful for content editors, not site builders. There is therefore no need to offer a preview of an admin page.
Changes
#61
tagging sprint
#62
Could we check if the following is true?
<?php+ * We assume all mobile devices' layout viewport's default width is 980px. It
+ * is the value used on all iOS and Android >=4.0 devices.
?>
The official Android documentation and various internet resources still say that the default viewport size on Android is
800px. I haven't found any mention that it changed in Android 4.0.#63
#62: My sources for that are limited, but this guy is really an expert in the mobile field, so I'd assumed it to be true.
I guess what this really implies is that this another aspect that should be incorporated into the .yml file so that we can accomodate whatever devices out there are using today or three years from now. We should make as few assumptions as possible. Easy enough to change of course :)
Thanks by the way, that's great feedback!
#64
Removed by mistake "RTBC Feb 18th"
#65
Found PPK's test page, and I can confirm the
980pxon my Galaxy Nexus running Android 4.2.2.#66
I don't know what the normal process is about adding something like this to core. Personal i don't really have a strong opinion. but it feels like comments / serious concerns of sun / aspilicious / bojhan are being neglected here.
Could be i'm missing discussions in IRC, but it doesn't seem resolved from a 'i just read this issuu'-perspective.
#67
This patch adds a label to the preview frame that exposes the device's name, dimensions, pixel density and the orientation. The active device is also marked in the toolbar tab dropdown with a checkmark.
This patch also implements front-end tests through the testswarm module.
The icons in the sprite could use some cleaning up. I've asked tkoleary to look at them. I'm not nearly so effective with Photoshop.
#68
The last submitted patch, mobile-preview-1741498-67.patch, failed testing.
#69
+++ b/core/modules/responsive_preview/responsive_preview.infoundefined+++ b/core/modules/responsive_preview/responsive_preview.infoundefined
@@ -0,0 +1,7 @@
+name = Responsive Preview
+description = Provides a component that previews a page in various device dimensions.
+package = Core
+version = VERSION
+core = 8.x
+
info file need conversion to info.yml
#70
converted info file to info.yml
#71
The last submitted patch, mobile-preview-1741498-70.patch, failed testing.
#72
#70: mobile-preview-1741498-70.patch queued for re-testing.
#73
The last submitted patch, mobile-preview-1741498-70.patch, failed testing.
#74
The module EnableDisableTest seemed like a non-legit fail, hence I retested it in #72, but it seems it's legitimate after all. It's probably related to the .info to YML conversion issue?
#75
I think it is because testswarm is not converted to info.yml.
#76
I created an issue for testswarm, #1937240: Convert info file to yml
#77
info file of testswarm is converted
#78
#70: mobile-preview-1741498-70.patch queued for re-testing.
#79
Ew. No. No dependencies between core and contrib, please:
+dependencies:+ - testswarm
#80
yay, more useful information!
#81
One more technical argument. This tool can lie to you as behaviors are specfic to the environment they are run in. For example some css/js behaves different in a scaled desktop than on an ipad. Thats why you always have to test with a "real" ipad when you're building mobile/responsive sites.
So with this tool, the management people you 'sold' this widget to can/will say: "Hey it looks great in my preview, why does it renders like that on my ipad". So if it's realy a sales tool you give management more tools to shoot at developers and themers.
I'm not a themer but I have seen problems with ipads and other mobile devices on every project I worked on caused by device specific issues (in combination with mobile specific browsers).
*Don't ignore this post like most of my previous post.*
#82
@aspilicious: that would also be a great argument for those who said above that browser plugins and other 3rd party desktop tools should be used for this, I guess. Those would not reproduce the real-real environment of the mobile device either. Let alone the touch controls vs. the mouse based navigation if touch detection features are used, etc. That would lead us to never attempting to support this since its not possible to be perfect, and just say to people to buy a piece of each device.
#83
Perfection is impossible, because we can't reproduce all exotic features and quirks of each possible device. That'd be insane :)
It's a best-effort thing, sure. But it does give people without the financial budget to test on each and every device to get a pretty good idea. And even if you have the budget, it's impossible to jump from previewing in one device to another with the same speed. All of the internet is best-effort. Those who strive for pixel perfection also have the budget to buy many test devices, and indeed won't be using this tool.
Also, did you see the screenshots in #41? There's hardly any difference… (the most notable difference lies in the font rendering, which is also true for Windows vs. OS X vs. Linux)
#84
Yeah to me the big win on this isn't a sales gimmick (not sure why that assertion is being made?) but because it actually empowers people without $14,000 in hardware laying around to get a reasonable idea of what their site is going to look like on numerous mobile devices in about 30 seconds flat.
Is it a "perfect" preview? No, of course not. But I don't understand why someone would expect that either. The frame border is clearly generic, and all it's doing is window sizing (actually a little more than that). If we were shipping with device chrome like several other proprietary CMSes do, then possibly, but that's not even an option for a GPL project.
Seriously, just apply the patch and play with it. It's an extremely small and unobtrusive feature, but also really handy and practical. I'd love to have something like this on Drupal.org when developing some of the larger landing page types of things.
#85
@webchick: Obviously, nobody is arguing about the usefulness of the feature. What's on the table is whether this belong to core at the eleventh hour, while there are *a lot* of other half-backed features to fix.
That's exactly where the "sales gimmick" comes to play: the only possible argument for having this into core is that it might help against the competition during a sales process. I have argued against this particular reasoning in #58.
Other then that, really, absolutely no good reason for this to be in core.
#86
Yes gabor if you want to do proper testing that is the case. If you need to support a new windows tablet you probably have to buy one to be sure it works. If you do want a preview for developer reasons than I would use browser tools in stead of these javascript tricks as they are "slow".
Tech people know those are just "previews", management does not. So thats why I say: Don't use it to sell Drupal, which is the primary reason if I read all the comments above. Because they remember those tools and want to use them.
#87
This was discussed in IRC, so just to re-iterate my stance as it relates to various "sales gimmick" assertions:
Designing and creating content for desktop browsers only already doesn't make sense in 2013. It's going to be an edge case by 2014, by the time people actually use Drupal 8. I therefore don't remotely understand why people think this feature is a "nice to have," let alone a mere "sales gimmick." Yes, proprietary CMSes already figured this out long ago, and we need to catch up (which impacts people trying to sell Drupal). But to me, this is a critical component of the task of content creation for any CMS that wants to have longevity for the next 5+ years. What you see is NOT what you get when you're only accounting for your desktop browser, so baking that assumption into core makes zero sense to me.
I've heard concerns voiced about the device list going out of date. Yes. For core, I'm sure we'd update in point releases based on some list of "top used devices" or whatever. For your own site, it's a CMI file. Update it for the devices that make sense for your particular use case.
I've also heard concerns that we don't know what mobile devices will be in 2015 (Google Contacts™? ;)). Yes. We'll need to evolve this feature over time, same as we'll need to evolve Modernizr, same as we'll need to evolve all of our mobile-facing features because this is a fast-changing world. But we already evolve features in D7 today, so this is nothing new.
If your manager's not smart enough to know that s/he's not looking at a "true" preview, then simply don't enable the module on your site. It's optional, like all of the other Spark modules.
#88
@webchick: Please be kind enough to read the points of the other parties, before trying to drown them under a wall of text.
Again, nobody is arguing against the usefulness of this feature. What's on the table is whether is belongs in core or not.
And because:
... I'm arguing that this belongs in the contrib / distributions land for now.
#89
I was responding to aspililicious's assertion, specifically, and documenting the follow-up conversation we had in IRC for transparency. Not trying to drown anyone. :)
I think your concerns can mostly be resolved now that http://buytaert.net/code-freeze-and-thresholds has been adopted. Basically, this patch can sit here and continue to get reviewed and improved as needed, and if we ever get below thresholds enough to commit new features, could be under consideration then, like various other features that didn't make the cut. We can commit features up all the way up until RC as long as we keep our technical debt down.
#90
This patch removes the testswarm dependency.
Thanks jibran for converting the info file to yml.
#91
Patch is awesome. Just played with it on simplytest.me. Great work.
Just one suggestion all the devices are declared in
responsive_preview.devices.yml. If devices can be defined using @Plugin annotation then contrib can add a lot more devices.#92
The last submitted patch, mobile-preview-1741498-90.patch, failed testing.
#93
I fixed a few issues in the JavaScript regarding the calculation of scaling transforms. I found these while backporting this module to Drupal 7 (http://drupal.org/node/1915852/git-instructions/7.x-1.x). The diff is small and changes are evident (I hope!).
#94
It is something similar to how views handler are defined in D8. In D7 a
hook_responsive_preview_devices()which can be used to define new devices.I don't want to get of track here we can discuss it in the follow up if someone likes the idea.
#95
@jessebeach amazing work, this looks great!
#96
#94: AFAIK the current viewpoint that Jesse and I hold is the one put forward by Dries, and it boils down to this: "no need to make this more complex than it needs to be". The list of devices is defined in a config file. If you want to modify the list of devices, then just modify the config file. That's what the config system exists for :) I don't think it makes sense to have a plugin type to define devices: 1) there's no logic involved, only metadata, hence it'd be massive overhead, 2) it doesn't really make sense for *modules* to provide new devices; each site owner decides for himself which devices he wants to support, and hence which ones he'd like to preview in. Therefor a configurable list of devices makes most sense.
I hope that adequately answers your questions :)
#97
Thanks @Wim Leers for explaining.
This is fine by me.
#98
I just caught up on this thread after being away for the past few weeks. Just responding to the discussion of what the benefit of this being in core is. Particularly:
Which is often a very valid reason for something to be in contrib. However, one could also claim that being able to preview a node at all before saving it is a feature that from a code architecture standpoint, could live in contrib. And also suffers from being potentially deceptive, has UX problems, and many developers, including myself, never use. But the reason node previews are a core feature is because being able to preview content before saving it, for many people, is an essential part of the content management process.
Similarly, I would extend #87 with an assertion that given the complete paradigm shift of mobile devices being in wide use already and especially in the next couple years, that someone with just a Drupal core installation not being able to quickly and seamlessly preview content in a range of sizes before saving/publishing it will seem as ridiculous as if you couldn't preview at all. As ridiculous as not being able to add images to posts (which we finally fixed in D7) and not having a wysiwyg editor (which we finally fixed in D8).
I sympathize with the concerns of this not having had time to get refined in contrib, but I also think that applies to much of what the mobile initiative has had to deal with: it's a result of everything related to mobile web technology changing so fast.
Maybe for one reason or another this won't make it in, but for the reasons above, I'll be a bit embarrassed about D8 if that's what happens.
#99
@effulgentsia: I already argued elsewhere that preview being also completely broken should be removed from core and mature in contrib. There is no reason to have a feature in core if it half-backed or half-broken, even if it can be considered by some a "core feature".
#100
@Damien: Ah. Well, good to know you're being consistent in that regard :)
#101
Browsed throught the code, can we avoid the shortcut.admin.js-style jQuery chaining ?
this.$el// Render the visibility of the toolbar tab.
.toggle(this.model.get('fittingDeviceCount') > 0)
// Toggle the display of the device list.
.toggleClass('open', isDeviceListOpen)
// Render the state of the toolbar tab button.
.find('> button')
.toggleClass('active', isActive)
.attr('aria-pressed', isActive)
// Return to $el.
.end()
.find('.device.active')
.removeClass('active')
// Return to $el.
.end()
.find($deviceLink)
.addClass('active');
Not readable.
#102
While working on backporting this module to D7, I added a block that launches the previewer so that the module wouldn't need to depend on the Navbar. I forward-ported the block to D8. Both the block and the toolbar components share a Backbone model, so their state is identical independent of which component is interacted with.
We'll need to move the testswarm tests to the FAT module if this is committed to core. For now, I'm leaving them in this patch so they are more convenient.
#103
The last submitted patch, mobile-preview-1741498-102.patch, failed testing.
#104
#102: mobile-preview-1741498-102.patch queued for re-testing.
#105
Note that we've backported this to D7 as the http://drupal.org/project/responsive_preview module. If you want to test out on your "real" Drupal 7 sites, have at it!
#106
@Jesse, what needs to happen to get this to a committable state?
This is a cute feature in its current state, I think I was wrong to fight it that much.
#107
To put it bluntly: the Drupal 8 gambit is that the frontend and mobile features will make it weather out the shitstorm developers will throw over the backend. Let's get this done.
#108
I have no idea what @chx means, but I am guessing its something about the state of Drupal.
Anyways, reviewing again. I think the patch is bugged, I do not get what jesse shows in #67. Could we get a reroll? The toolbar overlaps with the information part, there is no way to return to ordinary view, the arrow jumps around (do we really need an arrow?), there is a gray block on top of some previews (iPhone 4), there is useage of a checkmark in front of the selected option - this is quite new to Drupal, could we use a background color too?
I still do not get why you are so keen on adding specific devices, I understand it is easier to comprehend, but its just so fragile. Because you will need updates, to make sure they are up-to-date, as sizes changes, new mobile phones get more popular, it is currently very skewed towards Apple (there is no android tablet), there will be large potential for this list to become convoluted as we constantly add new ones (do we have rules on removing old ones?), and users are going to wonder how to preview it on every other device. I have not yet seen how we deal with this. It's all in .config to me, is just blowing away concerns and not actually addressing it, because we end up with a list that due to its code simplicity will be misleading to users in the long run.
I am happy we didn't rush this in, and allowed for further refinements because the meta data provides very useful information content creators can relay to site builders. @effulgentsia I think the thing that you lay it out clearly; the reason this got so much backslash is because it was rushed, and that always upsets people - especially when concerns are met with a lot of resistance. I think a lot of features have gone in, with loads and loads of UX followups (toolbar, edit in line) - sadly, few of them are going to get resolved before release, I think thats why me and probably also others push back on rushing things. Because in the end we need to solve those issues, and many of them are not within the resource reach of the Spark team.
Once we get a reroll, I will do a visual review - I have a few ideas, that might make it look nicer.
#109
I still agree on this, as mentioned several times already. I think a simple Phone / Phablet / Tablet would be (1) more manageable, (2) more future proof, and (3) less deceptive (because we don't pretend to do a preview of how it's going to look on an actual iPhone).
#110
I've addressed some bit-rot that set in since #102 was posted and we got
Drupal.displacecommitted. The preview window now positions its top edge using the latest Drupal Position-Rite Technology™.I also added an Esc key press handler so the preview can be closed with the keyboard in the case the Bojhan encountered where the close X button is unreachable.
Kevin gave me a cleaned up icon sprite, so I've incorporated that as well. I haven't made any changes to the icons themselves.
In many ways I'm just the developer on this issue and I can't make this call on my own, so I haven't touched this code. The good news is that making this change would just be editing a configuration file, so it won't be difficult to alter.
#111
Hand-updated to include type: module for #1292284: Require 'type' key in .info.yml files. Did not check if there are other changes needed though, just a direct update for that.
#112
The last submitted patch, mobile-preview-1741498-111.patch, failed testing.
#113
The patch did not apply to the contextual JS either, because of minor code cleanups in events. I made that apply. All the rest if new code, so it did apply fine. Patch is smaller mainly because of lack of diffstats in my setup, the same files/changes are included.
#114
I gave this patch a try with the latest core head today, and it still works as good as ever.
#115
So to give this the final test before marking it RTBC, someone should:
1) install it on simplytest.me (or wherever).
2) test creating a new article on a mobile device. Check the preview.
3) check editing that article on a mobile device. Check the preview.
4) Repeat steps 2 & 3 with at least android & apple devices.
5) Mark RTBC with screen shots from something like Opera Mobile Emulator.
#116
@mgifford And the Spark team needs to coinside with the feedback that is opposing the use of device specific options, and I still get some bugs around the information?