Couple of questions about fotorama - fotorama

I found your Fotorama gallery script v4.6.4 and it is exactly what I was looking for.
I do have a couple of questions:
How can I move the Caption down so that it is not overlaying the bottom of an image?
I would like it to be completely separate i.e.
Main Image
Caption
Thumbs
Here is an image that shows how the caption is currently obscuring the lower part of the main image, seems worse the smaller the viewport:
Caption Overlaying Image
Currently the caption shows the image title & a download link for the displayed image.
I would like the link to point to the Flickr image page instead of the ability to download it.
My JS script is currently:
<script type="text/javascript">
$(function() {
var AddPhotosToCarousel = function(data) {
var imgs = [];
$.each(data.photoset.photo, function(index, photo) {
// TODO: use flickr.photos.getSizes
caption = photo['title'] +
' <small>(Download)</small>'
imgs.unshift({img: photo['url_m'],
thumb: photo['url_s'],
caption: caption});
});
$('.fotorama').fotorama({
data: imgs,
width: '100%',
maxwidth: '960',
maxheight: '100%',
ratio: '4/3',
nav: 'thumbs',
autoplay: 8000,
keyboard: 'true',
arrows: 'true',
transition: 'crossfade'
});
};
$.getJSON('https://api.flickr.com/services/rest/?method=flickr.photosets.getPhotos&api_key=[API KEY]&photoset_id=[PHOTOSET ID]&format=json&extras=url_s,url_m,url_o&jsoncallback=?', AddPhotosToCarousel);
});
</script>
this forms a URL in the format:
https://farm2.staticflickr.com/1566/[IMAGE ID][SECRET]_o.jpg
but I would like it to form a URL in format:
https://www.flickr.com/photos/[USER]/[PHOTO ID]/in/dateposted-public/
Any help would be appreciated.
Kind regards..,
OK, I found this page:
Jquery JSON Flickr API Returning Photos in a Set
& altered my script to:
<script type="text/javascript">
$(function() {
var AddPhotosToCarousel = function(data) {
var imgs = [];
$.each(data.photoset.photo, function(index, photo) {
var a_href = "http://www.flickr.com/photos/" + data.photoset.owner + "/" + photo.id + "/";
// TODO: use flickr.photos.getSizes
caption = photo['title'] +
' (Open)'
imgs.unshift({img: photo['url_m'],
thumb: photo['url_s'],
caption: caption});
});
$('.fotorama').fotorama({
data: imgs,
width: '100%',
maxwidth: '960',
maxheight: '100%',
ratio: '4/3',
nav: 'thumbs',
autoplay: 8000,
keyboard: 'true',
arrows: 'true',
transition: 'crossfade',
click: 'false'
});
};
$.getJSON('https://api.flickr.com/services/rest/?format=json&method=flickr.photosets.getPhotos&photoset_id=72157664523293315&api_key=449126625d797cace5a6d5a90532b741&extras=url_s,url_m&jsoncallback=?', AddPhotosToCarousel);
});
</script>
While this does build the direct image link, clicking on this link only advances the slideshow instead of opening the link.
You can see that I also included the click: 'false' option but this has not stopped the issue.
How do I stop the slideshow advancing when clicking the link?
Regards..,
Right, got question 2 sorted, seemed to be an issue with Chrome caching the page.
Script is now:
<script type="text/javascript">
$(function() {
var AddPhotosToCarousel = function(data) {
var imgs = [];
$.each(data.photoset.photo, function(index, photo) {
var a_href = "http://www.flickr.com/photos/1cm69/" + photo.id + "/";
// TODO: use flickr.photos.getSizes
caption = ' <small><a href="' + a_href + '" target=_blank>' + photo['title'] + '</a></small>'
imgs.unshift({img: photo['url_m'],
thumb: photo['url_s'],
caption: caption});
});
$('.fotorama').fotorama({
data: imgs,
width: '100%',
maxwidth: '960',
maxheight: '100%',
ratio: '4/3',
nav: 'thumbs',
autoplay: 8000,
keyboard: 'true',
arrows: 'true',
transition: 'crossfade'
});
};
$.getJSON('https://api.flickr.com/services/rest/?format=json&method=flickr.photosets.getPhotos&photoset_id=72157664523293315&api_key=449126625d797cace5a6d5a90532b741&extras=url_s,url_m&jsoncallback=?', AddPhotosToCarousel);
});
</script>
& working.
So only one question left, that of the Caption overlaying the bottom of the image.
Regards..,

Related

Sencha Touch 2.0 Progress Indicator

I have to add progress indicator with % of complete in different ajax request using Sencha touch 2.x, for example if I've 2 Ajax request progress indicator will show 50% complete on each request after successful server response.
Here is another way to solve it without progressIndicator:
FIDDLE
Ext.application({
name : 'Fiddle',
launch : function() {
var progressIndicator = Ext.create('Ext.Panel', {
html: '<table style="height:30px; width:100%">'+
'<tr>'+
'<td id="start" style="background-color:green;width:1%"></td>'+
'<td id="end"></td>'+
'</tr></table>',
centered : true,
modal : true,
hideOnMaskTap : true,
width : '50%',
height : '80',
});
var progress = 1;
//progressIndicator.updateBar();
Ext.Viewport.add(progressIndicator);
progressIndicator.show();
var intervalProgress=setInterval(function(){
//console.log(progress);
progress+=1;
document.getElementById("start").style.width = (progress) +'%';
//progressIndicator.setProgress(progress);
//progressIndicator.updateBar();
if(progress >= 100){
clearInterval(intervalProgress)
}
},100)
}
});

Add a new item to static list and auto refresh in angular js

I want to display image based on the following codes:
app.controller('PostingCtrl', ['$scope','$http', '$q', function($scope, $http, $q) {
// Set of Photos
$scope.pictures = [
{src: 'images/sample1.jpg', desc: 'Sample Image 01'},
{src: 'images/sample2.jpg', desc: 'Sample Image 02'},
{src: 'images/sample3.jpg', desc: 'Sample Image 03'}
];
// initial image index
$scope._Index = 0;
// if a current image is the same as requested image
$scope.isActive = function (index) {
return $scope._Index === index;
};
// show a certain image
$scope.showPhoto = function (index) {
$scope._Index = index;
};
$scope.onCameraUpload = function() {
navigator.camera.getPicture(
function(imageInfo) {
var image = {src: imageInfo, desc: 'none'};
$scope.pictures.push.apply($scope.pictures, image);
},
function(message) {
alert('Failed because: ' + message);
},
{
quality: 50,
sourceType : Camera.PictureSourceType.CAMERA
}
);
};
}]);
The default images are loading well. However, I want to add another image to the list based on the image from camera upload given in the code and then automatically refresh it to the page.
I have tried as given in the code, but it did not work. Please help.
Edit:
Here is the html code
<section style="padding: 0 8px">
<!-- slider container -->
<div class="container slider">
<!-- enumerate all photos -->
<img ng-repeat="picture in pictures" class="slide" ng-swipe-right="showPrev()" ng-swipe-left="showNext()" ng-show="isActive($index)" ng-src="{{picture.src}}" />
<!-- extra navigation controls -->
<ul class="nav">
<li ng-repeat="picture in pictures" ng-class="{'active':isActive($index)}">
<img src="{{picture.src}}" alt="{{picture.desc}}" title="{{picture.desc}}" ng-click="showPhoto($index);" />
</li>
</ul>
</div>
</section>
<section style="padding: 0 8px 8px">
<ons-button modifier="normal" ng-click="onCameraUpload()" style="float: right; width: 48.5%;">
<ons-icon icon="camera"></ons-icon> Camera Upload
</ons-button>
</section>
I assume that that you need to replace your push command :
$scope.pictures.push(image);
If this is not working, please paste your HTML code taht is doing your loop.
This may be coming from that point if you binded it one way (with ::)
EDIT :
Here is how I get pictures from Cordova, my query is a bit different from yours... please verify yours
var options = {
quality: 50,
destinationType: Camera.DestinationType.NATIVE_URL,
sourceType: Camera.PictureSourceType.CAMERA,
allowEdit: false,
encodingType: Camera.EncodingType.JPEG,
targetWidth: 700,
targetHeight: 700,
popoverOptions: CameraPopoverOptions,
saveToPhotoAlbum: false,
correctOrientation: true
};
$cordovaCamera.getPicture(options).then(function(imageData) {
d.resolve(imageData);
}, function(err) {
d.reject(err);
});

Increase width of column in ui.grid

I have inserted some dummy object in Grid,The data displays in the grid found some issues. Here is My code:
html:
<div class="gridStyle" ui-grid="gridOptions"></div>
js:
$scope.myData = [{
JobId: '196',
siteType: 'abc',
Title: 'Happy womans day',
Message: 'hello',
devicetype: 'A',
jobDuration: '819',
totalMsgs: '2016',
msgsDelivered: 'Msg not found In the whole Body',
msgsFailed: '789',
jobCreatedDate: '11-03-2015',
jobCreatedBy: 'abc#abc.com'
}];
$scope.gridOptions = {
data: 'myData'
};
css :
.ui-grid-header-cell .ui-grid-cell-contents {
height: 48px;
white-space: normal;
-ms-text-overflow: clip;
-o-text-overflow: clip;
text-overflow: clip;
overflow: visible;
}
Data displays in the grid but only upto some fixed width. Unable to wrap the long text,
for eg:Msg not found In the whole Body, Displays as Msg not foun...........
How can I increase width of each and every column?
I am not able to wrap the long text lines into 2-3 lines, the whole text displays in one line only
The above css works only for headers
OK, a few things.
Firstly, to set the column width you need to use column definitions, then you can set a width in pixels or percentage on each. Refer http://ui-grid.info/docs/#/tutorial/201_editable as an example that has column widths.
Secondly, there is the ability to add tooltips, which are one way to show longer cells that don't fit in the space available. Refer http://ui-grid.info/docs/#/tutorial/117_tooltips
Thirdly, you can make the rows taller and therefore have space to wrap content within them. Be aware that all rows must be the same height, so you can't make only the rows that need it taller.
gridOptions.rowHeight = 50;
You'll also need to set the white-space attribute on the div so that it wraps, which you can do by setting a class in the cellTemplate, and then adding a style to the css.
A plunker as an example: http://plnkr.co/edit/kyhRm08ZtIKYspDqgyRa?p=preview
Set the Dependency for the javascript:
angular.module('app', [
'ngTouch',
'ui.grid',
'ui.grid.autoResize',
'ui.grid.resizeColumns'
])
for ui-grid 3.0, I am using this directive:
.directive('setOuterHeight',['$timeout', function ($timeout) {
return {
restrict: 'A',
link: function (scope, element) {
$timeout(function(){
// Get the Parent Divider.
var parentContainer = element.parent()[0];
console.log(parentContainer.offsetHeight);
// Padding of ui-grid-cell-contents is 5px.
// TODO: Better way to get padding height?
var topBottomPadding = 10;
//Get the wrapped contents rowHeight.
var rowHeight = topBottomPadding + parentContainer.offsetHeight;
var gridRowHeight = scope.grid.options.rowHeight;
// Get current rowHeight
if (!gridRowHeight ||
(gridRowHeight && gridRowHeight < rowHeight)) {
// This will OVERRIDE the existing rowHeight.
scope.grid.options.rowHeight = rowHeight;
}
},0);
}
};
}])
Under the controller:
.controller('MainCtrl',
['$scope', '$q', '$timeout', 'uiGridConstants',
function ($scope, $q, $timeout, uiGridConstants) {
$scope.gridOptions = {
enableVerticalScrollbar: uiGridConstants.scrollbars.NEVER,
enableHorizontalScrollbar: uiGridConstants.scrollbars.NEVER,
columnDefs: [
{name: 'firstName', width: '*'},
{name: 'lastName', width: '*'},
{
name: 'company', width: '*',
cellTooltip: function (row) {
return row.entity.company;
},
cellTemplate: '<div class="ui-grid-cell-contents wrap" title="TOOLTIP"><div><span class="label" set-row-height>{{row.entity.company}} </span></div><div>'
},
{name: 'employed', width: '*'}
],
enableColumnResize: true,
rowHeight: 10,
};
}]);
*Note the set-row-height directive for cellTemplate.
For CSS, you will have to put the white-space as normal:
.wrap {
white-space: normal;
}
.wrap .label {
display: inline-block;
}
Lastly, the HTML to change the Grid Height:
<div id="grid1" ui-grid="gridOptions" class="grid" ng-style="{height: (gridOptions.data.length*gridOptions.rowHeight)+32+'px'}" ui-grid-resize-columns ui-grid-auto-resize></div>
Plunker example is here:
http://plnkr.co/edit/OwgEfru0QyFaU1XJFezv?p=preview

Click one Panel, Hide other Panels - Ext JS

I have three separate buttons with controllers. When one of the buttons is clicked, a panel is created and displayed (with animation). Here's what one of my controllers looks like:
Ext.define('AM.controller.Prod_Select', {
extend: 'Ext.app.Controller',
init: function() {
this.control({
'#prod_select': {
click: this.prodSelect
}
});
},
prodSelect: function() {
var subPanel = Ext.create('Ext.panel.Panel', {
width: 200,
height: 160,
html: '<center><p class="sub_panel_text "> Link <br /> Link <br /> Link </p> </center>',
bodyStyle: 'background:#010a4d',
border:false,
floating: true,
shadow: false,
style: 'opacity: 0;',
x: 770,
y: 75,
cls: 'sub_panel'
});
subPanel.show();
subPanel.animate({
duration: 1000,
to: {
opacity: .6,
x: 800,
y: 75
}
});
console.log('Clicked Prod');
}
});
This works just fine, but currently I can click one button x amount of times, and it will create x amount of panels. What I want out of this controller, however, is to create only a single panel from a click AND hide any other panel (with fade out) that may displayed already out of the three.
Is there any way to accomplish this? Thanks for reading!
You could add a property to the subPanel so it can be easily selected using ComponentQuery, then iterate through the query's results and hide the other panels.
var subPanel = Ext.create('Ext.panel.Panel', {
someCustomProperty: 'someCustomValue',
...
});
var allPanels = Ext.ComponentQuery.query('panel[someCustomProperty="someCustomValue"]');
Ext.Array.each(allPanels, function(panel) {
if (panel === subPanel) {
//show it
} else {
//hide it
}
});

extjs adding icons to the titlebar of an extended window widget (two levels of extension)

I am new to extjs....
I am trying to add icons to the title bar of a window.
I am not able to figure out the error in my code
i tried using tools config for the window
Here is my code:
**Ext.ns('DEV');
DEV.ChartWindow = Ext.extend(Ext.ux.DEV.SampleDesktopWidget, {
width:740,
height:480,
iconCls: 'icon-grid',
shim:false,
animCollapse:false,
constrainHeader:true,
layout: 'fit',
initComponent : function() {
this.items = [
new Ext.Panel({
border:true,
html : '<iframe src="" width="100%" height="100%" ></iframe>'
})
];
DEV.ChartWindow.superclass.initComponent.apply(this, arguments);
},
getConfig : function() {
var x = DEV.ChartWindow.superclass.getConfig.apply(this, arguments);
x.xtype = 'DEV Sample Window';
return x;
},
tools: [{
id:'help',
type:'help',
handler: function(){},
qtip:'Help tool'
}]
});
Ext.reg('DEV Sample Window', DEV.ChartWindow);**
SampleDesktopWidget is an extension of Window
Can somebody help me with this
Thanks in advance
I believe title is part of the header. I dont think you can do this with initialConfig programmatically but you can either override part of component lifecycle or hook in with an event. E.g. add this to config. You might (probably) be able to hook in at any early stage after init maybe, but thats an experiment for you.
listeners: {
render: {
fn: function() {
this.header.insert(0,{
xtype: 'panel',
html: '<img src="/img/titleIcon1.gif"/>'
});
}
}
}
However for this particular scenario I would use iconCls
iconCls: 'myCssStyle'
Then include a CSS file with:
.myCssStyle {
padding-left: 25px;
background: url('/ima/titleIcon.gif') no-repeat;
}
This is a good example that might help, using extjs 3.2.1.
Adding tools dynamically

Resources