@@ -215,6 +215,37 @@ function RemoteFunctions(config) {
215215
216216 } ;
217217
218+ // TODO: need to implement
219+ function _handleSelectParentOptionClick ( e ) {
220+ console . log ( "handle select parent option button was clicked" ) ;
221+ }
222+
223+ // TODO: need to implement
224+ function _handleDuplicateOptionClick ( e ) {
225+ console . log ( "handle duplicate option button was clicked" ) ;
226+ }
227+
228+ // TODO: need to implement
229+ function _handleDeleteOptionClick ( e ) {
230+ console . log ( "handle delete option button was clicked" ) ;
231+ }
232+
233+
234+ /**
235+ * This function will get triggered when from the multiple advance DOM buttons, one is clicked
236+ * this function just checks which exact button was clicked and call the required function
237+ * @param {Event } e
238+ * @param {String } action - the data-action attribute to differentiate between buttons
239+ */
240+ function handleOptionClick ( e , action ) {
241+ if ( action === "select-parent" ) {
242+ _handleSelectParentOptionClick ( e ) ;
243+ } else if ( action === "duplicate" ) {
244+ _handleDuplicateOptionClick ( e ) ;
245+ } else if ( action === "delete" ) {
246+ _handleDeleteOptionClick ( e ) ;
247+ }
248+ }
218249 /**
219250 * This is for the advanced DOM options that appears when a DOM element is clicked
220251 * advanced options like: 'select parent', 'duplicate', 'delete'
@@ -266,7 +297,6 @@ function RemoteFunctions(config) {
266297 this . body . style . setProperty ( "box-shadow" , "0 2px 5px rgba(0,0,0,0.2)" ) ;
267298 this . body . style . setProperty ( "max-width" , "82px" ) ;
268299 this . body . style . setProperty ( "width" , "82px" ) ;
269- this . body . style . setProperty ( "pointer-events" , "none" ) ;
270300
271301 const ICONS = {
272302 arrowUp : `<svg viewBox="0 0 24 24" fill="currentColor">
@@ -294,9 +324,20 @@ function RemoteFunctions(config) {
294324 </span>
295325 </div>` ;
296326
297-
298327 this . body . innerHTML = content ;
299328 window . document . body . appendChild ( this . body ) ;
329+
330+ // add the click handler to all the buttons
331+ const spans = this . body . querySelectorAll ( '.node-options span' ) ;
332+ spans . forEach ( span => {
333+ // to differentiate between each button click we can use the data-action attribute
334+ span . addEventListener ( 'click' , ( event ) => {
335+ event . stopPropagation ( ) ;
336+ event . preventDefault ( ) ;
337+ const action = event . currentTarget . getAttribute ( 'data-action' ) ;
338+ handleOptionClick ( event , action ) ;
339+ } ) ;
340+ } ) ;
300341 } ,
301342
302343 remove : function ( ) {
@@ -766,9 +807,15 @@ function RemoteFunctions(config) {
766807 if ( _hoverHighlight ) {
767808 _hoverHighlight . clear ( ) ;
768809
769- // Skip highlighting for HTML and BODY tags
770- if ( event . target && event . target . nodeType === Node . ELEMENT_NODE &&
771- event . target . tagName !== "HTML" && event . target . tagName !== "BODY" ) {
810+ // Skip highlighting for HTML and BODY tags and for DOM elements which doesn't have 'data-brackets-id'
811+ // NOTE: Don't remove 'data-brackets-id' check else hover will also target internal live preview elements
812+ if (
813+ event . target &&
814+ event . target . nodeType === Node . ELEMENT_NODE &&
815+ event . target . tagName !== "HTML" &&
816+ event . target . tagName !== "BODY" &&
817+ event . target . hasAttribute ( "data-brackets-id" )
818+ ) {
772819 // Store original background color to restore on hover out
773820 event . target . _originalBackgroundColor = event . target . style . backgroundColor ;
774821 event . target . style . backgroundColor = "rgba(0, 162, 255, 0.2)" ;
@@ -814,7 +861,7 @@ function RemoteFunctions(config) {
814861 function onClick ( event ) {
815862 // make sure that the feature is enabled and also the clicked element has the attribute 'data-brackets-id'
816863 if ( isFlagActive && event . target . hasAttribute ( 'data-brackets-id' ) ) {
817- console . log ( "event:" , event ) ;
864+ // console.log("event:", event);
818865 if ( _nodeMoreOptionsBox ) {
819866 _nodeMoreOptionsBox . remove ( ) ;
820867 _nodeMoreOptionsBox = null ;
0 commit comments