I'm using the jQuery plugin Fotorama for my image gallery.
When I click on a thumbnail to open the Fotorama gallery in fullscreen, then it will only open the first time (it will not reopen again after exiting the fullscreen and clicking the same thumbnail).
Here is my code
jQuery code:
$(".open_gallery").click(function (){
$('body').prepend('<div class="close_gallery"> <img src="/images/round_delete.png" width="32" height="32" alt="close"/></div>');
$('.close_gallery').click(function(){
$('.my-fotorama').trigger('fullscreenclose');
$('#foto_gallery').hide();
//window.location.reload();//reload the page
});
$('.my-fotorama').show();
$('.my-fotorama').fotorama({
width: '100%',
height: 'auto',
aspectRatio: 1.4989293362, // =700/467
minWidth: null,
maxWidth: null,
minHeight: null,
maxHeight: null,
transition: 'slide', // or 'fade'
click: true,
loop: false, // or true
autoplay: false,
stopAutoplayOnAction: true,
transitionDuration: 333,
background: '#111',
// 'black', '#b10000', or url(bg.png)
margin: 4,
minPadding: 8,
alwaysPadding: false,
zoomToFit: true,
cropToFit: false,
cropToFitIfFullscreen: false,
flexible: false,
fitToWindowHeight: false,
fitToWindowHeightMargin: 20,
fullscreen: true,
fullscreenIcon: false,
vertical: false,
arrows: true,
arrowsColor: null,
arrowPrev: null,
arrowNext: null,
spinnerColor: '#808080',
nav: 'thumbs', // or 'dots', or 'none'
navPosition: 'auto',
// 'top' | 'right' | 'bottom' || 'left'
navBackground: null,
dotColor: null,
thumbSize: null, // 36 or 51, whatever :-)
thumbMargin: 4,
thumbBorderWidth: 2,
thumbBorderColor: null,
// 'white', '#ff9', or even '#00ff84 #00eb89 #00b66f'
thumbsCentered: true,
hideNavIfFullscreen: false,
caption: 'overlay', // 'simple', or 'none'
preload: 3,
preloader: 'dark', // or 'white'
shadows: true,
data: null,
// e.g. [{img: 'http://fotoramajs.com/;-)/03.jpg'}, {img: 'broken.jpg'}, {img: 'http://fotoramajs.com/;-)/13.jpg'}]
html: null,
hash: false,
startImg: 0,
cssTransitions: true,
onShowImg: null,
// function(data){alert('Photo #'+(data.index+1)+' is coming!')},
onClick: null,
onFullscreenOpen: null,
onFullscreenClose: function(data){
$('#foto_gallery').hide();
$('.close_gallery').hide();
},
onTransitionStop: null
});
});
Thumbnails
<div class="photo-section">
<table>
<td>
<a class="open_gallery" href="#"> <img border="0" src="<?=$arItem["PICTURE"]["SRC"]?>" width="140px" height="110px" alt="<?=$arItem["NAME"]?>" title="<?=$arItem["NAME"]?>" />
</a>
</td>
</table>
Main images
<div id="foto_gallery">
<div class="my-fotorama">
<img src="<?=$arItem["PREVIEW_PICTURE"]["SRC"]?>">
</div>
Never worked with Fotorama, but I noticed that you are hiding the #foto_gallery div after clicking the close button. But you are not showing it on the open event, so maybe the hide is the problem.
When you use the hide(); method, then jQuery sets the CSS of that object to display: none;, now if the plugin is animating the CSS property opacity to 1, then it will not be visible in the browser because of the display: none;.
Update
I looked at your code again and you initilize the FotoRama gallery on the .my-fotorama element every time the click event is triggered. Move the whole block code of $('.my-fotorama').fotorama({.. above the click function and use the plugins method for closing and opening the fullscreen mode. I updated your code to this:
// triggers when the DOM is loaded
$(function() {
$('.my-fotorama').fotorama({
width: '100%',
height: 'auto',
aspectRatio: 1.4989293362, // =700/467
minWidth: null,
maxWidth: null,
minHeight: null,
maxHeight: null,
transition: 'slide', // or 'fade'
click: true,
loop: false, // or true
autoplay: false,
stopAutoplayOnAction: true,
transitionDuration: 333,
background: '#111',
// 'black', '#b10000', or url(bg.png)
margin: 4,
minPadding: 8,
alwaysPadding: false,
zoomToFit: true,
cropToFit: false,
cropToFitIfFullscreen: false,
flexible: false,
fitToWindowHeight: false,
fitToWindowHeightMargin: 20,
fullscreen: true,
fullscreenIcon: false,
vertical: false,
arrows: true,
arrowsColor: null,
arrowPrev: null,
arrowNext: null,
spinnerColor: '#808080',
nav: 'thumbs', // or 'dots', or 'none'
navPosition: 'auto',
// 'top' | 'right' | 'bottom' || 'left'
navBackground: null,
dotColor: null,
thumbSize: null, // 36 or 51, whatever :-)
thumbMargin: 4,
thumbBorderWidth: 2,
thumbBorderColor: null,
// 'white', '#ff9', or even '#00ff84 #00eb89 #00b66f'
thumbsCentered: true,
hideNavIfFullscreen: false,
caption: 'overlay', // 'simple', or 'none'
preload: 3,
preloader: 'dark', // or 'white'
shadows: true,
data: null,
html: null,
hash: false,
startImg: 0,
cssTransitions: true,
onShowImg: null,
onClick: null,
onFullscreenOpen: function() {
$('#foto_gallery, .my-fotorama').show();
},
onFullscreenClose: function(data){
$('#foto_gallery, .my-fotorama').hide();
$('.close_gallery').remove(); // you need to remove the close element, otherwise it will add and add one every time the click event is triggered.
},
onTransitionStop: null
});
// add the click event to all open_gallery classes in the DOM
$(".open_gallery").click(function () {
$('body').prepend('<div class="close_gallery"> <img src="/images/round_delete.png" width="32" height="32" alt="close"/></div>');
$('.close_gallery').click(function() {
$('.my-fotorama').trigger('fullscreenclose');
});
$('.my-fotorama').trigger('fullscreenopen');
});
});
Related
i have a problem with jquery datatable pagination (Server side processing).
For example i have a 24 records in database. The count is displaying correctly and total pagination also displaying correctly.
when i click on Next or 2nd page it displays records as per the display page length.
Here 3rd Page last 4 records are not displayed.
Here my server side code is like this
$this->db->select("SQL_CALC_FOUND_ROWS user_id,user_name,email", FALSE);
$this->db->from("users");
$sTable="users";
// Data set length after filtering
$this->db->select('FOUND_ROWS() AS found_rows');
$iFilteredTotal = $this->db->get('users')->row()->found_rows;
// Total data set length
$iTotal = $this->db->count_all($sTable);
// Output
$output = array(
'sEcho' => intval($sEcho),
'iTotalRecords' => $iTotal,
'iTotalDisplayRecords' => $iFilteredTotal,
'aaData' => array()
);
Client side Code like this
$(document).ready(function () {
$('#data_appraiser').dataTable({
"bProcessing": true,
"bServerSide": true,
"oLanguage": {
"sProcessing": imgsrc,
},
//"aaData": data.aaData,
"iDisplayLength": 10,
"aLengthMenu": [
[10, 25, 50],
[10, 25, 50] // change per page values here
],
"aaSorting": [[0, 'asc']],
"sServerMethod": "POST",
"sAjaxSource": "appraiserlistajaxdata",
"sPaginationType": "full_numbers"
"aoColumns": [
{ "mData": "id" },
{ "mData": "appraiser_name" },
{ "mData": "user_name" }
....
]
});
});
I checked with $iFilteredTotal total count.when the page changes the value is 20.If it is in 1st page the value is 24.i am unable to solve this problem. Sorry if my problem was weired.Could any one help me how to resolve this issue. Thanks
You have to take start and length (like $_GET['start'])as the offset and limit respectively and apply in the query.
I 'm developing a wordpress theme. I have just integrate flexslider.
This is my settings default :
$.flexslider.defaults = {
namespace: "flex-", //{NEW} String: Prefix string attached to the class of every element generated by the plugin
selector: ".slides > li", //{NEW} Selector: Must match a simple pattern. '{container} > {slide}' -- Ignore pattern at your own peril
animation: "fade", //String: Select your animation type, "fade" or "slide"
easing: "swing", //{NEW} String: Determines the easing method used in jQuery transitions. jQuery easing plugin is supported!
direction: "horizontal", //String: Select the sliding direction, "horizontal" or "vertical"
reverse: false, //{NEW} Boolean: Reverse the animation direction
animationLoop: "enable_animation_slider", //Boolean: Should the animation loop? If false, directionNav will received "disable" classes at either end
smoothHeight: false, //{NEW} Boolean: Allow height of the slider to animate smoothly in horizontal mode
startAt: 0, //Integer: The slide that the slider should start on. Array notation (0 = first slide)
slideshow: true, //Boolean: Animate slider automatically
slideshowSpeed: 7000, //Integer: Set the speed of the slideshow cycling, in milliseconds
animationSpeed: 600, //Integer: Set the speed of animations, in milliseconds
initDelay: 0, //{NEW} Integer: Set an initialization delay, in milliseconds
randomize: false, //Boolean: Randomize slide order
thumbCaptions: false,
In my theme-options.php i have create this :
/* Slider Settings */
array(
'label' => 'Enable animation loop Slider',
'id' => 'enable_animation_slider',
'type' => 'checkbox',
'desc' => 'Check if you want to disable loop',
'choices' => array(
array(
'label' => 'false',
'value' => 'false'
)
),
'std' => 'false',
'rows' => '',
'post_type' => '',
'taxonomy' => '',
'class' => '',
'section' => 'slider_default'
),
My problem is flexslider do not grab id enable_animation_slider and settings admin panel not work.
I have a little statistic page where I can summorize my txt messages by user and by country.
I need now to have a new column where i can have operator as well.
To be more accurate, I need column to count all the Vodafone messages. I have already operator in my database and there are 5 different operators. I just need to bring out Vodafone.
Here are json php:
require_once("../corporate/php/modules/core/init.inc.php");
$where = " queue.dt_entered >= '".mysql_real_escape_string(trim($_POST["startdate"]))." 00:00:00' and queue.dt_entered <= '".mysql_real_escape_string(trim($_POST["enddate"]))." 23:59:59' ";
$result = $db -> query("
SELECT queue.user_id AS user, users.username as username, SUM( queue.amount ) AS amount, COUNT( queue.amount ) AS count, IFNULL( (
SELECT TRIM( country )
FROM CORE_E164
WHERE code = SUBSTR( queue.receiver, 3, 3 ) ) , IFNULL( (
SELECT TRIM( country )
FROM CORE_E164
WHERE code = SUBSTR( queue.receiver, 3, 2 ) ) , IFNULL( (
SELECT TRIM( country )
FROM CORE_E164
WHERE code = SUBSTR( queue.receiver, 3, 1 ) ) , 'None'
)
)
) AS country
FROM sms_queue AS queue, users AS users
WHERE queue.user_id = users.id
AND queue.client_type = 'corporative'
AND ".$where."
GROUP BY user, country
order by username
");
$result_array = array();
while ($row = mysql_fetch_array($result)) {
array_push($result_array, array("user" => $row["user"],
"username" => $row["username"],
"country" => $row["country"],
"amount" => $row["amount"],
"count" => $row["count"]
));
}
$result_total = array(
"success"=>true,
"messages" => $result_array
);
echo json_encode($result_total);
I am adding now the html page as well:
function columnWrap(val){
return '<div style="white-space:normal !important;">'+ val +'</div>';
}
var stat_store=new Ext.data.JsonStore({
root: 'messages',
fields : [
{name: 'id', mapping: 'user'},
{name: 'username', mapping: 'username'},
{name: 'country', mapping: 'country'},
{name: 'amount', mapping: 'amount'},
{name: 'count', mapping: 'count'},
{name: 'emt', mapping: 'emt'}
],
proxy : new Ext.data.HttpProxy({url:'group_stats.json.php'})
});
var filters = new Ext.ux.grid.GridFilters({
encode: false,
local: true,
filters: [{
type: 'string',
dataIndex: 'username'
},{
type: 'string',
dataIndex: 'country'
},{
type: 'string',
dataIndex: 'operator'
}]
});
var summary = new Ext.ux.grid.GridSummary();
var stat_grid = new Ext.grid.EditorGridPanel({
store: stat_store,
region: 'center',
plugins: [filters, summary],
columns: [
{header: "User ID", width: 50, dataIndex: 'id', sortable: true},
{header: "Username", width: 160, dataIndex: 'username', sortable: true, filterable: true},
{header: "Target country", width: 330, dataIndex: 'country', sortable: true, filterable: true},
{header: "Request count", width: 110, dataIndex: 'count', sortable: true, filterable: true, summaryType: 'sum'},
{header: "EMT count", width: 110, dataIndex: 'count', sortable: true, filterable: true, summaryType: 'sum'},
{header: "SMS sum", width: 110, dataIndex: 'amount', sortable: true, filterable: true, summaryType: 'sum'}
]
});
var FilterPanel = new Ext.FormPanel({
labelAlign: 'top',
frame:true,
region: 'north',
bodyStyle:'padding:5px 5px 0',
height: 95,
items: [{
layout:'column',
items:[{
columnWidth: 0.1,
layout: 'form',
items: [new Ext.form.DateField({
fieldLabel: 'Alguskuupäev',
name: 'startdate',
id: 'startdate',
value: new Date().format('Y-m-d'),
format:'Y-m-d',
anchor:'95%',
allowBlank:false })]
},{
columnWidth:.1,
layout: 'form',
items: [ new Ext.form.DateField({
fieldLabel: 'Lõppkuupäev',
name: 'enddate',
id: 'enddate',
value: new Date().format('Y-m-d'),
format:'Y-m-d',
anchor:'95%',
allowBlank:false })]
}]
}],
buttons: [{
text: 'Otsi',
handler: function(){
stat_store.baseParams = {startdate: Ext.get('startdate').dom.value, enddate: Ext.get('enddate').dom.value};
stat_store.load({params:{startdate: Ext.get('startdate').dom.value, enddate: Ext.get('enddate').dom.value}});
}
}]
});
var ContentPanel = new Ext.Panel({
layout: 'border',
items : [FilterPanel, stat_grid],
renderTo: 'list',
width: Ext.get('contentdiv').getWidth() - 5,
height: Ext.get('contentdiv').getHeight() - 30
});
Thank you,
Allan
So You want to count number of Vodafone messages among all selected messages.
SELECT ... SUM(IF(queue.operator = 'Vodafone', 1, 0)) AS vodafoners FROM ...
If You have access to some administration of the database (Adminer, phpMyAdmin or something similar), You can add the column in it. If You don't have such access, use SQL query to add the column:
ALTER TABLE yourTable ADD columnName columnType
For example:
ALTER TABLE sms_queue ADD opername VARCHAR(50)
And then use that column in Your SQL query:
... WHERE sms_queue.opername = 'Vodafone'
I also suggest using an index on that column.
I'm sure it can be done, I just need to see some examples. I want to use flexigrid to show massive sets of data stored in mysql. I am proficient in php, but new to jquery and json.
Can anyone point me in the right direction or provide a good example? I need to see how to return data back to the flexigrid json.
Thank you
Great Tutorial on this topic
This is just the partial code for returning your database results, you would call you page with the flexigrid jquery code
while ($row = mysql_fetch_assoc($results)) {
$data['rows'][] = array(
'id' => $row['pf_id'],
'cell' => array(
$row['cat_code'],
$row['cat_title'],
$row['cat_link'] = "Edit | Associate Familys | Order Children")); }
echo json_encode($data);
call the page with the flexigrid jquery code
$("#flex1").flexigrid({
url: 'category_main_json.php',
dataType: 'json',
colModel : [
{display: 'Code', name : 'cat_code', width : 70, sortable : true, align: 'left'},
{display: 'Name', name : 'cat_title', width : 550, sortable : true, align: 'left'},
{display: 'Action', name : 'cat_link', width : 205, sortable : true, align: 'left'},
],
buttons : [
{name: 'Add New Category', bclass: 'add', onpress : test},
{separator: true}
],
searchitems : [
{display: 'Code', name : 'cat_code'},
{display: 'Name', name : 'cat_title', isdefault: true}
],
sortname: "cat_code",
sortorder: "asc",
usepager: true,
useRp: true,
rp: 50,
showTableToggleBtn: false,
resizable: false,
width: 880,
height: 450,
singleSelect: true,
showTableToggleBtn: false
}
);
I am using flexigrid for one of my projects and I need to come up with a way to change the image source depending on the value of one of the cells. For people who are used to flexigrid, I have the following code:
$json .= ",'".addslashes("<span><img src='' id='flag' />" . $row['availability']. "</span>")."'";
and my javascript that I've come up with , looks like this:
<script type="text/javascript">
var available = "<?php echo '$row[availability]' ?>";
if (available == 0) {
document.getElementById('flag').src="images/flag_red.png";
}
elseif (available == 1) {
document.getElementById('flag').src="images/flag_green.png";
}
else {
document.getElementById('flag').src="images/flag_orange.png";
}
I am not sure where I need to insert this function and how to trigger it. Any help will be greatly appreciated.
Regards,
Cristian.
LE: The code where the problem is being reported:
url: 'post2.php',
dataType: 'json',
colModel : [
{display: 'ID', name : 'id', width : 40, sortable : true, align: 'center', hide: true},
{display: 'URL', name : 'url', width : 450, sortable : false, align: 'left'},
{display: 'File Name', name : 'filename', width : 270, sortable : true, align: 'left'},
{display: 'Availability', name : 'availability', width : 50, sortable : true, align: 'center'},
{display: 'State', name : 'state', width : 40, sortable : true, align: 'center'},
{display: 'Total Size', name : 'totalsize', width : 90, sortable : false, align: 'center'},
{display: 'Current Size', name : 'currentsize', width : 90, sortable : false, align: 'center'},
{display: 'Procent', name : 'procent', width : 40, sortable : true, align: 'center'},
{display: 'Log', width : 20, sortable : false, align: 'center'},
],
buttons : [
{name: 'Add', bclass: 'add', onpress : test},
{separator: true},
{name: 'Delete', bclass: 'delete', onpress : test},
{separator: true},
{name: 'Select All', bclass : 'selectall', onpress : test},
{name: 'DeSelect All', bclass : 'deselectall', onpress : test},
{separator: true}
],
searchitems : [
{display: 'URL', name : 'url'},
{display: 'Filename', name : 'filename', isdefault: true}
],
sortname: "state",
sortorder: "asc",
usepager: true,
title: '',
useRp: false,
rp: 5,
showTableToggleBtn: true,
} ----- **IE says there is a problem here** );
});
You shouldn't use javascript for this, you can do it directly in your existing PHP line.
$json .= ",'" .
addslashes("<span><img src='" .
($row['availability'] == 0 ? "images/flag_red.png" :
($row['availability'] == 1 ? "images/flag_green.png" :
"images/flag_orange.png")
) .
"' id='flag' />" . $row['availability'] . "</span>") . "'";