Nested Pages - Version 1.5.3

Version Description

  • Confirmation modal added when deleting a link item.
  • Bug fix where custom nav titles were not being saved.
  • Bug fix where replacing the default menus was breaking custom admin submenu links.
  • Minor interface enhancements.
Download this release

Release Info

Developer kylephillips
Plugin Icon 128x128 Nested Pages
Version 1.5.3
Comparing to
See all releases

Code changes from version 1.5.2 to 1.5.3

app/Activation/Dependencies.php CHANGED
@@ -3,6 +3,8 @@
3
  namespace NestedPages\Activation;
4
 
5
  use NestedPages\Entities\PostType\PostTypeRepository;
 
 
6
  /**
7
  * Plugin JS & CSS Dependencies
8
  */
@@ -30,7 +32,7 @@ class Dependencies
30
  $this->setPluginVersion();
31
  add_action( 'admin_enqueue_scripts', array($this, 'styles') );
32
  add_action( 'admin_enqueue_scripts', array($this, 'scripts') );
33
- $this->plugin_dir = plugins_url() . '/wp-nested-pages';
34
  }
35
 
36
  /**
3
  namespace NestedPages\Activation;
4
 
5
  use NestedPages\Entities\PostType\PostTypeRepository;
6
+ use NestedPages\Helpers;
7
+
8
  /**
9
  * Plugin JS & CSS Dependencies
10
  */
32
  $this->setPluginVersion();
33
  add_action( 'admin_enqueue_scripts', array($this, 'styles') );
34
  add_action( 'admin_enqueue_scripts', array($this, 'scripts') );
35
+ $this->plugin_dir = Helpers::plugin_url();
36
  }
37
 
38
  /**
app/Bootstrap.php CHANGED
@@ -23,6 +23,7 @@ class Bootstrap
23
  {
24
  new Activation\Activate;
25
  new Redirects;
 
26
  }
27
 
28
  /**
23
  {
24
  new Activation\Activate;
25
  new Redirects;
26
+ new RedirectsFrontEnd;
27
  }
28
 
29
  /**
app/Entities/AdminMenu/AdminSubmenu.php CHANGED
@@ -41,9 +41,9 @@ class AdminSubmenu
41
  public function addSubmenu()
42
  {
43
  global $submenu;
44
-
45
  // Get the right submenu and remove all pages link
46
  foreach($submenu as $key => $sub){
 
47
  if ($key == $this->post_type_repo->editSlug($this->post_type)){
48
  // Add the "All Link"
49
  $submenu[$this->slug][50] = array( $sub[5][0], 'publish_pages', esc_url(admin_url('admin.php?page=' . $this->slug)) );
@@ -51,16 +51,16 @@ class AdminSubmenu
51
  $menu_items = $sub;
52
  }
53
  }
54
-
55
  if ( isset($menu_items) ){
56
  $c = 60;
57
  foreach($menu_items as $item){
58
- $submenu[$this->slug][$c] = array( $item[0], $item[1], $item[2]);
 
 
59
  $c = $c + 10;
60
  }
61
  }
62
  $this->defaultLink($c);
63
-
64
  }
65
 
66
  /**
41
  public function addSubmenu()
42
  {
43
  global $submenu;
 
44
  // Get the right submenu and remove all pages link
45
  foreach($submenu as $key => $sub){
46
+
47
  if ($key == $this->post_type_repo->editSlug($this->post_type)){
48
  // Add the "All Link"
49
  $submenu[$this->slug][50] = array( $sub[5][0], 'publish_pages', esc_url(admin_url('admin.php?page=' . $this->slug)) );
51
  $menu_items = $sub;
52
  }
53
  }
 
54
  if ( isset($menu_items) ){
55
  $c = 60;
56
  foreach($menu_items as $item){
57
+ // Make sure URLs for custom menu items are correct
58
+ $url = ( isset($item[3]) ) ? 'edit.php?post_type=' . $this->post_type->name . '&page=' . $item[2] : $item[2];
59
+ $submenu[$this->slug][$c] = array( $item[0], $item[1], esc_url(admin_url($url)) );
60
  $c = $c + 10;
61
  }
62
  }
63
  $this->defaultLink($c);
 
64
  }
65
 
66
  /**
app/Entities/AdminMenu/EnabledMenus.php CHANGED
@@ -59,7 +59,6 @@ class EnabledMenus
59
  {
60
  $c = 1; // Counter for position
61
  foreach($this->enabled_types as $key => $type){
62
- //var_dump($type);
63
  if ( $type->np_enabled !== true ) continue;
64
  if ( $type->replace_menu ) {
65
  $this->post_type = get_post_type_object($key);
59
  {
60
  $c = 1; // Counter for position
61
  foreach($this->enabled_types as $key => $type){
 
62
  if ( $type->np_enabled !== true ) continue;
63
  if ( $type->replace_menu ) {
64
  $this->post_type = get_post_type_object($key);
app/Entities/NavMenu/NavMenuSyncListing.php CHANGED
@@ -81,6 +81,7 @@ class NavMenuSyncListing extends NavMenuSync
81
  $object_id = ( $this->post->nav_object_id ) ? intval($this->post->nav_object_id) : null;
82
  $url = ( $type == 'custom' ) ? esc_url($this->post->content) : '';
83
  $xfn = $this->post->id;
 
84
 
85
  // Compatibility for 1.4.1 - Reset Page links
86
  if ( $this->post->type == 'page' ){
@@ -91,7 +92,7 @@ class NavMenuSyncListing extends NavMenuSync
91
  }
92
 
93
  $args = array(
94
- 'menu-item-title' => $this->post->title,
95
  'menu-item-position' => $this->count,
96
  'menu-item-url' => $url,
97
  'menu-item-attr-title' => $this->post->nav_title_attr,
81
  $object_id = ( $this->post->nav_object_id ) ? intval($this->post->nav_object_id) : null;
82
  $url = ( $type == 'custom' ) ? esc_url($this->post->content) : '';
83
  $xfn = $this->post->id;
84
+ $title = ( $this->post->nav_title ) ? $this->post->nav_title : $this->post->title;
85
 
86
  // Compatibility for 1.4.1 - Reset Page links
87
  if ( $this->post->type == 'page' ){
92
  }
93
 
94
  $args = array(
95
+ 'menu-item-title' => $title,
96
  'menu-item-position' => $this->count,
97
  'menu-item-url' => $url,
98
  'menu-item-attr-title' => $this->post->nav_title_attr,
app/FrontEndBootstrap.php ADDED
@@ -0,0 +1,15 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace NestedPages;
3
+
4
+ class FrontEndBootstrap
5
+ {
6
+ public function __construct()
7
+ {
8
+ $this->init();
9
+ }
10
+
11
+ public function init()
12
+ {
13
+ new RedirectsFrontEnd;
14
+ }
15
+ }
app/Helpers.php CHANGED
@@ -23,7 +23,7 @@ class Helpers
23
  */
24
  public static function plugin_url()
25
  {
26
- return plugins_url() . '/wp-simple-locator';
27
  }
28
 
29
  /**
23
  */
24
  public static function plugin_url()
25
  {
26
+ return plugins_url('/', NESTEDPAGES_DIR);
27
  }
28
 
29
  /**
app/NestedPages.php CHANGED
@@ -12,8 +12,9 @@ class NestedPages
12
  $np_env = 'live';
13
 
14
  global $np_version;
15
- $np_version = '1.5.2';
16
 
17
  if ( is_admin() ) $app = new NestedPages\Bootstrap;
 
18
  }
19
  }
12
  $np_env = 'live';
13
 
14
  global $np_version;
15
+ $np_version = '1.5.3';
16
 
17
  if ( is_admin() ) $app = new NestedPages\Bootstrap;
18
+ if ( !is_admin() ) $app = new NestedPages\FrontEndBootstrap;
19
  }
20
  }
app/Redirects.php CHANGED
@@ -54,4 +54,5 @@ class Redirects
54
  }
55
  }
56
 
 
57
  }
54
  }
55
  }
56
 
57
+
58
  }
app/RedirectsFrontEnd.php ADDED
@@ -0,0 +1,59 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace NestedPages;
3
+
4
+ /**
5
+ * Fixes issue when pages are nested under non-page post types (np-redirect)
6
+ */
7
+ class RedirectsFrontEnd
8
+ {
9
+ public function __construct()
10
+ {
11
+ add_filter('page_link', array($this, 'pageLinks'),10,2);
12
+ add_action('request', array($this, 'request'));
13
+ }
14
+
15
+ public function pageLinks( $post_link, $id = 0 )
16
+ {
17
+ $post = get_post($id);
18
+ $post_link = $this->removeParentSlugs($post, $post_link);
19
+ return $post_link;
20
+ }
21
+
22
+ /**
23
+ * Recursive function removes non-page parent slugs
24
+ */
25
+ private function removeParentSlugs($post, $slug)
26
+ {
27
+ $parent_type = get_post_type($post->post_parent);
28
+ if ( $parent_type == 'np-redirect' ){
29
+ $parent_post = get_post($post->post_parent);
30
+ $slug = str_replace($parent_post->post_name . '/', '', $slug);
31
+ return $this->removeParentSlugs($parent_post, $slug);
32
+ }
33
+ return $slug;
34
+ }
35
+
36
+ /**
37
+ * Add page query
38
+ */
39
+ public function request($request)
40
+ {
41
+ if ( !isset($request['name']) ) return $request;
42
+ $slug = $request['name'];
43
+ $dpost = get_posts(array('name' => $slug, 'post_type' => 'page'));
44
+ if ( $dpost && $dpost[0]->post_type == 'page' ){
45
+ add_filter('pre_get_posts', array($this, 'query'));
46
+ }
47
+ return $request;
48
+ }
49
+
50
+ /**
51
+ * Set the query to page
52
+ */
53
+ public function query($query)
54
+ {
55
+ if (!$query->is_main_query()) return;
56
+ $query->set('post_type', 'page');
57
+ }
58
+
59
+ }
app/Views/forms/delete-confirmation-modal.php ADDED
@@ -0,0 +1,16 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Modal for confirming link delete
4
+ */
5
+ ?>
6
+ <div class="np-modal fade np-trash-modal" id="np-delete-confirmation-modal">
7
+ <div class="modal-dialog">
8
+ <div class="modal-content">
9
+ <div class="modal-body">
10
+ <p>Are you sure you would like to delete this item? This action is not reversable.</p>
11
+ <a href="#" class="np-cancel-trash button modal-close" data-dismiss="modal"><?php _e('Cancel', 'nestedpages'); ?></a>
12
+ <a href="#" class="button-primary" data-delete-confirmation><?php _e('Delete', 'nestedpages'); ?></a>
13
+ </div>
14
+ </div><!-- /.modal-content -->
15
+ </div><!-- /.modal-dialog -->
16
+ </div><!-- /.modal -->
app/Views/forms/new-child.php CHANGED
@@ -18,7 +18,7 @@
18
  <div class="form-control new-child-row">
19
  <label><?php _e( 'Title' ); ?></label>
20
  <div>
21
- <input type="text" name="post_title[]" class="np_title" placeholder="<?php _e('Title', 'nestedpages'); ?>" value="" />
22
  <a href="#" class="button-secondary np-remove-child">-</a>
23
  </div>
24
  </div>
18
  <div class="form-control new-child-row">
19
  <label><?php _e( 'Title' ); ?></label>
20
  <div>
21
+ <input type="text" name="post_title[]" class="np_title" placeholder="<?php _e('Title', 'nestedpages'); ?>" value="" tabindex="1" />
22
  <a href="#" class="button-secondary np-remove-child">-</a>
23
  </div>
24
  </div>
app/Views/listing.php CHANGED
@@ -37,7 +37,7 @@
37
  </div>
38
  <?php endif; ?>
39
 
40
- <img src="<?php echo plugins_url(); ?>/wp-nested-pages/assets/images/spinner-2x.gif" alt="loading" id="nested-loading" />
41
  </div><!-- .nestedpages-top-toggles -->
42
 
43
  <?php include(NestedPages\Helpers::view('partials/tool-list')); ?>
@@ -65,7 +65,9 @@
65
 
66
  </div><!-- .wrap -->
67
 
68
- <?php include( NestedPages\Helpers::view('forms/empty-trash-modal') ); ?>
69
- <?php include( NestedPages\Helpers::view('forms/clone-form') ); ?>
70
- <?php include( NestedPages\Helpers::view('forms/link-form') ); ?>
71
- <?php include( NestedPages\Helpers::view('forms/bulk-add') ); ?>
 
 
37
  </div>
38
  <?php endif; ?>
39
 
40
+ <img src="<?php echo NestedPages\Helpers::plugin_url(); ?>/assets/images/spinner-2x.gif" alt="loading" id="nested-loading" />
41
  </div><!-- .nestedpages-top-toggles -->
42
 
43
  <?php include(NestedPages\Helpers::view('partials/tool-list')); ?>
65
 
66
  </div><!-- .wrap -->
67
 
68
+ <?php
69
+ include( NestedPages\Helpers::view('forms/empty-trash-modal') );
70
+ include( NestedPages\Helpers::view('forms/clone-form') );
71
+ include( NestedPages\Helpers::view('forms/link-form') );
72
+ include( NestedPages\Helpers::view('forms/bulk-add') );
73
+ include( NestedPages\Helpers::view('forms/delete-confirmation-modal') );
app/Views/partials/row-link.php CHANGED
@@ -69,7 +69,7 @@ $link = ( $this->post->nav_type && $this->post->nav_type !== 'custom' )
69
  </a>
70
 
71
  <?php if ( current_user_can('delete_pages') ) : ?>
72
- <a href="<?php echo get_delete_post_link($this->post->id, '', true); ?>" class="np-btn np-btn-trash">
73
  <i class="np-icon-remove"></i>
74
  </a>
75
  <?php endif; ?>
69
  </a>
70
 
71
  <?php if ( current_user_can('delete_pages') ) : ?>
72
+ <a href="<?php echo get_delete_post_link($this->post->id, '', true); ?>" class="np-btn np-btn-trash" data-np-confirm-delete>
73
  <i class="np-icon-remove"></i>
74
  </a>
75
  <?php endif; ?>
assets/js/lib/nestedpages.confirm-delete.js ADDED
@@ -0,0 +1,47 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /**
2
+ * Confirm deletion of a link
3
+ * @package Nested Pages
4
+ * @author Kyle Phillips - https://github.com/kylephillips/wp-nested-pages
5
+ */
6
+ jQuery(document).ready(function(){
7
+ new NestedPagesConfirmDelete;
8
+ });
9
+
10
+ var NestedPagesConfirmDelete = function()
11
+ {
12
+ var plugin = this;
13
+ var $ = jQuery;
14
+
15
+ // DOM Selectors
16
+ plugin.deleteButton = '[data-np-confirm-delete]'; // delete button
17
+ plugin.confirmButton = '[data-delete-confirmation]'; // Confirm button in modal
18
+ plugin.warningModal = '#np-delete-confirmation-modal'; // Modal with empty confirmation
19
+
20
+ // JS Data
21
+ plugin.deleteLink = ''; // Link for deleting the item
22
+
23
+ // Initialization
24
+ plugin.init = function(){
25
+ plugin.bindEvents();
26
+ }
27
+
28
+ // Bind Events
29
+ plugin.bindEvents = function(){
30
+ $(document).on('click', plugin.deleteButton, function(e){
31
+ e.preventDefault();
32
+ plugin.deleteLink = $(this).attr('href');
33
+ $(plugin.warningModal).modal('show');
34
+ });
35
+ $(document).on('click', plugin.confirmButton, function(e){
36
+ e.preventDefault();
37
+ plugin.confirmEmpty();
38
+ });
39
+ }
40
+
41
+ // Confirm Trash Empty
42
+ plugin.confirmEmpty = function(){
43
+ window.location.replace(plugin.deleteLink);
44
+ }
45
+
46
+ return plugin.init();
47
+ }
assets/js/lib/nestedpages.formatter.js CHANGED
@@ -20,10 +20,19 @@ NestedPages.Formatter = function()
20
  var button = allButtons[i];
21
  var row = $(button).parent('.row').parent('li');
22
  if ( $(row).children('ol').length > 0 ){ // Row has a child menu
 
23
  var icon = ( $(row).children('ol:visible').length > 0 )
24
  ? NestedPages.cssClasses.iconToggleDown
25
  : NestedPages.cssClasses.iconToggleRight;
 
26
  $(button).html('<a href="#"><i class="' + icon + '"></i></a>');
 
 
 
 
 
 
 
27
  continue;
28
  }
29
  $(button).empty(); // No Child Menu
20
  var button = allButtons[i];
21
  var row = $(button).parent('.row').parent('li');
22
  if ( $(row).children('ol').length > 0 ){ // Row has a child menu
23
+
24
  var icon = ( $(row).children('ol:visible').length > 0 )
25
  ? NestedPages.cssClasses.iconToggleDown
26
  : NestedPages.cssClasses.iconToggleRight;
27
+
28
  $(button).html('<a href="#"><i class="' + icon + '"></i></a>');
29
+
30
+ if ( ($(row).children('ol').children('.np-hide').length > 0) && ($(row).children('ol').children('.np-hide.shown').length === 0) ){
31
+ $(button).find('a').hide();
32
+ } else if ( ($(row).children('ol').children('.np-hide').length > 0) && ($(row).children('ol').children('.np-hide.shown').length > 0) ){
33
+ $(button).find('a').show();
34
+ }
35
+
36
  continue;
37
  }
38
  $(button).empty(); // No Child Menu
assets/js/lib/nestedpages.new-page.js CHANGED
@@ -65,7 +65,7 @@ NestedPages.NewPage = function()
65
  $(NestedPages.selectors.newPageModal).find('.modal-body').html(newform);
66
  $(NestedPages.selectors.newPageModal).find('h3').text(nestedpages.add_multiple);
67
  $(NestedPages.selectors.newPageModal).find('.page_parent_id').val(plugin.parent_id);
68
- $(NestedPages.selectors.newPageModal).modal('show');
69
  }
70
 
71
 
@@ -90,6 +90,7 @@ NestedPages.NewPage = function()
90
  $(newform).find('.parent_name').html('<em>Parent:</em> ' + $(button).attr('data-parentname'));
91
  $(newform).find('.page_parent_id').val($(button).attr('data-id'));
92
  $(newform).show();
 
93
  }
94
 
95
 
@@ -107,9 +108,11 @@ NestedPages.NewPage = function()
107
  // Add a page title field to the form
108
  plugin.addTitleField = function(button)
109
  {
110
- var form = $(button).parents('form');
111
- var html = '<li><i class="handle np-icon-menu"></i><div class="form-control new-child-row"><label>' + NestedPages.jsData.titleText + '</label><div><input type="text" name="post_title[]" class="np_title" placeholder="' + NestedPages.jsData.titleText + '" value="" /><a href="#" class="button-secondary np-remove-child">-</a></div></div></li>';
 
112
  var container = $(button).siblings('.new-page-titles').append(html);
 
113
  $('.new-page-titles').sortable({
114
  items : 'li',
115
  handle: '.handle',
65
  $(NestedPages.selectors.newPageModal).find('.modal-body').html(newform);
66
  $(NestedPages.selectors.newPageModal).find('h3').text(nestedpages.add_multiple);
67
  $(NestedPages.selectors.newPageModal).find('.page_parent_id').val(plugin.parent_id);
68
+ $(NestedPages.selectors.newPageModal).modal('show');
69
  }
70
 
71
 
90
  $(newform).find('.parent_name').html('<em>Parent:</em> ' + $(button).attr('data-parentname'));
91
  $(newform).find('.page_parent_id').val($(button).attr('data-id'));
92
  $(newform).show();
93
+ $(newform).find('.np_title').focus();
94
  }
95
 
96
 
108
  // Add a page title field to the form
109
  plugin.addTitleField = function(button)
110
  {
111
+ var form = $(button).parents('form');
112
+ var fieldcount = $(button).siblings('.new-page-titles').children('li').length + 1;
113
+ var html = '<li><i class="handle np-icon-menu"></i><div class="form-control new-child-row"><label>' + NestedPages.jsData.titleText + '</label><div><input type="text" name="post_title[]" class="np_title" placeholder="' + NestedPages.jsData.titleText + '" value="" tabindex="' + fieldcount + '" /><a href="#" class="button-secondary np-remove-child">-</a></div></div></li>';
114
  var container = $(button).siblings('.new-page-titles').append(html);
115
+ $(form).find('.np_title').last().focus();
116
  $('.new-page-titles').sortable({
117
  items : 'li',
118
  handle: '.handle',
assets/js/lib/nestedpages.page-toggle.js CHANGED
@@ -38,11 +38,13 @@ NestedPages.PageToggle = function()
38
  if ( action === 'show' ){
39
  $(button).attr('href', 'hide').text(NestedPages.jsData.showHiddenText);
40
  $(NestedPages.selectors.hiddenRows).removeClass('shown').hide();
 
41
  plugin.formatter.setBorders();
42
  return;
43
  }
44
  $(button).attr('href', 'show').text(NestedPages.jsData.hideHiddenText);
45
  $(NestedPages.selectors.hiddenRows).addClass('shown').show();
 
46
  plugin.formatter.setBorders();
47
  }
48
 
38
  if ( action === 'show' ){
39
  $(button).attr('href', 'hide').text(NestedPages.jsData.showHiddenText);
40
  $(NestedPages.selectors.hiddenRows).removeClass('shown').hide();
41
+ plugin.formatter.updateSubMenuToggle();
42
  plugin.formatter.setBorders();
43
  return;
44
  }
45
  $(button).attr('href', 'show').text(NestedPages.jsData.hideHiddenText);
46
  $(NestedPages.selectors.hiddenRows).addClass('shown').show();
47
+ plugin.formatter.updateSubMenuToggle();
48
  plugin.formatter.setBorders();
49
  }
50
 
assets/js/nestedpages.min.js CHANGED
@@ -1,2301 +1,2 @@
1
- var NestedPages = NestedPages || {};
2
-
3
- /**
4
- * Responsive functionality for nested view
5
- * @package Nested Pages
6
- * @author Kyle Phillips - https://github.com/kylephillips/wp-nested-pages
7
- */
8
- NestedPages.Responsive = function()
9
- {
10
- var plugin = this;
11
- var $ = jQuery;
12
-
13
- plugin.init = function()
14
- {
15
- plugin.bindEvents();
16
- }
17
-
18
- plugin.bindEvents = function()
19
- {
20
- $(document).on('click', NestedPages.selectors.toggleEditButtons, function(e){
21
- e.preventDefault();
22
- plugin.toggleEdit($(this));
23
- });
24
- // Remove the block display when sizing up
25
- $(window).resize(function() {
26
- plugin.timer(function(){
27
- $('.action-buttons').removeAttr('style');
28
- $('.np-toggle-edit').removeClass('active');
29
- }, 500);
30
- });
31
- }
32
-
33
- // Toggle the responsive edit buttons
34
- plugin.toggleEdit = function(button)
35
- {
36
- var buttons = $(button).siblings('.action-buttons');
37
- if ( $(buttons).is(':visible') ){
38
- $(button).removeClass('active');
39
- $(buttons).hide();
40
- return;
41
- }
42
- $(button).addClass('active');
43
- $(buttons).show();
44
- }
45
-
46
- plugin.timer = (function(){
47
- var timer = 0;
48
- return function(callback, ms){
49
- clearTimeout (timer);
50
- timer = setTimeout(callback, ms);
51
- };
52
- })();
53
-
54
- return plugin.init();
55
- }
56
- var NestedPages = NestedPages || {};
57
-
58
- /**
59
- * Formatting updates
60
- * @package Nested Pages
61
- * @author Kyle Phillips - https://github.com/kylephillips/wp-nested-pages
62
- */
63
- NestedPages.Formatter = function()
64
- {
65
-
66
- var plugin = this;
67
- var $ = jQuery;
68
-
69
-
70
- // Update the Submenu Toggle Button State based on if the child menu is visible
71
- plugin.updateSubMenuToggle = function()
72
- {
73
- var allButtons = $(NestedPages.selectors.childToggle);
74
- for ( var i = 0; i < allButtons.length; i++ ){
75
- var button = allButtons[i];
76
- var row = $(button).parent('.row').parent('li');
77
- if ( $(row).children('ol').length > 0 ){ // Row has a child menu
78
- var icon = ( $(row).children('ol:visible').length > 0 )
79
- ? NestedPages.cssClasses.iconToggleDown
80
- : NestedPages.cssClasses.iconToggleRight;
81
- $(button).html('<a href="#"><i class="' + icon + '"></i></a>');
82
- continue;
83
- }
84
- $(button).empty(); // No Child Menu
85
- }
86
- }
87
-
88
-
89
- // Fix :visible :first css limitation when toggling various options
90
- plugin.setBorders = function()
91
- {
92
- $(NestedPages.selectors.rows).removeClass(NestedPages.cssClasses.noborder);
93
- $.each($(NestedPages.selectors.lists), function(){
94
- $(this).find('.page-row:visible:first').addClass(NestedPages.cssClasses.noborder);
95
- });
96
- }
97
-
98
-
99
- // Adjust nested margins based on how deep the list is nested
100
- plugin.setNestedMargins = function()
101
- {
102
- $.each($(NestedPages.selectors.lists), function(i, v){
103
- var parent_count = $(this).parents(NestedPages.selectors.lists).length;
104
- var padding = 56;
105
- if ( parent_count > 0 ){
106
- var padding = ( parent_count * 20 ) + padding;
107
- $(this).find('.row-inner').css('padding-left', padding + 'px');
108
- return;
109
- }
110
- $(this).find('.row-inner').css('padding-left', '0px');
111
- });
112
- }
113
-
114
-
115
- // Update the width of the placeholder ( width changes depending on level of nesting )
116
- plugin.updatePlaceholderWidth = function(ui)
117
- {
118
- if ( NestedPages.jsData.nestable ){
119
- var parentCount = $(ui.placeholder).parents('ol').length;
120
- var listWidth = $(NestedPages.selectors.sortable).width();
121
- var offset = ( parentCount * 40 ) - 40;
122
- var newWidth = listWidth - offset;
123
- $(ui.placeholder).width(newWidth).css('margin-left', offset + 'px');
124
- }
125
- plugin.updateListVisibility(ui);
126
- }
127
-
128
-
129
- // Update the list visibility on sort (prevent lists from collapsing when nesting)
130
- plugin.updateListVisibility = function(ui)
131
- {
132
- var parentList = $(ui.placeholder).parent('ol');
133
- if ( !$(parentList).is(':visible') ){
134
- $(parentList).addClass('nplist');
135
- $(parentList).show();
136
- }
137
- }
138
-
139
-
140
- // Remove the Quick Edit Overlay
141
- plugin.removeQuickEdit = function()
142
- {
143
- $(NestedPages.selectors.quickEditOverlay).removeClass('active').remove();
144
- $('.sortable .quick-edit').remove();
145
- $('.row').show();
146
- }
147
-
148
-
149
- // Show the Quick Edit Overlay
150
- plugin.showQuickEdit = function()
151
- {
152
- $('body').append('<div class="np-inline-overlay"></div>');
153
- setTimeout(function(){
154
- $('.np-inline-overlay').addClass('active');
155
- }, 50);
156
- }
157
-
158
-
159
- // Flash an updated row
160
- plugin.flashRow = function(row)
161
- {
162
- $(row).addClass('np-updated');
163
- plugin.setBorders();
164
- setTimeout(function(){
165
- $(row).addClass('np-updated-show');
166
- }, 1500);
167
- }
168
-
169
-
170
- }
171
- var NestedPages = NestedPages || {};
172
-
173
- /**
174
- * Toggles Menu Elements
175
- * @package Nested Pages
176
- * @author Kyle Phillips - https://github.com/kylephillips/wp-nested-pages
177
- */
178
- NestedPages.MenuToggle = function()
179
- {
180
- var plugin = this;
181
- var $ = jQuery;
182
-
183
- plugin.formatter = new NestedPages.Formatter;
184
-
185
- plugin.bindEvents = function()
186
- {
187
- $(document).on('click', NestedPages.selectors.childToggleLink, function(e){
188
- e.preventDefault();
189
- plugin.toggleSingleMenu($(this));
190
- });
191
- $(document).on('click', NestedPages.selectors.toggleAll, function(e){
192
- e.preventDefault();
193
- plugin.toggleAllMenus();
194
- });
195
- }
196
-
197
-
198
- // Toggle individual submenus
199
- plugin.toggleSingleMenu = function(button)
200
- {
201
- var submenu = $(button).parent(NestedPages.selectors.childToggle).parent(NestedPages.selectors.row).siblings('ol');
202
- $(button).find('i')
203
- .toggleClass(NestedPages.cssClasses.iconToggleDown)
204
- .toggleClass(NestedPages.cssClasses.iconToggleRight);
205
- $(submenu).toggle();
206
- plugin.formatter.setBorders();
207
- plugin.formatter.setNestedMargins();
208
- plugin.syncUserToggles();
209
- }
210
-
211
-
212
- // Toggle All Submenus
213
- plugin.toggleAllMenus = function()
214
- {
215
- var button = NestedPages.selectors.toggleAll;
216
- if ( $(button).attr('data-toggle') === 'closed' ){
217
- $(NestedPages.selectors.lists).show();
218
- $(button).attr('data-toggle', 'opened').text(NestedPages.jsData.collapseText);
219
- $(NestedPages.selectors.childToggle).find('i').removeClass(NestedPages.cssClasses.iconToggleRight).addClass(NestedPages.cssClasses.iconToggleDown);
220
- // revert_quick_edit();
221
- plugin.formatter.setBorders();
222
- plugin.syncUserToggles();
223
- return;
224
- }
225
-
226
- $(NestedPages.selectors.lists).not($(NestedPages.selectors.lists)[0]).hide();
227
- $(button).attr('data-toggle', 'closed').text(NestedPages.jsData.expandText);
228
- $(NestedPages.selectors.childToggle).find('i').removeClass(NestedPages.cssClasses.iconToggleDown).addClass(NestedPages.cssClasses.iconToggleRight);
229
- // revert_quick_edit();
230
- plugin.formatter.setBorders();
231
- plugin.syncUserToggles();
232
- }
233
-
234
-
235
- // Get an array of visible rows
236
- plugin.visibleRowIDs = function()
237
- {
238
- var visible_ids = [];
239
- var visible = $(NestedPages.selectors.rows + ':visible');
240
- $.each(visible, function(i, v){
241
- var id = $(this).attr('id');
242
- visible_ids.push(id.replace("menuItem_", ""));
243
- });
244
- return visible_ids;
245
- }
246
-
247
-
248
- // Save the user's toggled menus
249
- plugin.syncUserToggles = function()
250
- {
251
- $.ajax({
252
- url: NestedPages.jsData.ajaxurl,
253
- type: 'post',
254
- datatype: 'json',
255
- data: {
256
- action : NestedPages.formActions.syncToggles,
257
- nonce : NestedPages.jsData.nonce,
258
- ids : plugin.visibleRowIDs(),
259
- posttype : NestedPages.jsData.posttype
260
- },
261
- success: function(data){
262
- if ( data.status !== 'success' ){
263
- console.log('There was an error saving toggled pages.');
264
- }
265
- }
266
- });
267
- }
268
-
269
-
270
- return plugin.bindEvents();
271
- }
272
- var NestedPages = NestedPages || {};
273
-
274
- /**
275
- * Toggle Page Rows
276
- * @package Nested Pages
277
- * @author Kyle Phillips - https://github.com/kylephillips/wp-nested-pages
278
- */
279
- NestedPages.PageToggle = function()
280
- {
281
- var plugin = this;
282
- var $ = jQuery;
283
-
284
- plugin.formatter = new NestedPages.Formatter;
285
-
286
- plugin.init = function()
287
- {
288
- plugin.bindEvents();
289
- }
290
-
291
- plugin.bindEvents = function()
292
- {
293
- $(document).on('click', NestedPages.selectors.toggleHidden, function(e){
294
- e.preventDefault();
295
- plugin.toggleHidden();
296
- });
297
- $(document).on('click', NestedPages.selectors.toggleStatus, function(e){
298
- e.preventDefault();
299
- plugin.toggleStatus($(this));
300
- });
301
- }
302
-
303
-
304
- // Toggle Hidden Pages
305
- plugin.toggleHidden = function()
306
- {
307
- var button = NestedPages.selectors.toggleHidden;
308
- var action = $(button).attr('href');
309
- if ( action === 'show' ){
310
- $(button).attr('href', 'hide').text(NestedPages.jsData.showHiddenText);
311
- $(NestedPages.selectors.hiddenRows).removeClass('shown').hide();
312
- plugin.formatter.setBorders();
313
- return;
314
- }
315
- $(button).attr('href', 'show').text(NestedPages.jsData.hideHiddenText);
316
- $(NestedPages.selectors.hiddenRows).addClass('shown').show();
317
- plugin.formatter.setBorders();
318
- }
319
-
320
-
321
- // Toggle Pages based on status
322
- plugin.toggleStatus = function(button)
323
- {
324
- var target = $(button).attr('href');
325
- target = target.substring(1);
326
- $(NestedPages.selectors.toggleStatus).removeClass('active');
327
- $(button).addClass('active');
328
- if ( target == 'all' ){
329
- $(NestedPages.selectors.rows).show();
330
- return;
331
- }
332
- $(NestedPages.selectors.rows).hide();
333
- $('.' + target).show();
334
- return;
335
-
336
- }
337
-
338
-
339
- return plugin.init();
340
-
341
- }
342
- var NestedPages = NestedPages || {};
343
-
344
- /**
345
- * Enables and Saves Nesting
346
- * @package Nested Pages
347
- * @author Kyle Phillips - https://github.com/kylephillips/wp-nested-pages
348
- */
349
- NestedPages.Nesting = function()
350
- {
351
- var plugin = this;
352
- var $ = jQuery;
353
-
354
- plugin.formatter = new NestedPages.Formatter;
355
-
356
-
357
- // Make the Menu sortable
358
- plugin.initializeSortable = function()
359
- {
360
- maxLevels = ( NestedPages.jsData.nestable ) ? 0 : 1;
361
- $(NestedPages.selectors.sortable).not(NestedPages.selectors.notSortable).nestedSortable({
362
- items : NestedPages.selectors.rows,
363
- toleranceElement: '> .row',
364
- handle: NestedPages.selectors.handle,
365
- placeholder: "ui-sortable-placeholder",
366
- maxLevels: maxLevels,
367
- tabSize : 56,
368
- start: function(e, ui){
369
- ui.placeholder.height(ui.item.height());
370
- },
371
- sort: function(e, ui){
372
- plugin.formatter.updatePlaceholderWidth(ui);
373
- },
374
- stop: function(e, ui){
375
- setTimeout(
376
- function(){
377
- plugin.formatter.updateSubMenuToggle();
378
- plugin.formatter.setBorders();
379
- plugin.formatter.setNestedMargins();
380
- }, 100
381
- );
382
- plugin.syncNesting();
383
- },
384
- });
385
- }
386
-
387
-
388
- // Disable Nesting
389
- plugin.disableNesting = function()
390
- {
391
- $(NestedPages.selectors.sortable).sortable('destroy');
392
- }
393
-
394
-
395
- // Sync Nesting
396
- plugin.syncNesting = function()
397
- {
398
- $(NestedPages.selectors.errorDiv).hide();
399
- $(NestedPages.selectors.loadingIndicator).show();
400
-
401
- list = $(NestedPages.selectors.sortable).nestedSortable('toHierarchy', {startDepthCount: 0});
402
- plugin.disableNesting();
403
-
404
- $.ajax({
405
- url: ajaxurl,
406
- type: 'post',
407
- datatype: 'json',
408
- data: {
409
- action : NestedPages.formActions.syncNesting,
410
- nonce : NestedPages.jsData.nonce,
411
- list : list,
412
- post_type : NestedPages.jsData.posttype,
413
- syncmenu : NestedPages.jsData.syncmenu
414
- },
415
- success: function(data){
416
- plugin.initializeSortable();
417
- if (data.status === 'error'){
418
- $(NestedPages.selectors.errorDiv).text(data.message).show();
419
- $(NestedPages.selectors.loadingIndicator).hide();
420
- } else {
421
- $(NestedPages.selectors.loadingIndicator).hide();
422
- }
423
- }
424
- });
425
- }
426
-
427
- }
428
- var NestedPages = NestedPages || {};
429
-
430
- /**
431
- * Sync the "sync menu" setting
432
- * @package Nested Pages
433
- * @author Kyle Phillips - https://github.com/kylephillips/wp-nested-pages
434
- */
435
- NestedPages.SyncMenuSetting = function()
436
- {
437
- var plugin = this;
438
- var $ = jQuery;
439
-
440
- plugin.init = function()
441
- {
442
- plugin.bindEvents();
443
- }
444
-
445
- plugin.bindEvents = function()
446
- {
447
- $(document).ready(function(){ // catches trash updates
448
- if ( nestedpages.syncmenu === '1' ) plugin.syncSetting();
449
- });
450
- $(document).on('change', NestedPages.selectors.syncCheckbox, function(){
451
- plugin.syncSetting();
452
- });
453
- }
454
-
455
- // Sync the "Sync menu" preference / setting
456
- plugin.syncSetting = function()
457
- {
458
-
459
- if ( NestedPages.jsData.posttype !== 'page' ) return;
460
- if ($(NestedPages.selectors.syncCheckbox).length === 0) return;
461
-
462
- NestedPages.jsData.syncmenu = ( $(NestedPages.selectors.syncCheckbox).is(':checked') ) ? 'sync' : 'nosync';
463
-
464
- $.ajax({
465
- url: NestedPages.jsData.ajaxurl,
466
- type: 'post',
467
- datatype: 'json',
468
- data: {
469
- action : NestedPages.formActions.syncMenu,
470
- nonce : NestedPages.jsData.nonce,
471
- post_type : NestedPages.jsData.posttype,
472
- syncmenu : NestedPages.jsData.syncmenu
473
- },
474
- success: function(data){
475
- if (data.status === 'error'){
476
- alert('There was an error saving the sync setting.')
477
- }
478
- },
479
- });
480
- }
481
-
482
- return plugin.bindEvents();
483
- }
484
- var NestedPages = NestedPages || {};
485
-
486
- /**
487
- * Add new page(s) - Top level & child
488
- * @package Nested Pages
489
- * @author Kyle Phillips - https://github.com/kylephillips/wp-nested-pages
490
- */
491
- NestedPages.NewPage = function()
492
- {
493
- var plugin = this;
494
- var $ = jQuery;
495
-
496
- plugin.formatter = new NestedPages.Formatter;
497
- plugin.parent_id = 0; // Parent ID for the post(s) to add
498
- plugin.posts = ''; // The newly added posts
499
- plugin.form = ''; // The active form
500
-
501
-
502
- plugin.init = function()
503
- {
504
- plugin.bindEvents();
505
- }
506
-
507
-
508
- plugin.bindEvents = function()
509
- {
510
- $(document).on('click', NestedPages.selectors.openPageModal, function(e){
511
- e.preventDefault();
512
- plugin.openModal();
513
- });
514
- $(document).on('submit', NestedPages.selectors.newPageForm, function(e){
515
- e.preventDefault();
516
- });
517
- $(document).on('click', NestedPages.selectors.newPageSubmitButton, function(e){
518
- e.preventDefault();
519
- plugin.submitForm($(this));
520
- });
521
- $(document).on('click', NestedPages.selectors.newPageTitle, function(e){
522
- e.preventDefault();
523
- plugin.addTitleField($(this));
524
- });
525
- $(document).on('click', NestedPages.selectors.newPageRemoveTitle, function(e){
526
- e.preventDefault();
527
- plugin.removeTitleField($(this));
528
- });
529
- $(document).on('click', NestedPages.selectors.addChildButton, function(e){
530
- e.preventDefault();
531
- plugin.openQuickEdit($(this));
532
- });
533
- $(NestedPages.selectors.newPageModal).on('hide.bs.modal', function(){
534
- plugin.cancelNewPage();
535
- });
536
- $(document).on('click', NestedPages.selectors.cancelNewChildButton, function(e){
537
- e.preventDefault();
538
- plugin.cancelNewPage();
539
- $(NestedPages.selectors.newPageModal).modal('hide');
540
- });
541
- }
542
-
543
-
544
- // Open the form modal
545
- plugin.openModal = function()
546
- {
547
- var newform = $(NestedPages.selectors.newPageFormContainer).clone().find(NestedPages.selectors.newPageForm).addClass('in-modal');
548
- $(NestedPages.selectors.newPageModal).find('.modal-body').html(newform);
549
- $(NestedPages.selectors.newPageModal).find('h3').text(nestedpages.add_multiple);
550
- $(NestedPages.selectors.newPageModal).find('.page_parent_id').val(plugin.parent_id);
551
- $(NestedPages.selectors.newPageModal).modal('show');
552
- }
553
-
554
-
555
- // Open the new child quick edit
556
- plugin.openQuickEdit = function(button)
557
- {
558
- var parent_li = $(button).closest(NestedPages.selectors.row).parent('li');
559
- var newform = $(NestedPages.selectors.newPageFormContainer).clone();
560
-
561
- // Append the form to the list item
562
- if ( $(parent_li).children('ol').length > 0 ){
563
- var child_ol = $(parent_li).children('ol');
564
- $(newform).insertBefore(child_ol);
565
- } else {
566
- $(newform).appendTo(parent_li);
567
- }
568
-
569
- $(newform).siblings(NestedPages.selectors.row).hide();
570
-
571
- plugin.formatter.showQuickEdit();
572
-
573
- $(newform).find('.parent_name').html('<em>Parent:</em> ' + $(button).attr('data-parentname'));
574
- $(newform).find('.page_parent_id').val($(button).attr('data-id'));
575
- $(newform).show();
576
- }
577
-
578
-
579
- // Close the form modal
580
- plugin.cancelNewPage = function()
581
- {
582
- plugin.formatter.removeQuickEdit();
583
- $(NestedPages.selectors.newChildError).hide();
584
- $(NestedPages.selectors.newPageModal).find('.modal-body').empty();
585
- $(NestedPages.selectors.sortable).find('.new-child').remove();
586
- $(NestedPages.selectors.row).show();
587
- }
588
-
589
-
590
- // Add a page title field to the form
591
- plugin.addTitleField = function(button)
592
- {
593
- var form = $(button).parents('form');
594
- var html = '<li><i class="handle np-icon-menu"></i><div class="form-control new-child-row"><label>' + NestedPages.jsData.titleText + '</label><div><input type="text" name="post_title[]" class="np_title" placeholder="' + NestedPages.jsData.titleText + '" value="" /><a href="#" class="button-secondary np-remove-child">-</a></div></div></li>';
595
- var container = $(button).siblings('.new-page-titles').append(html);
596
- $('.new-page-titles').sortable({
597
- items : 'li',
598
- handle: '.handle',
599
- });
600
- }
601
-
602
-
603
- // Remove a page title field
604
- plugin.removeTitleField = function(button)
605
- {
606
- $(button).parents('.new-child-row').parent('li').remove();
607
- }
608
-
609
-
610
- // Submit the New Page Form
611
- plugin.submitForm = function(button)
612
- {
613
- plugin.toggleLoading(true);
614
- plugin.form = $(button).parents('form');
615
-
616
- var addedit = ( $(button).hasClass('add-edit') ) ? true : false;
617
-
618
- $.ajax({
619
- url: NestedPages.jsData.ajaxurl,
620
- type: 'post',
621
- datatype: 'json',
622
- data: $(plugin.form).serialize() + '&action=' + NestedPages.formActions.newPage + '&nonce=' + NestedPages.jsData.nonce + '&syncmenu=' + NestedPages.jsData.syncmenu + '&post_type=' + NestedPages.jsData.posttype,
623
- success: function(data){
624
- if (data.status === 'error'){
625
- plugin.toggleLoading(false);
626
- $(plugin.form).find(NestedPages.selectors.quickEditErrorDiv).text(data.message).show();
627
- return;
628
- }
629
- if ( addedit === true ){ // Redirect to Edit Screen
630
- var link = data.new_pages[0].edit_link;
631
- link = link.replace(/&amp;/g, '&');
632
- window.location.replace(link);
633
- return;
634
- }
635
- plugin.toggleLoading(false);
636
- plugin.posts = data.new_pages;
637
- plugin.addPosts();
638
- },
639
- error: function(){
640
- plugin.toggleLoading(false);
641
- $(form).find(NestedPages.selectors.quickEditErrorDiv).text('The form could not be saved at this time.').show();
642
- }
643
- });
644
- }
645
-
646
-
647
- // Add the new posts
648
- plugin.addPosts = function()
649
- {
650
- var parent_li = $(plugin.form).parent('.new-child').parent('.page-row');
651
-
652
- // If parent li doesn't have a child ol, add one
653
- if ( $(parent_li).children('ol').length === 0 ){
654
- $(parent_li).append('<ol class="nplist"></ol>');
655
- }
656
-
657
- if ( $(plugin.form).hasClass('in-modal') ){
658
- var appendto = $('.nplist.sortable li.page-row:first');
659
- } else {
660
- var appendto = $(parent_li).children('ol');
661
- }
662
-
663
- for (i = 0; i < plugin.posts.length; i++){
664
- plugin.appendRows(appendto, plugin.posts[i]);
665
- }
666
-
667
- // Show the child page list and reset submenu toggles
668
- $(appendto).show();
669
- plugin.formatter.updateSubMenuToggle();
670
- plugin.cancelNewPage();
671
- $(NestedPages.selectors.newPageModal).modal('hide');
672
- }
673
-
674
-
675
- // Append new post rows to the nested view
676
- plugin.appendRows = function(appendto, post)
677
- {
678
- var html = '<li id="menuItem_' + post.id + '" class="page-row';
679
- if ( post.status === 'publish' ) html += ' published';
680
- html += '">';
681
-
682
- if ( NestedPages.jsData.hierarchical ){
683
- html += '<div class="row">';
684
- html += '<div class="child-toggle"></div>';
685
- } else {
686
- html += '<div class="row non-hierarchical">';
687
- }
688
-
689
- html += '<div class="row-inner">';
690
- html += '<i class="np-icon-sub-menu"></i><i class="handle np-icon-menu"></i>';
691
- html += '<a href="' + post.edit_link + '" class="page-link page-title">';
692
- html += '<span class="title">' + post.title + '</span>';
693
-
694
- // Status
695
- if ( post.status !== 'Publish' ){
696
- html += '<span class="status">(' + post.status + ')</span>';
697
- } else {
698
- html += '<span class="status"></span>';
699
- }
700
-
701
- html += '<span class="nav-status"></span><span class="edit-indicator"><i class="np-icon-pencil"></i>Edit</span>';
702
- html += '</a>';
703
-
704
- // Action Buttons
705
- html += '<div class="action-buttons">';
706
- html += '<a href="#" class="np-btn open-redirect-modal" data-parentid="' + post.id + '"><i class="np-icon-link"></i></a>';
707
- html += '<a href="#" class="np-btn add-new-child" data-id="' + post.id + '" data-parentname="' + post.title + '">' + nestedpages.add_child_short + '</a>';
708
-
709
- // Quick Edit (data attrs)
710
- html += '<a href="#" class="np-btn np-quick-edit" data-id="' + post.id + '" data-template="' + post.page_template + '" data-title="' + post.title + '" data-slug="' + post.slug + '" data-commentstatus="closed" data-status="' + post.status.toLowerCase() + '" data-np-status="show" data-navstatus="show" data-author="' + post.author + '" data-template="' + post.template + '" data-month="' + post.month + '" data-day="' + post.day + '" data-year="' + post.year + '" data-hour="' + post.hour + '" data-minute="' + post.minute + '" data-datepicker="' + post.datepicker + '" data-time="' + post.time + '" data-formattedtime="' + post.formattedtime + '" data-ampm="' + post.ampm + '">' + nestedpages.quick_edit + '</a>';
711
-
712
- html += '<a href="' + post.view_link + '" class="np-btn" target="_blank">' + nestedpages.view + '</a>';
713
- html += '<a href="' + post.delete_link + '" class="np-btn np-btn-trash"><i class="np-icon-remove"></i></a>';
714
- html += '</div><!-- .action-buttons -->';
715
-
716
- html += '</div><!-- .row-inner --></div><!-- .row -->';
717
- html += '</li>';
718
-
719
- $(appendto).append(html);
720
- }
721
-
722
-
723
-
724
- // Toggle the form loading state
725
- plugin.toggleLoading = function(loading)
726
- {
727
- if ( loading ){
728
- $(NestedPages.selectors.quickEditErrorDiv).hide();
729
- $(NestedPages.selectors.newPageSubmitButton).attr('disabled', 'disabled');
730
- $(NestedPages.selectors.quickEditLoadingIndicator).show();
731
- return;
732
- }
733
- $(NestedPages.selectors.newPageSubmitButton).attr('disabled', false);
734
- $(NestedPages.selectors.quickEditLoadingIndicator).hide();
735
- }
736
-
737
-
738
-
739
- return plugin.init();
740
- }
741
- var NestedPages = NestedPages || {};
742
-
743
- /**
744
- * Quick Edit functionality for posts
745
- * @package Nested Pages
746
- * @author Kyle Phillips - https://github.com/kylephillips/wp-nested-pages
747
- */
748
- NestedPages.QuickEditPost = function()
749
- {
750
- var plugin = this;
751
- var $ = jQuery;
752
-
753
- plugin.formatter = new NestedPages.Formatter;
754
- plugin.button = ''; // The quick edit button
755
- plugin.initialData = ''; // The unedited post data
756
- plugin.parent_li = ''; // The post's nested pages list element
757
- plugin.form = ''; // The newly created form
758
- plugin.flatTerms = ''; // Object containing flat taxonomy IDs
759
- plugin.termNames = ''; // Flat Taxonomy Term Names
760
- plugin.saveButton = ''; // Save button
761
- plugin.newData = ''; // New Data, after save
762
- plugin.row = ''; // The row being edited
763
-
764
-
765
- plugin.init = function()
766
- {
767
- plugin.bindEvents();
768
- }
769
-
770
-
771
- plugin.bindEvents = function()
772
- {
773
- $(document).on('click', NestedPages.selectors.quickEditOpen, function(e){
774
- e.preventDefault();
775
- plugin.button = $(this);
776
- plugin.openForm();
777
- });
778
- $(document).on('click', NestedPages.selectors.quickEditCancel, function(e){
779
- e.preventDefault();
780
- plugin.formatter.removeQuickEdit();
781
- });
782
- $(document).on('click', NestedPages.selectors.quickEditToggleTaxonomies, function(e){
783
- e.preventDefault();
784
- $(this).parents('form').find('.np-taxonomies').toggle();
785
- });
786
- $(document).on('click', NestedPages.selectors.quickEditToggleMenuOptions, function(e){
787
- e.preventDefault();
788
- $(this).parents('form').find('.np-menuoptions').toggle();
789
- });
790
- $(document).on('change', '.keep_private', function(){
791
- if ( this.checked ){
792
- $('.post_password').val('').prop('readonly', true);
793
- } else {
794
- $('.post_password').prop('readonly', false);
795
- }
796
- });
797
- $(document).on('click', NestedPages.selectors.quickEditSaveButton, function(e){
798
- e.preventDefault();
799
- plugin.saveButton = $(this);
800
- plugin.save();
801
- });
802
- $(document).on('keydown', function(e){
803
- if ( e.keyCode === 27 ) plugin.formatter.removeQuickEdit();
804
- });
805
- }
806
-
807
-
808
- // Create and open the quick edit form
809
- plugin.openForm = function()
810
- {
811
- plugin.setInitialData();
812
- plugin.createForm();
813
- plugin.populateForm();
814
- plugin.populateFlatTaxonomies();
815
- }
816
-
817
-
818
- // Set the unedited initial data
819
- plugin.setInitialData = function()
820
- {
821
- plugin.initialData = {
822
- id : $(plugin.button).attr('data-id'),
823
- title : $(plugin.button).attr('data-title'),
824
- slug : $(plugin.button).attr('data-slug'),
825
- author : $(plugin.button).attr('data-author'),
826
- cs : $(plugin.button).attr('data-commentstatus'),
827
- status : $(plugin.button).attr('data-status'),
828
- template : $(plugin.button).attr('data-template'),
829
- month : $(plugin.button).attr('data-month'),
830
- day : $(plugin.button).attr('data-day'),
831
- year : $(plugin.button).attr('data-year'),
832
- hour : $(plugin.button).attr('data-hour'),
833
- minute : $(plugin.button).attr('data-minute'),
834
- navstatus : $(plugin.button).attr('data-navstatus'),
835
- npstatus : $(plugin.button).attr('data-np-status'),
836
- navtitle : $(plugin.button).attr('data-navtitle'),
837
- navtitleattr : $(plugin.button).attr('data-navtitleattr'),
838
- navcss : $(plugin.button).attr('data-navcss'),
839
- linktarget : $(plugin.button).attr('data-linktarget'),
840
- password : $(plugin.button).attr('data-password'),
841
- datepicker : $(plugin.button).attr('data-datepicker'),
842
- time: $(plugin.button).attr('data-formattedtime'),
843
- ampm: $(plugin.button).attr('data-ampm')
844
- };
845
-
846
- // Add Array of Taxonomies to the data object using classes applied to the list element
847
- plugin.initialData.h_taxonomies = [];
848
- plugin.initialData.f_taxonomies = [];
849
-
850
- plugin.parent_li = $(plugin.button).closest(NestedPages.selectors.row).parent('li');
851
- var classes = $(plugin.parent_li).attr('class').split(/\s+/);
852
- for ( i = 0; i < classes.length; i++ ){
853
- if ( classes[i].substring(0, 3) === 'in-'){
854
- plugin.initialData.h_taxonomies.push(classes[i]);
855
- }
856
- if ( classes[i].substring(0, 4) === 'inf-' ){
857
- plugin.initialData.f_taxonomies.push(classes[i]);
858
- }
859
- }
860
- }
861
-
862
-
863
- // Create the form and append it to the row
864
- plugin.createForm = function()
865
- {
866
- plugin.form = $(NestedPages.selectors.quickEditPostForm).clone();
867
- if ( $(plugin.parent_li).children('ol').length > 0 ){
868
- var child_ol = $(plugin.parent_li).children('ol');
869
- $(plugin.form).insertBefore(child_ol);
870
- } else {
871
- $(plugin.form).appendTo(plugin.parent_li);
872
- }
873
- $(plugin.form).siblings(NestedPages.selectors.row).hide();
874
- $(plugin.form).show();
875
- }
876
-
877
-
878
- // Populate the new quick edit form
879
- plugin.populateForm = function()
880
- {
881
- $(plugin.form).find('.page_id').html('<em>ID:</em> ' + plugin.initialData.id);
882
- $(plugin.form).find('.np_id').val(plugin.initialData.id);
883
- $(plugin.form).find('.np_title').val(plugin.initialData.title);
884
- $(plugin.form).find('.np_slug').val(plugin.initialData.slug);
885
- $(plugin.form).find('.np_author select').val(plugin.initialData.author);
886
- $(plugin.form).find('.np_status').val(plugin.initialData.status);
887
- $(plugin.form).find('.np_nav_title').val(plugin.initialData.navtitle);
888
- $(plugin.form).find('.np_title_attribute').val(plugin.initialData.navtitleattr);
889
- $(plugin.form).find('.np_nav_css_classes').val(plugin.initialData.navcss);
890
- $(plugin.form).find('.post_password').val(plugin.initialData.password);
891
- $(plugin.form).find('.np_datepicker').val(plugin.initialData.datepicker);
892
- $(plugin.form).find('.np_time').val(plugin.initialData.time);
893
- $(plugin.form).find('.np_ampm').val(plugin.initialData.ampm);
894
- if ( plugin.initialData.cs === 'open' ) $(plugin.form).find('.np_cs').attr('checked', 'checked');
895
-
896
- if ( plugin.initialData.template !== '' ){
897
- $(plugin.form).find('.np_template').val(plugin.initialData.template);
898
- } else {
899
- $(plugin.form).find('.np_template').val('default');
900
- }
901
-
902
- if ( plugin.initialData.status === 'private' ){
903
- $(plugin.form).find('.post_password').attr('readonly', true);
904
- $(plugin.form).find('.keep_private').attr('checked', true);
905
- }
906
-
907
- if ( plugin.initialData.npstatus === 'hide' ){
908
- $(plugin.form).find('.np_status').attr('checked', 'checked');
909
- } else {
910
- $(plugin.form).find('.np_status').removeAttr('checked');
911
- }
912
-
913
- if ( plugin.initialData.navstatus === 'hide' ) {
914
- $(plugin.form).find('.np_nav_status').attr('checked', 'checked');
915
- } else {
916
- $(plugin.form).find('.np_nav_status').attr('checked', false);
917
- }
918
-
919
- if ( plugin.initialData.linktarget === "_blank" ) {
920
- $(plugin.form).find('.link_target').attr('checked', 'checked');
921
- } else {
922
- $(plugin.form).find('.link_target').attr('checked', false);
923
- }
924
-
925
- if ( plugin.initialData.status === "private" ) {
926
- $(plugin.form).find('.np_status').val('publish');
927
- }
928
-
929
- // Date Fields
930
- $(plugin.form).find('select[name="mm"]').val(plugin.initialData.month);
931
- $(plugin.form).find('input[name="jj"]').val(plugin.initialData.day);
932
- $(plugin.form).find('input[name="aa"]').val(plugin.initialData.year);
933
- $(plugin.form).find('input[name="hh"]').val(plugin.initialData.hour);
934
- $(plugin.form).find('input[name="mn"]').val(plugin.initialData.minute);
935
-
936
- // Populate Hierarchical Taxonomy Checkboxes
937
- if ( plugin.initialData.hasOwnProperty('h_taxonomies') ){
938
- var taxonomies = plugin.initialData.h_taxonomies;
939
- for ( i = 0; i < taxonomies.length; i++ ){
940
- var tax = '#' + taxonomies[i];
941
- $(plugin.form).find(tax).attr('checked', 'checked');
942
- }
943
- }
944
-
945
- $(plugin.form).find('.np_datepicker').datepicker({
946
- beforeShow: function(input, inst) {
947
- $('#ui-datepicker-div').addClass('nestedpages-datepicker');
948
- }
949
- });
950
-
951
- plugin.formatter.showQuickEdit();
952
- $(plugin.form).show();
953
- }
954
-
955
-
956
- // Populate the flat taxonomies
957
- plugin.populateFlatTaxonomies = function()
958
- {
959
- if ( !plugin.initialData.hasOwnProperty('f_taxonomies') ) return;
960
- plugin.createTaxonomyObject();
961
- plugin.getTermNames();
962
- plugin.setWPSuggest();
963
- }
964
-
965
-
966
- // Create an object of taxonomies from class names
967
- plugin.createTaxonomyObject = function()
968
- {
969
- var out = "";
970
- var terms = {};
971
- for ( i = 0; i < plugin.initialData.f_taxonomies.length; i++ ){
972
-
973
- // Get the term
974
- var singleTerm = plugin.initialData.f_taxonomies[i];
975
-
976
- var tax_array = singleTerm.split('-'); // split the string into an array
977
- var splitter = tax_array.indexOf('nps'); // find the index of the name splitter
978
- var term = tax_array.splice(splitter + 1); // Splice off the name
979
- term = term.join('-'); // Join the name back into a string
980
-
981
- // Get the taxonomy
982
- var tax = singleTerm.split('-').splice(0, splitter);
983
- tax.shift('inf');
984
- var taxonomy = tax.join('-');
985
-
986
- // Add taxonomy array to object
987
- if ( !(taxonomy in terms) ){
988
- terms[taxonomy] = [];
989
- }
990
- // push term to taxonomy array
991
- var term_array = terms[taxonomy];
992
- term_array.push(term);
993
- }
994
- plugin.flatTerms = terms;
995
- }
996
-
997
-
998
- // Get the taxonomy names from the ids
999
- plugin.getTermNames = function()
1000
- {
1001
- $.ajax({
1002
- url: NestedPages.jsData.ajaxurl,
1003
- type: 'post',
1004
- datatype: 'json',
1005
- data : {
1006
- action : NestedPages.formActions.getTaxonomies,
1007
- nonce : NestedPages.jsData.nonce,
1008
- terms : plugin.flatTerms
1009
- },
1010
- success: function(data){
1011
- plugin.termNames = data.terms;
1012
- plugin.populateFlatTaxonomyFields();
1013
- }
1014
- });
1015
- }
1016
-
1017
-
1018
- // Populate the flat taxonomy fields in the form
1019
- plugin.populateFlatTaxonomyFields = function()
1020
- {
1021
- if ( !plugin.termNames ) return;
1022
- $.each(plugin.termNames, function(i, v){
1023
- var textarea = $('#' + i);
1024
- $(textarea).val(v.join(','));
1025
- });
1026
- }
1027
-
1028
-
1029
- // Initialize WP Auto Suggest on Flat Taxonomy fields
1030
- plugin.setWPSuggest = function()
1031
- {
1032
- var tagfields = $(plugin.form).find('[data-autotag]');
1033
- $.each(tagfields, function(i, v){
1034
- var taxonomy = $(this).attr('data-taxonomy');
1035
- $(this).suggest(ajaxurl + '?action=ajax-tag-search&tax=' + taxonomy , {multiple:true, multipleSep: ","});
1036
- });
1037
- }
1038
-
1039
-
1040
- // Save the quick edit
1041
- plugin.save = function()
1042
- {
1043
- plugin.toggleLoading(true);
1044
-
1045
- $.ajax({
1046
- url: NestedPages.jsData.ajaxurl,
1047
- type: 'post',
1048
- datatype: 'json',
1049
- data: $(plugin.form).find('form').serialize() + '&action=' + NestedPages.formActions.quickEditPost + '&nonce=' + NestedPages.jsData.nonce + '&syncmenu=' + NestedPages.jsData.syncmenu + '&post_type=' + NestedPages.jsData.posttype,
1050
- success: function(data){
1051
- if (data.status === 'error'){
1052
- plugin.toggleLoading(false);
1053
- $(plugin.form).find(NestedPages.selectors.quickEditErrorDiv).text(data.message).show();
1054
- } else {
1055
- plugin.toggleLoading(false);
1056
- plugin.newData = data.post_data;
1057
- plugin.updatePostRow();
1058
- }
1059
- },
1060
- error: function(data){
1061
- console.log(data);
1062
- }
1063
- });
1064
- }
1065
-
1066
-
1067
- // Update the Row after saving quick edit data
1068
- plugin.updatePostRow = function()
1069
- {
1070
- plugin.row = $(plugin.button).parents('.row-inner');
1071
-
1072
- $(plugin.row).find('.title').text(plugin.newData.post_title);
1073
-
1074
- var status = $(plugin.row).find('.status');
1075
- if ( (plugin.newData._status !== 'publish') && (plugin.newData._status !== 'future') ){
1076
- $(status).text('(' + plugin.newData._status + ')');
1077
- } else if (plugin.newData.keep_private === 'private') {
1078
- $(status).text('(' + plugin.newData.keep_private + ')');
1079
- } else {
1080
- $(status).text('');
1081
- }
1082
-
1083
- // Password Lock Icon
1084
- if ( plugin.newData.post_password !== "" ){
1085
- var statustext = $(status).text();
1086
- statustext += ' <i class="np-icon-lock"></i>';
1087
- $(status).html(statustext);
1088
- }
1089
-
1090
- // Hide / Show in Nav
1091
- var nav_status = $(plugin.row).find('.nav-status');
1092
- if ( (plugin.newData.nav_status == 'hide') ){
1093
- $(nav_status).text('(Hidden)');
1094
- } else {
1095
- $(nav_status).text('');
1096
- }
1097
-
1098
- // Hide / Show in Nested Pages
1099
- var li = $(plugin.row).parent('li');
1100
- if ( (plugin.newData.np_status == 'hide') ){
1101
- $(li).addClass('np-hide');
1102
- $(plugin.row).find('.status').after('<i class="np-icon-eye-blocked"></i>');
1103
- } else {
1104
- $(li).removeClass('np-hide');
1105
- $(plugin.row).find('.np-icon-eye-blocked').remove();
1106
- }
1107
-
1108
- // Author for Non-Hierarchical Types
1109
- if ( !NestedPages.jsData.hierarchical ){
1110
- $(plugin.row).find('.np-author-display').text(plugin.newData.author_name);
1111
- }
1112
-
1113
- var button = $(plugin.row).find(NestedPages.selectors.quickEditOpen);
1114
-
1115
- $(button).attr('data-id', plugin.newData.post_id);
1116
- $(button).attr('data-template', plugin.newData.page_template);
1117
- $(button).attr('data-title', plugin.newData.post_title);
1118
- $(button).attr('data-slug', plugin.newData.post_name);
1119
- $(button).attr('data-commentstatus', plugin.newData.comment_status);
1120
- $(button).attr('data-status', plugin.newData._status);
1121
-
1122
- // Private Status
1123
- if ( plugin.newData.keep_private === 'private' ) {
1124
- $(button).attr('data-status', 'private');
1125
- }
1126
-
1127
- $(button).attr('data-author', plugin.newData.post_author);
1128
- $(button).attr('data-np-status', plugin.newData.np_status);
1129
- $(button).attr('data-password', plugin.newData.post_password);
1130
-
1131
- $(button).attr('data-navstatus', plugin.newData.nav_status);
1132
- $(button).attr('data-navtitle', plugin.newData.np_nav_title);
1133
- $(button).attr('data-linktarget', plugin.newData.link_target);
1134
- $(button).attr('data-navtitleattr', plugin.newData.np_title_attribute);
1135
- $(button).attr('data-navcss', plugin.newData.np_nav_css_classes);
1136
-
1137
- $(button).attr('data-month', plugin.newData.mm);
1138
- $(button).attr('data-day', plugin.newData.jj);
1139
- $(button).attr('data-year', plugin.newData.aa);
1140
- $(button).attr('data-hour', plugin.newData.hh);
1141
- $(button).attr('data-minute', plugin.newData.mn);
1142
- $(button).attr('data-datepicker', plugin.newData.np_date);
1143
- $(button).attr('data-time', plugin.newData.np_time);
1144
- $(button).attr('data-formattedtime', plugin.newData.np_time);
1145
- $(button).attr('data-ampm', plugin.newData.np_ampm);
1146
-
1147
- plugin.removeTaxonomyClasses();
1148
- plugin.addCategoryClasses();
1149
- plugin.addHierarchicalClasses();
1150
- plugin.addFlatClasses();
1151
- plugin.addStatusClass();
1152
-
1153
- plugin.formatter.removeQuickEdit();
1154
- plugin.formatter.flashRow(plugin.row);
1155
- }
1156
-
1157
-
1158
- // Add Status Class
1159
- plugin.addStatusClass = function()
1160
- {
1161
- var taxonomies = ['published', 'draft', 'pending', 'future'];
1162
- for ( i = 0; i < taxonomies.length; i++ ){
1163
- $(plugin.row).removeClass(taxonomies[i]);
1164
- }
1165
- $(plugin.row).addClass(plugin.newData._status);
1166
- }
1167
-
1168
-
1169
- // Remove Taxonomy Classes from the updated row
1170
- plugin.removeTaxonomyClasses = function()
1171
- {
1172
- taxonomies = [];
1173
- var classes = $(plugin.row).attr('class').split(/\s+/);
1174
- for ( i = 0; i < classes.length; i++ ){
1175
- if ( classes[i].substring(0, 3) === 'in-'){ // hierarchical
1176
- $(plugin.row).removeClass(classes[i]);
1177
- }
1178
- if ( classes[i].substring(0, 4) === 'inf-'){ // flat
1179
- $(plugin.row).removeClass(classes[i]);
1180
- }
1181
- }
1182
- }
1183
-
1184
-
1185
- // Add Category Classes to the Row
1186
- plugin.addCategoryClasses = function()
1187
- {
1188
- if ( !plugin.newData.hasOwnProperty('post_category') ) return;
1189
- var cats = plugin.newData.post_category;
1190
- for ( i = 0; i < cats.length; i++ ){
1191
- var taxclass = 'in-category-' + cats[i];
1192
- $(plugin.row).addClass(taxclass);
1193
- }
1194
- }
1195
-
1196
-
1197
- // Add hierarchical taxonomy classes to the row
1198
- plugin.addHierarchicalClasses = function()
1199
- {
1200
- if ( !plugin.newData.hasOwnProperty('tax_input') ) return;
1201
- var taxonomies = plugin.newData.tax_input;
1202
- $.each(taxonomies, function(tax, terms){
1203
- for (i = 0; i < terms.length; i++){
1204
- var taxclass = 'in-' + tax + '-' + terms[i];
1205
- $(plugin.row).addClass(taxclass);
1206
- }
1207
- });
1208
- }
1209
-
1210
-
1211
- // Add flat taxonomy classes to the row
1212
- plugin.addFlatClasses = function()
1213
- {
1214
- if ( !plugin.newData.hasOwnProperty('flat_tax') ) return;
1215
- var taxonomies = plugin.newData.flat_tax;
1216
- $.each(taxonomies, function(tax, terms){
1217
- for (i = 0; i < terms.length; i++){
1218
- var taxclass = 'inf-' + tax + '-nps-' + terms[i];
1219
- $(plugin.row).addClass(taxclass);
1220
- }
1221
- });
1222
- }
1223
-
1224
-
1225
- // Toggle Form Loading State
1226
- plugin.toggleLoading = function(loading)
1227
- {
1228
- if ( loading ){
1229
- $(NestedPages.selectors.quickEditErrorDiv).hide();
1230
- $(plugin.saveButton).attr('disabled', 'disabled');
1231
- $(NestedPages.selectors.quickEditLoadingIndicator).show();
1232
- return;
1233
- }
1234
- $(plugin.saveButton).attr('disabled', false);
1235
- $(NestedPages.selectors.quickEditLoadingIndicator).hide();
1236
- }
1237
-
1238
-
1239
-
1240
- return plugin.init();
1241
-
1242
-
1243
- }
1244
- var NestedPages = NestedPages || {};
1245
-
1246
- /**
1247
- * Quick Edit functionality for links
1248
- * @package Nested Pages
1249
- * @author Kyle Phillips - https://github.com/kylephillips/wp-nested-pages
1250
- */
1251
- NestedPages.QuickEditLink = function()
1252
- {
1253
- var plugin = this;
1254
- var $ = jQuery;
1255
-
1256
- plugin.formatter = new NestedPages.Formatter;
1257
- plugin.button = ''; // The Active Quick Edit Button
1258
- plugin.postData = ''; // Data for Post being edited (before update)
1259
- plugin.newPostData = ''; // Data after update
1260
- plugin.form = ''; // The newly created Quick Edit Form
1261
-
1262
-
1263
- plugin.init = function()
1264
- {
1265
- plugin.bindEvents();
1266
- }
1267
-
1268
-
1269
- plugin.bindEvents = function()
1270
- {
1271
- $(document).on('click', NestedPages.selectors.quickEditButtonLink, function(e){
1272
- e.preventDefault();
1273
- plugin.formatter.removeQuickEdit();
1274
- plugin.button = $(this);
1275
- plugin.openQuickEdit();
1276
- });
1277
- $(document).on('click', NestedPages.selectors.quickEditLinkSaveButton, function(e){
1278
- e.preventDefault();
1279
- plugin.submitForm();
1280
- });
1281
- $(document).on('keydown', function(e){
1282
- if ( e.keyCode === 27 ) plugin.formatter.removeQuickEdit();
1283
- });
1284
- }
1285
-
1286
-
1287
- // Open the Quick Edit Form
1288
- plugin.openQuickEdit = function()
1289
- {
1290
- plugin.setData();
1291
- plugin.createForm();
1292
- plugin.populateForm();
1293
- }
1294
-
1295
-
1296
- // Set the Quick Edit Data
1297
- plugin.setData = function()
1298
- {
1299
- plugin.postData = {
1300
- id : $(plugin.button).attr('data-id'),
1301
- url : $(plugin.button).attr('data-url'),
1302
- title : $(plugin.button).attr('data-title'),
1303
- status : $(plugin.button).attr('data-status'),
1304
- navstatus : $(plugin.button).attr('data-navstatus'),
1305
- npstatus : $(plugin.button).attr('data-np-status'),
1306
- linktarget : $(plugin.button).attr('data-linktarget'),
1307
- parentid : $(plugin.button).attr('data-parentid'),
1308
- navtitleattr : $(plugin.button).attr('data-navtitleattr'),
1309
- navcss : $(plugin.button).attr('data-navcss'),
1310
- navtype : $(plugin.button).attr('data-nav-type'),
1311
- navobject : $(plugin.button).attr('data-nav-object'),
1312
- navobjectid : $(plugin.button).attr('data-nav-object-id'),
1313
- navoriginallink : $(plugin.button).attr('data-nav-original-link'),
1314
- navoriginaltitle : $(plugin.button).attr('data-nav-original-title')
1315
- };
1316
- }
1317
-
1318
-
1319
- // Create the quick edit form
1320
- plugin.createForm = function()
1321
- {
1322
- var parent_li = $(plugin.button).closest(NestedPages.selectors.row).parent('li');
1323
- plugin.form = $(NestedPages.selectors.quickEditLinkForm).clone();
1324
-
1325
- // Append the form to the list item
1326
- if ( $(parent_li).children('ol').length > 0 ){
1327
- var child_ol = $(parent_li).children('ol');
1328
- $(plugin.form).insertBefore(child_ol);
1329
- } else {
1330
- $(plugin.form).appendTo(parent_li);
1331
- }
1332
-
1333
- var row = $(plugin.form).siblings(NestedPages.selectors.row).hide();
1334
- }
1335
-
1336
-
1337
- // Populate the Quick Edit form with the post data
1338
- plugin.populateForm = function()
1339
- {
1340
- $(plugin.form).find('.np_id').val(plugin.postData.id);
1341
- $(plugin.form).find('.np_title').val(plugin.postData.title);
1342
- $(plugin.form).find('.np_author select').val(plugin.postData.author);
1343
- $(plugin.form).find('.np_status').val(plugin.postData.status);
1344
- $(plugin.form).find('.np_content').val(plugin.postData.url);
1345
- $(plugin.form).find('.np_parent_id').val(plugin.postData.parentid);
1346
- $(plugin.form).find('.np_title_attribute').val(plugin.postData.navtitleattr);
1347
- $(plugin.form).find('.np_nav_css_classes').val(plugin.postData.navcss);
1348
-
1349
- if ( plugin.postData.npstatus === 'hide' ){
1350
- $(plugin.form).find('.np_status').prop('checked', 'checked');
1351
- } else {
1352
- $(plugin.form).find('.np_status').removeAttr('checked');
1353
- }
1354
-
1355
- if ( plugin.postData.navstatus === 'hide' ) {
1356
- $(plugin.form).find('.np_nav_status').prop('checked', 'checked');
1357
- } else {
1358
- $(plugin.form).find('.np_nav_status').removeAttr('checked');
1359
- }
1360
-
1361
- if ( plugin.postData.linktarget === "_blank" ) {
1362
- $(plugin.form).find('.link_target').prop('checked', 'checked');
1363
- } else {
1364
- $(plugin.form).find('.link_target').removeAttr('checked');
1365
- }
1366
-
1367
- // Relationship Links
1368
- if ( plugin.postData.navobject !== 'custom' && plugin.postData.navobject !== '' ){
1369
- var html = '<div class="form-control original-link">Original: <a href="' + plugin.postData.navoriginallink + '" target="_blank">' + plugin.postData.navoriginaltitle + '</a></div>';
1370
- $(plugin.form).find('[data-url-field]').remove();
1371
- $(html).insertAfter($(plugin.form).find('h3'));
1372
- $(plugin.form).find('[data-np-menu-object-input]').val(plugin.postData.navobject);
1373
- $(plugin.form).find('[data-np-menu-objectid-input]').val(plugin.postData.navobjectid);
1374
- $(plugin.form).find('[data-np-menu-type-input]').val(plugin.postData.navtype);
1375
- $(plugin.form).find('h3').text('Link: ' + plugin.postData.navoriginaltitle);
1376
- } else {
1377
- $(plugin.form).find('h3').text('Link');
1378
- $(plugin.form).find('[data-np-menu-object-input]').val('custom');
1379
- $(plugin.form).find('[data-np-menu-type-input]').val('custom');
1380
- }
1381
-
1382
- plugin.formatter.showQuickEdit();
1383
- $(plugin.form).show();
1384
- }
1385
-
1386
-
1387
- // Submit the form
1388
- plugin.submitForm = function()
1389
- {
1390
- plugin.toggleLoading(true);
1391
-
1392
- $.ajax({
1393
- url: NestedPages.jsData.ajaxurl,
1394
- type: 'post',
1395
- datatype: 'json',
1396
- data: $(plugin.form).find('form').serialize() + '&action=' + NestedPages.formActions.quickEditLink + '&nonce=' + NestedPages.jsData.nonce + '&syncmenu=' + NestedPages.jsData.syncmenu + '&post_type=' + NestedPages.jsData.posttype,
1397
- success: function(data){
1398
- if (data.status === 'error'){
1399
- plugin.toggleLoading(false);
1400
- $(plugin.form).find(NestedPages.selectors.quickEditErrorDiv).text(data.message).show();
1401
- } else {
1402
- plugin.toggleLoading(false);
1403
- plugin.newPostData = data.post_data;
1404
- plugin.updateRow();
1405
- }
1406
- },
1407
- error: function(data){
1408
- plugin.toggleLoading(false);
1409
- $(plugin.form).find(NestedPages.selectors.quickEditErrorDiv).text('The form could not be saved at this time.').show();
1410
- }
1411
- });
1412
- }
1413
-
1414
-
1415
- // Update the row after successfully saving quick edit data
1416
- plugin.updateRow = function()
1417
- {
1418
- console.log(plugin.newPostData);
1419
- var row = $(plugin.form).siblings('.row');
1420
- $(row).find('.title').html(plugin.newPostData.post_title + ' <i class="np-icon-link"></i>');
1421
-
1422
- var status = $(row).find('.status');
1423
- if ( (plugin.newPostData._status !== 'publish') && (plugin.newPostData._status !== 'future') ){
1424
- $(status).text('(' + plugin.newPostData._status + ')');
1425
- } else {
1426
- $(status).text('');
1427
- }
1428
-
1429
- // Hide / Show in Nav
1430
- var nav_status = $(row).find('.nav-status');
1431
- if ( (plugin.newPostData.nav_status == 'hide') ){
1432
- $(nav_status).text('(' + NestedPages.jsData.hiddenText + ')');
1433
- } else {
1434
- $(nav_status).text('');
1435
- }
1436
-
1437
- // Hide / Show in Nested Pages
1438
- var li = $(row).parent('li');
1439
- if ( (plugin.newPostData.np_status == 'hide') ){
1440
- $(li).addClass('np-hide');
1441
- $(row).find('.status').after('<i class="np-icon-eye-blocked"></i>');
1442
- } else {
1443
- $(li).removeClass('np-hide');
1444
- $(row).find('.np-icon-eye-blocked').remove();
1445
- }
1446
-
1447
- var button = $(row).find(NestedPages.selectors.quickEditButtonLink);
1448
-
1449
- $(button).attr('data-id', plugin.newPostData.post_id);
1450
- $(button).attr('data-title', plugin.newPostData.post_title);
1451
- $(button).attr('data-url', plugin.newPostData.post_content);
1452
- $(button).attr('data-status', plugin.newPostData._status);
1453
- $(button).attr('data-navstatus', plugin.newPostData.nav_status);
1454
- $(button).attr('data-np-status', plugin.newPostData.np_status);
1455
- $(button).attr('data-linkTarget', plugin.newPostData.linkTarget);
1456
- $(button).attr('data-navtitleattr', plugin.newPostData.titleAttribute);
1457
- $(button).attr('data-navcss', plugin.newPostData.cssClasses);
1458
-
1459
- plugin.formatter.removeQuickEdit();
1460
- plugin.formatter.flashRow(row);
1461
- }
1462
-
1463
-
1464
- // Toggle loading state in form
1465
- plugin.toggleLoading = function(loading)
1466
- {
1467
- $('.row').removeClass('np-updated').removeClass('np-updated-show');
1468
- if ( loading ){
1469
- $(NestedPages.selectors.quickEditErrorDiv).hide();
1470
- $(NestedPages.selectors.quickEditLinkSaveButton).attr('disabled', 'disabled');
1471
- $(NestedPages.selectors.quickEditLoadingIndicator).show();
1472
- return;
1473
- }
1474
- $(NestedPages.selectors.quickEditLinkSaveButton).attr('disabled', false);
1475
- $(NestedPages.selectors.quickEditLoadingIndicator).hide();
1476
- }
1477
-
1478
-
1479
- return plugin.init();
1480
-
1481
- }
1482
- var NestedPages = NestedPages || {};
1483
-
1484
- /**
1485
- * Post clone functionality
1486
- * @package Nested Pages
1487
- * @author Kyle Phillips - https://github.com/kylephillips/wp-nested-pages
1488
- */
1489
- NestedPages.Clone = function()
1490
- {
1491
- var plugin = this;
1492
- var $ = jQuery;
1493
-
1494
- plugin.parent_id = ''; // The parent/source post ID
1495
- plugin.parent_title = ''; // The parent title
1496
- plugin.parentLi = null;
1497
-
1498
- plugin.formatter = new NestedPages.Formatter;
1499
-
1500
- plugin.init = function()
1501
- {
1502
- plugin.bindEvents();
1503
- }
1504
-
1505
-
1506
- plugin.bindEvents = function()
1507
- {
1508
- $(document).on('click', NestedPages.selectors.cloneButton, function(e){
1509
- e.preventDefault();
1510
- plugin.parent_id = $(this).attr('data-id');
1511
- plugin.parent_title = $(this).attr('data-parentname');
1512
- plugin.parentLi = $(this).parent('.row').parent('.page-row').parent('.npList');
1513
- plugin.openModal();
1514
- });
1515
- $(document).on('click', NestedPages.selectors.confirmClone, function(e){
1516
- e.preventDefault();
1517
- plugin.clone();
1518
- });
1519
- }
1520
-
1521
- // Open the modal with clone options
1522
- plugin.openModal = function()
1523
- {
1524
- $(NestedPages.selectors.cloneModal).find('[data-clone-parent]').text(plugin.parent_title);
1525
- $(NestedPages.selectors.cloneModal).modal('show');
1526
- }
1527
-
1528
-
1529
- // Clone the post
1530
- plugin.clone = function()
1531
- {
1532
- plugin.toggleLoading(true);
1533
- $.ajax({
1534
- url : NestedPages.jsData.ajaxurl,
1535
- type : 'post',
1536
- data : {
1537
- action : NestedPages.formActions.clonePost,
1538
- parent_id : plugin.parent_id,
1539
- quantity : $(NestedPages.selectors.cloneQuantity).val(),
1540
- status : $(NestedPages.selectors.cloneStatus).val(),
1541
- author : $(NestedPages.selectors.cloneAuthor).find('select').val(),
1542
- nonce : NestedPages.jsData.nonce,
1543
- posttype : NestedPages.jsData.posttype
1544
- },
1545
- success : function(data){
1546
- plugin.toggleLoading(false);
1547
- $(NestedPages.selectors.cloneModal).modal('hide');
1548
- location.reload();
1549
- }
1550
- });
1551
- }
1552
-
1553
-
1554
- // Toggle Loading
1555
- plugin.toggleLoading = function(loading)
1556
- {
1557
- if ( loading ){
1558
- $(NestedPages.selectors.cloneModal).find('[data-clone-loading]').show();
1559
- $(NestedPages.selectors.confirmClone).attr('disabled', 'disabled');
1560
- return;
1561
- }
1562
- $(NestedPages.selectors.cloneModal).find('[data-clone-loading]').hide();
1563
- $(NestedPages.selectors.confirmClone).attr('disabled', false);
1564
- }
1565
-
1566
- return plugin.init();
1567
- }
1568
- var NestedPages = NestedPages || {};
1569
-
1570
- /**
1571
- * Tab functionality
1572
- * @package Nested Pages
1573
- * @author Kyle Phillips - https://github.com/kylephillips/wp-nested-pages
1574
- */
1575
- NestedPages.Tabs = function()
1576
- {
1577
- var plugin = this;
1578
- var $ = jQuery;
1579
-
1580
- plugin.activeContent = '';
1581
- plugin.activeButton = '';
1582
-
1583
- plugin.init = function()
1584
- {
1585
- plugin.bindEvents();
1586
- }
1587
-
1588
-
1589
- plugin.bindEvents = function()
1590
- {
1591
- $(document).on('click', NestedPages.selectors.tabButton, function(e){
1592
- e.preventDefault();
1593
- plugin.activeButton = $(this);
1594
- plugin.toggleTabs();
1595
- });
1596
- }
1597
-
1598
-
1599
- plugin.toggleTabs = function()
1600
- {
1601
- plugin.activeContent = $(plugin.activeButton).attr('href');
1602
- $(NestedPages.selectors.tabContent).hide();
1603
- $(plugin.activeContent).show();
1604
- $(plugin.activeButton).parents(NestedPages.selectors.tabButtonParent).find(NestedPages.selectors.tabButton).removeClass('active');
1605
- $(plugin.activeButton).addClass('active');
1606
- }
1607
-
1608
- return plugin.init();
1609
- }
1610
- /**
1611
- * Primary Nested Pages Initialization
1612
- * @package Nested Pages
1613
- * @author Kyle Phillips - https://github.com/kylephillips/wp-nested-pages
1614
- */
1615
-
1616
- jQuery(document).ready(function(){
1617
- new NestedPages.Factory;
1618
- });
1619
-
1620
- var NestedPages = NestedPages || {};
1621
-
1622
-
1623
- // DOM Selectors
1624
- NestedPages.selectors = {
1625
- childToggle : '.child-toggle', // Child Toggle Buttons
1626
- childToggleLink : '.child-toggle a', // Actual link in button
1627
- toggleAll : '.nestedpages-toggleall', // Toggle All Button
1628
- toggleHidden : '.np-toggle-hidden', // Toggle Hidden Pages
1629
- toggleStatus : '.np-toggle-publish', // Toggle Published Pages
1630
- lists : '.nplist', // OL elements
1631
- rows : '.page-row', // Page Row,
1632
- row : '.row', // Inner row div element
1633
- sortable : '.sortable', // Sortable List
1634
- notSortable : '.no-sort', // Unsortable List
1635
- handle : '.handle', // Sortable Handle
1636
- published : '.published', // Published Rows
1637
- hiddenRows : '.np-hide', // Hidden Rows
1638
- errorDiv : '#np-error', // Error Alert
1639
- loadingIndicator : '#nested-loading', // Loading Indicator,
1640
- syncCheckbox : '.np-sync-menu', // Sync menu checkbox
1641
-
1642
- // Responsive Toggle
1643
- toggleEditButtons : '.np-toggle-edit', // Button that toggles responsive buttons
1644
-
1645
- // Quick Edit
1646
- quickEditOverlay : '.np-inline-overlay', // The inline modal
1647
- quickEditLoadingIndicator : '.np-qe-loading', // Loading indicator in Quick Edit
1648
- quickEditErrorDiv : '.np-quickedit-error', // Error Div in Quick Edit
1649
- quickEditCancel : '.np-cancel-quickedit', // Cancel button in quick edit
1650
- quickEditToggleTaxonomies : '.np-toggle-taxonomies', // Toggle Taxonomies in Quick Edit
1651
- quickEditToggleMenuOptions : '.np-toggle-menuoptions', // Toggle Menu Options in Quick Edit
1652
-
1653
- // Quick Edit - Links
1654
- quickEditButtonLink : '.np-quick-edit-redirect', // Button to open link quick edit
1655
- quickEditLinkForm : '.quick-edit-form-redirect', // Form for link quick edits
1656
- quickEditLinkSaveButton : '.np-save-quickedit-redirect', // Save button in link quick edit form
1657
-
1658
- // Quick Edit - Posts
1659
- quickEditOpen : '.np-quick-edit', // Button to open post quick edit
1660
- quickEditPostForm : '.quick-edit-form', // Form container
1661
- quickEditSaveButton : '.np-save-quickedit', // Save button in quick edit (posts)
1662
-
1663
- // Link Items
1664
- openLinkModal : '.open-redirect-modal', // Opens new link modal
1665
- linkModal : '#np-link-modal', // The add a link modal
1666
- saveLink : '.np-save-link', // Save Link Button
1667
- linkLoadingIndicator : '.np-link-loading', // Loading Indicator in Link Modal
1668
- linkErrorDiv : '.np-new-link-error', // Error Div in Link Modal
1669
- linkForm : '.np-new-link-form', // The form element for a new link
1670
-
1671
- // New Page Items
1672
- openPageModal : '.open-bulk-modal', // Opens the new page(s) modal
1673
- newPageModal : '#np-bulk-modal', // The modal with the new page form
1674
- newPageFormContainer : '.new-child-form', // The new page form container
1675
- newPageForm : '.np-new-child-form', // The form element
1676
- newPageSubmitButton : '.np-save-newchild', // Submit button in new page form
1677
- newPageTitle : '.add-new-child-row', // Button to add a new page title field to the form
1678
- newPageRemoveTitle : '.np-remove-child', // Button to remove a title field in the form
1679
- addChildButton : '.add-new-child', // Button to add child page(s)
1680
- newChildError : '.np-newchild-error', // Error div in new child quick edit
1681
- cancelNewChildButton : '.np-cancel-newchild', // Cancel button in new child quick edit
1682
-
1683
- // Clone
1684
- cloneButton : '.clone-post', // Button to clone a post
1685
- confirmClone : '[data-confirm-clone]', // Button in modal to confirm clone
1686
- cloneModal : '#np-clone-modal', // Modal with clone options
1687
- cloneQuantity : '[data-clone-quantity]', // Quantity to Clone
1688
- cloneStatus : '[data-clone-status]', // Clone Status
1689
- cloneAuthor : '[data-clone-author]', // Clone Author
1690
-
1691
- // Tabs
1692
- tabButtonParent : '[data-np-tabs]', // Tab Parent
1693
- tabButton : '[data-np-tab]', // Tab Link
1694
- tabContent : '[data-np-tab-pane]', // Tab Pane
1695
- }
1696
-
1697
-
1698
- // CSS Classes
1699
- NestedPages.cssClasses = {
1700
- iconToggleDown : 'np-icon-arrow-down',
1701
- iconToggleRight : 'np-icon-arrow-right',
1702
- noborder : 'no-border'
1703
- }
1704
-
1705
-
1706
- // JS Data
1707
- NestedPages.jsData = {
1708
- ajaxurl : ajaxurl,
1709
- nonce : nestedpages.np_nonce,
1710
- allPostTypes : nestedpages.post_types, // Localized data with all post types
1711
- syncmenu : 'nosync', // Whether to sync the menu
1712
- posttype : '', // current Screen's post type
1713
- nestable : true, // boolean - whether post type is nestable
1714
- hierarchical : true, // boolean - whether post type is hierarchical
1715
- expandText : nestedpages.expand_text, // Expand all button text
1716
- collapseText : nestedpages.collapse_text, // Collapse all button text
1717
- showHiddenText : nestedpages.show_hidden, // Show Hidden Pages Link Text
1718
- hideHiddenText : nestedpages.hide_hidden, // Hide Hidden Pages Link Text
1719
- quickEditText : nestedpages.quick_edit, // Quick Edit Button Text
1720
- hiddenText : nestedpages.hidden, // Localized "Hidden"
1721
- titleText : nestedpages.title, // Localized "Title"
1722
- }
1723
-
1724
-
1725
- // Form Actions
1726
- NestedPages.formActions = {
1727
- syncToggles : 'npnestToggle',
1728
- syncNesting : 'npsort',
1729
- syncMenu : 'npsyncMenu',
1730
- newPage : 'npnewChild',
1731
- quickEditLink : 'npquickEditLink',
1732
- getTaxonomies : 'npgetTaxonomies',
1733
- quickEditPost : 'npquickEdit',
1734
- clonePost : 'npclonePost',
1735
- search : 'npmenuSearch',
1736
- newMenuItem : 'npnewMenuItem'
1737
- }
1738
-
1739
-
1740
- /**
1741
- * Primary Nested Pages Class
1742
- */
1743
- NestedPages.Factory = function()
1744
- {
1745
- var plugin = this;
1746
- var $ = jQuery;
1747
-
1748
- plugin.formatter = new NestedPages.Formatter;
1749
- plugin.responsive = new NestedPages.Responsive;
1750
- plugin.menuToggle = new NestedPages.MenuToggle;
1751
- plugin.pageToggle = new NestedPages.PageToggle;
1752
- plugin.nesting = new NestedPages.Nesting;
1753
- plugin.syncMenuSetting = new NestedPages.SyncMenuSetting;
1754
- plugin.newPage = new NestedPages.NewPage;
1755
- plugin.quickEditLink = new NestedPages.QuickEditLink;
1756
- plugin.quickEditPost = new NestedPages.QuickEditPost;
1757
- plugin.clone = new NestedPages.Clone;
1758
- plugin.tabs = new NestedPages.Tabs;
1759
- plugin.menuLinks = new NestedPages.MenuLinks;
1760
-
1761
- plugin.init = function()
1762
- {
1763
- plugin.bindEvents();
1764
- plugin.setPostType();
1765
- plugin.setMenuSync();
1766
- plugin.setNestable();
1767
- plugin.formatter.updateSubMenuToggle();
1768
- plugin.formatter.setBorders();
1769
- plugin.formatter.setNestedMargins();
1770
- plugin.nesting.initializeSortable();
1771
- }
1772
-
1773
-
1774
- plugin.bindEvents = function()
1775
- {
1776
- $(document).on('click', NestedPages.selectors.quickEditOverlay, function(e){
1777
- plugin.formatter.removeQuickEdit();
1778
- plugin.newPage.cancelNewPage();
1779
- });
1780
- }
1781
-
1782
-
1783
- // Set whether or not post type is nestable
1784
- plugin.setNestable = function()
1785
- {
1786
- var nestable = true;
1787
- $.each(NestedPages.jsData.allPostTypes, function(i, v){
1788
- if ( v.name !== NestedPages.jsData.posttype ) return;
1789
- if ( v.hierarchical === true ) nestable = true;
1790
- if ( v.disable_nesting === true ) nestable = false;
1791
- });
1792
- NestedPages.jsData.nestable = nestable;
1793
- }
1794
-
1795
-
1796
- // Set the Screen's Post Type
1797
- plugin.setPostType = function()
1798
- {
1799
- NestedPages.jsData.posttype = $(NestedPages.selectors.sortable).attr('id').substring(3);
1800
- NestedPages.jsData.hierarchical = NestedPages.jsData.allPostTypes[NestedPages.jsData.posttype].hierarchical;
1801
- }
1802
-
1803
-
1804
- // Set menu sync
1805
- plugin.setMenuSync = function()
1806
- {
1807
- NestedPages.jsData.syncmenu = ( nestedpages.syncmenu === '1' ) ? 'sync' : 'nosync';
1808
- }
1809
-
1810
-
1811
- return plugin.init();
1812
- }
1813
- var NestedPages = NestedPages || {};
1814
-
1815
- /**
1816
- * Menu Item Selection in Modal Link Form
1817
- * @package Nested Pages
1818
- * @author Kyle Phillips - https://github.com/kylephillips/wp-nested-pages
1819
- */
1820
- NestedPages.MenuLinks = function()
1821
- {
1822
- var plugin = this;
1823
- var $ = jQuery;
1824
-
1825
- plugin.typeButton = ''; // The Link Type selected button
1826
- plugin.post = ''; // The new post created
1827
-
1828
- plugin.formatter = new NestedPages.Formatter;
1829
-
1830
- plugin.selectors = {
1831
- form : '[data-np-menu-item-form]', // The form element
1832
- typeSelect : '[data-np-menu-selection]', // Link in left column to choose type of link
1833
- accordion : '[data-np-menu-accordion]', // Accordion of objects
1834
- accordionItem : '[data-np-menu-accordion-item]', // Single item in the accordion
1835
- formPlaceholder : '.np-menu-link-object-placeholder', // Placeholder element
1836
- formDetails : '.np-menu-link-details', // Right pane form details
1837
- searchResults : '[data-np-search-result]', // Appended search result rows
1838
- defaultResults : '[data-default-result]', // Default results,
1839
- originalLink : '[data-np-original-link]', // Original Link Preview
1840
- saveButton : '[data-np-save-link]', // The Form Submit Button
1841
- urlInputCont : '[data-np-menu-url-cont]', // Container for URL input (only for custom links)
1842
- errorDiv : '[data-np-error]', // The error notification
1843
- }
1844
-
1845
- plugin.fields = {
1846
- object : '[data-np-menu-object-input]', // The object (ex: post/category/custom)
1847
- objectid : '[data-np-menu-objectid-input]', // ex: term id, post id
1848
- itemType : '[data-np-menu-type-input]', // ex: post_type, taxonomy
1849
- url : '[data-np-menu-url]', // custom url
1850
- navigationLabel : '[data-np-menu-navigation-label]',
1851
- titleAttribute : '[data-np-menu-title-attr]',
1852
- cssClasses : '[data-np-menu-css-classes]',
1853
- npStatus : '[data-np-menu-np-status]',
1854
- linkTarget : '[data-np-menu-link-target]',
1855
- menuTitle : '[data-np-menu-title]'
1856
- }
1857
-
1858
- plugin.search = new NestedPages.MenuSearch;
1859
-
1860
- plugin.init = function()
1861
- {
1862
- plugin.bindEvents();
1863
- }
1864
-
1865
- plugin.bindEvents = function()
1866
- {
1867
- $(document).on('click', NestedPages.selectors.openLinkModal, function(e){
1868
- e.preventDefault();
1869
- plugin.postParent = $(this).attr('data-parentid');
1870
- $(plugin.selectors.form).find('.parent_id').val($(this).attr('data-parentid'));
1871
- plugin.openModal();
1872
- });
1873
- $(document).on('click', plugin.selectors.accordionItem, function(e){
1874
- e.preventDefault();
1875
- plugin.accordion($(this));
1876
- });
1877
- $(document).on('click', plugin.selectors.typeSelect, function(e){
1878
- e.preventDefault();
1879
- plugin.typeButton = $(this);
1880
- plugin.setLinkType();
1881
- });
1882
- $(document).on('keyup', plugin.fields.navigationLabel, function(){
1883
- plugin.updateTitle();
1884
- });
1885
- $(document).on('click', plugin.selectors.saveButton, function(e){
1886
- e.preventDefault();
1887
- plugin.submitForm();
1888
- });
1889
- $(document).on('keydown', function(e){
1890
- if ( e.keyCode === 27 ) $('#np-link-modal').modal('hide');
1891
- });
1892
- }
1893
-
1894
- // Open the Modal and Clear/Populate hidden fields
1895
- plugin.openModal = function()
1896
- {
1897
- $(NestedPages.selectors.linkErrorDiv).hide();
1898
- $(NestedPages.selectors.linkModal).find('input').val('');
1899
- $(NestedPages.selectors.linkModal).find('.parent_id').val(plugin.postParent);
1900
- plugin.clearForm();
1901
- $(plugin.selectors.accordion).find('ul').hide();
1902
- $(plugin.selectors.typeSelect).removeClass('active');
1903
- $(NestedPages.selectors.linkModal).modal('show');
1904
- }
1905
-
1906
- // Accordion Menu
1907
- plugin.accordion = function(button)
1908
- {
1909
- plugin.clearForm();
1910
- var submenu = $(button).siblings('ul');
1911
- if ( $(submenu).is(':visible') ){
1912
- $(button).removeClass('active');
1913
- $(submenu).slideUp('fast');
1914
- return;
1915
- }
1916
- $(plugin.selectors.accordionItem).removeClass('active');
1917
- $(button).addClass('active');
1918
- $(button).parents(plugin.selectors.accordion).find('ul').slideUp('fast');
1919
- $(submenu).slideDown('fast');
1920
- }
1921
-
1922
- // Set the link type
1923
- plugin.setLinkType = function()
1924
- {
1925
- if ( $(plugin.typeButton).hasClass('active') ){
1926
- plugin.clearForm();
1927
- return;
1928
- }
1929
- if ( $(plugin.typeButton).hasClass('np-custom-link') ){
1930
- $(plugin.selectors.accordionItem).removeClass('active');
1931
- $(plugin.selectors.accordion).find('ul').slideUp('fast');
1932
- }
1933
- $(plugin.selectors.formPlaceholder).hide();
1934
- plugin.populateForm();
1935
- }
1936
-
1937
- // Populate the form
1938
- plugin.populateForm = function()
1939
- {
1940
- $(plugin.selectors.saveButton).show();
1941
- $(plugin.selectors.typeSelect).removeClass('active');
1942
- $(plugin.typeButton).addClass('active');
1943
- $(plugin.fields.menuTitle).text($(plugin.typeButton).text()).val($(plugin.typeButton).text());
1944
- $(plugin.selectors.form).find('h3').find('em').text($(plugin.typeButton).attr('data-np-object-name'));
1945
- if ( $(plugin.typeButton).attr('data-np-permalink') !== "" ){
1946
- $(plugin.selectors.form).find(plugin.selectors.urlInputCont).hide();
1947
- $(plugin.selectors.form).find(plugin.selectors.originalLink).html('<a href="' + $(plugin.typeButton).attr('data-np-permalink') + '">' + $(plugin.typeButton).text() + '</a>');
1948
- $(plugin.selectors.form).find(plugin.selectors.originalLink).parent('.original-link').show();
1949
- } else {
1950
- $(plugin.selectors.form).find(plugin.selectors.urlInputCont).show();
1951
- $(plugin.selectors.form).find(plugin.selectors.originalLink).parent('.original-link').hide();
1952
- }
1953
- $(plugin.fields.object).val($(plugin.typeButton).attr('data-np-menu-object'));
1954
- $(plugin.fields.objectid).val($(plugin.typeButton).attr('data-np-menu-objectid'));
1955
- $(plugin.fields.itemType).val($(plugin.typeButton).attr('data-np-menu-type'));
1956
- $(plugin.selectors.formDetails).show();
1957
- }
1958
-
1959
- // Clear the form
1960
- plugin.clearForm = function()
1961
- {
1962
- $(plugin.selectors.form).find(plugin.selectors.errorDiv).hide();
1963
- $(plugin.selectors.saveButton).hide();
1964
- $(plugin.selectors.formDetails).hide();
1965
- $(plugin.selectors.formPlaceholder).show();
1966
- $(plugin.selectors.form).find('input').not('.parent_id').val('');
1967
- $(plugin.selectors.form).find(plugin.fields.linkTarget).val('_blank');
1968
- $(plugin.selectors.form).find('input[type="checkbox"]').attr('checked', false);
1969
- $(plugin.selectors.typeSelect).removeClass('active');
1970
- plugin.search.toggleLoading(false);
1971
- $(plugin.selectors.searchResults).remove();
1972
- $(plugin.selectors.defaultResults).show();
1973
- }
1974
-
1975
- // Update the title text
1976
- plugin.updateTitle = function()
1977
- {
1978
- var value = $(plugin.fields.navigationLabel).val();
1979
- var title = $(plugin.selectors.form).find('h3').find('span');
1980
- if ( value !== "" ){
1981
- $(plugin.fields.menuTitle).val(value);
1982
- $(title).text(value);
1983
- } else {
1984
- $(plugin.fields.menuTitle).val($(plugin.typeButton).text());
1985
- $(title).text($(plugin.typeButton).text());
1986
- }
1987
- }
1988
-
1989
- // Submit the Form
1990
- plugin.submitForm = function()
1991
- {
1992
- plugin.toggleLoading(true);
1993
- $.ajax({
1994
- url : NestedPages.jsData.ajaxurl,
1995
- type : 'post',
1996
- data: $(plugin.selectors.form).serialize() + '&action=' + NestedPages.formActions.newMenuItem + '&nonce=' + NestedPages.jsData.nonce + '&post_type=' + NestedPages.jsData.posttype + '&syncmenu=' + NestedPages.jsData.syncmenu,
1997
- success : function(data){
1998
- plugin.toggleLoading(false);
1999
- if ( data.status === 'error' ){
2000
- $(plugin.selectors.form).find(plugin.selectors.errorDiv).text(data.message).show();
2001
- return;
2002
- }
2003
- plugin.post = data.post_data;
2004
- plugin.createRow();
2005
- },
2006
- error : function(data){
2007
- console.log(data);
2008
- }
2009
- });
2010
- }
2011
-
2012
- // Create the nested pages row for the new link
2013
- plugin.createRow = function()
2014
- {
2015
- var html = '<li id="menuItem_' + plugin.post.id + '" class="page-row published';
2016
- html += '">'
2017
-
2018
- html += '<div class="row"><div class="child-toggle"></div><div class="row-inner"><i class="np-icon-sub-menu"></i><i class="handle np-icon-menu"></i><a href="' + plugin.post.np_link_content + '" class="page-link page-title" target="_blank"><span class="title">' + plugin.post.menuTitle + ' <i class="np-icon-link"></i></span>';
2019
-
2020
- // Quick Edit Button
2021
- html += '</a><a href="#" class="np-toggle-edit"><i class="np-icon-pencil"></i></a><div class="action-buttons"><a href="#" class="np-btn np-quick-edit-redirect" ';
2022
- html += 'data-id="' + plugin.post.id + '"';
2023
- html += 'data-parentid="' + plugin.post.parent_id + '"';
2024
- html += 'data-title="' + plugin.post.menuTitle + '" ';
2025
- html += 'data-url="' + plugin.post.url + '" ';
2026
- html += 'data-status="publish" ';
2027
- html += 'data-np-status="show" ';
2028
- html += 'data-navstatus="show" ';
2029
- html += 'data-navcss="' + plugin.post.cssClasses + '" ';
2030
- html += 'data-navtitleattr="' + plugin.post.titleAttribute + '" ';
2031
- html += 'data-nav-type="' + plugin.post.menuType + '" ';
2032
- html += 'data-nav-object="' + plugin.post.objectType + '" ';
2033
- html += 'data-nav-object-id="' + plugin.post.objectId + '" ';
2034
- html += 'data-nav-original-link="' + plugin.post.original_link + '" ';
2035
- html += 'data-nav-original-title="' + plugin.post.original_title + '" ';
2036
- html += 'data-linktarget="' + plugin.post.link_target + '">';
2037
- html += NestedPages.jsData.quickEditText;
2038
- html += '</a>';
2039
-
2040
- // Delete Link
2041
- html += '<a href="' + plugin.post.delete_link + '" class="np-btn np-btn-trash"><i class="np-icon-remove"></i></a>';
2042
-
2043
- html += '</div></div></div></li>';
2044
-
2045
- if ( plugin.post.parent_id === "0" ){
2046
- $('.nplist:first li:first').after(html);
2047
- } else {
2048
- plugin.appendChildRow(html);
2049
- }
2050
-
2051
- $(NestedPages.selectors.linkModal).modal('hide');
2052
-
2053
- plugin.row = $('#menuItem_' + plugin.post.id).find('.row');
2054
- plugin.formatter.flashRow(plugin.row);
2055
- }
2056
-
2057
- // Append a new child link to the appropriate menu
2058
- plugin.appendChildRow = function(html)
2059
- {
2060
- var parent_row = $('#menuItem_' + plugin.post.parent_id);
2061
- if ( $(parent_row).children('ol').length === 0 ){
2062
- html = '<ol class="sortable nplist" style="display:block;">' + html + '</ol>';
2063
- $(parent_row).append(html);
2064
- } else {
2065
- $(parent_row).find('ol:first').prepend(html);
2066
- }
2067
- plugin.formatter.updateSubMenuToggle();
2068
- }
2069
-
2070
- // Toggle Loading
2071
- plugin.toggleLoading = function(loading)
2072
- {
2073
- if ( loading ){
2074
- $(plugin.selectors.form).find(plugin.selectors.errorDiv).hide();
2075
- $(plugin.selectors.form).find(NestedPages.selectors.quickEditLoadingIndicator).show();
2076
- $(plugin.selectors.saveButton).attr('disabled', 'disabled');
2077
- return;
2078
- }
2079
- $(plugin.selectors.form).find(NestedPages.selectors.quickEditLoadingIndicator).hide();
2080
- $(plugin.selectors.saveButton).attr('disabled', false);
2081
- }
2082
-
2083
- return plugin.init();
2084
- }
2085
- var NestedPages = NestedPages || {};
2086
-
2087
- /**
2088
- * Menu Item Search in Modal Link Form
2089
- * @package Nested Pages
2090
- * @author Kyle Phillips - https://github.com/kylephillips/wp-nested-pages
2091
- */
2092
- NestedPages.MenuSearch = function()
2093
- {
2094
- var plugin = this;
2095
- var $ = jQuery;
2096
-
2097
- plugin.selectors = {
2098
- searchForms : '*[data-np-menu-search]', // Search form selector
2099
- defaultResults : '[data-default-result]', // Default results list items
2100
- loadingIndicator : '.np-menu-search-loading', // loading indicator
2101
- noResults : '.np-menu-search-noresults', // No results
2102
- searchType : 'data-search-type', // The search object type (post_type, taxonomy)
2103
- searchObject : 'data-search-object', // The object to search (post, category, etc)
2104
- searchResults : '[data-np-search-result]', // Appended search result rows
2105
- }
2106
-
2107
- plugin.activeForm = ''; // The active form
2108
- plugin.results = ''; // Search results
2109
- plugin.defaultResults = ''; // The default, loaded results
2110
- plugin.searchType = ''; // The type of search (post_type, taxonomy)
2111
- plugin.searchObject = ''; // The object being searched (post, category, post_tag, etc…)
2112
-
2113
- plugin.init = function()
2114
- {
2115
- plugin.bindEvents();
2116
- }
2117
-
2118
- plugin.bindEvents = function()
2119
- {
2120
- $(document).on('keyup', plugin.selectors.searchForms, function(){
2121
- plugin.activeForm = $(this);
2122
- $(plugin.selectors.searchResults).remove();
2123
- plugin.performSearch();
2124
- });
2125
- }
2126
-
2127
-
2128
- // Perform the search
2129
- plugin.performSearch = function()
2130
- {
2131
- plugin.defaultResults = $(plugin.activeForm).parent('li').siblings(plugin.selectors.defaultResults);
2132
- if ( $(plugin.activeForm).val().length > 2 ){
2133
- $(plugin.defaultResults).hide();
2134
- plugin.toggleLoading(true);
2135
- plugin.query();
2136
- return;
2137
- }
2138
- plugin.toggleLoading(false);
2139
- $(plugin.defaultResults).show();
2140
- }
2141
-
2142
-
2143
- // Query Search
2144
- plugin.query = function()
2145
- {
2146
- plugin.searchType = $(plugin.activeForm).attr(plugin.selectors.searchType);
2147
- plugin.searchObject = $(plugin.activeForm).attr(plugin.selectors.searchObject);
2148
- $.ajax({
2149
- url: NestedPages.jsData.ajaxurl,
2150
- type: 'post',
2151
- datatype: 'json',
2152
- data: {
2153
- action : NestedPages.formActions.search,
2154
- nonce : NestedPages.jsData.nonce,
2155
- term : $(plugin.activeForm).val(),
2156
- searchType : plugin.searchType,
2157
- searchObject : plugin.searchObject,
2158
- },
2159
- success: function(data){
2160
- console.log(data);
2161
- if ( data.results ){
2162
- plugin.results = data.results;
2163
- plugin.toggleLoading(false);
2164
- if ( plugin.searchType === 'post_type' ){
2165
- plugin.appendPosts();
2166
- } else {
2167
- plugin.appendTaxonomies();
2168
- }
2169
- } else {
2170
- plugin.toggleLoading(false);
2171
- $(plugin.activeForm).siblings(plugin.selectors.noResults).show();
2172
- }
2173
- }
2174
- });
2175
- }
2176
-
2177
-
2178
- // Append post type results
2179
- plugin.appendPosts = function()
2180
- {
2181
- var html = "";
2182
- $.each(plugin.results, function(i, v){
2183
- html += '<li data-np-search-result><a href="#" data-np-menu-object="' + plugin.searchObject + '" data-np-menu-type="post_type" data-np-menu-objectid="' + v.ID + '" data-np-permalink="' + v.permalink + '" data-np-object-name="' + v.singular_name + '" data-np-menu-selection>' + v.post_title + '</a></li>';
2184
- });
2185
- $(html).insertAfter($(plugin.activeForm).parent('li'));
2186
- plugin.toggleLoading(false);
2187
- }
2188
-
2189
-
2190
- // Append taxonomy results
2191
- plugin.appendTaxonomies = function()
2192
- {
2193
- var html = "";
2194
- $.each(plugin.results, function(i, v){
2195
- html += '<li data-np-search-result><a href="#" data-np-menu-object="' + plugin.searchObject + '" data-np-menu-type="post_type" data-np-menu-objectid="' + v.term_id + '" data-np-permalink="' + v.permalink + '" data-np-object-name="' + v.taxonomy + '" data-np-menu-selection>' + v.name + '</a></li>';
2196
- });
2197
- $(html).insertAfter($(plugin.activeForm).parent('li'));
2198
- plugin.toggleLoading(false);
2199
- }
2200
-
2201
-
2202
- // Toggle the loading indicator
2203
- plugin.toggleLoading = function(loading)
2204
- {
2205
- var loadingIndicator = $(plugin.activeForm).siblings(plugin.selectors.loadingIndicator);
2206
- $(plugin.selectors.noResults).hide();
2207
- if ( loading ){
2208
- $(loadingIndicator).show();
2209
- return;
2210
- }
2211
- $(loadingIndicator).hide();
2212
- }
2213
-
2214
- return plugin.init();
2215
- }
2216
- /**
2217
- * Empty Trash Functionality
2218
- * @package Nested Pages
2219
- * @author Kyle Phillips - https://github.com/kylephillips/wp-nested-pages
2220
- */
2221
- jQuery(document).ready(function(){
2222
- new NestedPagesTrash;
2223
- });
2224
-
2225
- var NestedPagesTrash = function()
2226
- {
2227
- var plugin = this;
2228
- var $ = jQuery;
2229
-
2230
- // DOM Selectors
2231
- plugin.trashButton = '.np-empty-trash'; // Trash Link
2232
- plugin.confirmButton = '.np-trash-confirm'; // Confirm button in modal
2233
- plugin.warningModal = '#np-trash-modal'; // Modal with empty confirmation
2234
- plugin.errorAlert = '#np-error'; // Alert Error Notification
2235
- plugin.loadingIndicator = '#nested-loading'; // Loading Indication
2236
- plugin.trashLinks = '.np-trash-links';
2237
- plugin.postType = $('#np-trash-posttype').val();
2238
-
2239
- // JS Data
2240
- plugin.nonce = nestedpages.np_nonce;
2241
- plugin.formAction = 'npEmptyTrash';
2242
-
2243
-
2244
- // Initialization
2245
- plugin.init = function(){
2246
- plugin.bindEvents();
2247
- }
2248
-
2249
- // Bind Events
2250
- plugin.bindEvents = function(){
2251
- $(document).on('click', plugin.trashButton, function(e){
2252
- e.preventDefault();
2253
- $(plugin.warningModal).modal('show');
2254
- });
2255
- $(document).on('click', plugin.confirmButton, function(e){
2256
- e.preventDefault();
2257
- plugin.confirmEmpty();
2258
- });
2259
- }
2260
-
2261
- // Confirm Trash Empty
2262
- plugin.confirmEmpty = function(){
2263
- plugin.loading(true);
2264
- $(plugin.warningModal).hide();
2265
- $(plugin.errorAlert).hide();
2266
- plugin.emptyTrash();
2267
- }
2268
-
2269
- // Empty the Trash
2270
- plugin.emptyTrash = function(){
2271
- $.ajax({
2272
- url: ajaxurl,
2273
- type: 'post',
2274
- datatype: 'json',
2275
- data: {
2276
- action : plugin.formAction,
2277
- nonce : plugin.nonce,
2278
- posttype : plugin.postType
2279
- },
2280
- success: function(data){
2281
- plugin.loading(false);
2282
- if (data.status === 'error'){
2283
- $(plugin.errorAlert).text(data.message).show();
2284
- } else {
2285
- $(plugin.trashLinks).hide();
2286
- }
2287
- }
2288
- });
2289
- }
2290
-
2291
- // Loading Indication
2292
- plugin.loading = function(loading){
2293
- if ( loading ){
2294
- $(plugin.loadingIndicator).show();
2295
- return;
2296
- }
2297
- $(plugin.loadingIndicator).hide();
2298
- }
2299
-
2300
- return plugin.init();
2301
- }
1
+ var NestedPages=NestedPages||{};NestedPages.Responsive=function(){var e=this,t=jQuery;return e.init=function(){e.bindEvents()},e.bindEvents=function(){t(document).on("click",NestedPages.selectors.toggleEditButtons,function(a){a.preventDefault(),e.toggleEdit(t(this))}),t(window).resize(function(){e.timer(function(){t(".action-buttons").removeAttr("style"),t(".np-toggle-edit").removeClass("active")},500)})},e.toggleEdit=function(e){var a=t(e).siblings(".action-buttons");return t(a).is(":visible")?(t(e).removeClass("active"),void t(a).hide()):(t(e).addClass("active"),void t(a).show())},e.timer=function(){var e=0;return function(t,a){clearTimeout(e),e=setTimeout(t,a)}}(),e.init()};var NestedPages=NestedPages||{};NestedPages.Formatter=function(){var e=this,t=jQuery;e.updateSubMenuToggle=function(){for(var e=t(NestedPages.selectors.childToggle),a=0;a<e.length;a++){var s=e[a],n=t(s).parent(".row").parent("li");if(t(n).children("ol").length>0){var o=t(n).children("ol:visible").length>0?NestedPages.cssClasses.iconToggleDown:NestedPages.cssClasses.iconToggleRight;t(s).html('<a href="#"><i class="'+o+'"></i></a>'),t(n).children("ol").children(".np-hide").length>0&&0===t(n).children("ol").children(".np-hide.shown").length?t(s).find("a").hide():t(n).children("ol").children(".np-hide").length>0&&t(n).children("ol").children(".np-hide.shown").length>0&&t(s).find("a").show()}else t(s).empty()}},e.setBorders=function(){t(NestedPages.selectors.rows).removeClass(NestedPages.cssClasses.noborder),t.each(t(NestedPages.selectors.lists),function(){t(this).find(".page-row:visible:first").addClass(NestedPages.cssClasses.noborder)})},e.setNestedMargins=function(){t.each(t(NestedPages.selectors.lists),function(){var e=t(this).parents(NestedPages.selectors.lists).length,a=56;if(e>0){var a=20*e+a;return void t(this).find(".row-inner").css("padding-left",a+"px")}t(this).find(".row-inner").css("padding-left","0px")})},e.updatePlaceholderWidth=function(a){if(NestedPages.jsData.nestable){var s=t(a.placeholder).parents("ol").length,n=t(NestedPages.selectors.sortable).width(),o=40*s-40,i=n-o;t(a.placeholder).width(i).css("margin-left",o+"px")}e.updateListVisibility(a)},e.updateListVisibility=function(e){var a=t(e.placeholder).parent("ol");t(a).is(":visible")||(t(a).addClass("nplist"),t(a).show())},e.removeQuickEdit=function(){t(NestedPages.selectors.quickEditOverlay).removeClass("active").remove(),t(".sortable .quick-edit").remove(),t(".row").show()},e.showQuickEdit=function(){t("body").append('<div class="np-inline-overlay"></div>'),setTimeout(function(){t(".np-inline-overlay").addClass("active")},50)},e.flashRow=function(a){t(a).addClass("np-updated"),e.setBorders(),setTimeout(function(){t(a).addClass("np-updated-show")},1500)}};var NestedPages=NestedPages||{};NestedPages.MenuToggle=function(){var e=this,t=jQuery;return e.formatter=new NestedPages.Formatter,e.bindEvents=function(){t(document).on("click",NestedPages.selectors.childToggleLink,function(a){a.preventDefault(),e.toggleSingleMenu(t(this))}),t(document).on("click",NestedPages.selectors.toggleAll,function(t){t.preventDefault(),e.toggleAllMenus()})},e.toggleSingleMenu=function(a){var s=t(a).parent(NestedPages.selectors.childToggle).parent(NestedPages.selectors.row).siblings("ol");t(a).find("i").toggleClass(NestedPages.cssClasses.iconToggleDown).toggleClass(NestedPages.cssClasses.iconToggleRight),t(s).toggle(),e.formatter.setBorders(),e.formatter.setNestedMargins(),e.syncUserToggles()},e.toggleAllMenus=function(){var a=NestedPages.selectors.toggleAll;return"closed"===t(a).attr("data-toggle")?(t(NestedPages.selectors.lists).show(),t(a).attr("data-toggle","opened").text(NestedPages.jsData.collapseText),t(NestedPages.selectors.childToggle).find("i").removeClass(NestedPages.cssClasses.iconToggleRight).addClass(NestedPages.cssClasses.iconToggleDown),e.formatter.setBorders(),void e.syncUserToggles()):(t(NestedPages.selectors.lists).not(t(NestedPages.selectors.lists)[0]).hide(),t(a).attr("data-toggle","closed").text(NestedPages.jsData.expandText),t(NestedPages.selectors.childToggle).find("i").removeClass(NestedPages.cssClasses.iconToggleDown).addClass(NestedPages.cssClasses.iconToggleRight),e.formatter.setBorders(),void e.syncUserToggles())},e.visibleRowIDs=function(){var e=[],a=t(NestedPages.selectors.rows+":visible");return t.each(a,function(){var a=t(this).attr("id");e.push(a.replace("menuItem_",""))}),e},e.syncUserToggles=function(){t.ajax({url:NestedPages.jsData.ajaxurl,type:"post",datatype:"json",data:{action:NestedPages.formActions.syncToggles,nonce:NestedPages.jsData.nonce,ids:e.visibleRowIDs(),posttype:NestedPages.jsData.posttype},success:function(e){"success"!==e.status&&console.log("There was an error saving toggled pages.")}})},e.bindEvents()};var NestedPages=NestedPages||{};NestedPages.PageToggle=function(){var e=this,t=jQuery;return e.formatter=new NestedPages.Formatter,e.init=function(){e.bindEvents()},e.bindEvents=function(){t(document).on("click",NestedPages.selectors.toggleHidden,function(t){t.preventDefault(),e.toggleHidden()}),t(document).on("click",NestedPages.selectors.toggleStatus,function(a){a.preventDefault(),e.toggleStatus(t(this))})},e.toggleHidden=function(){var a=NestedPages.selectors.toggleHidden,s=t(a).attr("href");return"show"===s?(t(a).attr("href","hide").text(NestedPages.jsData.showHiddenText),t(NestedPages.selectors.hiddenRows).removeClass("shown").hide(),e.formatter.updateSubMenuToggle(),void e.formatter.setBorders()):(t(a).attr("href","show").text(NestedPages.jsData.hideHiddenText),t(NestedPages.selectors.hiddenRows).addClass("shown").show(),e.formatter.updateSubMenuToggle(),void e.formatter.setBorders())},e.toggleStatus=function(e){var a=t(e).attr("href");return a=a.substring(1),t(NestedPages.selectors.toggleStatus).removeClass("active"),t(e).addClass("active"),"all"==a?void t(NestedPages.selectors.rows).show():(t(NestedPages.selectors.rows).hide(),void t("."+a).show())},e.init()};var NestedPages=NestedPages||{};NestedPages.Nesting=function(){var e=this,t=jQuery;e.formatter=new NestedPages.Formatter,e.initializeSortable=function(){maxLevels=NestedPages.jsData.nestable?0:1,t(NestedPages.selectors.sortable).not(NestedPages.selectors.notSortable).nestedSortable({items:NestedPages.selectors.rows,toleranceElement:"> .row",handle:NestedPages.selectors.handle,placeholder:"ui-sortable-placeholder",maxLevels:maxLevels,tabSize:56,start:function(e,t){t.placeholder.height(t.item.height())},sort:function(t,a){e.formatter.updatePlaceholderWidth(a)},stop:function(){setTimeout(function(){e.formatter.updateSubMenuToggle(),e.formatter.setBorders(),e.formatter.setNestedMargins()},100),e.syncNesting()}})},e.disableNesting=function(){t(NestedPages.selectors.sortable).sortable("destroy")},e.syncNesting=function(){t(NestedPages.selectors.errorDiv).hide(),t(NestedPages.selectors.loadingIndicator).show(),list=t(NestedPages.selectors.sortable).nestedSortable("toHierarchy",{startDepthCount:0}),e.disableNesting(),t.ajax({url:ajaxurl,type:"post",datatype:"json",data:{action:NestedPages.formActions.syncNesting,nonce:NestedPages.jsData.nonce,list:list,post_type:NestedPages.jsData.posttype,syncmenu:NestedPages.jsData.syncmenu},success:function(a){e.initializeSortable(),"error"===a.status?(t(NestedPages.selectors.errorDiv).text(a.message).show(),t(NestedPages.selectors.loadingIndicator).hide()):t(NestedPages.selectors.loadingIndicator).hide()}})}};var NestedPages=NestedPages||{};NestedPages.SyncMenuSetting=function(){var e=this,t=jQuery;return e.init=function(){e.bindEvents()},e.bindEvents=function(){t(document).ready(function(){"1"===nestedpages.syncmenu&&e.syncSetting()}),t(document).on("change",NestedPages.selectors.syncCheckbox,function(){e.syncSetting()})},e.syncSetting=function(){"page"===NestedPages.jsData.posttype&&0!==t(NestedPages.selectors.syncCheckbox).length&&(NestedPages.jsData.syncmenu=t(NestedPages.selectors.syncCheckbox).is(":checked")?"sync":"nosync",t.ajax({url:NestedPages.jsData.ajaxurl,type:"post",datatype:"json",data:{action:NestedPages.formActions.syncMenu,nonce:NestedPages.jsData.nonce,post_type:NestedPages.jsData.posttype,syncmenu:NestedPages.jsData.syncmenu},success:function(e){"error"===e.status&&alert("There was an error saving the sync setting.")}}))},e.bindEvents()};var NestedPages=NestedPages||{};NestedPages.NewPage=function(){var e=this,t=jQuery;return e.formatter=new NestedPages.Formatter,e.parent_id=0,e.posts="",e.form="",e.init=function(){e.bindEvents()},e.bindEvents=function(){t(document).on("click",NestedPages.selectors.openPageModal,function(t){t.preventDefault(),e.openModal()}),t(document).on("submit",NestedPages.selectors.newPageForm,function(e){e.preventDefault()}),t(document).on("click",NestedPages.selectors.newPageSubmitButton,function(a){a.preventDefault(),e.submitForm(t(this))}),t(document).on("click",NestedPages.selectors.newPageTitle,function(a){a.preventDefault(),e.addTitleField(t(this))}),t(document).on("click",NestedPages.selectors.newPageRemoveTitle,function(a){a.preventDefault(),e.removeTitleField(t(this))}),t(document).on("click",NestedPages.selectors.addChildButton,function(a){a.preventDefault(),e.openQuickEdit(t(this))}),t(NestedPages.selectors.newPageModal).on("hide.bs.modal",function(){e.cancelNewPage()}),t(document).on("click",NestedPages.selectors.cancelNewChildButton,function(a){a.preventDefault(),e.cancelNewPage(),t(NestedPages.selectors.newPageModal).modal("hide")})},e.openModal=function(){var a=t(NestedPages.selectors.newPageFormContainer).clone().find(NestedPages.selectors.newPageForm).addClass("in-modal");t(NestedPages.selectors.newPageModal).find(".modal-body").html(a),t(NestedPages.selectors.newPageModal).find("h3").text(nestedpages.add_multiple),t(NestedPages.selectors.newPageModal).find(".page_parent_id").val(e.parent_id),t(NestedPages.selectors.newPageModal).modal("show")},e.openQuickEdit=function(a){var s=t(a).closest(NestedPages.selectors.row).parent("li"),n=t(NestedPages.selectors.newPageFormContainer).clone();if(t(s).children("ol").length>0){var o=t(s).children("ol");t(n).insertBefore(o)}else t(n).appendTo(s);t(n).siblings(NestedPages.selectors.row).hide(),e.formatter.showQuickEdit(),t(n).find(".parent_name").html("<em>Parent:</em> "+t(a).attr("data-parentname")),t(n).find(".page_parent_id").val(t(a).attr("data-id")),t(n).show(),t(n).find(".np_title").focus()},e.cancelNewPage=function(){e.formatter.removeQuickEdit(),t(NestedPages.selectors.newChildError).hide(),t(NestedPages.selectors.newPageModal).find(".modal-body").empty(),t(NestedPages.selectors.sortable).find(".new-child").remove(),t(NestedPages.selectors.row).show()},e.addTitleField=function(e){{var a=t(e).parents("form"),s=t(e).siblings(".new-page-titles").children("li").length+1,n='<li><i class="handle np-icon-menu"></i><div class="form-control new-child-row"><label>'+NestedPages.jsData.titleText+'</label><div><input type="text" name="post_title[]" class="np_title" placeholder="'+NestedPages.jsData.titleText+'" value="" tabindex="'+s+'" /><a href="#" class="button-secondary np-remove-child">-</a></div></div></li>';t(e).siblings(".new-page-titles").append(n)}t(a).find(".np_title").last().focus(),t(".new-page-titles").sortable({items:"li",handle:".handle"})},e.removeTitleField=function(e){t(e).parents(".new-child-row").parent("li").remove()},e.submitForm=function(a){e.toggleLoading(!0),e.form=t(a).parents("form");var s=t(a).hasClass("add-edit")?!0:!1;t.ajax({url:NestedPages.jsData.ajaxurl,type:"post",datatype:"json",data:t(e.form).serialize()+"&action="+NestedPages.formActions.newPage+"&nonce="+NestedPages.jsData.nonce+"&syncmenu="+NestedPages.jsData.syncmenu+"&post_type="+NestedPages.jsData.posttype,success:function(a){if("error"===a.status)return e.toggleLoading(!1),void t(e.form).find(NestedPages.selectors.quickEditErrorDiv).text(a.message).show();if(s===!0){var n=a.new_pages[0].edit_link;return n=n.replace(/&amp;/g,"&"),void window.location.replace(n)}e.toggleLoading(!1),e.posts=a.new_pages,e.addPosts()},error:function(){e.toggleLoading(!1),t(form).find(NestedPages.selectors.quickEditErrorDiv).text("The form could not be saved at this time.").show()}})},e.addPosts=function(){var a=t(e.form).parent(".new-child").parent(".page-row");if(0===t(a).children("ol").length&&t(a).append('<ol class="nplist"></ol>'),t(e.form).hasClass("in-modal"))var s=t(".nplist.sortable li.page-row:first");else var s=t(a).children("ol");for(i=0;i<e.posts.length;i++)e.appendRows(s,e.posts[i]);t(s).show(),e.formatter.updateSubMenuToggle(),e.cancelNewPage(),t(NestedPages.selectors.newPageModal).modal("hide")},e.appendRows=function(e,a){var s='<li id="menuItem_'+a.id+'" class="page-row';"publish"===a.status&&(s+=" published"),s+='">',NestedPages.jsData.hierarchical?(s+='<div class="row">',s+='<div class="child-toggle"></div>'):s+='<div class="row non-hierarchical">',s+='<div class="row-inner">',s+='<i class="np-icon-sub-menu"></i><i class="handle np-icon-menu"></i>',s+='<a href="'+a.edit_link+'" class="page-link page-title">',s+='<span class="title">'+a.title+"</span>",s+="Publish"!==a.status?'<span class="status">('+a.status+")</span>":'<span class="status"></span>',s+='<span class="nav-status"></span><span class="edit-indicator"><i class="np-icon-pencil"></i>Edit</span>',s+="</a>",s+='<div class="action-buttons">',s+='<a href="#" class="np-btn open-redirect-modal" data-parentid="'+a.id+'"><i class="np-icon-link"></i></a>',s+='<a href="#" class="np-btn add-new-child" data-id="'+a.id+'" data-parentname="'+a.title+'">'+nestedpages.add_child_short+"</a>",s+='<a href="#" class="np-btn np-quick-edit" data-id="'+a.id+'" data-template="'+a.page_template+'" data-title="'+a.title+'" data-slug="'+a.slug+'" data-commentstatus="closed" data-status="'+a.status.toLowerCase()+'" data-np-status="show" data-navstatus="show" data-author="'+a.author+'" data-template="'+a.template+'" data-month="'+a.month+'" data-day="'+a.day+'" data-year="'+a.year+'" data-hour="'+a.hour+'" data-minute="'+a.minute+'" data-datepicker="'+a.datepicker+'" data-time="'+a.time+'" data-formattedtime="'+a.formattedtime+'" data-ampm="'+a.ampm+'">'+nestedpages.quick_edit+"</a>",s+='<a href="'+a.view_link+'" class="np-btn" target="_blank">'+nestedpages.view+"</a>",s+='<a href="'+a.delete_link+'" class="np-btn np-btn-trash"><i class="np-icon-remove"></i></a>',s+="</div><!-- .action-buttons -->",s+="</div><!-- .row-inner --></div><!-- .row -->",s+="</li>",t(e).append(s)},e.toggleLoading=function(e){return e?(t(NestedPages.selectors.quickEditErrorDiv).hide(),t(NestedPages.selectors.newPageSubmitButton).attr("disabled","disabled"),void t(NestedPages.selectors.quickEditLoadingIndicator).show()):(t(NestedPages.selectors.newPageSubmitButton).attr("disabled",!1),void t(NestedPages.selectors.quickEditLoadingIndicator).hide())},e.init()};var NestedPages=NestedPages||{};NestedPages.QuickEditPost=function(){var e=this,t=jQuery;return e.formatter=new NestedPages.Formatter,e.button="",e.initialData="",e.parent_li="",e.form="",e.flatTerms="",e.termNames="",e.saveButton="",e.newData="",e.row="",e.init=function(){e.bindEvents()},e.bindEvents=function(){t(document).on("click",NestedPages.selectors.quickEditOpen,function(a){a.preventDefault(),e.button=t(this),e.openForm()}),t(document).on("click",NestedPages.selectors.quickEditCancel,function(t){t.preventDefault(),e.formatter.removeQuickEdit()}),t(document).on("click",NestedPages.selectors.quickEditToggleTaxonomies,function(e){e.preventDefault(),t(this).parents("form").find(".np-taxonomies").toggle()}),t(document).on("click",NestedPages.selectors.quickEditToggleMenuOptions,function(e){e.preventDefault(),t(this).parents("form").find(".np-menuoptions").toggle()}),t(document).on("change",".keep_private",function(){this.checked?t(".post_password").val("").prop("readonly",!0):t(".post_password").prop("readonly",!1)}),t(document).on("click",NestedPages.selectors.quickEditSaveButton,function(a){a.preventDefault(),e.saveButton=t(this),e.save()}),t(document).on("keydown",function(t){27===t.keyCode&&e.formatter.removeQuickEdit()})},e.openForm=function(){e.setInitialData(),e.createForm(),e.populateForm(),e.populateFlatTaxonomies()},e.setInitialData=function(){e.initialData={id:t(e.button).attr("data-id"),title:t(e.button).attr("data-title"),slug:t(e.button).attr("data-slug"),author:t(e.button).attr("data-author"),cs:t(e.button).attr("data-commentstatus"),status:t(e.button).attr("data-status"),template:t(e.button).attr("data-template"),month:t(e.button).attr("data-month"),day:t(e.button).attr("data-day"),year:t(e.button).attr("data-year"),hour:t(e.button).attr("data-hour"),minute:t(e.button).attr("data-minute"),navstatus:t(e.button).attr("data-navstatus"),npstatus:t(e.button).attr("data-np-status"),navtitle:t(e.button).attr("data-navtitle"),navtitleattr:t(e.button).attr("data-navtitleattr"),navcss:t(e.button).attr("data-navcss"),linktarget:t(e.button).attr("data-linktarget"),password:t(e.button).attr("data-password"),datepicker:t(e.button).attr("data-datepicker"),time:t(e.button).attr("data-formattedtime"),ampm:t(e.button).attr("data-ampm")},e.initialData.h_taxonomies=[],e.initialData.f_taxonomies=[],e.parent_li=t(e.button).closest(NestedPages.selectors.row).parent("li");var a=t(e.parent_li).attr("class").split(/\s+/);for(i=0;i<a.length;i++)"in-"===a[i].substring(0,3)&&e.initialData.h_taxonomies.push(a[i]),"inf-"===a[i].substring(0,4)&&e.initialData.f_taxonomies.push(a[i])},e.createForm=function(){if(e.form=t(NestedPages.selectors.quickEditPostForm).clone(),t(e.parent_li).children("ol").length>0){var a=t(e.parent_li).children("ol");t(e.form).insertBefore(a)}else t(e.form).appendTo(e.parent_li);t(e.form).siblings(NestedPages.selectors.row).hide(),t(e.form).show()},e.populateForm=function(){if(t(e.form).find(".page_id").html("<em>ID:</em> "+e.initialData.id),t(e.form).find(".np_id").val(e.initialData.id),t(e.form).find(".np_title").val(e.initialData.title),t(e.form).find(".np_slug").val(e.initialData.slug),t(e.form).find(".np_author select").val(e.initialData.author),t(e.form).find(".np_status").val(e.initialData.status),t(e.form).find(".np_nav_title").val(e.initialData.navtitle),t(e.form).find(".np_title_attribute").val(e.initialData.navtitleattr),t(e.form).find(".np_nav_css_classes").val(e.initialData.navcss),t(e.form).find(".post_password").val(e.initialData.password),t(e.form).find(".np_datepicker").val(e.initialData.datepicker),t(e.form).find(".np_time").val(e.initialData.time),t(e.form).find(".np_ampm").val(e.initialData.ampm),"open"===e.initialData.cs&&t(e.form).find(".np_cs").attr("checked","checked"),t(e.form).find(".np_template").val(""!==e.initialData.template?e.initialData.template:"default"),"private"===e.initialData.status&&(t(e.form).find(".post_password").attr("readonly",!0),t(e.form).find(".keep_private").attr("checked",!0)),"hide"===e.initialData.npstatus?t(e.form).find(".np_status").attr("checked","checked"):t(e.form).find(".np_status").removeAttr("checked"),"hide"===e.initialData.navstatus?t(e.form).find(".np_nav_status").attr("checked","checked"):t(e.form).find(".np_nav_status").attr("checked",!1),"_blank"===e.initialData.linktarget?t(e.form).find(".link_target").attr("checked","checked"):t(e.form).find(".link_target").attr("checked",!1),"private"===e.initialData.status&&t(e.form).find(".np_status").val("publish"),t(e.form).find('select[name="mm"]').val(e.initialData.month),t(e.form).find('input[name="jj"]').val(e.initialData.day),t(e.form).find('input[name="aa"]').val(e.initialData.year),t(e.form).find('input[name="hh"]').val(e.initialData.hour),t(e.form).find('input[name="mn"]').val(e.initialData.minute),e.initialData.hasOwnProperty("h_taxonomies")){var a=e.initialData.h_taxonomies;for(i=0;i<a.length;i++){var s="#"+a[i];t(e.form).find(s).attr("checked","checked")}}t(e.form).find(".np_datepicker").datepicker({beforeShow:function(){t("#ui-datepicker-div").addClass("nestedpages-datepicker")}}),e.formatter.showQuickEdit(),t(e.form).show()},e.populateFlatTaxonomies=function(){e.initialData.hasOwnProperty("f_taxonomies")&&(e.createTaxonomyObject(),e.getTermNames(),e.setWPSuggest())},e.createTaxonomyObject=function(){var t={};for(i=0;i<e.initialData.f_taxonomies.length;i++){var a=e.initialData.f_taxonomies[i],s=a.split("-"),n=s.indexOf("nps"),o=s.splice(n+1);o=o.join("-");var r=a.split("-").splice(0,n);r.shift("inf");var d=r.join("-");d in t||(t[d]=[]);var l=t[d];l.push(o)}e.flatTerms=t},e.getTermNames=function(){t.ajax({url:NestedPages.jsData.ajaxurl,type:"post",datatype:"json",data:{action:NestedPages.formActions.getTaxonomies,nonce:NestedPages.jsData.nonce,terms:e.flatTerms},success:function(t){e.termNames=t.terms,e.populateFlatTaxonomyFields()}})},e.populateFlatTaxonomyFields=function(){e.termNames&&t.each(e.termNames,function(e,a){var s=t("#"+e);t(s).val(a.join(","))})},e.setWPSuggest=function(){var a=t(e.form).find("[data-autotag]");t.each(a,function(){var e=t(this).attr("data-taxonomy");t(this).suggest(ajaxurl+"?action=ajax-tag-search&tax="+e,{multiple:!0,multipleSep:","})})},e.save=function(){e.toggleLoading(!0),t.ajax({url:NestedPages.jsData.ajaxurl,type:"post",datatype:"json",data:t(e.form).find("form").serialize()+"&action="+NestedPages.formActions.quickEditPost+"&nonce="+NestedPages.jsData.nonce+"&syncmenu="+NestedPages.jsData.syncmenu+"&post_type="+NestedPages.jsData.posttype,success:function(a){"error"===a.status?(e.toggleLoading(!1),t(e.form).find(NestedPages.selectors.quickEditErrorDiv).text(a.message).show()):(e.toggleLoading(!1),e.newData=a.post_data,e.updatePostRow())},error:function(e){console.log(e)}})},e.updatePostRow=function(){e.row=t(e.button).parents(".row-inner"),t(e.row).find(".title").text(e.newData.post_title);var a=t(e.row).find(".status");if(t(a).text("publish"!==e.newData._status&&"future"!==e.newData._status?"("+e.newData._status+")":"private"===e.newData.keep_private?"("+e.newData.keep_private+")":""),""!==e.newData.post_password){var s=t(a).text();s+=' <i class="np-icon-lock"></i>',t(a).html(s)}var n=t(e.row).find(".nav-status");t(n).text("hide"==e.newData.nav_status?"(Hidden)":"");var o=t(e.row).parent("li");"hide"==e.newData.np_status?(t(o).addClass("np-hide"),t(e.row).find(".status").after('<i class="np-icon-eye-blocked"></i>')):(t(o).removeClass("np-hide"),t(e.row).find(".np-icon-eye-blocked").remove()),NestedPages.jsData.hierarchical||t(e.row).find(".np-author-display").text(e.newData.author_name);var i=t(e.row).find(NestedPages.selectors.quickEditOpen);t(i).attr("data-id",e.newData.post_id),t(i).attr("data-template",e.newData.page_template),t(i).attr("data-title",e.newData.post_title),t(i).attr("data-slug",e.newData.post_name),t(i).attr("data-commentstatus",e.newData.comment_status),t(i).attr("data-status",e.newData._status),"private"===e.newData.keep_private&&t(i).attr("data-status","private"),t(i).attr("data-author",e.newData.post_author),t(i).attr("data-np-status",e.newData.np_status),t(i).attr("data-password",e.newData.post_password),t(i).attr("data-navstatus",e.newData.nav_status),t(i).attr("data-navtitle",e.newData.np_nav_title),t(i).attr("data-linktarget",e.newData.link_target),t(i).attr("data-navtitleattr",e.newData.np_title_attribute),t(i).attr("data-navcss",e.newData.np_nav_css_classes),t(i).attr("data-month",e.newData.mm),t(i).attr("data-day",e.newData.jj),t(i).attr("data-year",e.newData.aa),t(i).attr("data-hour",e.newData.hh),t(i).attr("data-minute",e.newData.mn),t(i).attr("data-datepicker",e.newData.np_date),t(i).attr("data-time",e.newData.np_time),t(i).attr("data-formattedtime",e.newData.np_time),t(i).attr("data-ampm",e.newData.np_ampm),e.removeTaxonomyClasses(),e.addCategoryClasses(),e.addHierarchicalClasses(),e.addFlatClasses(),e.addStatusClass(),e.formatter.removeQuickEdit(),e.formatter.flashRow(e.row)},e.addStatusClass=function(){var a=["published","draft","pending","future"];for(i=0;i<a.length;i++)t(e.row).removeClass(a[i]);t(e.row).addClass(e.newData._status)},e.removeTaxonomyClasses=function(){taxonomies=[];var a=t(e.row).attr("class").split(/\s+/);for(i=0;i<a.length;i++)"in-"===a[i].substring(0,3)&&t(e.row).removeClass(a[i]),"inf-"===a[i].substring(0,4)&&t(e.row).removeClass(a[i])},e.addCategoryClasses=function(){if(e.newData.hasOwnProperty("post_category")){var a=e.newData.post_category;for(i=0;i<a.length;i++){var s="in-category-"+a[i];t(e.row).addClass(s)}}},e.addHierarchicalClasses=function(){if(e.newData.hasOwnProperty("tax_input")){var a=e.newData.tax_input;t.each(a,function(a,s){for(i=0;i<s.length;i++){var n="in-"+a+"-"+s[i];t(e.row).addClass(n)}})}},e.addFlatClasses=function(){if(e.newData.hasOwnProperty("flat_tax")){var a=e.newData.flat_tax;t.each(a,function(a,s){for(i=0;i<s.length;i++){var n="inf-"+a+"-nps-"+s[i];t(e.row).addClass(n)}})}},e.toggleLoading=function(a){return a?(t(NestedPages.selectors.quickEditErrorDiv).hide(),t(e.saveButton).attr("disabled","disabled"),void t(NestedPages.selectors.quickEditLoadingIndicator).show()):(t(e.saveButton).attr("disabled",!1),void t(NestedPages.selectors.quickEditLoadingIndicator).hide())},e.init()};var NestedPages=NestedPages||{};NestedPages.QuickEditLink=function(){var e=this,t=jQuery;return e.formatter=new NestedPages.Formatter,e.button="",e.postData="",e.newPostData="",e.form="",e.init=function(){e.bindEvents()},e.bindEvents=function(){t(document).on("click",NestedPages.selectors.quickEditButtonLink,function(a){a.preventDefault(),e.formatter.removeQuickEdit(),e.button=t(this),e.openQuickEdit()}),t(document).on("click",NestedPages.selectors.quickEditLinkSaveButton,function(t){t.preventDefault(),e.submitForm()}),t(document).on("keydown",function(t){27===t.keyCode&&e.formatter.removeQuickEdit()})},e.openQuickEdit=function(){e.setData(),e.createForm(),e.populateForm()},e.setData=function(){e.postData={id:t(e.button).attr("data-id"),url:t(e.button).attr("data-url"),title:t(e.button).attr("data-title"),status:t(e.button).attr("data-status"),navstatus:t(e.button).attr("data-navstatus"),npstatus:t(e.button).attr("data-np-status"),linktarget:t(e.button).attr("data-linktarget"),parentid:t(e.button).attr("data-parentid"),navtitleattr:t(e.button).attr("data-navtitleattr"),navcss:t(e.button).attr("data-navcss"),navtype:t(e.button).attr("data-nav-type"),navobject:t(e.button).attr("data-nav-object"),navobjectid:t(e.button).attr("data-nav-object-id"),navoriginallink:t(e.button).attr("data-nav-original-link"),navoriginaltitle:t(e.button).attr("data-nav-original-title")}},e.createForm=function(){var a=t(e.button).closest(NestedPages.selectors.row).parent("li");if(e.form=t(NestedPages.selectors.quickEditLinkForm).clone(),t(a).children("ol").length>0){var s=t(a).children("ol");t(e.form).insertBefore(s)}else t(e.form).appendTo(a);t(e.form).siblings(NestedPages.selectors.row).hide()},e.populateForm=function(){if(t(e.form).find(".np_id").val(e.postData.id),t(e.form).find(".np_title").val(e.postData.title),t(e.form).find(".np_author select").val(e.postData.author),t(e.form).find(".np_status").val(e.postData.status),t(e.form).find(".np_content").val(e.postData.url),t(e.form).find(".np_parent_id").val(e.postData.parentid),t(e.form).find(".np_title_attribute").val(e.postData.navtitleattr),t(e.form).find(".np_nav_css_classes").val(e.postData.navcss),"hide"===e.postData.npstatus?t(e.form).find(".np_status").prop("checked","checked"):t(e.form).find(".np_status").removeAttr("checked"),"hide"===e.postData.navstatus?t(e.form).find(".np_nav_status").prop("checked","checked"):t(e.form).find(".np_nav_status").removeAttr("checked"),"_blank"===e.postData.linktarget?t(e.form).find(".link_target").prop("checked","checked"):t(e.form).find(".link_target").removeAttr("checked"),"custom"!==e.postData.navobject&&""!==e.postData.navobject){var a='<div class="form-control original-link">Original: <a href="'+e.postData.navoriginallink+'" target="_blank">'+e.postData.navoriginaltitle+"</a></div>";t(e.form).find("[data-url-field]").remove(),t(a).insertAfter(t(e.form).find("h3")),t(e.form).find("[data-np-menu-object-input]").val(e.postData.navobject),t(e.form).find("[data-np-menu-objectid-input]").val(e.postData.navobjectid),t(e.form).find("[data-np-menu-type-input]").val(e.postData.navtype),t(e.form).find("h3").text("Link: "+e.postData.navoriginaltitle)}else t(e.form).find("h3").text("Link"),t(e.form).find("[data-np-menu-object-input]").val("custom"),t(e.form).find("[data-np-menu-type-input]").val("custom");e.formatter.showQuickEdit(),t(e.form).show()},e.submitForm=function(){e.toggleLoading(!0),t.ajax({url:NestedPages.jsData.ajaxurl,type:"post",datatype:"json",data:t(e.form).find("form").serialize()+"&action="+NestedPages.formActions.quickEditLink+"&nonce="+NestedPages.jsData.nonce+"&syncmenu="+NestedPages.jsData.syncmenu+"&post_type="+NestedPages.jsData.posttype,success:function(a){"error"===a.status?(e.toggleLoading(!1),t(e.form).find(NestedPages.selectors.quickEditErrorDiv).text(a.message).show()):(e.toggleLoading(!1),e.newPostData=a.post_data,e.updateRow())},error:function(){e.toggleLoading(!1),t(e.form).find(NestedPages.selectors.quickEditErrorDiv).text("The form could not be saved at this time.").show()}})},e.updateRow=function(){console.log(e.newPostData);var a=t(e.form).siblings(".row");t(a).find(".title").html(e.newPostData.post_title+' <i class="np-icon-link"></i>');var s=t(a).find(".status");t(s).text("publish"!==e.newPostData._status&&"future"!==e.newPostData._status?"("+e.newPostData._status+")":"");var n=t(a).find(".nav-status");t(n).text("hide"==e.newPostData.nav_status?"("+NestedPages.jsData.hiddenText+")":"");var o=t(a).parent("li");"hide"==e.newPostData.np_status?(t(o).addClass("np-hide"),t(a).find(".status").after('<i class="np-icon-eye-blocked"></i>')):(t(o).removeClass("np-hide"),t(a).find(".np-icon-eye-blocked").remove());var i=t(a).find(NestedPages.selectors.quickEditButtonLink);t(i).attr("data-id",e.newPostData.post_id),t(i).attr("data-title",e.newPostData.post_title),t(i).attr("data-url",e.newPostData.post_content),t(i).attr("data-status",e.newPostData._status),t(i).attr("data-navstatus",e.newPostData.nav_status),t(i).attr("data-np-status",e.newPostData.np_status),t(i).attr("data-linkTarget",e.newPostData.linkTarget),t(i).attr("data-navtitleattr",e.newPostData.titleAttribute),t(i).attr("data-navcss",e.newPostData.cssClasses),e.formatter.removeQuickEdit(),e.formatter.flashRow(a)},e.toggleLoading=function(e){return t(".row").removeClass("np-updated").removeClass("np-updated-show"),e?(t(NestedPages.selectors.quickEditErrorDiv).hide(),t(NestedPages.selectors.quickEditLinkSaveButton).attr("disabled","disabled"),void t(NestedPages.selectors.quickEditLoadingIndicator).show()):(t(NestedPages.selectors.quickEditLinkSaveButton).attr("disabled",!1),void t(NestedPages.selectors.quickEditLoadingIndicator).hide())},e.init()};var NestedPages=NestedPages||{};NestedPages.Clone=function(){var e=this,t=jQuery;return e.parent_id="",e.parent_title="",e.parentLi=null,e.formatter=new NestedPages.Formatter,e.init=function(){e.bindEvents()},e.bindEvents=function(){t(document).on("click",NestedPages.selectors.cloneButton,function(a){a.preventDefault(),e.parent_id=t(this).attr("data-id"),e.parent_title=t(this).attr("data-parentname"),e.parentLi=t(this).parent(".row").parent(".page-row").parent(".npList"),e.openModal()}),t(document).on("click",NestedPages.selectors.confirmClone,function(t){t.preventDefault(),e.clone()})},e.openModal=function(){t(NestedPages.selectors.cloneModal).find("[data-clone-parent]").text(e.parent_title),t(NestedPages.selectors.cloneModal).modal("show")},e.clone=function(){e.toggleLoading(!0),t.ajax({url:NestedPages.jsData.ajaxurl,type:"post",data:{action:NestedPages.formActions.clonePost,parent_id:e.parent_id,quantity:t(NestedPages.selectors.cloneQuantity).val(),status:t(NestedPages.selectors.cloneStatus).val(),author:t(NestedPages.selectors.cloneAuthor).find("select").val(),nonce:NestedPages.jsData.nonce,posttype:NestedPages.jsData.posttype},success:function(){e.toggleLoading(!1),t(NestedPages.selectors.cloneModal).modal("hide"),location.reload()}})},e.toggleLoading=function(e){return e?(t(NestedPages.selectors.cloneModal).find("[data-clone-loading]").show(),void t(NestedPages.selectors.confirmClone).attr("disabled","disabled")):(t(NestedPages.selectors.cloneModal).find("[data-clone-loading]").hide(),void t(NestedPages.selectors.confirmClone).attr("disabled",!1))
2
+ },e.init()};var NestedPages=NestedPages||{};NestedPages.Tabs=function(){var e=this,t=jQuery;return e.activeContent="",e.activeButton="",e.init=function(){e.bindEvents()},e.bindEvents=function(){t(document).on("click",NestedPages.selectors.tabButton,function(a){a.preventDefault(),e.activeButton=t(this),e.toggleTabs()})},e.toggleTabs=function(){e.activeContent=t(e.activeButton).attr("href"),t(NestedPages.selectors.tabContent).hide(),t(e.activeContent).show(),t(e.activeButton).parents(NestedPages.selectors.tabButtonParent).find(NestedPages.selectors.tabButton).removeClass("active"),t(e.activeButton).addClass("active")},e.init()},jQuery(document).ready(function(){new NestedPages.Factory});var NestedPages=NestedPages||{};NestedPages.selectors={childToggle:".child-toggle",childToggleLink:".child-toggle a",toggleAll:".nestedpages-toggleall",toggleHidden:".np-toggle-hidden",toggleStatus:".np-toggle-publish",lists:".nplist",rows:".page-row",row:".row",sortable:".sortable",notSortable:".no-sort",handle:".handle",published:".published",hiddenRows:".np-hide",errorDiv:"#np-error",loadingIndicator:"#nested-loading",syncCheckbox:".np-sync-menu",toggleEditButtons:".np-toggle-edit",quickEditOverlay:".np-inline-overlay",quickEditLoadingIndicator:".np-qe-loading",quickEditErrorDiv:".np-quickedit-error",quickEditCancel:".np-cancel-quickedit",quickEditToggleTaxonomies:".np-toggle-taxonomies",quickEditToggleMenuOptions:".np-toggle-menuoptions",quickEditButtonLink:".np-quick-edit-redirect",quickEditLinkForm:".quick-edit-form-redirect",quickEditLinkSaveButton:".np-save-quickedit-redirect",quickEditOpen:".np-quick-edit",quickEditPostForm:".quick-edit-form",quickEditSaveButton:".np-save-quickedit",openLinkModal:".open-redirect-modal",linkModal:"#np-link-modal",saveLink:".np-save-link",linkLoadingIndicator:".np-link-loading",linkErrorDiv:".np-new-link-error",linkForm:".np-new-link-form",openPageModal:".open-bulk-modal",newPageModal:"#np-bulk-modal",newPageFormContainer:".new-child-form",newPageForm:".np-new-child-form",newPageSubmitButton:".np-save-newchild",newPageTitle:".add-new-child-row",newPageRemoveTitle:".np-remove-child",addChildButton:".add-new-child",newChildError:".np-newchild-error",cancelNewChildButton:".np-cancel-newchild",cloneButton:".clone-post",confirmClone:"[data-confirm-clone]",cloneModal:"#np-clone-modal",cloneQuantity:"[data-clone-quantity]",cloneStatus:"[data-clone-status]",cloneAuthor:"[data-clone-author]",tabButtonParent:"[data-np-tabs]",tabButton:"[data-np-tab]",tabContent:"[data-np-tab-pane]"},NestedPages.cssClasses={iconToggleDown:"np-icon-arrow-down",iconToggleRight:"np-icon-arrow-right",noborder:"no-border"},NestedPages.jsData={ajaxurl:ajaxurl,nonce:nestedpages.np_nonce,allPostTypes:nestedpages.post_types,syncmenu:"nosync",posttype:"",nestable:!0,hierarchical:!0,expandText:nestedpages.expand_text,collapseText:nestedpages.collapse_text,showHiddenText:nestedpages.show_hidden,hideHiddenText:nestedpages.hide_hidden,quickEditText:nestedpages.quick_edit,hiddenText:nestedpages.hidden,titleText:nestedpages.title},NestedPages.formActions={syncToggles:"npnestToggle",syncNesting:"npsort",syncMenu:"npsyncMenu",newPage:"npnewChild",quickEditLink:"npquickEditLink",getTaxonomies:"npgetTaxonomies",quickEditPost:"npquickEdit",clonePost:"npclonePost",search:"npmenuSearch",newMenuItem:"npnewMenuItem"},NestedPages.Factory=function(){var e=this,t=jQuery;return e.formatter=new NestedPages.Formatter,e.responsive=new NestedPages.Responsive,e.menuToggle=new NestedPages.MenuToggle,e.pageToggle=new NestedPages.PageToggle,e.nesting=new NestedPages.Nesting,e.syncMenuSetting=new NestedPages.SyncMenuSetting,e.newPage=new NestedPages.NewPage,e.quickEditLink=new NestedPages.QuickEditLink,e.quickEditPost=new NestedPages.QuickEditPost,e.clone=new NestedPages.Clone,e.tabs=new NestedPages.Tabs,e.menuLinks=new NestedPages.MenuLinks,e.init=function(){e.bindEvents(),e.setPostType(),e.setMenuSync(),e.setNestable(),e.formatter.updateSubMenuToggle(),e.formatter.setBorders(),e.formatter.setNestedMargins(),e.nesting.initializeSortable()},e.bindEvents=function(){t(document).on("click",NestedPages.selectors.quickEditOverlay,function(){e.formatter.removeQuickEdit(),e.newPage.cancelNewPage()})},e.setNestable=function(){var e=!0;t.each(NestedPages.jsData.allPostTypes,function(t,a){a.name===NestedPages.jsData.posttype&&(a.hierarchical===!0&&(e=!0),a.disable_nesting===!0&&(e=!1))}),NestedPages.jsData.nestable=e},e.setPostType=function(){NestedPages.jsData.posttype=t(NestedPages.selectors.sortable).attr("id").substring(3),NestedPages.jsData.hierarchical=NestedPages.jsData.allPostTypes[NestedPages.jsData.posttype].hierarchical},e.setMenuSync=function(){NestedPages.jsData.syncmenu="1"===nestedpages.syncmenu?"sync":"nosync"},e.init()};var NestedPages=NestedPages||{};NestedPages.MenuLinks=function(){var e=this,t=jQuery;return e.typeButton="",e.post="",e.formatter=new NestedPages.Formatter,e.selectors={form:"[data-np-menu-item-form]",typeSelect:"[data-np-menu-selection]",accordion:"[data-np-menu-accordion]",accordionItem:"[data-np-menu-accordion-item]",formPlaceholder:".np-menu-link-object-placeholder",formDetails:".np-menu-link-details",searchResults:"[data-np-search-result]",defaultResults:"[data-default-result]",originalLink:"[data-np-original-link]",saveButton:"[data-np-save-link]",urlInputCont:"[data-np-menu-url-cont]",errorDiv:"[data-np-error]"},e.fields={object:"[data-np-menu-object-input]",objectid:"[data-np-menu-objectid-input]",itemType:"[data-np-menu-type-input]",url:"[data-np-menu-url]",navigationLabel:"[data-np-menu-navigation-label]",titleAttribute:"[data-np-menu-title-attr]",cssClasses:"[data-np-menu-css-classes]",npStatus:"[data-np-menu-np-status]",linkTarget:"[data-np-menu-link-target]",menuTitle:"[data-np-menu-title]"},e.search=new NestedPages.MenuSearch,e.init=function(){e.bindEvents()},e.bindEvents=function(){t(document).on("click",NestedPages.selectors.openLinkModal,function(a){a.preventDefault(),e.postParent=t(this).attr("data-parentid"),t(e.selectors.form).find(".parent_id").val(t(this).attr("data-parentid")),e.openModal()}),t(document).on("click",e.selectors.accordionItem,function(a){a.preventDefault(),e.accordion(t(this))}),t(document).on("click",e.selectors.typeSelect,function(a){a.preventDefault(),e.typeButton=t(this),e.setLinkType()}),t(document).on("keyup",e.fields.navigationLabel,function(){e.updateTitle()}),t(document).on("click",e.selectors.saveButton,function(t){t.preventDefault(),e.submitForm()}),t(document).on("keydown",function(e){27===e.keyCode&&t("#np-link-modal").modal("hide")})},e.openModal=function(){t(NestedPages.selectors.linkErrorDiv).hide(),t(NestedPages.selectors.linkModal).find("input").val(""),t(NestedPages.selectors.linkModal).find(".parent_id").val(e.postParent),e.clearForm(),t(e.selectors.accordion).find("ul").hide(),t(e.selectors.typeSelect).removeClass("active"),t(NestedPages.selectors.linkModal).modal("show")},e.accordion=function(a){e.clearForm();var s=t(a).siblings("ul");return t(s).is(":visible")?(t(a).removeClass("active"),void t(s).slideUp("fast")):(t(e.selectors.accordionItem).removeClass("active"),t(a).addClass("active"),t(a).parents(e.selectors.accordion).find("ul").slideUp("fast"),void t(s).slideDown("fast"))},e.setLinkType=function(){return t(e.typeButton).hasClass("active")?void e.clearForm():(t(e.typeButton).hasClass("np-custom-link")&&(t(e.selectors.accordionItem).removeClass("active"),t(e.selectors.accordion).find("ul").slideUp("fast")),t(e.selectors.formPlaceholder).hide(),void e.populateForm())},e.populateForm=function(){t(e.selectors.saveButton).show(),t(e.selectors.typeSelect).removeClass("active"),t(e.typeButton).addClass("active"),t(e.fields.menuTitle).text(t(e.typeButton).text()).val(t(e.typeButton).text()),t(e.selectors.form).find("h3").find("em").text(t(e.typeButton).attr("data-np-object-name")),""!==t(e.typeButton).attr("data-np-permalink")?(t(e.selectors.form).find(e.selectors.urlInputCont).hide(),t(e.selectors.form).find(e.selectors.originalLink).html('<a href="'+t(e.typeButton).attr("data-np-permalink")+'">'+t(e.typeButton).text()+"</a>"),t(e.selectors.form).find(e.selectors.originalLink).parent(".original-link").show()):(t(e.selectors.form).find(e.selectors.urlInputCont).show(),t(e.selectors.form).find(e.selectors.originalLink).parent(".original-link").hide()),t(e.fields.object).val(t(e.typeButton).attr("data-np-menu-object")),t(e.fields.objectid).val(t(e.typeButton).attr("data-np-menu-objectid")),t(e.fields.itemType).val(t(e.typeButton).attr("data-np-menu-type")),t(e.selectors.formDetails).show()},e.clearForm=function(){t(e.selectors.form).find(e.selectors.errorDiv).hide(),t(e.selectors.saveButton).hide(),t(e.selectors.formDetails).hide(),t(e.selectors.formPlaceholder).show(),t(e.selectors.form).find("input").not(".parent_id").val(""),t(e.selectors.form).find(e.fields.linkTarget).val("_blank"),t(e.selectors.form).find('input[type="checkbox"]').attr("checked",!1),t(e.selectors.typeSelect).removeClass("active"),e.search.toggleLoading(!1),t(e.selectors.searchResults).remove(),t(e.selectors.defaultResults).show()},e.updateTitle=function(){var a=t(e.fields.navigationLabel).val(),s=t(e.selectors.form).find("h3").find("span");""!==a?(t(e.fields.menuTitle).val(a),t(s).text(a)):(t(e.fields.menuTitle).val(t(e.typeButton).text()),t(s).text(t(e.typeButton).text()))},e.submitForm=function(){e.toggleLoading(!0),t.ajax({url:NestedPages.jsData.ajaxurl,type:"post",data:t(e.selectors.form).serialize()+"&action="+NestedPages.formActions.newMenuItem+"&nonce="+NestedPages.jsData.nonce+"&post_type="+NestedPages.jsData.posttype+"&syncmenu="+NestedPages.jsData.syncmenu,success:function(a){return e.toggleLoading(!1),"error"===a.status?void t(e.selectors.form).find(e.selectors.errorDiv).text(a.message).show():(e.post=a.post_data,void e.createRow())},error:function(e){console.log(e)}})},e.createRow=function(){var a='<li id="menuItem_'+e.post.id+'" class="page-row published';a+='">',a+='<div class="row"><div class="child-toggle"></div><div class="row-inner"><i class="np-icon-sub-menu"></i><i class="handle np-icon-menu"></i><a href="'+e.post.np_link_content+'" class="page-link page-title" target="_blank"><span class="title">'+e.post.menuTitle+' <i class="np-icon-link"></i></span>',a+='</a><a href="#" class="np-toggle-edit"><i class="np-icon-pencil"></i></a><div class="action-buttons"><a href="#" class="np-btn np-quick-edit-redirect" ',a+='data-id="'+e.post.id+'"',a+='data-parentid="'+e.post.parent_id+'"',a+='data-title="'+e.post.menuTitle+'" ',a+='data-url="'+e.post.url+'" ',a+='data-status="publish" ',a+='data-np-status="show" ',a+='data-navstatus="show" ',a+='data-navcss="'+e.post.cssClasses+'" ',a+='data-navtitleattr="'+e.post.titleAttribute+'" ',a+='data-nav-type="'+e.post.menuType+'" ',a+='data-nav-object="'+e.post.objectType+'" ',a+='data-nav-object-id="'+e.post.objectId+'" ',a+='data-nav-original-link="'+e.post.original_link+'" ',a+='data-nav-original-title="'+e.post.original_title+'" ',a+='data-linktarget="'+e.post.link_target+'">',a+=NestedPages.jsData.quickEditText,a+="</a>",a+='<a href="'+e.post.delete_link+'" class="np-btn np-btn-trash"><i class="np-icon-remove"></i></a>',a+="</div></div></div></li>","0"===e.post.parent_id?t(".nplist:first li:first").after(a):e.appendChildRow(a),t(NestedPages.selectors.linkModal).modal("hide"),e.row=t("#menuItem_"+e.post.id).find(".row"),e.formatter.flashRow(e.row)},e.appendChildRow=function(a){var s=t("#menuItem_"+e.post.parent_id);0===t(s).children("ol").length?(a='<ol class="sortable nplist" style="display:block;">'+a+"</ol>",t(s).append(a)):t(s).find("ol:first").prepend(a),e.formatter.updateSubMenuToggle()},e.toggleLoading=function(a){return a?(t(e.selectors.form).find(e.selectors.errorDiv).hide(),t(e.selectors.form).find(NestedPages.selectors.quickEditLoadingIndicator).show(),void t(e.selectors.saveButton).attr("disabled","disabled")):(t(e.selectors.form).find(NestedPages.selectors.quickEditLoadingIndicator).hide(),void t(e.selectors.saveButton).attr("disabled",!1))},e.init()};var NestedPages=NestedPages||{};NestedPages.MenuSearch=function(){var e=this,t=jQuery;return e.selectors={searchForms:"*[data-np-menu-search]",defaultResults:"[data-default-result]",loadingIndicator:".np-menu-search-loading",noResults:".np-menu-search-noresults",searchType:"data-search-type",searchObject:"data-search-object",searchResults:"[data-np-search-result]"},e.activeForm="",e.results="",e.defaultResults="",e.searchType="",e.searchObject="",e.init=function(){e.bindEvents()},e.bindEvents=function(){t(document).on("keyup",e.selectors.searchForms,function(){e.activeForm=t(this),t(e.selectors.searchResults).remove(),e.performSearch()})},e.performSearch=function(){return e.defaultResults=t(e.activeForm).parent("li").siblings(e.selectors.defaultResults),t(e.activeForm).val().length>2?(t(e.defaultResults).hide(),e.toggleLoading(!0),void e.query()):(e.toggleLoading(!1),void t(e.defaultResults).show())},e.query=function(){e.searchType=t(e.activeForm).attr(e.selectors.searchType),e.searchObject=t(e.activeForm).attr(e.selectors.searchObject),t.ajax({url:NestedPages.jsData.ajaxurl,type:"post",datatype:"json",data:{action:NestedPages.formActions.search,nonce:NestedPages.jsData.nonce,term:t(e.activeForm).val(),searchType:e.searchType,searchObject:e.searchObject},success:function(a){console.log(a),a.results?(e.results=a.results,e.toggleLoading(!1),"post_type"===e.searchType?e.appendPosts():e.appendTaxonomies()):(e.toggleLoading(!1),t(e.activeForm).siblings(e.selectors.noResults).show())}})},e.appendPosts=function(){var a="";t.each(e.results,function(t,s){a+='<li data-np-search-result><a href="#" data-np-menu-object="'+e.searchObject+'" data-np-menu-type="post_type" data-np-menu-objectid="'+s.ID+'" data-np-permalink="'+s.permalink+'" data-np-object-name="'+s.singular_name+'" data-np-menu-selection>'+s.post_title+"</a></li>"}),t(a).insertAfter(t(e.activeForm).parent("li")),e.toggleLoading(!1)},e.appendTaxonomies=function(){var a="";t.each(e.results,function(t,s){a+='<li data-np-search-result><a href="#" data-np-menu-object="'+e.searchObject+'" data-np-menu-type="post_type" data-np-menu-objectid="'+s.term_id+'" data-np-permalink="'+s.permalink+'" data-np-object-name="'+s.taxonomy+'" data-np-menu-selection>'+s.name+"</a></li>"}),t(a).insertAfter(t(e.activeForm).parent("li")),e.toggleLoading(!1)},e.toggleLoading=function(a){var s=t(e.activeForm).siblings(e.selectors.loadingIndicator);return t(e.selectors.noResults).hide(),a?void t(s).show():void t(s).hide()},e.init()},jQuery(document).ready(function(){new NestedPagesTrash});var NestedPagesTrash=function(){var e=this,t=jQuery;return e.trashButton=".np-empty-trash",e.confirmButton=".np-trash-confirm",e.warningModal="#np-trash-modal",e.errorAlert="#np-error",e.loadingIndicator="#nested-loading",e.trashLinks=".np-trash-links",e.postType=t("#np-trash-posttype").val(),e.nonce=nestedpages.np_nonce,e.formAction="npEmptyTrash",e.init=function(){e.bindEvents()},e.bindEvents=function(){t(document).on("click",e.trashButton,function(a){a.preventDefault(),t(e.warningModal).modal("show")}),t(document).on("click",e.confirmButton,function(t){t.preventDefault(),e.confirmEmpty()})},e.confirmEmpty=function(){e.loading(!0),t(e.warningModal).hide(),t(e.errorAlert).hide(),e.emptyTrash()},e.emptyTrash=function(){t.ajax({url:ajaxurl,type:"post",datatype:"json",data:{action:e.formAction,nonce:e.nonce,posttype:e.postType},success:function(a){e.loading(!1),"error"===a.status?t(e.errorAlert).text(a.message).show():t(e.trashLinks).hide()}})},e.loading=function(a){return a?void t(e.loadingIndicator).show():void t(e.loadingIndicator).hide()},e.init()};jQuery(document).ready(function(){new NestedPagesConfirmDelete});var NestedPagesConfirmDelete=function(){var e=this,t=jQuery;return e.deleteButton="[data-np-confirm-delete]",e.confirmButton="[data-delete-confirmation]",e.warningModal="#np-delete-confirmation-modal",e.deleteLink="",e.init=function(){e.bindEvents()},e.bindEvents=function(){t(document).on("click",e.deleteButton,function(a){a.preventDefault(),e.deleteLink=t(this).attr("href"),t(e.warningModal).modal("show")}),t(document).on("click",e.confirmButton,function(t){t.preventDefault(),e.confirmEmpty()})},e.confirmEmpty=function(){window.location.replace(e.deleteLink)},e.init()};
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
nestedpages.php CHANGED
@@ -3,7 +3,7 @@
3
  Plugin Name: Nested Pages
4
  Plugin URI: http://nestedpages.com
5
  Description: Provides an intuitive drag and drop interface for managing pages in the Wordpress admin, while maintaining quick edit functionality.
6
- Version: 1.5.2
7
  Author: Kyle Phillips
8
  Author URI: https://github.com/kylephillips
9
  Text Domain: nestedpages
@@ -47,6 +47,7 @@ function nestedpages_check_versions( $wp = '3.9', $php = '5.3.2' ) {
47
  }
48
 
49
  if( !class_exists('Bootstrap') ) :
 
50
  nestedpages_check_versions();
51
  require_once('vendor/autoload.php');
52
  require_once('app/NestedPages.php');
3
  Plugin Name: Nested Pages
4
  Plugin URI: http://nestedpages.com
5
  Description: Provides an intuitive drag and drop interface for managing pages in the Wordpress admin, while maintaining quick edit functionality.
6
+ Version: 1.5.3
7
  Author: Kyle Phillips
8
  Author URI: https://github.com/kylephillips
9
  Text Domain: nestedpages
47
  }
48
 
49
  if( !class_exists('Bootstrap') ) :
50
+ define('NESTEDPAGES_DIR', __FILE__);
51
  nestedpages_check_versions();
52
  require_once('vendor/autoload.php');
53
  require_once('app/NestedPages.php');
readme.txt CHANGED
@@ -4,7 +4,7 @@ Donate link: http://nestedpages.com/
4
  Tags: pages, admin, nested, tree view, page tree, sort, quick edit, structure
5
  Requires at least: 3.8
6
  Tested up to: 4.3
7
- Stable tag: 1.4.1
8
 
9
  License: GPLv2 or later
10
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
@@ -89,6 +89,12 @@ If you have WordPress SEO by Yoast installed, your page score indicators are sho
89
 
90
  == Changelog ==
91
 
 
 
 
 
 
 
92
  = 1.5.2 =
93
  * Fixed bug when upgrading in an install with sync disabled.
94
 
4
  Tags: pages, admin, nested, tree view, page tree, sort, quick edit, structure
5
  Requires at least: 3.8
6
  Tested up to: 4.3
7
+ Stable tag: 1.5.2
8
 
9
  License: GPLv2 or later
10
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
89
 
90
  == Changelog ==
91
 
92
+ = 1.5.3 =
93
+ * Confirmation modal added when deleting a link item.
94
+ * Bug fix where custom nav titles were not being saved.
95
+ * Bug fix where replacing the default menus was breaking custom admin submenu links.
96
+ * Minor interface enhancements.
97
+
98
  = 1.5.2 =
99
  * Fixed bug when upgrading in an install with sync disabled.
100