Skip to content

Instantly share code, notes, and snippets.

View louy's full-sized avatar
💭
I may be slow to respond.

Louay Akkad louy

💭
I may be slow to respond.
View GitHub Profile
/**
* Fix element positioning when using adminbar
*/
@mixin fixed-top( $space, $property: "top", $factor: 1 ) {
#{$property}: $space * $factor;
.admin-bar & {
#{$property}: ($space + 46px) * $factor;
@media (min-width: 783px) {
#{$property}: ($space + 32px) * $factor;
}
@louy
louy / ko.subscribable.subscribechanged.js
Created July 10, 2014 02:45
Subscribe with Old and New Value for Knockout Subscribable
ko.subscribable.fn.subscribeChanged = function( callback ) {
var oldValue;
return [
this.subscribe( function( _oldValue ) {
oldValue = _oldValue;
}, this, 'beforeChange' ),
this.subscribe( function( newValue ) {
callback( newValue, oldValue );
} )
];
@louy
louy / ko.bindinghandlers.chosen.js
Created July 10, 2014 02:42
Knockout Chosen Binding Handler with Cleanup (jQuery)
ko.bindingHandlers.chosen = {
listenBindings: ['value', 'disable', 'options', 'foreach'],
init: function( element, valueAccessor, allBindings ) {
var options = ko.unwrap(valueAccessor()), $_ = $(element);
$_.chosen( $.extend( options, {
width: '100%',
} ) );
ko.computed(function() {
$.each(ko.bindingHandlers.chosen.listenBindings, function( i, binding ) {