1234567891011121314151617181920212223242526272829303132333435363738394041424344 |
- /**
- * @fileOverview
- *
- * 绑定到某个命令的下拉选框
- *
- */
- KityMinder.registerUI('widget/commandinputmenu', function(minder) {
- function generate(command, menuList) {
- var $menu = new FUI.InputMenu({
- menu: {
- items: menuList
- },
- input: {
- placeholder: minder.getLang('ui.' + command),
- },
- className: ['command-widget', 'command-inputmenu', command]
- });
- $menu.bindCommandState(minder, command, function(value) {
- if (!$menu.selectByValue(value)) {
- $menu.clearSelect();
- }
- });
- var lastIndex = -1;
- $menu.bindExecution('select', function(e, info) {
- if (~info.index) {
- minder.execCommand(command, info.value);
- } else {
- $menu.select(lastIndex);
- }
- lastIndex = info.index;
- });
- return $menu;
- }
- return {
- generate: generate
- };
- });
|