Skip to content

Instantly share code, notes, and snippets.

@rlfrahm
Last active August 29, 2015 14:10
Show Gist options
  • Select an option

  • Save rlfrahm/1b680fbed305263e4ce1 to your computer and use it in GitHub Desktop.

Select an option

Save rlfrahm/1b680fbed305263e4ce1 to your computer and use it in GitHub Desktop.

Revisions

  1. rlfrahm revised this gist May 26, 2015. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion README.md
    Original file line number Diff line number Diff line change
    @@ -1,3 +1,3 @@
    An example of a custom context menu.
    ## AngularJS : An example of a custom context menu.

    Right click in the window to view.
  2. rlfrahm revised this gist Dec 4, 2014. 1 changed file with 3 additions and 1 deletion.
    4 changes: 3 additions & 1 deletion README.md
    Original file line number Diff line number Diff line change
    @@ -1 +1,3 @@
    An example of a custom context menu.
    An example of a custom context menu.

    Right click in the window to view.
  3. rlfrahm revised this gist Dec 3, 2014. 1 changed file with 3 additions and 0 deletions.
    3 changes: 3 additions & 0 deletions app.js
    Original file line number Diff line number Diff line change
    @@ -11,5 +11,8 @@ angular.module('app',[])
    display: 'block'
    };
    $scope.contextmenu.show = true;
    if(!$scope.$$phase) {
    $scope.$apply();
    }
    });
    }]);
  4. rlfrahm revised this gist Dec 3, 2014. 1 changed file with 5 additions and 0 deletions.
    5 changes: 5 additions & 0 deletions app.js
    Original file line number Diff line number Diff line change
    @@ -5,6 +5,11 @@ angular.module('app',[])
    $document.on('contextmenu', function(e) {
    e.preventDefault();
    console.log(e);
    $scope.contextmenu.style = {
    left: e.clientX + 'px',
    top: e.clientY + 'px',
    display: 'block'
    };
    $scope.contextmenu.show = true;
    });
    }]);
  5. rlfrahm revised this gist Dec 3, 2014. 1 changed file with 1 addition and 0 deletions.
    1 change: 1 addition & 0 deletions README.md
    Original file line number Diff line number Diff line change
    @@ -0,0 +1 @@
    An example of a custom context menu.
  6. rlfrahm revised this gist Dec 3, 2014. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion app.js
    Original file line number Diff line number Diff line change
    @@ -5,6 +5,6 @@ angular.module('app',[])
    $document.on('contextmenu', function(e) {
    e.preventDefault();
    console.log(e);
    contextmenu.show = true;
    $scope.contextmenu.show = true;
    });
    }]);
  7. rlfrahm revised this gist Dec 3, 2014. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion app.js
    Original file line number Diff line number Diff line change
    @@ -2,7 +2,7 @@ angular.module('app',[])

    .controller('ContextMenuCtrl',['$scope', '$document', function($scope,$document) {
    $scope.contextmenu = {show:false};
    $document.on('click', function(e) {
    $document.on('contextmenu', function(e) {
    e.preventDefault();
    console.log(e);
    contextmenu.show = true;
  8. rlfrahm revised this gist Dec 3, 2014. 1 changed file with 1 addition and 0 deletions.
    1 change: 1 addition & 0 deletions app.js
    Original file line number Diff line number Diff line change
    @@ -3,6 +3,7 @@ angular.module('app',[])
    .controller('ContextMenuCtrl',['$scope', '$document', function($scope,$document) {
    $scope.contextmenu = {show:false};
    $document.on('click', function(e) {
    e.preventDefault();
    console.log(e);
    contextmenu.show = true;
    });
  9. rlfrahm renamed this gist Dec 3, 2014. 1 changed file with 0 additions and 0 deletions.
    File renamed without changes.
  10. rlfrahm created this gist Dec 3, 2014.
    9 changes: 9 additions & 0 deletions app.css
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,9 @@
    angular.module('app',[])

    .controller('ContextMenuCtrl',['$scope', '$document', function($scope,$document) {
    $scope.contextmenu = {show:false};
    $document.on('click', function(e) {
    console.log(e);
    contextmenu.show = true;
    });
    }]);
    23 changes: 23 additions & 0 deletions index.html
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,23 @@
    <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.1/css/bootstrap.min.css">
    <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.0/angular.min.js"></script>
    <script src="app.js"></script>
    <body ng-app="app" ng-controller="ContextMenuCtrl">
    <ul class="dropdown-menu" role="menu" ng-style="contextmenu.style" ng-if="contextmenu.show">
    <li><a href="" ng-click="contextmenu.show=false">Action</a></li>
    <li><a href="" ng-click="contextmenu.show=false">Another action</a></li>
    <li><a href="" ng-click="contextmenu.show=false">Something else here</a></li>
    <li class="divider"></li>
    <li><a href="" ng-click="contextmenu.show=false">Separated link</a></li>
    <div class="overlay" ng-click="contextmenu.show=false"></div>
    </ul>
    <style>
    .overlay {
    position:fixed;
    top:0;
    right:0;
    bottom:0;
    left:0;
    z-index:-1;
    }
    </style>
    </body>