Skip to content

Commit c67d2f5

Browse files
committed
Update fontawesome docs
Update integration paths for webdriverio tests First iteration of integration webdriverio.
1 parent 93ace40 commit c67d2f5

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

68 files changed

+13019
-23
lines changed

.sauce.yml

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
---
2+
language: "javascript"
3+
framework: "webdriverio"
4+
configPath: "wdio.conf.js"

dist/font/context-menu-icons.eot

0 Bytes
Binary file not shown.

dist/font/context-menu-icons.ttf

0 Bytes
Binary file not shown.

dist/font/context-menu-icons.woff

0 Bytes
Binary file not shown.

dist/font/context-menu-icons.woff2

0 Bytes
Binary file not shown.

dist/jquery.contextMenu.css

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
* Licensed under
1313
* MIT License http://www.opensource.org/licenses/mit-license
1414
*
15-
* Date: 2016-07-17T19:45:35.350Z
15+
* Date: 2016-08-26T12:03:55.082Z
1616
*/
1717
@font-face {
1818
font-family: "context-menu-icons";

dist/jquery.contextMenu.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
* MIT License http://www.opensource.org/licenses/mit-license
1313
* GPL v3 http://opensource.org/licenses/GPL-3.0
1414
*
15-
* Date: 2016-08-26T11:25:39.329Z
15+
* Date: 2016-08-26T12:03:55.490Z
1616
*/
1717

1818
(function (factory) {

dist/jquery.contextMenu.min.css

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/jquery.contextMenu.min.css.map

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/jquery.contextMenu.min.js

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/jquery.contextMenu.min.js.map

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

documentation/couscous.yml

+7
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ scripts:
1515
- cp -R ../dist/* website/dist/
1616
after:
1717
- rm -rf website/dist/
18+
- cp .couscous/generated/demo/* ../test/integration/html
1819

1920

2021
github:
@@ -51,6 +52,9 @@ menu:
5152
custom-icons:
5253
text: Customize icons
5354
relativeUrl: docs/customize.html
55+
fontawesome-icons:
56+
text: FontAwesome icons
57+
relativeUrl: demo/fontawesome-icons.html
5458
font-awesome:
5559
text: Font Awesome support
5660
relativeUrl: docs/font-awesome.html
@@ -73,6 +77,9 @@ menu:
7377
simple-context-menu:
7478
text: Simple Context Menu
7579
relativeUrl: demo.html
80+
fontawesome-icons:
81+
text: FontAwesome icons
82+
relativeUrl: demo/fontawesome-icons.html
7683
accesskeys:
7784
text: Accesskeys
7885
relativeUrl: demo/accesskeys.html
+45
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
---
2+
currentMenu: accesskeys
3+
---
4+
5+
# Demo: Accesskeys
6+
7+
<!-- START doctoc generated TOC please keep comment here to allow auto update -->
8+
<!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE -->
9+
10+
11+
- [Example code](#example-code)
12+
- [Example HTML](#example-html)
13+
14+
<!-- END doctoc generated TOC please keep comment here to allow auto update -->
15+
16+
The menu allows you to use [FontAwesome](http://fontawesome.io/) [icons](http://fontawesome.io/icons/) in your menu. Just include the CSS for FontAwesome and you are ready to go.
17+
18+
<span class="context-menu-one btn btn-neutral">right click me</span>
19+
20+
## Example code
21+
22+
<script type="text/javascript" class="showcase">
23+
$(function() {
24+
$.contextMenu({
25+
selector: '.context-menu-one',
26+
callback: function(key, options) {
27+
var m = "clicked: " + key;
28+
window.console && console.log(m) || alert(m);
29+
},
30+
items: {
31+
"edit": {name: "Edit", icon: "fa-edit"},
32+
"cut": {name: "Beer", icon: "fa-beer"},
33+
copy: {name: "Cloud download", icon: "fa-cloud-download"},
34+
"paste": {name: "Certificate", icon: "fa-certificate"}
35+
}
36+
});
37+
38+
$('.context-menu-one').on('click', function(e){
39+
console.log('clicked', this);
40+
})
41+
});
42+
</script>
43+
44+
## Example HTML
45+
<div style="display:none;" class="showcase" data-showcase-import=".context-menu-one"></div>

documentation/docs/customize.md

+2
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ You can add icons to src/icons and run ``gulp build-icons``. This will make the
88

99
So for example the file checkmark.svg wil result in the CSS context-menu-icon-checkmark which you can use by using the [icon option](items#icon) when defining a menu item.
1010

11+
Is is also possible to just use FontAwesome icons, see the [demo of FontAwesome](demo/fontawesome-icons).
12+
1113
### Example
1214

1315
```javascript

documentation/docs/font-awesome.md

+2-11
Original file line numberDiff line numberDiff line change
@@ -6,17 +6,8 @@ currentMenu: font-awesome
66

77
It is possible to use font-awesome icons if you like. You need to include the [Font Awesome CSS](https://www.bootstrapcdn.com/fontawesome/) in your application. That will enable you to use the icon classes to use those icons.
88

9-
### Example
10-
11-
```javascript
12-
var items = {
13-
firstCommand: {
14-
name: "Paste",
15-
icon: "fa-trash" // Font-awesome trash icon
16-
}
17-
}
18-
```
9+
Check out the [demo](demo/fontawesome-icons)
1910

2011
## Bring your own icons
2112

22-
It is also possible to use your own SVG icons if you like, you can [customize](customize) this by using the SASS files.
13+
It is also possible to use your own SVG icons if you like, you can [customize](customize) this by using the SASS files.

gulpfile.js

+18-3
Original file line numberDiff line numberDiff line change
@@ -158,11 +158,26 @@ gulp.task('build-icons', function () {
158158
.pipe(gulp.dest(icons.fontOutputPath));
159159
});
160160

161+
/**
162+
* Update paths in integration tests that are generated by the documentation
163+
* generator so they use the local source.
164+
*/
165+
gulp.task('integration-test-paths', function(){
166+
167+
168+
return gulp.src('test/integration/html/*.html').
169+
pipe(plugins.replace('https\:\/\/swisnl\.github\.io\/jQuery-contextMenu\/dist\/jquery\.ui\.position\.min\.js', '\.\.\/\.\.\/\.\.\/dist\/jquery\.ui\.position\.min\.js')).
170+
pipe(plugins.replace('https\:\/\/swisnl\.github\.io\/jQuery\-contextMenu\/dist\/', '\.\.\/\.\.\/\.\.\/src\/')).
171+
pipe(plugins.replace('\/src\/jquery.contextMenu.css', '\/dist\/jquery.contextMenu.css')).
172+
pipe(gulp.dest('test/integration/html/'));
173+
});
174+
175+
161176
gulp.task('watch', ['js', 'css'], function () {
162-
gulp.watch(scripts.src, ['js']);
163-
gulp.watch(styles.all, ['css']);
177+
gulp.watch(scripts.src, ['js']);
178+
gulp.watch(styles.all, ['css']);
164179
});
165180

166-
gulp.task('build', ['build-icons', 'css', 'js']);
181+
gulp.task('build', ['build-icons', 'css', 'js', 'integration-test-paths']);
167182

168183
gulp.task('default', ['watch']);

package.json

+9-2
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,12 @@
3838
"karma-phantomjs-launcher": "^1.0.0",
3939
"karma-qunit": "^1.0.0",
4040
"lodash": "^4.13.1",
41-
"qunitjs": "^2.0.0"
41+
"qunitjs": "^2.0.0",
42+
"wdio-dot-reporter": "0.0.6",
43+
"wdio-mocha-framework": "^0.4.0",
44+
"wdio-sauce-service": "^0.2.4",
45+
"wdio-selenium-standalone-service": "0.0.5",
46+
"webdriverio": "^4.2.7"
4247
},
4348
"description": "Management facility for context menus. Developed for a large number of triggering objects. HTML5 Polyfill",
4449
"keywords": [
@@ -89,6 +94,8 @@
8994
],
9095
"scripts": {
9196
"test": "npm run test-unit",
92-
"test-unit": "./node_modules/karma/bin/karma start"
97+
"test-unit": "./node_modules/karma/bin/karma start",
98+
"test-sauce": "./node_modules/.bin/wdio wdio.conf.js",
99+
"install-wdio": "npm install wdio-dot-reporter wdio-mocha-framework wdio-sauce-service wdio-selenium-standalone-service webdriverio"
93100
}
94101
}

src/sass/icons/_variables.scss

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// DON'T MANUALLY EDIT THIS FILE; run `gulp build-icons` instead.
2-
$context-menu-icons-cachebust: "14l1a";
2+
$context-menu-icons-cachebust: "2cl8a";
33
$context-menu-icons: (
44
add: "EA01",
55
copy: "EA02",

test/integration/accesskeys.js

+48
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
var pwd = process.cwd();
2+
var helper = require('../integration_test_helper.js');
3+
4+
// this test uses custom HTML because PhantomJS
5+
// has problems showing alert modal dialogs.
6+
// We are testing callbacks against simple DOM
7+
// manipulations instead.
8+
module.exports = {
9+
'Typing <e> on keyboard triggers "edit" menu item callback': function (test) {
10+
test
11+
.open('file://' + pwd + '/test/integration/html/accesskeys_test.html')
12+
.execute(helper.rightClick, '.context-menu-one')
13+
.waitForElement('#context-menu-layer')
14+
.sendKeys('body', 'e')
15+
.assert.text('#msg', 'clicked: edit', 'Edit menu item callback is triggered by accesskey')
16+
.done();
17+
},
18+
19+
'Typing <c> on keyboard triggers "cut" menu item callback': function (test) {
20+
test
21+
.open('file://' + pwd + '/test/integration/html/accesskeys_test.html')
22+
.execute(helper.rightClick, '.context-menu-one')
23+
.waitForElement('#context-menu-layer')
24+
.sendKeys('body', 'c')
25+
.assert.text('#msg', 'clicked: cut', 'Cut menu item callback is triggered by accesskey')
26+
.done();
27+
},
28+
29+
'Typing <o> on keyboard triggers "copy" menu item callback': function (test) {
30+
test
31+
.open('file://' + pwd + '/test/integration/html/accesskeys_test.html')
32+
.execute(helper.rightClick, '.context-menu-one')
33+
.waitForElement('#context-menu-layer')
34+
.sendKeys('body', 'o')
35+
.assert.text('#msg', 'clicked: copy', 'Copy menu item callback is triggered by accesskey')
36+
.done();
37+
},
38+
39+
'Typing <p> on keyboard triggers "paste" menu item callback': function (test) {
40+
test
41+
.open('file://' + pwd + '/test/integration/html/accesskeys_test.html')
42+
.execute(helper.rightClick, '.context-menu-one')
43+
.waitForElement('#context-menu-layer')
44+
.sendKeys('body', 'p')
45+
.assert.text('#msg', 'clicked: paste', 'Paste menu item callback is triggered by accesskey')
46+
.done();
47+
}
48+
};

test/integration/async-create.js

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
var pwd = process.cwd();
2+
var helper = require('../integration_test_helper.js');
3+
4+
module.exports = {
5+
'Render async context menu': function (test) {
6+
test
7+
.open('file://' + pwd + '/test/integration/html/async-create.html')
8+
.execute(helper.rightClick, '.context-menu-one', 'mouseup')
9+
.waitForElement('#context-menu-layer')
10+
.assert.exists('.context-menu-root', 'It opens context menu')
11+
.assert.numberOfElements('.context-menu-root li')
12+
.is(3, '3 context menu items are shown')
13+
.done();
14+
}
15+
};

test/integration/callback.js

+60
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
var pwd = process.cwd();
2+
var helper = require('../integration_test_helper.js');
3+
4+
// this test uses custom HTML because PhantomJS
5+
// has problems showing alert modal dialogs.
6+
// We are testing callbacks against simple DOM
7+
// manipulations instead.
8+
module.exports = {
9+
'Ensure edit menu item triggers callback': function (test) {
10+
test
11+
.open('file://' + pwd + '/test/integration/html/callback_test.html')
12+
.execute(helper.rightClick, '.context-menu-one')
13+
.waitForElement('#context-menu-layer')
14+
.wait(100)
15+
.assert.visible('.context-menu-root', 'Menu is present')
16+
.click('.context-menu-root li:nth-child(1)') // edit
17+
.assert.text('#msg', 'edit was clicked', 'Edit item triggers callback')
18+
.assert.doesntExist('#context-menu-layer', 'It closes context menu')
19+
.done();
20+
},
21+
22+
'Ensure cut menu item triggers global callback': function (test) {
23+
test
24+
.open('file://' + pwd + '/test/integration/html/callback_test.html')
25+
.execute(helper.rightClick, '.context-menu-one')
26+
.waitForElement('#context-menu-layer')
27+
.wait(100)
28+
.assert.visible('.context-menu-root', 'Menu is present')
29+
.click('.context-menu-root li:nth-child(2)') // cut
30+
.assert.text('#msg', 'global: cut', 'Cut item triggers callback')
31+
.assert.doesntExist('#context-menu-layer', 'It closes context menu')
32+
.done();
33+
},
34+
35+
'Ensure delete menu item triggers global callback': function (test) {
36+
test
37+
.open('file://' + pwd + '/test/integration/html/callback_test.html')
38+
.execute(helper.rightClick, '.context-menu-one')
39+
.waitForElement('#context-menu-layer')
40+
.wait(100)
41+
.assert.visible('.context-menu-root', 'Menu is present')
42+
.click('.context-menu-root li:nth-child(5)') // delete
43+
.assert.text('#msg', 'global: delete', 'delete item triggers callback')
44+
.assert.doesntExist('#context-menu-layer', 'It closes context menu')
45+
.done();
46+
},
47+
48+
'Ensure quit menu item triggers global callback': function (test) {
49+
test
50+
.open('file://' + pwd + '/test/integration/html/callback_test.html')
51+
.execute(helper.rightClick, '.context-menu-one')
52+
.waitForElement('#context-menu-layer')
53+
.wait(100)
54+
.assert.visible('.context-menu-root', 'Menu is present')
55+
.click('.context-menu-root li:nth-child(7)') // quit
56+
.assert.text('#msg', 'global: quit', 'quit item triggers callback')
57+
.assert.doesntExist('#context-menu-layer', 'It closes context menu')
58+
.done();
59+
}
60+
};

test/integration/custom-command.js

+42
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
var pwd = process.cwd();
2+
var helper = require('../integration_test_helper.js');
3+
4+
// this test uses custom HTML because PhantomJS
5+
// has problems showing alert modal dialogs.
6+
// We are testing callbacks against simple DOM
7+
// manipulations instead.
8+
module.exports = {
9+
'Click custom comand menu item triggers menu callback': function (test) {
10+
test
11+
.open('file://' + pwd + '/test/integration/html/custom-command_test.html')
12+
.execute(helper.rightClick, '.context-menu-one')
13+
.waitForElement('#context-menu-layer')
14+
.assert.numberOfElements('.context-menu-root>li')
15+
.is(3, '3 context menu items are shown')
16+
.click('.context-menu-root li.labels')
17+
.assert.text('#msg').to.contain('clicked: label', 'contextMenu callback was triggered')
18+
.done();
19+
},
20+
21+
'Click custom comand menu item label triggers custom action - red': function (test) {
22+
test
23+
.open('file://' + pwd + '/test/integration/html/custom-command_test.html')
24+
.execute(helper.rightClick, '.context-menu-one')
25+
.waitForElement('#context-menu-layer')
26+
.wait(100)
27+
.click('.context-menu-root li.labels .label1')
28+
.assert.text('#msg', 'clicked: label | text: label 1', 'custom action was triggered')
29+
.done();
30+
},
31+
32+
'Click custom comand menu item label triggers custom action - blue': function (test) {
33+
test
34+
.open('file://' + pwd + '/test/integration/html/custom-command_test.html')
35+
.execute(helper.rightClick, '.context-menu-one')
36+
.waitForElement('#context-menu-layer')
37+
.wait(100)
38+
.click('.context-menu-root li.labels .label3')
39+
.assert.text('#msg', 'clicked: label | text: label 3', 'custom action was triggered')
40+
.done();
41+
}
42+
};

test/integration/disabled-callback.js

+32
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
var pwd = process.cwd();
2+
var helper = require('../integration_test_helper.js');
3+
4+
// this test uses custom HTML because PhantomJS
5+
// has problems showing alert modal dialogs.
6+
// We are testing callbacks against simple DOM
7+
// manipulations instead.
8+
module.exports = {
9+
'Clicking on disabled item has no effect': function (test) {
10+
test
11+
.open('file://' + pwd + '/test/integration/html/disabled-callback_test.html')
12+
.execute(helper.rightClick, '.context-menu-one')
13+
.waitForElement('#context-menu-layer')
14+
.wait(100)
15+
.assert.numberOfElements('.context-menu-root li')
16+
.is(2, '2 context menu items are shown')
17+
.click('.context-menu-root li:last-child')
18+
.assert.text('#msg', '', 'Disabled menu item didnt set text')
19+
.done();
20+
},
21+
22+
'Clicking on enabled item works': function (test) {
23+
test
24+
.open('file://' + pwd + '/test/integration/html/disabled_test.html')
25+
.execute(helper.rightClick, '.context-menu-one')
26+
.waitForElement('#context-menu-layer')
27+
.wait(100)
28+
.click('.context-menu-root li:first-child')
29+
.assert.text('#msg', 'clicked: edit', 'Enabled menu item sets text')
30+
.done();
31+
}
32+
};

0 commit comments

Comments
 (0)