Answers.Body: <p>You could modify this JavaScript to do it for you. We currently have it running on a site where this was sought-after</p>
  
  <p>Caveat: Our script opens ALL folders, not just the first level - hence the need to modify.</p>
  
  <pre><code>jQuery(window).on('load', function() {
      var $ = jQuery;
  
      var openFolders = function() {
          var imageRootLinks = $('a[data-key^="folder:"]');
  
          $.each(imageRootLinks, function(index, link) {
              var imageRoot = $(link).parent();
              var toggle = imageRoot.find('.toggle');
              if (toggle.length &amp;&amp; !imageRoot.hasClass('expanded')) {
                  toggle.first().click();
              }
          });
      };
  
      // open folders in left menu
      openFolders();
  
      // open folders in image selector
      $(document).ajaxComplete(function(e, status, requestData) {
          if (requestData.url &amp;&amp; requestData.url.indexOf('getElements') &amp;&amp; requestData.data &amp;&amp; requestData.data.indexOf('context=modal&amp;elementType=Asset') != -1) {
              openFolders();  
          }
      });
  });
  </code></pre>
  
  <p>Then simply include the JS-file through a plugin</p>
  
  <pre><code>// runs on all requests
  public function init() {
      // check that user is logged in and in the control panel
      if ( craft()-&gt;request-&gt;isCpRequest() &amp;&amp; craft()-&gt;userSession-&gt;isLoggedIn() ) {
          // the includeJsResource method will add a js file to the bottom of the page
          craft()-&gt;templates-&gt;includeJsResource('myplugin/js/openFolders.js');
      }
  
  }
  </code></pre>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-10-18T11:11:06.067Z
Answers.LastActivityDate: 2017-10-18T11:11:06.067Z
Answers.UserDisplayName: Fuglsetrampen
Body: <p>Is there any way to make the Assets folder also show the first sub folder level by default, like in the attached screenshot?</p>
  
  <p><a href="https://i.sstatic.net/taDuA.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/taDuA.png" alt="enter image description here"></a></p>
  
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2017-10-16T18:43:14.160Z
Comments.Text: I would like to see this as well!
Comments.UserDisplayName: Anna_MediaGirl
Tags: <assets><control-panel>
Title: Assets folder first level open by default
ThreadText: # Assets folder first level open by default
  
  (Asked by: username_0 on 2017-03-28)
  
  Is there any way to make the Assets folder also show the first sub folder level by default, like in the attached screenshot?
  
  [![enter image description here](https://i.sstatic.net/taDuA.png)](https://i.sstatic.net/taDuA.png)
  
  **Tags:** assets, control-panel
  
  > **Comments:**
  > **username_1**: I would like to see this as well!  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_2 on 2017-10-18. Score: 2 | Accepted answer
  
  You could modify this JavaScript to do it for you. We currently have it running on a site where this was sought-after
  
  Caveat: Our script opens ALL folders, not just the first level - hence the need to modify.
  
  ```
  jQuery(window).on('load', function() {
      var $ = jQuery;
  
      var openFolders = function() {
          var imageRootLinks = $('a[data-key^="folder:"]');
  
          $.each(imageRootLinks, function(index, link) {
              var imageRoot = $(link).parent();
              var toggle = imageRoot.find('.toggle');
              if (toggle.length && !imageRoot.hasClass('expanded')) {
                  toggle.first().click();
              }
          });
      };
  
      // open folders in left menu
      openFolders();
  
      // open folders in image selector
      $(document).ajaxComplete(function(e, status, requestData) {
          if (requestData.url && requestData.url.indexOf('getElements') && requestData.data && requestData.data.indexOf('context=modal&elementType=Asset') != -1) {
              openFolders();  
          }
      });
  });
  
  ```
  
  Then simply include the JS-file through a plugin
  
  ```
  // runs on all requests
  public function init() {
      // check that user is logged in and in the control panel
      if ( craft()->request->isCpRequest() && craft()->userSession->isLoggedIn() ) {
          // the includeJsResource method will add a js file to the bottom of the page
          craft()->templates->includeJsResource('myplugin/js/openFolders.js');
      }
  
  }
  
  ```
  
  
  ---
  
  