mirror of
https://github.com/haiwen/seahub.git
synced 2025-07-16 00:06:11 +00:00
* add a commen contextmenu component * optimized translate for menu * repair contextmenu bug * optimized share btn show code * repair showShareBtn bug * optimized contextmenu * optimized contextmenu code * complete dirent-item-menu logic * optimized contextmenu code * complete dirent-container-menu logic * complete tree-node-contextmenu logic * delete unnecessary code * optimized contextmenu func * repair bug * optimized code style * optimized code style * add a dirent-none-view for dir-list-view mode * optimized dirent-container-menu&dirent-item-menu * add select-item contextmenu * repair rebase bug
34 lines
974 B
JavaScript
34 lines
974 B
JavaScript
import assign from 'object-assign';
|
|
|
|
import { store } from './helpers';
|
|
|
|
export const MENU_SHOW = 'REACT_CONTEXTMENU_SHOW';
|
|
export const MENU_HIDE = 'REACT_CONTEXTMENU_HIDE';
|
|
|
|
|
|
export function dispatchGlobalEvent(eventName, opts, target = window) {
|
|
// Compatibale with IE
|
|
// @see http://stackoverflow.com/questions/26596123/internet-explorer-9-10-11-event-constructor-doesnt-work
|
|
let event;
|
|
|
|
if (typeof window.CustomEvent === 'function') {
|
|
event = new window.CustomEvent(eventName, { detail: opts });
|
|
} else {
|
|
event = document.createEvent('CustomEvent');
|
|
event.initCustomEvent(eventName, false, true, opts);
|
|
}
|
|
|
|
if (target) {
|
|
target.dispatchEvent(event);
|
|
assign(store, opts);
|
|
}
|
|
}
|
|
|
|
export function showMenu(opts = {}, target) {
|
|
dispatchGlobalEvent(MENU_SHOW, assign({}, opts, { type: MENU_SHOW }), target);
|
|
}
|
|
|
|
export function hideMenu(opts = {}, target) {
|
|
dispatchGlobalEvent(MENU_HIDE, assign({}, opts, { type: MENU_HIDE }), target);
|
|
}
|