diff --git a/content/editor.html b/content/editor.html index 4fc5cfb5..d2916645 100644 --- a/content/editor.html +++ b/content/editor.html @@ -14,6 +14,7 @@ /lib/droplet.css"> /lib/font-awesome.css"> /lib/tooltipster/css/tooltipster.css"> +/lib/pencilcode-contextmenu/src/dist/pencilcode-contextmenu.css">
diff --git a/content/lib/pencilcode-contextmenu/Gruntfile.js b/content/lib/pencilcode-contextmenu/Gruntfile.js new file mode 100644 index 00000000..b7473d58 --- /dev/null +++ b/content/lib/pencilcode-contextmenu/Gruntfile.js @@ -0,0 +1,41 @@ + +module.exports = function(grunt) { + 'use strict'; + + grunt.initConfig({ + pkg: grunt.file.readJSON('package.json'), + + uglify: { + all: { + files: { + "src/dist/pencilcode-contextmenu.js": [ + "src/dev/pencilcode-contextmenu.js" + ] + }, + options: { + preserveComments: false, + screwIE8: true, + report: 'min', + beautify: { + beautify: true + } + } + } + }, + less: { + all: { + options: { compress: true }, + files: { + "src/dist/pencilcode-contextmenu.css": "src/dev/pencilcode-contextmenu.less" + } + } + } + }); + + grunt.loadNpmTasks('grunt-contrib-less'); + grunt.loadNpmTasks('grunt-contrib-uglify'); + + + grunt.registerTask('build',['uglify', 'less']); +}; + diff --git a/content/lib/pencilcode-contextmenu/bower.json b/content/lib/pencilcode-contextmenu/bower.json new file mode 100644 index 00000000..6443179e --- /dev/null +++ b/content/lib/pencilcode-contextmenu/bower.json @@ -0,0 +1,25 @@ +{ + "name": "pencilcode-contextmenu", + "description": "", + "main": "index.js", + "authors": [ + "Dinuka De Silva " + ], + "license": "ISC", + "homepage": "https://github.com/Dinuka2013513/pencilcode", + "moduleType": [ + "amd", + "globals" + ], + "ignore": [ + "**/.*", + "node_modules", + "bower_components", + "test", + "tests" + ], + "dependencies": { + "jquery": "~2.1.4", + "font-awesome": "~4.5.0" + } +} diff --git a/content/lib/pencilcode-contextmenu/package.json b/content/lib/pencilcode-contextmenu/package.json new file mode 100644 index 00000000..8eedc22a --- /dev/null +++ b/content/lib/pencilcode-contextmenu/package.json @@ -0,0 +1,20 @@ +{ + "name": "pencilcode-contextmenu", + "version": "1.0.0", + "description": "", + "main": "index.js", + "directories": { + "test": "test" + }, + "scripts": { + "test": "echo \"Error: no test specified\" && exit 1" + }, + "author": "Dinuka De Silva ", + "license": "ISC", + "devDependencies": { + "grunt": "^0.4.5", + "grunt-contrib-concat": "^0.5.1", + "grunt-contrib-less": "^1.1.0", + "grunt-contrib-uglify": "^0.11.0" + } +} diff --git a/content/lib/pencilcode-contextmenu/src/dev/pencilcode-contextmenu.js b/content/lib/pencilcode-contextmenu/src/dev/pencilcode-contextmenu.js new file mode 100644 index 00000000..c071dbc6 --- /dev/null +++ b/content/lib/pencilcode-contextmenu/src/dev/pencilcode-contextmenu.js @@ -0,0 +1,167 @@ +(function($) { + + function clearRightClickMenus(){ + $('.right-click-menu').css('display','none'); + $('.right-click-active').removeClass('right-click-active'); + } + + + + //Listeners tomanage Right CLick Menu + (function (){ + function clickInsideElement( e, className ) { + var el = e.srcElement || e.target; + + if ( el.classList.contains(className) ) { + return el; + } else { + while ( el = el.parentNode ) { + if ( el.classList && el.classList.contains(className) ) { + return el; + } + } + } + + return false; + } + + //Listens for click events. + (function () { + document.addEventListener( "click", function(e) { + var clickeElIsLink = clickInsideElement( e, 'right-click-menu' ); + + if ( !clickeElIsLink ) { + clearRightClickMenus(); + } + }); + })(); + + //Listens for keyup events. + (function () { + window.onkeyup = function(e) { + if ( e.keyCode === 27 ) { + clearRightClickMenus(); + } + } + })(); + + //Window resize event listener + (function () { + window.onresize = function(e) { + clearRightClickMenus(); + }; + })(); + })(); + + + /* $(document).ready(function () { + $('.right-click-menu').on('mouseenter', function(){ + console.log("Mouse enter"); + //mouseOverActiveElement = true; + }).on('mouseleave', function(){ + console.log("Mouse leave"); + //mouseOverActiveElement = false; + //clearRightClickMenus(); + }).on('focus', function(){ + console.log("Mouse focus"); + //mouseOverActiveElement = false; + //clearRightClickMenus(); + }).on('focusout', function(){ + console.log("Mouse focusout"); + //mouseOverActiveElement = false; + //clearRightClickMenus(); + }).on('blur', function(){ + console.log("Mouse blur"); + //mouseOverActiveElement = false; + //clearRightClickMenus(); + }).on('click', function(){ + console.log("Mouse click"); + //mouseOverActiveElement = false; + //clearRightClickMenus(); + }) + });*/ + + $.fn.extend({ + closeRightClickMenu: function () { + clearRightClickMenus(); + }, + addRightClickMenu:function (menus) { + this.each(function() { + function getMenu(menus) { + var menu=$('