티스토리 뷰
/**
* 트위터 bootstrap js 패턴
*/
;(function($){
var Calculator = function( el, options ) {
this.$el = $(el);
this.options = $.extend({} , $.fn.calculator.defaults, options);
}
Calculator.prototype = {
constructor : Calculator
, show : function(){
console.log( this.options );
}
}
$.fn.calculator = function ( option ) {
return this.each(function(){
var $this = $(this)
, data = $this.data('calculator')
, options = typeof option == 'object' && option // objects 일경우만
if ( !data ) {
$this.data('calculator',( data = new Calculator( this, options ) ) );
}
if ( typeof option == 'string' ) {
data[option](); // 바로 해당 메서드를 실행
}
});
}
$.fn.calculator.Constructor = Calculator;
$.fn.calculator.defaults = {
'monitor' : '.calc-screen',
'buttons' : '.calc-button' ,
'sign_monitor' : '.sign-monitor'
}
})( window.jQuery );
'웹개발 > Javascript' 카테고리의 다른 글
| 자바스크립트 키코드. (0) | 2012.03.09 |
|---|---|
| javascript constructor 속성 (0) | 2012.03.09 |
| Twitter jQuery (0) | 2012.03.05 |
| 천단위 콤마 찍기 (0) | 2012.02.14 |
| Javascript Match $1 표현하기 (0) | 2012.02.10 |
댓글