PluginProbe ʕ •ᴥ•ʔ
Nested Pages / trunk
Nested Pages vtrunk
3.2.14 3.1.8 3.1.9 3.2.0 3.2.1 3.2.10 3.2.11 3.2.12 3.2.13 3.2.2 3.2.3 3.2.4 3.2.5 3.2.6 3.2.7 3.2.8 3.2.9 trunk 1.0 1.1 1.1.1 1.1.2 1.1.3 1.1.4 1.1.5 1.1.6 1.1.7 1.1.8 1.1.9 1.2.0 1.2.1 1.3.0 1.3.1 1.3.10 1.3.11 1.3.12 1.3.13 1.3.14 1.3.15 1.3.2 1.3.4 1.3.5 1.3.6 1.3.7 1.3.8 1.3.9 1.4.0 1.4.1 1.5.0 1.5.1 1.5.2 1.5.3 1.5.4 1.6.0 1.6.1 1.6.2 1.6.3 1.6.3.1 1.6.3.2 1.6.4 1.6.5 1.6.5.1 1.6.5.2 1.6.6 1.6.7 1.6.8 1.7.0 1.7.1 2.0.1 2.0.2 2.0.3 2.0.4 3.0.1 3.0.10 3.0.11 3.0.2 3.0.3 3.0.4 3.0.5 3.0.6 3.0.7 3.0.8 3.0.9 3.1.0 3.1.1 3.1.10 3.1.11 3.1.12 3.1.13 3.1.14 3.1.15 3.1.16 3.1.17 3.1.18 3.1.19 3.1.2 3.1.20 3.1.21 3.1.22 3.1.3 3.1.4 3.1.5 3.1.6 3.1.7
wp-nested-pages / assets / js / lib / nestedpages.dropdowns.js
wp-nested-pages / assets / js / lib Last commit date
jquery.mjs.nestedSortable.js 4 years ago jquery.ui.touch-punch.min.js 11 years ago nestedpages-factory.js 3 years ago nestedpages.bulk-actions.js 4 years ago nestedpages.check-all.js 9 years ago nestedpages.clone.js 3 years ago nestedpages.confirm-delete.js 8 years ago nestedpages.dropdowns.js 8 years ago nestedpages.formatter.js 3 years ago nestedpages.hidden-item-count.js 9 years ago nestedpages.manual-sync.js 9 years ago nestedpages.menu-links.js 3 years ago nestedpages.menu-search.js 1 year ago nestedpages.menu-toggle.js 8 years ago nestedpages.modals.js 8 years ago nestedpages.move-post.js 8 years ago nestedpages.nesting.js 3 years ago nestedpages.new-post.js 6 years ago nestedpages.page-toggle.js 4 years ago nestedpages.post-search.js 9 years ago nestedpages.quickedit-link.js 8 years ago nestedpages.quickedit-post.js 3 years ago nestedpages.settings-admin-customization.js 6 years ago nestedpages.settings-reset.js 6 years ago nestedpages.settings.js 3 years ago nestedpages.sync-menu-setting.js 8 years ago nestedpages.tabs.js 6 years ago nestedpages.trash-with-children.js 6 years ago nestedpages.trash.js 8 years ago nestedpages.userprefs-reset.js 7 years ago nestedpages.wpml.js 8 years ago
nestedpages.dropdowns.js
89 lines
1 var NestedPages = NestedPages || {};
2 /**
3 * Dropdowns
4 *
5 * @author Kyle Phillips
6 *
7 * To use, wrap dropdown content and toggle link/button in an element with data attribute of data-dropdown
8 * Give content data attribute of data-dropdown-content and toggle element data attribute of data-dropdown-toggle
9 * For CSS, wrapping/parent element gets class of "dropdown", content gets class of "dropdown-content"
10 */
11 NestedPages.Dropdowns = function()
12 {
13 var self = this;
14 var $ = jQuery;
15
16 self.dropdown = ''; // The Active Dropdown
17 self.activeBtn = ''; // The Active Button
18 self.activeContent = ''; // The Active Dropdown Content
19 self.toggleBtn = '[data-dropdown-toggle]';
20 self.dropdownContainer = '[data-dropdown]';
21 self.dropdownContent = '[data-dropdown-content]'
22
23 self.selectors = {
24 caret_up : 'icon-arrow_drop_up',
25 caret_down : 'icon-arrow_drop_down'
26 }
27
28 self.bindEvents = function()
29 {
30 $(document).on('click', self.toggleBtn, function(e){
31 e.preventDefault();
32 self.activeBtn = $(this);
33 self.dropdown = $(this).parents(self.dropdownContainer);
34 self.toggleDropdown();
35 });
36 $(document).on('click', function(e){
37 self.closeDropdowns(e.target);
38 });
39 $(document).on('dropdown-opened', function(e, content){
40 if ( $(content).parents(NestedPages.selectors.row).length > 0 ){
41 $(content).parents(NestedPages.selectors.row).addClass('active');
42 }
43 });
44 $(document).on('dropdown-closed', function(){
45 $(NestedPages.selectors.row).removeClass('active');
46 });
47 }
48
49 self.toggleDropdown = function()
50 {
51 $('.' + self.selectors.caret_up).attr('class', self.selectors.caret_down);
52 var content = $(self.dropdown).find(self.dropdownContent);
53 self.activeContent = content;
54 if ( $(content).hasClass('active') ){
55 $(content).removeClass('active');
56 $(self.activeBtn).removeClass('active');
57 $(self.activeBtn).find('.' + self.selectors.caret_up).attr('class', self.selectors.caret_down);
58 $(document).trigger('dropdown-closed', content);
59 return;
60 }
61 self.setPositioning();
62 $(self.toggleBtn).removeClass('active');
63 $(self.dropdownContent).removeClass('active');
64 $(content).addClass('active');
65 $(self.activeBtn).find('.' + self.selectors.caret_down).attr('class', self.selectors.caret_up);
66 $(self.activeBtn).addClass('active');
67 $(document).trigger('dropdown-opened', content);
68 }
69
70
71 self.setPositioning = function()
72 {
73 var buttonHeight = $(self.activeBtn).outerHeight();
74 $(self.activeContent).css('top', buttonHeight + 'px');
75 }
76
77 self.closeDropdowns = function(target)
78 {
79 if ( $(target).parents(self.dropdownContainer).length === 0 ){
80 $(self.dropdownContent).removeClass('active');
81 $(self.toggleBtn).removeClass('active');
82 $(self.activeBtn).find('.' + self.selectors.caret_up).attr('class', self.selectors.caret_down);
83 var content;
84 $(document).trigger('dropdown-closed', content);
85 }
86 }
87
88 return self.bindEvents();
89 }