Advertisement
Guest User

kznavbar-001.patch

a guest
Jun 26th, 2018
141
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Diff 5.04 KB | None | 0 0
  1. diff --git a/src/app/browse/browse.controller.js b/src/app/browse/browse.controller.js
  2. index 74410e9..52ee1f3 100644
  3. --- a/src/app/browse/browse.controller.js
  4. +++ b/src/app/browse/browse.controller.js
  5. @@ -17,6 +17,7 @@ class BrowseController {
  6.      this.$scope = $scope;
  7.      this.$rootScope = $rootScope;
  8.      this.uiSettingsService = uiSettingsService;
  9. +    this.isMusicLibrary = false;
  10.  
  11.      if (this.browseService.isBrowsing || this.browseService.isSearching) {
  12.        this.renderBrowseTable();
  13. @@ -25,11 +26,16 @@ class BrowseController {
  14.        this.renderBrowseTable();
  15.      });
  16.  
  17. +    $scope.alphabet = "0abcdefghijklmnopqrstuvwxyz".split("");
  18. +    $scope.showkznavbar = false;
  19.      this.initController();
  20.    }
  21.  
  22. +
  23.    fetchLibrary(item, back = false) {
  24.      this.$log.debug(item);
  25. +    if (item.uri.startsWith('music-library')) { this.isMusicLibrary = true;}
  26. +    else { this.isMusicLibrary = false;}
  27.      if (item.uri !== 'cd') {
  28.        this.browseService.fetchLibrary(item, back);
  29.      }
  30. @@ -37,6 +43,7 @@ class BrowseController {
  31.  
  32.    backHome() {
  33.      this.searchField = '';
  34. +    this.isMusicLibrary = false;
  35.      this.browseService.backHome();
  36.    }
  37.  
  38. @@ -79,6 +86,7 @@ class BrowseController {
  39.        this.playQueueService.playPlaylist({title: item.name});
  40.      }
  41.    }
  42. +
  43.    clickListItemByIndex(listIndex, itemIndex) {
  44.      let item = this.browseService.lists[listIndex].items[itemIndex];
  45.      this.clickListItem(item);
  46. @@ -195,6 +203,7 @@ class BrowseController {
  47.          item.type === 'folder-with-favourites';
  48.      return ret;
  49.    }
  50. +
  51.    showAddToQueueButton(item) {
  52.      let ret = item.type === 'folder' || item.type === 'song' ||
  53.          item.type === 'mywebradio' || item.type === 'webradio' ||
  54. @@ -202,6 +211,7 @@ class BrowseController {
  55.          item.type === 'cuefile' || item.type === 'folder-with-favourites';
  56.      return ret;
  57.    }
  58. +
  59.    showAddToPlaylist(item) {
  60.      let ret = item.type === 'folder' || item.type === 'song' ||
  61.      item.type === 'remdisk' || item.type === 'folder-with-favourites';
  62. @@ -282,9 +292,35 @@ class BrowseController {
  63.          }
  64.  
  65.          this.table += `<div class="listWrapper">`;
  66. +
  67. +        // 20180626 - add filter ids
  68. +        var firstChar = '';
  69. +
  70.          list.items.forEach((item, itemIndex) => {
  71.            //Print items
  72.            this.table += `<div class="itemWrapper"><div class="itemTab">`;
  73. +          
  74. +          // 20180626 - add filter ids
  75. +          var currentChar = item.title.charAt(0).toLowerCase();
  76. +
  77. +          var isNumber = RegExp('[0-9]');
  78. +          var isAlpha = RegExp('[a-z]');
  79. +
  80. +          if (!isNumber.test(currentChar) && !isAlpha.test(currentChar)) {
  81. +            // if 1char is not a number and not an alpha, then use # as first char
  82. +            currentChar = '0';
  83. +          }
  84. +          else if (isNumber.test(currentChar)) {
  85. +            // if 1char is a number, then use # as first char
  86. +            currentChar = '0';
  87. +          }
  88. +
  89. +          if (firstChar != currentChar) {
  90. +            this.table += `<a id="scrollto-${currentChar}"></a>`;
  91. +            firstChar = currentChar;
  92. +          }
  93. +          
  94. +          
  95.            if (item.icon || item.albumart) {
  96.            this.table += `<div class="image" id="${item.active ? 'source-active': ''}"
  97.                onclick="${angularThis}.clickListItemByIndex(${listIndex}, ${itemIndex})">`;
  98. @@ -393,6 +429,20 @@ class BrowseController {
  99.        }
  100.      }
  101.    }
  102. +
  103. +  togglekzNavBar() {
  104. +    this.$scope.showkznavbar = ! this.$scope.showkznavbar;
  105. +  }
  106. +
  107. +  scrollTo(hash) {
  108. +    var element = angular.element('#scrollto-'+hash);
  109. +    if(element.length > 0) {
  110. +      var container = angular.element('#browseTablesWrapper');
  111. +      container.scrollTop(0);
  112. +      var scrolling = element.offset().top - container.offset().top;
  113. +      container.animate({scrollTop: scrolling}, "fast");
  114. +    }
  115. +  }
  116.  }
  117.  
  118.  export default BrowseController;
  119. diff --git a/src/app/browse/components/browse-nav-buttons.html b/src/app/browse/components/browse-nav-buttons.html
  120. index 48bcc9a..495a57b 100644
  121. --- a/src/app/browse/components/browse-nav-buttons.html
  122. +++ b/src/app/browse/components/browse-nav-buttons.html
  123. @@ -33,3 +33,10 @@
  124.      title="{{'COMMON.RIP' | translate}}">
  125.    <i class="fa fa-download"></i>
  126.  </button>
  127. +<button
  128. +    class="btn-link"
  129. +    ng-click="browse.togglekzNavBar()"
  130. +    ng-if="browse.isMusicLibrary">
  131. +  <i ng-if="showkznavbar" class="fa fa-times"></i>
  132. +  <i ng-if="!showkznavbar" class="fa fa-filter"></i>
  133. +</button>
  134. diff --git a/src/app/themes/volumio/browse/volumio-browse.html b/src/app/themes/volumio/browse/volumio-browse.html
  135. index 07f4d5c..e5337a3 100644
  136. --- a/src/app/themes/volumio/browse/volumio-browse.html
  137. +++ b/src/app/themes/volumio/browse/volumio-browse.html
  138. @@ -11,6 +11,9 @@
  139.            ng-include src="'app/browse/components/browse-search-box.html'">
  140.        </div>
  141.        <div class="clearfix"></div>
  142. +      <div
  143. +          ng-include src="'app/browse/components/browse-kznavbar.html'">
  144. +      </div>
  145.      </div>
  146.  
  147.      <div id="browseTablesWrapper">
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement