I am trying to display a video player inside a modal window in Liferay 6.2 through Alloy UI, with no luck. I have a simple portlet with the following structure in view.jsp:
<div id="myToggler">
<button class="header toggler-header-collapsed">Show Video</button>
<p class="content toggler-content-collapsed">
<div id="myVideo"></div>
</p>
</div>
In the main JavaScript file, main.js, the toggler is loaded into the #myToggler layer, and the video is loaded into the #myVideo layer, which is, in fact, inside the toggler. The video is not loaded into the toggler, though.
YUI ( ).use (
'aui-toggler',
'aui-video',
function (Y) {
new Y.TogglerDelegate ({
animated: true,
closeAllOnExpand: true,
container: '#myToggler',
content: '.content',
header: '.header',
transition: {
duration: .5,
easing: 'cubic-bezier'
}
}).render ( );
new Y.Video ({
boundingBox: '#myVideo',
ogvUrl: 'http://alloyui.com/video/movie.ogg',
url: 'http://alloyui.com/video/movie.mp4'
}).render ( );
}
);
So, how can I load the video inside the toggler? Or, for that matter, how can I load any arbitrary Alloy UI widget inside another (e.g. a video player inside a modal window)?
When I run your code I get:
Uncaught TypeError: undefined is not a function
This is due to the fact that, TogglerDelegate does not have a render() method. Also, you should not put a div into a p element. Instead, just make the toggler content into a div. See below for a runnable example:
YUI ( ).use (
'aui-toggler',
'aui-video',
function (Y) {
new Y.TogglerDelegate ({
animated: true,
closeAllOnExpand: true,
container: '#myToggler',
content: '.content',
header: '.header',
transition: {
duration: .5,
easing: 'cubic-bezier'
}
});
new Y.Video ({
boundingBox: '#myVideo',
ogvUrl: 'http://alloyui.com/video/movie.ogg',
url: 'http://alloyui.com/video/movie.mp4'
}).render ( );
}
);
<script src="https://cdn.rawgit.com/stiemannkj1/701826667a70997013605edcd37e92a6/raw/469fe1ae297e72a5a80eb9015003b7b04eac735e/alloy-ui-3.0.1_aui_aui-min.js"></script>
<link href="https://cdn.rawgit.com/stiemannkj1/90be22de7f48c729b443af14796d91d3/raw/a9f35ceedfac7fc0559b121bed105eaf80f10bf2/aui-css_css_bootstrap.min.css" rel="stylesheet"></link>
<div id="myToggler">
<button class="header toggler-header-collapsed">Show Video</button>
<div class="content toggler-content-collapsed">
<div id="myVideo"></div>
</div>
</div>
[H]ow can I load any arbitrary Alloy UI widget inside another (e.g. a video player inside a modal window)?
One way to do this is to specify the outer widget's boundingBox and contentBox, and place the inner widget inside the contentBox of the outer widget. See below for a runnable example:
YUI().use('aui-modal', 'aui-video', function(Y) {
new Y.Modal({
boundingBox: '#bb',
contentBox: '#cb',
headerContent: 'Modal header'
}).render();
new Y.Video({
boundingBox: '#myVideo',
ogvUrl: 'http://alloyui.com/video/movie.ogg',
url: 'http://alloyui.com/video/movie.mp4'
}).render();
});
<script src="https://cdn.rawgit.com/stiemannkj1/701826667a70997013605edcd37e92a6/raw/469fe1ae297e72a5a80eb9015003b7b04eac735e/alloy-ui-3.0.1_aui_aui-min.js"></script>
<link href="https://cdn.rawgit.com/stiemannkj1/90be22de7f48c729b443af14796d91d3/raw/a9f35ceedfac7fc0559b121bed105eaf80f10bf2/aui-css_css_bootstrap.min.css" rel="stylesheet"></link>
<div class="yui3-skin-sam">
<div id="bb">
<div id="cb" style="background-color: grey;">
<div id="myVideo">
</div>
</div>
</div>
</div>
Related
I'm trying to have the background of each section change when you scroll through (using locomotive-scroll) and i used this response which works up to a point, but doesn't change back when i move to the previous section. Any idea how to get this effect thanks. Here is a link to the website I saw that does it beautifully Example Use
https://stackoverflow.com/a/66184996/14719899
<div class="body locomotive-scroll" data-scroll-container>
<div data-scroll-section>
<section id="landing-page" data-scroll data-scroll-repeat data-scroll-call="pageColor" data-scroll-id="data-scroll-landing-page" data-scroll-id="black">
some content
</section>
<div>
<div data-scroll-section>
<section id="landing-page" data-scroll data-scroll-repeat data-scroll-call="pageColor" data-scroll-id="data-scroll-landing-page" data-scroll-id="white">
some content
</section>
<div>
<div data-scroll-section>
<section id="landing-page" data-scroll data-scroll-repeat data-scroll-call="pageColor" data-scroll-id="data-scroll-landing-page" data-scroll-id="black">
some content
</section>
<div>
</div>
<!-- Locomotive Scroll -->
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/locomotive-scroll#3.5.4/dist/locomotive-scroll.css">
<script src="https://cdn.jsdelivr.net/npm/locomotive-scroll#4.1.1/dist/locomotive-scroll.min.js"></script>
<script>
const locoScroll = new LocomotiveScroll({
el: document.querySelector(".locomotive-scroll"),
smooth: true,
smartphone: {
smooth: true
},
tablet: {
smooth: true
},
smoothMobile: 0,
multiplier: 1.0,
});
//BACKGROUND COLOR CHANGE AS SCROLL
locoScroll.on('call', (value, way, obj) => {
if (way === 'enter') {
switch (value) {
case "pageColor":
// get color code from data-scroll-id assigned to body by obj.id
document.querySelector('body').style.backgroundColor = obj.id;
break;
}
}
});
</script>
I have a page with several JWPlayer instances. I would like to stop, or pause the video that is playing if and when the user clicks on another one. Right now videos play at the same time and it is quite annoying.
I tried the stop and pause methods for JWPlayer but I can't get them to work.
Thank you in advance, here's my code so far (2 videos but there are several others).
<div class="col-lg-4">
<div id="video1"></div>
<script type="text/javascript">
jwplayer().stop();
jwplayer("video1").setup({
file: "video1.mp4",
image: "1.jpg",
width: "100%",
aspectratio: "16:9",
logo: { hide: true },
skin: "bekle"
});
</script>
<p>Description</p>
</div>
<div class="col-lg-4">
<div id="video2"></div>
<script type="text/javascript">
jwplayer("video2").setup({
file: "video2.mp4",
image: "2.jpg",
width: "100%",
aspectratio: "16:9",
logo: { hide: true },
skin: "bekle"
});
</script>
<p>Description</p>
</div>
The stop() in the first video doesn't work and actually deletes the player that doesn't load at all.
I iterate through all the players on the page and then make sure all are paused except for the one I want to play:
<script src="https://content.jwplatform.com/libraries/your_player_here.js"></script>
<div id="videoA"></div><br><br>
<div id="videoB"></div><br><br>
<div id="videoC"></div><br><br>
<div id="videoD"></div><br><br>
<script>
jwplayer('videoA').setup({
file: 'bunny.mp4'
}).on('play',function(){
pauseOthers(this.getContainer().id);
});
jwplayer('videoB').setup({
file: 'tears.mp4'
}).on('play',function(){
pauseOthers(this.getContainer().id);
});
jwplayer('videoC').setup({
file: 'sintel.mp4'
}).on('play',function(){
pauseOthers(this.getContainer().id);
});
jwplayer('videoD').setup({
file: 'http://content.jwplatform.com/manifests/s8BPzDe0.m3u8'
}).on('play',function(){
pauseOthers(this.getContainer().id);
});
function pauseOthers(id) {
console.log('Playback just started for: '+id);
var videos = document.getElementsByTagName('video');
for (i=0;i<videos.length;i++) {
if (id != videos[i].parentNode.parentNode.id) {
jwplayer(videos[i].parentNode.parentNode.id).pause(true);
console.log('Pausing: '+videos[i].parentNode.parentNode.id);
}
}
}
</script>
How do I crop my selected picture?
I've written web page that gives the user a choice to replace their current picture with a picture inside a carousel.
<div class="rcrop-wrapper">
<img id="ZoomAvatarPicture" src="Pictures/PhotoAlbum/203.jpg" height="200" />
</div>
<div class="owl-carousel-v4 margin-bottom-40">
<div class="owl-slider-v4">
<div class="item">
<img src="Pictures/PhotoAlbum/90.jpg" onclick="$('#ZoomAvatarPicture').attr('src','Pictures/PhotoAlbum/90.jpg"/>
</div>
<div class="item">
<img src="Pictures/PhotoAlbum/22.jpg" onclick="$('#ZoomAvatarPicture').attr('src','Pictures/PhotoAlbum/22.jpg"/>
</div>
<div class="item">
<img src="Pictures/PhotoAlbum/21.jpg" onclick="$('#ZoomAvatarPicture').attr('src','Pictures/PhotoAlbum/21.jpg"/>
</div>
</div>
When I click on the images in the carousel the ZoomAvatarPicture is replaced, as I expect it. I want to crop the newly selected ZoomAvatarPicture image. I've tried 3rd party cropping software (e.g. jQuery rcrop and imgAreaSelect) but their cropped images are of the original image, 203.jpg)
This is the code I added for rcrop:
jQuery(document).ready(function () {
$('#ZoomAvatarPicture').rcrop({
full: true,
preserveAspectRatio: true,
minSize: [50, 50],
inputsPrefix: '',
grid: false,
});
$('#ZoomAvatarPicture').on('rcrop-changed', function e() {
var srcResized = $(this).rcrop('getDataURL', 50, 50);
$('#cropped-resized').append('<img src="' + srcResized + '">');
})
});
And then I had a div to hold the cropped image
<div id="cropped-resized">
<h3>Images resized (50x50)</h3>
</div>
Since I got the same results for rcrop and imageSelect it leads me to believe that the problem isn't in the software but in my understanding of what can be done in jQuery.
Also, the demo page for rcrop is here: http://www.jqueryscript.net/demo/Responsive-Mobile-friendly-Image-Cropper-With-jQuery-rcrop/
I've added this code
function rcrop_Avatar()
{
var srcResized = $('#ZoomAvatarPicture').rcrop('getDataURL', 50, 50);
$('#cropped-resized').append('<img src="' + srcResized + '">');
alert('src = ' + $('#ZoomAvatarPicture').attr('src') );
}
function resetListener()
{
$('#ZoomAvatarPicture').off(onclick, 'rcrop-changed', rcrop_Avatar);
$('#ZoomAvatarPicture').rcrop({
preserveAspectRatio: true,
minSize: [100, 100],
inputs: true,
inputsPrefix: '',
preview: {
display: true,
size: [200, 200],
wrapper: '#custom-preview-wrapper'
}
});
rcrop_Avatar();
}
jQuery(document).ready(function () {
App.init();
App.initScrollBar();
Datepicker.initDatepicker();
OwlCarousel.initOwlCarousel();
CirclesMaster.initCirclesMaster1();
StyleSwitcher.initStyleSwitcher();
$('#ZoomAvatarPicture').rcrop({
preserveAspectRatio: true,
minSize: [100, 100],
inputs: true,
inputsPrefix: '',
preview: {
display: true,
size: [200, 200],
wrapper: '#custom-preview-wrapper'
}
});
$('#ZoomAvatarPicture').on('rcrop-changed', rcrop_Avatar);
});
and modified the HTML to this:
<div class="item">
<img src="Pictures/PhotoAlbum/Work/90.jpg" onclick="$('#CurrentAvatarPicture').attr('src','Pictures/PhotoAlbum/Work/90.jpg');resetListener();"/>
</div>
I'm still getting the same results. (i.e. the cropped image is the original image, not the newly selected one).
The entire process is in a bootstrap modal. I'm starting to think I should forgo this route and put everything into a tabbed series of iframes.
Apparently, rcrop doesn't like to change properties or subject on the fly, and the destroy method is pretty messy, as it sometimes deletes the original object or leaves the preview display behind.
So, to avoid that, I changed a bit the behaviour to delete the remains and then recreate the image and attach it to the rcrop again.
Due to the size limit of the answers and not being able to upload the js and css of rcrop, i made this Codepen: http://codepen.io/LordNeo/pen/XpxVVv
Here is the relevant parts so you can check for modifications, for working example see the above CodePen.
$(document).ready(function () {
$('#ZoomAvatarPicture').rcrop({
full: true,
minSize : [50,50],
preserveAspectRatio : true,
inputsPrefix: '',
grid: false,
preview : {
display: true,
size : [100,100],
}
});
});
function changeImage(imgsrc) {
$('#ZoomAvatarPicture').rcrop("destroy");
$('#ZoomAvatarPicture').remove();
$('.rcrop-preview-wrapper').remove();
$('.rcrop-wrapper').prepend('<img id="ZoomAvatarPicture" src="'+imgsrc+'" height="200" />');
$('#ZoomAvatarPicture').rcrop({
full: true,
minSize : [50,50],
preserveAspectRatio : true,
inputsPrefix: '',
grid: false,
preview : {
display: true,
size : [100,100],
}
});
}
<div class="rcrop-wrapper">
<img id="ZoomAvatarPicture" src="http://placehold.it/400x100/E8117F/FFFFFF?text=IMG1" height="200" />
</div>
<div class="owl-carousel-v4 margin-bottom-40">
<div class="owl-slider-v4">
<div class="item">
<img src="http://placehold.it/400x100/E8117F/FFFFFF?text=IMG2" onclick="changeImage('http://placehold.it/400x100/E8117F/FFFFFF?text=IMG2')"/>
</div>
<div class="item">
<img src="http://placehold.it/400x100/E8117F/FFFFFF?text=IMG3" onclick="changeImage('http://placehold.it/400x100/E8117F/FFFFFF?text=IMG3')"/>
</div>
<div class="item">
<img src="http://placehold.it/400x100/E8117F/FFFFFF?text=IMG4" onclick="changeImage('http://placehold.it/400x100/E8117F/FFFFFF?text=IMG4')"/>
</div>
</div>
I am using an external library - SwipeJS - for a touch picture slide, and it is only working when I resize my browser window.
I have my images in the Swipe Container like this inside the body:
<div id='mySwipe' style='max-width: 500px; margin: 0 auto' class='swipe'>
<div class='swipe-wrap'>
<div>
<img src="css/images/image4.jpg" width="100%" />
</div>
<div>
<img src="css/images/image2.jpg" width="100%" />
</div>
<div>
<img src="css/images/image3.jpg" width="100%" />
</div>
</div>
</div>
And, I am loading the swipe script right at the end of the body to make sure the document is ready - as the library author suggested. The library is loaded inside the <head> container.
<script>
var elem = document.getElementById('mySwipe');
window.mySwipe = Swipe(elem, {
startSlide : 1,
auto : 3000,
continuous : true
});
</script>
I have tried to check if the document is ready with $(document).ready(function() { } but that solution did not work either.
Have you tried using the widgets default example with just your minor tweaks specifically?
<script>
var slider = Swipe( document.getElementById('mySwipe'), {
startSlide: 1,
auto: 3000,
continuous: true,
disableScroll: false,
stopPropagation: false,
callback: function(index, elem) {},
transitionEnd: function(index, elem) {}
} );
</script>
So what I'm trying to do, is display some content from a SharePoint list in a div with some custom classes. The first script is using the jquery plugins from Awkward Showcase
So, my CAML query works. I have the function called in the div tag, because I want to display it as the thumbnail caption, however, it seems that it overwrites everything on the page and processes last.
So all my div tags and content are gone and it only writes the results of the function on the page.
Here is my code:
<script type="text/javascript">
`$(document).ready(function()'
{
$("#showcase").awShowcase(
{
content_width: 700,
content_height: 470,
fit_to_parent: false,
auto: false,
interval: 3000,
continuous: false,
loading: true,
tooltip_width: 200,
tooltip_icon_width: 32,
tooltip_icon_height: 32,
tooltip_offsetx: 18,
tooltip_offsety: 0,
arrows: true,
buttons: true,
btn_numbers: true,
keybord_keys: true,
mousetrace: false, /* Trace x and y coordinates for the mouse */
pauseonover: true,
stoponclick: true,
transition: 'hslide', /* hslide/vslide/fade */
transition_delay: 300,
transition_speed: 500,
show_caption: 'onhover', /* onload/onhover/show */
thumbnails: true,
thumbnails_position: 'outside-last', /* outside-last/outside-first/inside-last/inside-first */
thumbnails_direction: 'horizontal', /* vertical/horizontal */
thumbnails_slidex: 0, /* 0 = auto / 1 = slide one thumbnail / 2 = slide two thumbnails / etc. */
dynamic_height: false, /* For dynamic height to work in webkit you need to set the width and height of images in the source. Usually works to only set the dimension of the first slide in the showcase. */
speed_change: false, /* Set to true to prevent users from swithing more then one slide at once. */
viewline: false /* If set to true content_width, thumbnails, transition and dynamic_height will be disabled. As for dynamic height you need to set the width and height of images in the source. */
});
});
</script>
<script type="text/javascript">
function GetNews(){
/*Get News*/
$().SPServices({
operation: "GetListItems",
webURL: 'http://weburl.com',
async: false,
listName: "Posts",
CAMLViewFields: "<ViewFields><FieldRef Name='Title' /><FieldRef Name='Primary' /><FieldRef Name='Pic' /><FieldRef Name='Short_x0020_Description' /></ViewFields>",
CAMLRowLimit: "10",
CAMLQuery: "<Query><Where><Eq><FieldRef Name='Primary'/><Value Type='choice'>1</Value></Eq></Where></Query>",
completefunc: function (xData, Status) {
//alert("Status of XML message reaching Sharepoint webservice: " + Status);
//alert("Response from server: " + xData.responseText);
$(xData.responseXML).SPFilterNode("z:row").each(function () {
var name = ($(this).attr("ows_Title"));
document.write(name);
});
}
}); //Close getNews
}
</script>
<body>
<div style="width: 700px; margin: auto;">
<div id="showcase" class="showcase">
<!-- Each child div in #showcase with the class .showcase-slide represents a slide. -->
<div class="showcase-slide">
<!-- Put the slide content in a div with the class .showcase-content. -->
<div class="showcase-content">
<!-- The image below needs to be from the variable above pictureUrl -->
<img src="images/01.jpg" alt="01" />
</div>
<!-- Put the thumbnail content in a div with the class .showcase-thumbnail -->
<div class="showcase-thumbnail">
<!-- The image below needs to be from the variable above pictureUrl -->
<img src="images/01.jpg" alt="01" width="140px" />
<!-- The div below with the class .showcase-thumbnail-caption contains the thumbnail caption. This needs to be the variable 'name' from above -->
<div class="showcase-thumbnail-caption"><div><script type="text/javascript">GetNews()</script></div></div>
<!-- The div below with the class .showcase-thumbnail-cover is used for the thumbnails active state. -->
<div class="showcase-thumbnail-cover"></div>
</div>
<!-- Put the caption content in a div with the class .showcase-caption. This needs to be the variable 'postDesc' from above -->
<div class="showcase-caption">
<h2>Be creative. Get Noticed!</h2>
</div>
</div>
</div>
</div>
</body>
well its probably not working correctly because you are writing it directly not to the document and not to a specific div
$(xData.responseXML).SPFilterNode("z:row").each(function () {
var name = ($(this).attr("ows_Title"));
document.write(name);//this line needs a fix maybe $('#divID').append('<h1>'+name+'<h1>') for eg
});