Friday, January 27, 2012

Custom Scrollbars

 
/**
 * Copyright 2008-2011 The Aydniv Software Company.
 *
 * @author nuwan.bandara
 * @since November, 2010
 * @version 1.0
 */

html {
    overflow-y: auto;
    /* Kudos to @sami for pointing out that setting the overflow to "auto" instead of "hidden" fixes the keyboard nav bug! */
    background-color: transparent;
}

@media only screen and (max-device-width:480px) {
    html {
        overflow: auto;
    }
}

body.custom {

    background-position: center top;
    background-image: url(images/bg.jpg);
    background-repeat: no-repeat;
    position: absolute;
    top: 0;
        left: 0;
        bottom: 0;
        right: 10px;
    overflow-y: scroll;
    overflow-x: hidden;
}


::-webkit-scrollbar {
    width: 10px;
    height: 6px;
}

::-webkit-scrollbar-button:start:decrement,
::-webkit-scrollbar-button:end:increment {
    height: 30px;
    display: block;
    background-color: transparent;
}

::-webkit-scrollbar-track-piece {
    background-color: #3b3b3b;
    -webkit-border-radius: 6px;
}

::-webkit-scrollbar-thumb:vertical {
    height: 50px;
    background-color: #666;
    -webkit-border-radius: 6px;
}

::-webkit-scrollbar-thumb:horizontal {
    width: 50px;
    background-color: #666;
    -webkit-border-radius: 3px;
}

Labels:

Wednesday, January 18, 2012

DHTMLX Grid -> Vertical Align Cell Text

CSS
div.gridbox table.obj td {
    vertical-align: top;
}

OR JS

myGrid.setCellTextStyle(rowId, cellIndex, "vertical-align:top;padding-top:2px");

Labels: ,

Tuesday, January 17, 2012

Collections Sort with more than one key

Collections Sort with more than one key
        Collections.sort(jobs, new Comparator() {
            public int compare(Job o1, Job o2) {
                int result = o1.getJobNumPrefix().compareTo(o2.getJobNumPrefix());
                if (result == 0) {
                    result = o1.getJobNumSuffix().compareTo(o2.getJobNumSuffix());
                }
                if (result == 0) {
                    result = o1.getDocRev().compareTo(o2.getDocRev());
                }
                return result;
            }
        });

Labels:

Wednesday, January 11, 2012

JavaScript Array Contains

Extending JavaScript Arrays
 

/**
 * Array.prototype.[method name] allows you to define/overwrite an objects method
 * value is the item you are searching for
 * this is a special variable that refers to "this" instance of an Array.
 * returns true if value is in the array, and false otherwise
 */
Array.prototype.contains = function(value) {
    for (i in this) {
        if (this[i] === value) {
            return true;
        }
    }
    return false;
}

Usage
 

// Now you can do things like:
var x = Array();
if (x.contains('foo')) {
   // do something special
}

Labels: