Thursday, May 19, 2016

Magento- Magento Sort Attribute by Decimal not Alphanumerically

The best solution I found was to override the ORDER BY for the query by calling a primitive method of the Collection class, here's the example they give:

$_productCollection = Mage::getModel('catalog/product')->getCollection();
$_productCollection->setOrder('weight', 'asc');
$_productCollection->getSelect()->reset(Zend_Db_Select::ORDER);
$_productCollection->getSelect()->order('CAST(`weight` AS SIGNED) ASC'));

Thursday, May 12, 2016

JavaScript - Fullscreen API JavaScript Code

<p>
  <label>Click the button below to toggle fullscreen</label><br>
  <button id="btnFullscreen" type="button">Toggle Fullscreen</button>
</p>
<p>
<img id="exampleImage" src="https://aftabhusain.files.wordpress.com/2016/06/my-wp-profile-page.png">
</p>

<script>
function toggleFullscreen(elem) {
  elem = elem || document.documentElement;
  if (!document.fullscreenElement && !document.mozFullScreenElement &&
    !document.webkitFullscreenElement && !document.msFullscreenElement) {
    if (elem.requestFullscreen) {
      elem.requestFullscreen();
    } else if (elem.msRequestFullscreen) {
      elem.msRequestFullscreen();
    } else if (elem.mozRequestFullScreen) {
      elem.mozRequestFullScreen();
    } else if (elem.webkitRequestFullscreen) {
      elem.webkitRequestFullscreen(Element.ALLOW_KEYBOARD_INPUT);
    }
  } else {
    if (document.exitFullscreen) {
      document.exitFullscreen();
    } else if (document.msExitFullscreen) {
      document.msExitFullscreen();
    } else if (document.mozCancelFullScreen) {
      document.mozCancelFullScreen();
    } else if (document.webkitExitFullscreen) {
      document.webkitExitFullscreen();
    }
  }
}

document.getElementById('btnFullscreen').addEventListener('click', function() {
  toggleFullscreen();
});

document.getElementById('exampleImage').addEventListener('click', function() {
  toggleFullscreen(this);
});

/*
if (document.addEventListener)
{
    document.addEventListener('webkitfullscreenchange', exitHandler, false);
    document.addEventListener('mozfullscreenchange', exitHandler, false);
    document.addEventListener('fullscreenchange', exitHandler, false);
    document.addEventListener('MSFullscreenChange', exitHandler, false);
}

function exitHandler()
{
  if (!document.fullscreenElement && !document.mozFullScreenElement &&
        !document.webkitFullscreenElement && !document.msFullscreenElement) {
      jQuery('.click-to-full-scr').html('Full Screen');
      jQuery('#toPopup_photodet').removeClass('done-fullscreen');
  }
}*/
</script>

Sunday, May 1, 2016

Google Map- How to add Google Maps Autocomplete search box?


<html>
<head>
<script src="https://maps.googleapis.com/maps/api/js?v=3.exp&sensor=false&libraries=places"></script>
</head>
<body>
<input id="searchTextField" type="text" size="50">
<script>
function initialize() {

var input = document.getElementById('searchTextField');
var autocomplete = new google.maps.places.Autocomplete(input);
}

google.maps.event.addDomListener(window, 'load', initialize);
</script>
</body>
</html>