Skip to content

Instantly share code, notes, and snippets.

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

Anas Nakawa anasnakawa

💭
I may be slow to respond.
View GitHub Profile
@anasnakawa
anasnakawa / jquery.ajax.fake.md
Last active December 10, 2015 03:28
fake ajax readme file

jQuery.ajax.fake

when you want to fake an ajax call, that's because your server's web service is just not ready yet, and whenever that web service is ready, switching back to it should cost nothing..

with jquery.ajax.fake you simply write pure jQuery ajax call, with only one extra property fake: true

How to use it

include jquery.ajax.fake.js script into your markup, and create webservices.fake.js to handle fake ajax calls

<script src="jquery.ajax.fake.js"></script>
@anasnakawa
anasnakawa / javascript-comments.js
Created November 30, 2012 12:47
javascript file comments structure
/*!
* ------------------------------
* library name v#.#.#
* http://library-url.com
* license: MIT license (http://opensource.org/licenses/MIT)
* ------------------------------
*/
// ------------------------------
// table of content
@anasnakawa
anasnakawa / tiny-template.js
Last active October 13, 2015 07:18
parse a given template and repalce any variables wrapped withing brackets
// parse a given template and repalce any variables wrapped with brackets '{' & '}' with the
// corresponding object found in the passed context param
// * **param:** {string} template sting template to be parsed
// * **param:** {object} context object containing variables to inject into the template
//
// e.g: parse( 'hello my name is {name}, I am a {title}', {
// name: 'Anas Nakawa'
// title: function() {
// return 'software developer'
// }
// destroying the plugin and removing all handlers, and styles
$('#multiAccordion').multiAccordion('destroy');
// get an array of active tabs, if no active tabs it will return a one element array with [-1] value
$('#multiAccordion').multiAccordion('getActiveTabs');
// you can use the previous method to get active tabs value, then you can set it later simply by
// retrieve
var activeTabs = $('#multiAccordion').multiAccordion('getActiveTabs');
// set
/* fired when any tab is clicked, ui here hold clicked tab and its content
* ui['tab'] // current tab
* ui['content'] // current tab content (div)
*/
click: function(event, ui) {}
// when accordion is initialized, ui here holds a jQuery object to the whole accordion
init: function(event, ui) {}
// when tab is shown, ui here hold the same as in click event above
@anasnakawa
anasnakawa / jQuery-multi-open-accordion.js
Created November 17, 2012 05:18
plugin initialization options
$(function(){
// this will make the second tab by default opened (index starts from 0)
$('#multiAccordion').multiAccordion({active: 1 });
// [ OR ]
// supports multiple tabs to be opened by default
$('#multiAccordion').multiAccordion({active: [1, 2, 3] });
// show all tabs
$(function(){
$('#multiAccordion').multiAccordion();
});
@anasnakawa
anasnakawa / jQuery-multi-open-accordion.html
Created November 17, 2012 05:15
markup for an old plugin
<div id="multiAccordion">
<h3><a href="#">tab 1</a></h3>
<div>
Lorem ipsum dolor sit amet
</div>
<h3><a href="#">tab 2</a></h3>
<div>
Lorem ipsum dolor sit amet
</div>
<h3><a href="#">tab 3</a></h3>
@anasnakawa
anasnakawa / inline-image.scss
Created October 16, 2012 17:15
Base64 inline images function using compass/sass
.some-selector {
background: white #{inline_image("image.png")}
}