mirror of
https://github.com/HabitRPG/habitica.git
synced 2025-12-17 14:47:53 +01:00
* Stable: basic layout (based on equipment) * extract item popover-content as component # Conflicts: # website/client/components/inventory/item.vue * extract item-content as slot - list standard pets with image * dynamic list petGroups in sidebar / content - with selected / open filter * itemContentClass for pets * fix filter - extract filter labels * Filter: Hide Missing * fix position of pets * sort by: A-Z, Color, Hatchable * refactor animalList - created the list once per type and cache it - sort now works before viewing one or all pets * custom petItem to show the progress * list specialPets - rename petGroup to animalGroup (more generic) * equip a pet * filter animals by input * count pets * list mounts * hatchable pet popover * hatchable pet popover #2 * PixelPaw Opacity for not owned and not hatchable pets - change item background for unowned pets * Hold to hatch the pet - cleanup * add food drawer + countBadge - special mounts - hide un-owned special animals - fixes * Sliding Drawer: Buttons to scroll left/right * Drag&Drop: food on pets * fix hold to hatch - use mouseleave event * 'Show All' / 'Show Less' - Animals * Matts Image + Popover + use image width as sidebar width (removed col-2 / col-10) * fixes: colors, v-once, drawer-errorMessage, strings * drawerSlider - split items to pages / add divider / add first item of the next page - ResizeDirective * ResizeDirective - throttle emits by `v-resize="value"` - fix drawer left padding * show animals by available content width * change sortBy button / label * fix pet colors / backgrounds * DragDropDirective - grabbing cursor * remove browser specific prefixes * fix lint issues * show welcome dialog * change translationkey (noFood, already exists)
64 lines
1.6 KiB
JavaScript
64 lines
1.6 KiB
JavaScript
import {emit} from './directive.common';
|
|
|
|
import _keys from 'lodash/keys';
|
|
import _without from 'lodash/without';
|
|
|
|
/**
|
|
* DRAG_GROUP is a static custom value
|
|
* KEY_OF_ITEM
|
|
*
|
|
* v-drag.DRAG_GROUP="KEY_OF_ITEM"
|
|
* v-drag.drop.DRAG_GROUP="KEY_OF_ITEM" @dropped="callback" @dragover="optional"
|
|
*/
|
|
|
|
const DROPPED_EVENT_NAME = 'dropped';
|
|
const DRAGOVER_EVENT_NAME = 'dragover';
|
|
|
|
export default {
|
|
bind (el, binding, vnode) {
|
|
el.isDropHandler = binding.modifiers.drop === true;
|
|
el.dragGroup = _without(_keys(binding.modifiers), 'drop')[0];
|
|
el.key = binding.value;
|
|
|
|
if (!el.isDropHandler) {
|
|
el.draggable = true;
|
|
el.handleDrag = (ev) => {
|
|
ev.dataTransfer.setData('KEY', binding.value);
|
|
};
|
|
el.addEventListener('dragstart', el.handleDrag);
|
|
} else {
|
|
el.handleDragOver = (ev) => {
|
|
let dragOverEventData = {
|
|
dropable: true,
|
|
draggingKey: ev.dataTransfer.getData('KEY'),
|
|
};
|
|
|
|
emit(vnode, DRAGOVER_EVENT_NAME, dragOverEventData);
|
|
|
|
if (dragOverEventData.dropable) {
|
|
ev.preventDefault();
|
|
}
|
|
};
|
|
el.handleDrop = (ev) => {
|
|
let dropEventData = {
|
|
draggingKey: ev.dataTransfer.getData('KEY'),
|
|
};
|
|
|
|
emit(vnode, DROPPED_EVENT_NAME, dropEventData);
|
|
};
|
|
|
|
el.addEventListener('dragover', el.handleDragOver);
|
|
el.addEventListener('drop', el.handleDrop);
|
|
}
|
|
},
|
|
|
|
unbind (el) {
|
|
if (!el.isDropHandler) {
|
|
el.removeEventListener('drag', el.handleDrag);
|
|
} else {
|
|
el.removeEventListener('dragover', el.handleDragOver);
|
|
el.removeEventListener('drop', el.handleDrop);
|
|
}
|
|
},
|
|
};
|