PluginProbe
Edit Flow / 0.8
Edit Flow v0.8
0.11.1 0.11.0 0.7.2 0.7.3 0.7.4 0.7.5 0.7.6 0.8 0.8.1 0.8.2 0.9 0.9.1 0.9.2 0.9.3 0.9.4 0.9.5 0.9.6 0.9.7 0.9.8 0.9.9 trunk 0.1.5 0.10.0 0.10.1 0.10.2 All 44 releases
edit-flow / modules / settings / lib / settings.js

settings.js in Edit Flow 0.8, at modules/settings/lib/settings.js

90 lines 4.3 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 // Hide a given message
2 function edit_flow_hide_message() {
3 jQuery('.edit-flow-message').fadeOut(function(){ jQuery(this).remove(); });
4 }
5
6 jQuery(document).ready(function(){
7
8 // Restore the Edit Flow submenu if there are no modules enabled
9 // We need it down below for dynamically rebuilding the link list when on the settings page
10 var ef_settings_submenu_html = '<div class="wp-submenu"><div class="wp-submenu-wrap"><div class="wp-submenu-head">Edit Flow</div><ul><li class="wp-first-item current"><a tabindex="1" class="wp-first-item current" href="admin.php?page=ef-settings">Edit Flow</a></li></ul></div></div>';
11 if ( jQuery( 'li#toplevel_page_ef-settings .wp-submenu' ).length == 0 ) {
12 jQuery( 'li#toplevel_page_ef-settings' ).addClass('wp-has-submenu wp-has-current-submenu wp-menu-open');
13 jQuery( 'li#toplevel_page_ef-settings' ).append( ef_settings_submenu_html );
14 jQuery( 'li#toplevel_page_ef-settings .wp-submenu' ).show();
15 }
16
17 // Set auto-removal to 8 seconds
18 if ( jQuery('.edit-flow-message').length > 0 ) {
19 setTimeout( edit_flow_hide_message, 8000 );
20 }
21
22 jQuery('.enable-disable-edit-flow-module').click(function(){
23 if ( jQuery(this).hasClass('button-primary') )
24 var module_action = 'enable';
25 else if ( jQuery(this).hasClass('button-remove') )
26 var module_action = 'disable';
27
28 var slug = jQuery(this).closest('.edit-flow-module').attr('id');
29 var change_module_nonce = jQuery('#' + slug + ' #change-module-nonce').val();
30 var data = {
31 action: 'change_edit_flow_module_state',
32 module_action: module_action,
33 slug: slug,
34 change_module_nonce: change_module_nonce,
35 }
36
37 jQuery.post( ajaxurl, data, function(response) {
38
39 if ( response == 1 ) {
40 jQuery('#' + slug + ' .enable-disable-edit-flow-module' ).hide();
41 if ( module_action == 'disable' ) {
42 jQuery('#' + slug).addClass('module-disabled').removeClass('module-enabled');
43 jQuery('#' + slug + ' .enable-disable-edit-flow-module.button-primary' ).show();
44 jQuery('#' + slug + ' a.configure-edit-flow-module' ).hide().addClass('hidden');
45 // If there was a configuration URL in the module, let's hide it from the left nav too
46 if ( jQuery('#' + slug + ' a.configure-edit-flow-module' ).length > 0 ) {
47 var configure_url = jQuery('#' + slug + ' a.configure-edit-flow-module' ).attr('href').replace(ef_admin_url, '');
48 var top_level_menu = jQuery('#' + adminpage );
49 jQuery('.wp-submenu-wrap li a', top_level_menu ).each(function(){
50 if ( jQuery(this).attr('href') == configure_url )
51 jQuery(this).closest('li').fadeOut(function(){ jQuery(this).remove(); });
52 });
53 }
54 } else if ( module_action == 'enable' ) {
55 jQuery('#' + slug).addClass('module-enabled').removeClass('module-disabled');
56 jQuery('#' + slug + ' .enable-disable-edit-flow-module.button-remove' ).show();
57 jQuery('#' + slug + ' a.configure-edit-flow-module' ).show().removeClass('hidden');
58 // If there was a configuration URL in the module, let's go through the complex process of adding it again to the left nav
59 if ( jQuery('#' + slug + ' a.configure-edit-flow-module' ).length > 0 ) {
60 // Identify the order it should be in
61 var link_order = 0;
62 var counter = 0;
63 jQuery('.edit-flow-module.has-configure-link').each(function(key,item){
64 if ( jQuery(this).attr('id') == slug && !jQuery('a.configure-edit-flow-module', this).hasClass('hidden') )
65 link_order = counter;
66 if ( !jQuery('a.configure-edit-flow-module', this).hasClass('hidden') )
67 counter++;
68 });
69 // Build the HTML for the new link
70 var configure_url = jQuery('#' + slug + ' a.configure-edit-flow-module' ).attr('href').replace(ef_admin_url, '');
71 var top_level_menu = jQuery('#' + adminpage );
72 var html_title = jQuery('#' + slug + ' h4').html();
73 var html_insert = '<li><a class="ef-settings-fade-in" style="display:none;" href="' + configure_url + '" tabindex="1">' + html_title + '</a>';
74 jQuery('.wp-submenu-wrap ul li', top_level_menu).each(function(key,item) {
75 if ( key == link_order )
76 jQuery(this).after(html_insert);
77 });
78 // Trick way to do a fade in: add a class of 'ef-settings-fade-in' and run it after the action
79 jQuery('.ef-settings-fade-in').fadeIn().removeClass('ef-settings-fade-in');
80 }
81 }
82 }
83 return false;
84
85 });
86
87 return false;
88 });
89
90 });