diff options
| author | Jules Laplace <jules@okfoc.us> | 2016-08-30 13:42:16 +0200 |
|---|---|---|
| committer | Jules Laplace <jules@okfoc.us> | 2016-08-30 13:42:16 +0200 |
| commit | a28c7299d75b592a1f47221719304fefaa2a39a7 (patch) | |
| tree | 2e283e8d61d01117cdd220010759bdf9b7dde335 /StoneIsland/www/js/lib/blogs/HubView.js | |
| parent | 85183bf6eb549cd0833bd1cc764f34c1feae0c22 (diff) | |
fix hub, fix product view
Diffstat (limited to 'StoneIsland/www/js/lib/blogs/HubView.js')
| -rwxr-xr-x | StoneIsland/www/js/lib/blogs/HubView.js | 45 |
1 files changed, 35 insertions, 10 deletions
diff --git a/StoneIsland/www/js/lib/blogs/HubView.js b/StoneIsland/www/js/lib/blogs/HubView.js index e73e49a7..0d733494 100755 --- a/StoneIsland/www/js/lib/blogs/HubView.js +++ b/StoneIsland/www/js/lib/blogs/HubView.js @@ -36,7 +36,7 @@ var HubView = ScrollableView.extend({ }).sort(function(a,b){ return a[0] > b[0] ? -1 : a[0] == b[0] ? 0 : 1 }).map(function(pair){ - console.log(pair[1]) + // console.log(pair[1]) return pair[1] }) this.$loader.hide() @@ -45,7 +45,7 @@ var HubView = ScrollableView.extend({ // id date subtitle body link store image[uri caption] this.data.forEach(function(row){ // console.log(row) - console.log(moment(row.date)) + // console.log(moment(row.date)) var t = this.template.replace(/{{id}}/g, row.id) .replace(/{{date}}/, moment(row.date).format("MM.DD.YYYY")) .replace(/{{title}}/, row.title) @@ -58,7 +58,7 @@ var HubView = ScrollableView.extend({ } this.$content.append($t) - if (row.image.length > 1) { + if (row.image && row.image.length > 1) { // image gallery var $gallery = $(".gallery-" + row.id) row.image.forEach(function(img){ @@ -82,19 +82,44 @@ var HubView = ScrollableView.extend({ } else { // single image + var url = row.link + var is_video = url.match(/youtube|youtu.be|vimeo/) + var image_url + if (row.image && row.image.length) { + image_url = row.image[0].uri + } + else if (is_video && url.match(/youtube|youtu.be/)) { + var ytid = (url.match(/v=([-_a-zA-Z0-9]{11})/i) || url.match(/youtu.be\/([-_a-zA-Z0-9]{11})/i) || url.match(/embed\/([-_a-zA-Z0-9]{11})/i))[1].split('&')[0]; + image_url = "http://i.ytimg.com/vi/" + ytid + "/hqdefault.jpg" + } + else { + image_url = "" + } + var el = document.createElement("div") - el.style.backgroundImage = "url(" + row.image[0].uri + ")" + + if (is_video) { + var ytid = (url.match(/v=([-_a-zA-Z0-9]{11})/i) || url.match(/youtu.be\/([-_a-zA-Z0-9]{11})/i) || url.match(/embed\/([-_a-zA-Z0-9]{11})/i))[1].split('&')[0]; + var tag = '<iframe src="https://www.youtube.com/embed/' + ytid + '?" frameborder="0"></iframe>' + el.innerHTML = tag + + // webkit-playsinline (html attribute) + // &playsinline=1 (yt iframe api param) + } + else { + el.style.backgroundImage = "url(" + image_url + ")" + } el.className = "item" $(".gallery-" + row.id).append(el) $(".gallery-" + row.id).data("row", row) // video, append play button - if (row.link.match(/youtube|youtu.be|vimeo/)) { - var play = document.createElement("div") - play.className = "play" - $(".gallery-" + row.id).append(play) - $(".gallery-" + row.id).addClass("gallery-video-post") - } +// if (is_video) { +// var play = document.createElement("div") +// play.className = "play" +// $(".gallery-" + row.id).append(play) +// $(".gallery-" + row.id).addClass("gallery-video-post") +// } $t.find(".gallery-left").remove() $t.find(".gallery-right").remove() } |
