mediacms/static/js/playlist.js

1 line
26 KiB
JavaScript
Raw Permalink Normal View History

!function(){"use strict";var e,t={6081:function(e,t,n){var a=n(2541),i=(n(2322),n(9268),n(9006),n(5090),n(3233),n(9808),n(4458),n(2004),n(8407),n(6394),n(8288),n(5677),n(2129),n(4655),n(288),n(3675),n(5101),n(3080),n(5466)),l=n(541),r=n(3613),o=n(2546),s=n(8578),u=n(4234),c=n(7642),d=n(2819),p=n(473),f=n(3074),y=n.n(f),m=n(7777);function g(e){return i.createElement(m.s,{items:e.media,playlistId:e.playlistId,hidePlaylistOptions:e.hidePlaylistOptions,singleLinkContent:!0,hideDate:!0,hideViews:!0,hidePlaylistOrderNumber:!1,horizontalItemsOrientation:!0,itemsCountCallback:e.itemsCountCallback,itemsLoadCallback:e.itemsLoadCallback,pageItems:99999,inPlaylistPage:!0})}function v(e){return(v="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 h(e,t){for(var n=0;n<t.length;n++){var a=t[n];a.enumerable=a.enumerable||!1,a.configurable=!0,"value"in a&&(a.writable=!0),Object.defineProperty(e,a.key,a)}}function b(e,t){return(b=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function P(e,t){return!t||"object"!==v(t)&&"function"!=typeof t?S(e):t}function S(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function E(e){return(E=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}g.propTypes={media:y().array.isRequired,playlistId:y().string.isRequired,itemsCountCallback:y().func,itemsLoadCallback:y().func,hidePlaylistOptions:y().bool},g.defaultProps={hidePlaylistOptions:!0};var k=function(e){!function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&b(e,t)}(u,e);var t,n,a,o,s=(a=u,o=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}(),function(){var e,t=E(a);if(o){var n=E(this).constructor;e=Reflect.construct(t,arguments,n)}else e=t.apply(this,arguments);return P(this,e)});function u(e){var t;return function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,u),(t=s.call(this,e)).state={media:e.media},t.containerRef=i.createRef(),t.onItemsLoad=t.onItemsLoad.bind(S(t)),t}return t=u,(n=[{key:"onItemsLoad",value:function(){if(this.props.loggedinUserPlaylist){var e=this.containerRef.current.querySelector(".items-list");if(e){var t=this.props.id,n=function(e){return this.state.media[e]}.bind(this),a=function(e){for(var t=this,n=[],a=0;a<e.length;)n.push(this.state.media[e[a]]),a+=1;this.setState({media:n},(function(){l.PlaylistPageActions.reorderedMediaInPlaylist(t.state.media)}))}.bind(this);d.ZP.create(e,{onStart:function(t){e.classList.add("on-dragging")},onEnd:function(l){for(var s,u,c,d=[],f=e.querySelectorAll(".item-order-number div div"),y=0;y<f.length;)(u=y+1)!==(s=parseInt(f[y].getAttribute("data-order"),10))&&(c=n(s-1).friendly_token,(0,p.putRequest)(r.ApiUrlContext._currentValue.playlists+"/"+t,{type:"ordering",ordering:u,media_friendly_token:c},{headers:{"X-CSRFToken":(0,p.csrfToken)()}},!1,i,o)),d.push(s-1),f[y].setAttribute("data-order",u),f[y].innerHTML=u,y+=1;e.classList.remove("on-dragging"),a(d)}})}}function i(e){}function o(e){}}},{key:"render",value:function(){return i.createElement("div",{ref:this.containerRef,className:"playlist-videos-list"+(this.props.loggedinUserPlaylist?" draggable":"")},this.state.media.length?i.createElement(g,{itemsLoadCallback:this.onItemsLoad,playlistId:this.props.id,media:this.state.media,hidePlaylistOptions:!this.props.loggedinUserPlaylist}):null)}}])&&h(t.prototype,n),u}(i.PureComponent),_=n(8204);function w(e){return(w="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof