diff --git a/modules/index.js b/modules/index.js index 7b79ecf9f..e14719f0e 100644 --- a/modules/index.js +++ b/modules/index.js @@ -37,6 +37,7 @@ export { rendererFeatures as Features } from './renderer/features'; export { rendererMap as Map } from './renderer/map'; export { rendererTileLayer as TileLayer } from './renderer/tile_layer'; export { utilDetect as Detect } from './util/detect'; +export { uiPresetEditor as uiPreset } from './ui/preset_editor'; export var debug = false; diff --git a/modules/ui/entity_editor.js b/modules/ui/entity_editor.js index 4f2e0e2fc..91ff7e0cf 100644 --- a/modules/ui/entity_editor.js +++ b/modules/ui/entity_editor.js @@ -10,7 +10,7 @@ import { uiRawMemberEditor } from './raw_member_editor'; import { uiRawMembershipEditor } from './raw_membership_editor'; import { uiRawTagEditor } from './raw_tag_editor'; import { uiTagReference } from './tag_reference'; -import { uiPreset } from './preset'; +import { uiPresetEditor } from './preset_editor'; import { utilRebind } from '../util'; @@ -24,7 +24,7 @@ export function uiEntityEditor(context) { activePreset, reference; - var presetEditor = uiPreset(context) + var presetEditor = uiPresetEditor(context) .on('change', changeTags); var rawTagEditor = uiRawTagEditor(context) .on('change', changeTags); diff --git a/modules/ui/index.js b/modules/ui/index.js index 4ecf2b9cc..3abe1ebb2 100644 --- a/modules/ui/index.js +++ b/modules/ui/index.js @@ -27,7 +27,7 @@ export { uiMapInMap } from './map_in_map'; export { uiModal } from './modal'; export { uiModes } from './modes'; export { uiNotice } from './notice'; -export { uiPreset } from './preset'; +export { uiPresetEditor } from './preset_editor'; export { uiPresetIcon } from './preset_icon'; export { uiPresetList } from './preset_list'; export { uiRadialMenu } from './radial_menu'; diff --git a/modules/ui/preset.js b/modules/ui/preset_editor.js similarity index 79% rename from modules/ui/preset.js rename to modules/ui/preset_editor.js index 86a8c0d69..54545e50c 100644 --- a/modules/ui/preset.js +++ b/modules/ui/preset_editor.js @@ -14,7 +14,7 @@ import { } from '../util'; -export function uiPreset(context) { +export function uiPresetEditor(context) { var dispatch = d3.dispatch('change'), expandedPreference = (context.storage('preset_fields.expanded') !== 'false'), state, @@ -24,61 +24,7 @@ export function uiPreset(context) { id; - // // Field Constructor - // function UIField(field, entity, show) { - // field = _.clone(field); - - // field.input = uiFields[field.type](field, context) - // .on('change', function(t, onInput) { - // dispatch.call('change', field, t, onInput); - // }); - - // if (field.input.entity) field.input.entity(entity); - - // field.keys = field.keys || [field.key]; - - // field.show = show; - - // field.shown = function() { - // return field.show || _.some(field.keys, function(key) { return !!tags[key]; }); - // }; - - // field.modified = function() { - // var original = context.graph().base().entities[entity.id]; - // return _.some(field.keys, function(key) { - // return original ? tags[key] !== original.tags[key] : tags[key]; - // }); - // }; - - // field.revert = function() { - // var original = context.graph().base().entities[entity.id], - // t = {}; - // field.keys.forEach(function(key) { - // t[key] = original ? original.tags[key] : undefined; - // }); - // return t; - // }; - - // field.present = function() { - // return _.some(field.keys, function(key) { - // return tags[key]; - // }); - // }; - - // field.remove = function() { - // var t = {}; - // field.keys.forEach(function(key) { - // t[key] = undefined; - // }); - // return t; - // }; - - // return field; - // } - - - - function presets(selection) { + function presetEditor(selection) { selection.call(uiDisclosure() .title(t('inspector.all_fields')) .expanded(expandedPreference) @@ -305,38 +251,38 @@ export function uiPreset(context) { } - presets.preset = function(_) { + presetEditor.preset = function(_) { if (!arguments.length) return preset; - if (preset && preset.id === _.id) return presets; + if (preset && preset.id === _.id) return presetEditor; preset = _; fieldsArr = null; - return presets; + return presetEditor; }; - presets.state = function(_) { + presetEditor.state = function(_) { if (!arguments.length) return state; state = _; - return presets; + return presetEditor; }; - presets.tags = function(_) { + presetEditor.tags = function(_) { if (!arguments.length) return tags; tags = _; // Don't reset fieldsArr here. - return presets; + return presetEditor; }; - presets.entityID = function(_) { + presetEditor.entityID = function(_) { if (!arguments.length) return id; - if (id === _) return presets; + if (id === _) return presetEditor; id = _; fieldsArr = null; - return presets; + return presetEditor; }; - return utilRebind(presets, dispatch, 'on'); + return utilRebind(presetEditor, dispatch, 'on'); }