Skip to content

Commit

Permalink
Quickmenu now closes immediately when clicking outside the container.…
Browse files Browse the repository at this point in the history
… Bump to 1.0.3
  • Loading branch information
mmikkel committed May 22, 2018
1 parent 836fdcd commit cb7def8
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 14 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,13 @@ All notable changes to this project will be documented in this file.

The format is based on [Keep a Changelog](http://keepachangelog.com/) and this project adheres to [Semantic Versioning](http://semver.org/).

## 1.0.3 - 2018-05-23
### Improved
- Child Me! quickmenu now closes immediately when clicking outside the container

### Fixed
– Fixes an issue where the Child Me! JavaScript would get initialised multiple times

## 1.0.2 - 2018-05-23
### Improved
- Entry Type names are now translated using the "site" translation category
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "mmikkel/child-me",
"description": "Easily create child elements",
"type": "craft-plugin",
"version": "1.0.2",
"version": "1.0.3",
"keywords": [
"craft",
"cms",
Expand Down
32 changes: 19 additions & 13 deletions src/resources/childme.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,13 @@

Craft.ChildMePlugin = {

initialized: false,

init: function (data) {
if (this.initialized) {
return;
}
this.initialized = true;
this.data = data || {};
this.addEventListeners();
},
Expand Down Expand Up @@ -139,36 +145,36 @@
onDragStop: function (tableSorter) {

var $items = tableSorter.$items;
$items.find('[data-childmeadd]')
//.removeAttr('aria-hidden')
//.removeAttr('tabindex')
.show()
$items.find('[data-childmeadd]').show();

var maxLevels = tableSorter.maxLevels;
if (!maxLevels) return false;

var $hiddenItems = $items.filter(function () {
return $(this).data('level') >= maxLevels;
}).find('[data-childmeadd]')
//.attr('aria-hidden', 'true')
//.attr('tabindex', '-1')
.hide();
}).find('[data-childmeadd]').hide();

},

onDocClick: function (e) {
if (!$(e.target).closest('[data-childmeadd]').length) {
this.closeActiveEntryTypeMenu();
}
},

addEventListeners: function () {
Garnish.$doc
.on('focus', '[data-childmeadd]', this.onChildMeButtonClick.bind(this))
.on('blur', '[data-childmeadd]', (function (e) {
this.closeActiveEntryTypeMenu();
}).bind(this))
.on('click', '[data-childmeadd] a', this.onEntryTypeOptionSelect.bind(this));
.on('blur', '[data-childmeadd]', this.closeActiveEntryTypeMenu.bind(this))
.on('click', '[data-childmeadd] a', this.onEntryTypeOptionSelect.bind(this))
.on('click', this.onDocClick.bind(this));
},

removeEventListeners: function () {
Garnish.$doc
.off('focus blur', '[data-childmeadd]')
.off('click', '[data-childmeadd] a');
.off('click', '[data-childmeadd] a')
.off('click', this.onDocClick.bind(this))
}

}
Expand Down

0 comments on commit cb7def8

Please sign in to comment.