@ucd-lib/theme-elements 1.2.0 → 1.2.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -115,26 +115,26 @@ export default class UcdThemePagination extends LitElement {
115
115
  }
116
116
 
117
117
  /**
118
- * @method updated()
119
- * @description Changes occur on update
118
+ * @method willUpdate()
119
+ * @description Changes before updated
120
120
  */
121
- updated(props3) {
122
- if( props3.has('currentPage') ) {
121
+ willUpdate(props) {
122
+ if( props.has('currentPage') || props.has('maxPages') ) {
123
123
 
124
- if(this.xs_screen && this.screen_check) {
124
+ if( this.xs_screen && this.screen_check ) {
125
125
  let pages = [this.currentPage];
126
126
  this._pages = pages; // Mobile Pagination
127
- }else{
128
- if(this.ellipses && this.maxPages >= 8){
127
+ } else {
128
+ if( this.ellipses && this.maxPages >= 8 ) {
129
129
  this._pages = this._renderEllipse();
130
- }else if(this.ellipses && this.maxPages < 8){
130
+ } else if ( this.ellipses && this.maxPages < 8 ) {
131
131
  this._pages = this._renderOriginal();
132
- }else {
132
+ } else {
133
133
  let startIndex = Math.floor(this.currentPage - (this.visibleLinkCount/2));
134
134
 
135
135
  if( startIndex < 0 ) {
136
136
  startIndex = 0;
137
- } else if( (this.currentPage + (this.visibleLinkCount/2)) > this.maxPages ) {
137
+ } else if ( (this.currentPage + (this.visibleLinkCount/2)) > this.maxPages ) {
138
138
  startIndex -= Math.ceil(this.currentPage + (this.visibleLinkCount/2)) - this.maxPages - 1;
139
139
  }
140
140
  if( startIndex < 0 ) {
@@ -150,9 +150,7 @@ export default class UcdThemePagination extends LitElement {
150
150
  }
151
151
  this._pages = pages;
152
152
  }
153
-
154
153
  } // Desktop Pagination
155
-
156
154
  }
157
155
  }
158
156
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ucd-lib/theme-elements",
3
- "version": "1.2.0",
3
+ "version": "1.2.2",
4
4
  "description": "Custom elements for the UCD brand theme",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -87,8 +87,27 @@ export default class UcdlibSilsSearchRedirect extends LitElement {
87
87
  */
88
88
  _onSubmit(e){
89
89
  e.preventDefault();
90
+ this.doSearch('simple-search');
91
+
92
+ }
93
+
94
+ /**
95
+ * @method _onAdvancedSearch
96
+ * @description Called when advanced search button is clicked
97
+ * @private
98
+ */
99
+ _onAdvancedSearch(){
100
+ this.doSearch('advanced-search');
101
+ }
102
+
103
+ /**
104
+ * @method doSearch
105
+ * @description Either redirects to Primo or fires event listener
106
+ * @param {*} searchType - advanced or basic
107
+ */
108
+ doSearch(searchType){
109
+ let advanced = searchType == "advanced-search";
90
110
  let corpus = this.ucdOnly ? "ucd" : "everything";
91
- let advanced = e.submitter.id == "advanced-search";
92
111
 
93
112
  let url = this.primo.makeSearchUrl(this.query, corpus, advanced);
94
113
  if ( this.preventRedirect ) {
@@ -107,7 +107,7 @@ return html`
107
107
  <div class="checkbox u-space-mr--small u-space-mt--small">
108
108
  <input id="corpus" type="checkbox" ?checked=${this.ucdOnly} @input=${this._onCorpusChange}><label for="corpus">UC Davis libraries only</label>
109
109
  </div>
110
- <button id="advanced-search" class="u-space-mt--small" type="submit">Advanced Search</button>
110
+ <button id="advanced-search" class="u-space-mt--small" type="button" @click=${this._onAdvancedSearch}>Advanced Search</button>
111
111
  </div>
112
112
  </form>
113
113