mirror of
				https://github.com/zulip/zulip.git
				synced 2025-11-04 14:03:30 +00:00 
			
		
		
		
	hotspots.js: Inline map_hotspots_to_DOM.
The function is confusing and added unnecessary complexity, given that it is only called in one place, and is not a function that should be exposed to other modules.
This commit is contained in:
		@@ -1,38 +0,0 @@
 | 
			
		||||
const hotspots = require('js/hotspots');
 | 
			
		||||
 | 
			
		||||
const test_hotspots = [
 | 
			
		||||
    {
 | 
			
		||||
        delay: 5,
 | 
			
		||||
        description: 'Click anywhere on a message to reply.',
 | 
			
		||||
        name: 'click_to_reply',
 | 
			
		||||
        title: 'Respond to a message',
 | 
			
		||||
    },
 | 
			
		||||
];
 | 
			
		||||
 | 
			
		||||
const TEST_HOTSPOT_LOCATIONS = {
 | 
			
		||||
    click_to_reply: {
 | 
			
		||||
        element: '.selected_message .messagebox-content',
 | 
			
		||||
        icon: {
 | 
			
		||||
            top: -71,
 | 
			
		||||
            left: 284,
 | 
			
		||||
        },
 | 
			
		||||
        popover: {
 | 
			
		||||
            top: -213,
 | 
			
		||||
            left: -176,
 | 
			
		||||
            arrow: {
 | 
			
		||||
                placement: 'bottom',
 | 
			
		||||
                top: -5,
 | 
			
		||||
                left: -5,
 | 
			
		||||
            },
 | 
			
		||||
        },
 | 
			
		||||
    },
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
(function test_map_hotspot_to_DOM() {
 | 
			
		||||
    const test_hotspot = test_hotspots[0];
 | 
			
		||||
    assert.equal(test_hotspot.location, undefined);
 | 
			
		||||
 | 
			
		||||
    hotspots.map_hotspots_to_DOM(test_hotspots, TEST_HOTSPOT_LOCATIONS);
 | 
			
		||||
 | 
			
		||||
    assert.deepEqual(test_hotspot.location, TEST_HOTSPOT_LOCATIONS[test_hotspot.name]);
 | 
			
		||||
}());
 | 
			
		||||
@@ -32,13 +32,6 @@ var HOTSPOT_LOCATIONS = {
 | 
			
		||||
// popover illustration url(s)
 | 
			
		||||
var WHALE = '/static/images/hotspots/whale.svg';
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
exports.map_hotspots_to_DOM = function (hotspots, locations) {
 | 
			
		||||
    hotspots.forEach(function (hotspot) {
 | 
			
		||||
        hotspot.location = locations[hotspot.name];
 | 
			
		||||
    });
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
exports.post_hotspot_as_read = function (hotspot_name) {
 | 
			
		||||
    channel.post({
 | 
			
		||||
        url: '/json/users/me/hotspots',
 | 
			
		||||
@@ -208,7 +201,9 @@ exports.is_open = function () {
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
exports.load_new = function (new_hotspots) {
 | 
			
		||||
    exports.map_hotspots_to_DOM(new_hotspots, HOTSPOT_LOCATIONS);
 | 
			
		||||
    new_hotspots.forEach(function (hotspot) {
 | 
			
		||||
        hotspot.location = HOTSPOT_LOCATIONS[hotspot.name];
 | 
			
		||||
    });
 | 
			
		||||
    new_hotspots.forEach(insert_hotspot_into_DOM);
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user