(function() { define(['restful', 'utils'], function(_restful, _utils) { var HeartBeat, Search; HeartBeat = (function() { function HeartBeat() { var self; self = this; this.initElements(); this.requestSession(function(result) { window.MEMBER = result; return self.changeMemberNav(); }); window.setInterval((function() { return self.requestSession(); }), 6000 * 5); } HeartBeat.prototype.initElements = function() { var $o; $o = $('#member_nav'); this.elements = { memberNav: $o }; return $o.find('.signout').bind('click', function(e) { e.preventDefault(); return _restful["delete"]('session', function() { return location.reload(); }); }); }; HeartBeat.prototype.changeMemberNav = function() { var $authority, $member, $o, isLogin; $o = this.elements.memberNav; $member = $o.find('.member'); $authority = $o.find('.authority'); isLogin = typeof MEMBER !== "undefined" && MEMBER !== null ? MEMBER.isLogin : void 0; $member.toggle(isLogin); return $authority.toggle(!isLogin); }; HeartBeat.prototype.requestSession = function(cb) { return _restful.get('session', function(result) { return typeof cb === "function" ? cb(result) : void 0; }); }; return HeartBeat; })(); Search = (function() { function Search() { var keyword, keyword1, keyword2; this.keywords = []; if (keyword = _utils.getUrlParam('keyword')) { this.keywords.push(keyword); } if (keyword1 = _utils.getUrlParam('keyword1')) { this.keywords.push(keyword1); } if (keyword2 = _utils.getUrlParam('keyword2')) { this.keywords.push(keyword2); } this.initElements(); } Search.prototype.initElements = function() { var $els, self; $els = this.elements = { headerSearch: $('#headerSearch'), headerInput: $('#headerSearchInput'), mainSearch: $('#mainSearch'), mainInput: $('#mainSearchInput'), mainButton: $('#btnMainSearchResult') }; self = this; $els.mainButton.toggle(this.keywords.length); $els.mainButton.bind('click', function() { return self.mainSearchSubmit(true); }); this.elements.mainSearch.bind('submit', function(event) { event.preventDefault(); return self.mainSearchSubmit(); }); return this.elements.headerSearch.bind('submit', function() { return self.headerSearchSubmit(); }); }; Search.prototype.getParams = function(keyword, inResult) { var index, params, value, _i, _len, _ref; params = { type: _utils.getUrlParam('type') }; if (!inResult) { params.keyword = keyword; return params; } this.keywords.push(keyword); _ref = this.keywords; for (index = _i = 0, _len = _ref.length; _i < _len; index = ++_i) { value = _ref[index]; params["keyword" + (index || '')] = value; } return params; }; Search.prototype.mainSearchSubmit = function(inResult) { var params; params = this.getParams(this.elements.mainInput.val(), inResult); return location.href = "/search.html?" + ($.param(params)); }; return Search; })(); return { HeartBeat: HeartBeat, Search: Search }; }); }).call(this);