Skip to content

Instantly share code, notes, and snippets.

@clyfe
Last active August 29, 2015 14:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save clyfe/ff9d9608ae2a35af18d2 to your computer and use it in GitHub Desktop.
Save clyfe/ff9d9608ae2a35af18d2 to your computer and use it in GitHub Desktop.
Prevent submenu collapse in polymer's core-submenu
<link rel="import" href="../../bower_components/polymer/polymer.html">
<link rel="import" href="../../bower_components/core-menu/core-submenu.html">
<!--
Similar to core-submenu, can be set to stay always open.
When selected, also selects it's first child.
<ik-submenu icon="settings" label="Topics" alwaysOpened>
<core-item label="Topic1"></core-item>
<core-item label="Topic2"></core-item>
</ik-submenu>
@element ik-submenu
@extends core-submenu
-->
<polymer-element name="ik-submenu" extends="core-submenu" attributes="alwaysOpened">
<template>
<shadow></shadow>
</template>
<script>
(function () {
'use strict';
Polymer({
/**
* If true, the submenu will stay allways open; otherwise can collapse.
*
* @attribute alwaysOpened
* @type boolean
* @default false
*/
alwaysOpened: false,
get opened() {
return this.alwaysOpened || this._opened;
},
set opened(v) {
this._opened = v;
},
activate: function () {
this.items[0].children[0].click();
}
});
})();
</script>
</polymer-element>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment