This module simply responsifies vertical tabs in admin pages. The result is similar to what we see on Drupal 8:

  • For desktop resolutions vertical tabs will appear in a right sidebar. However, you can also choose vertical tabs to appear on left sidebar through module's administration page.
  • For mobile resolutions vertical tabs will appear at the bottom of the page.

You can choose following options on module's administration form:

  • Which side the vertical tabs will be on wider screens.
  • Width of content and vertical tabs (in percentage).

It has been tested with these administration themes:

Finally, this module is compatible with add/edit node forms that use "Fieldsets" and "Horizontal tabs group" of Field Group module.

Similar modules

The problem is that I found out there are no more alternatives to have responsive vertical tabs on drupal 7. Maybe my module is too simple but I think It can do the job while there is no stable release of Responsive Vertical Tabs.

Homepage

https://www.drupal.org/sandbox/rcodina/2301115

Git

git clone --branch 7.x-1.x http://git.drupal.org/sandbox/rcodina/2301115.git vertical_tabs_responsive

Manual reviews of other projects

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

EthanT’s picture

Hey, @rcodina. You have given the command to your personal repo. The command for everyone else should be something like:
git clone http://git.drupal.org/sandbox/rcodina/2301115.git

Also, this module doesn't contain much code - 16 lines of php that are used to unset two files, and then one very small js function, so I don't think this qualifies for evaluation.

rcodina’s picture

Issue summary: View changes

Thank you @EthanT! I just changed the git clone command.

rcodina’s picture

Issue summary: View changes

I think now it's correct, isn't it?

EthanT’s picture

Yes, @rcodina, but I still don't think this is eligible for review, or at least not to allow you to receive the "promote to full project" permission. The rule is that a module should contain at least 5 functions, and 80 + lines of code, minimum, iirc.

rcodina’s picture

@EthanT, where can I find these rules? Sorry but I'm newbie and I can't find them. If I count php, css and js files, the module has far more than 80 lines of code. Finally, what do you mean by iirc? Thank you!

rcodina’s picture

Although this module is quite small in terms of lines of code, I think it does quite well his job. There is no need for more code. I think it may be handy for a lot of people until a stable release of Responsive Vertical Tabs is out.

EthanT’s picture

Have a look here, @rcodina: https://groups.drupal.org/node/195848
I misspoke when I said 80 lines - the rule of thumb is 120. I'm pretty sure that css doesn't count towards this tally, as you aren't building functions and making use of drupal api's when styling. What is needed is a certain amount of php, first and foremost, and then if you want to use some js towards this requirement, that *may* work (not sure). Either way, there really isn't anywhere near enough here to evaluate your level of ability and adherence to drupal logic and best coding practices.
"IIRC" = "If I remember correctly."

All of this said, this module may be promoted to a full project if there is a community need, but this module does not meet the minimum requirements for you to be given the permission to promote your projects from sandbox to full projects.

rcodina’s picture

Ok, I understand why this module will remain as a sandbox for now.

You can see which level of ability I have If you take a look at this custom modules I've written for some of my projects:
https://github.com/rogercodina?tab=repositories

PA robot’s picture

Status: Needs review » Needs work

There are some errors reported by automated review tools, did you already check them? See http://pareview.sh/pareview/httpgitdrupalorgsandboxrcodina2301115git

We are currently quite busy with all the project applications and we prefer projects with a review bonus. Please help reviewing and put yourself on the high priority list, then we will take a look at your project right away :-)

Also, you should get your friends, colleagues or other community members involved to review this application. Let them go through the review checklist and post a comment that sets this issue to "needs work" (they found some problems with the project) or "reviewed & tested by the community" (they found no major flaws).

I'm a robot and this is an automated message from Project Applications Scraper.

rcodina’s picture

Status: Needs work » Needs review

I have just modified the module so now it passes pareview.sh test.

rcodina’s picture

@EthanT, I have updated the module with a new feature: You can configure via administration page which side vertical tabs will show on desktop resolutions. Now the module has 105 lines of PHP, JS code. Is now ok?

rcodina’s picture

Issue summary: View changes

@EthanT, Do you already think this doesn't qualify for evaluation?

EthanT’s picture

Hey @rcodina - you are still kind of code light, imho, but I like the idea of building out your admin form a little bit more to overcome this. You should add more form options, as opposed to a simple on off kind of toggle. Adding some logic to said form will quickly get you over the lack of code hump.

rcodina’s picture

Issue summary: View changes

@EthanT, I have added two new fields on module's administration form to allow user to select width of content and vertical tabs width. Now I count 185 lines of PHP + Javascript. Could you please take a look on module's code? Thank you!

EthanT’s picture

1) PAReview is clean
2) Functionally works as expected, although you might consider some css cleanup (widths, etc.)
3) Please use t() for text in .module lines 15, 16, 26, 27
4) Not a show stopper, but you could make your .js file more concise. For example:
Instead of:

jQuery('body[class~="page-node"] #content').css('width', 'initial');
jQuery('body[class~="page-node"] #content').css('margin-left', 'initial');

Do:

jQuery('body[class~="page-node"] #content').css({
         'width': 'initial',
         'margin-left': 'initial'
});
rcodina’s picture

Issue summary: View changes
rcodina’s picture

FileSize
210.88 KB

@EthanT, I answer point by point:

1) :)
2) Done
3) I did, but I rolled back this change because PAReview told me I can't use "t" function on hook_menu!
4) Done

I have also fixed an error (container sizes on mobile resolutions were wrong) by adding a little bit of CSS for screens under 960px.

See commit for details.

Do you think this module needs more clean up?

Thank you!

EthanT’s picture

Status: Needs review » Reviewed & tested by the community

Yep, my bad. Looks good to me.

rcodina’s picture

FileSize
159.4 KB

@EthanT, I have added again two rules of CSS I erased because I found out in my project are necessary (see attached screenshot).

Well, now that this project is in state "Reviewed & tested by the community", what is the next step?

Thank you!

rcodina’s picture

FileSize
7.13 KB
132.32 KB

@EthanT, I just found out that on Bootstrap theme administration page there are Vertical Tabs which get full width. With my module active, this page looks really awful. To solve this issue, I think about changing selector body[class~="page-admin"] to body[class~="page-admin-structure"]. I have done some tests in local and it works ok. I enclose the patch. Do you think this change would be ok?

Thank you!

EthanT’s picture

Yes, those css changes are fine. Now you have to wait for others to review your module, and a git administrator to promote this to a full project. Looking through the issues queue, you'll see that this process can take a considerable amount of time.

rcodina’s picture

Ok, thank you @EthanT! Just commited bootstrap.patch! Let's wait :)

rcodina’s picture

Issue summary: View changes

I've done some improvements to leave default vertical tabs CSS/JS on pages where I don't responsify them (for example, Bootstrap theme administration page).

rcodina’s picture

Issue summary: View changes
er.pushpinderrana’s picture

Status: Reviewed & tested by the community » Needs work

@rcodina, thankyou for your contribution!

Automated Review

Best practice issues identified by pareview.sh / drupalcs / coder. None.

Manual Review

Individual user account
Yes: Follows the guidelines for individual user accounts.
No duplication
Yes: Does not cause module duplication and fragmentation.
Master Branch
Yes: Follows the guidelines for master branch.
Licensing
Yes: Follows the licensing requirements
3rd party code
Yes: Follows the guidelines for 3rd party code.
README.txt/README.md
Yes: Follows the guidelines for in-project documentation and the README Template.
Code long/complex enough for review
Yes: Follows the guidelines for project length and complexity.
Secure code
Yes. If "no", list security issues identified.
Coding style & Drupal API usage
  1. (+) vertical_tabs_responsive_admin_settings: This setting form contains separate submit function, even you are also using system_settings_form(). Also in your submit function you are using variable_get() that system_settings_form does itself. Your code should be something like this.
    function vertical_tabs_responsive_admin_settings() {
    
      $form['vertical_tabs_responsive_left'] = array(
        '#type' => 'checkbox',
        '#title' => t('Show vertical tabs on left side.'),
        '#default_value' => variable_get('vertical_tabs_responsive_left', 0),
      );
    
      $form['vertical_tabs_responsive_content_width'] = array(
        '#type' => 'textfield',
        '#title' => t('Content width.'),
        '#description' => t('Enter percentage.'),
        '#default_value' => variable_get('vertical_tabs_responsive_content_width', '70'),
        '#size' => 2,
        '#maxlength' => 2,
        '#required' => TRUE,
        '#field_suffix' => t('%'),
      );
    
      $form['vertical_tabs_responsive_vt_width'] = array(
        '#type' => 'textfield',
        '#title' => t('Vertical tabs width.'),
        '#description' => t('Enter percentage.'),
        '#default_value' => variable_get('vertical_tabs_responsive_vt_width', '30'),
        '#size' => 2,
        '#maxlength' => 2,
        '#required' => TRUE,
        '#field_suffix' => t('%'),
      );
    
      $form['#validate'][] = 'vertical_tabs_responsive_admin_settings_validate';
      return system_settings_form($form, TRUE);
    }
    

    Just removed the extra submit function, it would work in similar as you required.

  2. hook_help() is missing in your module.
  3. (+) vertical_tabs_responsive_page_build: You are adding js/css files using drupal_add_js/drupal_add_css rather use #attached to add the JS/CSS file with page rendered array where these actually required.
  4. vertical-tabs-custom.js:Use Drupal.behaviors, not jQuery(document).ready() in your js file.

The starred items (*) are fairly big issues and warrant going back to Needs Work. Items marked with a plus sign (+) are important and should be addressed before a stable project release. The rest of the comments in the code walkthrough are recommendations.

As I am not a git administrator, so I would recommend you, please help to review other project applications to get a review bonus. This will put you on the high priority list, then git administrators will take a look at your project right away :-)

Thanks again for your hard work.

er.pushpinderrana’s picture

One more point in vertical_tabs_responsive_page_build: you are passing php values in your js file using following code.


// Passing variables to javascript.
  drupal_add_js("var vertical_tabs_responsive_left = " . drupal_json_encode(variable_get('vertical_tabs_responsive_left', 0)) . ";
    var vertical_tabs_responsive_content_width = " . drupal_json_encode(variable_get('vertical_tabs_responsive_content_width', 70)) . ";
    var vertical_tabs_responsive_vt_width = " . drupal_json_encode(variable_get('vertical_tabs_responsive_vt_width', 30)) . ";", 'inline');

This is not a recommended approach in drupal, better to pass these variables in following way:

You can add variables in the Drupal.settings object like the following syntax :
drupal_add_js(array('module_name' => array('base_path' => base_path())), 'setting');

You can have the base_path variable in your js file as mentioned below :
alert(Drupal.settings.module_name.base_path);

For more information you can visit to following URLs:

  1. https://www.drupal.org/node/756722
  2. http://drupal.stackexchange.com/questions/23132/sending-a-variable-to-ja...
  3. http://drupal.stackexchange.com/questions/4482/how-to-send-variable-from...
rcodina’s picture

Status: Needs work » Needs review

@er.pushpinderrana

Thank you for all your suggestions and for recommending me. I have already done all changes you suggested except point number 3 on your first comment. Could you please take a look? I wonder If I have done all changes the right way.

On the other hand, I've read the doc of #attached but I don't figure out how to include my JS and CSS files using it because I don't have any forms (except the form to change module's configuration) Please, could you give me an idea of how I should apply this suggestion on my module?

Thank you so much for everything!

rcodina’s picture

@er.pushpinderrana

I have just uploaded a new version of the module which uses #attached as you recommended. So now all changes you suggested are done.

pkamerakodi’s picture

Status: Needs review » Needs work

Hi,

Thanks for the contribution, mean while some small suggestions if you like to update.

Manual Review

Individual user account
Yes: Follows the guidelines for individual user accounts.

No duplication
Yes
Master Branch
Yes: Follows the guidelines for master branch.
Licensing
Yes: Follows the licensing requirements
3rd party code
Yes: Follows the guidelines for 3rd party code.
README.txt/README.md
Yes
Code long/complex enough for review
Yes: Follows the guidelines for project length and complexity.
Secure code
YES
Coding style & Drupal API usage

1) Not sure what the second paramter does
system_settings_form($form, TRUE), becuase in drupal 7 it excepts only one paramter

2) If you are creating a local scope $ variable for Jquery then i think it is better to use $ than jquery
(function ($) {

})(jQuery);

3) General practice is that
if (left != undefined) we use

if (tyepeof left != 'undefined')

4) Is there any reason why you are using json encode on a string?
drupal_json_encode(variable_get('vertical_tabs_responsive_content_width', 70))

5) is it really necessary to create invisible fieldset as below
$form['vertical_tabs_responsive'] = array(
'#type' => 'fieldset',
'#title' => t('Vertical tabs responsive'),
'#collapsible' => TRUE,
'#collapsed' => FALSE,
'#tree' => TRUE,
'#weight' => 99,
'#group' => 'additional_settings',
'#attached' => vertical_tabs_responsive_get_attached(),
'#attributes' => array('class' => array('element-invisible')),
);

Instead cant we use as mentioned in the documentation.

$form['#attached']['css'] = array(
drupal_get_path('module', 'ajax_example') . '/ajax_example.css',
);

$form['#attached']['js'] = array(
drupal_get_path('module', 'ajax_example') . '/ajax_example.js',
);
$form['#attached']['css'][] = array(
'data' => 'YOUR_INLINE_CODES',
'type' => 'inline',
)

$form['#attached']['js'][] = array(
'data' => 'YOUR_INLINE_CODES',
'type' => 'inline',
)

6) is it necessary to check if (path_is_admin(current_path()) && vertical_tabs_responsive_should_responsify_vt()) { inside vertical_tabs_responsive_get_attached becuase if you are calling the function vertical_tabs_responsive_get_attached only after that check in the parent function.
7) Not sure if the below code is really necessary in hook_help
default:
$out = '';
break;

8) I think it would be better if you could combine these 3 array elements into 1 array element.
$attached['js'][] = array(
'data' => array('vertical_tabs_responsive' => $left),
'type' => 'setting',
);
$attached['js'][] = array(
'data' => array('vertical_tabs_responsive' => $content_width),
'type' => 'setting',
);
$attached['js'][] = array(
'data' => array('vertical_tabs_responsive' => $vt_width),
'type' => 'setting',
);

Prajwal

rcodina’s picture

Status: Needs work » Needs review

@pkamerakodi Thank you so much for your suggestions!!! I answer them one by one:

1) Done
2) Done
3) Done
4) Yes, because if I don't use it, the module doesn't work properly. I don't know why, I just saw it in other module source code ;)
5) Done
6) Fixed
7) It is, pareview.sh asked me to do that.
8) Done

So, all it's done. I'm learning a lot with community suggestions ;)

pkamerakodi’s picture

Thanks looks to good to me. We all are learning. Keep up the good work

joachim’s picture

Status: Needs review » Needs work
  $items['admin/config/vertical_tabs_responsive'] = array(

All admin items MUST be below one of the config sub-sections.


  if ($form_state['values']['vertical_tabs_responsive_content_width'] + $form_state['values']['vertical_tabs_responsive_vt_width'] != 100) {
    form_set_error('vertical_tabs_responsive_content_width', t('Content width plus vertical tabs width must equal 100%'));
  }

If these two settings MUST add up to 100%, then why ask the user for both? Surely you can ask me for just one and calculate the other!

  $form['vertical_tabs_responsive_left'] = array(
    '#type' => 'checkbox',
    '#title' => t('Show vertical tabs on left side.'),
    '#default_value' => variable_get('vertical_tabs_responsive_left', 0),
  );

This is not a good UI pattern. Checkboxes should be used for 'on/off' states, but this doesn't fit that case. Here you force the user to think about what 'off' means. It would be better to have a dropdown with two options: left and right.

function vertical_tabs_responsive_admin_settings() {

Missing form builder params.

 * Configuration form render.

The word 'render' is redundant.

/**
 * Returns true if CSS and JS of this module should be added on currents page.
 */
function vertical_tabs_responsive_should_responsify_vt() {
  $is_node_add = ((arg(0) == 'node') && (arg(1) == 'add'));
  $is_node_edit = ((arg(0) == 'node') && (arg(2) == 'edit'));

Needs a @return.

Also, if you're calling arg() lots, just call arg() without the parameter and look in the returned array yourself.

Lastly, you're calling this function at least 3 times in a single request. Statically cache the return result so you don't have to calculate it each time.

  if (vertical_tabs_responsive_should_responsify_vt()) {
    unset($javascript['misc/vertical-tabs.js']);
  }

Though if your aim is to always change vertical tabs, can't you just assume that if $javascript['misc/vertical-tabs.js'] is set, then you should unset it?

/**
 * Some help for users.
 *
 * Implements hook_help().
 */

The 'implements' line should always be first.

Finally, I tried enabling this module with my own custom theme, and it doesn't work! Vertical tabs get turned off and I just see fieldgroups.

rcodina’s picture

Issue summary: View changes
Status: Needs work » Needs review

@joachim, thanks for your suggestions!!! I have done all you have said. I just want to answer these two issues:

Though if your aim is to always change vertical tabs, can't you just assume that if $javascript['misc/vertical-tabs.js'] is set, then you should unset it?

No, I can't because I only responsify them in node add/edit pages and pages under admin/structure.

Finally, I tried enabling this module with my own custom theme, and it doesn't work! Vertical tabs get turned off and I just see fieldgroups.

Could I have the code of theme to test it together with my module? Without it I can't do anything more. Just now my module is only compatible with following administration themes: Seven, Adminimal and Commerce Kickstart Admin Theme.

joachim’s picture

> Just now my module is only compatible with following administration themes: Seven, Adminimal and Commerce Kickstart Admin Theme

I'm not a themer, so this might be a stupid question, but why does it only work with specific themes?

> No, I can't because I only responsify them in node add/edit pages and pages under admin/structure.

Also maybe a stupid question, but can't it change all vertical tabs?

rcodina’s picture

@joachim

I'm not a themer, so this might be a stupid question, but why does it only work with specific themes?

Because not all themes have same HTML tags, attributes, classes, etc.. So, some CSS/JS tuning may be required in order to get this module running on more themes.

Also maybe a stupid question, but can't it change all vertical tabs?

No because I discovered that some modules/themes use "full width" vertical tabs as form. In theses cases, my module would mess the form and turn into an unusable thing. Just install bootstrap theme and go to theme preferences. You will see an example of this kind of forms.

rcodina’s picture

@joachim

I have done some changes to my module: I found out the way I was attaching CSS/JS files I was losing CSS/JS from other modules. Could you please try again my module on your custom theme?

Thank you!

rcodina’s picture

@all and specially @joachim

I have done some changes in code to improve compatibility with field_group module and with Drupal Commerce Kickstart and Shiny theme. Please, tell me if it works for you.

Thank you so much!

rcodina’s picture

Issue summary: View changes

I think this module is already ok for a first beta release. I wait for full project permission and more reviews. Thanks!

rcodina’s picture

Issue summary: View changes

@all I have just updated the module:

Now it responsifies all vertical tabs in admin pages (not only on node add/edit and admin/structure pages). The module detects automatically if vertical tabs of forms must be responsified: there are some forms that are full width vertical tabs and this module avoids them (bootstrap theme admin page, and forms build with field_group module for example).

rcodina’s picture

@joachim

Though if your aim is to always change vertical tabs, can't you just assume that if $javascript['misc/vertical-tabs.js'] is set, then you should unset it?

Now I always unset this. If it is necessary, I restablish normal vertical tabs behaviour.

Finally, I tried enabling this module with my own custom theme, and it doesn't work! Vertical tabs get turned off and I just see fieldgroups.

Please, try it again.

Also maybe a stupid question, but can't it change all vertical tabs?

Now I detect "full width" vertical tabs forms in order to apply normal behaviour on them. So now I can responsify all forms, not only under node add/edit and admin/structure pages.

rcodina’s picture

Just done a few changes to improve theming and javascript of module.

joachim’s picture

> No because I discovered that some modules/themes use "full width" vertical tabs as form. In theses cases, my module would mess the form and turn into an unusable thing. Just install bootstrap theme and go to theme preferences. You will see an example of this kind of forms.

I've had a look at this, and I'm not sure what you mean by 'full width'. How is the Bootstrap theme settings use of vertical tabs different from node edit?

rcodina’s picture

@joachim

I've had a look at this, and I'm not sure what you mean by 'full width'. How is the Bootstrap theme settings use of vertical tabs different from node edit?

The difference is:

Node edit: there is a form and under it there are vertical tabs.

Bootstrap theme settings page: whole form are vertical tabs.

My module should not do anything on forms which are 100% vertical tabs (aka full width forms).

joachim’s picture

> whole form are vertical tabs

Is it possible to detect this form structure from the form array? That would mean you can drop the specific form ID detection.

rcodina’s picture

Is it possible to detect this form structure from the form array? That would mean you can drop the specific form ID detection.

Yes, it is. With latest changes I done to the module (commited a few days ago) I already handle both cases well. I also simplified CSS selectors a bit.

Check this commit (it is not the latest one).

rcodina’s picture

I have done all I have been told to improve the module. Why no one marks this as RTBC?

I know my module may need more improvements, but this improvements will come form users that will try the first beta version. A lot of users don't use modules that are sandboxes because they want to just download a zip (they don't want to use git or simply they don't know what git is).

hoosk’s picture

Status: Needs review » Reviewed & tested by the community

It works for me. I think he can do a beta version because then a lot of more users will give him feedback.

rcodina’s picture

I just have done a few improvements to the module regarding the code responsible for deciding on which forms vertical tabs should be responsified.

@joachim With this change I have dropped the specific form ID detection

Can anyone tell me why this issue is taking sooooo long?

stBorchert’s picture

Since we are quite busy handling all the project applications you should take part in the Review bonus system. This system rewards people who are willing to help out with a bonus in the form of a prioritized application queue.

Thanks.

rcodina’s picture

Issue summary: View changes
rcodina’s picture

Issue summary: View changes
rcodina’s picture

Issue summary: View changes
Issue tags: +#PAReview: review bonus
klausi’s picture

Issue tags: -#PAReview: review bonus +PAreview: review bonus

fixing tag.

rcodina’s picture

Ok, thanks! What's the difference between two?

klausi’s picture

Status: Reviewed & tested by the community » Fixed

manual review:

  • vertical_tabs_responsive_help(): all user facing text such as the help text must run through t() for translation.

But otherwise looks good to me, so ...

Thanks for your contribution, rcodina!

I updated your account so you can promote this to a full project and also create new projects as either a sandbox or a "full" project.

Here are some recommended readings to help with excellent maintainership:

You can find lots more contributors chatting on IRC in #drupal-contribute. So, come hang out and stay involved!

Thanks, also, for your patience with the review process. Anyone is welcome to participate in the review process. Please consider reviewing other projects that are pending review. I encourage you to learn more about that process and join the group of reviewers.

Thanks to the dedicated reviewer(s) as well.

rcodina’s picture

Thank you so much Klausi!

I will make help text to pass through t() before doing a release. Also, I will checkout all the readings you suggested.

Thanks!

rcodina’s picture

FileSize
54.71 KB

@Klausi I have already done the changes you suggested on hook_help. Also, I just tried to promote my sandbox to a full project but I can't see the button which is shown here in this help page. I've attached an image just to show you the tab "Promote" doesn't appear for me.

Thanks!

klausi’s picture

You have the git vetted user role, so that seems to be in order. Please open a webmaster issue at https://www.drupal.org/node/add/project-issue/webmasters

rcodina’s picture

Thanks @Klausi, I just created an issue as you suggested.

rcodina’s picture

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.