Skip to content

Instantly share code, notes, and snippets.

@kiennt2
kiennt2 / Sorting Elements with jQuery
Last active December 18, 2015 15:19
Sorting Elements with jQuery
// sort by class
var mylist = jQuery('ul');
var listitems = mylist.children('li').get();
listitems.sort(function(a, b) {
var compA = jQuery(a).attr("class");
var compB = jQuery(b).attr("class");
return (compA < compB) ? -1 : (compA > compB) ? 1 : 0;
})
jQuery(document).ready(function(){
@kiennt2
kiennt2 / Google Chrome (browser) CSS Hack
Last active October 18, 2016 03:52
Google Chrome (browser) CSS Hack
I can't test it on safari/mac but Safari and Google Chrome uses WebKit rendering engine so it is very likely that every hack works in Safari.
Google Chrome is rather new player but it rapidly increases and there is a need for using specific styles only for that browser. Thats why i am looking for hack for Google Chrome.
Hack 1: @media and -webkit-min-device-pixel-ratio
Testsuite: This text is red in Google Chrome.
This hack uses webkit specific feature.
/* will be red only in google chrome */
@kiennt2
kiennt2 / sass - mixin retina images
Created August 21, 2013 07:39
sass - mixin retina images
// mixin retina images
@mixin background-image-retina($file, $type, $width, $height) {
background-image: url($file + '.' + $type);
@media
only screen and (-webkit-min-device-pixel-ratio: 1.5),
only screen and (-o-min-device-pixel-ratio: 3/2),
only screen and (min--moz-device-pixel-ratio: 1.5),
only screen and (min-device-pixel-ratio: 1.5) {
& {
@kiennt2
kiennt2 / test webpage for Retina display
Created August 23, 2013 11:26
test webpage for Retina display
//css
body {
zoom: 200%;
-moz-transform: scale(2);
-moz-transform-origin: 0 0;
}
@kiennt2
kiennt2 / Magento: Show price ranges of custom option prices in list.phtml instead of base price
Last active August 19, 2017 21:03
Magento: Show price ranges of custom option prices in list.phtml instead of base price
<!-- code change to show price ranges -->
<?php
$product = Mage::getModel('catalog/product')->load($_product->getId());
$prodPrice = $product->getPrice();
if($product->getOptions()){
$minPrices=array();
$maxPrices=array();
foreach ($product->getOptions() as $_option) {
switch ($_option->getType()) {
case 'field': case 'file': case 'area': case 'date_time': case 'date': case 'time':
@kiennt2
kiennt2 / input clearText : onblur - onfocus
Created September 2, 2013 08:12
input clearText : onblur - onfocus
function clearText(field){
if (field.defaultValue == field.value) field.value = '';
else if (field.value == '') field.value = field.defaultValue;
//<input type="text" onblur="clearText(this)" onfocus="clearText(this)" value="value"/>
}
@kiennt2
kiennt2 / simple - jquery multi tab
Last active December 22, 2015 05:48
simple - jquery multi tab
<script type="text/javascript">
jQuery( function($) {
$('.tabs-block').each( function() {
var container = $(this);
container.find('.tab-nav li a').click( function () {
$(this).parent().addClass( 'selected-tab' ).siblings().removeClass( 'selected-tab' );
container.find('.tab-content').hide().filter(this.hash).show();
return false;
}).eq(0).click();
});
@kiennt2
kiennt2 / jquery multi accordion very simple
Last active December 22, 2015 07:49
jquery multi accordion very simple
<script type="text/javascript">
$(document).ready(function(){
$('.accordion > .accordion-title').click(function() {
$(this).siblings(".accordion-title").removeClass('selected');
$(this).siblings(".accordion-content").removeClass('accordion-show');
if($(this).hasClass('selected')) {
$(this).removeClass('selected');
$(this).next(".accordion-content").removeClass('accordion-show');
}else{
@kiennt2
kiennt2 / remove the space between inline-block elements
Created October 9, 2013 06:53
remove the space between inline-block elements
// jQuery
$('.selector').contents().filter(function() { return this.nodeType === 3; }).remove();
@kiennt2
kiennt2 / carousel responsive - using bxslider
Last active March 29, 2018 11:57
carousel responsive - using bxslider