Advertisement
Guest User

Untitled

a guest
Jul 19th, 2018
2,050
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <template>
  2. <div >
  3. <div class="page subsciptions_container">
  4.     <!-- <div v-for="x in updates" :key="e.id">
  5.     </div> -->
  6.  
  7.         <div id="filters-group" class="filters-group">
  8.             <div id="topic_tag_bar" class="topic_tag_bar filter-options">
  9.               <div class="reset_button">
  10.                 <button @click="shuffleFilter()" class="topic_tag left coolbtn"><i class="fa fa-times"></i></button>
  11.               </div>
  12.               <div v-for="i in topics" :key="i.id" class="left topic_tag">
  13.                 <button @click="shuffleFilter(i.topic)" :id="i.topic" class="coolbtn ">{{i.topic}}</button>
  14.               </div>
  15.             </div>
  16.         </div>
  17.  
  18.     <!-- <button @click="addItem" class="coolbtn">Add Item</button> -->
  19.     <div id="grid" class="row my-shuffle-container">
  20.  
  21.  
  22.     <div v-for="i in posts" :key="i.id" :class="i.platform" class="picture-item" :data-groups="JSON.stringify(i.topics)" :data-date-created="i.createdAt" :data-title="i.title">
  23.  
  24.      
  25.  
  26.         <figure class="update">
  27.           <div class="update_inner">
  28.             <div class="update_top">
  29.               <div class="right">
  30.                   <div class="dropdown">
  31.  
  32.                     <div class="dropdown-toggle-ellipsis" id="dropdownMenuButton" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
  33.                       <i class="fa fa-ellipsis-v"></i>
  34.                     </div>
  35.  
  36.                     <div class="dropdown-menu mini dropdown-menu-right" aria-labelledby="dropdownMenuButton">
  37.  
  38.                       <a @click.prevent='modal("NewTip")' class="dropdown-item tip" href="#"><i class="fa fa-dollar-sign"></i> Send Tip</a>
  39.                       <div class="dropdown-divider"></div>
  40.                       <a @click.prevent='createNotification' class="dropdown-item" href="#">Unsubscribe</a>
  41.                       <a @click.prevent='createNotification' class="dropdown-item" href="#">Mute</a>
  42.                        
  43.                       <div v-if="isMyChannel(i.owner)">                          
  44.                         <div class="dropdown-divider"></div>
  45.                         <a @click.prevent='deleteNotification(i.id)' class="dropdown-item" href="#">Delete</a>
  46.                         <a @click.prevent='createNotification' class="dropdown-item" href="#">Resend Notifcation</a>
  47.                       </div>
  48.  
  49.                     </div>
  50.               </div>
  51.             </div>
  52.               <div @click="openChannel(i.owner)" class="creator_meta">
  53.                 <div v-bind:style="{ 'background-image': 'url(' + i.channel.avatar + ')' }" class="creator_avatar avatar"></div>
  54.                 <div class="creator_name">{{i.channel.displayName}}</div>
  55.                 <div class="post_time"> {{ niceTime(i.createdAt) }} </div>
  56.               </div>
  57.             </div>
  58.             <div class="thumbnail_container">
  59.             <!-- <a :href="i.link" target="blank"> -->
  60.  
  61.               <div v-if="i.platform == 'Instagram'"><div class="icon instagram"></div></div>
  62.               <div v-if="i.platform == 'Soundcloud'"><div class="icon soundcloud"></div></div>
  63.  
  64.  
  65.               <div v-if="i.duration" class="duration">{{convertDuration(i.duration)}}</div>
  66.               <div class="update_thumb">
  67.  
  68.                 <!-- REMOVE THE IF -->
  69.                
  70.                 <div class="thumb_img" v-if="i.thumbnail.medium" :style="{ 'background-image': 'url(' + i.thumbnail.medium.url + ')' }"></div>
  71.                 <div class="thumb_img" v-else :style="{ 'background-image': 'url(' + i.thumbnail + ')' }"></div>
  72.                
  73.  
  74.                 <!-- {{getColors(i.thumbnail, i.id)}} -->
  75.  
  76.                 </div>
  77.                             <!-- </a> -->
  78.  
  79.             </div>
  80.             <div class="update_title"> {{ trimmedTitle(i.title) }} </div>
  81.          
  82.           </div>
  83.         </figure>
  84.  
  85.  
  86.     </div>
  87.  
  88.  
  89.     </div>
  90.  
  91. </div>
  92.  
  93. </div>
  94. </template>
  95.  
  96.  
  97.  
  98.  
  99. <script>
  100. // import FeedItem from '@/components/feeditem'
  101. import { server } from '@/main'
  102. import $ from 'jquery'
  103. import Shuffle from 'shufflejs'
  104.  
  105. import moment from 'moment'
  106. import momentDurationFormatSetup from 'moment-duration-format'
  107.  
  108. // import numeral from 'numeral'
  109. // import Vibrant from 'node-vibrant'
  110. // import { xyzToCIELab } from 'node-vibrant/lib/util'
  111.  
  112. export default {
  113.     name: 'subscriptions',
  114.     components: {
  115.         // FeedItem
  116.     },
  117.     data() {
  118.         return {
  119.             shuffleInstance: null
  120.             // topics: [// CHANGE TO STORE ( add computed)
  121.             //   {id:this.uuid(), topic:'fortnite'},
  122.             //   {id:this.uuid(), topic:'gaming'},
  123.             //   {id:this.uuid(), topic:'overwatch'},
  124.             //   {id:this.uuid(), topic:'comedy'},
  125.             //   {id:this.uuid(), topic:'commentary'},
  126.             // ]
  127.         }
  128.     },
  129.     mounted() {
  130.         // init shuffle JS
  131.         this.feedShuffle()
  132.  
  133.         // $('#grid').css('overflow', '')
  134.         this.shuffleInstance.filter()
  135.  
  136.         // this.shuffleInstance.filter(function(element) {
  137.         //  return element.getAttribute('data-date-created') < 10
  138.         // })
  139.  
  140.         this.shuffleInstance.sort((a, b) => new Date(a.getAttribute('data-date')) - new Date(b.getAttribute('data-date')))
  141.  
  142.         // this.feedShuffle.prototype.onAppendBoxes = function (newItems) {
  143.         //  newItems.forEach(function (newItem) {
  144.         //      this.feedShuffle.element.appendChild(newItem);
  145.         //  }, this);
  146.         // }
  147.     },
  148.     updated() {
  149.         var vm = this
  150.         this.feedShuffle(function() {
  151.             vm.shuffleInstance.filter('ijernfeofimnreon')
  152.             setTimeout(function() {
  153.                 vm.shuffleInstance.filter()
  154.             }, 300)
  155.         })
  156.     },
  157.     methods: {
  158.         feedShuffle(callback) {
  159.             var element = document.querySelector('.my-shuffle-container')
  160.             var sizer = element.querySelector('.my-sizer-element')
  161.  
  162.             this.shuffleInstance = new Shuffle(element, {
  163.                 itemSelector: '.picture-item',
  164.                 sizer: sizer // could also be a selector: '.my-sizer-element'
  165.             })
  166.             if (callback) callback()
  167.             // shuffleInstance.filter('animal');
  168.         },
  169.         shuffleFilter(topic) {
  170.             this.shuffleInstance.filter(topic)
  171.             $('#topic_tag_bar .active').removeClass('active')
  172.             if (topic !== undefined) {
  173.                 document.getElementById(topic).classList.add('active')
  174.                 // $('.reset_button').show()
  175.             }
  176.         },
  177.  
  178.         addItem() {
  179.             console.log(this.shuffleInstance)
  180.             this.shuffleInstance.add([
  181.                 {
  182.                     id: 4,
  183.                     owner: 3,
  184.                     title: 'FouseyTube goes off on keemstar!',
  185.                     platform: 'yotube',
  186.                     datePublished: '2018-07-16T06:57:31.000Z',
  187.                     duration: 420,
  188.                     link: 'https://www.youtube.com/watch?v=GnH2DIFPnDk&ab_channel=Tys',
  189.                     topics: ['fuck', 'you'],
  190.                     meta: null,
  191.                     thumbnail: 'https://i.ytimg.com/vi/GnH2DIFPnDk/mqdefault.jpg',
  192.                     createdAt: '2018-07-19T14:24:36.463Z',
  193.                     updatedAt: '2018-07-19T14:24:36.463Z',
  194.                     deletedAt: null
  195.                 }
  196.             ])
  197.         },
  198.  
  199.         deleteNotification(id) {
  200.             console.log('deleting notification')
  201.             server
  202.                 .delete(`post/` + id)
  203.                 .then(response => {
  204.                     var removed = this.removeByKey(this.$store.state.posts, {
  205.                         key: 'id',
  206.                         value: id
  207.                     })
  208.                     // this.$parent.updates = removed
  209.                     this.saveData('posts', removed)
  210.                     console.log(response)
  211.                 })
  212.                 .catch(err => {})
  213.         },
  214.         niceTime(time) {
  215.             moment.updateLocale('en', {
  216.                 relativeTime: {
  217.                     future: 'in %s',
  218.                     past: '%s',
  219.                     s: '1s',
  220.                     m: '1m',
  221.                     mm: '%dm',
  222.                     h: '1hr',
  223.                     hh: '%dhr',
  224.                     d: '1d',
  225.                     dd: '%dd',
  226.                     M: '1 month',
  227.                     MM: '%d months',
  228.                     y: '1 year',
  229.                     yy: '%d years'
  230.                 }
  231.             })
  232.             return moment(time).fromNow()
  233.         },
  234.         trimmedTitle(title) {
  235.             if (title.length > 55) {
  236.                 return title.substring(0, 55) + '...'
  237.             }
  238.  
  239.             return title
  240.         },
  241.         convertDuration(duration) {
  242.             if (duration === undefined) return null
  243.             return moment.duration(duration, 'minutes').format()
  244.             // return dur.format('HH:mm:ss', {trim: false})
  245.         }
  246.     },
  247.     computed: {
  248.         posts() {
  249.             return this.$store.getters.getFeed
  250.         },
  251.         topics() {
  252.             return this.$store.getters.getTopics
  253.         }
  254.     }
  255.     // watch: {
  256.     //  topics() {}
  257.     // }
  258. }
  259. </script>
  260.  
  261.  
  262. <style>
  263. </style>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement