asked on
(function( $ ){
var methods = {
init : function( options ) {
var settings = $.extend( {
'location' : 'top',
'background-color' : 'blue'
}, options);
alert ( settings.location );
},
show : function( ) {
// IS
},
hide : function( ) {
// GOOD
},
update : function( content ) {
// !!!
},
display : function ( test1, test2 ) {
var test1 = test1;
alert ( "test1: " + test1 + "\ntest2: " + test2 );
self.display2( test2 );
},
display2 : function ( test3 ) {
alert ( "test3: " + test3 );
}
};
$.fn.tooltip = function( method ) {
// Method calling logic
if ( methods[method] ) {
return methods[ method ].apply( this, Array.prototype.slice.call( arguments, 1 ));
} else if ( typeof method === 'object' || ! method ) {
return methods.init.apply( this, arguments );
} else {
$.error( 'Method ' + method + ' does not exist on jQuery.tooltip' );
}
};
})( jQuery );
$(document).ready(function() {
// calls the init method
$('div').tooltip();
// calls the init method
$('div').tooltip({
'location' : 'left'
});
$().tooltip('display', 'John', '316');
});