dist/meditor.js
function (e) {

        // if you click something from the toolbar
        // don't do anything
        if(e && e.target && $toolbar.find(e.target).length) {
          return false;
        }

        var newSelection = window.getSelection();

        // get selection node
        var anchorNode = newSelection.anchorNode;

        // if nothing selected, hide the toolbar
        if(newSelection.toString().trim() === '' || !anchorNode) {
          // hide the toolbar
          return $timeout(function() {
            scope.model.showToolbar = false;
          });
        }

        // check if selection is in the current editor/directive container
        var parentNode = anchorNode.parentNode;
        while (parentNode.tagName !== undefined && parentNode !== element[0]) {
          parentNode = parentNode.parentNode;
        }

        // if the selection is in the current editor
        if(parentNode === element[0]) {
          // show the toolbar
          $timeout(function() {
            scope.model.showToolbar = true;
            setToolbarPosition();
          });

          // check selection styles and active buttons based on it
          checkActiveButtons(newSelection);
        } else {
          // hide the toolbar
          $timeout(function() {
            scope.model.showToolbar = false;
          });
        }

        return this;
      }
function (e) {

        // if you click something from the toolbar
        // don't do anything
        if(e && e.target && $toolbar.find(e.target).length) {
          return false;
        }

        var newSelection = window.getSelection();

        // get selection node
        var anchorNode = newSelection.anchorNode;

        // if nothing selected, hide the toolbar
        if(newSelection.toString().trim() === '' || !anchorNode) {
          // hide the toolbar
          return $timeout(function() {
            scope.model.showToolbar = false;
          });
        }

        // check if selection is in the current editor/directive container
        var parentNode = anchorNode.parentNode;
        while (parentNode.tagName !== undefined && parentNode !== element[0]) {
          parentNode = parentNode.parentNode;
        }

        // if the selection is in the current editor
        if(parentNode === element[0]) {
          // show the toolbar
          $timeout(function() {
            scope.model.showToolbar = true;
            setToolbarPosition();
          });

          // check selection styles and active buttons based on it
          checkActiveButtons(newSelection);
        } else {
          // hide the toolbar
          $timeout(function() {
            scope.model.showToolbar = false;
          });
        }

        return this;
      }
function ( e ) { // if you click something from the toolbar // don't do anything if ( e && e . target && $toolbar . find ( e . target ) . length ) { return false ; } var newSelection = window . getSelection ( ) ; // get selection node var anchorNode = newSelection . anchorNode ; // if nothing selected, hide the toolbar if ( newSelection . toString ( ) . trim ( ) === '' || ! anchorNode ) { // hide the toolbar return $timeout ( function ( ) { scope . model . showToolbar = false ; } ) ; } // check if selection is in the current editor/directive container var parentNode = anchorNode . parentNode ; while ( parentNode . tagName !== undefined && parentNode !== element [ 0 ] ) { parentNode = parentNode . parentNode ; } // if the selection is in the current editor if ( parentNode === element [ 0 ] ) { // show the toolbar $timeout ( function ( ) { scope . model . showToolbar = true ; setToolbarPosition ( ) ; } ) ; // check selection styles and active buttons based on it checkActiveButtons ( newSelection ) ; } else { // hide the toolbar $timeout ( function ( ) { scope . model . showToolbar = false ; } ) ; } return this ; }
get current selection and act on toolbar depending on it
get current selection and act on toolbar depending on it