<link href="//netdna.bootstrapcdn.com/bootstrap/3.0.0/css/bootstrap.min.css" rel="stylesheet" id="bootstrap-css">
<script src="//netdna.bootstrapcdn.com/bootstrap/3.0.0/js/bootstrap.min.js"></script>
<script src="//code.jquery.com/jquery-1.11.1.min.js"></script>
<!------ Include the above in your HEAD tag ---------->
<div class="container">
<div class="row">
<h2>Create your snippet's HTML, CSS and Javascript in the editor tabs</h2>
</div>
</div>
<script type="text/javascript">
function getVideoGaleries(_PageOfGalleries) {
$(".videoPagging").removeClass("active");
$(".videoPagging_" + _PageOfGalleries).addClass("active");
$.ajax({
url: '/_layouts/15/WSSC.PRT.PNT6.Core/Handlers/Ajax.ashx',
data: {
method: 'WSSC.PRT.PNT6.Galleries:VideoGallery:PrintVideosList',
page: _PageOfGalleries,
rand: Math.random()
},
type: 'POST',
success: function (result) {
$(".VideoGalleriesContent").html(result);
FindLikeThingsAndDisplayStars();
}
});
}
function paging() {
dlinna1 = $(".jPag-control-back").next().css("width");
if (dlinna1 != null) {
dlinna1 = dlinna1.split("px")[0];
dlinna1 *= 1;
if (dlinna1 > 284) dlinna1 = 284;
dlinna1 += 112;
}
dlinna = $(".jPag-control-back").next().children().eq(0).css("width");
if (dlinna != null) {
dlinna = dlinna.split("px")[0];
dlinna *= 1;
dlinna += 112;
}
if (dlinna != null && dlinna1 != null) {
if (dlinna > dlinna1) { $(".jPag-control-back").next().css("width", dlinna1 - 102 + "px"); $(".jPag-control-back").next().next().css("left", dlinna1 + 10 + "px"); }
else $(".jPag-control-back").next().next().css("left", dlinna + "px");
}
}
</script>
<script id="video-template" type="text/x-handlebars-template">
<div class="videogallery-container clearfix">
{{#if this}}
{{#each this}}
<div class="item-wrapper">
<a href="{{PlayerUrl}}" class="item-video-wrapper fancyboxlink" style="background: url({{CoverUrl}}); background-size: cover;">
<img class="item-video-play-btn" src='/_layouts/15/WSSC.PRT.PNT6.Design/img/Galleries/play.png'>
</a>
<div class="item-footer">
<a href="{{UrlToGallery}}" class="item-comment-count-wrapper">
<div class="item-comment"><span>{{CommentsCountStr}}</span></div>
</a>
<div class="item-like-wrapper">
<div id='like_things_locator' class='LIKE_div_initial_locator' objtype='video' objid='{{ID}}'></div>
</div>
</div>
</div>
{{/each}}
{{/if}}
</div>
</script>
<div class='c-video-gallery js-video-gallery'>
<h1 class="o-main-header">Видеогаллерея</h1>
<button type="button" class="o-video-btn js-add-folder">Добавить папку</button>
<%--<button type="button" class="o-video-btn js-add-video">Добавить видео</button>--%>
<div id="content-video" class="content-video js-content-video"></div>
<div class="c-folder-edit js-folder-edit" style="display: none;">
<div class="field-item">
<label>Title</label>
<input type="text" placeholder="title" class="js-folder-title"/>
</div>
<button type="button" class="js-confirm-edit-folder">Создать</button>
<button type="button" class="js-cancel-folder">Отмена</button>
</div>
<div class="js-folder-content">
</div>
</div>
<input type="hidden" class="allGalleriesCount" value="<%=GetCountAllGalleries() %>"/>
var folder = (function () {
var ID = 0;
function editFolder(title) {
$.ajax({
url: "/_layouts/15/WSSC.PRT.PNT6.Core/Handlers/ajax.ashx",
data: {
method: "WSSC.PRT.PNT6.Galleries:VideoGallery:AjaxEditFolder",
title: title
},
dataType: "json",
async: true,
type: "POST",
success: function (data) {
if (data.Error) {
console.log(data.Error);
} else {
window.location.reload();
}
}
});
}
function editViewToggle() {
$('.js-content-video').toggle();
$('.js-folder-edit').toggle();
$('.js-add-folder').toggle();
}
function init() {
console.log("init folder");
$('.js-video-gallery')
.on('click', '.js-add-folder', function () {
console.log('js-add-folder');
editViewToggle();
})
.on('click', '.js-confirm-edit-folder', function () {
console.log('js-confirm-edit-folder');
var title = $('.js-folder-title').val();
editFolder(title);
})
.on('click', '.js-cancel-folder', function () {
console.log('js-create-folder');
editViewToggle();
})
}
return {
init: init
}
})();
$(function () {
var initialVideoTemplate = document.getElementById('video-template').innerHTML;
var videoTemplate = Handlebars.compile(initialVideoTemplate);
var itemsToShow = 15;
var renderVideogallery = function (data) {
var renderHtml = videoTemplate(data);
$('#content-video').html(renderHtml);
FindLikeThingsAndDisplayStars();
}
function videogalleryShow() {
$.ajax({
url: '/_layouts/15/WSSC.PRT.PNT6.Core/Handlers/Ajax.ashx',
async: true,
type: 'POST',
data: {
method: 'WSSC.PRT.PNT6.Galleries:VideoGallery:GetVideos',
lastid: 0,
rand: Math.random()
},
success: function (response) {
if (response) {
renderVideogallery(JSON.parse(response));
}
}
});
}
videogalleryShow();
folder.init();
$(".fancyboxlink").fancybox({
'overlayColor': '#FFF',
'showCloseButton': true,
'openEffect': 'elastic',
'speedIn': 1000,
'width': 640,
'height': 480,
'type': 'iframe',
'padding': 0,
'margin': 0,
'beforeShow': function () {
$('.fancybox-iframe').height(480);
}
});
})