Documentation

Clicked links handling

The method BX.SidePanel.Instance.bindAnchors defines the handling rules for links on a page. When a link is clicked, slider compares an address in the 'href' attribute with the registered templates. If they match, corresponding page is opened in the slider's iframe.

BX.SidePanel.Instance.bindAnchors({
   rules:
   [
		{
			condition: [
				"/company/personal/user/(\\d+)/tasks/task/view/(\\d+)/",
				"/workgroups/group/(\\d+)/tasks/task/view/(\\d+)/",
				"/extranet/contacts/personal/user/(\\d+)/tasks/task/view/(\\d+)/"
			],
			loader: "tasks:view-loader",

			//Ignore links that contain the following parameters in Query String
			stopParameters: [
				"PAGEN_(\\d+)",
				"MID"
			]
		},
		{
			condition: [
				"/company/personal/user/(\\d+)/tasks/task/edit/0/",
				"/workgroups/group/(\\d+)/tasks/task/edit/0/",
				"/extranet/contacts/personal/user/(\\d+)/tasks/task/edit/0/"
			],
			loader: "tasks:new-loader"
		},
		{
			condition: [ 
				new RegExp("/crm/lead/details/[0-9]+/", "i") 
			],
        	loader: "crm:entity-details-loader"
        },
		{
			condition: [
				"/company/personal/user/(\\d+)/groups/create/"
			],
			loader: "intranet:group-create-loader",
			
			//Options, that the opened slider will have 
			options: {
				width: 1200
			}
		},
		{
			condition: [
				/\/online\/\?(IM_DIALOG|IM_HISTORY)=([a-zA-Z0-9_|]+)/i
			],

			//Own handler for link click.
			//Messenger will open instead of slider
			handler: function(event, link)
			{
				if (!window.BXIM)
				{
					return;
				}
	
				var type = link.matches[1];
				var id = link.matches[2];
	
				if (type === "IM_HISTORY")
				{
					BXIM.openHistory(id);
				}
				else
				{
					BXIM.openMessenger(id);
				}
	
				event.preventDefault();
			}
		}
   ]
});

BX.SidePanel.Instance.bindAnchors can be called several times. New rules will be added to the existing ones.

If links are required to be handled on all site pages, the call of BX.SidePanel.Instance.bindAnchors must be moved to the site template.

Links inside the iframe are analyzed by the same rules, as on the parent page.

Links with the data-slider-ignore-autobinding data attribute are not handled.

For safety reasons, links to another domain are not opened in slider. However, this behaviour can be cancelled by the allowCrossDomain=true option.

Links handling in mobile browsers is not performed, it can be cancelled by the mobileFriendly=true option.

Options for the opened slider can be specified in the options parameter.

Slider opens when the link template and the address match in the 'href' attribute. This behaviour can be re-defined by default, by specifying your own handler function.



© «Bitrix24», 2001-2024
Up