(function (ns) { ns.Sitemap = function () { this.construct.apply(this, arguments); }; var proto = ns.Sitemap.prototype; proto.construct = function () { this.links = $('a[data-action=new]'); if (!this.links.length) { return; } this.links.popover({ html: true, placement: 'bottom', trigger: 'manual', title: this.renderTitle, content: this.renderContent }); this.links.on('click', $.proxy(this.onNewClick, this)); $('body').on('click', $.proxy(this.onBodyClick, this)); }; proto.onNewClick = function (ev) { this.links.popover('hide'); $(ev.target).popover('show'); return false; }; proto.renderTitle = function () { var $a = $(this); var type = ($a.data('parent-id')) ? 'Subpage' : 'Page'; return 'Add ' + type; }; proto.renderContent = function () { var $a = $(this); var content = ''; content += '
  • Text Layout
  • '; content += '
  • Grid Layout
  • '; content = ''; return content; }; proto.onBodyClick = function (ev) { if (!$(ev.target).closest('.popover').length) { this.links.popover('hide'); } }; })(qs.defineNS('lib.cms'));