SSG default style&event emitter
SSG default style&event emitter
HTML
<div id="_main_banner">
<div class="banner_img">
<ul class="bn_blist">
<li>
<a href='/event/eventDetail.ssg?promId=1100200569' target='_self'><img src='http://static.ssgcdn.com/cmpt/banner/201702/2017020210323743351154330215_169.jpg' alt='쓱-배송 LIVE'></a>
</li>
<li>
<a href='/event/eventDetail.ssg?promId=1100199918' target='_self'><img src='http://static.ssgcdn.com/cmpt/banner/201702/2017020117025509614440967444_425.jpg'></a>
</li>
<li>
<a href='/event/eventDetail.ssg?promId=1100199654' target='_self'><img src='http://static.ssgcdn.com/cmpt/banner/201701/2017012518493756323975630497_600.jpg'></a>
</li>
<li>
<a href='/event/eventDetail.ssg?promId=1100196731' target='_self'><img src='http://static.ssgcdn.com/cmpt/banner/201701/2017012616074009675680961668_917.jpg'></a>
</li>
</ul>
</div>
<div class="bn_brem direction">
<a href="#" class="sp_rban prev">이전 배너 보기</a><a href="#" class="sp_rban next">다음 배너 보기</a>
</div>
</div>
JavaScript
var ssg = ssg || {};
ssg.View = ssg.View || {};
ssg.Event = ssg.Event || {};
ssg.Event.emitter = {
subscribers: {},
on: function (event, cb, context) {
console.log('cc')
this.subscribers[event] = this.subscribers[event] || [ ];
this.subscribers[event].push({
callback: cb,
context: context
});
},
off: function (event, cb, context) {
var idx, subs = this.subscribers[event], sub;
if (subs) {
idx = subs.length - 1;
while (idx >= 0) {
sub = subs[idx];
if (sub.callback === cb && (!context || sub.context === context)) {
subs.splice(idx, 1);
break;
}
idx--;
}
}
},
emit: function (event) {
var subs = this.subscribers[event], idx = 0, args = Array.prototype.slice.call(arguments, 1), sub;
if (subs) {
while (idx < subs.length) {
sub = subs[idx];
sub.callback.apply(sub.context || this, args);
idx++;
}
}
}
};
var emall = emall || {};
emall.View = emall.View || {};
emall.View.main = emall.View.main || {};
emall.View.main.slider = function() {
this.init();
};
/*emall.View.main.slider = function(htOptions){
$.extend(this, htOptions || {});
this.init();
};*/
//emall.View.main.slider.prototype = {
emall.View.main.slider.prototype = $.extend({
init: function() {
this._assignElements();
this._attachEventHandlers();
},
_assignElements: function() {
this._welMainBannerArea = $('#_main_banner');
this._welMainBannerList = this._welMainBannerArea.find('.banner_img ul');
this._welMainBannerItem = this._welMainBannerList.find('>li');
this._welMainNav = this._welMainBannerArea.find('.direction');
},
_attachEventHandlers: function() {
this._welMainNav.on('click', 'a.prev', $.proxy(this._onClickMovePrev,...