Event not triggering until 3rd click - php

I have a filter by alphabet within a WordPress website that I would like to filter when the letter is selected without the user having to select the letter and then the search button. However it only seems to work after the 3rd click and that is if you click quickly. The filter itself is a customisation for an existing WordPress directory theme, here is a link to the directory: https://staging.pata.org.uk/item/. How can I get the click to trigger on the first click of a letter rather than the third?
This is the jquery:
<script type="text/javascript">
jQuery(document).ready(function(){
// filter type actions
// checkbox
jQuery('.advanced-filters-wrap-letter ul li.filter-checkbox-letter').on('click', function(e){
jQuery(this).toggleClass('filter-enabled');
var $input = jQuery(this).find('input');
if($input.is(':checked')){
$input.removeAttr('checked');
} else {
$input.attr('checked', true);
}
// filter submit actions
jQuery('.filter-container').on('click', function(e){
e.preventDefault();
// build new query
var addToFilter = "";
var filterString = "";
var filterCheck = 0;
// &filters=id;id;id
jQuery('.advanced-filters-wrap ul li').each(function(){
var $inputOne = jQuery(this).find('input');
if($inputOne.is(':checked')){
addToFilter = $inputOne.val() + " ";
filterCheck += 1;
}
});
jQuery('.advanced-filters-wrap-letter ul li').each(function(){
var $input = jQuery(this).find('input');
if($input.is(':checked')){
filterString = filterString + $input.val() + " " + addToFilter;
filterCheck += 1;
}
});
filterString = filterString.trim().replace(new RegExp(' ', 'g'), ";");
var pathName = window.location.pathname;
/* remove page parameter from url */
pathName = pathName.replace(new RegExp("page\/[0-9]*\/", 'g'), "");
/* remove page parameter from url */
var baseUrl = window.location.protocol+"//"+window.location.host+pathName;
var eParams = window.location.search.replace("?", "").split('&');
var nParams = {};
jQuery.each(eParams, function(index, value){
var val = value.split("=");
if(typeof val[1] == "undefined"){
nParams[val[0]] = "";
} else {
nParams[val[0]] = decodeURIComponent(val[1]);
}
});
var query = jQuery.extend({}, nParams, { filters: filterString });
if(filterCheck == 0){
delete query.filters;
}
delete query.paged;
delete query.count;
// remove empty keys
jQuery.each(query, function(k, v){
if(!k){
delete query[k];
}
});
var queryString = jQuery.param(query);
window.location.href = baseUrl + "?" + queryString;
});
});
});
</script>
and this is the rest of the code
<?php
// &filters=id;id;id;id
$themeOptions = aitOptions()->getOptionsByType('theme');
$advancedFiltersOptions = (object)$themeOptions['itemAdvancedFilters'];
if($advancedFiltersOptions->enabled){
$filters_avalaible = get_terms('ait-items_filters', array('hide_empty' => false));
$filters_enabled = array();
if(isset($_REQUEST['filters']) && !empty($_REQUEST['filters'])){
$filters_enabled = explode(";",$_REQUEST['filters']);
}
if($query->max_num_pages != 1){
// check if there will be pagination
$item_query_args = $query->query_vars; // populate new variable ... dont modify original query
$item_query_args['nopaging'] = true;
$item_query = new WP_Query($item_query_args);
} else {
$item_query = $query;
}
$item_filters = array();
foreach($item_query->posts as $post){
$post_meta = get_post_meta( $post->ID, '_ait-item_filters-options');
if(!empty($post_meta)){
$post_filters = $post_meta[0]['filters'];
foreach ($post_filters as $id) {
$filter = get_term($id, 'ait-items_filters', "OBJECT");
if(!empty($filter)){
array_push($item_filters, $filter);
}
}
}
}
$unique_filters = array_map("unserialize", array_unique(array_map("serialize", $item_filters)));
$filters_avalaible = $unique_filters;
usort($filters_avalaible, function($a, $b){
return strcmp($a->slug, $b->slug);
});
?>
<?php
if(is_array($filters_avalaible) && count($filters_avalaible) > 0){
?>
<div class="advanced-filters-wrap-letter">
<div class="advanced-filters-container">
<div class="content">
<h3>Alphabetical</h3>
<ul class="advanced-filters columns-<?php echo $advancedFiltersOptions->filterColumns ?>">
<?php
$array=array("A", "B", "C", "D", "E", "F","G","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z");
$letters = array();
foreach($filters_avalaible as $filter){
if(in_array($filter->name,$array)) {
array_push($letters, $filter);
}
}
?>
<?php
foreach($letters as $letter)
{
if(!empty($letter))
{
$filter_options = get_option( "ait-items_filters_category_".$letter->term_id );
$filter_type = isset($filter_options['type']) ? $filter_options['type'] : 'checkbox';
$is_enabled = in_array($letter->term_id, $filters_enabled);
$li_class = "";
$in_checked = "";
if($is_enabled){
$li_class = "filter-enabled";
$in_checked = "checked";
}
switch($filter_type){
case 'checkbox':
/*$imageClass = !empty($filter_options['icon']) ? 'has-image' : '';*/
$imageClass = 'has-image';
$image = !empty($filter_options['icon']) ? '<i class="fa '.$filter_options['icon'].'"></i>' : '<i class="fa fa-dot-circle-o"></i>';
echo '<li class="filter-container filter-checkbox-letter '.$li_class.' '.$imageClass.' "><input type="checkbox" name="'.$letter->slug.'" value="'.$letter->term_id.'" '.$in_checked.'> <span class="filter-name">'.$letter->name.'</span></li>';
break;
default:
echo '<li class="filter-container filter-unsupported">'.__('Unsupported filter', 'ait-advanced-filters').'</li>';
break;
}
}}}?>
</ul>
</div>
</div>
<div class="advanced-filters-actions">
<?php _e('Search', 'ait') ?>
Back
</div>
</div>
<?php
}

Related

Get Value of Appended Element After Submit Button with POST Type Form

I want to get the value of appended elements after submitting. It appends the right name attributes, but I can't get the value
<script>
<?php
$options = '';
while($searched_species_adding = mysqli_fetch_array($search_species_adding)){
$name = $searched_species_adding['name'];
$options = $options.'<option>'.$name.'</option>';
}
echo 'var options = "'.$options.'";';
?>
var count=2;
$( "#add-species" ).click(function() {
var html=$("<tr id='species-"+count+"'><td><select name='species-"+count+"' class='form-control'>"+options+"</select></td><td><input id='species-num-"+count+"' name='species-num-"+count+"' class='form-control' type='number'></td></tr>");
$("#species-container").append(html);
$("#species-num-"+count).prop('required',true);
count++;
var wew = ($('tr', $("#wew").find('tbody')).length);
$(".tr-num").remove();
$("#species-container").append("<input class='tr-num' type='hidden' value='"+wew+"' name='tr_count'>");
$(".tr-num").val(wew);
});
$( "#remove-species" ).click(function() {
count--;
$("#species-"+count).remove();
var wew = ($('tr', $("#wew").find('tbody')).length);
$(".tr-num").val(wew);
});
</script>
Above is the script for appending.
And here is my code in getting the values in a form after submitting:
if(isset($_POST['add-delivered'])){
$requestor = $_POST['requestor'];
$org_office = $_POST['org_office'];
$address = $_POST['address'];
$date_pickup = $_POST['date_pickup'];
$location = $_POST['location'];
$planting_type = $_POST['planting_type'];
$tr_count = $_POST['tr_count'];
$species = '';
for($x = 1; $x <= $tr_count; $x++){
$species = $species.$_POST['species-'.$x];
}
echo '<script>alert("'.$tr_count.'")</script>';
exit();
}

How to get the href click event to work with a variable?

I am working on jquery to click on the mail folder href links for my emails so I could do something. But I have got a problem with clicking on the href links because when I click on the href links, nothing will happens.
When I try this:
$(document).on('click', 'a[href^=#'+folder+']', function(e) {
alert("Now you are working on mailfolder");
});
Here is the PHP:
$folders_list = imap_listmailbox($mailbox, $mailserver, "*");
$folders_arr = array();
$key = array();
sort($folders_list);
if (is_array($folders_list)) {
unset($folders_list[0]);
$imp = '{imap.example.com:993/imap/ssl/novalidate-cert}INBOX.Archive.Important';
$trash = '{imap.example.com:993/imap/ssl/novalidate-cert}INBOX.Trash';
$sent = '{imap.example.com:993/imap/ssl/novalidate-cert}INBOX.Sent';
$draft = '{imap.example.com:993/imap/ssl/novalidate-cert}INBOX.Drafts';
$archive = '{imap.example.com:993/imap/ssl/novalidate-cert}INBOX.Archive';
$junk = '{imap.example.com:993/imap/ssl/novalidate-cert}INBOX.Junk';
$spam = '{imap.example.com:993/imap/ssl/novalidate-cert}INBOX.spam';
$key1 = array_search($imp, $folders_list);
$key2 = array_search($trash, $folders_list);
$key3 = array_search($sent, $folders_list);
$key4 = array_search($draft, $folders_list);
$key5 = array_search($archive, $folders_list);
$key6 = array_search($junk, $folders_list);
$key7 = array_search($spam, $folders_list);
$key = [$key1, $key2, $key3, $key4, $key5, $key6, $key7];
sort($key);
foreach ($key as $val) {
unset($folders_list[$val]);
}
foreach ($folders_list as $mailbox_name) {
$mailbox_name = str_replace("{imap.example.com:993/imap/ssl/novalidate-cert}", "", $mailbox_name);
$mailbox_name = str_replace("INBOX.", "", $mailbox_name);
$folders_arr[] = $mailbox_name;
}
}
sort($folders_arr);
<ul class="folder-nav inbox-divider">
<li> <h4>Folders</h4></li>
<?php
foreach ($folders_arr as $folders) {
?>
<div style="width: 100%;">
<li>
<i style="margin-left: -7px;" class="folder_icon"></i><span style="margin-left: 7px;"> <?php echo $folders;?></span>
</li>
</div>
<?php
}
?>
</ul>
Here is the jquery:
var hash = window.location.hash;
var folder = hash.split('/')[0].replace('#', '');
$(document).on('click', 'a[href^=#'+folder+']', function(e) {
e.preventDefault();
start_idx = 0;
alert("Now you are working on mailfolder");
if ($("#movetoFolder").css('display') == 'block') {
$('#movetoFolder').hide();
}
if (openMail == true) {
openMail = false;
}
if(window.location.hash == '#'+folder) {
$("#click_nav_prev").addClass("disabled");
$("#click_nav_next").removeClass("disabled");
loadEmailBodyContent = false;
$(".bottom_space").show();
$(".emailMessages").hide();
$(".emailBodyShowUp").hide();
$("#opt_refresh").show();
$('.tbody_maillist').show();
mailfolder();
}
else
{
mailfolder();
}
});
I have already tried this:
$(document).on('click', '.mailfolder', function(e) {
....etc
});
It works fine, but it wont add the folder name in the url like http://example.com/#foldername when I click on the href links.
What I am trying to do is I want to get the href click event to work for any folder that I click on the a tag using with the variable so I can work on the code to fetch the data from the mail folders.
Can you please show me an example how I can get the href click event to work with the variable called folder?
Thank you.
I think you want something like this:
$(".mailfolder").on('click', function(e) {
e.preventDefault();
var folder = $(this).attr("href");
start_idx = 0;
alert("Now you are working on mailfolder");
if ($("#movetoFolder").css('display') == 'block') {
$('#movetoFolder').hide();
}
if (openMail == true) {
openMail = false;
}
if (window.location.hash == folder) {
$("#click_nav_prev").addClass("disabled");
$("#click_nav_next").removeClass("disabled");
loadEmailBodyContent = false;
$(".bottom_space").show();
$(".emailMessages").hide();
$(".emailBodyShowUp").hide();
$("#opt_refresh").show();
$('.tbody_maillist').show();
mailfolder();
} else {
mailfolder();
}
});
If you use a variable in an event delegation selector, the variable is expanded at the time you create the delegation, not every time the event occurs. So you can't have the delegation check automatically whether the link matches the current hash.
Another way you could do this is with a hashchange event handler. It could add a class to the link that matches the new hash, and remove the class from other links, and you can delegate to that class. Like this:
$(window).on("hashchange", function() {
$(".mailfolder").removeClass("current");
$(`.mailfolder[href=${window.location.hash}]`).addClass("current");
});
// Special code just for current folder
$(document).on('click', ".mailfolder.current", function(e) {
$("#click_nav_prev").addClass("disabled");
$("#click_nav_next").removeClass("disabled");
loadEmailBodyContent = false;
$(".bottom_space").show();
$(".emailMessages").hide();
$(".emailBodyShowUp").hide();
$("#opt_refresh").show();
$('.tbody_maillist').show();
});
// Common code for all mail folder links
$(".mailfolder").on("click", function() {
e.preventDefault();
var folder = $(this).attr("href");
start_idx = 0;
alert("Now you are working on mailfolder");
if ($("#movetoFolder").css('display') == 'block') {
$('#movetoFolder').hide();
}
if (openMail == true) {
openMail = false;
}
window.location.hash = $(this).attr("href");
mailfolder();
});

Magento : How to display selected custom option price in product detail page In price box

I want to display custom option price with name in price box in product detail page.
I also try this link but not getting success this is link i use
So please suggest me any solution.
first of all you have to put button calculateprice
then onclick of calculateprice you have to call function chkprice()
function chkpice()
{
var a=document.getElementById("options_1_text").value;
var b=document.getElementById("options_2_text").value;
var c=document.getElementById("options_3_text").value;
var d=document.getElementById("options_4_text").value;
var e=<?php echo $_product = $this->getProduct()->getPrice()?>;
var f=(a+b+c+d)+e;
var e=document.getElementById(('product-price-'+<?php echo $_product = $this->getProduct()->getId()?>)).innerHTML;
$('product-price-'+<?php echo $_product = $this->getProduct()->getId()?>).innerHTML =''+e.replace(<?php echo $_product = $this->getProduct()->getPrice()?>,d)+'</span>';
}
insted of options_1_text,options_2_text,options_3_text,options_4_text put your id it will get your result
First you do the function that takes care of updating the charges:
function updateCharges(){
var tmpText="";
$("input[type='select']").each(function{
tmpText+=$("#"+this.id+"option:selected").text()+"<br>";
});
$("#detailDiv").html(tmpText)
}
Then you just bind the selects to that function
$("input[type='select']").change(updateCharges)
Now you just have to make sure to include in your template a <div id="detailDiv"></div>
I would just create a custom block with the above code and place it inside the product detail page. Also you should check the selectors used, they will look for absolutelty ALL selects on the page, so thats not what you may want. But its just a matter of firebug-ging untill the aproppiate selector is found
Recently I need something similar. Perhaps it is helpful for you.
Block class:
class Foo_Bar_Block_Baz extends Mage_Catalog_Block_Product_View {
protected function getOptionDataCollection($options) {
$optionDataCollection = array();
foreach ($options as $option) {
$optionDataCollection[$option->getData('option_id')] = array_filter($option->getData());
}
return $optionDataCollection;
}
protected function getOptionValueDataCollection($options) {
$optionValueDataCollection = array();
foreach ($options as $option) {
$optionType = $option->getType();
if ($optionType == 'drop_down') {
$optionValues = $option->getValues();
foreach ($optionValues as $valueItem) {
// here you could also use the option_type_id (in my case I needed the sku)
$optionValueDataCollection[$valueItem->getData('sku')] = array_filter($valueItem->getData());
}
} else {
//Mage::throwException('Unexpected input. Processing for this optionType is not implemented');
}
}
return $optionValueDataCollection;
}
public function getOptionsJson() {
$data = array(
'options' => array(),
'optionValues' => array()
);
$options = $this->getProduct()->getOptions();
array_push($data['options'], $this->getOptionDataCollection($options));
array_push($data['optionValues'], $this->getOptionValueDataCollection($options));
$optionsJson = json_encode($data);
return $optionsJson;
}
}
Template
<script id="optionsJson" type="application/json">
<?php echo $this->getOptionsJson(); ?>
</script>
JS
var json = JSON.parse(document.getElementById("optionsJson").innerHTML),
options = json.options[0],
optionValues = json.optionValues[0];
optionValues['<optionValueSKU>'].default_title
optionValues['<optionValueSKU>'].price
-----------Create controller-------------
<?php
class Magento_Guys_IndexController extends Mage_Core_Controller_Front_Action
{
public function indexAction()
{
echo "Thank you !";
}
public function genCartAction()
{
$id = $this->getRequest()->getParam('pid');
$_product = Mage::getModel('catalog/product')->load($id);
$buy = Mage::helper('checkout/cart')->getAddUrl($_product);
echo $qty = (int) Mage::getModel('cataloginventory/stock_item')->loadByProduct($_product)->getQty();
//echo $id;
//echo $this->getRequest()->getParam('id');;
}
}
?>
----------------Change Add to cart code-------------------
<?php if ($_product->isAvailable()): ?>
<b class="available_quanity" style="display: none">Available Quantity :</b> <span id="simplestock" class="simplestock">Please select a color to view the quantity</span>
<?php endif; ?>
</div>
<?php if(!$_product->isGrouped()): ?>
<div class="qty">
<label for="qty"><?php echo $this->__('Qty:') ?></label>
<?php $i = 0; ?>
<select id="qty" class="input-text" name="qty" style="width:50px;">
<?php while($i<=(int) Mage::getModel('cataloginventory/stock_item')->loadByProduct($_product)->getQty()):?>
<option value="<?php echo $i; ?>"><?php echo $i++; ?></option>
<?php endwhile; ?>
</select>
</div>
<?php endif; ?>
----------------Add Ajax for get Quantity---------------
<script>
jQuery(document).ready(function() {
jQuery(".product-options select[id^='attribute']").on('change', function() {
var id = getSimpleProductId();
var qty = "";
jQuery('.available_quanity').show();
jQuery("#fancybox-loading").show();
jQuery.ajax({
type: "POST",
data: 'pid=' + id,
url:'https://www.thewirelesscircle.com/guys/index/genCart',
success:function(response){
if (response) {
qty = response;
var x = document.getElementById("qty");
var i;
removeOptions(x);
for(i=1;i<=qty;i++) {
var option = document.createElement("option");
option.text = i;
option.value = i;
x.add(option);
}
}
jQuery("#fancybox-loading").hide();
}
});
});
});
</script>
---------------Get Selected Option Id in Magento-------------------
<script type="text/javascript">
function removeOptions(selectbox)
{
var i;
for(i = selectbox.options.length - 1 ; i >= 0 ; i--)
{
selectbox.remove(i);
}
}
function getSimpleProductId() {
var productCandidates = [];
jQuery.each(spConfig.settings, function (selectIndex, select) {
var attributeId = select.id.replace('attribute', '');
var selectedValue = select.options[select.selectedIndex].value;
jQuery.each(spConfig.config.attributes[attributeId].options, function(optionIndex, option) {
if (option.id == selectedValue) {
var optionProducts = option.products;
if (productCandidates.length == 0) {
productCandidates = optionProducts;
} else {
var productIntersection = [];
jQuery.each(optionProducts, function (productIndex, productId) {
if (productCandidates.indexOf(productId) > -1) {
productIntersection.push(productId);
}
});
productCandidates = productIntersection;
}
}
});
});
return (productCandidates.length == 1) ? productCandidates[0] : null;
}
</script>
Open page: app\code\core\Mage\Catalog\Block\Product\View\Options.php find protected function _getPriceConfiguration($option) function and add $data['title'] = $option->getTitle(); before return $data; statement.
Now, open app\design\frontend\YOUT_TEMPLATE_PATH\default\template\catalog\product\view\options.phtml
Add <div id="optiontitle"></div> top of the page.
Then find this:
$A(element.options).each(function(selectOption){
if ('selected' in selectOption && selectOption.selected) {
if (typeof(configOptions[selectOption.value]) != 'undefined') {
curConfig = configOptions[selectOption.value];
}
}
});
Replace by:
$A(element.options).each(function(selectOption){
if ('selected' in selectOption && selectOption.selected) {
if (typeof(configOptions[selectOption.value]) != 'undefined') {
curConfig = configOptions[selectOption.value];
optionTitle = curConfig.title + "<br>";
$("optiontitle").insert(optionTitle);
}
}
});

Maps left top, not centered

When I'm clicking on add marker, the marker is in the top left of maps and not in the center.
I know that I'm working on V2, but I need it to work so I can get myself some time to figure V3 out.
Can someone please help me to fix this?
Already tried:
map.setCenter() on different places, but nothing works.
This is the main script:
<script
src="http://maps.google.com/maps?file=api&v=2&sensor=false&key=<?php echo $this->params->get('map_api_key');?>"
type="text/javascript"></script>
<script type="text/javascript">
//<!--
var map;
var marker;
var markeradded=false;
var markerfixed=false;
var current_point;
var catIcon;
function initialize()
{
if (GBrowserIsCompatible())
{
map = new GMap2(document.getElementById("map_canvas"),{ size: new GSize(430, 315) });
map.setUIToDefault();
map.disableScrollWheelZoom();
geocoder = new GClientGeocoder();
map.checkResize()
}
}
window.addEvent('domready',function()
{
initialize();
//var mapSlider = new Fx.Slide('gb_maplocator', {duration: 1000});
var mapSlider = document.getElementById('gb_maplocator');
//var mapSlider = $('gb_maplocator');
<?php if( $this->data->published==0){?>
mapSlider.style.visibility = 'hidden';
mapSlider.style.height = '0px';
mapSlider.style.overflow = 'hidden';
<?php } ?>
$$('.gb_map_controls').addEvent('click',function(){
if(this.getProperty('value')==1)
{
mapSlider.style.visibility = 'visible';
mapSlider.style.height = 'auto';
}
else if(this.getProperty('value')==0)
{
mapSlider.style.visibility = 'hidden';
mapSlider.style.height = '0px';
mapSlider.style.overflow = 'hidden';
}
});
$('btnAddtomap').addEvent('click',
function(e) {
$('map_level').value=map.getZoom();
$('map_glat').value=current_point.lat();
$('map_glng').value=current_point.lng();
});
GEvent.addListener(map, "zoomend",
function(oldlevel,newlevel) {
$('map_level').value=newlevel;
});
GEvent.addListener(map, "dragend",
function() {
current_point=map.getCenter();
});
<?php
if( $this->pin->map_image )
{
?>
catIcon = new GIcon();
catIcon.image = '<?php echo JUri::root().$this->pin->map_image.".".$this->pin->extension;?>';
catIcon.shadow = '<?php echo JUri::root().$this->pin->shadow_image.".".$this->pin->extension;?>';
//catIcon.iconSize = new GSize(25.0, 32.0);
//catIcon.shadowSize = new GSize(42.0, 32.0);
catIcon.iconAnchor = new GPoint(12.0, 16.0);
catIcon.infoWindowAnchor = new GPoint(12.0, 16.0);
map.disableScrollWheelZoom();
<?php
}
if(abs($this->data->glat)==0&&abs($this->data->glng)==0)
{
$country=$mainframe->getUserState($option."countrytitle");
$region=$mainframe->getUserState($option."regiontitle");
$address= array();
if($region!= JText::_('ALL') && !empty($region)){
$address[]=$region;
}
if($country!= JText::_('ALL') && !empty($country)){
$address[]=$country;
}
array_filter ($address);
if(count($address)>0)
{
?>
showAddress('<?php echo implode(',',$address)?>');
<?php
}
else
{
?>
showAddress('<?php echo $this->params->get('map_default_address','Brisbane, Australia');?>');
<?php
}
}
else
{
if( ! $this->pin->map_image && $this->data->map_image )
{
?>
catIcon = new GIcon();
catIcon.image = '<?php echo JUri::root().$this->data->map_image.".".$this->data->extension;?>';
catIcon.shadow = '<?php echo JUri::root().$this->data->shadow_image.".".$this->data->extension;?>';
//catIcon.iconSize = new GSize(25.0, 32.0);
//catIcon.shadowSize = new GSize(42.0, 32.0);
catIcon.iconAnchor = new GPoint(12.0, 16.0);
catIcon.infoWindowAnchor = new GPoint(12.0, 16.0);
<?php }?>
current_point=new GLatLng(<?php echo $this->data->glat;?>,<?php echo $this->data->glng;?>);
map.setCenter(current_point,<?php echo $this->data->level;?>);
marker = new GMarker(current_point,{icon:catIcon,draggable:true});
GEvent.addListener(marker, "dragend",
function(latlng) {
current_point = latlng;
$('map_level').value=map.getZoom();
$('map_glat').value=latlng.lat();
$('map_glng').value=latlng.lng();
});
marker.disableDragging();
map.addOverlay(marker);
checkResize()
markeradded=true;
markerfixed=true;
$('addMarkerButton').disabled=true;
$('addMarkerButton').setHTML("<?php echo JText::_('REMOVE_MARKER');?>");
$('fixMarkerButton').setHTML("<?php echo JText::_('UNFIX_MARKER');?>");
$('map_level').value=map.getZoom();
$('map_glat').value=current_point.lat();
$('map_glng').value=current_point.lng();
<?php if($this->data->published==0){?>
mapSlider.style.visibility = 'hidden';
mapSlider.style.height = "0px";
mapSlider.style.overflow = 'hidden';
<?php }?>
<?php
}
?>
if(markeradded)
{
$('fixMarkerButton').disabled=false;
}
else
{
$('fixMarkerButton').disabled=true;
}
});
window.addEvent('unload',function(){GUnload()});
//-->
</script>
<div class="gb_madata_publish">
<label><?php echo JText::_('Activeer Google Maps');?>:</label><div class="gb_madata_publish_control"><?php echo $this->lists['status'];?></div>
</div>
<div class="gb_map_locator" id="gb_maplocator">
<a id="btnAddtomap"><?php echo JText::_('LOCATE_ADDRESS_TO_MAP');?></a>
<fieldset class="adminform"><input type="hidden" name="glat"
id="map_glat" /> <input type="hidden" name="glng" id="map_glng" /> <input
type="hidden" name="level" id="map_level" />
<div id="map_canvas" style="width: 430px; height: 315px"><script>checkResize() </script></div>
<br />
<div class="mapbuttons"><a id="addMarkerButton"><?php echo JText::_('ADD_MARKER');?></a>
<a id="fixMarkerButton"><?php echo JText::_('FIX_MARKER');?></a></div>
</fieldset>
</div>
<?php
}
?>
And this is the JavaScript file that is included:
/**
* Map controller buttons
*
*/
window.addEvent('domready', function() {
var country_id = '';
var region_id = '';
var address1 = '';
var address2 = '';
$('btnAddtomap')
.addEvent(
'click',
function(e) {
e = new Event(e);
e.stop();
if($('address1')== undefined && $('address2')== undefined) return false;
if($('country_id')!= undefined) country_id= $('country_id').value;
if($('region_id')!= undefined) region_id= $('region_id').value;
if($('address1')!= undefined) address1= $('address1').value;
if($('address2')!= undefined) address2= $('address2').value;
url = 'index.php?option=com_listbingo&format=raw&task=addons.map.admin.loadadd&cid='
+ country_id
+ '&region_id='
+ region_id;
url += '&street=' + address2
+ '&address='
+ address1;
req = new Ajax(url, {
onComplete :showAddress,
method :'get',
evalscript :true
});
req.request();
setCenter()
});
$('addMarkerButton').addEvent(
'click',
function(e) {
e = new Event(e);
e.stop();
if (!markeradded) {
marker = new GMarker(current_point, { icon:catIcon,
draggable :true
});
$('map_level').value=map.getZoom();
$('map_glat').value=(0);
$('map_glng').value=(0);
map.addOverlay(marker);
marker.enableDragging();
}
});
});
Done, i solved it by not using hidden divs.

shuffle slider display

i have a problem on the slider of my site, though the slider works fine and good but i need it to be random or shuffle instead of displaying an ordered content..
i already have the code and it need some modification.
this is the line on the main file.php
<script type="text/javascript">
$(document).ready(function() {
$('#slider1').s3Slider({
timeOut: 8000
});
});
<div id="slider1">
<ul id="slider1Content">
<li class="slider1Image">
<img src="products/1.png" alt="1" />
<span class="left">
caption1
</span>
</li>
<li class="slider1Image">
<img src="products/2.png" alt="2" />
<span class="right">caption2
</span>
</li>
<li class="slider1Image">
<img src="products/3.png" alt="3" />
<span class="right">caption3.
</span>
</li></div>
this is the java script file
(function($){
$.fn.s3Slider = function(vars) {
var element = this;
var timeOut = (vars.timeOut != undefined) ? vars.timeOut : 4000;
var current = null;
var timeOutFn = null;
var faderStat = true;
var mOver = false;
var items = $("#" + element[0].id + "Content ." + element[0].id + "Image");
var itemsSpan = $("#" + element[0].id + "Content ." + element[0].id + "Image span");
items.each(function(i) {
$(items[i]).mouseover(function() {
mOver = true;
});
$(items[i]).mouseout(function() {
mOver = false;
fadeElement(true);
});
});
var fadeElement = function(isMouseOut) {
var thisTimeOut = (isMouseOut) ? (timeOut/2) : timeOut;
thisTimeOut = (faderStat) ? 10 : thisTimeOut;
if(items.length > 0) {
timeOutFn = setTimeout(makeSlider, thisTimeOut);
} else {
console.log("Poof..");
}
}
var makeSlider = function() {
current = (current != null) ? current : items[(items.length-1)];
var currNo = jQuery.inArray(current, items) + 1
currNo = (currNo == items.length) ? 0 : (currNo - 1);
var newMargin = $(element).width() * currNo;
if(faderStat == true)
{
if(!mOver) {
$(items[currNo]).fadeIn((timeOut/6), function() {
if($(itemsSpan[currNo]).css('bottom') == 0) {
$(itemsSpan[currNo]).slideUp((timeOut/6), function() {
faderStat = false;
current = items[currNo];
if(!mOver) {
fadeElement(false);
}
});
} else {
$(itemsSpan[currNo]).slideDown((timeOut/6), function() {
faderStat = false;
current = items[currNo];
if(!mOver) {
fadeElement(false);
}
});
}
});
}
} else {
if(!mOver) {
if($(itemsSpan[currNo]).css('bottom') == 0) {
$(itemsSpan[currNo]).slideDown((timeOut/6), function() {
$(items[currNo]).fadeOut((timeOut/6), function() {
faderStat = true;
current = items[(currNo+1)];
if(!mOver) {
fadeElement(false);
}
});
});
} else {
$(itemsSpan[currNo]).slideUp((timeOut/6), function() {
$(items[currNo]).fadeOut((timeOut/6), function() {
faderStat = true;
current = items[(currNo+1)];
if(!mOver) {
fadeElement(false);
}
});
});
}
}
}
}
makeSlider();
};})(jQuery);
i am struggling modifying this script for almost a week ... please help
Not sure if your still looking for a solution... I've just done this, but thought it would have been a better method to write the li tags out server side by calling them from a random array. That's if your using server side scriptiing - Below is what I did in php.
$arr = array("
Some text", "
Some text", "
Some text", );
$arrCnt = count($arr);
for ($i=0; $i<=$arrCnt; $i++)
{
$random = array_rand($arr);
echo "<li class='sliderImage'>";
echo $arr[$random];
echo "</li>\n";
if($i<$arrCnt-1)
unset($arr[$random]);
}
?>
Hope that helps.

Categories