"use strict";
var _prototypeProperties = function (child, staticProps, instanceProps) { if (staticProps) Object.defineProperties(child, staticProps); if (instanceProps) Object.defineProperties(child.prototype, instanceProps); };
var _inherits = function (subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) subClass.__proto__ = superClass; };
var _classCallCheck = function (instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } };
/* global S */
var DropdownComponent = (function (_S$Component) {
function DropdownComponent() {
_classCallCheck(this, DropdownComponent);
if (_S$Component != null) {
_S$Component.apply(this, arguments);
}
}
_inherits(DropdownComponent, _S$Component);
_prototypeProperties(DropdownComponent, null, {
init: {
value: function init() {
this.elements.push("link", "menu");
},
writable: true,
configurable: true
},
firstRender: {
/**
* Invoked on both server and browser (except the first time for the browser)
*/
value: function firstRender(data) {
this.$container.addClass("dropdown");
this.$link = $.create("a").appendTo(this.$container).addClass("dropdown-toggle").setAttribute("href", "#").setAttribute("onclick", "return false");
this.$menu = $.create("ul").addClass("dropdown-menu clickable linksList spaced").appendTo(this.$container);
},
writable: true,
configurable: true
},
render: {
value: function render(data) {
this.$link.text(data.title);
},
writable: true,
configurable: true
},
append: {
value: function append(item) {
$.create("li").append(item).appendTo(this.$menu);
},
writable: true,
configurable: true
},
appendText: {
value: function appendText(item) {
$.create("li").appendText(item).appendTo(this.$menu);
},
writable: true,
configurable: true
},
prepare: {
value: function prepare() {
var _this = this;
console.log("prepare DropdownComponent");
this.$link.on("click", function (e) {
e.preventDefault();
e.stopPropagation();
_this.$menu.stop();
_this.$container.toggleClass("open");
return false;
});
},
writable: true,
configurable: true
}
});
return DropdownComponent;
})(S.Component);
module.exports = DropdownComponent;
//# sourceMappingURL=../components/DropdownComponent.js.map