From 1d30107c59a99d4a2edb4d24fcfa755dc4702023 Mon Sep 17 00:00:00 2001 From: booploops <49113086+booploops@users.noreply.github.com> Date: Tue, 7 Dec 2021 18:12:35 -0800 Subject: [PATCH] Implemented vue-observe-visibility --- resources/cider-ui-tests/index.js | 16 ++-- .../views/components/mediaitem-artwork.ejs | 15 +++- .../views/components/mediaitem-list-item.ejs | 81 +++++++++++-------- resources/cider-ui-tests/views/main.ejs | 5 +- .../views/pages/library-songs.ejs | 2 +- .../vue-observe-visibility.min.js | 1 + 6 files changed, 72 insertions(+), 48 deletions(-) create mode 100644 resources/cider-ui-tests/vue-observe-visibility.min.js diff --git a/resources/cider-ui-tests/index.js b/resources/cider-ui-tests/index.js index 2609fe69..9276fa08 100644 --- a/resources/cider-ui-tests/index.js +++ b/resources/cider-ui-tests/index.js @@ -1,10 +1,12 @@ +Vue.use(VueObserveVisibility); + + Vue.component('sidebar-library-item', { template: '#sidebar-library-item', props: ['name', 'page', 'cd-click'], methods: {} }); - Vue.component('lyrics-view', { template: '#lyrics-view', props: ["time", "lyrics", "translation"], @@ -83,7 +85,7 @@ const app = new Vue({ "albumName": "Album", "artistName": "Artist", "name": "Name", - "genreNames": "Genre", + "genre": "Genre", "releaseDate": "Release Date", "durationInMillis": "Duration" }, @@ -384,14 +386,12 @@ const app = new Vue({ // sort this.library.songs.displayListing by song.attributes[self.library.songs.sorting] in descending order based on alphabetical order and numeric order // check if song.attributes[self.library.songs.sorting] is a number and if so, sort by number if not, sort by alphabetical order ignoring case self.library.songs.displayListing.sort((a, b) => { - let aa = null; - let bb = null; - if(self.library.songs.sorting == "genreNames") { + if(self.library.songs.sorting == "genre") { aa = a.attributes.genreNames[0] bb = b.attributes.genreNames[0] } - aa = a.attributes[self.library.songs.sorting] - bb = b.attributes[self.library.songs.sorting] + let aa = a.attributes[self.library.songs.sorting] + let bb = b.attributes[self.library.songs.sorting] if (aa == null) { aa = "" } @@ -1074,7 +1074,7 @@ const app = new Vue({ } if (xmlHttp.status === 200) { - console.log('SUCCESS', xmlHttp.responseText); + // console.log('SUCCESS', xmlHttp.responseText); callback(JSON.parse(xmlHttp.responseText)); } else { console.warn('request_error'); diff --git a/resources/cider-ui-tests/views/components/mediaitem-artwork.ejs b/resources/cider-ui-tests/views/components/mediaitem-artwork.ejs index 4cae6dae..7e5c2562 100644 --- a/resources/cider-ui-tests/views/components/mediaitem-artwork.ejs +++ b/resources/cider-ui-tests/views/components/mediaitem-artwork.ejs @@ -6,10 +6,11 @@ \ No newline at end of file diff --git a/resources/cider-ui-tests/vue-observe-visibility.min.js b/resources/cider-ui-tests/vue-observe-visibility.min.js new file mode 100644 index 00000000..1ef2968c --- /dev/null +++ b/resources/cider-ui-tests/vue-observe-visibility.min.js @@ -0,0 +1 @@ +var VueObserveVisibility=function(e){"use strict";function t(e){return(t="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function i(e,t){for(var i=0;i2&&void 0!==arguments[2]?arguments[2]:{},l=function(l){for(var a=arguments.length,c=new Array(a>1?a-1:0),u=1;u1){var n=e.find(function(e){return e.isIntersecting});n&&(t=n)}if(i.callback){var r=t.isIntersecting&&t.intersectionRatio>=i.threshold;if(r===i.oldResult)return;i.oldResult=r,i.callback(r,t)}},this.options.intersection),t.context.$nextTick(function(){i.observer&&i.observer.observe(i.el)})}}},{key:"destroyObserver",value:function(){this.observer&&(this.observer.disconnect(),this.observer=null),this.callback&&this.callback._clear&&(this.callback._clear(),this.callback=null)}},{key:"threshold",get:function(){return this.options.intersection&&"number"==typeof this.options.intersection.threshold?this.options.intersection.threshold:0}}])&&i(t.prototype,r),o&&i(t,o),e}();function o(e,t,i){var n=t.value;if(n)if("undefined"==typeof IntersectionObserver)console.warn("[vue-observe-visibility] IntersectionObserver API is not available in your browser. Please install this polyfill: https://github.com/w3c/IntersectionObserver/tree/master/polyfill");else{var o=new r(e,n,i);e._vue_visibilityState=o}}function s(e){var t=e._vue_visibilityState;t&&(t.destroyObserver(),delete e._vue_visibilityState)}var l={bind:o,update:function(e,i,n){var r=i.value;if(!function e(i,n){if(i===n)return!0;if("object"===t(i)){for(var r in i)if(!e(i[r],n[r]))return!1;return!0}return!1}(r,i.oldValue)){var l=e._vue_visibilityState;r?l?l.createObserver(r,n):o(e,{value:r},n):s(e)}},unbind:s};function a(e){e.directive("observe-visibility",l)}var c={version:"1.0.0",install:a},u=null;return"undefined"!=typeof window?u=window.Vue:"undefined"!=typeof global&&(u=global.Vue),u&&u.use(c),e.ObserveVisibility=l,e.default=c,e.install=a,e}({});