diff --git a/.github/CONTRIBUTING.md b/.github/CONTRIBUTING.md new file mode 100644 index 0000000..00404d1 --- /dev/null +++ b/.github/CONTRIBUTING.md @@ -0,0 +1,4 @@ +Thanks for contributing :+1: + +In lieu of an own guideline, please have a look at the +[Fancytree Contributing Guidelines](https://github.com/mar10/fancytree/wiki/HowtoContribute#report-issues). diff --git a/.github/ISSUE_TEMPLATE.md b/.github/ISSUE_TEMPLATE.md new file mode 100644 index 0000000..e6fc770 --- /dev/null +++ b/.github/ISSUE_TEMPLATE.md @@ -0,0 +1,24 @@ +Thanks for contributing :-) + +Please add info below, then remove all unneeded lines from this issue report. + + +### Expected and actual behavior + +... (Maybe even a screenshot? Any hints on the browser's debug console?) + + +### Steps to reproduce the problem + + 1. ... + 2. ... + +Could you set up a jsFiddle (http://jsfiddle.net/mar10/6o3u8a88/) or +Plunker (http://plnkr.co/edit/Bbcoqy?p=preview) ? + + +### Environment + + - Browser type and version: + - jQuery and jQuery UI versions: + - ui-contextmenu version: diff --git a/.gitignore b/.gitignore index 3c58feb..f0844a2 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,6 @@ /.settings /node_modules +/test/issue-* .DS_Store npm-debug.log .sizecache.json diff --git a/CHANGELOG.md b/CHANGELOG.md index 1b3af35..be29c0b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,12 @@ -# 1.12.1-0 / Unreleased +# 1.13.0-0 / Unreleased + * - * +# 1.13.0 / 2016-08-21 + + * [FEATURE] Test with jQuery 3 + * [FEATURE] #104 Allow to pass mouse click events to `open()` + * Update grunt to 1.0 + * Upate QUnit to 1.23 and refactor tests to use `assert` # 1.12.0 / 2016-05-18 diff --git a/Gruntfile.coffee b/Gruntfile.coffee index ea752e4..060ee20 100644 --- a/Gruntfile.coffee +++ b/Gruntfile.coffee @@ -75,34 +75,43 @@ module.exports = (grunt) -> options: urls: [ # "http://localhost:9999/test/index.html", - "http://localhost:9999/test/index-jquery-ui-1-10.html" + "http://localhost:9999/test/test-jquery-1.9-ui-1.10.html" ] - - # username: process.env.SAUCE_USERNAME, - # key: process.env.SAUCE_ACCESS_KEY, build: process.env.TRAVIS_JOB_ID throttled: 8 browsers: [ - { browserName: "chrome", platform: "Windows 7" } - { browserName: "firefox", platform: "Windows 7" } + { browserName: "chrome", platform: "Windows 8.1" } + { browserName: "firefox", platform: "Windows 8.1" } { browserName: "firefox", platform: "Linux" } { browserName: "internet explorer", version: "6", platform: "Windows XP" } { browserName: "internet explorer", version: "7", platform: "Windows XP" } - # { browserName: "internet explorer", version: "8", platform: "Windows 7" } - # { browserName: "internet explorer", version: "9", platform: "Windows 7" } - # { browserName: "internet explorer", version: "10", platform: "Windows 8" } + { browserName: "internet explorer", version: "8", platform: "Windows 7" } { browserName: "internet explorer", version: "11", platform: "Windows 8.1" } { browserName: "microsoftedge", platform: "Windows 10" } - # { browserName: "safari", version: "6", platform: "OS X 10.8" } - # { browserName: "safari", version: "7", platform: "OS X 10.9" } - # { browserName: "safari", version: "8", platform: "OS X 10.10" } { browserName: "safari", version: "9", platform: "OS X 10.11" } ] testname: "jquery.ui-contextmenu qunit tests (jQuery UI 10)" + ui_12: + options: + urls: [ + "http://localhost:9999/test/test-jquery-3-ui-1.12.html" + ] + build: process.env.TRAVIS_JOB_ID + throttled: 8 + browsers: [ + { browserName: "chrome", platform: "Windows 8.1" } + { browserName: "firefox", platform: "Windows 8.1" } + { browserName: "firefox", platform: "Linux" } + { browserName: "internet explorer", version: "11", platform: "Windows 8.1" } + { browserName: "microsoftedge", platform: "Windows 10" } + { browserName: "safari", version: "9", platform: "OS X 10.11" } + ] + testname: "jquery.ui-contextmenu qunit tests (jQuery UI 12)" ui: # UI Menu 11+ dropped support for IE7 options: urls: [ - "http://localhost:9999/test/index.html", + "http://localhost:9999/test/test-jquery-1.11-ui-1.11.html" + # "http://localhost:9999/test/index.html", # "http://localhost:9999/test/index-jquery-ui-1-10.html" ] @@ -111,8 +120,8 @@ module.exports = (grunt) -> build: process.env.TRAVIS_JOB_ID throttled: 8 browsers: [ - { browserName: "chrome", platform: "Windows 7" } - { browserName: "firefox", platform: "Windows 7" } + { browserName: "chrome", platform: "Windows 8.1" } + { browserName: "firefox", platform: "Windows 8.1" } # { browserName: "firefox", platform: "Windows XP" } { browserName: "firefox", platform: "Linux" } # jQuery UI 11+ stopped support for IE 7 @@ -132,7 +141,7 @@ module.exports = (grunt) -> uglify: options: - banner: "/*! <%= pkg.title || pkg.name %> - v<%= pkg.version %> - " + "<%= grunt.template.today('yyyy-mm-dd') %> | " + "<%= pkg.homepage ? ' ' + pkg.homepage + ' | ' : '' %>" + " Copyright (c) <%= grunt.template.today('yyyy') %> <%= pkg.author.name %>;" + " Licensed <%= _.pluck(pkg.licenses, 'type').join(', ') %> */\n" + banner: "/*! <%= pkg.title || pkg.name %> - v<%= pkg.version %> - " + "<%= grunt.template.today('yyyy-mm-dd') %> | " + "<%= pkg.homepage ? ' ' + pkg.homepage + ' | ' : '' %>" + " Copyright (c) <%= grunt.template.today('yyyy') %> <%= pkg.author.name %>;" + " Licensed <%= _.map(pkg.licenses, 'type').join(', ') %> */\n" report: "gzip" build: @@ -156,7 +165,7 @@ module.exports = (grunt) -> yabs: release: common: # defaults for all tools - manifests: ['package.json', 'bower.json', 'ui-contextmenu.jquery.json'] + manifests: ['package.json', 'bower.json'] # The following tools are run in order: check: { branch: ['master'], canPush: true, clean: true, cmpVersion: 'gte' } run_test: { tasks: ['test'] } @@ -182,7 +191,7 @@ module.exports = (grunt) -> grunt.registerTask "server", ["connect:demo"] grunt.registerTask "dev", ["connect:dev", "watch:dev"] grunt.registerTask "test", ["jshint", "jscs", "qunit"] - grunt.registerTask "sauce", ["connect:sauce", "saucelabs-qunit:ui", "saucelabs-qunit:ui_10"] + grunt.registerTask "sauce", ["connect:sauce", "saucelabs-qunit:ui","saucelabs-qunit:ui_10", "saucelabs-qunit:ui_12"] if parseInt(process.env.TRAVIS_PULL_REQUEST, 10) > 0 # saucelab keys do not work on forks # http://support.saucelabs.com/entries/25614798 diff --git a/LICENSE.txt b/LICENSE.txt index 1a742e8..1fe179f 100644 --- a/LICENSE.txt +++ b/LICENSE.txt @@ -1,4 +1,4 @@ -Copyright 2013-2015 Martin Wendt and others (see commiter list on GitHub) +Copyright 2013-2016 Martin Wendt and others (see commiter list on GitHub) https://github.com/mar10/jquery-ui-contextmenu Permission is hereby granted, free of charge, to any person obtaining diff --git a/README.md b/README.md index e23255a..e614ce6 100644 --- a/README.md +++ b/README.md @@ -26,6 +26,14 @@ See also the [Change Log](https://github.com/mar10/jquery-ui-contextmenu/blob/ma [Live demo page](http://wwwendt.de/tech/demo/jquery-contextmenu/demo/):
[ ![sample](demo/teaser.png?raw=true) ](http://wwwendt.de/tech/demo/jquery-contextmenu/demo/ "Live demo") +See also the unit tests and live examples + +**More:** + + * Play with [jsFiddle](http://jsfiddle.net/mar10/6o3u8a88/) or + [Plunker](http://plnkr.co/edit/Bbcoqy?p=preview) + * Run the [unit tests](http://rawgit.com/mar10/jquery-ui-contextmenu/master/test/index.html). + ## Getting Started diff --git a/bower.json b/bower.json index 472431b..8fb7fda 100644 --- a/bower.json +++ b/bower.json @@ -1,7 +1,7 @@ { "name": "ui-contextmenu", "description": "Turn a jQuery UI Menu widget into a contextmenu.", - "version": "1.12.0", + "version": "1.13.0", "main": [ "jquery.ui-contextmenu.js" ], diff --git a/demo/index-1-12.html b/demo/index-1-12.html index 742dbf8..820b092 100644 --- a/demo/index-1-12.html +++ b/demo/index-1-12.html @@ -5,7 +5,12 @@ jquery.ui-contextmenu.js - Demo (jQuery UI 1.12) - + + + + + + @@ -231,21 +236,21 @@

Sample 2

Sample 3

diff --git a/demo/index.html b/demo/index.html index cd61118..aca4390 100644 --- a/demo/index.html +++ b/demo/index.html @@ -5,7 +5,12 @@ jquery.ui-contextmenu.js - Demo - + + + + + + diff --git a/jquery.ui-contextmenu.js b/jquery.ui-contextmenu.js index 9f21334..055856b 100644 --- a/jquery.ui-contextmenu.js +++ b/jquery.ui-contextmenu.js @@ -5,7 +5,7 @@ * * @see https://github.com/mar10/jquery-ui-contextmenu * - * Copyright (c) 2013-2015, Martin Wendt (http://wwWendt.de). Licensed MIT. + * Copyright (c) 2013-2016, Martin Wendt (http://wwWendt.de). Licensed MIT. */ (function( factory ) { @@ -193,7 +193,7 @@ $.widget("moogle.contextmenu", { self = this, manualTrigger = !!event.isTrigger, ui = { menu: this.$menu, target: $(event.target), - extraData: event.extraData, originalEvent: event, + extraData: event._extraData, originalEvent: event, result: null }; if ( !opts.autoTrigger && !manualTrigger ) { @@ -337,10 +337,20 @@ $.widget("moogle.contextmenu", { /** Open context menu on a specific target (must match options.delegate) * Optional `extraData` is passed to event handlers as `ui.extraData`. */ - open: function(target, extraData) { + open: function(targetOrEvent, extraData) { // Fake a 'contextmenu' event extraData = extraData || {}; - var e = jQuery.Event("contextmenu", { target: target.get(0), extraData: extraData }); + + var isEvent = (targetOrEvent && targetOrEvent.type && targetOrEvent.target), + event = isEvent ? targetOrEvent : {}, + target = isEvent ? targetOrEvent.target : targetOrEvent, + e = jQuery.Event("contextmenu", { + target: $(target).get(0), + pageX: event.pageX, + pageY: event.pageY, + originalEvent: isEvent ? targetOrEvent : undefined, + _extraData: extraData + }); return this.element.trigger(e); }, /** Replace the menu altogether. */ diff --git a/jquery.ui-contextmenu.min.js b/jquery.ui-contextmenu.min.js index 5adb2bd..832f57f 100644 --- a/jquery.ui-contextmenu.min.js +++ b/jquery.ui-contextmenu.min.js @@ -1,4 +1,4 @@ -/*! jQuery UI context menu plugin - v1.12.0 - 2016-05-18 | https://github.com/mar10/jquery-ui-contextmenu | Copyright (c) 2016 Martin Wendt; Licensed MIT */ +/*! jQuery UI context menu plugin - v1.13.0 - 2016-08-21 | https://github.com/mar10/jquery-ui-contextmenu | Copyright (c) 2016 Martin Wendt; Licensed MIT */ -!function(a){"use strict";"function"==typeof define&&define.amd?define(["jquery","jquery-ui/menu"],a):a(jQuery)}(function(a){"use strict";var b="onselectstart"in document.createElement("div"),c=a.ui.menu.version.match(/^(\d)\.(\d+)/),d={major:parseInt(c[1],10),minor:parseInt(c[2],10)},e=d.major<2&&d.minor<=10,f=d.major<2&&d.minor<=11;a.widget("moogle.contextmenu",{version:"@VERSION",options:{addClass:"ui-contextmenu",autoFocus:!1,autoTrigger:!0,delegate:null,hide:{effect:"fadeOut",duration:"fast"},ignoreParentSelect:!0,menu:null,position:null,preventContextMenuForPopup:!1,preventSelect:!1,show:{effect:"slideDown",duration:"fast"},taphold:!1,uiMenuOptions:{},beforeOpen:a.noop,blur:a.noop,close:a.noop,create:a.noop,createMenu:a.noop,focus:a.noop,open:a.noop,select:a.noop},_create:function(){var c,d,e,f=this.options;if(this.$headStyle=null,this.$menu=null,this.menuIsTemp=!1,this.currentTarget=null,this.previousFocus=null,f.preventSelect){e=(a(this.element).is(document)?a("body"):this.element).uniqueId().attr("id"),c="#"+e+" "+f.delegate+" { -webkit-user-select: none; -khtml-user-select: none; -moz-user-select: none; -ms-user-select: none; user-select: none; }",this.$headStyle=a("").prop("type","text/css").appendTo("head");try{this.$headStyle.html(c)}catch(g){this.$headStyle[0].styleSheet.cssText=c}b&&this.element.delegate(f.delegate,"selectstart"+this.eventNamespace,function(a){a.preventDefault()})}this._createUiMenu(f.menu),d="contextmenu"+this.eventNamespace,f.taphold&&(d+=" taphold"+this.eventNamespace),this.element.delegate(f.delegate,d,a.proxy(this._openMenu,this))},_destroy:function(){this.element.undelegate(this.eventNamespace),this._createUiMenu(null),this.$headStyle&&(this.$headStyle.remove(),this.$headStyle=null)},_createUiMenu:function(b){var c,d=this.options;this.isOpen()&&(c=this.currentTarget,this._closeMenu(!0),this.currentTarget=c),this.menuIsTemp?this.$menu.remove():this.$menu&&this.$menu.menu("destroy").removeClass(this.options.addClass).hide(),this.$menu=null,this.menuIsTemp=!1,b&&(a.isArray(b)?(this.$menu=a.moogle.contextmenu.createMenuMarkup(b),this.menuIsTemp=!0):this.$menu="string"==typeof b?a(b):b,this.$menu.hide().addClass(d.addClass).menu(a.extend(!0,{},d.uiMenuOptions,{items:"> :not(.ui-widget-header)",blur:a.proxy(d.blur,this),create:a.proxy(d.createMenu,this),focus:a.proxy(d.focus,this),select:a.proxy(function(b,c){var e,f=a.moogle.contextmenu.isMenu(c.item),g=c.item.data("actionHandler");c.cmd=c.item.attr("data-command"),c.target=a(this.currentTarget),f&&d.ignoreParentSelect||(e=this._trigger.call(this,"select",b,c),g&&(e=g.call(this,b,c)),e!==!1&&this._closeMenu.call(this),b.preventDefault())},this)})))},_openMenu:function(b,c){var d,e,f=this.options,g=f.position,h=this,i=!!b.isTrigger,j={menu:this.$menu,target:a(b.target),extraData:b.extraData,originalEvent:b,result:null};if(f.autoTrigger||i){if(b.preventDefault(),this.currentTarget=b.target,!c){if(d=this._trigger("beforeOpen",b,j),e=j.result&&a.isFunction(j.result.promise)?j.result:null,j.result=null,d===!1)return this.currentTarget=null,!1;if(e)return e.done(function(){h._openMenu(b,!0)}),this.currentTarget=null,!1;j.menu=this.$menu}a(document).bind("keydown"+this.eventNamespace,function(b){b.which===a.ui.keyCode.ESCAPE&&h._closeMenu()}).bind("mousedown"+this.eventNamespace+" touchstart"+this.eventNamespace,function(b){a(b.target).closest(".ui-menu-item").length||h._closeMenu()}),a.isFunction(g)&&(g=g(b,j)),g=a.extend({my:"left top",at:"left bottom",of:void 0===b.pageX?b.target:b,collision:"fit"},g),this.$menu.show().css({position:"absolute",left:0,top:0}).position(g).hide(),f.preventContextMenuForPopup&&this.$menu.bind("contextmenu"+this.eventNamespace,function(a){a.preventDefault()}),this._show(this.$menu,f.show,function(){f.autoFocus&&(h.$menu.focus(),h.previousFocus=a(b.target)),h._trigger.call(h,"open",b,j)})}},_closeMenu:function(b){var c=this,d=b?!1:this.options.hide;a(document).unbind("mousedown"+this.eventNamespace).unbind("touchstart"+this.eventNamespace).unbind("keydown"+this.eventNamespace),c.currentTarget=null,this.$menu?(this.$menu.unbind("contextmenu"+this.eventNamespace),this._hide(this.$menu,d,function(){c.previousFocus&&(c.previousFocus.focus(),c.previousFocus=null),c._trigger("close")})):c._trigger("close")},_setOption:function(b,c){switch(b){case"menu":this.replaceMenu(c)}a.Widget.prototype._setOption.apply(this,arguments)},_getMenuEntry:function(a){return this.$menu.find("li[data-command="+a+"]")},close:function(){this.isOpen()&&this._closeMenu()},enableEntry:function(a,b){this._getMenuEntry(a).toggleClass("ui-state-disabled",b===!1)},getMenu:function(){return this.$menu},isOpen:function(){return!!this.$menu&&!!this.currentTarget},open:function(a,b){b=b||{};var c=jQuery.Event("contextmenu",{target:a.get(0),extraData:b});return this.element.trigger(c)},replaceMenu:function(a){this._createUiMenu(a)},setEntry:function(b,c){var d,e=this._getMenuEntry(b);"string"==typeof c?a.moogle.contextmenu.updateTitle(e,c):(e.empty(),c.cmd=c.cmd||b,a.moogle.contextmenu.createEntryMarkup(c,e),a.isArray(c.children)&&(d=a("