SMALL_TEXT_LIMIT = 120 onYouTubeIframeAPIReady = function () { var video_id = 'w2wF8LOV5kw', yt_player = null, player_selector = '.video .player', aspect_ratio = 1.77777, start_btn = $('.video .start'), thumbnail = $('.video .thumbnail'), thumbnail_wrapper = $('.video .thumbnail_wrapper'), video_wrapper = $('.video_wrapper') yt_player = new YT.Player($(player_selector)[0], { // height: 'auto', // width: video_wrapper.width(), videoId: video_id, // youtube video id playerVars: { 'autoplay': 0, 'rel': 0, 'showinfo': 0 }, events: { 'onStateChange': function (event) { if (event.data == YT.PlayerState.ENDED) { } } } }); var player_iframe = $(player_selector) aspect_ratio = parseInt(player_iframe.width())/parseInt(player_iframe.height()) $(player_selector).hide(); // uncomment to use preview provided by youtube // thumbnail.css('background-image', "url('http://img.youtube.com/vi/"+video_id+"/0.jpg')") //hack for correct image position thumbnail.css('background-image', "url('hushme_preview.png')") start_btn.on('click', function () { start_btn.hide(); $(player_selector).show(); thumbnail_wrapper.hide(); yt_player.playVideo(); }); $(window).resize(function() { var newWidth = video_wrapper.width(); $(player_selector).width(newWidth) .height(newWidth / aspect_ratio); thumbnail_wrapper.width(newWidth) .height(newWidth / aspect_ratio); }).resize() } function validateEmail(email) { //http://stackoverflow.com/a/32686261 var re = /^[^\s@]+@[^\s@]+\.[^\s@]+$/; var res = re.test(email); console.log('validation result', email, res) return res; } function add_news(parser, remodal, remodal_title, remodal_image, remodal_content, container, info){ var text_container = $('
') var html = parser.parseString(info.text); console.log(html) text_container.html(html) var text = text_container.text() var full_text_size = text.length text = text.substring(0, SMALL_TEXT_LIMIT) if (full_text_size > SMALL_TEXT_LIMIT) { text = text + "..." } var read_more_btn = $('Read more...') var event = $('
' + '' + '

'+info.title+'

' + '

'+text+'

'+ '
') event.append(read_more_btn) read_more_btn.bind('click', function(e){ remodal_content.html(html) remodal_image.attr({'src':info.img}) remodal_title.text(info.title) remodal.open() e.preventDefault() }) var holder = $('
') holder.append(event) container.append(holder) } $().ready(function() { var body = $('body') //smooth jumps $(document).bind('click', 'a', function (event) { var href = $.attr(this, 'href') if (!(href == undefined || href == null || href == '#')) { if (href.indexOf('#') == 0) { event.preventDefault(); body.animate({ scrollTop: $(href).offset().top }, 500); } } }); //fill news var show_all_btn = $('#show_all_btn'), news_block = $('.section-news .news'), news_row = $('.section-news') var parser = new BBCodeParser(BBCodeParser.defaultTags()) var remodal = $('.remodal'), remodal_image = $(remodal.find('.image')), remodal_title = $(remodal.find('.title')), remodal_content = $(remodal.find('.content')) remodal = remodal.remodal() show_all_btn.bind('click', function(e){ if (news.length > 3) { for (var i=3; i 0) { for (var i=0; i