Showing
1 changed file
with
48 additions
and
29 deletions
| ... | ... | @@ -12,23 +12,11 @@ |
| 12 | 12 | 'use strict'; |
| 13 | 13 | |
| 14 | 14 | // Your code here... |
| 15 | - var MENU_DATE = { | |
| 16 | - '0': { | |
| 17 | - 'title': 'menu首页' | |
| 18 | - } | |
| 19 | - }, | |
| 20 | - TAXONOMY_DATE = { | |
| 21 | - '0': { | |
| 22 | - 'title': 'date首页' | |
| 23 | - } | |
| 24 | - }, | |
| 25 | - NODE_DATE = { | |
| 26 | - '0': { | |
| 27 | - 'title': 'node首页' | |
| 28 | - } | |
| 29 | - }, | |
| 30 | - TAXONOMY_INIT_DATE = {}, | |
| 31 | - NODE_INIT_DATE = {}; | |
| 15 | + var MENU_DATE = {}; | |
| 16 | + var TAXONOMY_DATE = {}; | |
| 17 | + var NODE_DATE = {}; | |
| 18 | + var TAXONOMY_INIT_DATE = {}; | |
| 19 | + var NODE_INIT_DATE = {}; | |
| 32 | 20 | |
| 33 | 21 | function hasStorage(name, date) { |
| 34 | 22 | if (JSON.stringify(date) === '{}') { |
| ... | ... | @@ -55,15 +43,23 @@ |
| 55 | 43 | return false; |
| 56 | 44 | }); |
| 57 | 45 | |
| 58 | - if (hasStorage('link_date', TAXONOMY_INIT_DATE)) { | |
| 59 | - var link_obj = $.parseJSON(localStorage.getItem('link_date')); | |
| 60 | - $.each(link_obj, function(index, arr) { | |
| 61 | - if (link_obj[index].taxonomy == settingObj.title) { | |
| 62 | - settingObj.url = link_obj[index].url; | |
| 63 | - delete link_obj[index]; | |
| 64 | - } | |
| 65 | - }); | |
| 66 | - } | |
| 46 | + var toxonomy_link_obj = $.parseJSON(localStorage.getItem('toxonomy_link_date')); | |
| 47 | + var node_link_obj = $.parseJSON(localStorage.getItem('node_link_date')); | |
| 48 | + | |
| 49 | + $.each(toxonomy_link_obj, function(index, arr) { | |
| 50 | + if (toxonomy_link_obj[index].taxonomy == settingObj.title) { | |
| 51 | + settingObj.url = toxonomy_link_obj[index].url; | |
| 52 | + delete toxonomy_link_obj[index]; | |
| 53 | + } | |
| 54 | + }); | |
| 55 | + | |
| 56 | + $.each(node_link_obj, function(index, arr) { | |
| 57 | + if (node_link_obj[index].node == settingObj.title) { | |
| 58 | + settingObj.nid = node_link_obj[index].url; | |
| 59 | + delete node_link_obj[index]; | |
| 60 | + } | |
| 61 | + }); | |
| 62 | + | |
| 67 | 63 | |
| 68 | 64 | return settingObj; |
| 69 | 65 | } |
| ... | ... | @@ -72,6 +68,27 @@ |
| 72 | 68 | hasStorage('toxonomy_link_date', TAXONOMY_INIT_DATE); |
| 73 | 69 | hasStorage('node_link_date', NODE_INIT_DATE); |
| 74 | 70 | |
| 71 | + if ($('#taxonomy .menu-item__link').length > 0) { | |
| 72 | + $('#taxonomy .menu-item__link').each(function(index) { | |
| 73 | + TAXONOMY_INIT_DATE[index] = { | |
| 74 | + 'taxonomy': $(this).text(), | |
| 75 | + 'url': /[0-9]*$/.exec($(this).attr('href'))[0] | |
| 76 | + }; | |
| 77 | + }); | |
| 78 | + localStorage.setItem('toxonomy_link_date', JSON.stringify(TAXONOMY_INIT_DATE)); | |
| 79 | + } | |
| 80 | + | |
| 81 | + if ($('.view-id-manage_page').length > 0) { | |
| 82 | + $('.footable tbody tr').each(function(index) { | |
| 83 | + NODE_INIT_DATE[index] = { | |
| 84 | + 'node': $(this).find('.views-field-title a').text(), | |
| 85 | + 'url': $(this).find('.views-field-nid').text().trim(), | |
| 86 | + }; | |
| 87 | + }); | |
| 88 | + localStorage.setItem('node_link_date', JSON.stringify(NODE_INIT_DATE)); | |
| 89 | + } | |
| 90 | + | |
| 91 | + | |
| 75 | 92 | if ($('[data-drupal-link-system-path="manage/department/add"]').length > 0) { |
| 76 | 93 | $('[data-drupal-link-system-path="manage/department/add"]')[0].click(); |
| 77 | 94 | } |
| ... | ... | @@ -91,7 +108,7 @@ |
| 91 | 108 | $('#edit-name-0-value').val(settingObj.title); |
| 92 | 109 | if (settingObj.hasOwnProperty('parent')) { |
| 93 | 110 | $('#edit-parent option').each(function() { |
| 94 | - if ($(this).text() == settingObj.parent) { | |
| 111 | + if ($(this).text().indexOf(settingObj.parent)) { | |
| 95 | 112 | $('#edit-parent option').attr('selected', false); |
| 96 | 113 | $(this).attr('selected', true); |
| 97 | 114 | } |
| ... | ... | @@ -104,8 +121,8 @@ |
| 104 | 121 | //基本页 |
| 105 | 122 | if ($('.node-page-form #edit-title-0-value').length > 0 && hasStorage('node_date', NODE_DATE)) { |
| 106 | 123 | var NodesettingObj = storageOper('node_date', $.parseJSON(localStorage.getItem('node_date'))); |
| 107 | - $('##edit-title-0-value').val(NodesettingObj.title); | |
| 108 | - $('#edit-submit').trigger('click'); | |
| 124 | + $('#edit-title-0-value').val(NodesettingObj.title); | |
| 125 | + $('#edit-moderation-state-published').trigger('click'); | |
| 109 | 126 | } |
| 110 | 127 | //菜单 |
| 111 | 128 | if ($('#edit-title-0-value').length > 0 && $('#edit-link-0-uri').length > 0 && hasStorage('menu_date', MENU_DATE) && ((JSON.stringify(localStorage.getItem('toxonomy_link_date')) !== '{}') || (JSON.stringify(localStorage.getItem('node_link_date')) !== '{}'))) { |
| ... | ... | @@ -126,6 +143,8 @@ |
| 126 | 143 | |
| 127 | 144 | if (MenusettingObj.hasOwnProperty('url')) { |
| 128 | 145 | $('#edit-link-0-uri').val('/taxonomy/term/' + MenusettingObj.url); |
| 146 | + } else if (MenusettingObj.hasOwnProperty('nid')) { | |
| 147 | + $('#edit-link-0-uri').val('/basic/' + MenusettingObj.nid); | |
| 129 | 148 | } else { |
| 130 | 149 | $('#edit-link-0-uri').val('/'); |
| 131 | 150 | } | ... | ... |
Please
register
or
login
to post a comment