   class EffectiveMenuEditor
     defaults:
       menuClass: 'effective-menu'
+      expandThreshold: 1000
 
     menu: null
     draggable: null
+    droppable: null
 
     constructor: (el, options) ->
       @options = $.extend({}, @defaults, options)
       @menu = $(el)
 
-      @initDragDropEvents()
       @initCkEditorEvents()
       @initAdditionalEvents()
+      @initDragDropEvents()
       true
 
+    initCkEditorEvents: ->
+      @menu.on 'click', 'li.dropdown.open', (event) ->
+        event.stopPropagation()
+        CKEDITOR.instances[Object.keys(CKEDITOR.instances)[0]].openDialog 'effectiveMenusDialog', (dialog) ->
+          dialog.effective_menu_item = $(event.currentTarget)
+
+      @menu.on 'click', '.dropdown-menu > li.dropdown', (event) ->
+        event.stopPropagation()
+        CKEDITOR.instances[Object.keys(CKEDITOR.instances)[0]].openDialog 'effectiveMenusDialog', (dialog) ->
+          dialog.effective_menu_item = $(event.currentTarget)
+
+      @menu.on 'click', 'li:not(.dropdown)', (event) ->
+        event.stopPropagation()
+        CKEDITOR.instances[Object.keys(CKEDITOR.instances)[0]].openDialog 'effectiveMenusDialog', (dialog) ->
+          dialog.effective_menu_item = $(event.currentTarget)
+
+    initAdditionalEvents: ->
+      @menu.on 'click', 'a', (event) -> event.preventDefault()
+
     initDragDropEvents: ->
-      @menu.on 'dragenter', 'li', (event) => event.preventDefault() if @draggable  # enable drag and drop
-      @menu.on 'dragleave', 'li', (event) => event.preventDefault() if @draggable # enable drag and drop
+      @menu.on 'dragenter', 'li', (event) =>
+        @droppable = null
+        @droppable = {item: $(event.currentTarget), time: new Date().getTime()}
+        event.preventDefault() if @draggable  # enable drag and drop
+
+      @menu.on 'dragleave', 'li', (event) =>
+        event.preventDefault() if @draggable # enable drag and drop
 
       @menu.on 'dragstart', 'li', (event) =>
         @draggable = node = $(event.currentTarget)

      parent.children('.menu-item').children("input[name$='[rgt]']").val(rgt)

      rgt + 1

  $.fn.extend effectiveMenuEditor: (option, args...) ->
    @each ->


        node = $(event.currentTarget)
        node.css('opacity', '1.0')
        @menu.removeClass('dragging')

        @menu.find('.placeholder').removeClass('placeholder')
        @menu.find('.effective-menu-expand').remove()
        @menu.find('.open').removeClass('open')

        @draggable = null
        @droppable = null

      @menu.on 'drop', 'li', (event) =>
        return false unless @draggable
